From 044a921c23fb10ab3bc58ca40af1fb27f4665aef Mon Sep 17 00:00:00 2001 From: jiweitao1986 Date: Sat, 13 Sep 2025 15:53:44 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feature:=20=E5=BC=80=E5=8F=91=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E6=8F=90=E4=BE=9B=E6=89=93=E5=BC=80=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E5=B8=AE=E5=8A=A9=E5=92=8C=E6=89=B9=E9=87=8F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/batch-edit.service.ts | 139 ++++++++++++++++-- .../command-services/lib/dialog.service.ts | 6 +- packages/command-services/lib/utils/index.ts | 1 + .../lib/utils/json-object-util.ts | 123 ++++++++++++++++ .../pc-supported-controller.json | 8 + 5 files changed, 265 insertions(+), 12 deletions(-) create mode 100644 packages/command-services/lib/utils/index.ts create mode 100644 packages/command-services/lib/utils/json-object-util.ts diff --git a/packages/command-services/lib/batch-edit.service.ts b/packages/command-services/lib/batch-edit.service.ts index c7c1b2644..a1c24820d 100644 --- a/packages/command-services/lib/batch-edit.service.ts +++ b/packages/command-services/lib/batch-edit.service.ts @@ -1,15 +1,50 @@ -import { EntityFieldSchema, EntityListFieldSchema, EntitySchema, FieldSchema, FieldType, ViewModel, ViewModelState } from "@farris/devkit-vue"; -import { FormNotifyService } from "./form-notify.service"; -import { BefRepository } from "@farris/bef-vue"; -import { LocaleService } from "./locale"; - +import { EntityFieldSchema, Entity, FieldSchema, FieldType, EntityState, EntityStore, ViewModel, ViewModelState } from '@farris/devkit-vue'; +import { BefRepository } from '@farris/bef-vue'; +import { LocaleService } from './locale'; +import { JSONObjectUtil } from './utils/index'; +import { BaseDataService } from './data-services'; +import { FormNotifyService } from './form-notify.service'; +import { FormLoadingService } from './form-loading.service'; +import { DialogService } from './dialog.service'; + +/** + * 批量编辑服务 + */ export class BatchEditService { + + + /** + * 数据仓库 + */ + protected repository: BefRepository; + + /** + * 实体状态 + */ + protected entityStore: EntityStore>; + + /** + * 构造函数 + * @param viewModel 视图模型 + * @param formNotifyService 通知服务 + */ constructor( private viewModel: ViewModel, - private formNotifyService: FormNotifyService - ) { } + private formNotifyService: FormNotifyService, + private formLoadingService: FormLoadingService, + private dialogService: DialogService + ) { + this.repository = viewModel.repository as BefRepository; + this.entityStore = viewModel.entityStore as EntityStore>; + } - public openHiddenHelp(helpId: string) { } + /** + * 打开隐藏帮助 + * @param helpId 隐藏帮助ID + */ + public openHiddenHelp(helpId: string): void { + this.dialogService.openLookup(null, helpId); + } public beforeMultiSelectHelpOpen() { } @@ -85,7 +120,21 @@ export class BatchEditService { public checkCurrentRow() { } - public batchAppend() { } + /** + * 批量追加主表数据(基于帮助选中数据) + * @summary + * 该方法仅适用于处理帮助后事件 + */ + public batchAppend(frameId: string, mapFields: string): Promise | undefined { + const lookupSelectedItems = this.getLookupSelectedItems(); + const lookupMappingFields = this.formatLookupMappings(mapFields); + if (!lookupSelectedItems || !lookupMappingFields) { + return; + } + + const defaultValues = this.buildBatchDefaultValues(lookupSelectedItems, lookupMappingFields); + return this.batchAppendEntites(defaultValues); + } public clone(id: string, path: string) { } @@ -129,4 +178,76 @@ export class BatchEditService { return entitySchema.entitySchema.getFieldSchemasByType(FieldType.EntityList); } } + + /** + * 获取帮助选中数据 + */ + private getLookupSelectedItems(): any[] | null { + const context = (this as any)['context'] as any; + if (!context || !context.command || !context.command.eventParams || + !context.command.eventParams.payload || !context.command.eventParams.payload.items) { + throw new Error('The selected items cannot be found in the context.'); + } + return context.command.eventParams.payload.items; + } + + /** + * 格式化帮助字段映射 + */ + private formatLookupMappings(mappingFieldsStr: string): any[] | null { + if (!mappingFieldsStr) { + return null; + } + const mappingFieldsObj = JSON.parse(mappingFieldsStr); + + const formattedMappingFields: any[] = []; + Object.keys(mappingFieldsObj).forEach((key: string) => { + const srcFieldPath = key; + const targetFieldPath = mappingFieldsObj[key]; + if (!srcFieldPath || !targetFieldPath) { + return; + } + const targetFieldPaths = targetFieldPath.split(','); + formattedMappingFields.push({ + srcFieldPath, + targetFieldPaths + }); + }); + + return formattedMappingFields; + } + + /** + * 构造批量新增数据的默认值 + */ + private buildBatchDefaultValues(lookupSelectedItems: any[], lookupMappingFields: any[]): any[] { + const defaultValueItems: any[] = []; + lookupSelectedItems.forEach((lookupSelectedItem) => { + const defaultValueItem = {}; + lookupMappingFields.forEach((lookupMappingField) => { + const { srcFieldPath, targetFieldPaths } = lookupMappingField; + const srcFieldValue = JSONObjectUtil.getValueByPath(lookupSelectedItem, srcFieldPath); + targetFieldPaths.forEach((targetFieldPath: string) => { + JSONObjectUtil.setValueByPath(defaultValueItem, targetFieldPath, srcFieldValue, true); + }) + }); + defaultValueItems.push(defaultValueItem); + }) + + return defaultValueItems; + } + + /** + * 批量追加实体 + */ + private batchAppendEntites(defaultValues: any): Promise { + const timerId = this.formLoadingService.showLoadingWithDelay(); + const appendPromise = this.repository.createEntities(defaultValues).then((entities: Entity[]) => { + this.entityStore.appendEntities(entities); + return entities; + }).finally(() => { + this.formLoadingService.hideDelayLoading(timerId); + }); + return appendPromise; + } } diff --git a/packages/command-services/lib/dialog.service.ts b/packages/command-services/lib/dialog.service.ts index 149d031b9..1e5f98054 100644 --- a/packages/command-services/lib/dialog.service.ts +++ b/packages/command-services/lib/dialog.service.ts @@ -86,7 +86,7 @@ export class DialogService { /** * 根据ID打开帮助 */ - public openLookup(config: string | LookupConfig, lookupId: string) { + public openLookup(config: string | LookupConfig | null, lookupId: string): void { const lookupInstance = this.renderEngineService.getComponentInstance(lookupId); // 设置帮助配置 @@ -161,7 +161,7 @@ export class DialogService { /** * 构造帮助属性 */ - private buildLookupProps(config: LookupConfig | string, instanceDialogConfig: any) { + private buildLookupProps(config: LookupConfig | string | null, instanceDialogConfig: any) { const dialogConfig = this.normalizeConfig(config); if (!dialogConfig) { return null; @@ -191,7 +191,7 @@ export class DialogService { /** * 标准化对象 */ - private normalizeConfig(config: string | ModalConfig): ModalConfig | null { + private normalizeConfig(config: string | ModalConfig | null): ModalConfig | null { if (!config) { return null; } diff --git a/packages/command-services/lib/utils/index.ts b/packages/command-services/lib/utils/index.ts new file mode 100644 index 000000000..24cbcf376 --- /dev/null +++ b/packages/command-services/lib/utils/index.ts @@ -0,0 +1 @@ +export * from './json-object-util'; \ No newline at end of file diff --git a/packages/command-services/lib/utils/json-object-util.ts b/packages/command-services/lib/utils/json-object-util.ts new file mode 100644 index 000000000..4886d7cee --- /dev/null +++ b/packages/command-services/lib/utils/json-object-util.ts @@ -0,0 +1,123 @@ + +/** + * JSON对象工具类 + */ +class JSONObjectUtil { + + /** + * 根据path为属性赋值 + * @summary + * 父节点不存在时支持自动创建,父节点存在但不是对象时抛出异常 + */ + public static setValueByPath(jsonObj: any, path: string, value: any, autoCreateParent: boolean): void { + if (!jsonObj) { + throw new Error('The jsonObj parameter can not be empty'); + } + + const propNames = this.getPropNames(path); + if (propNames.length === 0) { + throw new Error('The path parameter can not be empty'); + } + + let currentParent: Record = jsonObj; + for (let propIndex = 0; propIndex < propNames.length; propIndex++) { + const propName = propNames[propIndex]; + const isLastPropName = propIndex === propNames.length - 1; + if (isLastPropName) { + currentParent[propName] = value; + break; + } + + // 父节点不存在:创建或报错 + if (!Object.prototype.hasOwnProperty.call(currentParent, propName)) { + if (autoCreateParent) { + currentParent[propName] = {}; + } else { + throw new Error(`The parent(propName=${propName}) node does not exist`); + } + } + + // 父节点存在但不是对象:直接报错 + const nextParent = currentParent[propName]; + if (nextParent === null || typeof nextParent !== 'object') { + throw new Error(`The parent(propName=${propName}) node must be an object`); + } + + // 父节点符合要求 + currentParent = nextParent; + }; + } + + /** + * 根据Path获取属性值 + * @summary + * 父节点不存在返回undefined + */ + public static getValueByPath(jsonObj: any, path: string): any { + if (jsonObj === null || typeof jsonObj !== 'object') { + throw new Error(`The jsonObj parameter must be an object`);; + } + + // path为空返回根对象 + const propNames = this.getPropNames(path); + if (propNames.length === 0) { + return jsonObj; + } + + // 逐层获取目标属性值 + let currentParent: any = jsonObj; + let targetPropValue = undefined; + for (let propIndex = 0; propIndex < propNames.length; propIndex++) { + const propName = propNames[propIndex]; + if (!Object.prototype.hasOwnProperty.call(currentParent, propName)) { + targetPropValue = undefined; + break; + } + + const isLastPropName = propIndex === propNames.length - 1; + if (isLastPropName) { + targetPropValue = currentParent[propName]; + break; + } else { + const nextParent = currentParent[propName]; + if (nextParent === null || typeof nextParent !== 'object') { + targetPropValue = undefined; + break; + } + currentParent = nextParent; + } + }; + + return targetPropValue; + } + + /** + * 获取字段路径片段 + * @param path 属性路径,形如:propName1.propName2.propName3 + */ + public static getPropNames(path: string): string[] { + if (typeof path !== 'string') { + throw new Error('The path parameter must be a string'); + } + + // 空path视为根路径 + if (path === '') { + return []; + } + + // 分割path + const pathSegs = path.split('.'); + const emptyPathSeg = pathSegs.find((pathSeg) => { + return !pathSeg; + }); + + // path中的属性名不允许为空 + if (emptyPathSeg) { + throw new Error('The property name in the path can not be empty'); + } + + return pathSegs; + } +} + +export { JSONObjectUtil }; diff --git a/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json b/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json index 0741fe0ee..def05c7f8 100644 --- a/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json +++ b/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json @@ -519,6 +519,14 @@ { "id": "d5f67e0a-767d-a238-5ad4-b1285476c16f", "code": "copyRow" + }, + { + "id": "461bf7f7-7383-f30f-1eed-66df1f8f7891", + "code": "openHiddenHelp" + }, + { + "id": "b7823f2a-5bc8-9292-d49f-0660d37f2863", + "code": "batchAppend" } ], "3f40288a-d11e-4dbd-89ba-388abf931ca3": [ -- Gitee From 9552e350ba7a6e948c13ba35958e1db9bd4767af Mon Sep 17 00:00:00 2001 From: jiweitao1986 Date: Mon, 15 Sep 2025 11:02:24 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E3=80=90=E6=89=93=E5=BC=80=E9=9A=90=E8=97=8F=E5=B8=AE?= =?UTF-8?q?=E5=8A=A9=E3=80=91=E5=91=BD=E4=BB=A4=E5=8F=82=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../composition/use-event-parameter-data.ts | 30 +++++++++++++++---- .../components/composition/use-form-schema.ts | 11 ++++++- .../designer/src/components/types/metadata.ts | 1 + 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/packages/designer/src/components/composition/use-event-parameter-data.ts b/packages/designer/src/components/composition/use-event-parameter-data.ts index e240395fa..616216b4f 100644 --- a/packages/designer/src/components/composition/use-event-parameter-data.ts +++ b/packages/designer/src/components/composition/use-event-parameter-data.ts @@ -5,10 +5,10 @@ export function useEventParameterData( useFormSchemaComposition: UseFormSchema, useFormStateMachineComposition: UseFormStateMachine) { /** - * 获取重组的actions - * @param actions - * @returns - */ + * 获取重组的actions + * @param actions + * @returns + */ function getActionsChanged(actions: any) { const result: any = []; if (actions && Object.keys(actions).length > 0) { @@ -158,14 +158,32 @@ export function useEventParameterData( return result; } - function getEventParameterData(dataValue: string) { - let data = null; + /** + * 构造隐藏帮助下拉列表数据 + */ + function buildHiddenLookups() { + const externalComponents = useFormSchemaComposition.getExternalComponents(); + const result: any[] = []; + externalComponents.forEach((externalComponent) => { + if (externalComponent.type === 'lookup') { + const lookupItem = { id: externalComponent.id, label: externalComponent.name }; + result.push(lookupItem); + } + }); + + return result; + } + + function getEventParameterData(dataValue: string): any[] | null { + let data: any[] | null = null; if (dataValue === ':Actions') { data = buildActions(); } else if (dataValue === ':Components') { data = buildComponents(); } else if (dataValue === ':CommandsTree') { data = buildCommands(); + } else if (dataValue === ':HiddenLookups') { + data = buildHiddenLookups(); } return data; } diff --git a/packages/designer/src/components/composition/use-form-schema.ts b/packages/designer/src/components/composition/use-form-schema.ts index 47c631d8f..8eed093d4 100644 --- a/packages/designer/src/components/composition/use-form-schema.ts +++ b/packages/designer/src/components/composition/use-form-schema.ts @@ -1266,6 +1266,14 @@ export function useFormSchema(): UseFormSchema { }); } } + + /** + * 获取外部组件集合 + */ + function getExternalComponents(): any[] { + return formSchema?.module?.externalComponents || []; + } + return { getModule, setViewmodels, @@ -1310,6 +1318,7 @@ export function useFormSchema(): UseFormSchema { getComponetsByPredicate, getDefaultValueByFiledAndType, designerMode, - removeCommunicationInComponent + removeCommunicationInComponent, + getExternalComponents }; } diff --git a/packages/designer/src/components/types/metadata.ts b/packages/designer/src/components/types/metadata.ts index 3b09c0214..23d41be9f 100644 --- a/packages/designer/src/components/types/metadata.ts +++ b/packages/designer/src/components/types/metadata.ts @@ -251,6 +251,7 @@ export interface UseFormSchema { getComponetsByPredicate(predicate: (component: any) => boolean); removeCommunicationInComponent: (componentSchema: any) => void; externalFormSchema: Map; + getExternalComponents: () => any[]; } export interface UseSchemaService { -- Gitee From edf590e3b921c8c0976aa7d9e63bd6bc3dfff828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E7=BB=B4=E6=B6=9B?= Date: Mon, 15 Sep 2025 02:38:55 +0000 Subject: [PATCH 3/6] =?UTF-8?q?feature:=20=E6=89=B9=E9=87=8F=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=9C=8D=E5=8A=A1=E6=8F=90=E4=BE=9B=E6=89=93=E5=BC=80?= =?UTF-8?q?=E5=B8=AE=E5=8A=A9=E5=92=8C=E6=89=B9=E9=87=8F=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/command-services/lib/batch-edit.service.ts | 9 +++++++-- packages/command-services/lib/locale/locales/en.json | 1 + packages/command-services/lib/locale/locales/zh-CHS.json | 1 + packages/command-services/lib/locale/locales/zh-CHT.json | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/command-services/lib/batch-edit.service.ts b/packages/command-services/lib/batch-edit.service.ts index a1c24820d..60a6f0585 100644 --- a/packages/command-services/lib/batch-edit.service.ts +++ b/packages/command-services/lib/batch-edit.service.ts @@ -126,9 +126,14 @@ export class BatchEditService { * 该方法仅适用于处理帮助后事件 */ public batchAppend(frameId: string, mapFields: string): Promise | undefined { - const lookupSelectedItems = this.getLookupSelectedItems(); const lookupMappingFields = this.formatLookupMappings(mapFields); - if (!lookupSelectedItems || !lookupMappingFields) { + if (!lookupMappingFields) { + throw new Error('The parameter mapFields can not be empty'); + } + + const lookupSelectedItems = this.getLookupSelectedItems(); + if (!Array.isArray(lookupSelectedItems) || lookupSelectedItems.length === 0) { + this.formNotifyService.warning(LocaleService.translate('pleaseSelectReferenceData')); return; } diff --git a/packages/command-services/lib/locale/locales/en.json b/packages/command-services/lib/locale/locales/en.json index 51a2bb2f2..b911e74d7 100644 --- a/packages/command-services/lib/locale/locales/en.json +++ b/packages/command-services/lib/locale/locales/en.json @@ -18,6 +18,7 @@ "pleaseSelectDetailFormData": "Please select a detail form data first.", "pleaseSelectEditData": "Please select the data you want to edit.", "pleaseSelectViewData": "Please select the data you want to view.", + "pleaseSelectReferenceData": "Please select the data you want to reference.", "hasChangeCheckFaild": "An error occurred while checking the page for unsaved changes! Please make sure the data has been saved. Do you want to continue closing?", "pleaseSelectCopyData": "Please select the data you want to copy.", "unallowEmptyBizBillId": "Please select the data you want to print.", diff --git a/packages/command-services/lib/locale/locales/zh-CHS.json b/packages/command-services/lib/locale/locales/zh-CHS.json index 5476841d7..e30e469c1 100644 --- a/packages/command-services/lib/locale/locales/zh-CHS.json +++ b/packages/command-services/lib/locale/locales/zh-CHS.json @@ -18,6 +18,7 @@ "pleaseSelectDetailFormData": "请先选择一条从表数据!", "pleaseSelectEditData": "请选择要编辑的数据!", "pleaseSelectViewData": "请选择要查看的数据!", + "pleaseSelectReferenceData": "请选择要参照的数据!", "hasChangeCheckFaild": "在检查页面是否存在未保存的变更时发生错误!请确保数据已经保存。是否继续关闭?", "pleaseSelectCopyData": "请选择要复制的数据!", "unallowEmptyBizBillId": "请选择要打印的数据!", diff --git a/packages/command-services/lib/locale/locales/zh-CHT.json b/packages/command-services/lib/locale/locales/zh-CHT.json index 8f049c184..3a7884ef6 100644 --- a/packages/command-services/lib/locale/locales/zh-CHT.json +++ b/packages/command-services/lib/locale/locales/zh-CHT.json @@ -18,6 +18,7 @@ "pleaseSelectDetailFormData": "請先選擇一條從表數據!", "pleaseSelectEditData": "請選擇要編輯的數據!", "pleaseSelectViewData": "請選擇要查看的數據!", + "pleaseSelectReferenceData": "請選擇要參照的數據!", "hasChangeCheckFaild": "在檢查頁面是否存在未保存的變更時發生錯誤!請確保數據已經保存。是否繼續關閉?", "pleaseSelectCopyData": "請選擇要復制的數據!", "unallowEmptyBizBillId": "請選擇要打印的數據!", -- Gitee From 6a21d0dc8f4c4b09c335ca20e001b0f6b7430775 Mon Sep 17 00:00:00 2001 From: jiweitao1986 Date: Tue, 23 Sep 2025 14:06:31 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feature:=201=E3=80=81=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E5=B8=AE=E5=8A=A9=E6=95=B0=E6=8D=AE=E5=BC=95=E7=94=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=EF=BC=9B2=E3=80=81=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E5=B8=AE=E5=8A=A9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BC=95=E7=94=A8=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/batch-edit.service.ts | 98 +----------- .../lib/data-services/create-data.service.ts | 66 +++++++- .../command-services/lib/dialog.service.ts | 72 ++++++--- packages/command-services/lib/index.ts | 1 + .../lib/lookup-data-reference.service.ts | 146 ++++++++++++++++++ packages/command-services/lib/providers.ts | 13 +- .../lib/utils/entity-path-util.ts | 28 ++++ packages/command-services/lib/utils/index.ts | 4 +- .../command-services/lib/utils/lookup-util.ts | 49 ++++++ .../pc-supported-controller.json | 14 +- .../controller/pc-categories.ts | 2 +- 11 files changed, 360 insertions(+), 133 deletions(-) create mode 100644 packages/command-services/lib/lookup-data-reference.service.ts create mode 100644 packages/command-services/lib/utils/entity-path-util.ts create mode 100644 packages/command-services/lib/utils/lookup-util.ts diff --git a/packages/command-services/lib/batch-edit.service.ts b/packages/command-services/lib/batch-edit.service.ts index 60a6f0585..58bc7fc42 100644 --- a/packages/command-services/lib/batch-edit.service.ts +++ b/packages/command-services/lib/batch-edit.service.ts @@ -1,11 +1,10 @@ import { EntityFieldSchema, Entity, FieldSchema, FieldType, EntityState, EntityStore, ViewModel, ViewModelState } from '@farris/devkit-vue'; import { BefRepository } from '@farris/bef-vue'; import { LocaleService } from './locale'; -import { JSONObjectUtil } from './utils/index'; -import { BaseDataService } from './data-services'; import { FormNotifyService } from './form-notify.service'; import { FormLoadingService } from './form-loading.service'; import { DialogService } from './dialog.service'; +import { LookupDataReferenceService } from './lookup-data-reference.service'; /** * 批量编辑服务 @@ -32,7 +31,8 @@ export class BatchEditService { private viewModel: ViewModel, private formNotifyService: FormNotifyService, private formLoadingService: FormLoadingService, - private dialogService: DialogService + private dialogService: DialogService, + private lookupDataReferenceService: LookupDataReferenceService ) { this.repository = viewModel.repository as BefRepository; this.entityStore = viewModel.entityStore as EntityStore>; @@ -121,24 +121,12 @@ export class BatchEditService { public checkCurrentRow() { } /** - * 批量追加主表数据(基于帮助选中数据) - * @summary - * 该方法仅适用于处理帮助后事件 + * 帮助后批量追加主表数据(已废弃) + * @deprecated */ public batchAppend(frameId: string, mapFields: string): Promise | undefined { - const lookupMappingFields = this.formatLookupMappings(mapFields); - if (!lookupMappingFields) { - throw new Error('The parameter mapFields can not be empty'); - } - - const lookupSelectedItems = this.getLookupSelectedItems(); - if (!Array.isArray(lookupSelectedItems) || lookupSelectedItems.length === 0) { - this.formNotifyService.warning(LocaleService.translate('pleaseSelectReferenceData')); - return; - } - - const defaultValues = this.buildBatchDefaultValues(lookupSelectedItems, lookupMappingFields); - return this.batchAppendEntites(defaultValues); + const dictPickedContext = (this as any).context; + return this.lookupDataReferenceService.batchAppendByContext(dictPickedContext, mapFields); } public clone(id: string, path: string) { } @@ -183,76 +171,4 @@ export class BatchEditService { return entitySchema.entitySchema.getFieldSchemasByType(FieldType.EntityList); } } - - /** - * 获取帮助选中数据 - */ - private getLookupSelectedItems(): any[] | null { - const context = (this as any)['context'] as any; - if (!context || !context.command || !context.command.eventParams || - !context.command.eventParams.payload || !context.command.eventParams.payload.items) { - throw new Error('The selected items cannot be found in the context.'); - } - return context.command.eventParams.payload.items; - } - - /** - * 格式化帮助字段映射 - */ - private formatLookupMappings(mappingFieldsStr: string): any[] | null { - if (!mappingFieldsStr) { - return null; - } - const mappingFieldsObj = JSON.parse(mappingFieldsStr); - - const formattedMappingFields: any[] = []; - Object.keys(mappingFieldsObj).forEach((key: string) => { - const srcFieldPath = key; - const targetFieldPath = mappingFieldsObj[key]; - if (!srcFieldPath || !targetFieldPath) { - return; - } - const targetFieldPaths = targetFieldPath.split(','); - formattedMappingFields.push({ - srcFieldPath, - targetFieldPaths - }); - }); - - return formattedMappingFields; - } - - /** - * 构造批量新增数据的默认值 - */ - private buildBatchDefaultValues(lookupSelectedItems: any[], lookupMappingFields: any[]): any[] { - const defaultValueItems: any[] = []; - lookupSelectedItems.forEach((lookupSelectedItem) => { - const defaultValueItem = {}; - lookupMappingFields.forEach((lookupMappingField) => { - const { srcFieldPath, targetFieldPaths } = lookupMappingField; - const srcFieldValue = JSONObjectUtil.getValueByPath(lookupSelectedItem, srcFieldPath); - targetFieldPaths.forEach((targetFieldPath: string) => { - JSONObjectUtil.setValueByPath(defaultValueItem, targetFieldPath, srcFieldValue, true); - }) - }); - defaultValueItems.push(defaultValueItem); - }) - - return defaultValueItems; - } - - /** - * 批量追加实体 - */ - private batchAppendEntites(defaultValues: any): Promise { - const timerId = this.formLoadingService.showLoadingWithDelay(); - const appendPromise = this.repository.createEntities(defaultValues).then((entities: Entity[]) => { - this.entityStore.appendEntities(entities); - return entities; - }).finally(() => { - this.formLoadingService.hideDelayLoading(timerId); - }); - return appendPromise; - } } diff --git a/packages/command-services/lib/data-services/create-data.service.ts b/packages/command-services/lib/data-services/create-data.service.ts index 7041edaf5..6b351dcc6 100644 --- a/packages/command-services/lib/data-services/create-data.service.ts +++ b/packages/command-services/lib/data-services/create-data.service.ts @@ -1,7 +1,9 @@ import { ViewModel, Entity, ViewModelState } from '@farris/devkit-vue'; +import { EntityPathUtil } from '../utils/entity-path-util'; import { BaseDataService } from './base-data.service'; import { FormLoadingService } from '../form-loading.service'; + /** * 数据新增服务 */ @@ -29,19 +31,75 @@ class CreateDataService extends BaseDataService { } /** - * 追加新数据 + * 追加数据 + * @param defaultValue 默认值 */ - public append() { + public append(defaultValue?: any): Promise { const timerId = this.formLoadingService.showLoadingWithDelay(); - const createPromise = this.repository.createEntity().then((entity: Entity) => { + const appendPromise = this.repository.createEntity(defaultValue).then((entity: Entity) => { this.entityState.appendEntities([entity]); return entity; }).finally(() => { this.formLoadingService.hideDelayLoading(timerId); }); - return createPromise; + return appendPromise; + } + + /** + * 批量追加数据 + * @param defaultValues 默认值集合 + */ + public batchAppend(defaultValues?: any): Promise { + const timerId = this.formLoadingService.showLoadingWithDelay(); + const appendPromise = this.repository.createEntities(defaultValues).then((entities: Entity[]) => { + this.entityState.appendEntities(entities); + return entities; + }).finally(() => { + this.formLoadingService.hideDelayLoading(timerId); + }); + return appendPromise; + } + + /** + * 追加从表数据 + * @param path 从表/从从表路径,形如/child1s/grand11s + * @param defaultValue 默认值 + */ + public appendByPath(path: string, defaultValue?: any): Promise { + if (!path) { + throw new Error('The path parameter can not be empty'); + } + + const timerId = this.formLoadingService.showLoadingWithDelay(); + const appendPromise = this.repository.createEntityByPath(path, defaultValue).then((entity: Entity) => { + this.entityState.appendEntities([entity]); + return entity; + }).finally(() => { + this.formLoadingService.hideDelayLoading(timerId); + }); + return appendPromise; } + /** + * 批量追加从表数据 + * @param path 从表或从从表路径,形如/child1s/grand11s + * @param defaultValues 默认值集合 + */ + public batchAppendByPath(path: string, defaultValues?: any): Promise { + if (!path) { + throw new Error('The path parameter can not be empty'); + } + const longPath = EntityPathUtil.convertToFullEntityListPath(path, this.entityState); + + const timerId = this.formLoadingService.showLoadingWithDelay(); + const appendPromise = this.repository.createEntitiesByPath(longPath, defaultValues).then((entities: Entity[]) => { + this.entityState.appendEntitesByPath(path, entities); + return entities; + }).finally(() => { + this.formLoadingService.hideDelayLoading(timerId); + }); + return appendPromise; + } } export { CreateDataService } \ No newline at end of file diff --git a/packages/command-services/lib/dialog.service.ts b/packages/command-services/lib/dialog.service.ts index 1e5f98054..fe1df4bbc 100644 --- a/packages/command-services/lib/dialog.service.ts +++ b/packages/command-services/lib/dialog.service.ts @@ -88,12 +88,17 @@ export class DialogService { */ public openLookup(config: string | LookupConfig | null, lookupId: string): void { const lookupInstance = this.renderEngineService.getComponentInstance(lookupId); - - // 设置帮助配置 const oldLookupProps = this.renderEngineService.getProps(lookupId); - const lookupProps = this.buildLookupProps(config, oldLookupProps.dialog); - if (lookupProps) { - lookupInstance.setProps(lookupProps); + const newLookupProps = this.buildLookupProps(config, oldLookupProps); + + // 设置弹窗属性 + if (newLookupProps && newLookupProps.dialog) { + lookupInstance.setProps({ dialog: newLookupProps.dialog }); + } + + // 设置帮助后回调 + if (newLookupProps && newLookupProps.dictPicked) { + this.renderEngineService.setProps(lookupId, { dictPicked: newLookupProps.dictPicked }); } // 打开帮助 @@ -161,12 +166,39 @@ export class DialogService { /** * 构造帮助属性 */ - private buildLookupProps(config: LookupConfig | string | null, instanceDialogConfig: any) { - const dialogConfig = this.normalizeConfig(config); - if (!dialogConfig) { + private buildLookupProps(config: LookupConfig | string | null, oldLookupProps: any): any { + const lookupConfig = this.normalizeConfig(config) as LookupConfig; + if (!lookupConfig) { + return null; + } + + const lookupProps: any = {}; + const { title, dictPicked } = lookupConfig; + if (title) { + const oldDialogProps = oldLookupProps.dialog; + lookupProps.dialog = this.buildLookupDialogProps(title, oldDialogProps) + } + + if (dictPicked) { + lookupProps.dictPicked = dictPicked; + } + + return lookupProps; + } + + /** + * 构造帮助弹窗属性 + */ + private buildLookupDialogProps(title: string, oldDialogProps: any): any { + + // 如果没有设置title,则返回null,不去触发设置帮助弹窗属性的操作 + if (!title) { return null; } + // 新传入的窗口配置 + const newDialogConfig = { title }; + // 默认窗口配置 const defaultDialogConfig = { title: '', @@ -176,22 +208,20 @@ export class DialogService { showCloseButton: true }; - // 组件实例上的配置 - instanceDialogConfig = instanceDialogConfig || {}; + // 组件实例上原来的窗口配置 + oldDialogProps = oldDialogProps || {}; - // 构造新的配置 - const newLookupDialogProps = { ...defaultDialogConfig, ...instanceDialogConfig, ...dialogConfig }; - this.stripUndefinedProps(newLookupDialogProps); + // 构造新的弹窗属性(优先级:新配置 > 组件实例配置 > 默认值) + const newDialogProps = { ...defaultDialogConfig, ...oldDialogProps, ...newDialogConfig }; + this.stripUndefinedProps(newDialogProps); - return { - dialog: newLookupDialogProps - }; + return newDialogProps; } /** * 标准化对象 */ - private normalizeConfig(config: string | ModalConfig | null): ModalConfig | null { + private normalizeConfig(config: string | ModalConfig | null): any | null { if (!config) { return null; } @@ -200,12 +230,12 @@ export class DialogService { return JSON.parse(config); } - const modalConfig = Object.assign({}, config); - if (Object.keys(modalConfig).length === 0) { + const normalizedConfig = Object.assign({}, config); + if (Object.keys(normalizedConfig).length === 0) { return null; } - return modalConfig; + return normalizedConfig; } /** @@ -319,4 +349,6 @@ export interface LookupConfig { // * 弹窗高度 // */ // height?: number; + + dictPicked?: (items: any[], options: Record) => Promise; } diff --git a/packages/command-services/lib/index.ts b/packages/command-services/lib/index.ts index a5fe36b6f..c9dc6c72e 100644 --- a/packages/command-services/lib/index.ts +++ b/packages/command-services/lib/index.ts @@ -17,6 +17,7 @@ export * from './entity-change.service'; export * from './pagination.service'; export * from './data-services/tree-data.service'; export * from './lookup-data.service'; +export * from './lookup-data-reference.service'; export * from './change-item.service'; export * from './data-check.service'; export * from './datagrid.service'; diff --git a/packages/command-services/lib/lookup-data-reference.service.ts b/packages/command-services/lib/lookup-data-reference.service.ts new file mode 100644 index 000000000..7aa09e2a3 --- /dev/null +++ b/packages/command-services/lib/lookup-data-reference.service.ts @@ -0,0 +1,146 @@ +import { Entity, EntityState, EntityStore, ViewModel, ViewModelState } from '@farris/devkit-vue'; +import { JSONObjectUtil, LookupUtil } from './utils/index'; +import { LocaleService } from './locale'; +import { FormNotifyService } from './form-notify.service'; +import { FormLoadingService } from './form-loading.service'; +import { DialogService, LookupConfig } from './dialog.service'; +import { CreateDataService } from './data-services/index'; + +/** + * 帮助数据引用服务 + */ +class LookupDataReferenceService { + + /** + * 实体仓库 + */ + private entityStore: EntityStore>; + + /** + * 构造函数 + */ + constructor( + private viewModel: ViewModel, + private formNotifyService: FormNotifyService, + private formLoadingService: FormLoadingService, + private dialogService: DialogService, + private createDataService: CreateDataService + ) { + this.entityStore = this.viewModel.entityStore as EntityStore>; + } + + /** + * 批量新增主表数据 + */ + public batchAppend(lookupId: string, mappingFields: string | Object): Promise { + if (!lookupId) { + throw new Error('The parameter lookupId can not be empty'); + } + const normalizedLookupMappings = LookupUtil.normalizeLookupMappingFields(mappingFields); + if (!normalizedLookupMappings) { + throw new Error('The parameter mappingFields can not be empty'); + } + + const resultPromsie: Promise = new Promise((resolve, reject) => { + const dictPickedCallback = (context: any) => { + const defaultValues = this.buildDefaultValues(context.items, normalizedLookupMappings); + this.createDataService.batchAppend(defaultValues).then( + (entities: Entity[]) => { + resolve(entities) + }, + (reason: any) => { + reject(reason); + } + ); + + return Promise.resolve(true); + } + const lookupConfig: LookupConfig = { + dictPicked: dictPickedCallback + }; + this.dialogService.openLookup(lookupConfig, lookupId); + }); + + return resultPromsie; + } + + /** + * 批量新增从表数据 + */ + public batchAppendByPath(entityPath: string, lookupId: string, mappingFields: string | Object): Promise { + if (!entityPath) { + throw new Error('The parameter path can not be empty'); + } + if (!lookupId) { + throw new Error('The parameter lookupId can not be empty'); + } + const normalizedLookupMappings = LookupUtil.normalizeLookupMappingFields(mappingFields); + if (!normalizedLookupMappings) { + throw new Error('The parameter mapFields can not be empty'); + } + + const resultPromsie: Promise = new Promise((resolve, reject) => { + const dictPickedCallback = (context: any) => { + const defaultValues = this.buildDefaultValues(context.items, normalizedLookupMappings); + this.createDataService.batchAppendByPath(entityPath, defaultValues).then( + (entities: Entity[]) => { + resolve(entities) + }, + (reason: any) => { + reject(reason); + } + ); + + return Promise.resolve(true); + } + const lookupConfig: LookupConfig = { + dictPicked: dictPickedCallback + }; + this.dialogService.openLookup(lookupConfig, lookupId); + }); + + return resultPromsie; + } + + /** + * 根据帮助后上下文批量新增 + */ + public batchAppendByContext(dictPickedContext: string, mapFields: string): Promise | undefined { + const lookupMappingFields = LookupUtil.normalizeLookupMappingFields(mapFields); + if (!lookupMappingFields) { + throw new Error('The parameter mapFields can not be empty'); + } + + const lookupSelectedItems = LookupUtil.getSelectionItemsFromDictPickedContext(dictPickedContext); + if (!Array.isArray(lookupSelectedItems) || lookupSelectedItems.length === 0) { + this.formNotifyService.warning(LocaleService.translate('pleaseSelectReferenceData')); + return; + } + + const defaultValues = this.buildDefaultValues(lookupSelectedItems, lookupMappingFields); + return this.createDataService.batchAppend(defaultValues); + } + + /** + * 构造批量新增数据的默认值 + */ + private buildDefaultValues(lookupSelectedItems: any[], lookupMappingFields: any[]): any[] { + const defaultValueItems: any[] = []; + lookupSelectedItems.forEach((lookupSelectedItem) => { + const defaultValueItem = {}; + lookupMappingFields.forEach((lookupMappingField) => { + const { srcFieldPath, targetFieldPaths } = lookupMappingField; + const srcFieldValue = JSONObjectUtil.getValueByPath(lookupSelectedItem, srcFieldPath); + targetFieldPaths.forEach((targetFieldPath: string) => { + JSONObjectUtil.setValueByPath(defaultValueItem, targetFieldPath, srcFieldValue, true); + }) + }); + defaultValueItems.push(defaultValueItem); + }) + + return defaultValueItems; + } +} + +export { LookupDataReferenceService }; + diff --git a/packages/command-services/lib/providers.ts b/packages/command-services/lib/providers.ts index ffcdcdbba..e6098e539 100644 --- a/packages/command-services/lib/providers.ts +++ b/packages/command-services/lib/providers.ts @@ -1,12 +1,8 @@ import { ViewModel, StaticProvider, Injector, EXCEPTION_HANDLER_TOKEN, HttpClient } from '@farris/devkit-vue'; import { EntityStateService } from './devkit-services/index'; import { - LoadDataService, CreateDataService, RemoveDataService, SaveDataService, - CancelDataService, UpdateDataService, - CardDataService, - ListDataService, - SubListDataService, - FilterConditionDataService + LoadDataService, CreateDataService, RemoveDataService, SaveDataService, CancelDataService, UpdateDataService, + CardDataService, ListDataService, SubListDataService, FilterConditionDataService } from './data-services/index'; import { ContextService } from './devkit-services/index'; import { @@ -19,6 +15,7 @@ import { EntityChangeService, PaginationService, TreeDataService, LookupDataService, + LookupDataReferenceService, StateService, FormExceptionHandler, changeItemService, @@ -58,7 +55,6 @@ const commandServicesDevkitProviders: StaticProvider[] = [ { provide: RuntimeFrameworkService, useClass: RuntimeFrameworkService, deps: [QuerystringService] }, { provide: NavigationHistoryService, useClass: NavigationHistoryService, deps: [] }, { provide: NavigationEventService, useClass: NavigationEventService, deps: [RuntimeFrameworkService, QuerystringService, NavigationHistoryService] }, - ]; const commandServiceModuleProviders: StaticProvider[] = [ @@ -86,6 +82,7 @@ const commandServiceViewModelProviders: StaticProvider[] = [ { provide: PaginationService, useClass: PaginationService, deps: [ViewModel] }, { provide: TreeDataService, useClass: TreeDataService, deps: [ViewModel, FormLoadingService, FormNotifyService, FormMessageService, StateService, EntityChangeService] }, { provide: LookupDataService, useClass: LookupDataService, deps: [ViewModel, HttpClient] }, + { provide: LookupDataReferenceService, useClass: LookupDataReferenceService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService, CreateDataService] }, { provide: CardDataService, useClass: CardDataService, deps: [ViewModel, FormLoadingService, FormNotifyService, EntityChangeService, FormMessageService] }, { provide: ListDataService, useClass: ListDataService, deps: [ViewModel, FormLoadingService, FormMessageService, FormNotifyService, EntityChangeService] }, { provide: SubListDataService, useClass: SubListDataService, deps: [ViewModel, FormLoadingService, FormMessageService, FormNotifyService] }, @@ -97,7 +94,7 @@ const commandServiceViewModelProviders: StaticProvider[] = [ { provide: ValidationService, useClass: ValidationService, deps: [ViewModel] }, { provide: GridMiddlewareService, useClass: GridMiddlewareService, deps: [ViewModel] }, { provide: BindingDataService, useClass: BindingDataService, deps: [ViewModel] }, - { provide: BatchEditService, useClass: BatchEditService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService] }, + { provide: BatchEditService, useClass: BatchEditService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService, LookupDataReferenceService] }, { provide: DialogService, useClass: DialogService, deps: [ViewModel, RenderEngineService] }, { provide: FormAttentionService, useClass: FormAttentionService, deps: [ViewModel] }, { provide: DiscussionGroupService, useClass: DiscussionGroupService, deps: [ViewModel, FormLoadingService, RuntimeFrameworkService] }, diff --git a/packages/command-services/lib/utils/entity-path-util.ts b/packages/command-services/lib/utils/entity-path-util.ts new file mode 100644 index 000000000..1e1103a9f --- /dev/null +++ b/packages/command-services/lib/utils/entity-path-util.ts @@ -0,0 +1,28 @@ +import { Entity, EntityState, EntityStore } from '@farris/devkit-vue'; + +/** + * 实体路径工具类 + */ +class EntityPathUtil { + + /** + * 获取实体列表长路径 + */ + public static convertToFullEntityListPath(shortPath: string, entityStore: EntityStore>): string { + if (!entityStore) { + throw new Error('EntityStore not found'); + } + + const entityListPath = entityStore.createPath(shortPath, true); + const entityListPathNodes = entityListPath.getNodes(); + + let fullEntityListPath = ''; + entityListPathNodes.forEach((entityPathNode) => { + fullEntityListPath += '/' + entityPathNode.getNodeValue(); + }); + + return fullEntityListPath; + } +} + +export { EntityPathUtil } \ No newline at end of file diff --git a/packages/command-services/lib/utils/index.ts b/packages/command-services/lib/utils/index.ts index 24cbcf376..39bb35e1f 100644 --- a/packages/command-services/lib/utils/index.ts +++ b/packages/command-services/lib/utils/index.ts @@ -1 +1,3 @@ -export * from './json-object-util'; \ No newline at end of file +export * from './json-object-util'; +export * from './entity-path-util'; +export * from './lookup-util'; diff --git a/packages/command-services/lib/utils/lookup-util.ts b/packages/command-services/lib/utils/lookup-util.ts new file mode 100644 index 000000000..51b33b7e5 --- /dev/null +++ b/packages/command-services/lib/utils/lookup-util.ts @@ -0,0 +1,49 @@ +/** + * 帮助工具类 + */ +class LookupUtil { + + /** + * 帮助后事件上下文中获取选中项 + */ + public static getSelectionItemsFromDictPickedContext(context: any): any[] { + if (!context || !context.command || !context.command.eventParams || + !context.command.eventParams.payload || !context.command.eventParams.payload.items) { + throw new Error('The selected items cannot be found in the context.'); + } + return context.command.eventParams.payload.items; + } + + /** + * 标准化帮助映射 + */ + public static normalizeLookupMappingFields(mappingFields: string | Object): any[] | null { + if (!mappingFields) { + throw new Error('The parameter mapFields can not be empty'); + } + + if (typeof mappingFields !== 'object' && typeof mappingFields !== 'string') { + throw new Error('The parameter mapFields must be a string or an object'); + } + const mappingFieldsObj = typeof mappingFields === 'object' ? mappingFields : JSON.parse(mappingFields) + + // 格式化字段映射 + const normalizedMappingFields: any[] = []; + Object.keys(mappingFieldsObj).forEach((key: string) => { + const srcFieldPath = key; + const targetFieldPath = mappingFieldsObj[key]; + if (!srcFieldPath || !targetFieldPath) { + return; + } + const targetFieldPaths = targetFieldPath.split(','); + normalizedMappingFields.push({ + srcFieldPath, + targetFieldPaths + }); + }); + + return normalizedMappingFields; + } +} + +export { LookupUtil } \ No newline at end of file diff --git a/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json b/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json index def05c7f8..40a778ed5 100644 --- a/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json +++ b/packages/designer/src/components/composition/command/supported-controllers/pc-supported-controller.json @@ -519,14 +519,6 @@ { "id": "d5f67e0a-767d-a238-5ad4-b1285476c16f", "code": "copyRow" - }, - { - "id": "461bf7f7-7383-f30f-1eed-66df1f8f7891", - "code": "openHiddenHelp" - }, - { - "id": "b7823f2a-5bc8-9292-d49f-0660d37f2863", - "code": "batchAppend" } ], "3f40288a-d11e-4dbd-89ba-388abf931ca3": [ @@ -586,5 +578,11 @@ "id": "9891fa58-14de-9753-12b8-415fe185978b", "code": "printByIds" } + ], + "1a8484e8-20eb-49d0-bc49-9fbbc4df20c6": [ + { + "id": "5e915b73-3ef6-d0c8-2800-85b456d130eb", + "code": "batchAppend" + } ] } \ No newline at end of file diff --git a/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts b/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts index 328c78967..ba1dcb208 100644 --- a/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts +++ b/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts @@ -31,7 +31,7 @@ export default [ code: 'data', name: '数据', active: false, - contains: ['RemoveCommands', 'EditCommands', 'BatchEditCommands', 'LoadCommands'] + contains: ['RemoveCommands', 'EditCommands', 'BatchEditCommands', 'LoadCommands', 'LookupDataReferenceCommands'] }, // { // id: 'flow', -- Gitee From b0c4083b7f51fd604b4b57cbdeb519c32fd91b60 Mon Sep 17 00:00:00 2001 From: jiweitao1986 Date: Tue, 23 Sep 2025 14:29:37 +0800 Subject: [PATCH 5/6] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4Lookup=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E9=80=89=E6=8B=A9=E6=A1=86=E6=95=B0=E6=8D=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=B9=E6=B3=95=E5=90=8D=E7=A7=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/composition/use-event-parameter-data.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/designer/src/components/composition/use-event-parameter-data.ts b/packages/designer/src/components/composition/use-event-parameter-data.ts index 616216b4f..598747ce4 100644 --- a/packages/designer/src/components/composition/use-event-parameter-data.ts +++ b/packages/designer/src/components/composition/use-event-parameter-data.ts @@ -159,9 +159,9 @@ export function useEventParameterData( } /** - * 构造隐藏帮助下拉列表数据 + * 构造Lookup选择框选项 */ - function buildHiddenLookups() { + function buildLookups() { const externalComponents = useFormSchemaComposition.getExternalComponents(); const result: any[] = []; externalComponents.forEach((externalComponent) => { @@ -182,8 +182,8 @@ export function useEventParameterData( data = buildComponents(); } else if (dataValue === ':CommandsTree') { data = buildCommands(); - } else if (dataValue === ':HiddenLookups') { - data = buildHiddenLookups(); + } else if (dataValue === ':Lookups') { + data = buildLookups(); } return data; } -- Gitee From a78ddcbe0b32d0cceaf343f0e73697270fcc6f30 Mon Sep 17 00:00:00 2001 From: jiweitao1986 Date: Wed, 24 Sep 2025 16:23:55 +0800 Subject: [PATCH 6/6] =?UTF-8?q?chore:=201=E3=80=81=E8=B0=83=E6=95=B4Lookup?= =?UTF-8?q?DataReferenceService=E7=B1=BB=E5=90=8D=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E6=B3=A8=E5=86=8C=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/command-services/lib/batch-edit.service.ts | 6 +++--- packages/command-services/lib/index.ts | 2 +- packages/command-services/lib/providers.ts | 6 +++--- ...-reference.service.ts => reference-dict-data.service.ts} | 6 +++--- .../schema-repository/controller/pc-categories.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename packages/command-services/lib/{lookup-data-reference.service.ts => reference-dict-data.service.ts} (98%) diff --git a/packages/command-services/lib/batch-edit.service.ts b/packages/command-services/lib/batch-edit.service.ts index 58bc7fc42..00e979491 100644 --- a/packages/command-services/lib/batch-edit.service.ts +++ b/packages/command-services/lib/batch-edit.service.ts @@ -4,7 +4,7 @@ import { LocaleService } from './locale'; import { FormNotifyService } from './form-notify.service'; import { FormLoadingService } from './form-loading.service'; import { DialogService } from './dialog.service'; -import { LookupDataReferenceService } from './lookup-data-reference.service'; +import { ReferenceDictDataService } from './reference-dict-data.service'; /** * 批量编辑服务 @@ -32,7 +32,7 @@ export class BatchEditService { private formNotifyService: FormNotifyService, private formLoadingService: FormLoadingService, private dialogService: DialogService, - private lookupDataReferenceService: LookupDataReferenceService + private referenceDictDataService: ReferenceDictDataService ) { this.repository = viewModel.repository as BefRepository; this.entityStore = viewModel.entityStore as EntityStore>; @@ -126,7 +126,7 @@ export class BatchEditService { */ public batchAppend(frameId: string, mapFields: string): Promise | undefined { const dictPickedContext = (this as any).context; - return this.lookupDataReferenceService.batchAppendByContext(dictPickedContext, mapFields); + return this.referenceDictDataService.batchAppendByContext(dictPickedContext, mapFields); } public clone(id: string, path: string) { } diff --git a/packages/command-services/lib/index.ts b/packages/command-services/lib/index.ts index c9dc6c72e..afb582024 100644 --- a/packages/command-services/lib/index.ts +++ b/packages/command-services/lib/index.ts @@ -17,7 +17,7 @@ export * from './entity-change.service'; export * from './pagination.service'; export * from './data-services/tree-data.service'; export * from './lookup-data.service'; -export * from './lookup-data-reference.service'; +export * from './reference-dict-data.service'; export * from './change-item.service'; export * from './data-check.service'; export * from './datagrid.service'; diff --git a/packages/command-services/lib/providers.ts b/packages/command-services/lib/providers.ts index e6098e539..2aaded0d5 100644 --- a/packages/command-services/lib/providers.ts +++ b/packages/command-services/lib/providers.ts @@ -15,7 +15,7 @@ import { EntityChangeService, PaginationService, TreeDataService, LookupDataService, - LookupDataReferenceService, + ReferenceDictDataService, StateService, FormExceptionHandler, changeItemService, @@ -82,7 +82,7 @@ const commandServiceViewModelProviders: StaticProvider[] = [ { provide: PaginationService, useClass: PaginationService, deps: [ViewModel] }, { provide: TreeDataService, useClass: TreeDataService, deps: [ViewModel, FormLoadingService, FormNotifyService, FormMessageService, StateService, EntityChangeService] }, { provide: LookupDataService, useClass: LookupDataService, deps: [ViewModel, HttpClient] }, - { provide: LookupDataReferenceService, useClass: LookupDataReferenceService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService, CreateDataService] }, + { provide: ReferenceDictDataService, useClass: ReferenceDictDataService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService, CreateDataService] }, { provide: CardDataService, useClass: CardDataService, deps: [ViewModel, FormLoadingService, FormNotifyService, EntityChangeService, FormMessageService] }, { provide: ListDataService, useClass: ListDataService, deps: [ViewModel, FormLoadingService, FormMessageService, FormNotifyService, EntityChangeService] }, { provide: SubListDataService, useClass: SubListDataService, deps: [ViewModel, FormLoadingService, FormMessageService, FormNotifyService] }, @@ -94,7 +94,7 @@ const commandServiceViewModelProviders: StaticProvider[] = [ { provide: ValidationService, useClass: ValidationService, deps: [ViewModel] }, { provide: GridMiddlewareService, useClass: GridMiddlewareService, deps: [ViewModel] }, { provide: BindingDataService, useClass: BindingDataService, deps: [ViewModel] }, - { provide: BatchEditService, useClass: BatchEditService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService, LookupDataReferenceService] }, + { provide: BatchEditService, useClass: BatchEditService, deps: [ViewModel, FormNotifyService, FormLoadingService, DialogService, ReferenceDictDataService] }, { provide: DialogService, useClass: DialogService, deps: [ViewModel, RenderEngineService] }, { provide: FormAttentionService, useClass: FormAttentionService, deps: [ViewModel] }, { provide: DiscussionGroupService, useClass: DiscussionGroupService, deps: [ViewModel, FormLoadingService, RuntimeFrameworkService] }, diff --git a/packages/command-services/lib/lookup-data-reference.service.ts b/packages/command-services/lib/reference-dict-data.service.ts similarity index 98% rename from packages/command-services/lib/lookup-data-reference.service.ts rename to packages/command-services/lib/reference-dict-data.service.ts index 7aa09e2a3..5286f1245 100644 --- a/packages/command-services/lib/lookup-data-reference.service.ts +++ b/packages/command-services/lib/reference-dict-data.service.ts @@ -7,9 +7,9 @@ import { DialogService, LookupConfig } from './dialog.service'; import { CreateDataService } from './data-services/index'; /** - * 帮助数据引用服务 + * 引用字典数据服务 */ -class LookupDataReferenceService { +class ReferenceDictDataService { /** * 实体仓库 @@ -142,5 +142,5 @@ class LookupDataReferenceService { } } -export { LookupDataReferenceService }; +export { ReferenceDictDataService }; diff --git a/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts b/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts index ba1dcb208..8ccdbb5d1 100644 --- a/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts +++ b/packages/designer/src/components/composition/schema-repository/controller/pc-categories.ts @@ -31,7 +31,7 @@ export default [ code: 'data', name: '数据', active: false, - contains: ['RemoveCommands', 'EditCommands', 'BatchEditCommands', 'LoadCommands', 'LookupDataReferenceCommands'] + contains: ['RemoveCommands', 'EditCommands', 'BatchEditCommands', 'LoadCommands', 'ReferenceDictDataCommands'] }, // { // id: 'flow', -- Gitee