diff --git a/packages/command-services/lib/batch-edit.service.ts b/packages/command-services/lib/batch-edit.service.ts index 60a6f058550110180ce6359f877596cce9fcd411..58bc7fc420e41efb5d2e10583e50237d26949714 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 7041edaf5da51a218c447b40686300fef7980e80..6b351dcc62cb8349a4e4896692d83d72945cd890 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 1e5f98054f5eed5044d5b1974070616e266b0a54..fe1df4bbc69c6781a438828705c32f98d2ef4576 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 a5fe36b6f4ff714e3471862b4622c9c1333bedf0..c9dc6c72ef61a5ca524128c5f04c1f65017e36e5 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 0000000000000000000000000000000000000000..7aa09e2a3249a325edc8fd4c32199f9de6b8e6bd --- /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 de7582fdadc54494d835e5776fb2310c23bf6837..bca0ea3cf26bb39e7b60e8251f6e9201714c9c36 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, @@ -57,7 +54,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[] = [ @@ -85,6 +81,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] }, @@ -96,7 +93,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 0000000000000000000000000000000000000000..1e1103a9f97adbc0cb6c85c2d7d56ef6b7db4397 --- /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 24cbcf3768b1b567b0266ca9ffb8be4d20ad0739..39bb35e1fa2d70c3571611542f324ce54a1964fd 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 0000000000000000000000000000000000000000..51b33b7e55a7c6705eba95bf0eea252d40c150b5 --- /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 b5f195eb6d492a7aae9b3f4af0f920ab8ae8ac79..d2ccc6123f5a94d01d95c2addf4872c034859bb0 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": [ @@ -572,5 +564,11 @@ "id": "b707e9c2-61c7-01d8-bd0e-aac222271602", "code": "PreviewBySubDirName" } + ], + "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 328c789671042fcc8bfd9c6892edada3449928fe..ba1dcb20891f9247aa315935424f191681486e24 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', 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 e240395fa659dcbb653a9e891fd8cbd926634701..616216b4fac484602acd545811b9ad3604e57dee 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 47c631d8f47913fb8c2712e9a0145d974b057b31..8eed093d4b92af8ae5c4f3062536c3232e651749 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 b7c245d48a4f0fc1f3b60cce4ce3769991b059d4..617334505dc33294b229537161f25c112232222f 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 {