cloud-web-corejs 1.0.174 → 1.0.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/package.json +2 -1
  2. package/src/components/Tinymce/index.vue +112 -71
  3. package/src/components/VabUpload/image-viewer.vue +2 -2
  4. package/src/components/VabUpload/index.js +2 -1
  5. package/src/components/VabUpload/mixins.js +1 -1
  6. package/src/components/VabUpload/privateProfileDialogMixins.js +1 -1063
  7. package/src/components/VabUpload/view.vue +4 -2
  8. package/src/components/baseAlert/mixins.js +1 -1
  9. package/src/components/baseAttachment/mixins.js +2 -1
  10. package/src/components/baseInputExport/index.vue +19 -12
  11. package/src/components/baseInputExport/mixins.js +1 -1
  12. package/src/components/baseTabs/mixins.js +1 -1
  13. package/src/components/code-editor/index.vue +102 -63
  14. package/src/components/confirmDialog/index.vue +24 -17
  15. package/src/components/confirmDialog/mixins.js +1 -1
  16. package/src/components/errorMsg/index.vue +42 -34
  17. package/src/components/errorMsg/mixins.js +1 -1
  18. package/src/components/excelExport/index.js +1 -2
  19. package/src/components/excelExport/mixins.js +1 -1
  20. package/src/components/scriptDescription/button.vue +12 -4
  21. package/src/components/scriptTest/mixins.js +1 -1
  22. package/src/components/table/index.js +1 -1
  23. package/src/components/table/plugins/extend-cell-area/vxe-table-extend-cell-area.es6.min.js +11028 -0
  24. package/src/components/table/plugins/extend-cell-area/vxe-table-extend-cell-area.min.css +200 -0
  25. package/src/components/vb-tabs/x-tabs.vue +0 -1
  26. package/src/components/xform/form-designer/designer.js +1 -1
  27. package/src/components/xform/form-designer/form-widget/components/gantt/index.vue +16 -1
  28. package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +1 -1
  29. package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +17 -4
  30. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +1 -1
  31. package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +247 -187
  32. package/src/components/xform/form-designer/form-widget/field-widget/gantt-widget.vue +2 -0
  33. package/src/components/xform/form-designer/form-widget/field-widget/html-text-widget.vue +6 -2
  34. package/src/components/xform/form-designer/form-widget/field-widget/static-content-wrapper.vue +10 -0
  35. package/src/components/xform/form-designer/form-widget/field-widget/text-widget.vue +65 -4
  36. package/src/components/xform/form-designer/setting-panel/form-setting.vue +131 -118
  37. package/src/components/xform/form-designer/setting-panel/property-editor/autoValueEnabled-editor.vue +1 -1
  38. package/src/components/xform/form-designer/setting-panel/property-editor/formatType-editor.vue +137 -0
  39. package/src/components/xform/form-designer/setting-panel/property-editor/name-editor.vue +124 -50
  40. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
  41. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +5 -1
  42. package/src/components/xform/form-render/indexMixin copy.js +3462 -0
  43. package/src/components/xform/form-render/indexMixin.js +1 -1
  44. package/src/components/xform/mixins/defaultHandle.js +1 -1
  45. package/src/components/xform/utils/format.js +14 -4
  46. package/src/components/xform/utils/formula-util.js +0 -4
  47. package/src/components/xform/utils/util.js +1 -1
  48. package/src/layout/components/Sidebar/default.vue +1421 -1266
  49. package/src/layout/components/createCompany/createCompanyDialog.vue +157 -0
  50. package/src/utils/index.js +1 -6
  51. package/src/utils/vab.js +1 -1
  52. package/src/views/user/form/vform/designer.vue +2 -1
  53. package/src/views/user/outLink/index.vue +57 -18
