diff --git a/packages/designer/src/components/components/view-model-designer/method-manager/components/method-list/method-list.component.tsx b/packages/designer/src/components/components/view-model-designer/method-manager/components/method-list/method-list.component.tsx index 1b733125a26724638bdac3fdca5fd2dcfc8fc33f..8b1d00de0f57271c79ac92cec904b6663b41831b 100644 --- a/packages/designer/src/components/components/view-model-designer/method-manager/components/method-list/method-list.component.tsx +++ b/packages/designer/src/components/components/view-model-designer/method-manager/components/method-list/method-list.component.tsx @@ -116,7 +116,8 @@ export default defineComponent({ refreshMethodList, selectedTreeNode, isCommandNodeSelected, - isValidCommandSelected + isValidCommandSelected, + updateViewModel }); /** diff --git a/packages/designer/src/components/components/view-model-designer/method-manager/entity/param.ts b/packages/designer/src/components/components/view-model-designer/method-manager/entity/param.ts index c6356df441a0153201029dcd1e9ab0a8ef311a32..2ed6b79c22e20ade67e058a8e6572cf08d73fa56 100644 --- a/packages/designer/src/components/components/view-model-designer/method-manager/entity/param.ts +++ b/packages/designer/src/components/components/view-model-designer/method-manager/entity/param.ts @@ -47,7 +47,10 @@ export class ParamConfig { if (this.defaultValue !== undefined) { param.defaultValue = this.defaultValue; } - + // 参数里增加类型,这样获取参数时能带type属性 + if (this.type && this.type !== 'string') { + param.type = this.type; + } return param; } } diff --git a/packages/designer/src/components/components/view-model-designer/method-manager/method-manager.component.tsx b/packages/designer/src/components/components/view-model-designer/method-manager/method-manager.component.tsx index 42a0ef92874b4e8e6affe649cffe8f2e6c3ce876..d37bb0f6d54c1ee661e3cc20a1cc90d28526f1f2 100644 --- a/packages/designer/src/components/components/view-model-designer/method-manager/method-manager.component.tsx +++ b/packages/designer/src/components/components/view-model-designer/method-manager/method-manager.component.tsx @@ -48,6 +48,8 @@ export default defineComponent({ methodBuilderComposition.build(activeViewModel.value?.commands || []).then(commands => { commandsTreeData.value = commands || []; methodListRef.value.refreshMethodList(commandsTreeData.value, activeViewModel.value); + // 更新ViewModel中命令 + methodListRef.value.updateViewModel(commandsTreeData.value); loadingInstance.value.close(); }); } diff --git a/packages/designer/src/components/composition/command.service.ts b/packages/designer/src/components/composition/command.service.ts index e39f0b7ac15300d60c7f4f505bdee0cd8bcf2302..35aa7cbb13027f8c87496daa5f3e7534dad1529e 100644 --- a/packages/designer/src/components/composition/command.service.ts +++ b/packages/designer/src/components/composition/command.service.ts @@ -12,6 +12,8 @@ import { IdService } from "../components/view-model-designer/method-manager/serv import { useParameterEditorData } from "./use-parameter-editor-data"; import { useEventParameterData } from "./use-event-parameter-data"; import { getSupportedControllerMethods } from "./command/supported-controller"; +import { Command } from "../components/view-model-designer/method-manager/entity/command"; +import { ParamConfig } from "../components/view-model-designer/method-manager/entity/param"; export function useFormCommandService(formSchemaService: UseFormSchema, useFormStateMachineComposition: UseFormStateMachine, loadingService: FLoadingService, webCmpBuilderService: UseCommandBuilderService): UseFormCommandService { const metadataService = new MetadataService(); @@ -81,6 +83,7 @@ export function useFormCommandService(formSchemaService: UseFormSchema, useFormS commands = cloneDeep(webCmds); generateInternalCommandList(); checkViewModelCommands(webCmds); + updateViewModels(webCmds); syncActions(); // loadingInstance.value.close(); resolve([]); @@ -278,7 +281,7 @@ export function useFormCommandService(formSchemaService: UseFormSchema, useFormS window['suspendChangesOnForm'] = true; formSchemaService.getViewModels().forEach(viewModel => { - if (!viewModel.commands) { + if (!viewModel.commands || viewModel.commands.length === 0) { return; } viewModel.commands.map(curCmd => { @@ -306,11 +309,47 @@ export function useFormCommandService(formSchemaService: UseFormSchema, useFormS curCmd.isInvalid = true; } }); - }); window['suspendChangesOnForm'] = false; } + /** + * 将变更同步到表单DOM中,主要处理新命令参数没有填写,也不会带着type类型的问题 + * @param commands 命令列表 + */ + function updateViewModels(webCmds) { + formSchemaService.getViewModels().forEach(viewModel => { + if (!viewModel.commands || viewModel.commands.length === 0) { + return; + } + viewModel.commands.map(curCommand => { + const webCmd = webCmds.find(item => item.Id === curCommand.cmpId); + // 不可用或者已有参数,不需要特殊处理 + if (curCommand.isInvalid || !curCommand.params || curCommand.params.length>0) { + return; + } + const commandInWebCmd = webCmd.Commands.find(commandItem => commandItem.Code === curCommand.handlerName); + if (commandInWebCmd) { + // 将表单中记录的参数名称更新为控制器中的参数名称 + if (commandInWebCmd.Parameters && commandInWebCmd.Parameters.length) { + curCommand.params = commandInWebCmd.Parameters.reduce((result: ParamConfig[], parameter: any) => { + const param = new ParamConfig(); + param.name = parameter.Code; + param.shownName = parameter.Name; + param.type = parameter.ParameterType; + param.EditorType = parameter && parameter.EditorType ? parameter.EditorType : null; + param.value = ''; + param.description = parameter.Description; + param.controlSource = parameter.controlSource; + param.defaultValue = parameter.defaultValue; + result.push(param.toJson()); + return result; + }, []); + } + } + }); + }); + } /** 4.渲染表单取出所有的已绑定事件,同步至actions节点 */ function syncActions() { diff --git a/packages/ui-vue/components/tabs/src/designer/tab-page-use-designer-rules.ts b/packages/ui-vue/components/tabs/src/designer/tab-page-use-designer-rules.ts index 132f201dc03e67bd53b87d69fea99be03317da1b..739e7fd8a0528edddd4fddf90d0eac1bf0c64ebd 100644 --- a/packages/ui-vue/components/tabs/src/designer/tab-page-use-designer-rules.ts +++ b/packages/ui-vue/components/tabs/src/designer/tab-page-use-designer-rules.ts @@ -25,7 +25,16 @@ export function useDesignerRules(designItemContext: DesignerItemContext, designe /** 选中标签页内容区后,避免向上选中父容器 */ function getDraggableDesignItemElement(context: DesignerItemContext) { - return null; + return null; } - return { canAccepts, getDraggableDesignItemElement }; + /** + * 组件删除后事件,如果父元素设置了以此元素为activeId就重置为空 + */ + function onRemoveComponent() { + const { schema, parent } = designItemContext; + if (parent?.schema.activeId&&schema.id === parent.schema.activeId){ + parent.schema.activeId=""; + } + } + return { canAccepts, getDraggableDesignItemElement, onRemoveComponent }; } diff --git a/packages/ui-vue/components/tabs/src/property-config/tabs.property-config.ts b/packages/ui-vue/components/tabs/src/property-config/tabs.property-config.ts index 10d7be32425b9774dd829d5809b2259d4d3ae6e7..260c553cfe818c4d89e9903544bcca22d2322d48 100644 --- a/packages/ui-vue/components/tabs/src/property-config/tabs.property-config.ts +++ b/packages/ui-vue/components/tabs/src/property-config/tabs.property-config.ts @@ -56,6 +56,7 @@ export class TabsProperty extends BaseControlProperty { // 有些标签页被删除,但是默认值还是原标签页 const foundItem = tabPages.find(tabItem => tabItem.id === propertyData.activeId); if (!foundItem) { + // 此处的重置更改不了activeId获取时的值 propertyData.activeId = ""; } }