diff --git a/packages/command-services/lib/print.service.ts b/packages/command-services/lib/print.service.ts index 03a2afd337bbd78c810006818e5a8ff64c035734..5e0a19fbd5f005e2469abfa3db127ea54d4cbdfa 100644 --- a/packages/command-services/lib/print.service.ts +++ b/packages/command-services/lib/print.service.ts @@ -1,8 +1,14 @@ +import { LocaleService } from './locale'; +import { CloudPrintService, OutputOptions, SourceOptions, OutputType, FileType, SourceFilterOptions, PrintType } from '@gsp-svc/cloudprint-vue'; +import { FormNotifyService } from './form-notify.service'; + class PrintService { /** * 构造函数 */ constructor( + private printService: CloudPrintService, + private formNotifyService: FormNotifyService, ) { } @@ -12,7 +18,11 @@ class PrintService { * @param bizBillId 业务单据标识 */ public printSingle(beMetaId: string, bizBillId: string) { - + if (!bizBillId) { + this.showWarning(LocaleService.translate('unallowEmptyBizBillId')); + return Promise.reject(); + } + return this.printArray(beMetaId, [bizBillId]); } /** * 打印单据(通过id或ids) @@ -20,7 +30,15 @@ class PrintService { * @param ids 单据id或ids */ public printByIds(beMetaId: string, ids: string | string[]) { - + if (!ids) { + this.showWarning(LocaleService.translate('unallowEmptyBizBillId')); + return Promise.reject(); + } + if (typeof ids === 'string') { + ids = ids.split(',').filter(item => item); + } + const dataIds: Array = ids; + return this.printArray(beMetaId, dataIds); } /** * 打印单据(带维度) @@ -31,7 +49,12 @@ class PrintService { * @param billCategoryId 单据类型Id */ public printByIdsWithDimension(beMetaId: string, ids: string, dim1: string, dim2: string, billCategoryId?: string) { - + if (!ids) { + this.showWarning(LocaleService.translate('unallowEmptyBizBillId')); + return Promise.reject(); + } + const dataIds: Array = ids.split(',').filter(item => item); + return this.printArray(beMetaId, dataIds, dim1, dim2, billCategoryId); } /** * 打印多个单据 @@ -42,7 +65,27 @@ class PrintService { * @param billCategoryId 业务单据类型Id */ public printArray(beMetaId: string, dataIds: string[], dim1?: any, dim2?: any, billCategoryId?: string) { - + if (!dataIds || dataIds.length === 0) { + this.showWarning(LocaleService.translate('unallowEmptyBizBillId')); + return Promise.reject(); + } + const sourceOptions: SourceOptions = this.buildSourceOptions({ + dataIds: dataIds, + sourceId: beMetaId + }); + + const outputOptions: OutputOptions = this.buildOutputOptions(); + + if (typeof dim1 !== 'undefined') { + sourceOptions.FirstDimensionVal = dim1; + } + if (typeof dim2 !== 'undefined') { + sourceOptions.SecondDimensionVal = dim2; + } + if (typeof billCategoryId !== 'undefined') { + sourceOptions.billCategoryId = billCategoryId; + } + return this.printService.outputBEData(sourceOptions, outputOptions, 'tab'); } /** @@ -53,7 +96,23 @@ class PrintService { * @param includeChildData 包含子表数据 */ public printMulti(beMetaId: string, filterCondition: string, sortCondition: string, includeChildData: boolean = true) { - + const entryFilter = { 'isUsePagination': false, 'filterConditions': [], 'sortConditions': [], 'pagination': null }; + if (filterCondition) { + // 统一纠正最后一个过滤条件的Relation + const filters = JSON.parse(filterCondition); + if (filters && filters.length > 0) { + filters[filters.length - 1].Relation = 0; + } + entryFilter.filterConditions = filters; + } + + if (sortCondition) { + entryFilter.sortConditions = JSON.parse(sortCondition); + } + // sfo:SourceFilterOptions + const sourceFilterOptions: SourceFilterOptions = this.buildSourceFilterOptions({ sourceId: beMetaId, entryFilter, includeChildData }); + const outputOptions: OutputOptions = this.buildOutputOptions(); + return this.printService.outputBEDataWithFilter(sourceFilterOptions, outputOptions, 'tab'); } /** * 按照BE取数方式批量打印单据(带维度) @@ -66,7 +125,100 @@ class PrintService { * @param includeChildData 包含子表数据 */ public printMultiWithDimension(beMetaId: string, filterCondition: string, sortCondition: string, dim1: string, dim2: string, billCategoryId?: string, includeChildData: boolean = true) { - + const entryFilter = { 'isUsePagination': false, 'filterConditions': [], 'sortConditions': [], 'pagination': null }; + if (filterCondition) { + // 统一纠正最后一个过滤条件的Relation + const filters = JSON.parse(filterCondition); + if (filters && filters.length > 0) { + filters[filters.length - 1].Relation = 0; + } + entryFilter.filterConditions = filters; + } + + if (sortCondition) { + entryFilter.sortConditions = JSON.parse(sortCondition); + } + const sfo: SourceFilterOptions = this.buildSourceFilterOptions({ sourceId: beMetaId, entryFilter, includeChildData }); + if (typeof dim1 !== 'undefined') { + sfo.FirstDimensionVal = dim1; + } + if (typeof dim2 !== 'undefined') { + sfo.SecondDimensionVal = dim2; + } + if (typeof billCategoryId !== 'undefined') { + sfo.billCategoryId = billCategoryId; + } + const outputOptions: OutputOptions = this.buildOutputOptions(); + return this.printService.outputBEDataWithFilter(sfo, outputOptions, 'tab'); + } + /** + * 构造SourceOptions + * @param options options + */ + private buildSourceOptions(options: { dataIds: string[], sourceId: string, [prop: string]: any; }): SourceOptions { + const outputOptions: SourceOptions = { + DataIds: options.dataIds, + SourceId: options.sourceId, + FirstDimensionVal: options.dim1, + SecondDimensionVal: options.dim2, + RetrieveParam: options.retrieveParam, + FormatId: options.formatId, + billCategoryId: options.billCategoryId, + ServiceUnit: options.serviceUnit, + currentPage: options.currentPage, + pageRowCount: options.pageRowCount, + queryType: options.queryType, + queryServiceId: options.queryServiceId, + queryParam: options.queryParam + }; + return outputOptions; + } + /** + * 构造OutputOptions + * @param options options + */ + private buildOutputOptions(options?: { [prop: string]: any; }): OutputOptions { + const outputOptions: OutputOptions = { + OutputType: options && options.outputType || OutputType.PRINT, + FileType: options && options.fileType || FileType.Html5, + Path: options && options.path, + DeviceId: options && options.deviceId, + printJob: options && options.printJob, + printerName: options && options.printerName, + printSetting: options && options.printSetting, + printType: options && options.printType || PrintType.Form, + }; + return outputOptions; + } + /** + * 构造SourceFilterOptions + * @param options options + */ + private buildSourceFilterOptions(options: { sourceId: string, [prop: string]: any; }): SourceFilterOptions { + const entryFilter = { 'isUsePagination': false, 'filterConditions': [], 'sortConditions': [], 'pagination': null }; + const sourceFilterOptions: SourceFilterOptions & { [prop: string]: any; } = { + SourceId: options.sourceId, + EntityFilter: options.entryFilter || entryFilter, + FirstDimensionVal: options.dim1, + SecondDimensionVal: options.dim2, + FormatId: options.formatId, + ServiceUnit: options.serviceUnit, + billCategoryId: options.billCategoryId, + currentPage: options.currentPage, + pageRowCount: options.pageRowCount, + queryParam: options.queryParam, + queryServiceId: options.queryServiceId, + queryType: options.queryType, + includeChildData: options && options.hasOwnProperty('includeChildData') ? options.includeChildData : true + }; + return sourceFilterOptions; + } + /** + * 展示错误消息 + * @param message 错误消息 + */ + private showWarning(message: string) { + this.formNotifyService.warning(message); } } diff --git a/packages/command-services/lib/providers.ts b/packages/command-services/lib/providers.ts index 0946566a796409bd7679d039baf51b83a2c17bc3..0fbf8815ee799b2a136a05c2f3b498c5b6c9e6ea 100644 --- a/packages/command-services/lib/providers.ts +++ b/packages/command-services/lib/providers.ts @@ -53,12 +53,14 @@ import { } from './index'; import { UploadDialogService, DownloadService } from '@gsp-svc/formdoc-upload-vue'; import { FileViewerService } from '@gsp-svc/file-viewer-vue'; +import { CloudPrintService } from '@gsp-svc/cloudprint-vue'; const commandServicesDevkitProviders: StaticProvider[] = [ { provide: QuerystringService, useClass: QuerystringService, deps: [] }, { provide: RuntimeFrameworkService, useClass: RuntimeFrameworkService, deps: [QuerystringService] }, { provide: NavigationHistoryService, useClass: NavigationHistoryService, deps: [] }, { provide: NavigationEventService, useClass: NavigationEventService, deps: [RuntimeFrameworkService, QuerystringService, NavigationHistoryService] }, + ]; const commandServiceModuleProviders: StaticProvider[] = [ @@ -115,7 +117,7 @@ const commandServiceViewModelProviders: StaticProvider[] = [ { provide: DirtyCheckingService, useClass: DirtyCheckingService, deps: [] }, { provide: RenderEngineService, useClass: RenderEngineService, deps: [Injector] }, { provide: TemplateService, useClass: TemplateService, deps: [ViewModel] }, - { provide: PrintService, useClass: PrintService, deps: [] }, + { provide: PrintService, useClass: PrintService, deps: [CloudPrintService, FormNotifyService] }, { provide: FilterConditionDataService, useClass: FilterConditionDataService, deps: [ViewModel, CommandService] }, { provide: SortConditionDataService, useClass: SortConditionDataService, deps: [ViewModel, CommandService] }, // 导航相关服务 @@ -124,7 +126,7 @@ const commandServiceViewModelProviders: StaticProvider[] = [ { provide: ParamService, useClass: ParamService, deps: [QuerystringService, RuntimeFrameworkService] }, { provide: ApplicationParamService, useClass: ApplicationParamService, deps: [ParamService, RuntimeFrameworkService, ViewModel] }, { provide: ContextService, useClass: ContextService, deps: [ViewModel, RenderEngineService] }, - { provide: TranslateService, useClass: TranslateService, deps: [Injector] } + { provide: TranslateService, useClass: TranslateService, deps: [Injector]} ]; export { commandServicesDevkitProviders, commandServiceModuleProviders, commandServiceViewModelProviders }; diff --git a/packages/command-services/lib/utils/lookup-util.ts b/packages/command-services/lib/utils/lookup-util.ts index 51b33b7e55a7c6705eba95bf0eea252d40c150b5..86b75822ad99cce94f753592da2165ce955cf601 100644 --- a/packages/command-services/lib/utils/lookup-util.ts +++ b/packages/command-services/lib/utils/lookup-util.ts @@ -25,8 +25,10 @@ class LookupUtil { 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 mappingFieldsObj = typeof mappingFields === 'object' ? mappingFields : JSON.parse(mappingFields); + if (!mappingFieldsObj || typeof mappingFieldsObj !== 'object' || Object.keys(mappingFieldsObj).length === 0) { + throw new Error('The parameter mapFields must be an object and can not be empty'); + } // 格式化字段映射 const normalizedMappingFields: any[] = []; Object.keys(mappingFieldsObj).forEach((key: string) => { @@ -46,4 +48,4 @@ class LookupUtil { } } -export { LookupUtil } \ No newline at end of file +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 d2ccc6123f5a94d01d95c2addf4872c034859bb0..40a778ed56d4981e17c196d9788c20d8c9749067 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 @@ -565,6 +565,20 @@ "code": "PreviewBySubDirName" } ], + "e353b4e9-e073-4e18-b9f7-ec4cc8ac72b1": [ + { + "id": "abbfb7aa-7a2d-1683-fab4-19e6da2bc45a", + "code": "printSingle" + }, + { + "id": "774fa275-2da1-e927-e8bf-d27d9886a168", + "code": "printMulti" + }, + { + "id": "9891fa58-14de-9753-12b8-415fe185978b", + "code": "printByIds" + } + ], "1a8484e8-20eb-49d0-bc49-9fbbc4df20c6": [ { "id": "5e915b73-3ef6-d0c8-2800-85b456d130eb", diff --git a/packages/renderer/package.json b/packages/renderer/package.json index febc6c782614d1cb75f87e709a9c8a0717bef324..2a7f289c3e161eb79fcf68771647bf3fcdc89844 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -45,8 +45,9 @@ "rxjs": "^7.4.0", "@gsp-wf/wf-task-handler-vue": "0.0.1", "@gsp-dip/data-imp-exp-vue": "0.0.1", - "@gsp-svc/formdoc-upload-vue":"1.0.1", - "@gsp-svc/file-viewer-vue":"1.0.1", + "@gsp-svc/formdoc-upload-vue": "1.0.1", + "@gsp-svc/file-viewer-vue": "1.0.1", + "@gsp-svc/cloudprint-vue": "0.0.2", "@gsp-cmp/chgdr-vue": "0.0.1" }, "devDependencies": { diff --git a/packages/renderer/src/composition/use-module-config.ts b/packages/renderer/src/composition/use-module-config.ts index 515d25bdccb21df2f0965225b5a15b5245b1ee0b..9c8a481fb190700da47706a43c8419693f83e6b6 100644 --- a/packages/renderer/src/composition/use-module-config.ts +++ b/packages/renderer/src/composition/use-module-config.ts @@ -27,8 +27,9 @@ import { BifDevkitRootProviders, BifDevkitProviders } from "@edp-bif/runtime-api import { UploadDevkitProviders, UploadDevkitRootProviders } from '@gsp-svc/formdoc-upload-vue'; import { FileViewerServiceProviders, FileViewerDevkitProviders, FileViewerDevkitRootProviders } from '@gsp-svc/file-viewer-vue'; import { i18nModuleProviders } from "../i18n"; -import { componentServiceProviders } from "../component-services"; +import { CloudPrintServiceProviders } from '@gsp-svc/cloudprint-vue'; import { ChgdrProviders } from '@gsp-cmp/chgdr-vue'; +import { componentServiceProviders } from "../component-services"; export function useModuleConfig(metadata: Ref, uiProviders: StaticProvider[], render: Ref, parentContainerId: string): ModuleConfig { const moduleMetaContext: any = { @@ -75,8 +76,9 @@ export function useModuleConfig(metadata: Ref, uiProviders: StaticProvider[], re ...DataIECommandProviders, ...UploadDevkitProviders, ...FileViewerDevkitProviders, + ...CloudPrintServiceProviders, + ...ChgdrProviders, ...componentServiceProviders, - ...ChgdrProviders ] }; const moduleConfigBuilder = new ModuleConfigBuilder(moduleMetaContext); diff --git a/packages/ui-binding/lib/compositions/use-tree-grid-binding.ts b/packages/ui-binding/lib/compositions/use-tree-grid-binding.ts index 145175f52e2f74039e3ce2d765eaa7ba7722d797..e3c68cfdf3d2f27e93774685da2d36c90fc5c8f9 100644 --- a/packages/ui-binding/lib/compositions/use-tree-grid-binding.ts +++ b/packages/ui-binding/lib/compositions/use-tree-grid-binding.ts @@ -60,12 +60,14 @@ export function useTreeGridBinding(elementRef: ElementRef, options: TreeBuilderB if (change.type === EntityChangeType.Load) { componentRef.value.updateDataSource(data); if (rootId && isFirstRender) { + componentRef.value.selectRowById(rootId); selectItemById(rootId); isFirstRender = false; viewModel.entityStore?.changeCurrentEntityByPath(viewModel.bindingPath, rootId); } else { const entity = viewModel.entityStore?.getEntityListByPath(options.entityPath).getCurrentEntity(); const primaryValue = entity?.idValue; + componentRef.value.selectRowById(primaryValue); selectItemById(primaryValue); viewModel.entityStore?.changeCurrentEntityByPath(viewModel.bindingPath, primaryValue); } @@ -109,9 +111,8 @@ export function useTreeGridBinding(elementRef: ElementRef, options: TreeBuilderB if (currentId === id && !forceSelect) { return; } - // componentRef.value.activeRowById(id); + componentRef.value.activeRowById(id); componentRef.value.clickRowItemById(id); - componentRef.value.selectRowById(id); } function getTreeBuilder(): TreeBuilder | null { const { getHierarchyInfo } = useHierarchyInfo(options.hierarchyKey);