@@ -0,0 +1,3462 @@
1
+ import emitter from "../../../components/xform/utils/emitter";
2
+ import i18n, { changeLocale } from "../../../components/xform/utils/i18n";
3
+ import Vue from "vue";
4
+ import dynamicDialogRender from "./dynamicDialogRender.js";
5
+ import VFormRender from "../../../components/xform/form-render/index.vue";
6
+ import {
7
+ generateId,
8
+ deepClone,
9
+ getAllContainerWidgets,
10
+ getAllFieldWidgets,
11
+ insertCustomCssToHead,
12
+ insertGlobalFunctionsToHtml,
13
+ traverseFieldWidgets,
14
+ buildDefaultFormJson,
15
+ traverseFieldWidgetsOfContainer,
16
+ getFieldWidgetByName,
17
+ getDSByName,
18
+ overwriteObj,
19
+ runDataSourceRequest,
20
+ getContainerWidgetByName,
21
+ cloneFormConfigWithoutEventHandler,
22
+ loopHandleWidget,
23
+ traverseAllWidgetsNew,
24
+ columnFormatMap,
25
+ } from "../../../components/xform/utils/util";
26
+ import {
27
+ containers,
28
+ advancedFields,
29
+ basicFields,
30
+ customFields,
31
+ businessFields,
32
+ hiddenWidgetTypesOfWf,
33
+ freeWidgetTypesOfWf,
34
+ } from "../../../components/xform/form-designer/widget-panel/widgetsConfig.js";
35
+ import scriptHttpMixin from "../../../components/xform/mixins/scriptHttp";
36
+ import defaultHandleMixin from "../../../components/xform/mixins/defaultHandle";
37
+ import xeUtils from "xe-utils";
38
+ import { extendDeeply } from "@base/utils/index.js";
39
+ import "@base/components/xform/utils/directive";
40
+ import html2Canvas from "html2canvas";
41
+ import JsPDF from "jspdf";
42
+ import formulaDialog from "@base/components/xform/form-designer/form-widget/dialog/formulaDialog.vue";
43
+ import baseFormulaDialog from "@base/components/xform/form-designer/form-widget/dialog/baseFormulaDialog.vue";
44
+
45
+ let modules = {};
46
+ const baseRefUtil = {
47
+ emitter,
48
+ i18n,
49
+ changeLocale,
50
+ Vue,
51
+ generateId,
52
+ deepClone,
53
+ getAllContainerWidgets,
54
+ getAllFieldWidgets,
55
+ insertCustomCssToHead,
56
+ insertGlobalFunctionsToHtml,
57
+ traverseFieldWidgets,
58
+ buildDefaultFormJson,
59
+ traverseFieldWidgetsOfContainer,
60
+ getFieldWidgetByName,
61
+ getDSByName,
62
+ overwriteObj,
63
+ runDataSourceRequest,
64
+ getContainerWidgetByName,
65
+ cloneFormConfigWithoutEventHandler,
66
+ dynamicDialogRender,
67
+ };
68
+
69
+ modules = {
70
+ componentName: "VFormRender",
71
+ components: {
72
+ formulaDialog,
73
+ baseFormulaDialog,
74
+ },
75
+ mixins: [
76
+ baseRefUtil.emitter,
77
+ baseRefUtil.i18n,
78
+ scriptHttpMixin,
79
+ defaultHandleMixin,
80
+ ],
81
+ props: {
82
+ formJson: {
83
+ //prop传入的表单JSON配置
84
+ type: Object,
85
+ default: () => buildDefaultFormJson(),
86
+ },
87
+ formData: {
88
+ //prop传入的表单数据
89
+ type: Object,
90
+ default: () => ({}),
91
+ },
92
+ optionData: {
93
+ //prop传入的选项数据
94
+ type: Object,
95
+ default: () => ({}),
96
+ },
97
+ previewState: {
98
+ //是否表单预览状态
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+ disabledMode: {
103
+ type: Boolean,
104
+ default: !1,
105
+ },
106
+ globalDsv: {
107
+ type: Object,
108
+ default: function () {
109
+ return {};
110
+ },
111
+ },
112
+ parentForm: {
113
+ type: Object,
114
+ default: null,
115
+ },
116
+ dynamicCreation: {
117
+ type: Boolean,
118
+ default: !1,
119
+ },
120
+ reportTemplate: {
121
+ type: Object,
122
+ default: null,
123
+ },
124
+ dataId: {
125
+ type: [Number, String],
126
+ default: null,
127
+ },
128
+ param: {
129
+ type: Object,
130
+ default: null,
131
+ },
132
+ },
133
+ provide() {
134
+ let e = this;
135
+ return {
136
+ refList: this.widgetRefList,
137
+ widgetKeyNameMap: this.widgetKeyNameMap,
138
+ sfRefList: this.subFormRefList,
139
+ getFormConfig: function () {
140
+ return e.formJsonObj.formConfig;
141
+ },
142
+ getGlobalDsv: function () {
143
+ return e.globalDsv;
144
+ },
145
+ globalOptionData: this.optionData,
146
+ getOptionData: function () {
147
+ return e.optionData;
148
+ },
149
+ globalModel: {
150
+ formModel: this.formDataModel,
151
+ formData: this.currentFormData,
152
+ },
153
+ previewState: this.previewState,
154
+ getReadMode: function () {
155
+ return e.readModeFlag;
156
+ },
157
+ getSubFormFieldFlag: function () {
158
+ return !1;
159
+ },
160
+ getSubFormName: function () {
161
+ return "";
162
+ },
163
+ doScriptAccess: this.doScriptAccess,
164
+ formHttp: this.formHttp,
165
+ getReportTemplate: () => this.reportTemplate,
166
+ getObjectFieldFlag: () => !1,
167
+ getObjectName: () => "",
168
+ getHasWf: () => this.hasWf,
169
+ hasConfig: this.hasConfig,
170
+ };
171
+ },
172
+ data() {
173
+ return {
174
+ formJsonObj: this.formJson,
175
+ formDataModel: {},
176
+ widgetRefList: {},
177
+ subFormRefList: {},
178
+ widgetKeyNameMap: {},
179
+ formId: null,
180
+ externalComponents: {},
181
+ readModeFlag: !1,
182
+ dialogOrDrawerRef: null,
183
+ searchDialogOption: {},
184
+ showSearchDialog: false,
185
+ currentFormData: {},
186
+ timerMap: {},
187
+ hasWf: false,
188
+ showFormContent: false,
189
+
190
+ showFormDialog: false,
191
+ formDialogOption: {},
192
+ showImportDialog: false,
193
+ importDialogOption: {},
194
+ formDrawerOption: {},
195
+ showFormDrawer: false,
196
+ userInfo: null,
197
+ userSaleOrgDTOs: [],
198
+ userRoleDTOs: [],
199
+
200
+ userSaleOrgDTO2s: [],
201
+ userRoleDTO2s: [],
202
+ defaultUserSaleOrgDTO: null,
203
+ bdService: null,
204
+ globalParam: {},
205
+ widgetEditOnWf: null,
206
+ wfModifyEnabled: false,
207
+
208
+ fileReferenceDialogOption: null,
209
+ showFileReferenceDialog: false,
210
+
211
+ formulaDialogOption: null,
212
+ formulaDialogVisible: false,
213
+ baseFormulaDialogOption: null,
214
+ baseFormulaDialogVisible: false,
215
+ globalConfig: {}
216
+ };
217
+ },
218
+ computed: {
219
+ formConfig() {
220
+ return this.formJsonObj.formConfig;
221
+ },
222
+
223
+ widgetList() {
224
+ return this.formJsonObj.widgetList;
225
+ },
226
+
227
+ labelPosition() {
228
+ if (!!this.formConfig && !!this.formConfig.labelPosition) {
229
+ return this.formConfig.labelPosition;
230
+ }
231
+
232
+ return "left";
233
+ },
234
+
235
+ labelWidth() {
236
+ if (!!this.formConfig && !!this.formConfig.labelWidth) {
237
+ return this.formConfig.labelWidth + "px";
238
+ }
239
+
240
+ return "112px";
241
+ },
242
+
243
+ size() {
244
+ if (!!this.formConfig && !!this.formConfig.size) {
245
+ return this.formConfig.size;
246
+ }
247
+
248
+ return "medium";
249
+ },
250
+
251
+ customClass() {
252
+ return !!this.formConfig && !!this.formConfig.customClass
253
+ ? this.formConfig.customClass
254
+ : "";
255
+ },
256
+ },
257
+ watch: {
258
+ //
259
+ },
260
+ async created() {
261
+ this.registerFormToRefList();
262
+ this.currentFormData = this.formData;
263
+ let formConfig = this.formConfig;
264
+ await this.initUserInfo();
265
+ await this.initSaleOrgData();
266
+ await this.initUserRoleData();
267
+ await this.initBdService();
268
+ // this.handleAllTableColumnWidget();
269
+ this.initGlobalConfig();//初始化全局配置
270
+ this.buildFormModel(!this.formJsonObj ? null : this.formJsonObj.widgetList);
271
+ // this.hanldeCommonWidget();//处理组件显隐规则
272
+ if (formConfig.isLoadEntity) {
273
+ await this.loadDefaultEntityData(() => {
274
+ this.handleCustomEvent(formConfig.formScriptSuccess);
275
+ });
276
+ } else {
277
+ this.hanldeCommonWidget2(); //处理组件显隐,可编辑
278
+ this.handleShowContent();
279
+ }
280
+ this.handleOnCreated(),
281
+ // this.buildFormModel(!this.formJsonObj ? null : this.formJsonObj.widgetList);
282
+ this.initFormObject();
283
+ },
284
+ mounted() {
285
+ this.initLocale();
286
+ this.handleOnMounted();
287
+ },
288
+ methods: {
289
+ initGlobalConfig(){
290
+ //初始化全局配置
291
+ this.globalConfig = this.handleCustomEvent(
292
+ this.formConfig.globalConfig
293
+ ) || {};
294
+
295
+ },
296
+ /**
297
+ * 数据对象key 驼峰下划线相互转化
298
+ * @param {Object} data - 原始对象 支持-数组、key-value对象、字符串
299
+ * @param {String} type hump-转驼峰 toLine-转下划线
300
+ */
301
+ formatHumpLineTransfer(data, type = "hump") {
302
+ let hump = "";
303
+ // 转换对象中的每一个键值为驼峰的递归
304
+ let formatTransferKey = (data) => {
305
+ if (data instanceof Array) {
306
+ data.forEach((item) => formatTransferKey(item));
307
+ } else if (data instanceof Object) {
308
+ for (let key in data) {
309
+ hump =
310
+ type === "hump" ? this.formatToHump(key) : this.formatToLine(key);
311
+ data[hump] = data[key];
312
+ if (key !== hump) {
313
+ delete data[key];
314
+ }
315
+ if (data[hump] instanceof Object) {
316
+ formatTransferKey(data[hump]);
317
+ }
318
+ }
319
+ } else if (typeof data === "string") {
320
+ data =
321
+ type === "hump" ? this.formatToHump(data) : this.formatToLine(data);
322
+ }
323
+ };
324
+ formatTransferKey(data);
325
+ return data;
326
+ },
327
+
328
+ /**
329
+ * 字符串下划线转驼峰
330
+ * @param {String} value 需要转换的值
331
+ */
332
+ formatToHump(value) {
333
+ return value.replace(/\_(\w)/g, (_, letter) => letter.toUpperCase());
334
+ },
335
+
336
+ /**
337
+ * 字符串驼峰转下划线
338
+ * @param {String} value
339
+ */
340
+ formatToLine(value) {
341
+ return value.replace(/([A-Z])/g, "_$1").toLowerCase();
342
+ },
343
+
344
+ initUserInfo() {
345
+ return this.$http({
346
+ url: USER_PREFIX + "/user/currentUser",
347
+ method: "post",
348
+ // isLoading: true,
349
+ // loadingTarget: document.body,
350
+ modalStrictly: true,
351
+ success: (res) => {
352
+ let userInfo = res.objx;
353
+ let row = this.formatHumpLineTransfer(userInfo, "toLine");
354
+ this.userInfo = row;
355
+ },
356
+ });
357
+ },
358
+ initSaleOrgData() {
359
+ if (this.$store.getters.userId) {
360
+ return this.$http({
361
+ url: USER_PREFIX + "/user/getUserSaleOrg",
362
+ method: `post`,
363
+ data: { id: this.$store.getters.userId },
364
+ // isLoading: true,
365
+ // loadingTarget: document.body,
366
+ modalStrictly: true,
367
+ success: (res) => {
368
+ let rows = res.objx || [];
369
+ this.userSaleOrgDTOs = rows;
370
+
371
+ let companyCode = this.$store.getters.companyCode;
372
+ let row2s = rows.filter((row) => row.companyCode === companyCode);
373
+ this.userSaleOrgDTO2s = row2s;
374
+ this.defaultUserSaleOrgDTO = row2s.find((item) => item.defaults);
375
+ },
376
+ });
377
+ }
378
+ },
379
+ initUserRoleData() {
380
+ if (this.$store.getters.userId) {
381
+ return this.$http({
382
+ url: USER_PREFIX + "/user/getUserRole",
383
+ method: `post`,
384
+ data: { id: this.$store.getters.userId },
385
+ // isLoading: true,
386
+ // loadingTarget: document.body,
387
+ modalStrictly: true,
388
+ success: (res) => {
389
+ let rows = res.objx || [];
390
+ this.userRoleDTOs = rows;
391
+
392
+ let companyCode = this.$store.getters.companyCode;
393
+ this.userRoleDTO2s = rows.filter(
394
+ (row) => row.companyCode === companyCode
395
+ );
396
+ },
397
+ });
398
+ }
399
+ },
400
+ initBdService() {
401
+ return this.$http({
402
+ url: USER_PREFIX + "/form_develop/getBdService",
403
+ method: `post`,
404
+ data: {},
405
+ // isLoading: true,
406
+ // loadingTarget: document.body,
407
+ modalStrictly: true,
408
+ success: (res) => {
409
+ this.bdService = res.objx;
410
+ },
411
+ });
412
+ },
413
+ getUserInfo() {
414
+ return this.userInfo;
415
+ },
416
+ getUserSaleOrgDTOs() {
417
+ return this.userSaleOrgDTO2s;
418
+ },
419
+ getUserRoleDTOs() {
420
+ return this.userRoleDTO2s;
421
+ },
422
+ getDefaultUserSaleOrgDTO() {
423
+ return this.defaultUserSaleOrgDTO;
424
+ },
425
+ getSaleOrgDTOs() {
426
+ return this.userSaleOrgDTO2s.map((item) => {
427
+ return {
428
+ id: item.saleOrgId,
429
+ sn: item.sn,
430
+ name: item.saleOrgName,
431
+ companyCode: item.companyCode,
432
+ companyName: item.companyName,
433
+ };
434
+ });
435
+ },
436
+ getRoleDTOs() {
437
+ return this.userRoleDTO2s.map((item) => {
438
+ return {
439
+ id: item.roleId,
440
+ code: item.roleCode,
441
+ name: item.roleName,
442
+ companyCode: item.companyCode,
443
+ companyName: item.companyName,
444
+ };
445
+ });
446
+ },
447
+ getDefaultSaleOrgDTO() {
448
+ let item = this.defaultUserSaleOrgDTO;
449
+ return item
450
+ ? {
451
+ id: item.saleOrgId,
452
+ sn: item.sn,
453
+ name: item.saleOrgName,
454
+ companyCode: item.companyCode,
455
+ companyName: item.companyName,
456
+ }
457
+ : null;
458
+ },
459
+ handleShowContent(callback) {
460
+ // this.buildFormModel(!this.formJsonObj ? null : this.formJsonObj.widgetList);
461
+ this.showFormContent = true;
462
+ this.$nextTick(() => {
463
+ this.handleShowHideRule();
464
+ callback && callback();
465
+ });
466
+ },
467
+ hasConfig(widget, configName) {
468
+ if (!widget) return false;
469
+ let originalWidget = null;
470
+ if (!!widget.category) {
471
+ originalWidget = this.getContainerByType(widget.type);
472
+ } else {
473
+ originalWidget = this.getFieldWidgetByType(widget.type);
474
+ }
475
+
476
+ if (!originalWidget || !originalWidget.options) {
477
+ return false;
478
+ }
479
+
480
+ return Object.keys(originalWidget.options).indexOf(configName) > -1;
481
+ },
482
+ loopHandleAllWidget(callback) {
483
+ let columnLoopDo = (t, e) => {
484
+ if (t.children && t.children.length) {
485
+ t.children.forEach((item) => {
486
+ columnLoopDo(item);
487
+ });
488
+ } else {
489
+ if (t.widget) {
490
+ callback && callback(t.widget);
491
+ }
492
+ if (t.editWidget) {
493
+ callback && callback(t.editWidget);
494
+ }
495
+ if (t.widgetList && t.widgetList.length) {
496
+ loopHandleWidget(t.widgetList, (widget) => {
497
+ callback && callback(widget);
498
+ });
499
+ }
500
+ }
501
+ };
502
+ loopHandleWidget(this.formJson.widgetList, (widget, parentWidget) => {
503
+ if (callback) {
504
+ callback(widget);
505
+ if (widget.type == "data-table") {
506
+ widget.options.tableColumns.forEach((item) => {
507
+ columnLoopDo(item);
508
+ });
509
+ }
510
+ }
511
+ });
512
+ },
513
+ handleAllTableColumnWidget() {
514
+ traverseAllWidgetsNew(this.formJson.widgetList, (widget) => {
515
+ //修复data-table旧数据表格列widget与editWidget为空的问题
516
+ if (widget.type == "data-table") {
517
+ this.handleTableColumnWidget(widget);
518
+ }
519
+ });
520
+ },
521
+ handleTableColumnWidget(widget) {
522
+ //修复data-table旧数据表格列widget与editWidget为空的问题
523
+ if (
524
+ !widget ||
525
+ widget.type != "data-table" ||
526
+ !widget.options.tableColumns
527
+ )
528
+ return;
529
+ let columnLoopDo = (t, e) => {
530
+ if(t.filterable===null || t.filterable===undefined) t.filterable = true;
531
+ if (t.children && t.children.length) {
532
+ for (let item of t.children) {
533
+ columnLoopDo(item);
534
+ }
535
+ } else {
536
+ let type1 = columnFormatMap[t.formatS];
537
+ if (type1) {
538
+ if (!t.widget) {
539
+ let fieldWidget = this.getColumnWidget(t, false);
540
+ t.widget = fieldWidget;
541
+ }
542
+ if (t.widget) t.widget.columnType = t.formatS;
543
+ }
544
+ let type2 = columnFormatMap[t.editFormatS];
545
+ if (type2) {
546
+ if (!t.editWidget) {
547
+ let fieldWidget = this.getColumnWidget(t, true);
548
+ t.editWidget = fieldWidget;
549
+ }
550
+ if (t.editWidget) t.editWidget.columnType = t.editFormatS;
551
+ }
552
+
553
+ /* let type1 = columnFormatMap[t.formatS];
554
+ if (type1 && t.columnOption && !t.widget) {
555
+ let fieldWidget = this.copyNewFieldWidget(
556
+ this.getFieldWidgetByType(type1)
557
+ );
558
+ fieldWidget.options = t.columnOption;
559
+ t.widget = fieldWidget;
560
+ }
561
+ if (t.widget) t.widget.columnType = t.formatS
562
+
563
+ let type2 = columnFormatMap[t.editFormatS];
564
+ if (type2 && t.editColumnOption && !t.editWidget) {
565
+ let fieldWidget = this.copyNewFieldWidget(
566
+ this.getFieldWidgetByType(type2)
567
+ );
568
+ fieldWidget.options = t.editColumnOption;
569
+ t.editWidget = fieldWidget;
570
+ }
571
+ if (t.editWidget) t.editWidget.columnType = t.editFormatS */
572
+ }
573
+ };
574
+
575
+ for (let item of widget.options.tableColumns) {
576
+ columnLoopDo(item);
577
+ }
578
+ /*widget.options.tableColumns.forEach(item => {
579
+ columnLoopDo(item)
580
+ })*/
581
+ },
582
+ hanldeCommonWidget2() {
583
+ let wfParam = this.wfParam || {};
584
+ let wfInfo = wfParam?.wfInfo;
585
+ let taskDefinitionKey = wfInfo?.taskDefinitionKey;
586
+ let toModify = wfInfo?.toModify || false; //后台返回流程可以修改单据
587
+
588
+ let hasModifyItem = false;
589
+ let saveButton;
590
+ let saveButtonOptions;
591
+ let bdService = this.bdService;
592
+
593
+ let widgetEditOnWf = this.hanldeWfWidgetNew0(); //是否有流程时,当前用户特定流程节点是否可全局可编辑
594
+ this.widgetEditOnWf = widgetEditOnWf;
595
+
596
+ traverseAllWidgetsNew(this.formJson.widgetList, (widget) => {
597
+ //修复data-table旧数据表格列widget与editWidget为空的问题
598
+ this.handleTableColumnWidget(widget);
599
+
600
+ //处理组件显隐规则
601
+ this.handleWidgetShowRule(widget);
602
+ if (wfParam.hasWf) {
603
+ if (!widgetEditOnWf) {
604
+ //有流程,且不匹配流程节点可编辑表单设置信息
605
+ //设置组件的有流程可编辑,有流程隐藏
606
+ this.hanldeWfWidgetNew1(widget);
607
+ if (wfInfo.taskStep == "9999") {
608
+ this.hanldeWfWidgetItemNew(widget);
609
+ } else if (toModify) {
610
+ //后台返回流程可以修改单据
611
+ //设置组件的特定流程节点的可编辑,仅显示,隐藏
612
+ if (taskDefinitionKey) {
613
+ // this.hanldeWfWidgetNew2(widget)
614
+ this.hanldeWfWidgetItemNew(widget);
615
+ }
616
+ if (
617
+ widget.formItemFlag &&
618
+ !widget.options.hidden &&
619
+ !widget.options.disbaled
620
+ ) {
621
+ //存在存在可以编辑输入框框
622
+ hasModifyItem = true;
623
+ }
624
+ }
625
+ }
626
+ }
627
+ });
628
+
629
+ this.wfModifyEnabled = hasModifyItem;
630
+ },
631
+ getIsSaveAtWfAgree() {
632
+ //流程通过的时候是否可以执行保存
633
+ let wfParam = this.wfParam || {};
634
+ let wfInfo = wfParam?.wfInfo;
635
+ let toModify = wfInfo?.toModify;
636
+ let result = false;
637
+
638
+ let formConfig = this.formConfig;
639
+ if (toModify && formConfig.wfAgreenBindSave) {
640
+ let modelKey = wfInfo.modelKey;
641
+ let modelOrders = wfInfo.orders;
642
+ let companyCode = this.$store.getters.companyCode;
643
+ let taskStep = (wfInfo.taskStep ?? "") + "";
644
+ let taskDefinitionKey = wfInfo.taskDefinitionKey;
645
+ let bdService = this.bdService;
646
+
647
+ let wfConfigData = formConfig.wfAgreeConfigData || [];
648
+ let flag = false;
649
+ wfConfigData.forEach((item) => {
650
+ let type = item.type;
651
+ let taskStepList = item.taskSteps ? item.taskSteps.split(",") : [];
652
+ if (taskStepList.includes(taskStep)) {
653
+ let companyCodeStr = item.companyCodes;
654
+ let companyCodes = companyCodeStr
655
+ ? companyCodeStr.split(",").filter((item) => !!item)
656
+ : [];
657
+ let flag1 = !item.serveName || item.serveName == bdService;
658
+ // let flag2 = !item.modelKey || item.modelKey == modelKey;
659
+ let flag2 =
660
+ item.modelOrders === undefined ||
661
+ item.modelOrders === null ||
662
+ item.modelOrders === modelOrders;
663
+ let flag3 =
664
+ !companyCodes.length || companyCodes.includes(companyCode);
665
+ if (flag1 && flag2 && flag3) {
666
+ //可编辑
667
+ result = true;
668
+ }
669
+ }
670
+ });
671
+ return result;
672
+ }
673
+ },
674
+
675
+ hanldeWfWidgetNew0() {
676
+ let wfParam = this.wfParam || {};
677
+ let wfInfo = wfParam?.wfInfo;
678
+ let toModify = wfInfo?.toModify;
679
+ let result = false;
680
+
681
+ let formConfig = this.formConfig;
682
+ if (toModify && formConfig.wfConfigDataEnabled) {
683
+ let modelKey = wfInfo.modelKey;
684
+ let modelOrders = wfInfo.orders;
685
+ let companyCode = this.$store.getters.companyCode;
686
+ let taskStep = (wfInfo.taskStep ?? "") + "";
687
+ let taskDefinitionKey = wfInfo.taskDefinitionKey;
688
+ let bdService = this.bdService;
689
+
690
+ let wfConfigData = formConfig.wfConfigData || [];
691
+ let flag = false;
692
+ wfConfigData.forEach((item) => {
693
+ let type = item.type;
694
+ let taskStepList = item.taskSteps ? item.taskSteps.split(",") : [];
695
+ if (taskStepList.includes(taskStep)) {
696
+ let companyCodeStr = item.companyCodes;
697
+ let companyCodes = companyCodeStr
698
+ ? companyCodeStr.split(",").filter((item) => !!item)
699
+ : [];
700
+ let flag1 = !item.serveName || item.serveName == bdService;
701
+ // let flag2 = !item.modelKey || item.modelKey == modelKey;
702
+ let flag2 =
703
+ item.modelOrders === undefined ||
704
+ item.modelOrders === null ||
705
+ item.modelOrders === modelOrders;
706
+ let flag3 =
707
+ !companyCodes.length || companyCodes.includes(companyCode);
708
+ if (flag1 && flag2 && flag3) {
709
+ //可编辑
710
+ result = true;
711
+ }
712
+ }
713
+ });
714
+ return result;
715
+ }
716
+ },
717
+ getIsfreeWidgetTypesOfWf(widget) {
718
+ if (!widget) return false;
719
+ let widgetType = widget.type;
720
+ let sourceType = widget.sourceType;
721
+ let result =
722
+ freeWidgetTypesOfWf.includes(widgetType) ||
723
+ (sourceType && freeWidgetTypesOfWf.includes(sourceType));
724
+ return widget.options.label == "重置" || result;
725
+ },
726
+ getIsHiddenWidgetTypesOfWf(widget) {
727
+ if (!widget) return false;
728
+ let widgetType = widget.type;
729
+ let targetType = widget.targetType;
730
+ let result =
731
+ hiddenWidgetTypesOfWf.includes(widgetType) ||
732
+ (targetType && hiddenWidgetTypesOfWf.includes(targetType));
733
+ return result;
734
+ },
735
+ hanldeWfWidgetNew1(widget) {
736
+ if (!widget) return;
737
+ let flag =
738
+ widget.columnType &&
739
+ ["editDelete", "removeTreeRow"].includes(widget.columnType);
740
+ if (!flag && this.getIsfreeWidgetTypesOfWf(widget)) return; //过滤掉不受限组件
741
+ if (this.widgetEditOnWf) return; //匹配到流程第一步可编辑,不执行下面禁用隐藏
742
+ let wfParam = this.wfParam || {};
743
+ if (!wfParam.hasWf) return; //过滤掉没流程
744
+
745
+ if (flag) {
746
+ //数据表格列的删除标识,有流程隐藏
747
+ widget.options.hidden = true;
748
+ } else if (this.getIsHiddenWidgetTypesOfWf(widget)) {
749
+ //有流程隐藏的组件,button
750
+ widget.options.hidden = true;
751
+ } else if (widget.formItemFlag) {
752
+ //有流程禁用,编辑输入框
753
+ widget.options.disabled = true;
754
+ }
755
+ },
756
+ hanldeWfWidgetNew2(widget, callback) {
757
+ let hasModifyItem = false;
758
+ let saveButton;
759
+ if (!this.widgetEditOnWf) {
760
+ let flag = this.hanldeWfWidgetItemNew(widget);
761
+ if (flag) {
762
+ hasModifyItem = true;
763
+ }
764
+ }
765
+
766
+ if (widget?.options?.saveButton) {
767
+ saveButton = widget;
768
+ }
769
+ callback && callback(hasModifyItem, saveButton);
770
+ },
771
+ hanldeWfWidgetItemNew(widget) {
772
+ let hasModifyItem = false;
773
+ // let widget = target.field || target.widget;
774
+ let wfEdit = widget?.options.wfEdit;
775
+
776
+ let bdService = this.bdService;
777
+ let wfParam = this.wfParam;
778
+ let wfInfo = wfParam.wfInfo;
779
+ let modelKey = wfInfo.modelKey;
780
+ let modelOrders = wfInfo.orders;
781
+ let companyCode = this.$store.getters.companyCode;
782
+ let taskStep = (wfInfo.taskStep ?? "") + "";
783
+
784
+ let handleWfConfigData = (widget, columnOptions) => {
785
+ let options = widget?.options || columnOptions;
786
+ if (!options || !options.wfEdit) return;
787
+ let wfConfigData = options.wfConfigData || [];
788
+ let flag = false;
789
+
790
+ wfConfigData.forEach((item) => {
791
+ let type = item.type;
792
+ let taskStepList = item.taskSteps ? item.taskSteps.split(",") : [];
793
+ if (type && taskStepList.includes(taskStep)) {
794
+ let companyCodeStr = item.companyCodes;
795
+ let companyCodes = companyCodeStr
796
+ ? companyCodeStr.split(",").filter((item) => !!item)
797
+ : [];
798
+ let flag1 = !item.serveName || item.serveName == bdService;
799
+ // let flag2 = !item.modelKey || item.modelKey == modelKey;
800
+
801
+ let flag2 =
802
+ item.modelOrders === undefined ||
803
+ item.modelOrders === null ||
804
+ item.modelOrders === modelOrders;
805
+ let flag3 =
806
+ !companyCodes.length || companyCodes.includes(companyCode);
807
+ if (flag1 && flag2 && flag3) {
808
+ if (type === 1) {
809
+ //可编辑
810
+ hasModifyItem = true;
811
+ if (options.disabled !== undefined) options.disabled = false;
812
+ // target.setDisabled && target.setDisabled(false);
813
+ // target.setHidden(false);
814
+ options.hidden = false;
815
+ flag = true;
816
+ } /* else if (type === 2) {
817
+ //仅显示
818
+ // target.setDisabled && target.setDisabled(true);
819
+ if (options.disabled !== undefined) options.disabled = true;
820
+ // target.setHidden(false);
821
+ options.hidden = false;
822
+ flag = true;
823
+ } else if (type === 3) {
824
+ // target.setHidden(true);
825
+ options.hidden = true;
826
+ flag = true;
827
+ }*/
828
+ }
829
+ }
830
+ });
831
+ /*if (flag && e && widget.type == 'baseAttachment') {
832
+ e.initOption();
833
+ }*/
834
+ };
835
+ handleWfConfigData(widget);
836
+ return hasModifyItem;
837
+ },
838
+
839
+ hanldeCommonWidget() {
840
+ loopHandleWidget(this.formJson.widgetList, (widget) => {
841
+ //处理组件显隐规则
842
+ this.handleWidgetShowRule(widget);
843
+ });
844
+ },
845
+ handleWidgetShowRule(widget) {
846
+ if (widget) {
847
+ let optionModel = widget.options;
848
+ if (optionModel.widgetShowRuleEnabled) {
849
+ let companyCode = this.$store.getters.companyCode;
850
+ let bdService = this.bdService;
851
+ let userRoleDTOs = this.userRoleDTOs;
852
+ let userRoleCodes = userRoleDTOs.map((item) => item.roleCode);
853
+
854
+ let widgetShowRuleConfig = optionModel.widgetShowRuleConfig || [];
855
+ if (widgetShowRuleConfig.length) {
856
+ let item1 = null; //匹配服务+组织
857
+ let item2 = null; //匹配服务
858
+ let item3 = null; //匹配所有服务和组织
859
+ widgetShowRuleConfig.forEach((item) => {
860
+ let serveName = item.serveName ?? null;
861
+
862
+ // let flag1 = item.serveType === 5;//所有组织和服务
863
+ let flag1 = !item.serveName && !item.companyCodes; //所有组织和服务
864
+
865
+ //匹配服务名
866
+ let flag2 = serveName === bdService;
867
+
868
+ //匹配组织编码
869
+ let companyCodeStr = item.companyCodes;
870
+ let companyCodes = companyCodeStr
871
+ ? companyCodeStr.split(",").filter((item) => !!item)
872
+ : [];
873
+ let flag3 =
874
+ !companyCodes.length || companyCodes.includes(companyCode);
875
+ if (flag1) {
876
+ item3 = item;
877
+ } else if (flag2) {
878
+ if (companyCodes.length) {
879
+ if (companyCodes.includes(companyCode)) {
880
+ item1 = item;
881
+ }
882
+ } else {
883
+ item2 = item;
884
+ }
885
+ }
886
+ });
887
+ let showRuleItem = item1 || item2 || item3 || null;
888
+ if (showRuleItem) {
889
+ //匹配角色
890
+ let roleCodeStr = showRuleItem.roleCodes;
891
+ let roleCodes = roleCodeStr
892
+ ? roleCodeStr.split(",").filter((item) => !!item)
893
+ : [];
894
+ let flag = userRoleCodes.some((roleCode) =>
895
+ roleCodes.includes(roleCode)
896
+ );
897
+ if (showRuleItem.type == 1) {
898
+ //符合条件的角色显示,否则隐藏
899
+ optionModel.hidden = flag ? false : true;
900
+ } else if (showRuleItem.type == 2) {
901
+ //符合条件的角色隐藏,否则显示
902
+ optionModel.hidden = flag ? true : false;
903
+ }
904
+ }
905
+ }
906
+ }
907
+ return optionModel.hidden;
908
+ }
909
+ },
910
+ hanldeWfWidget() {
911
+ let wfParam = this.wfParam || {};
912
+ if (!wfParam.hasWf) return;
913
+ let refList = this.widgetRefList;
914
+
915
+ let toDo2 = (widget, options, e) => {
916
+ // let widget = options ? null : (target.field || target.widget);
917
+ let isWfFlag = options ? true : this.hasConfig(widget, "wfFlag");
918
+ let widgetType = widget?.type;
919
+ let enabledByWf = options
920
+ ? options.enabledByWf
921
+ : widget?.options?.enabledByWf;
922
+ let hiddenByWf = options
923
+ ? options.hiddenByWf
924
+ : widget?.options?.hiddenByWf;
925
+ let widgetName = options ? options.name : widget?.options?.name;
926
+ if (isWfFlag) {
927
+ if (this.hasConfig(widget, "disabled") || !!options) {
928
+ let disabled = null;
929
+ if (!enabledByWf) {
930
+ disabled = true;
931
+ // setDisabled(target,true);
932
+ let onClick = options ? options.onClick : widget.options.onClick;
933
+ if (
934
+ onClick &&
935
+ onClick.startsWith("this.getFormRef().$baseReload()")
936
+ ) {
937
+ // setDisabled(target,false);
938
+ disabled = false;
939
+ }
940
+ } else {
941
+ // setDisabled(target,false);
942
+ disabled = false;
943
+ }
944
+ if (widgetType == "reset_button" && enabledByWf === undefined) {
945
+ // setDisabled(target,false)
946
+ disabled = false;
947
+ }
948
+ if (disabled !== null) {
949
+ if (options) {
950
+ options.disabled = disabled;
951
+ } else {
952
+ widget.options.disabled = disabled;
953
+ }
954
+ }
955
+ }
956
+
957
+ let hidden = null;
958
+ if (hiddenByWf) {
959
+ // setHidden(target,true);
960
+ // widget.options.hidden = true;
961
+ hidden = true;
962
+ }
963
+ if (
964
+ widget &&
965
+ widgetType == "save_button" &&
966
+ hiddenByWf === undefined
967
+ ) {
968
+ // setHidden(target,true)
969
+ // widget.options.hidden = true;
970
+ hidden = true;
971
+ }
972
+ if (hidden !== null) {
973
+ if (options) {
974
+ options.hidden = hidden;
975
+ } else {
976
+ widget.options.hidden = hidden;
977
+ }
978
+ }
979
+ }
980
+
981
+ if (widget?.type == "data-table") {
982
+ let loopDo = (t, e) => {
983
+ if (t.children && t.children.length) {
984
+ t.children.forEach((item) => {
985
+ loopDo(item);
986
+ });
987
+ } else {
988
+ if (t.columnOption) {
989
+ toDo2(null, t.columnOption);
990
+ }
991
+ }
992
+ };
993
+ widget.options.tableColumns.forEach((item) => {
994
+ loopDo(item);
995
+ loopHandleWidget(item.widgetList, (item1) => {
996
+ toDo2(item1);
997
+ });
998
+ });
999
+ }
1000
+ /*if (target && widgetType == 'baseAttachment') {
1001
+ target.initOption();
1002
+ }*/
1003
+ };
1004
+
1005
+ loopHandleWidget(this.formJson.widgetList, (widget) => {
1006
+ //有流程,处理禁用状态
1007
+ let formItemFlag = widget?.formItemFlag;
1008
+ if (formItemFlag) {
1009
+ widget.options.disabled = true;
1010
+ }
1011
+ toDo2(widget);
1012
+ });
1013
+ },
1014
+ hanldeWfWidget2() {
1015
+ let wfParam = this.wfParam;
1016
+ if (!wfParam.hasWf) return;
1017
+ let wfInfo = wfParam.wfInfo;
1018
+ let modelKey = wfInfo.modelKey;
1019
+ let companyCode = this.$store.getters.companyCode;
1020
+ let taskStep = (wfInfo.taskStep ?? "") + "";
1021
+ let taskDefinitionKey = wfInfo.taskDefinitionKey;
1022
+ if (!taskDefinitionKey) return;
1023
+ let toModify = wfInfo.toModify;
1024
+ if (!toModify) return;
1025
+
1026
+ let hasModifyItem = false;
1027
+ let refList = this.widgetRefList;
1028
+ let saveButton;
1029
+ let saveButtonOptions;
1030
+ let bdService = this.bdService;
1031
+
1032
+ loopHandleWidget(this.formJson.widgetList, (widget) => {
1033
+ let flag = this.hanldeWfWidgetItem(widget);
1034
+ if (!hasModifyItem && flag) {
1035
+ hasModifyItem = true;
1036
+ }
1037
+ if (!saveButtonOptions && widget?.options?.saveButton) {
1038
+ saveButtonOptions = widget?.options;
1039
+ }
1040
+ });
1041
+
1042
+ if (hasModifyItem) {
1043
+ if (saveButtonOptions) {
1044
+ saveButtonOptions.disabled = false;
1045
+ saveButtonOptions.hidden = false;
1046
+ }
1047
+ }
1048
+ },
1049
+ hanldeWfWidgetItem(widget) {
1050
+ let hasModifyItem = false;
1051
+ // let widget = target.field || target.widget;
1052
+ let wfEdit = widget?.options.wfEdit;
1053
+
1054
+ let bdService = this.bdService;
1055
+ let wfParam = this.wfParam;
1056
+ let wfInfo = wfParam.wfInfo;
1057
+ let modelKey = wfInfo.modelKey;
1058
+ let companyCode = this.$store.getters.companyCode;
1059
+ let taskStep = (wfInfo.taskStep ?? "") + "";
1060
+
1061
+ let handleWfConfigData = (widget, columnOptions) => {
1062
+ let options = widget?.options || columnOptions;
1063
+ if (!options || !options.wfEdit) return;
1064
+ let wfConfigData = options.wfConfigData || [];
1065
+ let flag = false;
1066
+ wfConfigData.forEach((item) => {
1067
+ let type = item.type;
1068
+ let taskStepList = item.taskSteps ? item.taskSteps.split(",") : [];
1069
+ if (type && taskStepList.includes(taskStep)) {
1070
+ let companyCodeStr = item.companyCodes;
1071
+ let companyCodes = companyCodeStr
1072
+ ? companyCodeStr.split(",").filter((item) => !!item)
1073
+ : [];
1074
+ let flag1 = !item.serveName || item.serveName == bdService;
1075
+ let flag2 = !item.modelKey || item.modelKey == modelKey;
1076
+ let flag3 =
1077
+ !companyCodes.length || companyCodes.includes(companyCode);
1078
+ if (flag1 && flag2 && flag3) {
1079
+ if (type === 1) {
1080
+ //可编辑
1081
+ hasModifyItem = true;
1082
+ if (options.disabled !== undefined) options.disabled = false;
1083
+ // target.setDisabled && target.setDisabled(false);
1084
+ // target.setHidden(false);
1085
+ options.hidden = false;
1086
+ flag = true;
1087
+ } else if (type === 2) {
1088
+ //仅显示
1089
+ // target.setDisabled && target.setDisabled(true);
1090
+ if (options.disabled !== undefined) options.disabled = true;
1091
+ // target.setHidden(false);
1092
+ options.hidden = false;
1093
+ flag = true;
1094
+ } else if (type === 3) {
1095
+ // target.setHidden(true);
1096
+ options.hidden = true;
1097
+ flag = true;
1098
+ }
1099
+ }
1100
+ }
1101
+ });
1102
+ /*if (flag && e && widget.type == 'baseAttachment') {
1103
+ e.initOption();
1104
+ }*/
1105
+ };
1106
+ handleWfConfigData(widget);
1107
+ if (widget.type == "data-table") {
1108
+ let loopDo = (t) => {
1109
+ if (t.children && t.children.length) {
1110
+ t.children.forEach((item) => {
1111
+ loopDo(item);
1112
+ });
1113
+ } else {
1114
+ if (t.columnOption) {
1115
+ handleWfConfigData(null, t.columnOption);
1116
+ }
1117
+ }
1118
+ };
1119
+
1120
+ widget.options.tableColumns.forEach((item) => {
1121
+ loopDo(item);
1122
+ loopHandleWidget(item.widgetList, (item1) => {
1123
+ handleWfConfigData(item1);
1124
+ });
1125
+ });
1126
+ }
1127
+
1128
+ return hasModifyItem;
1129
+ },
1130
+ loadFormData(options) {
1131
+ let config = options.config || {}
1132
+ let that = this;
1133
+ let formConfig = this.formConfig;
1134
+ let entity = formConfig.entity;
1135
+ let dataId = this.dataId;
1136
+ let reportTemplate = this.reportTemplate;
1137
+ let scriptCode = formConfig.formScriptCode || "getOne";
1138
+
1139
+ let formData = {};
1140
+ if (scriptCode) {
1141
+ let formCode = reportTemplate.formCode;
1142
+
1143
+ let formScriptParam = this.handleCustomEvent(
1144
+ this.formConfig.formScriptParam
1145
+ );
1146
+
1147
+ let defaultOption = {
1148
+ addCreateInfo: true,
1149
+ queryCreateInfo:
1150
+ window.$vueRoot.$store.getters.queryCreateInfo || "0",
1151
+ };
1152
+ return this.formHttp({
1153
+ // url: "/" + reportTemplate.serviceName + "/form_ins/getOne",
1154
+ scriptCode: scriptCode,
1155
+ data: {
1156
+ formCode: formCode,
1157
+ formVersion: reportTemplate.formVersion,
1158
+ taBm: entity,
1159
+ data: {
1160
+ id: dataId,
1161
+ ...formScriptParam,
1162
+ },
1163
+ },
1164
+ ...defaultOption,
1165
+ success: (res) => {
1166
+ formData = res.objx || {};
1167
+ this.setFormData(formData);
1168
+ options.callback && options.callback(formData);
1169
+ },
1170
+ ...config,
1171
+ });
1172
+ }
1173
+ },
1174
+ loadDefaultEntityData(callback) {
1175
+ let that = this;
1176
+ let formConfig = this.formConfig;
1177
+ // let isLoadEntity = formConfig.isLoadEntity;
1178
+ let entity = formConfig.entity;
1179
+ let wfEnabled = formConfig.wfEnabled || false;
1180
+ let dataId = this.dataId;
1181
+ let reportTemplate = this.reportTemplate;
1182
+ let scriptCode = formConfig.formScriptCode || "getOne";
1183
+
1184
+ let formData = {};
1185
+ let wfConfig = null;
1186
+ if (entity && dataId && scriptCode) {
1187
+ let formCode = reportTemplate.formCode;
1188
+ let otherParam = {};
1189
+ if (wfEnabled) {
1190
+ let wfCode = reportTemplate.objTypeCode;
1191
+ wfConfig = (res) => {
1192
+ let wfConfig1 = null;
1193
+ let callback1 = null;
1194
+ if (formConfig.wfConfig) {
1195
+ let formData = res.objx;
1196
+ let e = new Function(
1197
+ "formCode",
1198
+ "dataId",
1199
+ "formData",
1200
+ formConfig.wfConfig
1201
+ );
1202
+ wfConfig1 = e.call(this, formCode, dataId, formData);
1203
+ callback1 = wfConfig1?.callback;
1204
+ delete wfConfig1?.callback;
1205
+ }
1206
+
1207
+ let option = {
1208
+ objId: dataId, //单据ID
1209
+ wfCode: wfCode, //流程编码
1210
+ showStartBtn: true, //是否放出启动按钮,流程已启动时此参数失效
1211
+ showWfFold: true,
1212
+ formCode: formCode,
1213
+ callback: (wfParam) => {
1214
+ this.setFormData(formData);
1215
+
1216
+ let { hasWf } = wfParam;
1217
+ this.hasWf = hasWf;
1218
+ this.wfParam = wfParam;
1219
+
1220
+ /*if (hasWf) {
1221
+ this.hanldeWfWidget();
1222
+ this.hanldeWfWidget2();
1223
+ }*/
1224
+ this.hanldeCommonWidget2(); //处理组件显隐,可编辑
1225
+
1226
+ this.showFormContent = true;
1227
+ this.$nextTick(() => {
1228
+ this.handleShowHideRule();
1229
+ /*if (hasWf) {
1230
+
1231
+ }*/
1232
+ setTimeout(() => {
1233
+ callback && callback();
1234
+ callback1 && callback1(wfParam);
1235
+ }, 1000);
1236
+ wfParam.done();
1237
+ });
1238
+ },
1239
+ };
1240
+ if (formConfig.wfStartBindSave) {
1241
+ //启用流程启动自动保存
1242
+ option.onStart = (done) => {
1243
+ let formRef = this.getFormRef ? this.getFormRef() : this;
1244
+ formRef.validate((valid) => {
1245
+ if (valid) {
1246
+ done();
1247
+ }
1248
+ });
1249
+ };
1250
+ option.onBeforeStartSubmit = (done) => {
1251
+ this.saveDefaultHandle({
1252
+ config: {
1253
+ successMsg: false,
1254
+ isConfirm: false,
1255
+ success: (res) => {
1256
+ done();
1257
+ },
1258
+ },
1259
+ });
1260
+ };
1261
+ }
1262
+
1263
+ if (formConfig.wfAgreenBindSave) {
1264
+ //流程通过的时候,是否自动保存单据
1265
+ option.onClickAgree = (done) => {
1266
+ if (that.getIsSaveAtWfAgree()) {
1267
+ let formRef = this.getFormRef ? this.getFormRef() : this;
1268
+ formRef.validate((valid) => {
1269
+ if (valid) {
1270
+ done();
1271
+ }
1272
+ });
1273
+ } else {
1274
+ done();
1275
+ }
1276
+ };
1277
+ option.onBeforeAgree = (done) => {
1278
+ if (that.getIsSaveAtWfAgree()) {
1279
+ this.saveDefaultHandle({
1280
+ config: {
1281
+ successMsg: false,
1282
+ isConfirm: false,
1283
+ success: (res) => {
1284
+ done();
1285
+ },
1286
+ },
1287
+ });
1288
+ } else {
1289
+ done();
1290
+ }
1291
+ };
1292
+ }
1293
+
1294
+ let resOption = option;
1295
+ if (wfConfig1) {
1296
+ resOption = extendDeeply(resOption, wfConfig1);
1297
+ }
1298
+ return resOption;
1299
+ };
1300
+ }
1301
+ return this.loadFormData({
1302
+ config:{
1303
+ sync: false,
1304
+ wfConfig,
1305
+ success: (res) => {
1306
+ formData = res.objx || {};
1307
+ // this.currentFormData = res.objx || {};
1308
+ if (!wfConfig) {
1309
+ this.hanldeCommonWidget2(); //处理组件显隐,可编辑
1310
+ this.setFormData(formData);
1311
+ this.showFormContent = true;
1312
+ this.$nextTick(() => {
1313
+ this.handleShowHideRule();
1314
+ callback && callback();
1315
+ });
1316
+ }
1317
+ }
1318
+ }
1319
+ });
1320
+ } else {
1321
+ this.hanldeCommonWidget2(); //处理组件显隐,可编辑
1322
+ this.handleShowContent();
1323
+ }
1324
+ },
1325
+ handleShowHideRule() {
1326
+ return;
1327
+ let userId = this.$store.getters.userId;
1328
+ let userSaleOrgDTOs = this.userSaleOrgDTOs;
1329
+ let userRoleDTOs = this.userRoleDTOs;
1330
+ let saleOrgIds = userSaleOrgDTOs.map((item) => item.saleOrgId);
1331
+ let roleIds = userRoleDTOs.map((item) => item.roleId);
1332
+ let refList = this.widgetRefList;
1333
+ for (let key in refList) {
1334
+ let target = refList[key];
1335
+ let widget = target.field || target.widget;
1336
+ if (widget?.options?.showRuleEnabled) {
1337
+ let showRules = widget.options.showRules || [];
1338
+ showRules.forEach((showRule) => {
1339
+ let ruleType = showRule.ruleType;
1340
+ let isShow = showRule.show;
1341
+ let value = showRule.value || [];
1342
+ let valIds = value.map((item) => item.id);
1343
+ if (valIds.length) {
1344
+ let result = !widget.options.hidden;
1345
+ if (ruleType == 1) {
1346
+ result = valIds.includes(userId) ? isShow : !isShow;
1347
+ } else if (ruleType == 2) {
1348
+ result = saleOrgIds.find((item) => valIds.includes(item))
1349
+ ? isShow
1350
+ : !isShow;
1351
+ } else if (ruleType == 3) {
1352
+ result = roleIds.find((item) => valIds.includes(item))
1353
+ ? isShow
1354
+ : !isShow;
1355
+ }
1356
+ target.setHidden(!result);
1357
+ }
1358
+ });
1359
+ }
1360
+ }
1361
+ },
1362
+ initFormObject: function () {
1363
+ let e = this,
1364
+ t = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0];
1365
+ (this.formId = "vfRender" + baseRefUtil.generateId()),
1366
+ t && !this.dynamicCreation && this.insertCustomStyleAndScriptNode(),
1367
+ this.addFieldChangeEventHandler(),
1368
+ this.addFieldValidateEventHandler(),
1369
+ this.registerFormToRefList(),
1370
+ // this.handleOnCreated(),
1371
+ this.disabledMode &&
1372
+ this.$nextTick(function () {
1373
+ e.disableForm();
1374
+ });
1375
+ },
1376
+ getContainerWidgetName: function (e) {
1377
+ return "grid" === e.type ? "grid-item" : e.type + "-item";
1378
+ },
1379
+ getWidgetName: function (e) {
1380
+ return (e.targetType || e.type) + "-widget";
1381
+ },
1382
+ initLocale: function () {
1383
+ let e = localStorage.getItem("v_form_locale") || "zh-CN";
1384
+ this.changeLanguage(e);
1385
+ },
1386
+ insertCustomStyleAndScriptNode: function () {
1387
+ this.formConfig &&
1388
+ this.formConfig.cssCode &&
1389
+ baseRefUtil.insertCustomCssToHead(
1390
+ this.formConfig.cssCode,
1391
+ this.previewState ? "" : this.formId
1392
+ ),
1393
+ this.formConfig &&
1394
+ this.formConfig.functions &&
1395
+ baseRefUtil.insertGlobalFunctionsToHtml(
1396
+ this.formConfig.functions,
1397
+ this.previewState ? "" : this.formId
1398
+ );
1399
+ },
1400
+ buildFormModel: function (e) {
1401
+ let t = this;
1402
+ e &&
1403
+ e.length > 0 &&
1404
+ e.forEach(function (e) {
1405
+ t.buildDataFromWidget(e);
1406
+ });
1407
+ },
1408
+ buildDataFromWidget: function (e) {
1409
+ let t = this;
1410
+ let dataId = this.dataId;
1411
+ let currentFormData = this.currentFormData;
1412
+ let fieldKeyName = this.getFieldKeyName(e);
1413
+ let defaultValue =
1414
+ e.options.defaultValue === undefined || e.options.defaultValue === ""
1415
+ ? null
1416
+ : e.options.defaultValue;
1417
+ if ("container" === e.category) {
1418
+ if ("vf-dialog" === e.type || "vf-drawer" === e.type);
1419
+ else if ("data-table" === e.type) {
1420
+ if (!!e.widgetList && e.widgetList.length > 0) {
1421
+ e.widgetList.forEach((childItem) => {
1422
+ this.buildDataFromWidget(childItem, e);
1423
+ });
1424
+ }
1425
+ let c = currentFormData[fieldKeyName] ?? [];
1426
+ this.$set(this.formDataModel, fieldKeyName, baseRefUtil.deepClone(c));
1427
+ } else if ("list-h5" === e.type) {
1428
+ if (!!e.widgetList && e.widgetList.length > 0) {
1429
+ e.widgetList.forEach((childItem) => {
1430
+ this.buildDataFromWidget(childItem, e);
1431
+ });
1432
+ }
1433
+ } else if ("grid" === e.type)
1434
+ e.cols &&
1435
+ e.cols.length > 0 &&
1436
+ e.cols.forEach(function (e) {
1437
+ t.buildDataFromWidget(e);
1438
+ });
1439
+ else if ("table" === e.type)
1440
+ e.rows &&
1441
+ e.rows.length > 0 &&
1442
+ e.rows.forEach(function (e) {
1443
+ e.cols &&
1444
+ e.cols.length > 0 &&
1445
+ e.cols.forEach(function (e) {
1446
+ t.buildDataFromWidget(e);
1447
+ });
1448
+ });
1449
+ else if ("h5-table" === e.type)
1450
+ e.rows &&
1451
+ e.rows.length > 0 &&
1452
+ e.rows.forEach(function (e) {
1453
+ e.cols &&
1454
+ e.cols.length > 0 &&
1455
+ e.cols.forEach(function (e) {
1456
+ t.buildDataFromWidget(e);
1457
+ });
1458
+ });
1459
+ else if ("tab" === e.type)
1460
+ e.tabs &&
1461
+ e.tabs.length > 0 &&
1462
+ e.tabs.forEach(function (e) {
1463
+ e.widgetList &&
1464
+ e.widgetList.length > 0 &&
1465
+ e.widgetList.forEach(function (e) {
1466
+ t.buildDataFromWidget(e);
1467
+ });
1468
+ });
1469
+ else if ("detail" === e.type)
1470
+ e.panes &&
1471
+ e.panes.length > 0 &&
1472
+ e.panes.forEach(function (e) {
1473
+ e.widgetList &&
1474
+ e.widgetList.length > 0 &&
1475
+ e.widgetList.forEach(function (e) {
1476
+ t.buildDataFromWidget(e);
1477
+ });
1478
+ });
1479
+ else if ("sub-form" === e.type) {
1480
+ let i = e.options.name;
1481
+ if (currentFormData.hasOwnProperty(i)) {
1482
+ let n = currentFormData[i];
1483
+ this.$set(this.formDataModel, i, baseRefUtil.deepClone(n));
1484
+ } else {
1485
+ let o = {};
1486
+ e.options.showBlankRow
1487
+ ? (e.widgetList.forEach(function (e) {
1488
+ e.formItemFlag && (o[e.options.name] = defaultValue);
1489
+ }),
1490
+ this.$set(this.formDataModel, i, [o]))
1491
+ : this.$set(this.formDataModel, i, []);
1492
+ }
1493
+ } else if ("grid-sub-form" === e.type) {
1494
+ let a = e.options.name;
1495
+ if (currentFormData.hasOwnProperty(a)) {
1496
+ let l = currentFormData[a];
1497
+ this.$set(this.formDataModel, a, baseRefUtil.deepClone(l));
1498
+ } else {
1499
+ let s = [],
1500
+ r = function (e) {
1501
+ s.push(e);
1502
+ };
1503
+ baseRefUtil.traverseFieldWidgetsOfContainer(e, r);
1504
+ let d = {};
1505
+ e.options.showBlankRow
1506
+ ? (s.forEach(function (e) {
1507
+ d[e.options.name] = defaultValue;
1508
+ }),
1509
+ this.$set(this.formDataModel, a, [d]))
1510
+ : this.$set(this.formDataModel, a, []);
1511
+ }
1512
+ } else if ("detail-h5" === e.type) {
1513
+ e.panes &&
1514
+ e.panes.length > 0 &&
1515
+ e.panes.forEach(function (e) {
1516
+ t.buildDataFromWidget(e);
1517
+ });
1518
+ } else if ("h5-card" === e.type) {
1519
+ e.panes &&
1520
+ e.panes.length > 0 &&
1521
+ e.panes.forEach(function (e) {
1522
+ e.widgetList &&
1523
+ e.widgetList.length > 0 &&
1524
+ e.widgetList.forEach(function (e) {
1525
+ t.buildDataFromWidget(e);
1526
+ });
1527
+ });
1528
+ } else
1529
+ "grid-col" === e.type || e.type,
1530
+ e.widgetList &&
1531
+ e.widgetList.length > 0 &&
1532
+ e.widgetList.forEach(function (e) {
1533
+ t.buildDataFromWidget(e);
1534
+ });
1535
+ } else if ("vabsearch" === e.type) {
1536
+ let c = currentFormData[fieldKeyName];
1537
+ this.$set(this.formDataModel, fieldKeyName, baseRefUtil.deepClone(c));
1538
+ let vabSearchName = e.options.vabSearchName;
1539
+ if (vabSearchName) {
1540
+ let val = currentFormData[vabSearchName] ?? null;
1541
+ this.$set(
1542
+ this.formDataModel,
1543
+ vabSearchName,
1544
+ baseRefUtil.deepClone(val)
1545
+ );
1546
+ }
1547
+ } else if ("table2-item" === e.type) {
1548
+ this.$set(this.formDataModel, fieldKeyName, []);
1549
+ } else if (e.formItemFlag) {
1550
+ if (dataId || currentFormData.hasOwnProperty(fieldKeyName)) {
1551
+ let c = currentFormData[fieldKeyName] ?? null;
1552
+ this.$set(this.formDataModel, fieldKeyName, baseRefUtil.deepClone(c));
1553
+ } else {
1554
+ this.$set(this.formDataModel, fieldKeyName, defaultValue);
1555
+ }
1556
+ }
1557
+ },
1558
+ addFieldChangeEventHandler: function () {
1559
+ let e = this;
1560
+ this.$off("fieldChange"),
1561
+ this.$on("fieldChange", function (t, i, n, o, a) {
1562
+ e.handleFieldDataChange(t, i, n, o, a),
1563
+ e.$emit("formChange", t, i, n, e.formDataModel, o, a);
1564
+ });
1565
+ },
1566
+ addFieldValidateEventHandler: function () {
1567
+ let e = this;
1568
+ this.$off("fieldValidation"),
1569
+ this.$on("fieldValidation", function (t) {
1570
+ e.$refs.renderForm.validateField(t);
1571
+ });
1572
+ },
1573
+ registerFormToRefList: function () {
1574
+ this.widgetRefList["v_form_ref"] = this;
1575
+ },
1576
+ handleFieldDataChange: function (e, t, i, n, o) {
1577
+ if (this.formConfig && this.formConfig.onFormDataChange) {
1578
+ let a = new Function(
1579
+ "fieldName",
1580
+ "newValue",
1581
+ "oldValue",
1582
+ "formModel",
1583
+ "subFormName",
1584
+ "subFormRowIndex",
1585
+ this.formConfig.onFormDataChange
1586
+ );
1587
+ a.call(this, e, t, i, this.formDataModel, n, o);
1588
+ }
1589
+ },
1590
+
1591
+ getEventParam() {
1592
+ let dataId = this.dataId;
1593
+ let formCode = this.reportTemplate.formCode;
1594
+ return {
1595
+ eventParamNames: ["dataId", "formCode"],
1596
+ eventParamValues: [dataId, formCode],
1597
+ };
1598
+ },
1599
+ handleCustomEvent(funtionStr, eventParamNames = [], eventParamValues = []) {
1600
+ if (!this.designState && funtionStr) {
1601
+ let eventParam = this.getEventParam();
1602
+ var e = new Function(
1603
+ ...eventParam.eventParamNames,
1604
+ ...eventParamNames,
1605
+ funtionStr
1606
+ );
1607
+ return e.call(
1608
+ this,
1609
+ ...eventParam.eventParamValues,
1610
+ ...eventParamValues
1611
+ );
1612
+ }
1613
+ },
1614
+
1615
+ handleOnCreated: function () {
1616
+ this.handleCustomEvent(this.formConfig?.onFormCreated);
1617
+ /*if (this.formConfig && this.formConfig.onFormCreated) {
1618
+ let e = new Function(this.formConfig.onFormCreated);
1619
+ e.call(this);
1620
+ }*/
1621
+ },
1622
+ handleOnMounted: function () {
1623
+ /*if (this.formConfig && this.formConfig.onFormMounted) {
1624
+ let e = new Function(this.formConfig.onFormMounted);
1625
+ e.call(this);
1626
+ }*/
1627
+ this.handleCustomEvent(this.formConfig?.onFormMounted);
1628
+ },
1629
+ findWidgetAndSetDisabled: function (e, t) {
1630
+ let i = this.getWidgetRef(e);
1631
+ i && i.setDisabled
1632
+ ? i.setDisabled(t)
1633
+ : this.findWidgetOfSubFormAndSetDisabled(e, t);
1634
+ },
1635
+ findWidgetOfSubFormAndSetDisabled: function (e, t) {
1636
+ let i = this,
1637
+ n = baseRefUtil.getFieldWidgetByName(this.formJsonObj.widgetList, e);
1638
+ n &&
1639
+ n.options &&
1640
+ n.options.hasOwnProperty("disabled") &&
1641
+ (n.options.disabled = t),
1642
+ this.findWidgetNameInSubForm(e).forEach(function (e) {
1643
+ let n = i.getWidgetRef(e);
1644
+ n && n.setDisabled && n.setDisabled(t);
1645
+ });
1646
+ },
1647
+ findWidgetAndSetHidden: function (e, t) {
1648
+ let i = this.getWidgetRef(e);
1649
+ i && i.setDisabled
1650
+ ? i.setHidden(t)
1651
+ : this.findWidgetOfSubFormAndSetHidden(e, t);
1652
+ },
1653
+ findWidgetOfSubFormAndSetHidden: function (e, t) {
1654
+ let i = this,
1655
+ n = baseRefUtil.getFieldWidgetByName(this.formJsonObj.widgetList, e);
1656
+ n &&
1657
+ n.options &&
1658
+ n.options.hasOwnProperty("hidden") &&
1659
+ (n.options.hidden = t),
1660
+ this.findWidgetNameInSubForm(e).forEach(function (e) {
1661
+ let n = i.getWidgetRef(e);
1662
+ n && n.setDisabled && n.setHidden(t);
1663
+ });
1664
+ },
1665
+ findWidgetNameInSubForm(widgetName) {
1666
+ let result = [];
1667
+ let subFormName = null;
1668
+ Object.keys(this.subFormRefList).forEach((sfName) => {
1669
+ const fwHandler = (fw) => {
1670
+ if (fw.options.name === widgetName) {
1671
+ subFormName = sfName;
1672
+ }
1673
+ };
1674
+
1675
+ const sfRef = this.subFormRefList[sfName];
1676
+ traverseFieldWidgetsOfContainer(sfRef.widget, fwHandler, true);
1677
+ });
1678
+
1679
+ if (!!subFormName) {
1680
+ let subFormRef = this.getWidgetRef(subFormName);
1681
+ if (!!subFormRef) {
1682
+ if (subFormRef.widget.type == "data-table") {
1683
+ let rows = subFormRef.getValue();
1684
+ if (rows) {
1685
+ rows.forEach((row) => {
1686
+ result.push(widgetName + "_" + row._X_ROW_KEY);
1687
+ });
1688
+ }
1689
+ } else {
1690
+ let rowIds = subFormRef.getRowIdData();
1691
+ if (!!rowIds && rowIds.length > 0) {
1692
+ rowIds.forEach((rid) => {
1693
+ result.push(widgetName + "@row" + rid);
1694
+ });
1695
+ }
1696
+ }
1697
+ }
1698
+ }
1699
+
1700
+ return result;
1701
+ },
1702
+
1703
+ findFieldWidgetById(fieldId, staticWidgetsIncluded) {
1704
+ return getFieldWidgetById(
1705
+ this.formJsonObj.widgetList,
1706
+ fieldId,
1707
+ staticWidgetsIncluded
1708
+ );
1709
+ },
1710
+
1711
+ getSubFormNameOfWidget(widgetName) {
1712
+ let result = [];
1713
+ let subFormName = null;
1714
+ Object.keys(this.subFormRefList).forEach((sfName) => {
1715
+ const fwHandler = (fw) => {
1716
+ if (fw.options.name === widgetName) {
1717
+ subFormName = sfName;
1718
+ }
1719
+ };
1720
+
1721
+ const sfRef = this.subFormRefList[sfName];
1722
+ traverseFieldWidgetsOfContainer(sfRef.widget, fwHandler);
1723
+ });
1724
+
1725
+ return subFormName;
1726
+ },
1727
+
1728
+ changeLanguage: function (e) {
1729
+ baseRefUtil.changeLocale(e);
1730
+ },
1731
+ getLanguageName: function () {
1732
+ return localStorage.getItem("v_form_locale") || "zh-CN";
1733
+ },
1734
+ getNativeForm: function () {
1735
+ return this.$refs["renderForm"];
1736
+ },
1737
+ getWidgetRef: function (e) {
1738
+ let t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1],
1739
+ i = this.widgetRefList[e];
1740
+ return (
1741
+ !i &&
1742
+ t &&
1743
+ this.$message.error(this.i18nt("render.hint.refNotFound") + e),
1744
+ i
1745
+ );
1746
+ },
1747
+ clearFormDataModel: function () {
1748
+ for (let e in this.formDataModel) delete this.formDataModel[e];
1749
+ },
1750
+ setFormJson: function (e) {
1751
+ let t = this;
1752
+ if (e)
1753
+ if ("string" === typeof e || e.constructor === Object) {
1754
+ let i = null;
1755
+ if (
1756
+ ((i = "string" === typeof e ? JSON.parse(e) : e),
1757
+ !i.formConfig || !i.widgetList)
1758
+ )
1759
+ return void this.$message.error("Invalid format of form json.");
1760
+ this.clearFormDataModel(),
1761
+ this.buildFormModel(i.widgetList),
1762
+ this.$set(this.formJsonObj, "formConfig", i.formConfig),
1763
+ (this._provided.formConfig = i.formConfig),
1764
+ this.$set(this.formJsonObj, "widgetList", i.widgetList),
1765
+ this.insertCustomStyleAndScriptNode(),
1766
+ this.$nextTick(function () {
1767
+ t.initFormObject(!1), t.handleOnMounted();
1768
+ });
1769
+ } else this.$message.error("Set form json failed.");
1770
+ },
1771
+ reloadOptionData: function (e) {
1772
+ let t = [];
1773
+ e && "string" === typeof e
1774
+ ? (t = [e])
1775
+ : e && Array.isArray(e) && (t = [...e]),
1776
+ this.broadcast("FieldWidget", "reloadOptionItems", [t]);
1777
+ },
1778
+ getFormData: function () {
1779
+ let e = this,
1780
+ t = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0];
1781
+ if (!t) return this.formDataModel;
1782
+ let i = function () {},
1783
+ n = new window.Promise(function (e, t) {
1784
+ i = function (i, n) {
1785
+ n ? t(n) : e(i);
1786
+ };
1787
+ });
1788
+ return (
1789
+ this.$refs["renderForm"].validate(function (t) {
1790
+ t
1791
+ ? i(e.formDataModel)
1792
+ : i(e.formDataModel, e.i18nt("render.hint.validationFailed"));
1793
+ }),
1794
+ n
1795
+ );
1796
+ },
1797
+ setFormData: function (e) {
1798
+ let t = this;
1799
+ /*Object.keys(this.formDataModel).forEach(function (i) {
1800
+ e && e.hasOwnProperty(i) && (t.formDataModel[i] = baseRefUtil.deepClone(e[i]));
1801
+ });*/
1802
+ Object.assign(t.formDataModel, baseRefUtil.deepClone(e));
1803
+ this.currentFormData = e || {};
1804
+ this.broadcast("ContainerItem", "setFormData", this.formDataModel),
1805
+ this.broadcast("FieldWidget", "setFormData", this.formDataModel);
1806
+ },
1807
+ getFieldValue: function (e) {
1808
+ let t = this,
1809
+ i = this.getWidgetRef(e);
1810
+ if (i && i.getValue) return i.getValue();
1811
+ if (!i) {
1812
+ let n = [];
1813
+ return (
1814
+ this.findWidgetNameInSubForm(e).forEach(function (e) {
1815
+ let i = t.getWidgetRef(e);
1816
+ i && i.getValue && n.push(i.getValue());
1817
+ }),
1818
+ n
1819
+ );
1820
+ }
1821
+ },
1822
+ setFieldValue: function (e, t) {
1823
+ let i = this,
1824
+ n = this.getWidgetRef(e);
1825
+ n && n.setValue && n.setValue(t),
1826
+ n ||
1827
+ this.findWidgetNameInSubForm(e).forEach(function (e) {
1828
+ let n = i.getWidgetRef(e);
1829
+ n && n.setValue && n.setValue(t);
1830
+ });
1831
+ },
1832
+ getSubFormValues: function (e) {
1833
+ let t =
1834
+ !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1],
1835
+ i = this.subFormRefList[e];
1836
+ return i.getSubFormValues(t);
1837
+ },
1838
+ setSubFormValues: function (e, t) {},
1839
+ disableForm(ignoreFields) {
1840
+ let wNameList = Object.keys(this.widgetRefList);
1841
+ wNameList.forEach((wName) => {
1842
+ let foundW = this.getWidgetRef(wName);
1843
+ if (!!foundW) {
1844
+ if (ignoreFields && ignoreFields.includes(wName)) {
1845
+ return;
1846
+ }
1847
+ if (!!foundW.widget && foundW.widget.type === "sub-form") {
1848
+ foundW.disableSubForm();
1849
+ } else if (
1850
+ !!foundW.widget &&
1851
+ foundW.widget.type === "grid-sub-form"
1852
+ ) {
1853
+ foundW.disableGridSubForm();
1854
+ } else if (!!foundW.widget && foundW.widget.type === "data-table") {
1855
+ foundW.disableGridForm();
1856
+ } else {
1857
+ !!foundW.setDisabled && foundW.setDisabled(true);
1858
+ }
1859
+ }
1860
+ });
1861
+ },
1862
+
1863
+ enableForm(ignoreFields) {
1864
+ let wNameList = Object.keys(this.widgetRefList);
1865
+ wNameList.forEach((wName) => {
1866
+ let foundW = this.getWidgetRef(wName);
1867
+ if (!!foundW) {
1868
+ if (ignoreFields && ignoreFields.includes(wName)) {
1869
+ return;
1870
+ }
1871
+ if (!!foundW.widget && foundW.widget.type === "sub-form") {
1872
+ foundW.enableSubForm();
1873
+ } else if (
1874
+ !!foundW.widget &&
1875
+ foundW.widget.type === "grid-sub-form"
1876
+ ) {
1877
+ foundW.enableGridSubForm();
1878
+ } else if (!!foundW.widget && foundW.widget.type === "data-table") {
1879
+ foundW.enableGridForm();
1880
+ } else {
1881
+ !!foundW.setDisabled && foundW.setDisabled(false);
1882
+ }
1883
+ }
1884
+ });
1885
+ },
1886
+ resetForm: function () {
1887
+ let e = this,
1888
+ t = Object.keys(this.subFormRefList);
1889
+ t.forEach(function (t) {
1890
+ e.subFormRefList[t].resetSubForm && e.subFormRefList[t].resetSubForm();
1891
+ });
1892
+ let i = Object.keys(this.widgetRefList);
1893
+ i.forEach(function (t) {
1894
+ let i = e.getWidgetRef(t);
1895
+ i && !i.subFormItemFlag && i.resetField && i.resetField();
1896
+ }),
1897
+ this.$nextTick(function () {
1898
+ e.clearValidate();
1899
+ });
1900
+ },
1901
+ clearValidate: function (e) {
1902
+ this.$refs.renderForm.clearValidate(e);
1903
+ },
1904
+ validateForm: function (e) {
1905
+ this.$refs["renderForm"].$baseValidate(function (t) {
1906
+ e(t);
1907
+ });
1908
+ },
1909
+ validateFields: function () {},
1910
+ disableWidgets: function (e) {
1911
+ let t = this;
1912
+ e &&
1913
+ ("string" === typeof e
1914
+ ? this.findWidgetAndSetDisabled(e, !0)
1915
+ : Array.isArray(e) &&
1916
+ e.forEach(function (e) {
1917
+ t.findWidgetAndSetDisabled(e, !0);
1918
+ }));
1919
+ },
1920
+ enableWidgets: function (e) {
1921
+ let t = this;
1922
+ e &&
1923
+ ("string" === typeof e
1924
+ ? this.findWidgetAndSetDisabled(e, !1)
1925
+ : Array.isArray(e) &&
1926
+ e.forEach(function (e) {
1927
+ t.findWidgetAndSetDisabled(e, !1);
1928
+ }));
1929
+ },
1930
+ hideWidgets: function (e) {
1931
+ let t = this;
1932
+ e &&
1933
+ ("string" === typeof e
1934
+ ? this.findWidgetAndSetHidden(e, !0)
1935
+ : Array.isArray(e) &&
1936
+ e.forEach(function (e) {
1937
+ t.findWidgetAndSetHidden(e, !0);
1938
+ }));
1939
+ },
1940
+ showWidgets: function (e) {
1941
+ let t = this;
1942
+ e &&
1943
+ ("string" === typeof e
1944
+ ? this.findWidgetAndSetHidden(e, !1)
1945
+ : Array.isArray(e) &&
1946
+ e.forEach(function (e) {
1947
+ t.findWidgetAndSetHidden(e, !1);
1948
+ }));
1949
+ },
1950
+ getFieldWidgets: function () {
1951
+ let e =
1952
+ arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null;
1953
+ return e
1954
+ ? baseRefUtil.getAllFieldWidgets(e)
1955
+ : baseRefUtil.getAllFieldWidgets(this.formJsonObj.widgetList);
1956
+ },
1957
+ getContainerWidgets: function () {
1958
+ let e =
1959
+ arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null;
1960
+ return e
1961
+ ? baseRefUtil.getAllContainerWidgets(e)
1962
+ : baseRefUtil.getAllContainerWidgets(this.formJsonObj.widgetList);
1963
+ },
1964
+ addEC: function (e, t) {
1965
+ this.externalComponents[e] = t;
1966
+ },
1967
+ hasEC: function (e) {
1968
+ return this.externalComponents.hasOwnProperty(e);
1969
+ },
1970
+ getEC: function (e) {
1971
+ return this.externalComponents[e];
1972
+ },
1973
+ setReadMode: function () {
1974
+ let e =
1975
+ !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0];
1976
+ this.readModeFlag = e;
1977
+ },
1978
+ getReadMode: function () {
1979
+ return this.readModeFlag;
1980
+ },
1981
+ getGlobalDsv: function () {
1982
+ return this.globalDsv;
1983
+ },
1984
+ executeDataSource: function (e, t) {
1985
+ let i = this;
1986
+ return Object(ie["a"])(
1987
+ regeneratorRuntime.mark(function n() {
1988
+ let o, a;
1989
+ return regeneratorRuntime.wrap(function (n) {
1990
+ while (1)
1991
+ switch ((n.prev = n.next)) {
1992
+ case 0:
1993
+ return (
1994
+ (o = baseRefUtil.getDSByName(i.formJsonObj.formConfig, e)),
1995
+ (a = new Object({})),
1996
+ baseRefUtil.overwriteObj(a, i.globalDsv),
1997
+ baseRefUtil.overwriteObj(a, t),
1998
+ (n.next = 6),
1999
+ baseRefUtil.runDataSourceRequest(o, a, i, !1, i.$message)
2000
+ );
2001
+ case 6:
2002
+ return n.abrupt("return", n.sent);
2003
+ case 7:
2004
+ case "end":
2005
+ return n.stop();
2006
+ }
2007
+ }, n);
2008
+ })
2009
+ )();
2010
+ },
2011
+ getParentFormRef: function () {
2012
+ return this.parentForm;
2013
+ },
2014
+ isDynamicCreation: function () {
2015
+ return this.dynamicCreation;
2016
+ },
2017
+ setDialogOrDrawerRef: function (e) {
2018
+ this.dialogOrDrawerRef = e;
2019
+ },
2020
+ getDialogOrDrawerRef: function () {
2021
+ return this.dialogOrDrawerRef;
2022
+ },
2023
+ showDialog: function (e, t) {
2024
+ let i = baseRefUtil.getContainerWidgetByName(this.widgetList, e);
2025
+ if (e && "vf-dialog" === i.type) {
2026
+ let n = {
2027
+ widgetList: baseRefUtil.deepClone(i.widgetList),
2028
+ formConfig: baseRefUtil.cloneFormConfigWithoutEventHandler(
2029
+ this.formConfig
2030
+ ),
2031
+ },
2032
+ // a = o.a.extend(fe),
2033
+ a = baseRefUtil.Vue.extend(baseRefUtil.dynamicDialogRender),
2034
+ l = new a({
2035
+ propsData: {
2036
+ options: i.options,
2037
+ formJson: n,
2038
+ formData: t || {},
2039
+ optionData: this.optionData,
2040
+ globalDsv: this.globalDsv,
2041
+ parentFormRef: this,
2042
+ },
2043
+ components: { VFormRender },
2044
+ });
2045
+ document.body.appendChild(l.$mount().$el), l.show();
2046
+ } else {
2047
+ this.$message.error(this.i18nt("render.hint.refNotFound") + e);
2048
+ }
2049
+ },
2050
+ showDrawer: function (e, t) {
2051
+ let i = baseRefUtil.getContainerWidgetByName(this.widgetList, e);
2052
+ if (i && "vf-drawer" === i.type) {
2053
+ let n = {
2054
+ widgetList: baseRefUtil.deepClone(i.widgetList),
2055
+ formConfig: baseRefUtil.cloneFormConfigWithoutEventHandler(
2056
+ this.formConfig
2057
+ ),
2058
+ },
2059
+ a = o.a.extend(we),
2060
+ l = new a({
2061
+ propsData: {
2062
+ options: i.options,
2063
+ formJson: n,
2064
+ formData: t || {},
2065
+ optionData: this.optionData,
2066
+ globalDsv: this.globalDsv,
2067
+ parentFormRef: this,
2068
+ },
2069
+ });
2070
+ document.body.appendChild(l.$mount().$el), l.show();
2071
+ } else this.$message.error(this.i18nt("render.hint.refNotFound") + e);
2072
+ },
2073
+ showDialogOrDrawer: function (e) {},
2074
+ getTableFiledMap(flag) {
2075
+ let fieldMap = {};
2076
+ let fJson = this.formJson;
2077
+ let itemFieldMap = {
2078
+ grid: "cols",
2079
+ table: "rows",
2080
+ "table-cell": "widgetList",
2081
+ "h5-table": "rows",
2082
+ "h5-table-cell": "widgetList",
2083
+ tab: "tabs",
2084
+ "tab-pane": "widgetList",
2085
+ "grid-col": "widgetList",
2086
+ "vf-box": "widgetList",
2087
+ card: "widgetList",
2088
+ detail: "panes",
2089
+ "detail-pane": "widgetList",
2090
+ "detail-h5": "panes",
2091
+ "h5-card": "panes",
2092
+ "h5-card-pane": "widgetList",
2093
+ };
2094
+ let loopDo = (widgetList) => {
2095
+ if (!widgetList) return;
2096
+ widgetList.forEach((widget) => {
2097
+ let widgetName = widget.options.name;
2098
+ let fieldKeyName = this.getFieldKeyName(widget);
2099
+ if (widget.tableField) {
2100
+ if (flag == 1) {
2101
+ fieldMap[fieldKeyName] = widget;
2102
+ } else {
2103
+ fieldMap[fieldKeyName] = fieldKeyName;
2104
+ if (this.isVabsearchFlagWidget(widget)) {
2105
+ let vabSearchName = widget.options.vabSearchName;
2106
+ if (vabSearchName) fieldMap[vabSearchName] = vabSearchName;
2107
+ }
2108
+ }
2109
+ } else {
2110
+ if (widget.category == "container") {
2111
+ let itemField = itemFieldMap[widget.type];
2112
+ if (itemField) {
2113
+ if ("table" == widget.type) {
2114
+ widget[itemField].forEach((item) => {
2115
+ loopDo(item.cols);
2116
+ });
2117
+ } else if ("h5-table" == widget.type) {
2118
+ widget[itemField].forEach((item) => {
2119
+ loopDo(item.cols);
2120
+ });
2121
+ } else {
2122
+ loopDo(widget[itemField]);
2123
+ }
2124
+ }
2125
+ }
2126
+ }
2127
+ });
2128
+ };
2129
+ loopDo(fJson.widgetList);
2130
+ return fieldMap;
2131
+ },
2132
+ getFieldKeyName(widget) {
2133
+ let o = widget.options.name;
2134
+ return (widget.options.keyNameEnabled && widget.options.keyName) || o;
2135
+ },
2136
+ isVabsearchFlagWidget(widget) {
2137
+ let type = widget?.type;
2138
+ return (
2139
+ type == "vabsearch" || type == "singerSearch" || type == "multiSearch"
2140
+ );
2141
+ },
2142
+ getFormTemplateTableDTOs() {
2143
+ let formTemplateTableDTOs = [];
2144
+ let formCode = this.reportTemplate.formCode;
2145
+ let fields = [];
2146
+ let fJson = this.formJson;
2147
+
2148
+ let itemFieldMap = {
2149
+ grid: "cols",
2150
+ table: "rows",
2151
+ "table-cell": "widgetList",
2152
+ "h5-table": "rows",
2153
+ "h5-table-cell": "widgetList",
2154
+ tab: "tabs",
2155
+ "tab-pane": "widgetList",
2156
+ "grid-col": "widgetList",
2157
+ "vf-box": "widgetList",
2158
+ card: "widgetList",
2159
+ detail: "panes",
2160
+ "detail-pane": "widgetList",
2161
+ "detail-h5": "panes",
2162
+ "h5-card": "panes",
2163
+ "h5-card-pane": "widgetList",
2164
+ };
2165
+ let loopDo = (widgetList) => {
2166
+ if (!widgetList) return;
2167
+ widgetList.forEach((widget) => {
2168
+ let submitFlag = widget.options.submitFlag || false;
2169
+ if (widget.formItemFlag || widget.type == "data-table") {
2170
+ if (widget.options.submitFlag === void 0) {
2171
+ submitFlag = true;
2172
+ }
2173
+ }
2174
+
2175
+ let uniqueName = widget.options.name;
2176
+ let widgetName = this.getFieldKeyName(widget);
2177
+ let entityTableCode = widget.options.entityTableCode;
2178
+ if (widget.type == "data-table" || widget.type == "list-h5") {
2179
+ let isTreeTable = widget.options.isTreeTable || false;
2180
+ if (submitFlag) {
2181
+ let vailColumns = widget.options.tableColumns.filter(
2182
+ (item) => item.prop && item.label
2183
+ );
2184
+ let itemFields = [];
2185
+ vailColumns.forEach((item) => {
2186
+ if (item.formatS == "editSearch") {
2187
+ itemFields.push({
2188
+ fieldDesc: item.label + "ID",
2189
+ fieldName: item.prop,
2190
+ });
2191
+ let vabSearchName = item?.columnOption?.vabSearchName;
2192
+ if (vabSearchName) {
2193
+ itemFields.push({
2194
+ fieldDesc: item.label,
2195
+ fieldName: vabSearchName,
2196
+ });
2197
+ }
2198
+ } else {
2199
+ itemFields.push({
2200
+ fieldDesc: item.label,
2201
+ fieldName: item.prop,
2202
+ });
2203
+ }
2204
+ });
2205
+
2206
+ if (itemFields.length) {
2207
+ let formTemplateTable = {
2208
+ tableAlias: widgetName,
2209
+ name: widgetName,
2210
+ formCode: formCode,
2211
+ tableType: 1,
2212
+ isTreeTable,
2213
+ uniqueName,
2214
+ formTemplateFieldDTOs: [],
2215
+ };
2216
+ formTemplateTable.formTemplateFieldDTOs = itemFields;
2217
+ formTemplateTableDTOs.push(formTemplateTable);
2218
+ }
2219
+ }
2220
+ } else if (widget.type == "vabUpload") {
2221
+ if (submitFlag) {
2222
+ let formTemplateTable = {
2223
+ tableAlias: widgetName,
2224
+ name: widgetName,
2225
+ formCode: formCode,
2226
+ tableType: 2,
2227
+ uniqueName,
2228
+ };
2229
+ formTemplateTableDTOs.push(formTemplateTable);
2230
+ }
2231
+ } else if (widget.type == "project-tag") {
2232
+ if (submitFlag) {
2233
+ let formTemplateTable = {
2234
+ tableAlias: widgetName,
2235
+ name: widgetName,
2236
+ formCode: formCode,
2237
+ tableType: 1,
2238
+ uniqueName,
2239
+ };
2240
+ formTemplateTableDTOs.push(formTemplateTable);
2241
+ }
2242
+ } else if (widget.type == "table2") {
2243
+ if (submitFlag) {
2244
+ let formTemplateTable = {
2245
+ tableAlias: widgetName,
2246
+ name: widgetName,
2247
+ formCode: formCode,
2248
+ tableType: 2,
2249
+ uniqueName,
2250
+ };
2251
+ formTemplateTableDTOs.push(formTemplateTable);
2252
+ }
2253
+ } else if (widget.tableField && this.isVabsearchFlagWidget(widget)) {
2254
+ if (submitFlag) {
2255
+ fields.push({
2256
+ fieldDesc: widget.options.label + "ID",
2257
+ fieldName: widgetName,
2258
+ });
2259
+ let vabSearchName = widget.options.vabSearchName;
2260
+ if (vabSearchName) {
2261
+ fields.push({
2262
+ fieldDesc: widget.options.label,
2263
+ fieldName: vabSearchName,
2264
+ name: vabSearchName,
2265
+ });
2266
+ }
2267
+ }
2268
+ } else if (widget.tableField) {
2269
+ if (submitFlag) {
2270
+ fields.push({
2271
+ fieldDesc: widget.options.label,
2272
+ fieldName: widgetName,
2273
+ name: widget.options.name,
2274
+ });
2275
+ }
2276
+ } else {
2277
+ if (widget.category == "container") {
2278
+ let itemField = itemFieldMap[widget.type];
2279
+ if (itemField) {
2280
+ if ("table" == widget.type) {
2281
+ widget[itemField].forEach((item) => {
2282
+ loopDo(item.cols);
2283
+ });
2284
+ } else if ("h5-table" == widget.type) {
2285
+ widget[itemField].forEach((item) => {
2286
+ loopDo(item.cols);
2287
+ });
2288
+ } else {
2289
+ loopDo(widget[itemField]);
2290
+ }
2291
+ }
2292
+ }
2293
+ }
2294
+ });
2295
+ };
2296
+ loopDo(fJson.widgetList);
2297
+ if (fields.length) {
2298
+ let formTemplateTable = {
2299
+ tableAlias: null,
2300
+ formCode: formCode,
2301
+ tableType: 0,
2302
+ formTemplateFieldDTOs: fields,
2303
+ };
2304
+ formTemplateTableDTOs.push(formTemplateTable);
2305
+ }
2306
+
2307
+ return formTemplateTableDTOs;
2308
+ },
2309
+ getSubData() {
2310
+ let that = this;
2311
+ let formCode = this.reportTemplate.formCode;
2312
+ let tableFiledMap = this.getTableFiledMap();
2313
+ let formTemplateTableDTOs = this.getFormTemplateTableDTOs();
2314
+ let formDataModel = this.formDataModel;
2315
+ let formConfig = this.formConfig;
2316
+ return new Promise((resolve, reject) => {
2317
+ let res = {};
2318
+ this.getFormData()
2319
+ .then((formData, b) => {
2320
+ for (let key in formData) {
2321
+ let tableField = tableFiledMap[key];
2322
+ if (tableField) {
2323
+ res[tableField] = formData[key];
2324
+ }
2325
+ }
2326
+ let newFormData = {};
2327
+ formTemplateTableDTOs.forEach((formTemplateTableDTO) => {
2328
+ let tableAlias =
2329
+ formTemplateTableDTO.tableType == 0
2330
+ ? formCode
2331
+ : formTemplateTableDTO.tableAlias;
2332
+ if (formTemplateTableDTO.tableType == 0) {
2333
+ let item = this.$baseLodash.cloneDeep(this.formData);
2334
+ Object.keys(item).forEach((key) => {
2335
+ if (Array.isArray(item[key])) {
2336
+ delete item[key];
2337
+ }
2338
+ });
2339
+ formTemplateTableDTO.formTemplateFieldDTOs.forEach(
2340
+ (formTemplateFieldDTO) => {
2341
+ item[formTemplateFieldDTO.fieldName] =
2342
+ res[formTemplateFieldDTO.fieldName];
2343
+ }
2344
+ );
2345
+ newFormData[tableAlias] = item;
2346
+ } else {
2347
+ newFormData[tableAlias] =
2348
+ formDataModel[formTemplateTableDTO.name];
2349
+ }
2350
+ });
2351
+ /*if (formConfig.formType === 1) {
2352
+ newFormData = this.getSysFormData(newFormData);
2353
+ }*/
2354
+ resolve(newFormData);
2355
+ })
2356
+ .catch((msg) => {
2357
+ reject(msg);
2358
+ });
2359
+ });
2360
+ },
2361
+ getSubData2(flag) {
2362
+ let that = this;
2363
+ let formCode = this.reportTemplate.formCode;
2364
+ let tableFiledMap = this.getTableFiledMap();
2365
+ let formTemplateTableDTOs = this.getFormTemplateTableDTOs();
2366
+ let formDataModel = this.formDataModel;
2367
+ let formConfig = this.formConfig;
2368
+
2369
+ let res = {};
2370
+ let formData = formDataModel;
2371
+
2372
+ for (let key in formData) {
2373
+ let tableField = tableFiledMap[key];
2374
+ if (tableField) {
2375
+ res[tableField] = formData[key];
2376
+ }
2377
+ }
2378
+
2379
+ let newFormData = {};
2380
+ formTemplateTableDTOs.forEach((formTemplateTableDTO) => {
2381
+ let tableAlias =
2382
+ formTemplateTableDTO.tableType == 0
2383
+ ? formCode
2384
+ : formTemplateTableDTO.tableAlias;
2385
+ if (formTemplateTableDTO.tableType == 0) {
2386
+ let item = this.$baseLodash.cloneDeep(this.currentFormData);
2387
+ Object.keys(item).forEach((key) => {
2388
+ if (Array.isArray(item[key])) {
2389
+ delete item[key];
2390
+ }
2391
+ });
2392
+ formTemplateTableDTO.formTemplateFieldDTOs.forEach(
2393
+ (formTemplateFieldDTO) => {
2394
+ item[formTemplateFieldDTO.fieldName] =
2395
+ res[formTemplateFieldDTO.fieldName];
2396
+ }
2397
+ );
2398
+ newFormData[tableAlias] = item ?? null;
2399
+ } else {
2400
+ if (formTemplateTableDTO.isTreeTable) {
2401
+ let tableTarget = this.getWidgetRef(
2402
+ formTemplateTableDTO.uniqueName
2403
+ );
2404
+ let $grid = tableTarget.getGridTable();
2405
+ let parentField = $grid.treeConfig.parentField;
2406
+ let treeTaBm = newFormData.treeTaBm || [];
2407
+ treeTaBm.push(formTemplateTableDTO.tableAlias);
2408
+ newFormData.treeTaBm = treeTaBm;
2409
+ let tableDatas = this.$baseLodash.cloneDeep(
2410
+ formDataModel[formTemplateTableDTO.name] || []
2411
+ );
2412
+ tableDatas.forEach((tableData) => {
2413
+ if (
2414
+ tableData.id &&
2415
+ tableData.id.startsWith &&
2416
+ tableData.id.startsWith("row_")
2417
+ ) {
2418
+ tableData.id = null;
2419
+ }
2420
+ if (
2421
+ tableData[parentField] &&
2422
+ tableData[parentField].startsWith &&
2423
+ tableData[parentField].startsWith("row_")
2424
+ ) {
2425
+ tableData[parentField] = null;
2426
+ }
2427
+ if (tableData[parentField] === undefined)
2428
+ tableData[parentField] = null;
2429
+ });
2430
+ tableDatas = tableDatas.filter((item) => {
2431
+ return item[parentField] === 0 || item[parentField] === null;
2432
+ });
2433
+ newFormData[tableAlias] = tableDatas;
2434
+ } else {
2435
+ newFormData[tableAlias] =
2436
+ formDataModel[formTemplateTableDTO.name] ?? null;
2437
+ }
2438
+ }
2439
+ });
2440
+ if (flag) {
2441
+ newFormData = this.getSysFormData(newFormData);
2442
+ }
2443
+ return newFormData;
2444
+ },
2445
+ getSysFormData(realFormData) {
2446
+ let formData0 = this.$baseLodash.cloneDeep(realFormData);
2447
+ let formConfig = this.formConfig;
2448
+ let reportTemplate = this.reportTemplate;
2449
+ let formCode = reportTemplate.formCode;
2450
+ let formData = this.$baseLodash.cloneDeep(formData0[formCode]);
2451
+ if (formData) {
2452
+ Object.keys(formData0).forEach((key) => {
2453
+ if (key != formCode) {
2454
+ formData[key] = formData0[key];
2455
+ }
2456
+ });
2457
+ }
2458
+
2459
+ return formData;
2460
+ },
2461
+ getRealFormData(option) {
2462
+ let formCode = this.reportTemplate.formCode;
2463
+ let subData = this.getSubData2();
2464
+ let realFormData = {};
2465
+ if (option) {
2466
+ Object.keys(option).forEach((key) => {
2467
+ realFormData[option[key]] = subData[key];
2468
+ });
2469
+ } else {
2470
+ realFormData = subData;
2471
+ }
2472
+ return realFormData;
2473
+ },
2474
+ closeDetailPage(){
2475
+ //关闭详情页
2476
+ let listPageRef = this.getListPageRef();
2477
+ if(listPageRef){
2478
+ listPageRef.dataId = 0;
2479
+ listPageRef.showEdit = false;
2480
+ }
2481
+ },
2482
+ getListPageRef() {
2483
+ //获取列表页面对象
2484
+ let target1 = this.$attrs["parent-target"];
2485
+ let parentTarget = target1?.$attrs["parent-target"];
2486
+ return parentTarget;
2487
+ },
2488
+ getListTabFormRef() {
2489
+ //获取列表tab的表单对象
2490
+ let parentTarget = this.getListPageRef();
2491
+ let listTabFormRef = parentTarget?.$refs?.list?.$refs?.vFormRef ?? null;
2492
+ return listTabFormRef;
2493
+ },
2494
+ getFirstWidgetRef(){
2495
+ //获取表单的第一个组件
2496
+ let target = null;
2497
+ if(this.formJsonObj.widgetList && this.formJsonObj.widgetList.length > 0){
2498
+ target = this.getWidgetRef(this.formJsonObj.widgetList[0].options.name);
2499
+ }
2500
+ return target
2501
+ },
2502
+ switchToListTab(option){
2503
+ //切换到列表页的tab
2504
+ let handleType = option?.handleType;
2505
+ let listPageRef = this.getListPageRef();
2506
+ if(listPageRef){
2507
+ listPageRef.activeName = "second";
2508
+ }
2509
+ if(handleType){
2510
+ let listTabFormRef = this.getListTabFormRef();
2511
+ if(handleType == "reload"){
2512
+ listTabFormRef.reloadForm();
2513
+ }else if(handleType == "searchEvent"){
2514
+ listTabFormRef.getFirstWidgetRef().searchEvent();
2515
+ }else if(handleType == "resethEvent"){
2516
+ listTabFormRef.getFirstWidgetRef().resethEvent();
2517
+ }
2518
+ }
2519
+ },
2520
+ reloadForm(option) {
2521
+ let target1 = this.$attrs["parent-target"];
2522
+ let target2 = target1?.$attrs["parent-target"];
2523
+ let target = !target2 ? this : target1;
2524
+ /* if (this.$attrs['reloadDialog'] !== true) {
2525
+ target = this.$attrs['parent-target'];
2526
+ }else{
2527
+ target = this;
2528
+ } */
2529
+ /*let updateParam= option && option.updateParam ? option.updateParam:{}
2530
+ for (let key in updateParam) {
2531
+ target.$emit("update:" + key, updateParam[key]);
2532
+ }*/
2533
+ target.$baseReload(option);
2534
+ },
2535
+ saveForm(callback) {
2536
+ this.validateForm(() => {
2537
+ this.getSubData().then((formData) => {
2538
+ let reportTemplate = this.reportTemplate || {};
2539
+ let formConfig = this.formConfig;
2540
+ let realFormData = Object.assign({}, formData);
2541
+
2542
+ let reqData = {
2543
+ ...this.$attrs.conditionParam,
2544
+ formTemplateId: reportTemplate.id,
2545
+ formCode: reportTemplate.formCode,
2546
+ formVersion: reportTemplate.formVersion,
2547
+ // insUuid: reportTemplate.insUuid,
2548
+ data: realFormData,
2549
+ };
2550
+
2551
+ this.$baseConfirm("您确定要保存吗?").then(() => {
2552
+ let saveConfig = formConfig.saveConfig || {};
2553
+ this.formHttp({
2554
+ options: saveConfig,
2555
+ params: reqData,
2556
+ targetFormTemplate: reportTemplate,
2557
+ success: (res) => {
2558
+ this.$message({
2559
+ message: res.content,
2560
+ type: "success",
2561
+ duration: 500,
2562
+ onClose: (t) => {
2563
+ callback && callback(res);
2564
+ this.$parent.$emit("update:object_foreign_id", res.objx);
2565
+ // this.$parent.$attrs.wfParam.submitCallback();
2566
+ this.$parent.$baseReload();
2567
+ },
2568
+ });
2569
+ },
2570
+ });
2571
+ });
2572
+ });
2573
+ });
2574
+ },
2575
+ submitForm(callback) {
2576
+ let reportTemplate = this.reportTemplate || {};
2577
+ let insUuid = reportTemplate.insUuid;
2578
+ if (insUuid) {
2579
+ this.$baseConfirm("您确定要提交吗?").then(() => {
2580
+ this.$http({
2581
+ url: USER_PREFIX + `/form_ins/submit`,
2582
+ method: `post`,
2583
+ data: { stringOne: insUuid },
2584
+ isLoading: true,
2585
+ // loadingTarget: document.body,
2586
+ modalStrictly: true,
2587
+ success: (res) => {
2588
+ this.$message({
2589
+ message: res.content,
2590
+ type: "success",
2591
+ duration: 500,
2592
+ onClose: (t) => {
2593
+ callback && callback(res);
2594
+ // this.$parent.$attrs.wfParam.submitCallback();
2595
+ this.$parent.$baseReload();
2596
+ },
2597
+ });
2598
+ },
2599
+ });
2600
+ });
2601
+ }
2602
+ },
2603
+ jumpFormView(row) {
2604
+ // let data = {};
2605
+ let data = this.getFormData2(row);
2606
+ this.setFormData(data);
2607
+ },
2608
+ getFormData2(data) {
2609
+ let tableFiledMap = this.getTableFiledMap(1);
2610
+ let res = {};
2611
+ for (let key in data) {
2612
+ let widget = tableFiledMap[key];
2613
+ if (widget) {
2614
+ res[widget.id] = data[key];
2615
+ } else {
2616
+ res[key] = data[key];
2617
+ }
2618
+ }
2619
+ return res;
2620
+ },
2621
+ getContainerByType(typeName) {
2622
+ let allWidgets = [
2623
+ ...containers,
2624
+ ...basicFields,
2625
+ ...advancedFields,
2626
+ ...customFields,
2627
+ ...businessFields,
2628
+ ];
2629
+ let foundCon = null;
2630
+ allWidgets.forEach((con) => {
2631
+ if (!!con.category && !!con.type && con.type === typeName) {
2632
+ foundCon = con;
2633
+ }
2634
+ });
2635
+
2636
+ return foundCon;
2637
+ },
2638
+ getFieldWidgetByType(typeName) {
2639
+ let allWidgets = [
2640
+ ...containers,
2641
+ ...basicFields,
2642
+ ...advancedFields,
2643
+ ...customFields,
2644
+ ...businessFields,
2645
+ ];
2646
+ let foundWidget = null;
2647
+ allWidgets.forEach((widget) => {
2648
+ if (!!!widget.category && !!widget.type && widget.type === typeName) {
2649
+ foundWidget = widget;
2650
+ }
2651
+ });
2652
+
2653
+ return foundWidget;
2654
+ },
2655
+ copyNewFieldWidget(origin) {
2656
+ let newWidget = deepClone(origin);
2657
+ newWidget.type = newWidget.targetType || newWidget.type;
2658
+ let tempId = generateId();
2659
+ newWidget.id = newWidget.type.replace(/-/g, "") + tempId;
2660
+ return newWidget;
2661
+ },
2662
+ getColumnWidget(row, isEdit) {
2663
+ //获取
2664
+ let formatS = isEdit ? row.editFormatS : row.formatS;
2665
+ let type = columnFormatMap[formatS];
2666
+ if (!type) return null;
2667
+ if (isEdit) {
2668
+ if (row.editWidget) {
2669
+ return row.editWidget;
2670
+ }
2671
+ if (row.editColumnOption) {
2672
+ let fieldWidget = this.copyNewFieldWidget(
2673
+ this.getFieldWidgetByType(type)
2674
+ );
2675
+ fieldWidget.options = row.editColumnOption;
2676
+ return fieldWidget;
2677
+ }
2678
+ } else {
2679
+ if (row.widget) {
2680
+ return row.widget;
2681
+ }
2682
+ if (row.columnOption) {
2683
+ let fieldWidget = this.copyNewFieldWidget(
2684
+ this.getFieldWidgetByType(type)
2685
+ );
2686
+ fieldWidget.options = row.columnOption;
2687
+ return fieldWidget;
2688
+ }
2689
+ }
2690
+ return this.createColumnWidget(row, isEdit);
2691
+ },
2692
+ createColumnWidget(row, isEdit) {
2693
+ let formatS = isEdit ? row.editFormatS : row.formatS;
2694
+ let type = columnFormatMap[formatS];
2695
+ if (!type) return null;
2696
+
2697
+ let columnSelectedWidget = null;
2698
+ if (type) {
2699
+ columnSelectedWidget = this.copyNewFieldWidget(
2700
+ this.getFieldWidgetByType(type)
2701
+ );
2702
+
2703
+ if (columnSelectedWidget.options.hasOwnProperty("required")) {
2704
+ columnSelectedWidget.options.required = row.required || false;
2705
+ }
2706
+
2707
+ if ("editDelete" == formatS) {
2708
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2709
+ columnSelectedWidget.options.label = "删除";
2710
+ columnSelectedWidget.options.labelHidden = true;
2711
+ columnSelectedWidget.options.hiddenByWf = true;
2712
+ columnSelectedWidget.options.onClick =
2713
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
2714
+ } else if ("editButton" == formatS) {
2715
+ columnSelectedWidget.options.prefixIcon = "el-icon-edit";
2716
+ columnSelectedWidget.options.label = "查看";
2717
+ columnSelectedWidget.options.labelHidden = true;
2718
+ columnSelectedWidget.options.onClick =
2719
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
2720
+ } else if ("addSiblingEditRow" == formatS) {
2721
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2722
+ columnSelectedWidget.options.label = "新增兄弟节点";
2723
+ columnSelectedWidget.options.labelHidden = false;
2724
+ columnSelectedWidget.options.onClick =
2725
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
2726
+ } else if ("addChildTreeRow" == formatS) {
2727
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2728
+ columnSelectedWidget.options.label = "新增子节点";
2729
+ columnSelectedWidget.options.labelHidden = false;
2730
+ columnSelectedWidget.options.onClick =
2731
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
2732
+ } else if ("moveUpRow" == formatS) {
2733
+ columnSelectedWidget.options.label = "↑上移";
2734
+ columnSelectedWidget.options.labelHidden = false;
2735
+ columnSelectedWidget.options.onClick =
2736
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
2737
+ } else if ("moveDownRow" == formatS) {
2738
+ columnSelectedWidget.options.label = "↓下移";
2739
+ columnSelectedWidget.options.labelHidden = false;
2740
+ columnSelectedWidget.options.onClick =
2741
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
2742
+ } else if ("removeTreeRow" == formatS) {
2743
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2744
+ columnSelectedWidget.options.label = "删除";
2745
+ columnSelectedWidget.options.labelHidden = true;
2746
+ columnSelectedWidget.options.onClick =
2747
+ "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
2748
+ }
2749
+
2750
+ if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
2751
+ columnSelectedWidget.options.keyName = row.prop;
2752
+ columnSelectedWidget.options.keyNameEnabled = true;
2753
+ } else {
2754
+ columnSelectedWidget.options.name = row.prop;
2755
+ }
2756
+
2757
+ if (type != "button" && type != "a-link") {
2758
+ columnSelectedWidget.options.label = row.label;
2759
+ columnSelectedWidget.options.labelHidden = true;
2760
+ }
2761
+ }
2762
+ return columnSelectedWidget;
2763
+ },
2764
+ doScriptAccess(scriptUuid, callback) {
2765
+ if (scriptUuid) {
2766
+ let scripts = this.formJson.formConfig.scriptList || [];
2767
+ let item = scripts.find((item) => item.scriptUuid == scriptUuid);
2768
+ if (item && item.enabled) {
2769
+ let path = "";
2770
+ let reportTemplate = this.getReportTemplate();
2771
+ let formCode = reportTemplate.formCode;
2772
+ let e = new Function("formCode", item.scriptParams);
2773
+ let params = e.call(this, formCode);
2774
+ this.$http({
2775
+ url: path,
2776
+ method: `post`,
2777
+ data: {
2778
+ ...params,
2779
+ },
2780
+ isLoading: true,
2781
+ // loadingTarget: document.body,
2782
+ modalStrictly: true,
2783
+ success: (res) => {
2784
+ let e1 = new Function("resultMsg", item.onScriptSuccess);
2785
+ e1.call(this, res);
2786
+ callback && callback(res && res.objx ? res.objx : []);
2787
+ },
2788
+ });
2789
+ }
2790
+ }
2791
+ },
2792
+ validate(callback) {
2793
+ this.$refs["renderForm"].$baseValidate(
2794
+ (valid, obj) => {
2795
+ if (!valid) {
2796
+ let message = null;
2797
+ let keys = Object.keys(obj);
2798
+ if (keys.length) {
2799
+ let item = obj[keys[0]];
2800
+ if (item && item.length) {
2801
+ message = item[0].message;
2802
+ }
2803
+ }
2804
+ if (!message) {
2805
+ message = this.$t2("必填项不能为空", "system.message.required");
2806
+ }
2807
+
2808
+ this.$message({
2809
+ message: message,
2810
+ type: "error",
2811
+ duration: 2000,
2812
+ });
2813
+ }
2814
+ callback && callback(valid);
2815
+ },
2816
+ { errorTip: false }
2817
+ );
2818
+ },
2819
+ /*scrollToFirstError() {
2820
+ // 获取第一个验证失败的字段
2821
+ let formTarget = this.$refs['renderForm'];
2822
+ const firstErrorField = Object.keys(formTarget.fields).find(key => {
2823
+ return formTarget.fields[key].validateState === 'error';
2824
+ });
2825
+
2826
+ if (firstErrorField) {
2827
+ const field = formTarget.fields[firstErrorField];
2828
+
2829
+ // 滚动到该字段位置
2830
+ field.$el.scrollIntoView({
2831
+ behavior: 'smooth',
2832
+ block: 'center'
2833
+ });
2834
+
2835
+ // 添加高亮效果
2836
+ field.$el.classList.add('highlight');
2837
+
2838
+ // 3秒后移除高亮效果
2839
+ setTimeout(() => {
2840
+ field.$el.classList.remove('highlight');
2841
+ }, 3000);
2842
+ }
2843
+ },*/
2844
+ openSearchDialog(option) {
2845
+ this.searchDialogOption = option;
2846
+ this.showSearchDialog = true;
2847
+ },
2848
+ confirmSearchDialog(rows) {
2849
+ this.searchDialogOption.confirm && this.searchDialogOption.confirm(rows);
2850
+ },
2851
+ openFormDialog(option) {
2852
+ this.formDialogOption = option;
2853
+ this.showFormDialog = true;
2854
+ },
2855
+ closeFormDialog() {
2856
+ if (this.showFormDialog) {
2857
+ this.$refs.formDialog.close();
2858
+ }
2859
+ },
2860
+ confirmFormDialog() {
2861
+ this.formDialogOption.confirm && this.formDialogOption.confirm();
2862
+ },
2863
+ addInterval(handler, timeout) {
2864
+ let timer = setInterval(handler, timeout);
2865
+ this.timerMap[timer] = timer;
2866
+ return timer;
2867
+ },
2868
+ clearAllInterval() {
2869
+ let timerMap = this.timerMap;
2870
+ for (let key in timerMap) {
2871
+ let timer = timerMap[key];
2872
+ clearInterval(timer);
2873
+ }
2874
+ this.timerMap = {};
2875
+ },
2876
+ getI18nLabel(label, path, param) {
2877
+ return !this.designState && label ? this.$t2(label, path, param) : label;
2878
+ },
2879
+ openImportDialog(option) {
2880
+ this.showImportDialog = true;
2881
+ this.importDialogOption = option;
2882
+ },
2883
+ openFormDrawer(option) {
2884
+ this.formDrawerOption = option;
2885
+ this.showFormDrawer = true;
2886
+ },
2887
+ confirmFormDrawer() {
2888
+ this.formDrawerOption.confirm && this.formDrawerOption.confirm();
2889
+ },
2890
+
2891
+ openFileReferenceDialog(option) {
2892
+ this.fileReferenceDialogOption = option;
2893
+ this.showFileReferenceDialog = true;
2894
+ },
2895
+ confirmFileReferenceDialog() {
2896
+ this.fileReferenceDialogOption.confirm &&
2897
+ this.fileReferenceDialogOption.confirm();
2898
+ },
2899
+ getFormRef() {
2900
+ return this;
2901
+ },
2902
+ isObject(value) {
2903
+ return Object.prototype.toString.call(value) === "[object Object]";
2904
+ },
2905
+ openCopyEditTab(copyData) {
2906
+ let formData = this.$baseLodash.cloneDeep(copyData || this.formDataModel);
2907
+
2908
+ const handleData = (data) => {
2909
+ if (!data) return;
2910
+ if (Array.isArray(data)) {
2911
+ data.forEach((item) => {
2912
+ handleData(item);
2913
+ });
2914
+ return;
2915
+ } else if (this.isObject(data)) {
2916
+ data.id = null;
2917
+ data.create_by = null;
2918
+ data.create_date = null;
2919
+ data.modify_by = null;
2920
+ data.modify_date = null;
2921
+ delete data.head_table_id;
2922
+ delete data.objectForeignId;
2923
+ if (data.createBy) data.createBy;
2924
+ if (data.createDate) data.createDate;
2925
+ if (data.modifyBy) data.modifyBy;
2926
+ if (data.modifyDate) data.modifyDate;
2927
+ Object.keys(data).forEach((key) => {
2928
+ let value = data[key];
2929
+ if (value && Array.isArray(value)) {
2930
+ handleData(value);
2931
+ }
2932
+ });
2933
+ }
2934
+ };
2935
+ if (formData) {
2936
+ handleData(formData);
2937
+ }
2938
+
2939
+ this.$emit("openCopyEditTab", formData);
2940
+ },
2941
+
2942
+ async exportPdf() {
2943
+ // statusEl.style.display = 'block';
2944
+ // statusEl.textContent = '正在准备导出内容...';
2945
+ const loadingObj = this.$baseLoading();
2946
+ try {
2947
+ // 获取要导出的元素
2948
+ const element = this.$parent.$el;
2949
+ // 计算内容总高度
2950
+
2951
+ // 克隆元素(不影响原始页面)
2952
+ // statusEl.textContent = '克隆内容...';
2953
+
2954
+ const constainter = this.$parent.$parent.$el;
2955
+
2956
+ const clonedElement = element.cloneNode(true);
2957
+ let wfTab = clonedElement.querySelector(".wf-tab");
2958
+ if (wfTab) wfTab.remove();
2959
+
2960
+ clonedElement.style.width = element.offsetWidth + "px";
2961
+
2962
+ // 应用样式以展开内容
2963
+ clonedElement.style.height = "auto";
2964
+ clonedElement.style.overflow = "visible";
2965
+ clonedElement.style.position = "absolute";
2966
+ clonedElement.style.left = "-9999px";
2967
+ // document.body.appendChild(clonedElement);
2968
+ // document.body.appendChild(constainter);
2969
+
2970
+ constainter.appendChild(clonedElement);
2971
+
2972
+ const contentHeight = clonedElement.scrollHeight;
2973
+ const contentWidth = clonedElement.offsetWidth;
2974
+
2975
+ // 设置PDF参数
2976
+ const pdf = new JsPDF("p", "mm", "a4");
2977
+ const pageWidth = pdf.internal.pageSize.getWidth();
2978
+ const pageHeight = pdf.internal.pageSize.getHeight();
2979
+ const padding = 10;
2980
+
2981
+ // 计算需要多少页
2982
+ const scale = pageWidth / contentWidth;
2983
+ const scaledHeight = contentHeight * scale;
2984
+ const pages = Math.ceil(scaledHeight / pageHeight);
2985
+
2986
+ // 分页捕获并添加到PDF
2987
+ // statusEl.textContent = '正在生成PDF (0/' + pages + ')';
2988
+
2989
+ for (let i = 0; i < pages; i++) {
2990
+ // 计算当前页的裁剪位置
2991
+ const position = (i * pageHeight) / scale;
2992
+
2993
+ // 使用html2canvas捕获当前页内容
2994
+ const canvas = await html2Canvas(clonedElement, {
2995
+ scale: 2,
2996
+ // useCORS: true,
2997
+ windowHeight: pageHeight / scale,
2998
+ y: position,
2999
+ height: pageHeight / scale,
3000
+ width: contentWidth,
3001
+ logging: false,
3002
+ });
3003
+
3004
+ // 将canvas转换为图像
3005
+ const imgData = canvas.toDataURL("image/jpeg", 0.95);
3006
+
3007
+ // 添加新页面(第一页除外)
3008
+ if (i > 0) {
3009
+ pdf.addPage();
3010
+ }
3011
+
3012
+ // 将图像添加到PDF
3013
+ pdf.addImage(
3014
+ imgData,
3015
+ "JPEG",
3016
+ padding,
3017
+ padding,
3018
+ pageWidth - 2 * padding,
3019
+ pageHeight - 2 * padding
3020
+ );
3021
+
3022
+ // statusEl.textContent = '正在生成PDF (' + (i+1) + '/' + pages + ')';
3023
+ }
3024
+
3025
+ // 移除克隆元素
3026
+ // document.body.removeChild(constainter);
3027
+ constainter.removeChild(clonedElement);
3028
+
3029
+ // 保存PDF
3030
+ // statusEl.textContent = '正在保存文件...';
3031
+ let fileName = this.reportTemplate.formName + ".pdf";
3032
+ pdf.save(fileName);
3033
+
3034
+ // statusEl.textContent = 'PDF导出成功!';
3035
+ // statusEl.style.background = '#e8f5e9';
3036
+ // statusEl.style.color = '#2e7d32';
3037
+
3038
+ // 3秒后隐藏状态
3039
+ /* setTimeout(() => {
3040
+ statusEl.style.display = 'none';
3041
+ }, 3000); */
3042
+ } catch (error) {
3043
+ console.error("导出失败:", error);
3044
+ // statusEl.textContent = '导出失败: ' + error.message;
3045
+ // statusEl.style.background = '#ffebee';
3046
+ // statusEl.style.color = '#c62828';
3047
+ } finally {
3048
+ loadingObj.close();
3049
+ }
3050
+ },
3051
+
3052
+ async exportPdf1() {
3053
+ // statusEl.style.display = 'block';
3054
+ // statusEl.textContent = '正在准备导出内容...';
3055
+
3056
+ try {
3057
+ // 获取要导出的元素
3058
+ const element = this.$parent.$el;
3059
+ // 计算内容总高度
3060
+
3061
+ // 克隆元素(不影响原始页面)
3062
+ // statusEl.textContent = '克隆内容...';
3063
+
3064
+ const constainter = this.$parent.$parent.$el;
3065
+
3066
+ const clonedElement = element.cloneNode(true);
3067
+ let wfTab = clonedElement.querySelector(".wf-tab");
3068
+ if (wfTab) wfTab.remove();
3069
+
3070
+ const scrollElements = clonedElement.querySelectorAll(
3071
+ ".vxe-table--body-wrapper"
3072
+ );
3073
+
3074
+ // 临时禁用虚拟滚动
3075
+ /* for(let scrollElement of scrollElements){
3076
+ const originalScrollTop = scrollElement.scrollTop
3077
+ // scrollElement.style = 'overflow:visible;max-height:inherit !important'
3078
+ scrollElement.style = scrollElement.style+ 'overflow:visible;max-height:inherit !important;'
3079
+ // scrollElement.style["max-height"] = 'inherit !important'
3080
+ scrollElement.scrollTop = 0
3081
+ } */
3082
+
3083
+ clonedElement.style.width = element.offsetWidth + "px";
3084
+
3085
+ // 应用样式以展开内容
3086
+ clonedElement.style.height = "auto";
3087
+ clonedElement.style.overflow = "visible";
3088
+ clonedElement.style.position = "absolute";
3089
+ clonedElement.style.left = "-9999px";
3090
+ // document.body.appendChild(clonedElement);
3091
+ // document.body.appendChild(constainter);
3092
+
3093
+ /* let dom1 = clonedElement.querySelector(".detail-wrap")
3094
+ if(dom1){
3095
+ let dom2 = dom1.children[1];
3096
+ dom2.style.height = "auto;"
3097
+ dom2.querySelector(".d-cont").style.height = "auto;"
3098
+
3099
+ } */
3100
+
3101
+ constainter.appendChild(clonedElement);
3102
+
3103
+ html2Canvas(clonedElement, {
3104
+ scrollY: 0,
3105
+ useCORS: true,
3106
+ allowTaint: true,
3107
+ scale: 2, // 提高分辨率
3108
+ }).then((canvas) => {
3109
+ const pdf = new JsPDF("p", "mm", "a4");
3110
+ const imgData = canvas.toDataURL("image/png");
3111
+ const imgWidth = 210; // A4宽度
3112
+ const imgHeight = (canvas.height * imgWidth) / canvas.width;
3113
+
3114
+ // 分页处理
3115
+ let heightLeft = imgHeight;
3116
+ let position = 0;
3117
+ pdf.addImage(imgData, "PNG", 0, position, imgWidth, imgHeight);
3118
+
3119
+ while (heightLeft > 0) {
3120
+ position = heightLeft - imgHeight;
3121
+ pdf.addPage();
3122
+ pdf.addImage(imgData, "PNG", 0, position, imgWidth, imgHeight);
3123
+ heightLeft -= 297; // A4高度
3124
+ }
3125
+
3126
+ pdf.save(`导出.pdf`);
3127
+
3128
+ constainter.removeChild(clonedElement);
3129
+ });
3130
+ } catch (error) {
3131
+ console.error("导出失败:", error);
3132
+ // statusEl.textContent = '导出失败: ' + error.message;
3133
+ // statusEl.style.background = '#ffebee';
3134
+ // statusEl.style.color = '#c62828';
3135
+ }
3136
+ },
3137
+ async exportPdf2() {
3138
+ // statusEl.style.display = 'block';
3139
+ // statusEl.textContent = '正在准备导出内容...';
3140
+
3141
+ try {
3142
+ // 获取要导出的元素
3143
+ const element = this.$parent.$el;
3144
+ // 计算内容总高度
3145
+
3146
+ // 克隆元素(不影响原始页面)
3147
+ // statusEl.textContent = '克隆内容...';
3148
+
3149
+ const constainter = this.$parent.$parent.$el;
3150
+
3151
+ const clonedElement = element.cloneNode(true);
3152
+ let wfTab = clonedElement.querySelector(".wf-tab");
3153
+ if (wfTab) wfTab.remove();
3154
+
3155
+ const scrollElements = clonedElement.querySelectorAll(
3156
+ ".vxe-table--body-wrapper"
3157
+ );
3158
+
3159
+ // 临时禁用虚拟滚动
3160
+ /* for(let scrollElement of scrollElements){
3161
+ const originalScrollTop = scrollElement.scrollTop
3162
+ // scrollElement.style = 'overflow:visible;max-height:inherit !important'
3163
+ // scrollElement.style = scrollElement.style+ 'overflow:visible;max-height:inherit !important;'
3164
+ scrollElement.style["overflow"] = 'visible'
3165
+ scrollElement.style["max-height"] = 'inherit !important'
3166
+ scrollElement.scrollTop = 0
3167
+ } */
3168
+
3169
+ let dom4 = clonedElement.querySelector(".designer-view");
3170
+ // dom4.style.height = "auto;"
3171
+ let dom1 = clonedElement.querySelector(".detail-wrap");
3172
+ if (dom1) {
3173
+ let dom2 = dom1.children[1];
3174
+ dom2.style.height = "auto;";
3175
+ dom2.querySelector(".d-cont").style.height = "auto;";
3176
+ }
3177
+
3178
+ clonedElement.style.width = element.offsetWidth + "px";
3179
+
3180
+ // 应用样式以展开内容
3181
+ clonedElement.style.height = "auto";
3182
+ clonedElement.style.overflow = "visible";
3183
+ clonedElement.style.position = "absolute";
3184
+ // clonedElement.style.left = '-9999px';
3185
+ clonedElement.style.left = "100px";
3186
+ // document.body.appendChild(clonedElement);
3187
+ // document.body.appendChild(constainter);
3188
+
3189
+ constainter.appendChild(clonedElement);
3190
+
3191
+ const contentHeight = clonedElement.scrollHeight;
3192
+ const contentWidth = clonedElement.offsetWidth;
3193
+
3194
+ // 设置PDF参数
3195
+ const pdf = new JsPDF("p", "mm", "a4");
3196
+ const pageWidth = pdf.internal.pageSize.getWidth();
3197
+ const pageHeight = pdf.internal.pageSize.getHeight();
3198
+ const padding = 10;
3199
+
3200
+ // 计算需要多少页
3201
+ const scale = pageWidth / contentWidth;
3202
+ const scaledHeight = contentHeight * scale;
3203
+ const pages = Math.ceil(scaledHeight / pageHeight);
3204
+
3205
+ // 分页捕获并添加到PDF
3206
+ // statusEl.textContent = '正在生成PDF (0/' + pages + ')';
3207
+ for (let i = 0; i < pages; i++) {
3208
+ // 计算当前页的裁剪位置
3209
+ const position = (i * pageHeight) / scale;
3210
+
3211
+ // 使用html2canvas捕获当前页内容
3212
+ const canvas = await html2Canvas(clonedElement, {
3213
+ scale: 2,
3214
+ useCORS: true,
3215
+ windowHeight: pageHeight / scale,
3216
+ y: position,
3217
+ height: pageHeight / scale,
3218
+ width: contentWidth,
3219
+ logging: false,
3220
+ });
3221
+
3222
+ // 将canvas转换为图像
3223
+ const imgData = canvas.toDataURL("image/jpeg", 0.95);
3224
+
3225
+ // 添加新页面(第一页除外)
3226
+ if (i > 0) {
3227
+ pdf.addPage();
3228
+ }
3229
+
3230
+ // 将图像添加到PDF
3231
+ pdf.addImage(
3232
+ imgData,
3233
+ "JPEG",
3234
+ padding,
3235
+ padding,
3236
+ pageWidth - 2 * padding,
3237
+ pageHeight - 2 * padding
3238
+ );
3239
+
3240
+ // statusEl.textContent = '正在生成PDF (' + (i+1) + '/' + pages + ')';
3241
+ }
3242
+
3243
+ // 移除克隆元素
3244
+ // document.body.removeChild(constainter);
3245
+ constainter.removeChild(clonedElement);
3246
+
3247
+ // 保存PDF
3248
+ // statusEl.textContent = '正在保存文件...';
3249
+ pdf.save("exported-content.pdf");
3250
+
3251
+ // statusEl.textContent = 'PDF导出成功!';
3252
+ // statusEl.style.background = '#e8f5e9';
3253
+ // statusEl.style.color = '#2e7d32';
3254
+
3255
+ // 3秒后隐藏状态
3256
+ /* setTimeout(() => {
3257
+ statusEl.style.display = 'none';
3258
+ }, 3000); */
3259
+ } catch (error) {
3260
+ console.error("导出失败:", error);
3261
+ // statusEl.textContent = '导出失败: ' + error.message;
3262
+ // statusEl.style.background = '#ffebee';
3263
+ // statusEl.style.color = '#c62828';
3264
+ }
3265
+ },
3266
+ async exportPdf4() {
3267
+ // statusEl.style.display = 'block';
3268
+ // statusEl.textContent = '正在准备导出内容...';
3269
+
3270
+ try {
3271
+ // 获取要导出的元素
3272
+ const element = this.$parent.$el;
3273
+ // 计算内容总高度
3274
+
3275
+ // 克隆元素(不影响原始页面)
3276
+ // statusEl.textContent = '克隆内容...';
3277
+
3278
+ const constainter = this.$parent.$parent.$el;
3279
+
3280
+ const clonedElement = element.cloneNode(true);
3281
+ let wfTab = clonedElement.querySelector(".wf-tab");
3282
+ if (wfTab) wfTab.remove();
3283
+
3284
+ const scrollElements = clonedElement.querySelectorAll(
3285
+ ".vxe-table--body-wrapper"
3286
+ );
3287
+
3288
+ // 临时禁用虚拟滚动
3289
+ for (let scrollElement of scrollElements) {
3290
+ const originalScrollTop = scrollElement.scrollTop;
3291
+ // scrollElement.style = 'overflow:visible;max-height:inherit !important'
3292
+ // scrollElement.style = scrollElement.style+ 'overflow:visible;max-height:inherit !important;'
3293
+ scrollElement.style["overflow"] = "visible";
3294
+ scrollElement.style["max-height"] = "inherit !important";
3295
+ scrollElement.scrollTop = 0;
3296
+ }
3297
+
3298
+ let dom4 = clonedElement.querySelector(".designer-view");
3299
+ // dom4.style.height = "auto;"
3300
+ let dom1 = clonedElement.querySelector(".detail-wrap");
3301
+ if (dom1) {
3302
+ let dom2 = dom1.children[1];
3303
+ dom2.style.height = "auto;";
3304
+ dom2.querySelector(".d-cont").style.height = "auto;";
3305
+ }
3306
+
3307
+ clonedElement.style.width = element.offsetWidth + "px";
3308
+
3309
+ // 应用样式以展开内容
3310
+ clonedElement.style.height = "auto";
3311
+ clonedElement.style.overflow = "visible";
3312
+ clonedElement.style.position = "absolute";
3313
+ // clonedElement.style.left = '-9999px';
3314
+ clonedElement.style.left = "100px";
3315
+ // document.body.appendChild(clonedElement);
3316
+ // document.body.appendChild(constainter);
3317
+
3318
+ constainter.appendChild(clonedElement);
3319
+
3320
+ const canvas = await html2Canvas(clonedElement, {
3321
+ scale: 2,
3322
+ useCORS: true,
3323
+ logging: false,
3324
+ onclone: (clonedDoc) => {},
3325
+ });
3326
+
3327
+ // 移除克隆元素
3328
+ // document.body.removeChild(constainter);
3329
+ constainter.removeChild(clonedElement);
3330
+
3331
+ // 5. 生成PDF
3332
+ this.currentStep = "创建PDF文档...";
3333
+ this.progress = 70;
3334
+
3335
+ const imgData = canvas.toDataURL("image/jpeg", 0.95);
3336
+ const pdf = new JsPDF("p", "mm", "a4");
3337
+
3338
+ const pageWidth = pdf.internal.pageSize.getWidth();
3339
+ const pageHeight = pdf.internal.pageSize.getHeight();
3340
+
3341
+ // const imgWidth = canvas.width;
3342
+ const imgWidth = element.offsetWidth;
3343
+ const imgHeight = canvas.height;
3344
+
3345
+ const ratio = pageWidth / imgWidth;
3346
+ const imgHeightOnPDF = imgHeight * ratio;
3347
+
3348
+ // 计算需要多少页
3349
+ let totalPages = Math.ceil(imgHeightOnPDF / pageHeight);
3350
+ let position = 0;
3351
+
3352
+ // 添加第一页
3353
+ pdf.addImage(imgData, "JPEG", 0, position, pageWidth, imgHeightOnPDF);
3354
+
3355
+ // 添加额外页面(如果需要)
3356
+ for (let i = 1; i < totalPages; i++) {
3357
+ position -= pageHeight;
3358
+ pdf.addPage();
3359
+ pdf.addImage(imgData, "JPEG", 0, position, pageWidth, imgHeightOnPDF);
3360
+ }
3361
+
3362
+ this.pdfPages = totalPages;
3363
+
3364
+ // 6. 生成预览
3365
+ this.currentStep = "生成预览...";
3366
+ this.progress = 90;
3367
+
3368
+ const pdfBlob = pdf.output("blob");
3369
+ this.pdfPreviewUrl = URL.createObjectURL(pdfBlob);
3370
+
3371
+ // 7. 自动下载
3372
+ pdf.save("exported-content.pdf");
3373
+
3374
+ this.progress = 100;
3375
+ setTimeout(() => {
3376
+ this.isExporting = false;
3377
+ }, 500);
3378
+ } catch (error) {
3379
+ console.error("导出失败:", error);
3380
+ // statusEl.textContent = '导出失败: ' + error.message;
3381
+ // statusEl.style.background = '#ffebee';
3382
+ // statusEl.style.color = '#c62828';
3383
+ }
3384
+ },
3385
+ async exportPdf5() {
3386
+ try {
3387
+ // 获取要导出的元素
3388
+ const element = this.$parent.$el;
3389
+ // 计算内容总高度
3390
+
3391
+ // 克隆元素(不影响原始页面)
3392
+ // statusEl.textContent = '克隆内容...';
3393
+
3394
+ const constainter = this.$parent.$parent.$el;
3395
+ // 获取dom元素
3396
+ // const dom = document.querySelector('#id名称')
3397
+ if (element) {
3398
+ html2Canvas(element).then(async (canvas) => {
3399
+ // A4纸,纵向
3400
+ let pdf = new JsPDF("p", "mm", "a4");
3401
+ let ctx = canvas.getContext("2d");
3402
+ let a4w = 190;
3403
+ // A4大小,210mm x 297mm,四边各保留10mm的边距,显示区域190x277
3404
+ let a4h = 277;
3405
+ // 按A4显示比例换算一页图像的像素高度
3406
+ let imgHeight = Math.floor((a4h * canvas.width) / a4w);
3407
+ let renderedHeight = 0;
3408
+ while (renderedHeight < canvas.height) {
3409
+ let page = document.createElement("canvas");
3410
+ page.width = canvas.width;
3411
+ // 可能内容不足一页
3412
+ page.height = Math.min(imgHeight, canvas.height - renderedHeight);
3413
+ // 用getImageData剪裁指定区域,并画到前面创建的canvas对象中
3414
+ page
3415
+ .getContext("2d")
3416
+ .putImageData(
3417
+ ctx.getImageData(
3418
+ 0,
3419
+ renderedHeight,
3420
+ canvas.width,
3421
+ Math.min(imgHeight, canvas.height - renderedHeight)
3422
+ ),
3423
+ 0,
3424
+ 0
3425
+ );
3426
+ // 添加图像到页面,保留10mm边距
3427
+ pdf.addImage(
3428
+ page.toDataURL("image/jpeg", 1.0),
3429
+ "JPEG",
3430
+ 10,
3431
+ 10,
3432
+ a4w,
3433
+ Math.min(a4h, (a4w * page.height) / page.width)
3434
+ );
3435
+
3436
+ renderedHeight += imgHeight;
3437
+ if (renderedHeight < canvas.height) {
3438
+ // 如果后面还有内容,添加一个空页
3439
+ pdf.addPage();
3440
+ }
3441
+ // delete page;
3442
+ }
3443
+ // 保存文件
3444
+ pdf.save("文档名称.pdf");
3445
+ });
3446
+ }
3447
+ } catch (err) {
3448
+ console.log(err);
3449
+ }
3450
+ },
3451
+ openFormulaDialog(option) {
3452
+ this.formulaDialogOption = option;
3453
+ this.formulaDialogVisible = true;
3454
+ },
3455
+ openBaseFormulaDialog(option) {
3456
+ this.baseFormulaDialogOption = option;
3457
+ this.baseFormulaDialogVisible = true;
3458
+ },
3459
+ },
3460
+ };
3461
+
3462
+ export default modules;