cloud-web-corejs 1.0.54-dev.120 → 1.0.54-dev.121

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.
@@ -1,1943 +1,2122 @@
1
- import emitter from '../../../../components/xform/utils/emitter';
2
- import i18n from '../../../../components/xform/utils/i18n';
3
- import refMixin from '../../../../components/xform/form-render/refMixin';
4
- import containerItemMixin from './containerItemMixin';
5
-
6
- import * as formatUtil from '../../../../components/xform/utils/format.js';
7
- import tableConfig from '../../../../components/table/config.js';
8
- import {extendDeeply} from "../../../../utils/index.js";
9
- import {
10
- assembleAxiosConfig,
11
- getReportGlobalMap,
12
- generateId
13
- } from '../../../../components/xform/utils/util';
14
- import {tableTreeMixins} from '../../../../mixins/tableTree/index.js';
15
-
16
- let modules = {};
17
- const baseRefUtil = {
18
- emitter,
19
- i18n,
20
- refMixin,
21
- containerItemMixin,
22
- formatUtil,
23
- assembleAxiosConfig,
24
- tableConfig,
25
- getReportGlobalMap
26
- };
27
-
28
- modules = {
29
- mixins: [baseRefUtil.emitter, baseRefUtil.i18n, baseRefUtil.refMixin, baseRefUtil.containerItemMixin, tableTreeMixins],
30
- componentName: 'ContainerItem',
31
- props: {
32
- widget: Object,
33
- parentWidget: Object,
34
- parentList: Array,
35
- indexOfParentList: Number,
36
- subFormRowIndex: {
37
- type: Number,
38
- default: -1
39
- },
40
- subFormColIndex: {
41
- type: Number,
42
- default: -1
43
- },
44
- subFormRowId: {
45
- type: String,
46
- default: ''
47
- }
48
- },
49
- inject: ['refList', 'sfRefList', 'globalModel', 'getFormConfig', 'getGlobalDsv', 'previewState'],
50
- data: function () {
51
- let that = this;
52
- return {
53
- fieldModel: [],
54
- selectedIndices: [],
55
- pageSize: this.widget.options.pagination.pageSize,
56
- pageSizes: this.widget.options.pagination.pageSizes,
57
- currentPage: this.widget.options.pagination.currentPage,
58
- total: this.widget.options.pagination.total,
59
- formData: {
60
- saleOrgName: '',
61
- loginAccount: '',
62
- mobile: '',
63
- enabled: 1
64
- },
65
- vxeOption: {},
66
- requestAccess: null,
67
- columnFormatMap: {
68
- editInput: 'input',
69
- editNumber: 'number',
70
- editDate: 'date',
71
- editSelect: 'select',
72
- editSearch: 'vabsearch',
73
- editAttachment: 'baseAttachment',
74
- editStatus: 'status',
75
- aText: 'a-text',
76
- aLink: 'a-link',
77
- editDelete: 'a-link',
78
- editButton: 'a-link',
79
- button: 'button',
80
- addSiblingEditRow: 'a-link',
81
- addChildTreeRow: 'a-link',
82
- moveUpRow: 'a-link',
83
- moveDownRow: 'a-link',
84
- removeTreeRow: 'a-link'
85
- },
86
- dataTableConfig: {},
87
- widgets: [],
88
- editWidgets: [],
89
-
90
- sortParentRow: null,
91
- sortRows: [],
92
- showTreeMoveDialog: false,
93
- tableConfig: {}
94
- };
95
- },
96
- watch: {
97
- fieldModel(val) {
98
- this.formModel[this.fieldKeyName] = val || [];
99
- }
100
- },
101
- computed: {
102
- hasWf() {
103
- return this.getFormRef().hasWf || false;
104
- },
105
- tableDatas: {
106
- cache: !1,
107
- get: function () {
108
- return this.globalModel.formModel[this.fieldKeyName] || [];
109
- }
110
- },
111
- formConfig: function () {
112
- return this.getFormConfig();
113
- },
114
- paginationLayout: function () {
115
- return this.widget.options.smallPagination ? 'prev, pager, next' : 'total, sizes, prev, pager, next, jumper';
116
- },
117
- customClass: function () {
118
- return this.widget.options.customClass || '';
119
- },
120
- singleRowSelectFlag: function () {
121
- return !this.widget.options.showCheckBox;
122
- },
123
- buttonsColumnFixed: function () {
124
- return void 0 === this.widget.options.buttonsColumnFixed ? 'right' : !!this.widget.options
125
- .buttonsColumnFixed && this.widget.options.buttonsColumnFixed;
126
- },
127
- formModel: {
128
- cache: !1,
129
- get: function () {
130
- return this.globalModel.formModel;
131
- }
132
- },
133
- formDataId() {
134
- let formRef = this.getFormRef();
135
- return formRef.dataId;
136
- }
137
- },
138
- created: function () {
139
- if (!this.formModel[this.fieldKeyName]) this.formModel[this.fieldKeyName] = [];
140
- this.initRefList();
141
- this.handleOnCreated();
142
- },
143
- mounted: async function () {
144
- this.handleOnMounted();
145
- this.initTableList();
146
- },
147
- beforeDestroy: function () {
148
- this.unregisterFromRefList();
149
- },
150
- methods: {
151
- getGridTableName() {
152
- let formCode = this.getFormRef().reportTemplate.formCode;
153
- let tableName = formCode + "_" + this.widget.options.name;
154
- return tableName;
155
- },
156
- updateFormField: function () {
157
- let rows = this.fieldModel || [];
158
- let formRows = this.formModel[this.fieldKeyName];
159
- if (formRows) {
160
- this.formModel[this.fieldKeyName].splice(0, formRows.length);
161
- this.formModel[this.fieldKeyName].push(...rows);
162
- } else {
163
- this.formModel[this.fieldKeyName] = rows;
164
- }
165
- },
166
- setValue(val) {
167
- // console.log("rows:",val);
168
- let rows = val || []
169
- this.formModel[this.fieldKeyName] = rows;
170
- let $grid = this.getGridTable();
171
- this.fieldModel = rows;
172
- // $grid.loadData(rows);
173
- },
174
- getValue() {
175
- return this.formModel[this.fieldKeyName];
176
- },
177
- getFieldKeyName(widget) {
178
- let o = widget.options.name;
179
- return (
180
- (widget.options.keyNameEnabled
181
- && widget.options.keyName)
182
- || o
183
- );
184
- },
185
- selectWidget: function (e) {
186
- this.designer.setSelected(e);
187
- },
188
- formatterValue: function ({cellValue, row, column}) {
189
- if (cellValue === null || cellValue === undefined) return cellValue;
190
-
191
- if (column.params && column.params.formatS)
192
- switch (column.params.formatS) {
193
- case 'd1':
194
- return baseRefUtil.formatUtil.formatDate1(cellValue);
195
- case 'd2':
196
- return baseRefUtil.formatUtil.formatDate2(cellValue);
197
- case 'd3':
198
- return baseRefUtil.formatUtil.formatDate3(cellValue);
199
- case 'd4':
200
- return baseRefUtil.formatUtil.formatDate4(cellValue);
201
- case 'd5':
202
- return baseRefUtil.formatUtil.formatDate4(cellValue);
203
- case 'n1':
204
- return baseRefUtil.formatUtil.formatNumber1(cellValue);
205
- case 'n2':
206
- return baseRefUtil.formatUtil.formatNumber2(cellValue);
207
- case 'n3':
208
- return baseRefUtil.formatUtil.formatNumber3(cellValue);
209
- case 'n4':
210
- return baseRefUtil.formatUtil.formatNumber4(cellValue);
211
- case 'n5':
212
- return baseRefUtil.formatUtil.formatNumber5(cellValue);
213
- case 'n6':
214
- return baseRefUtil.formatUtil.formatNumber6(cellValue);
215
- case 'n7':
216
- return baseRefUtil.formatUtil.formatNumber7(cellValue);
217
- }
218
- return cellValue;
219
- },
220
- getRowIndex: function (e) {
221
- return this.widget.options.tableData.lastIndexOf(e);
222
- },
223
- setTableColumns: function (e) {
224
- var t = this;
225
- (this.widget.options.tableColumns = e),
226
- this.$nextTick(function () {
227
- t.$refs.dataTable.doLayout();
228
- });
229
- },
230
- setTableColumn: function (e) {
231
- this.setTableColumns(e);
232
- },
233
- getTableData: function () {
234
- return this.widget.options.tableData;
235
- },
236
- resetForm(options) {
237
- let formData = this.formModel;
238
- let ignoreFields = options?.ignoreFields || [];
239
- this.widget.widgetList.forEach(subWidget => {
240
- if (!ignoreFields.length || !ignoreFields.includes(subWidget.options.name)) {
241
- let widgetRef = this.getWidgetRef(subWidget.options.name)
242
- if (widgetRef && widgetRef.setValue) widgetRef.setValue(null);
243
- }
244
- });
245
- },
246
- searchEvent() {
247
- this.getGridTable().commitProxy('reload');
248
- },
249
- async resetEvent(options) {
250
- this.resetForm(options);
251
- this.getGridTable().commitProxy('reload');
252
- },
253
- handleSearchClick() {
254
- if (this.widget.options.onSearchTable) {
255
- this.handleCustomEvent(this.widget.options.onSearchTable);
256
- return
257
- }
258
- this.searchEvent();
259
- },
260
- handleResetClick() {
261
- if (this.widget.options.onResetTable) {
262
- this.handleCustomEvent(this.widget.options.onResetTable);
263
- return
264
- }
265
- this.resetEvent();
266
- },
267
- openEditDialog(row, param) {
268
- let formRef = this.getFormRef();
269
- let parentTarget = formRef.$attrs["parent-target"];
270
- parentTarget && parentTarget.$attrs.openEditDialog && parentTarget.$attrs.openEditDialog(row, param);
271
- },
272
- importExcel() {
273
- },
274
- getGrid(that, tableRef) {
275
- var $grid;
276
- if (Array.isArray(that.$refs[tableRef])) {
277
- $grid = that.$refs[tableRef][0];
278
- } else {
279
- $grid = that.$refs[tableRef];
280
- }
281
- return $grid;
282
- },
283
- getTableCondition: function () {
284
- if (this.widget.options.tableCondition) {
285
- var e = new Function(this.widget.options.tableCondition);
286
- return e.call(this);
287
- }
288
- },
289
- getSearchCondition: function () {
290
- let extraAccessData = this.extraAccessData || {};
291
- let searchFormData = this.getSearchFormData();
292
- let defaultData = {};
293
-
294
- // let globalReqData = baseRefUtil.getReportGlobalMap();//全局请求参数
295
- let tableCondition = this.getTableCondition();
296
- let conditions = {
297
- ...defaultData,
298
- ...tableCondition,
299
- ...searchFormData,
300
- ...extraAccessData,
301
- // ...globalReqData
302
- };
303
- return conditions;
304
- },
305
- createColumns() {
306
- let tableColumns = this.widget.options.tableColumns;
307
- let newColumns = [];
308
- newColumns.push({
309
- type: 'checkbox',
310
- width: 48,
311
- resizable: false,
312
- fixed: 'left'
313
- });
314
-
315
- const createColumn = (t, isChild) => {
316
- let col = {
317
- fixed: !!t.fixed && t.fixed,
318
- field: t.prop,
319
- title: this.getI18nLabel(t.label),
320
- sortable: t.sortable,
321
- align: t.align ? t.align : 'center',
322
- formatter: this.formatterValue,
323
- params: {
324
- formatS: t.formatS,
325
- columnId: t.columnId,
326
- exportType: t.exportType,
327
- isItemLine: t.isItemLine,
328
- footerDataType: t.footerDataType,
329
- footerMethodConfg: t.footerMethodConfg,
330
- },
331
- visible: t.show,
332
- slots: {}
333
- };
334
- if (t.treeNode) {
335
- col.treeNode = true;
336
- }
337
- if (t.children && t.children.length) {
338
- col.align = 'center';
339
- delete col.field
340
- let childColumns = t.children.map(child => {
341
- return createColumn(child, true);
342
- });
343
- col.children = childColumns;
344
-
345
- col.sortable = false;
346
- col.filterType = false;
347
- } else {
348
- col.width = t.width;
349
- if (isChild) {
350
- if (col.title && col.field) {
351
- col.filters = [
352
- {
353
- data: {},
354
- },
355
- ];
356
- col.filterRender = {
357
- name: "FilterContent",
358
- };
359
- }
360
- }
361
- }
362
- col = addColumProperty(col, t)
363
- return col;
364
- };
365
-
366
- const addColumProperty = (col, t) => {
367
- let columnOption;
368
- let widget;
369
- let columnWidgetConfig = this.getColumnWidgetConfig(t);
370
- let {columnSelectedWidget, columnEditFields} = columnWidgetConfig;
371
- if (columnSelectedWidget) {
372
- widget = columnSelectedWidget
373
- columnOption = widget.options;
374
- } else {
375
- columnOption = {};
376
- }
377
-
378
- let {columnSelectedWidget: editWidget} = this.getColumnWidgetConfig(t, true);
379
-
380
- let params = {
381
- ...columnOption,
382
- widget: widget,
383
- formatS: t.formatS,
384
- required: t.required || false,
385
- columnConfig: t,
386
- editWidget
387
- }
388
- Object.assign(col.params, params);
389
- if (!col.children || !col.children.length) {
390
- if (t.formatS == 'render') {
391
- let r = t.render ? new Function('params', 'h', t.render) : null;
392
- col.slots.default = (params, h) => {
393
- return r ? r.call(this, params, h) : '';
394
- };
395
- } else if (columnSelectedWidget) {
396
- // col.slots.default = columnSelectedWidget.id;
397
- col.slots.default = "widget";
398
- } else if (t.formatS == 'editTreeButtonGroup') {
399
- col.slots.default = 'editTreeButtonGroup';
400
- }
401
-
402
- if (editWidget) {
403
- col.editRender = {name: 'input'};
404
- // col.slots.edit = editWidget.id;
405
- col.slots.edit = "editWidget"
406
- }
407
- }
408
- if (t.tableColumnConfig) {
409
- let tableColumnConfig = this.handleCustomEvent(t.tableColumnConfig) || {};
410
- col = extendDeeply(col, tableColumnConfig);
411
- }
412
- return col
413
- }
414
-
415
- let formRef = this.getFormRef();
416
- tableColumns.forEach(t => {
417
- let col = createColumn(t);
418
- newColumns.push(col);
419
- });
420
-
421
- if (baseRefUtil.tableConfig && baseRefUtil.tableConfig.className == "list-table") {
422
- if (tableColumns.length) {
423
- let tableColumn = [tableColumns.length - 1];
424
- if (tableColumn.fixed != "right") {
425
- newColumns.push({
426
- width: 47,
427
- title: '',
428
- fixed: 'right',
429
- sortable: false,
430
- });
431
- }
432
- }
433
- }
434
- return this.$baseLodash.cloneDeep(newColumns);
435
- },
436
- initTableList() {
437
- let that = this;
438
- let path = null;
439
- let paramFun = null;
440
- // let mainDataSetDTO = null;
441
- let requestAccess = this.requestAccess;
442
- let tableRef = this.getTableRef();
443
- let formDataModel = this.getFormRef().formDataModel;
444
- let isQueryTable = this.widget.options.isQueryTable || false;
445
- let isDataPage = this.widget.options.accessReturnType == "2";
446
- let reportTemplate = this.getFormRef().reportTemplate;
447
- let formCode = reportTemplate.formCode;
448
- let dataId = this.formDataId;
449
- let accessScript = this.widget.options.accessScript;
450
- let searchColumns = null;
451
- if (isQueryTable) {
452
- path = "#";
453
- paramFun = () => {
454
- let conditions = this.getSearchCondition();
455
- let $grid = this.getGridTable();
456
- if (this.widget.options.showPagination) {
457
- let proxyInfo = $grid.getProxyInfo();
458
- let searchCount = true;
459
- let isQueryAllPage = $grid.isQueryAllPage;
460
- if (isQueryAllPage == false) {
461
- searchCount = false;
462
- }
463
- let pager = proxyInfo ? proxyInfo.pager : null;
464
- if (pager) {
465
- conditions.current = pager.currentPage;
466
- conditions.size = pager.pageSize;
467
- conditions.searchCount = searchCount;
468
- }
469
- }
470
-
471
- /*let formData = {
472
- accessCode: requestAccess.accessCode,
473
- conditions: conditions
474
- };*/
475
- let formData = conditions;
476
- return formData;
477
- };
478
-
479
- searchColumns = [];
480
- let widgetList = this.widget.widgetList;
481
- let typeMap = {
482
- "input": "input",
483
- "number": "number",
484
- "inputBatch": "inputBatch",
485
- "date": "date"
486
- }
487
-
488
- widgetList.forEach(widget => {
489
- if ('container' !== widget.category) {
490
- let options = widget.options;
491
- let type = typeMap[widget.type] || null;
492
- searchColumns.push({
493
- title: this.getI18nLabel(options.label),
494
- field: this.getFieldKeyName(widget),
495
- type: type,
496
- common: true,
497
- disabled: options.disabled,
498
- defaultValueEnabled: !!type,
499
- slot: options.name,
500
- widget: widget,
501
- formItem: false
502
- });
503
- }
504
- });
505
- }
506
-
507
- let formRef = this.getFormRef();
508
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
509
- this.dataTableConfig = dataTableConfig;
510
-
511
- let columns = this.createColumns();
512
- this.widgets = columns.filter(column => !!column?.params?.widget).map(column => column.params.widget);
513
- this.editWidgets = columns.filter(column => !!column?.params?.editWidget).map(column => column.params.editWidget);
514
-
515
- let height = this.widget.options.tableHeight || (isQueryTable ? "auto" : null);
516
- if (!this.widget.options.tableHeight && isQueryTable && this.previewState) {
517
- height = "550px";
518
- }
519
-
520
- let formConfig = this.formConfig;
521
- let scriptCode = this.getScriptCode();
522
-
523
- let otherParam = {}
524
- let attachmentType = this.getAttachmentType();
525
- if (attachmentType.length) {
526
- otherParam.attachmentType = attachmentType;
527
- }
528
- let thirdtabm = this.getThirdtabm();
529
- if (thirdtabm.length) {
530
- otherParam.thirdtabm = thirdtabm;
531
- }
532
-
533
- let pagerConfig = {};
534
- let editDefaultRow, treeNodeParam, treeConfig;
535
- let isTreeTable = this.widget.options.isTreeTable;
536
- if (isTreeTable) {
537
- pagerConfig.pagerClass = "is--hidden"
538
- if (this.widget.options.editDefaultRow) {
539
- editDefaultRow = this.handleCustomEvent(this.widget.options.editDefaultRow);
540
- }
541
- treeNodeParam = row => {
542
- return {
543
- [this.widget.options.parentField]: row.id
544
- };
545
- }
546
- treeConfig = {
547
- lazy: false,
548
- children: "f_children",
549
- hasChild: "f_has_child", // 设置是否有子节点标识
550
- parentField: "f_parent",
551
- transform: true,
552
- expandAll: true,
553
- loadMethod({$table, row}) {
554
- // 模拟后台接口
555
- let $grid = that.getGridTable();
556
- let parentField = $grid.treeConfig.parentField;
557
- return new Promise((resolve, reject) => {
558
- let treeParam = that.widget.options.tableConfig?.treeNodeParam;
559
- let reqPram = {};
560
- if (treeParam) {
561
- reqPram = treeParam(row) || {}
562
- }
563
- Object.assign(reqPram, {
564
- [parentField]: row.id,
565
- });
566
- let accessParam = this.getAccessParam() || {};
567
- let defaultOption = that.getHttpConfigForUser();
568
- that.formHttp({
569
- scriptCode: scriptCode,
570
- data: {
571
- formCode: formCode,
572
- formVersion: reportTemplate.formVersion,
573
- taBm: that.fieldKeyName,
574
- data: {
575
- ...reqPram,
576
- ...otherParam,
577
- ...accessParam
578
- }
579
- },
580
- callback: (res) => {
581
- if (res.type == "success") {
582
- let rows = res.objx ? res.objx.records || res.objx || [] : [];
583
-
584
- let hasChildField = $grid.treeConfig.hasChild;
585
- if (row[hasChildField] && !rows.length) {
586
- row[hasChildField] = false;
587
- }
588
-
589
- resolve(rows);
590
- let treeCallback = that.widget.options.tableConfig?.treeCallback;
591
- if (treeCallback) {
592
- that.$nextTick(() => {
593
- setTimeout(function () {
594
- treeCallback(rows);
595
- }, 0);
596
- });
597
- }
598
- } else {
599
- reject(res);
600
- }
601
- },
602
- });
603
- });
604
- },
605
- };
606
-
607
- }
608
- let editOpts = {};
609
- if (this.widget.options.isEditTable) {
610
- editOpts = {
611
- keepSource: true,
612
- editConfig: {
613
- trigger: "manual",
614
- mode: "row",
615
- showStatus: true,
616
- autoClear: false,
617
- }
618
- }
619
- }
620
- let showFooter = this.widget.options.showGridFooter || false;
621
- let tableOption = {
622
- // vue: this,
623
- tableRef: tableRef,
624
- tableName: this.getGridTableName(),
625
- param: paramFun,
626
- columns: columns,
627
- searchColumns: searchColumns,
628
- vform: true,
629
- config: {
630
- height: height,
631
- showFooter,
632
- pagerConfig,
633
- treeConfig,
634
- ...editOpts,
635
- ...dataTableConfig.config
636
- },
637
- exportAjax: (param) => {
638
- let $grid = this.getGridTable();
639
- let pageSize = param.size;
640
- let currentPage = param.current;
641
- let page = {pageSize, currentPage};
642
- let customParam = {
643
- config: {
644
- modal: false
645
- }
646
- }
647
- return $grid.$options.propsData.proxyConfig.ajax.query.call(this, {page, param, customParam})
648
- },
649
- // treeNodeUrl,
650
- editDefaultRow,
651
- treeNodeParam
652
- };
653
-
654
- if (isQueryTable) {
655
- /*if(this.widget.options.isTreeTable){
656
- tableOption.config.pagerConfig.autoHidden = false;
657
- }*/
658
- tableOption.path = path;
659
- tableOption.config.proxyConfig = {
660
- props: {
661
- result: isDataPage ? 'objx.records' : 'objx', // 配置响应结果列表字段
662
- total: isDataPage ? 'objx.total' : 'objx.length' // 配置响应结果总页数字段
663
- },
664
- ajax: {
665
- // 接收 Promise 对象
666
- query: ({page, sorts, filters, form, param, customParam}) => {
667
-
668
- let formData = tableOption.param ? tableOption.param() || {} : {};
669
- const queryParams = Object.assign({}, formData);
670
-
671
- // 处理排序条件
672
- /*if (sorts) {
673
- const firstSort = sorts[0];
674
- if (firstSort) {
675
- queryParams.sort = firstSort.property;
676
- queryParams.order = firstSort.order;
677
- }
678
- }*/
679
-
680
- // 处理筛选条件
681
- if (filters) {
682
- filters.forEach(({property, values}) => {
683
- queryParams[property] = values.join(",");
684
- });
685
- }
686
-
687
- if (page.pageSize !== undefined) {
688
- queryParams["size"] = page.pageSize;
689
- queryParams["current"] = page.currentPage;
690
- }
691
-
692
- let $grid = this.getGridTable();
693
- let isQueryAllPage = $grid.isQueryAllPage;
694
- let pathStr1 = "";
695
- if (isQueryAllPage === false) {
696
- queryParams.searchCount = false;
697
- }
698
- Object.assign(queryParams, param)
699
-
700
- var reqPath = typeof path == "function" ? path() : path;
701
- let accessReturnType = this.widget.options.accessReturnType || 2;
702
- let scriptCode = this.getScriptCode();
703
- return new Promise((resolve, reject) => {
704
- /*let items = [
705
- {
706
- "create_by": "admin",
707
- "object_foreign_id": 224,
708
- "f_code": "202501068569",
709
- "f_grade": "1",
710
- "f_name": "呃呃呃呃呃呃俄文",
711
- "company_code": "mk1",
712
- "id": 95,
713
- "modify_by": "admin",
714
- "create_date": "2025-01-06 17:53:34",
715
- "f_flag": "A",
716
- "modify_date": "2025-01-16 21:11:44"
717
- },
718
- {
719
- "create_by": "admin",
720
- "object_foreign_id": 224,
721
- "f_code": "202501068569",
722
- "f_grade": "1",
723
- "f_name": "呃呃呃呃呃呃俄文",
724
- "company_code": "mk1",
725
- "id": 10095,
726
- "modify_by": "admin",
727
- "create_date": "2025-01-06 17:53:34",
728
- "f_flag": "A",
729
- "modify_date": "2025-01-16 21:11:44"
730
- },
731
- {
732
- "create_by": "admin",
733
- "object_foreign_id": 221,
734
- "f_code": "202501037347",
735
- "f_grade": "1",
736
- "f_name": "张三",
737
- "company_code": "mk1",
738
- "id": 92,
739
- "modify_by": "admin",
740
- "create_date": "2025-01-03 17:49:55",
741
- "f_flag": "A",
742
- "modify_date": "2025-01-05 17:21:46"
743
- },
744
- {
745
- "create_by": "admin",
746
- "object_foreign_id": 222,
747
- "f_code": "202501037348",
748
- "f_grade": "2",
749
- "f_name": "李四",
750
- "company_code": "mk1",
751
- "id": 93,
752
- "modify_by": "admin",
753
- "create_date": "2025-01-03 17:49:55",
754
- "f_flag": "A",
755
- "modify_date": "2025-01-03 17:49:55"
756
- },
757
- {
758
- "create_by": "admin",
759
- "object_foreign_id": 222,
760
- "f_code": "202501037348",
761
- "f_grade": "2",
762
- "f_name": "李四",
763
- "company_code": "mk1",
764
- "id": 10093,
765
- "modify_by": "admin",
766
- "create_date": "2025-01-03 17:49:55",
767
- "f_flag": "A",
768
- "modify_date": "2025-01-03 17:49:55"
769
- },
770
- {
771
- "create_by": "admin",
772
- "object_foreign_id": 223,
773
- "f_code": "202501037349",
774
- "f_grade": "3",
775
- "f_name": "王五",
776
- "company_code": "mk1",
777
- "id": 94,
778
- "modify_by": "admin",
779
- "create_date": "2025-01-03 17:49:55",
780
- "f_flag": "A",
781
- "modify_date": "2025-01-03 17:49:55"
782
- },
783
- {
784
- "create_by": "admin",
785
- "object_foreign_id": 218,
786
- "f_code": "202501037340",
787
- "f_grade": "4",
788
- "f_name": "林一",
789
- "company_code": "mk1",
790
- "id": 89,
791
- "modify_by": "admin",
792
- "create_date": "2025-01-03 15:02:31",
793
- "f_flag": "A",
794
- "modify_date": "2025-01-03 15:02:31"
795
- },
796
- {
797
- "create_by": "admin",
798
- "object_foreign_id": 219,
799
- "f_code": "202501037341",
800
- "f_grade": "3",
801
- "f_name": "林二",
802
- "company_code": "mk1",
803
- "id": 90,
804
- "modify_by": "admin",
805
- "create_date": "2025-01-03 15:02:31",
806
- "f_flag": "A",
807
- "modify_date": "2025-01-03 15:02:31"
808
- }
809
- ];
810
- let currentId = 0;
811
- let records = [];
812
- for(let i=0;i<50;i++){
813
- let newItems = items.map((item,index)=>{
814
- let flag = (index+1)%2!=0;
815
- let line = flag ? index : (index-1)
816
- let f_code = '10000'+i+''+line;
817
- currentId++
818
- return {
819
- ...item,
820
- id:currentId,
821
- f_code
822
- };
823
- })
824
- records.push(...newItems)
825
- }
826
-
827
- let res = {
828
- "time": "2025-03-21 11:24:55",
829
- "type": "success",
830
- "content": "success",
831
- "objx": {
832
- "records": [],
833
- "total": 77,
834
- "size": 100,
835
- "current": 1,
836
- "orders": [],
837
- "optimizeCountSql": true,
838
- "hitCount": false,
839
- "countId": null,
840
- "maxLimit": null,
841
- "searchCount": true,
842
- "pages": 1
843
- },
844
- "rmid": null
845
- };
846
- res.objx.records = records
847
- resolve(res);
848
- return*/
849
- let reqData = {
850
- ...queryParams
851
- }
852
- if (scriptCode) {
853
- let index = 0;
854
- let toDo = () => {
855
- // let f = new Function("dataId", "formCode", "param", "done", accessScript);
856
- let done = (res) => {
857
- resolve(res);
858
- if (res.type == "success") {
859
- let rows = res.objx ? res.objx.records || res.objx || [] : [];
860
- if (that.widget.options.isTreeTable) {
861
- if (rows.length > 0) {
862
- let fullAllDataRowMap
863
- = $grid.$refs.xTable.fullAllDataRowMap;
864
- let parentField = $grid.treeConfig.parentField;
865
- let expandAll = $grid.treeConfig.expandAll || false;
866
- let isLazy = $grid.treeConfig.lazy;
867
- let expandIds = rows.filter(item => item[parentField]).map(item => item[parentField])
868
- let expandRows = expandIds.length ? rows.filter(item => expandIds.includes(item.id)) : [];
869
- if (expandAll && expandRows.length) {
870
- that.$nextTick(() => {
871
- setTimeout(function () {
872
- $grid.treeConfig.lazy = false;
873
- $grid.setTreeExpand(expandRows, true);
874
- expandRows.forEach((lineData) => {
875
- if ($grid.$refs.xTable.isTreeExpandByRow(lineData)) {
876
- let rest = fullAllDataRowMap.get(lineData);
877
- rest.treeLoaded = true;
878
- }
879
- });
880
-
881
- $grid.treeConfig.lazy = isLazy;
882
- }, 0);
883
- });
884
- }
885
-
886
- let row = rows.find(item => !item[parentField]);
887
- if (row && (!expandAll || !expandIds.includes(row.id))) {
888
- let hasChild = $grid.treeConfig.hasChild;
889
- if (row[hasChild]) {
890
- that.$nextTick(() => {
891
- setTimeout(function () {
892
- $grid.setTreeExpand(row, true);
893
- }, 0);
894
- });
895
- }
896
- }
897
- }
898
- }
899
- that.$nextTick(() => {
900
- setTimeout(function () {
901
- tableOption.callback && tableOption.callback(rows);
902
- that.handleCustomEvent(that.widget.options.formScriptCallback, ['rows'], [rows])
903
- }, 0);
904
- });
905
- }
906
- }
907
- this.loadDefaultQueryList(reqData, done, customParam)
908
- };
909
- let loopHandle = () => {
910
- if (index < 500 && $grid.tableFormStop === true) {
911
- //阻塞列表查询,或者次数达到500时,自动释放
912
- index++
913
- setTimeout(() => {
914
- loopHandle();
915
- }, 10)
916
- } else {
917
- if ($grid.tableFormStop) $grid.tableFormStop = false;
918
- toDo();
919
- }
920
- }
921
- loopHandle();
922
- } else {
923
- resolve();
924
- }
925
- });
926
- }
927
- }
928
- };
929
- tableOption.callback = (rows) => {
930
- // this.fieldModel = rows;
931
- this.formModel[this.fieldKeyName] = rows
932
- }
933
- }
934
-
935
- if (isTreeTable) {
936
- tableOption.filterType = false;
937
- }
938
-
939
- if (this.widget.options.tableConfig) {
940
- let tableConfig = this.handleCustomEvent(this.widget.options.tableConfig) || {};
941
- tableOption = extendDeeply(tableOption, tableConfig);
942
- this.tableConfig = tableConfig;
943
- }
944
-
945
- if (tableOption.config.showFooter && !tableOption.config.footerMethod) {
946
-
947
- let footerColumnIds = columns.filter(item => !!item.params?.footerDataType).map(item => item.params.columnId);
948
- if (footerColumnIds.length) {
949
- tableOption.config.footerMethod = (param) => {
950
- let {columns: column1s, data} = param;
951
- return [
952
- column1s.map((column, columnIndex) => {
953
- let columnId = column.params?.columnId;
954
- if (columnId && footerColumnIds.includes(columnId)) {
955
- let footerDataType = column.params.footerDataType;
956
- if (footerDataType == "1") {
957
- //求和
958
- return this.sumNum(data, column.field);
959
- } else if (footerDataType == "2") {
960
- //求平均值
961
- return this.meanNum(data, column.field);
962
- } else if (footerDataType == "3") {
963
- if (column.params.footerMethodConfg) {
964
- let n = new Function('dataId', 'formCode', 'param', column.params.footerMethodConfg);
965
- return n.call(this, dataId, formCode, param) ?? null;
966
- }
967
- }
968
- }
969
- return null
970
- })
971
- ]
972
- }
973
- }
974
- }
975
- tableOption.vue = this;
976
- this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
977
- this.vxeOption = opts;
978
- if (!isQueryTable) {
979
- setTimeout(() => {
980
- this.loadAccessData(1);
981
- }, 20);
982
- }
983
- });
984
- },
985
- meanNum(list, field) {
986
- let count = this.sumNum(list, field)
987
- return this.$baseDiv(count, list.length);
988
- },
989
- sumNum(list, field) {
990
- let count = 0
991
- list.forEach(item => {
992
- count = this.$baseAdd(count, item[field])
993
- })
994
- return count
995
- },
996
- getSearchFormData() {
997
- let map = {condition: []};
998
- let formData = this.globalModel.formModel;
999
- let widgetList = this.widget.widgetList;
1000
- if (!!widgetList && widgetList.length > 0) {
1001
- let loop = (wItem) => {
1002
- if (wItem.category === 'container') {
1003
- loop(wItem);
1004
- } else {
1005
- let formField = this.getFieldKeyName(wItem);
1006
- let vaule = formData[formField];
1007
- if (vaule !== null && vaule !== undefined && vaule !== '') {
1008
- if (!Array.isArray(vaule) || vaule.length > 0) {
1009
- let item = {
1010
- "value": vaule,
1011
- "field": formField,
1012
- "filter": null
1013
- };
1014
- let wType = wItem.type;
1015
- if (["date-range", "time-range"].includes(wType)) {
1016
- item.filter = "between"
1017
- } else if (["input-batch", "checkbox"].includes(wType) || (wType == "select" && wItem.options.multiple)) {
1018
- item.filter = "in"
1019
- } else if (["radio", "time", "date"].includes(wType) || (wType == "select" && !wItem.options.multiple)) {
1020
- item.filter = "eq"
1021
- } else {
1022
- item.filter = "like"
1023
- }
1024
- map.condition.push(item);
1025
- }
1026
- }
1027
- }
1028
- };
1029
- widgetList.forEach(wItem => {
1030
- loop(wItem);
1031
- });
1032
- }
1033
- return map;
1034
- },
1035
- getUrl() {
1036
- let accessUrl = this.widget.options.accessUrl
1037
- return accessUrl || (USER_PREFIX + `/form_ins/getFormInsData`);
1038
- },
1039
- getAttachmentType() {
1040
- let vailColumns = this.widget.options.tableColumns.filter(item => item.prop && item.label);
1041
- let result = vailColumns.filter(item => {
1042
- return item.formatS == 'editAttachment'
1043
- }).map(item => item.prop);
1044
- return result;
1045
- },
1046
- getThirdtabm() {
1047
- let vailColumns = this.widget.options.tableColumns.filter(item => item.prop && item.label);
1048
- let result = vailColumns.filter(item => {
1049
- return item.formatS == "editSearch" && item.columnOption.multipleChoices
1050
- }).map(item => item.prop);
1051
- return result;
1052
- },
1053
-
1054
- loadDefaultViewList() {
1055
- let dataId = this.formDataId;
1056
- let reportTemplate = this.getFormRef().reportTemplate;
1057
- let formCode = reportTemplate.formCode;
1058
- let accessParam = this.getAccessParam() || {};
1059
- let otherParam = {}
1060
- let attachmentType = this.getAttachmentType();
1061
- if (attachmentType.length) {
1062
- otherParam.attachmentType = attachmentType;
1063
- }
1064
- let thirdtabm = this.getThirdtabm();
1065
- if (thirdtabm.length) {
1066
- otherParam.thirdtabm = thirdtabm;
1067
- }
1068
- let scriptCode = this.getScriptCode();
1069
- return this.formHttp({
1070
- /*url: "/" + reportTemplate.serviceName + "/form_ins/getList",*/
1071
- scriptCode: scriptCode,
1072
- data: {
1073
- formCode: formCode,
1074
- formVersion: reportTemplate.formVersion,
1075
- taBm: this.fieldKeyName,
1076
- data: {
1077
- id: dataId,
1078
- ...otherParam,
1079
- ...accessParam
1080
- }
1081
- },
1082
- callback: res => {
1083
- let $grid = this.getGridTable();
1084
- let rows = res.objx ? res.objx.records || res.objx || [] : [];
1085
- let defaultRow = this.createNewTableData();
1086
- rows = rows.map(row => {
1087
- return {
1088
- ...defaultRow,
1089
- ...row
1090
- }
1091
- });
1092
- this.setValue(rows)
1093
- this.$nextTick(() => {
1094
- /*if (this.widget.options.isTreeTable) {
1095
- let $grid = this.getGridTable();
1096
- $grid.treeConfig.lazy = false;
1097
- $grid.setAllTreeExpand(true);
1098
- }*/
1099
- this.tableConfig.callback && this.tableConfig.callback(rows);
1100
- this.handleCustomEvent(this.widget.options.formScriptCallback, ['rows'], [rows])
1101
- this.$forceUpdate();
1102
- })
1103
- }
1104
- });
1105
- },
1106
- getAccessParam() {
1107
- if (!this.widget.options.formScriptParam) return;
1108
- return this.handleCustomEvent(this.widget.options.formScriptParam)
1109
- },
1110
- getScriptCode() {
1111
- let accessReturnType = this.widget.options.accessReturnType
1112
- let defaultScriptCode = "getList";
1113
- if (accessReturnType == 1) {
1114
- defaultScriptCode = "getList";
1115
- } else if (accessReturnType == 2) {
1116
- defaultScriptCode = "getPage";
1117
- }
1118
- let scriptCode = this.widget.options.formScriptCode || defaultScriptCode;
1119
- return scriptCode;
1120
- },
1121
- loadDefaultQueryList(reqData, done, customParam) {
1122
- let reportTemplate = this.getFormRef().reportTemplate;
1123
- let prefix = "/" + reportTemplate.serviceName;
1124
- let formCode = reportTemplate.formCode;
1125
- let formConfig = this.formConfig;
1126
- let accessReturnType = this.widget.options.accessReturnType
1127
- let scriptCode = this.getScriptCode();
1128
- let accessParam = this.getAccessParam() || {};
1129
-
1130
- let otherParam = {}
1131
- let attachmentType = this.getAttachmentType();
1132
- if (attachmentType.length) {
1133
- otherParam.attachmentType = attachmentType;
1134
- }
1135
-
1136
- let defaultOption = this.getHttpConfigForUser();
1137
-
1138
- let ajaxConfig = customParam?.config || {};
1139
-
1140
- return this.formHttp({
1141
- // url: prefix + "/form_ins/getPage",
1142
- scriptCode: scriptCode,
1143
- data: {
1144
- formCode: formCode,
1145
- formVersion: reportTemplate.formVersion,
1146
- taBm: this.fieldKeyName,
1147
- data: {
1148
- ...reqData,
1149
- ...otherParam,
1150
- ...accessParam
1151
- }
1152
- },
1153
- ...defaultOption,
1154
- ...ajaxConfig,
1155
- callback: res => {
1156
- done(res);
1157
- }
1158
- });
1159
- },
1160
- loadAccessData(flag) {
1161
- if (flag === 1) {
1162
- let tableConfig = this.tableConfig;
1163
- let accessEnabled = tableConfig.accessEnabled ?? true;
1164
- if (accessEnabled === false) {
1165
- return
1166
- }
1167
- if ((this.formConfig.isLoadEntity && !this.formDataId)) {
1168
- return
1169
- }
1170
- }
1171
-
1172
- let scriptCode = this.getScriptCode()
1173
- if (scriptCode) {
1174
- this.loadDefaultViewList();
1175
- }
1176
- },
1177
- getReqParam(item, dataId, billData) {
1178
- let param = {};
1179
- if (item.accessParam) {
1180
- if (typeof item.accessParam === "string") {
1181
- let n = new Function('billData', item.accessParam);
1182
- param = n.call(this, billData);
1183
- } else {
1184
- param = item.accessParam
1185
- }
1186
- } else {
1187
- param = {id: dataId}
1188
- }
1189
- return param;
1190
- },
1191
- getTableRef() {
1192
- let tableRef = this.widget.id;
1193
- return tableRef;
1194
- },
1195
- exportData(option) {
1196
- let tableRef = this.getTableRef();
1197
- let serviceName = this.getFormRef().reportTemplate.serviceName;
1198
- option.prefix = option.prefix || ('/' + serviceName);
1199
- this.$excelExport({targetRef: tableRef, ...option})
1200
- },
1201
- async deleteRow(row, rowIndex) {
1202
- let isTreeTable = this.widget.options.isTreeTable;
1203
- if (isTreeTable) {
1204
- this.removeTreeRow({row})
1205
- return
1206
- }
1207
- let $grid = this.getGridTable();
1208
- $grid.remove(row)
1209
- let tableData = $grid.getTableData();
1210
- let isEditTable = this.widget.options.isEditTable;
1211
- let fullData = !isEditTable ? tableData.fullData : tableData.tableData;
1212
- await this.$nextTick(() => {
1213
- this.formModel[this.fieldKeyName] = fullData
1214
- this.fieldModel = fullData;
1215
- });
1216
- this.$nextTick(() => {
1217
- this.handleWbs();
1218
- });
1219
- },
1220
- createNewTableData(isEdit) {
1221
- let vailColumns = this.widget.options.tableColumns.filter(item => item.prop && item.label);
1222
- let newData = {};
1223
- vailColumns.forEach(item => {
1224
- let formatS = !isEdit ? item.formatS : item.editFormatS;
1225
- let columnOption = !isEdit ? item.columnOption : item.editColumnOption;
1226
- if (formatS == 'editSearch') {
1227
- newData[item.prop] = null;
1228
- let vabSearchName = item?.columnOption?.vabSearchName;
1229
- if (vabSearchName) newData[vabSearchName] = null;
1230
- }
1231
- if (formatS == 'editAttachment') {
1232
- newData[item.prop] = [];
1233
- } else {
1234
- newData[item.prop] = null;
1235
- if (columnOption && columnOption.defaultValue !== undefined && columnOption.defaultValue !== null && columnOption.defaultValue !== '') {
1236
- newData[item.prop] = columnOption.defaultValue;
1237
- }
1238
- }
1239
- });
1240
- return newData;
1241
- },
1242
- addTableData(rows, field) {
1243
- let $grid = this.getGridTable();
1244
- let formDataModel = this.formModel;
1245
- let tableRows = formDataModel[this.fieldKeyName] || [];
1246
- let fullData = $grid.getTableData().fullData;
1247
- let items;
1248
- if (field) {
1249
- let keys = fullData.map(item => {
1250
- return item[field] + "";
1251
- });
1252
- items = rows.filter(item => {
1253
- let value = item[field] + ""
1254
- return !keys.includes(value);
1255
- });
1256
- } else {
1257
- items = rows;
1258
- }
1259
- if (items) {
1260
- if (items.length) {
1261
- items.forEach(row => {
1262
- let newData = this.createNewTableData();
1263
- Object.assign(newData, row);
1264
-
1265
- tableRows.push(newData);
1266
- })
1267
- }
1268
- } else {
1269
- let newData = this.createNewTableData();
1270
- tableRows.push(newData);
1271
- }
1272
- // this.formModel[this.fieldKeyName] = this.$baseLodash(this.fieldModel)
1273
- // this.fieldModel = tableRows
1274
- this.setValue(tableRows)
1275
- this.$nextTick(() => {
1276
- this.handleWbs();
1277
- });
1278
- // $grid.loadData(tableRows);
1279
- },
1280
- getColumnWidgetConfig(row, isEdit) {
1281
- let formatS = isEdit ? row.editFormatS : row.formatS
1282
- let formRef = this.getFormRef();
1283
- let columnSelectedWidget = null;
1284
- let columnEditFields = null;
1285
-
1286
- let type = this.columnFormatMap[formatS];
1287
- /*if (type == 'date') {
1288
- columnEditFields = ['type', 'format', 'valueFormat']
1289
- } else if (type == 'select') {
1290
-
1291
- }
1292
- if (type == 'vabsearch') {
1293
- columnEditFields = ['vabSearchField', 'formCode', 'formVersion', 'required', 'showFormField', 'onSearchConfirm', 'onSearchClear']
1294
- }*/
1295
-
1296
- if (type) {
1297
- columnSelectedWidget = this.$baseLodash.cloneDeep(formRef.getFieldWidgetByType(type));
1298
- let tmpId = generateId();
1299
- let idVal = row.prop ? row.prop : (type + tmpId);
1300
- columnSelectedWidget.id = idVal;
1301
- columnSelectedWidget.options.name = idVal;
1302
-
1303
- let columnOption;
1304
- if (!isEdit) {
1305
- columnOption = row.columnOption;
1306
- } else {
1307
- columnOption = row.editColumnOption;
1308
- }
1309
-
1310
- if (columnOption && Object.keys(columnOption).length) {
1311
- columnOption.required = row.required || false;
1312
- columnSelectedWidget.options = columnOption;
1313
- if ('editDelete' == formatS) {
1314
- columnSelectedWidget.options.hiddenByWf = columnSelectedWidget.options.hiddenByWf ?? true;
1315
- columnSelectedWidget.options.prefixIcon = columnSelectedWidget.options.prefixIcon || "el-icon-delete";
1316
- } else if ('editButton' == formatS) {
1317
- columnSelectedWidget.options.prefixIcon = columnSelectedWidget.options.prefixIcon || "el-icon-edit";
1318
- }
1319
- } else {
1320
- columnSelectedWidget.options.required = row.required || false;
1321
- if ('editDelete' == formatS) {
1322
- columnSelectedWidget.options.prefixIcon = "el-icon-delete";
1323
- columnSelectedWidget.options.label = "删除";
1324
- columnSelectedWidget.options.labelHidden = true;
1325
- columnSelectedWidget.options.hiddenByWf = true;
1326
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
1327
- } else if ('editButton' == formatS) {
1328
- columnSelectedWidget.options.prefixIcon = "el-icon-edit";
1329
- columnSelectedWidget.options.label = "查看";
1330
- columnSelectedWidget.options.labelHidden = true;
1331
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
1332
- } else if ('addSiblingEditRow' == formatS) {
1333
- columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1334
- columnSelectedWidget.options.label = "新增兄弟节点";
1335
- columnSelectedWidget.options.labelHidden = false;
1336
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
1337
- } else if ('addChildTreeRow' == formatS) {
1338
- columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1339
- columnSelectedWidget.options.label = "新增子节点";
1340
- columnSelectedWidget.options.labelHidden = false;
1341
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
1342
- } else if ('moveUpRow' == formatS) {
1343
- // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1344
- columnSelectedWidget.options.label = "↑上移";
1345
- columnSelectedWidget.options.labelHidden = false;
1346
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
1347
- } else if ('moveDownRow' == formatS) {
1348
- // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1349
- columnSelectedWidget.options.label = "↓下移";
1350
- columnSelectedWidget.options.labelHidden = false;
1351
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
1352
- } else if ('removeTreeRow' == formatS) {
1353
- columnSelectedWidget.options.prefixIcon = "el-icon-delete";
1354
- columnSelectedWidget.options.label = "删除";
1355
- columnSelectedWidget.options.labelHidden = true;
1356
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
1357
- }
1358
- columnOption = columnSelectedWidget.options;
1359
- }
1360
- if (columnSelectedWidget.options.hasOwnProperty('keyName')) {
1361
- columnSelectedWidget.options.keyName = row.prop;
1362
- columnSelectedWidget.options.keyNameEnabled = true;
1363
- } else {
1364
- columnSelectedWidget.options.name = row.prop;
1365
- }
1366
- if (type != "button" && type != "a-link") {
1367
- columnSelectedWidget.options.label = row.label;
1368
- columnSelectedWidget.options.labelHidden = true;
1369
- }
1370
- }
1371
- return {columnSelectedWidget, columnEditFields};
1372
- },
1373
- getColumnProp(widget, obj, isEdit) {
1374
- if (!widget) {
1375
- return "false"
1376
- }
1377
- /*if(isEdit){
1378
- return "false"
1379
- }*/
1380
-
1381
- let fieldKeyName = this.getFieldKeyName(widget);
1382
- let rowIndex = Math.max(obj.rowIndex, 0)
1383
- let isQueryTable = this.widget.options.isQueryTable || false;
1384
- if (isEdit || !isQueryTable) {
1385
- let propName = fieldKeyName + '.' + rowIndex + '.' + obj.column.property
1386
- let lineWidget = !isEdit ? obj.column.params.widget : obj.column.params.editWidget;
1387
- if (!lineWidget) {
1388
- return "false";
1389
- }
1390
- if (lineWidget?.type == 'vabsearch') {
1391
- let fieldName = lineWidget.options.vabSearchName || this.getFieldKeyName(lineWidget);
1392
- propName = fieldKeyName + '.' + rowIndex + '.' + fieldName;
1393
- }
1394
-
1395
- return propName;
1396
- } else {
1397
- return "false";
1398
- }
1399
- },
1400
- getColumnWidgetName(e) {
1401
- if (e && e.type) {
1402
- return e.type + '-widget';
1403
- }
1404
- },
1405
- getGridTable() {
1406
- let $grid = this.$refs[this.getTableRef()];
1407
- return $grid;
1408
- },
1409
- getContainerWidgetName: function (e) {
1410
- return 'grid' === e.type ? 'grid-item' : e.type + '-item';
1411
- },
1412
- getWidgetName: function (e) {
1413
- return (e.targetType || e.type) + '-widget';
1414
- },
1415
- handleCheckboxChange(param) {
1416
- let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
1417
- let mergeRowKey = this.widget.options.mergeRowKey
1418
- if (mergeRowEnabled && mergeRowKey) {
1419
- let grid = this.getGridTable();
1420
- let fullData = grid.getTableData().fullData;
1421
- let row = param.row;
1422
- let val = row[mergeRowKey]
1423
- let items = fullData.filter(item => item[mergeRowKey] === val);
1424
- if (items.length) {
1425
- grid.setCheckboxRow(items, param.checked)
1426
- }
1427
- }
1428
- if (this.widget.options.onCheckboxChange) {
1429
- let t = new Function("param", this.widget.options.onCheckboxChange);
1430
- t.call(this, param);
1431
- }
1432
- let formRef = this.getFormRef();
1433
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
1434
- dataTableConfig.onCheckboxChange && dataTableConfig.onCheckboxChange(param);
1435
- },
1436
- handleCheckboxAll(param) {
1437
- if (this.widget.options.onCheckboxAll) {
1438
- let t = new Function("param", this.widget.options.onCheckboxAll);
1439
- t.call(this, param);
1440
- }
1441
- let formRef = this.getFormRef();
1442
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
1443
- dataTableConfig.onCheckboxAll && dataTableConfig.onCheckboxAll(param);
1444
- },
1445
- handleCellDblclick(param) {
1446
- if (this.widget.options.onCellDblclick) {
1447
- let t = new Function("param", this.widget.options.onCellDblclick);
1448
- t.call(this, param);
1449
- }
1450
- let formRef = this.getFormRef();
1451
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
1452
- dataTableConfig.onCellDblclick && dataTableConfig.onCellDblclick(param);
1453
- },
1454
- advancedClear() {
1455
- let formModel = this.formModel;
1456
- this.getFormRef().setFormData(formModel);
1457
- },
1458
- tableFormSettingConfirm() {
1459
- let formModel = this.formModel;
1460
- this.getFormRef().setFormData(formModel);
1461
- },
1462
-
1463
- //editTable begin
1464
- saveEditRow(obj) {
1465
-
1466
- let formRef = this.getFormRef();
1467
- let formConfig = this.formConfig;
1468
- let entity = formConfig.entity;
1469
- if (!entity) return
1470
- let dataId = formRef?.dataId;
1471
- let reportTemplate = formRef?.reportTemplate;
1472
- let formCode = reportTemplate?.formCode;
1473
- let scriptCode = formConfig.saveScriptCode || "saveUpdate"
1474
-
1475
- let that = this;
1476
- let $grid = obj.$table.$xegrid;
1477
- let originOption = $grid.originOption;
1478
-
1479
- let formModel = this.formModel;
1480
- let dataMap = this.getGridTable().getTableData();
1481
-
1482
- formRef.validate(valid => {
1483
- if (valid) {
1484
- $grid.clearActived().then(() => {
1485
- $grid.setActiveRow(obj.row);
1486
- let mainData = commonDataUtil.handleForm(obj.row);
1487
-
1488
- delete mainData._createNickName;
1489
- delete mainData._createMobile;
1490
- delete mainData._modifyNickName;
1491
- delete mainData._modifyMobile;
1492
- delete mainData._createBy;
1493
- delete mainData._modifyBy;
1494
-
1495
- let formData = {
1496
- [entity]: mainData
1497
- };
1498
-
1499
- let reqData = {
1500
- formCode: formCode,
1501
- formVersion: reportTemplate.formVersion,
1502
- taBm: entity,
1503
- data: formData
1504
- };
1505
-
1506
- this.formHttp({
1507
- scriptCode: scriptCode,
1508
- data: reqData,
1509
- successMsg: true,
1510
- isConfirm: true,
1511
- confirmText: "您确定要保存吗?",
1512
- success: res0 => {
1513
- this.getRowData(res0.objx, (res) => {
1514
- if (obj.row.id == res.objx.id) {
1515
- $grid.clearActived().then(() => {
1516
- Object.assign(obj.row, res.objx);
1517
- });
1518
- } else {
1519
- $grid.remove(obj.row);
1520
- $grid.insertAt(res.objx);
1521
- }
1522
- delete obj.$table.editCloneRow
1523
- })
1524
- }
1525
- });
1526
- })
1527
- }
1528
- });
1529
- },
1530
- getRowData(dataId, callback) {
1531
- let reportTemplate = this.getFormRef()?.reportTemplate;
1532
- let formCode = reportTemplate.formCode;
1533
- let formConfig = this.formConfig;
1534
- // let isLoadEntity = formConfig.isLoadEntity;
1535
- let entity = formConfig.entity;
1536
- let scriptCode = formConfig.formScriptCode || "getOne";
1537
- let defaultOption = this.getHttpConfigForUser();
1538
- this.formHttp({
1539
- scriptCode: scriptCode,
1540
- data: {
1541
- formCode: formCode,
1542
- formVersion: reportTemplate.formVersion,
1543
- taBm: entity,
1544
- data: {
1545
- id: dataId
1546
- }
1547
- },
1548
- ...defaultOption,
1549
- success: res => {
1550
- callback && callback(res)
1551
- }
1552
- });
1553
- },
1554
- addChildTreeRow(rowData, obj, toTop) {
1555
- let toEnd = !toTop;
1556
- this.addTreeRow(rowData, obj, toEnd, null)
1557
- },
1558
- addTopTreeRow(rowData, toTop) {
1559
- let toEnd = !toTop;
1560
- this.addTreeRow(rowData, null, toEnd, null)
1561
- },
1562
- addSiblingTreeRow(rowData, obj) {
1563
- this.addTreeRow(rowData, obj, null, true)
1564
- },
1565
- addTreeRow(rowData, obj, toEnd, toSibling) {
1566
- let isEditTable = this.widget.options.isEditTable || false;
1567
- let parent = obj?.row;
1568
- let $grid = this.getGridTable()
1569
- if (isEditTable && this.hasEditingRow($grid, 1)) {
1570
- return false;
1571
- }
1572
- let parentField = $grid.treeConfig.parentField;
1573
- let newRow = {};
1574
- let originOption = $grid.originOption;
1575
- let editDefaultRow;
1576
- if (originOption.editDefaultRow) {
1577
- if (typeof originOption.editDefaultRow == "function") {
1578
- editDefaultRow = originOption.editDefaultRow() || {};
1579
- } else {
1580
- editDefaultRow = originOption.editDefaultRow || {};
1581
- }
1582
- }
1583
- // Object.assign(newRow, editDefaultRow, rowData);
1584
- newRow.id = "row_" + (new Date()).valueOf() + Math.floor(Math.random() * 1000000);
1585
- if (!toSibling) {
1586
- newRow[parentField] = parent?.id || 0;
1587
- } else {
1588
- newRow[parentField] = obj?.row[parentField] || 0;
1589
- }
1590
-
1591
- let newData = this.createNewTableData(isEditTable);
1592
- newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
1593
-
1594
- let tableRows = this.formModel[this.fieldKeyName] || [];
1595
- if (!parent) {
1596
- if (toEnd === true) {
1597
- tableRows.push(newRow)
1598
- } else if (toSibling === true) {
1599
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1600
- tableRows.splice(addIndex, 0, newRow)
1601
- } else {
1602
- tableRows.splice(0, 0, newRow)
1603
- }
1604
- this.setValue(tableRows)
1605
- this.$nextTick(() => {
1606
- this.handleWbs();
1607
- if (isEditTable) {
1608
- $grid.setActiveRow(newRow);
1609
- }
1610
- })
1611
-
1612
- // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
1613
- } else {
1614
- $grid.setTreeExpand(obj.row, true).then(() => {
1615
- if (toEnd === true) {
1616
- tableRows.push(newRow)
1617
- } else if (toSibling === true) {
1618
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1619
- tableRows.splice(addIndex, 0, newRow)
1620
- } else {
1621
- tableRows.splice(0, 0, newRow)
1622
- }
1623
- this.setValue(tableRows)
1624
- this.$nextTick(() => {
1625
- this.handleWbs();
1626
- $grid.setTreeExpand(obj.row, true).then(() => {
1627
- if (isEditTable) {
1628
- $grid.setActiveRow(newRow);
1629
- }
1630
- });
1631
- })
1632
- });
1633
- }
1634
- },
1635
- removeTreeRow(obj) {
1636
- let row = obj.row;
1637
- let $grid = this.getGridTable()
1638
- let childrenField = $grid.treeConfig.children;
1639
- let tableRows = this.formModel[this.fieldKeyName];
1640
- // let index = tableRows.findIndex(item => item.id === row.id)
1641
- let delIds = [];
1642
- if (row[childrenField]) {
1643
- let loopDo = (item) => {
1644
- if (item.id) delIds.push(item.id);
1645
- item[childrenField] && item[childrenField].forEach(subItem => {
1646
- loopDo(subItem)
1647
- })
1648
- }
1649
- loopDo(row);
1650
- }
1651
- delIds.forEach(id => {
1652
- let index = tableRows.findIndex(item => item.id === id);
1653
- tableRows.splice(index, 1);
1654
- })
1655
- this.$nextTick(() => {
1656
- this.handleWbs();
1657
- });
1658
- },
1659
- addSiblingEditRow(rowData, obj) {
1660
- this.addEditRow(rowData, obj, null, true)
1661
- },
1662
- addEditRow(rowData, obj, toEnd, toSibling) {
1663
- let isEditTable = this.widget.options.isEditTable || false;
1664
- let parent = obj?.row;
1665
- let $grid = this.getGridTable()
1666
- if (isEditTable && this.hasEditingRow($grid, 1)) {
1667
- return false;
1668
- }
1669
- let parentField = $grid.treeConfig.parentField;
1670
- let newRow = {};
1671
- let originOption = $grid.originOption;
1672
- let editDefaultRow;
1673
- if (originOption.editDefaultRow) {
1674
- if (typeof originOption.editDefaultRow == "function") {
1675
- editDefaultRow = originOption.editDefaultRow() || {};
1676
- } else {
1677
- editDefaultRow = originOption.editDefaultRow || {};
1678
- }
1679
- }
1680
- // Object.assign(newRow, editDefaultRow, rowData);
1681
- newRow.id = "row_" + (new Date()).valueOf() + Math.floor(Math.random() * 1000000);
1682
- if (!toSibling) {
1683
- newRow[parentField] = parent?.id || 0;
1684
- } else {
1685
- newRow[parentField] = obj?.row[parentField] || 0;
1686
- }
1687
-
1688
- let newData = this.createNewTableData(isEditTable);
1689
- newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
1690
-
1691
- let tableRows = this.formModel[this.fieldKeyName] || [];
1692
- if (!parent) {
1693
- if (toEnd === true) {
1694
- tableRows.push(newRow)
1695
- } else if (toSibling === true) {
1696
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1697
- tableRows.splice(addIndex, 0, newRow)
1698
- } else {
1699
- tableRows.splice(0, 0, newRow)
1700
- }
1701
- this.setValue(tableRows)
1702
- this.$nextTick(() => {
1703
- this.handleWbs();
1704
- if (isEditTable) {
1705
- $grid.setActiveRow(newRow);
1706
- }
1707
- })
1708
-
1709
- // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
1710
- } else {
1711
- $grid.setTreeExpand(obj.row, true).then(() => {
1712
- if (toEnd === true) {
1713
- tableRows.push(newRow)
1714
- } else if (toSibling === true) {
1715
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1716
- tableRows.splice(addIndex, 0, newRow)
1717
- } else {
1718
- tableRows.splice(0, 0, newRow)
1719
- }
1720
- this.setValue(tableRows)
1721
- this.$nextTick(() => {
1722
- this.handleWbs();
1723
- $grid.setTreeExpand(obj.row, true).then(() => {
1724
- if (isEditTable) {
1725
- $grid.setActiveRow(newRow);
1726
- }
1727
- });
1728
- })
1729
- });
1730
- }
1731
- },
1732
- async removeEditRow(obj) {
1733
- this.removeTreeRow(obj)
1734
- },
1735
- //editTable end
1736
- getHttpConfigForUser() {
1737
- let defaultOption = {
1738
- addCreateInfo: true,
1739
- queryCreateInfo: window.$vueRoot.$store.getters.queryCreateInfo || "0"
1740
- };
1741
- return defaultOption;
1742
- },
1743
- handleWbs() {
1744
- if (this.widget.options.wbsEnabled) {
1745
- this.updateWbs();
1746
- }
1747
- },
1748
- updateWbs() {
1749
- let that = this;
1750
- let $grid = that.getGridTable();
1751
- let childrenField = $grid.treeConfig.children;
1752
- let fullData = $grid.getTableData().fullData;
1753
- let tableRows = this.formModel[that.fieldKeyName] || [];
1754
- let map = {}
1755
- let loopDo = (item, wbs) => {
1756
- item.f_wbs = wbs;
1757
- map[item._X_ROW_KEY] = wbs;
1758
- item[childrenField] && item[childrenField].forEach((subitem, subindex) => {
1759
- let sub_wbs = wbs + '.' + (subindex + 1) + '';
1760
- loopDo(subitem, sub_wbs)
1761
- })
1762
- }
1763
- fullData.forEach((item, index) => {
1764
- let wbs = (index + 1) + '';
1765
- loopDo(item, wbs)
1766
- })
1767
- $grid.updateData();
1768
- },
1769
- moveUpRow(obj) {
1770
- let row = obj.row;
1771
- let $grid = this.getGridTable();
1772
- let tableRows = this.formModel[this.fieldKeyName] || [];
1773
- let isTreeTable = this.widget.options.isTreeTable;
1774
- if (isTreeTable) {
1775
- let parentField = $grid.treeConfig.parentField;
1776
- let rowField = $grid.treeConfig.rowField || "id";
1777
- let paretValue = row[parentField];
1778
- let siblingRows = tableRows.filter(item => item[parentField] === paretValue)
1779
- if (siblingRows.length > 1) {
1780
- let currentIndex = tableRows.findIndex(item => item[rowField] == row[rowField]);
1781
- let index1 = siblingRows.findIndex(item => item[rowField] == row[rowField]);
1782
- if (index1 > 0) {
1783
- let prevRow = siblingRows[index1 - 1];
1784
- let prevIndex = tableRows.findIndex(item => item[rowField] == prevRow[rowField]);
1785
- tableRows.splice(currentIndex, 1)
1786
- tableRows.splice(prevIndex, 0, row)
1787
- this.setValue(tableRows);
1788
- this.$nextTick(() => {
1789
- this.handleWbs();
1790
- });
1791
- }
1792
- }
1793
- } else {
1794
- let rowIndex = $grid.getRowIndex(row);
1795
- if (rowIndex >= 0) {
1796
- tableRows.splice(rowIndex, 1)
1797
- tableRows.splice(rowIndex - 1, 0, row)
1798
- this.setValue(tableRows);
1799
- this.$nextTick(() => {
1800
- this.handleWbs();
1801
- });
1802
- }
1803
- }
1804
- },
1805
- moveDownRow(obj) {
1806
- let row = obj.row;
1807
- let $grid = this.getGridTable();
1808
- let tableRows = this.formModel[this.fieldKeyName] || [];
1809
- let isTreeTable = this.widget.options.isTreeTable;
1810
- if (isTreeTable) {
1811
- let parentField = $grid.treeConfig.parentField;
1812
- let rowField = $grid.treeConfig.rowField || "id";
1813
- let paretValue = row[parentField];
1814
- let siblingRows = tableRows.filter(item => item[parentField] === paretValue)
1815
- if (siblingRows.length > 1) {
1816
- let currentIndex = tableRows.findIndex(item => item[rowField] == row[rowField]);
1817
- let index1 = siblingRows.findIndex(item => item[rowField] == row[rowField]);
1818
- if (index1 < siblingRows.length - 1) {
1819
- let nextRow = siblingRows[index1 + 1];
1820
- let nextIndex = tableRows.findIndex(item => item[rowField] == nextRow[rowField]);
1821
- tableRows.splice(currentIndex, 1)
1822
- tableRows.splice(nextIndex, 0, row)
1823
- this.setValue(tableRows);
1824
- this.$nextTick(() => {
1825
- this.handleWbs();
1826
- });
1827
- }
1828
- }
1829
- } else {
1830
- let rowIndex = $grid.getRowIndex(row);
1831
- if (rowIndex < tableRows.length - 1) {
1832
- tableRows.splice(rowIndex, 1)
1833
- tableRows.splice(rowIndex + 1, 0, row)
1834
- this.setValue(tableRows);
1835
- this.$nextTick(() => {
1836
- this.handleWbs();
1837
- });
1838
- }
1839
- }
1840
- },
1841
-
1842
- openSortRowDialog(obj) {
1843
- let $grid = this.getGridTable();
1844
- let parentField = $grid.treeConfig.parentField;
1845
- let rowField = $grid.treeConfig.rowField || "id";
1846
- let row = obj.row;
1847
- let tableRows = this.formModel[this.fieldKeyName] || [];
1848
-
1849
- let sortParentRow = tableRows.find(item => item[rowField] === row[parentField])
1850
- let sortRows = tableRows.filter(item => item[parentField] === row[parentField])
1851
- this.sortRows = sortRows;
1852
- this.sortParentRow = sortParentRow;
1853
- this.showTreeMoveDialog = true;
1854
- },
1855
- confirmTreeMoveDialog(rows) {
1856
- if (this.widget.options.isEditTable) {
1857
- let reportTemplate = this.getFormRef().reportTemplate;
1858
- let formConfig = this.formConfig;
1859
- let entity = formConfig.entity;
1860
- let reqData = {
1861
- formCode: reportTemplate.formCode,
1862
- formVersion: reportTemplate.formVersion,
1863
- taBm: entity,
1864
- data: rows
1865
- };
1866
- let scriptCode = this.widget.options.sortScriptCode;
1867
- this.formHttp({
1868
- scriptCode: scriptCode,
1869
- data: reqData,
1870
- successMsg: true,
1871
- isConfirm: true,
1872
- confirmText: "您确定要保存排序吗?",
1873
- success: res => {
1874
- this.getGridTable().reloadTreeExpand(this.sortParentRow)
1875
- }
1876
- });
1877
- } else {
1878
- let $grid = this.getGridTable();
1879
- let rowField = $grid.treeConfig.rowField || "id";
1880
- let tableRows = this.formModel[this.fieldKeyName] || [];
1881
-
1882
- let ids = rows.map(item => item[rowField]);
1883
- let index = tableRows.findIndex(item => ids.includes(item[rowField]))
1884
- let items = tableRows.filter(item => !ids.includes(item[rowField]));
1885
- rows.forEach((row, index1) => {
1886
- items.splice(index + index1, 0, row);
1887
- })
1888
- this.setValue(items);
1889
- this.$nextTick(() => {
1890
- this.handleWbs();
1891
- })
1892
- }
1893
- },
1894
- // 通用行合并函数(将相同多列数据合并为一行)
1895
- mergeRowMethod(tableParam) {
1896
-
1897
- let {row, _rowIndex, column, visibleData} = tableParam;
1898
- let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
1899
- let unikey = this.widget.options.mergeRowKey
1900
- const cellValue = row[unikey]
1901
- let isItemLine = column.params?.isItemLine || false;
1902
- if (mergeRowEnabled && unikey && !isItemLine) {
1903
- const prevRow = visibleData[_rowIndex - 1]
1904
- let nextRow = visibleData[_rowIndex + 1]
1905
- if (prevRow && prevRow[unikey] === cellValue) {
1906
- return {rowspan: 0, colspan: 0}
1907
- } else {
1908
- let countRowspan = 1
1909
- while (nextRow && nextRow[unikey] === cellValue) {
1910
- nextRow = visibleData[++countRowspan + _rowIndex]
1911
- }
1912
- if (countRowspan > 1) {
1913
- return {rowspan: countRowspan, colspan: 1}
1914
- }
1915
- }
1916
-
1917
- } else {
1918
- // return { rowspan: 1, colspan: 1 }
1919
- }
1920
- },
1921
- mergeRowMethod2({row, _rowIndex, column, visibleData}) {
1922
- const fields = ['key']
1923
- const cellValue = row[column.field]
1924
- if (cellValue && fields.includes(column.field)) {
1925
- const prevRow = visibleData[_rowIndex - 1]
1926
- let nextRow = visibleData[_rowIndex + 1]
1927
- if (prevRow && prevRow[column.field] === cellValue) {
1928
- return {rowspan: 0, colspan: 0}
1929
- } else {
1930
- let countRowspan = 1
1931
- while (nextRow && nextRow[column.field] === cellValue) {
1932
- nextRow = visibleData[++countRowspan + _rowIndex]
1933
- }
1934
- if (countRowspan > 1) {
1935
- return {rowspan: countRowspan, colspan: 1}
1936
- }
1937
- }
1938
- }
1939
- }
1940
- }
1941
- };
1942
-
1943
- export default modules;
1
+ import emitter from "../../../../components/xform/utils/emitter";
2
+ import i18n from "../../../../components/xform/utils/i18n";
3
+ import refMixin from "../../../../components/xform/form-render/refMixin";
4
+ import containerItemMixin from "./containerItemMixin";
5
+
6
+ import * as formatUtil from "../../../../components/xform/utils/format.js";
7
+ import tableConfig from "../../../../components/table/config.js";
8
+ import { extendDeeply } from "../../../../utils/index.js";
9
+ import {
10
+ assembleAxiosConfig,
11
+ getReportGlobalMap,
12
+ generateId,
13
+ } from "../../../../components/xform/utils/util";
14
+ import { tableTreeMixins } from "../../../../mixins/tableTree/index.js";
15
+ import ItemEdit from "@/views/user/form/form_template/itemEdit.vue";
16
+
17
+ let modules = {};
18
+ const baseRefUtil = {
19
+ emitter,
20
+ i18n,
21
+ refMixin,
22
+ containerItemMixin,
23
+ formatUtil,
24
+ assembleAxiosConfig,
25
+ tableConfig,
26
+ getReportGlobalMap,
27
+ };
28
+
29
+ modules = {
30
+ mixins: [
31
+ baseRefUtil.emitter,
32
+ baseRefUtil.i18n,
33
+ baseRefUtil.refMixin,
34
+ baseRefUtil.containerItemMixin,
35
+ tableTreeMixins,
36
+ ],
37
+ componentName: "ContainerItem",
38
+ props: {
39
+ widget: Object,
40
+ parentWidget: Object,
41
+ parentList: Array,
42
+ indexOfParentList: Number,
43
+ subFormRowIndex: {
44
+ type: Number,
45
+ default: -1,
46
+ },
47
+ subFormColIndex: {
48
+ type: Number,
49
+ default: -1,
50
+ },
51
+ subFormRowId: {
52
+ type: String,
53
+ default: "",
54
+ },
55
+ },
56
+ inject: [
57
+ "refList",
58
+ "sfRefList",
59
+ "globalModel",
60
+ "getFormConfig",
61
+ "getGlobalDsv",
62
+ "previewState",
63
+ ],
64
+ data: function () {
65
+ let that = this;
66
+ return {
67
+ fieldModel: [],
68
+ selectedIndices: [],
69
+ pageSize: this.widget.options.pagination.pageSize,
70
+ pageSizes: this.widget.options.pagination.pageSizes,
71
+ currentPage: this.widget.options.pagination.currentPage,
72
+ total: this.widget.options.pagination.total,
73
+ formData: {
74
+ saleOrgName: "",
75
+ loginAccount: "",
76
+ mobile: "",
77
+ enabled: 1,
78
+ },
79
+ vxeOption: {},
80
+ requestAccess: null,
81
+ columnFormatMap: {
82
+ editInput: "input",
83
+ editNumber: "number",
84
+ editDate: "date",
85
+ editSelect: "select",
86
+ editSearch: "vabsearch",
87
+ editAttachment: "baseAttachment",
88
+ editStatus: "status",
89
+ aText: "a-text",
90
+ aLink: "a-link",
91
+ editDelete: "a-link",
92
+ editButton: "a-link",
93
+ button: "button",
94
+ addSiblingEditRow: "a-link",
95
+ addChildTreeRow: "a-link",
96
+ moveUpRow: "a-link",
97
+ moveDownRow: "a-link",
98
+ removeTreeRow: "a-link",
99
+ },
100
+ dataTableConfig: {},
101
+ widgets: [],
102
+ editWidgets: [],
103
+
104
+ sortParentRow: null,
105
+ sortRows: [],
106
+ showTreeMoveDialog: false,
107
+ tableConfig: {},
108
+ };
109
+ },
110
+ watch: {
111
+ fieldModel(val) {
112
+ this.formModel[this.fieldKeyName] = val || [];
113
+ },
114
+ },
115
+ computed: {
116
+ hasWf() {
117
+ return this.getFormRef().hasWf || false;
118
+ },
119
+ tableDatas: {
120
+ cache: !1,
121
+ get: function () {
122
+ return this.globalModel.formModel[this.fieldKeyName] || [];
123
+ },
124
+ },
125
+ formConfig: function () {
126
+ return this.getFormConfig();
127
+ },
128
+ paginationLayout: function () {
129
+ return this.widget.options.smallPagination
130
+ ? "prev, pager, next"
131
+ : "total, sizes, prev, pager, next, jumper";
132
+ },
133
+ customClass: function () {
134
+ return this.widget.options.customClass || "";
135
+ },
136
+ singleRowSelectFlag: function () {
137
+ return !this.widget.options.showCheckBox;
138
+ },
139
+ buttonsColumnFixed: function () {
140
+ return void 0 === this.widget.options.buttonsColumnFixed
141
+ ? "right"
142
+ : !!this.widget.options.buttonsColumnFixed &&
143
+ this.widget.options.buttonsColumnFixed;
144
+ },
145
+ formModel: {
146
+ cache: !1,
147
+ get: function () {
148
+ return this.globalModel.formModel;
149
+ },
150
+ },
151
+ formDataId() {
152
+ let formRef = this.getFormRef();
153
+ return formRef.dataId;
154
+ },
155
+ },
156
+ created: function () {
157
+ if (!this.formModel[this.fieldKeyName])
158
+ this.formModel[this.fieldKeyName] = [];
159
+ this.initRefList();
160
+ this.handleOnCreated();
161
+ },
162
+ mounted: async function () {
163
+ this.handleOnMounted();
164
+ this.initTableList();
165
+ },
166
+ beforeDestroy: function () {
167
+ this.unregisterFromRefList();
168
+ },
169
+ methods: {
170
+ getGridTableName() {
171
+ let formCode = this.getFormRef().reportTemplate.formCode;
172
+ let tableName = formCode + "_" + this.widget.options.name;
173
+ return tableName;
174
+ },
175
+ updateFormField: function () {
176
+ let rows = this.fieldModel || [];
177
+ let formRows = this.formModel[this.fieldKeyName];
178
+ if (formRows) {
179
+ this.formModel[this.fieldKeyName].splice(0, formRows.length);
180
+ this.formModel[this.fieldKeyName].push(...rows);
181
+ } else {
182
+ this.formModel[this.fieldKeyName] = rows;
183
+ }
184
+ },
185
+ setValue(val) {
186
+ // console.log("rows:",val);
187
+ let rows = val || [];
188
+ this.formModel[this.fieldKeyName] = rows;
189
+ let $grid = this.getGridTable();
190
+ this.fieldModel = rows;
191
+ // $grid.loadData(rows);
192
+ },
193
+ getValue() {
194
+ return this.formModel[this.fieldKeyName];
195
+ },
196
+ getFieldKeyName(widget) {
197
+ let o = widget.options.name;
198
+ return (widget.options.keyNameEnabled && widget.options.keyName) || o;
199
+ },
200
+ selectWidget: function (e) {
201
+ this.designer.setSelected(e);
202
+ },
203
+ formatterValue: function ({ cellValue, row, column }) {
204
+ if (cellValue === null || cellValue === undefined) return cellValue;
205
+
206
+ if (column.params && column.params.formatS)
207
+ switch (column.params.formatS) {
208
+ case "d1":
209
+ return baseRefUtil.formatUtil.formatDate1(cellValue);
210
+ case "d2":
211
+ return baseRefUtil.formatUtil.formatDate2(cellValue);
212
+ case "d3":
213
+ return baseRefUtil.formatUtil.formatDate3(cellValue);
214
+ case "d4":
215
+ return baseRefUtil.formatUtil.formatDate4(cellValue);
216
+ case "d5":
217
+ return baseRefUtil.formatUtil.formatDate4(cellValue);
218
+ case "n1":
219
+ return baseRefUtil.formatUtil.formatNumber1(cellValue);
220
+ case "n2":
221
+ return baseRefUtil.formatUtil.formatNumber2(cellValue);
222
+ case "n3":
223
+ return baseRefUtil.formatUtil.formatNumber3(cellValue);
224
+ case "n4":
225
+ return baseRefUtil.formatUtil.formatNumber4(cellValue);
226
+ case "n5":
227
+ return baseRefUtil.formatUtil.formatNumber5(cellValue);
228
+ case "n6":
229
+ return baseRefUtil.formatUtil.formatNumber6(cellValue);
230
+ case "n7":
231
+ return baseRefUtil.formatUtil.formatNumber7(cellValue);
232
+ }
233
+ return cellValue;
234
+ },
235
+ getRowIndex: function (e) {
236
+ return this.widget.options.tableData.lastIndexOf(e);
237
+ },
238
+ setTableColumns: function (e) {
239
+ var t = this;
240
+ (this.widget.options.tableColumns = e),
241
+ this.$nextTick(function () {
242
+ t.$refs.dataTable.doLayout();
243
+ });
244
+ },
245
+ setTableColumn: function (e) {
246
+ this.setTableColumns(e);
247
+ },
248
+ getTableData: function () {
249
+ return this.widget.options.tableData;
250
+ },
251
+ resetForm(options) {
252
+ let formData = this.formModel;
253
+ let ignoreFields = options?.ignoreFields || [];
254
+ this.widget.widgetList.forEach((subWidget) => {
255
+ if (
256
+ !ignoreFields.length ||
257
+ !ignoreFields.includes(subWidget.options.name)
258
+ ) {
259
+ let widgetRef = this.getWidgetRef(subWidget.options.name);
260
+ if (widgetRef && widgetRef.setValue) widgetRef.setValue(null);
261
+ }
262
+ });
263
+ },
264
+ searchEvent() {
265
+ this.getGridTable().commitProxy("reload");
266
+ },
267
+ async resetEvent(options) {
268
+ this.resetForm(options);
269
+ this.getGridTable().commitProxy("reload");
270
+ },
271
+ handleSearchClick() {
272
+ if (this.widget.options.onSearchTable) {
273
+ this.handleCustomEvent(this.widget.options.onSearchTable);
274
+ return;
275
+ }
276
+ this.searchEvent();
277
+ },
278
+ handleResetClick() {
279
+ if (this.widget.options.onResetTable) {
280
+ this.handleCustomEvent(this.widget.options.onResetTable);
281
+ return;
282
+ }
283
+ this.resetEvent();
284
+ },
285
+ openEditDialog(row, param) {
286
+ let formRef = this.getFormRef();
287
+ let parentTarget = formRef.$attrs["parent-target"];
288
+ parentTarget &&
289
+ parentTarget.$attrs.openEditDialog &&
290
+ parentTarget.$attrs.openEditDialog(row, param);
291
+ },
292
+ importExcel() {},
293
+ getGrid(that, tableRef) {
294
+ var $grid;
295
+ if (Array.isArray(that.$refs[tableRef])) {
296
+ $grid = that.$refs[tableRef][0];
297
+ } else {
298
+ $grid = that.$refs[tableRef];
299
+ }
300
+ return $grid;
301
+ },
302
+ getTableCondition: function () {
303
+ if (this.widget.options.tableCondition) {
304
+ var e = new Function(this.widget.options.tableCondition);
305
+ return e.call(this);
306
+ }
307
+ },
308
+ getSearchCondition: function () {
309
+ let extraAccessData = this.extraAccessData || {};
310
+ let searchFormData = this.getSearchFormData();
311
+ let defaultData = {};
312
+
313
+ // let globalReqData = baseRefUtil.getReportGlobalMap();//全局请求参数
314
+ let tableCondition = this.getTableCondition();
315
+ let conditions = {
316
+ ...defaultData,
317
+ ...tableCondition,
318
+ ...searchFormData,
319
+ ...extraAccessData,
320
+ // ...globalReqData
321
+ };
322
+ return conditions;
323
+ },
324
+ createColumns() {
325
+ let tableColumns = this.widget.options.tableColumns;
326
+ let newColumns = [];
327
+ newColumns.push({
328
+ type: "checkbox",
329
+ width: 48,
330
+ resizable: false,
331
+ fixed: "left",
332
+ });
333
+
334
+ const createColumn = (t, isChild) => {
335
+ let col = {
336
+ fixed: !!t.fixed && t.fixed,
337
+ field: t.prop,
338
+ title: this.getI18nLabel(t.label),
339
+ sortable: t.sortable,
340
+ align: t.align ? t.align : "center",
341
+ formatter: this.formatterValue,
342
+ params: {
343
+ formatS: t.formatS,
344
+ columnId: t.columnId,
345
+ exportType: t.exportType,
346
+ isItemLine: t.isItemLine,
347
+ footerDataType: t.footerDataType,
348
+ footerMethodConfg: t.footerMethodConfg,
349
+ },
350
+ visible: t.show,
351
+ slots: {},
352
+ };
353
+ if (t.treeNode) {
354
+ col.treeNode = true;
355
+ }
356
+ if (t.children && t.children.length) {
357
+ col.align = "center";
358
+ delete col.field;
359
+ let childColumns = t.children.map((child) => {
360
+ return createColumn(child, true);
361
+ });
362
+ col.children = childColumns;
363
+
364
+ col.sortable = false;
365
+ col.filterType = false;
366
+ } else {
367
+ col.width = t.width;
368
+ if (isChild) {
369
+ if (col.title && col.field) {
370
+ col.filters = [
371
+ {
372
+ data: {},
373
+ },
374
+ ];
375
+ col.filterRender = {
376
+ name: "FilterContent",
377
+ };
378
+ }
379
+ }
380
+ }
381
+ col = addColumProperty(col, t);
382
+ return col;
383
+ };
384
+
385
+ const addColumProperty = (col, t) => {
386
+ let columnOption;
387
+ let widget;
388
+ let columnWidgetConfig = this.getColumnWidgetConfig(t);
389
+ let { columnSelectedWidget, columnEditFields } = columnWidgetConfig;
390
+ if (columnSelectedWidget) {
391
+ widget = columnSelectedWidget;
392
+ columnOption = widget.options;
393
+ } else {
394
+ columnOption = {};
395
+ }
396
+
397
+ let { columnSelectedWidget: editWidget } = this.getColumnWidgetConfig(
398
+ t,
399
+ true
400
+ );
401
+
402
+ let params = {
403
+ ...columnOption,
404
+ widget: widget,
405
+ formatS: t.formatS,
406
+ required: t.required || false,
407
+ columnConfig: t,
408
+ editWidget,
409
+ };
410
+ Object.assign(col.params, params);
411
+ if (!col.children || !col.children.length) {
412
+ if (t.formatS == "render") {
413
+ let r = t.render ? new Function("params", "h", t.render) : null;
414
+ col.slots.default = (params, h) => {
415
+ return r ? r.call(this, params, h) : "";
416
+ };
417
+ } else if (columnSelectedWidget) {
418
+ // col.slots.default = columnSelectedWidget.id;
419
+ col.slots.default = "widget";
420
+ } else if (t.formatS == "editTreeButtonGroup") {
421
+ col.slots.default = "editTreeButtonGroup";
422
+ }
423
+
424
+ if (editWidget) {
425
+ col.editRender = { name: "input" };
426
+ // col.slots.edit = editWidget.id;
427
+ col.slots.edit = "editWidget";
428
+ }
429
+ }
430
+ if (t.tableColumnConfig) {
431
+ let tableColumnConfig =
432
+ this.handleCustomEvent(t.tableColumnConfig) || {};
433
+ col = extendDeeply(col, tableColumnConfig);
434
+ }
435
+ return col;
436
+ };
437
+
438
+ let formRef = this.getFormRef();
439
+ tableColumns.forEach((t) => {
440
+ let col = createColumn(t);
441
+ newColumns.push(col);
442
+ });
443
+
444
+ if (
445
+ baseRefUtil.tableConfig &&
446
+ baseRefUtil.tableConfig.className == "list-table"
447
+ ) {
448
+ if (tableColumns.length) {
449
+ let tableColumn = [tableColumns.length - 1];
450
+ if (tableColumn.fixed != "right") {
451
+ newColumns.push({
452
+ width: 47,
453
+ title: "",
454
+ fixed: "right",
455
+ sortable: false,
456
+ });
457
+ }
458
+ }
459
+ }
460
+ return this.$baseLodash.cloneDeep(newColumns);
461
+ },
462
+ initTableList() {
463
+ let that = this;
464
+ let path = null;
465
+ let paramFun = null;
466
+ // let mainDataSetDTO = null;
467
+ let requestAccess = this.requestAccess;
468
+ let tableRef = this.getTableRef();
469
+ let formDataModel = this.getFormRef().formDataModel;
470
+ let isQueryTable = this.widget.options.isQueryTable || false;
471
+ let isDataPage = this.widget.options.accessReturnType == "2";
472
+ let reportTemplate = this.getFormRef().reportTemplate;
473
+ let formCode = reportTemplate.formCode;
474
+ let dataId = this.formDataId;
475
+ let accessScript = this.widget.options.accessScript;
476
+ let searchColumns = null;
477
+ if (isQueryTable) {
478
+ path = "#";
479
+ paramFun = () => {
480
+ let conditions = this.getSearchCondition();
481
+ let $grid = this.getGridTable();
482
+ if (this.widget.options.showPagination) {
483
+ let proxyInfo = $grid.getProxyInfo();
484
+ let searchCount = true;
485
+ let isQueryAllPage = $grid.isQueryAllPage;
486
+ if (isQueryAllPage == false) {
487
+ searchCount = false;
488
+ }
489
+ let pager = proxyInfo ? proxyInfo.pager : null;
490
+ if (pager) {
491
+ conditions.current = pager.currentPage;
492
+ conditions.size = pager.pageSize;
493
+ conditions.searchCount = searchCount;
494
+ }
495
+ }
496
+
497
+ /*let formData = {
498
+ accessCode: requestAccess.accessCode,
499
+ conditions: conditions
500
+ };*/
501
+ let formData = conditions;
502
+ return formData;
503
+ };
504
+
505
+ searchColumns = [];
506
+ let widgetList = this.widget.widgetList;
507
+
508
+ let getDateItem = (widget) => {
509
+ let options = widget.options;
510
+
511
+ let dateConfig = {
512
+ format: options.format,
513
+ valueFormat: options.valueFormat,
514
+ isRange: widget.type == "time-range",
515
+ };
516
+ let typeMap = {
517
+ input: { type: "input" },
518
+ number: { type: "number" },
519
+ inputBatch: { type: "inputBatch" },
520
+ date: {
521
+ type: "date",
522
+ widgetType: options.type,
523
+ widgetConfig: dateConfig,
524
+ },
525
+ time: { type: "time", isRange: false, widgetConfig: dateConfig },
526
+ "date-range": {
527
+ type: "date",
528
+ widgetType: "daterange",
529
+ widgetConfig: dateConfig,
530
+ },
531
+ "time-range": {
532
+ type: "time",
533
+ widgetConfig: dateConfig,
534
+ },
535
+ };
536
+ let item = typeMap[widget.type] || {};
537
+ return item;
538
+ };
539
+
540
+ widgetList.forEach((widget) => {
541
+ if ("container" !== widget.category) {
542
+ let options = widget.options;
543
+ let item = getDateItem(widget);
544
+ let type = item.type ?? null;
545
+ // let widgetType = item.widgetType ?? widgetType;
546
+ // let isRange = item.isRange || false;
547
+ searchColumns.push({
548
+ title: this.getI18nLabel(options.label),
549
+ field: this.getFieldKeyName(widget),
550
+ // type,
551
+ // widgetType,
552
+ // isRange,
553
+ common: true,
554
+ disabled: options.disabled,
555
+ defaultValueEnabled: !!type,
556
+ slot: options.name,
557
+ widget: widget,
558
+ formItem: false,
559
+ ...item,
560
+ });
561
+ }
562
+ });
563
+ }
564
+
565
+ let formRef = this.getFormRef();
566
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
567
+ this.dataTableConfig = dataTableConfig;
568
+
569
+ let columns = this.createColumns();
570
+ this.widgets = columns
571
+ .filter((column) => !!column?.params?.widget)
572
+ .map((column) => column.params.widget);
573
+ this.editWidgets = columns
574
+ .filter((column) => !!column?.params?.editWidget)
575
+ .map((column) => column.params.editWidget);
576
+
577
+ let height =
578
+ this.widget.options.tableHeight || (isQueryTable ? "auto" : null);
579
+ if (
580
+ !this.widget.options.tableHeight &&
581
+ isQueryTable &&
582
+ this.previewState
583
+ ) {
584
+ height = "550px";
585
+ }
586
+
587
+ let formConfig = this.formConfig;
588
+ let scriptCode = this.getScriptCode();
589
+
590
+ let otherParam = {};
591
+ let attachmentType = this.getAttachmentType();
592
+ if (attachmentType.length) {
593
+ otherParam.attachmentType = attachmentType;
594
+ }
595
+ let thirdtabm = this.getThirdtabm();
596
+ if (thirdtabm.length) {
597
+ otherParam.thirdtabm = thirdtabm;
598
+ }
599
+
600
+ let pagerConfig = {};
601
+ let editDefaultRow, treeNodeParam, treeConfig;
602
+ let isTreeTable = this.widget.options.isTreeTable;
603
+ if (isTreeTable) {
604
+ pagerConfig.pagerClass = "is--hidden";
605
+ if (this.widget.options.editDefaultRow) {
606
+ editDefaultRow = this.handleCustomEvent(
607
+ this.widget.options.editDefaultRow
608
+ );
609
+ }
610
+ treeNodeParam = (row) => {
611
+ return {
612
+ [this.widget.options.parentField]: row.id,
613
+ };
614
+ };
615
+ treeConfig = {
616
+ lazy: false,
617
+ children: "f_children",
618
+ hasChild: "f_has_child", // 设置是否有子节点标识
619
+ parentField: "f_parent",
620
+ transform: true,
621
+ expandAll: true,
622
+ loadMethod({ $table, row }) {
623
+ // 模拟后台接口
624
+ let $grid = that.getGridTable();
625
+ let parentField = $grid.treeConfig.parentField;
626
+ return new Promise((resolve, reject) => {
627
+ let treeParam = that.widget.options.tableConfig?.treeNodeParam;
628
+ let reqPram = {};
629
+ if (treeParam) {
630
+ reqPram = treeParam(row) || {};
631
+ }
632
+ Object.assign(reqPram, {
633
+ [parentField]: row.id,
634
+ });
635
+ let accessParam = this.getAccessParam() || {};
636
+ let defaultOption = that.getHttpConfigForUser();
637
+ that.formHttp({
638
+ scriptCode: scriptCode,
639
+ data: {
640
+ formCode: formCode,
641
+ formVersion: reportTemplate.formVersion,
642
+ taBm: that.fieldKeyName,
643
+ data: {
644
+ ...reqPram,
645
+ ...otherParam,
646
+ ...accessParam,
647
+ },
648
+ },
649
+ callback: (res) => {
650
+ if (res.type == "success") {
651
+ let rows = res.objx
652
+ ? res.objx.records || res.objx || []
653
+ : [];
654
+
655
+ let hasChildField = $grid.treeConfig.hasChild;
656
+ if (row[hasChildField] && !rows.length) {
657
+ row[hasChildField] = false;
658
+ }
659
+
660
+ resolve(rows);
661
+ let treeCallback =
662
+ that.widget.options.tableConfig?.treeCallback;
663
+ if (treeCallback) {
664
+ that.$nextTick(() => {
665
+ setTimeout(function () {
666
+ treeCallback(rows);
667
+ }, 0);
668
+ });
669
+ }
670
+ } else {
671
+ reject(res);
672
+ }
673
+ },
674
+ });
675
+ });
676
+ },
677
+ };
678
+ }
679
+ let editOpts = {};
680
+ if (this.widget.options.isEditTable) {
681
+ editOpts = {
682
+ keepSource: true,
683
+ editConfig: {
684
+ trigger: "manual",
685
+ mode: "row",
686
+ showStatus: true,
687
+ autoClear: false,
688
+ },
689
+ };
690
+ }
691
+ let showFooter = this.widget.options.showGridFooter || false;
692
+ let tableOption = {
693
+ // vue: this,
694
+ tableRef: tableRef,
695
+ tableName: this.getGridTableName(),
696
+ param: paramFun,
697
+ columns: columns,
698
+ searchColumns: searchColumns,
699
+ vform: true,
700
+ config: {
701
+ height: height,
702
+ showFooter,
703
+ pagerConfig,
704
+ treeConfig,
705
+ ...editOpts,
706
+ ...dataTableConfig.config,
707
+ },
708
+ exportAjax: (param) => {
709
+ let $grid = this.getGridTable();
710
+ let pageSize = param.size;
711
+ let currentPage = param.current;
712
+ let page = { pageSize, currentPage };
713
+ let customParam = {
714
+ config: {
715
+ modal: false,
716
+ },
717
+ };
718
+ return $grid.$options.propsData.proxyConfig.ajax.query.call(this, {
719
+ page,
720
+ param,
721
+ customParam,
722
+ });
723
+ },
724
+ // treeNodeUrl,
725
+ editDefaultRow,
726
+ treeNodeParam,
727
+ };
728
+
729
+ if (isQueryTable) {
730
+ /*if(this.widget.options.isTreeTable){
731
+ tableOption.config.pagerConfig.autoHidden = false;
732
+ }*/
733
+ tableOption.path = path;
734
+ tableOption.config.proxyConfig = {
735
+ props: {
736
+ result: isDataPage ? "objx.records" : "objx", // 配置响应结果列表字段
737
+ total: isDataPage ? "objx.total" : "objx.length", // 配置响应结果总页数字段
738
+ },
739
+ ajax: {
740
+ // 接收 Promise 对象
741
+ query: ({ page, sorts, filters, form, param, customParam }) => {
742
+ let formData = tableOption.param ? tableOption.param() || {} : {};
743
+ const queryParams = Object.assign({}, formData);
744
+
745
+ // 处理排序条件
746
+ /*if (sorts) {
747
+ const firstSort = sorts[0];
748
+ if (firstSort) {
749
+ queryParams.sort = firstSort.property;
750
+ queryParams.order = firstSort.order;
751
+ }
752
+ }*/
753
+
754
+ // 处理筛选条件
755
+ if (filters) {
756
+ filters.forEach(({ property, values }) => {
757
+ queryParams[property] = values.join(",");
758
+ });
759
+ }
760
+
761
+ if (page.pageSize !== undefined) {
762
+ queryParams["size"] = page.pageSize;
763
+ queryParams["current"] = page.currentPage;
764
+ }
765
+
766
+ let $grid = this.getGridTable();
767
+ let isQueryAllPage = $grid.isQueryAllPage;
768
+ let pathStr1 = "";
769
+ if (isQueryAllPage === false) {
770
+ queryParams.searchCount = false;
771
+ }
772
+ Object.assign(queryParams, param);
773
+
774
+ var reqPath = typeof path == "function" ? path() : path;
775
+ let accessReturnType = this.widget.options.accessReturnType || 2;
776
+ let scriptCode = this.getScriptCode();
777
+ return new Promise((resolve, reject) => {
778
+ /*let items = [
779
+ {
780
+ "create_by": "admin",
781
+ "object_foreign_id": 224,
782
+ "f_code": "202501068569",
783
+ "f_grade": "1",
784
+ "f_name": "呃呃呃呃呃呃俄文",
785
+ "company_code": "mk1",
786
+ "id": 95,
787
+ "modify_by": "admin",
788
+ "create_date": "2025-01-06 17:53:34",
789
+ "f_flag": "A",
790
+ "modify_date": "2025-01-16 21:11:44"
791
+ },
792
+ {
793
+ "create_by": "admin",
794
+ "object_foreign_id": 224,
795
+ "f_code": "202501068569",
796
+ "f_grade": "1",
797
+ "f_name": "呃呃呃呃呃呃俄文",
798
+ "company_code": "mk1",
799
+ "id": 10095,
800
+ "modify_by": "admin",
801
+ "create_date": "2025-01-06 17:53:34",
802
+ "f_flag": "A",
803
+ "modify_date": "2025-01-16 21:11:44"
804
+ },
805
+ {
806
+ "create_by": "admin",
807
+ "object_foreign_id": 221,
808
+ "f_code": "202501037347",
809
+ "f_grade": "1",
810
+ "f_name": "张三",
811
+ "company_code": "mk1",
812
+ "id": 92,
813
+ "modify_by": "admin",
814
+ "create_date": "2025-01-03 17:49:55",
815
+ "f_flag": "A",
816
+ "modify_date": "2025-01-05 17:21:46"
817
+ },
818
+ {
819
+ "create_by": "admin",
820
+ "object_foreign_id": 222,
821
+ "f_code": "202501037348",
822
+ "f_grade": "2",
823
+ "f_name": "李四",
824
+ "company_code": "mk1",
825
+ "id": 93,
826
+ "modify_by": "admin",
827
+ "create_date": "2025-01-03 17:49:55",
828
+ "f_flag": "A",
829
+ "modify_date": "2025-01-03 17:49:55"
830
+ },
831
+ {
832
+ "create_by": "admin",
833
+ "object_foreign_id": 222,
834
+ "f_code": "202501037348",
835
+ "f_grade": "2",
836
+ "f_name": "李四",
837
+ "company_code": "mk1",
838
+ "id": 10093,
839
+ "modify_by": "admin",
840
+ "create_date": "2025-01-03 17:49:55",
841
+ "f_flag": "A",
842
+ "modify_date": "2025-01-03 17:49:55"
843
+ },
844
+ {
845
+ "create_by": "admin",
846
+ "object_foreign_id": 223,
847
+ "f_code": "202501037349",
848
+ "f_grade": "3",
849
+ "f_name": "王五",
850
+ "company_code": "mk1",
851
+ "id": 94,
852
+ "modify_by": "admin",
853
+ "create_date": "2025-01-03 17:49:55",
854
+ "f_flag": "A",
855
+ "modify_date": "2025-01-03 17:49:55"
856
+ },
857
+ {
858
+ "create_by": "admin",
859
+ "object_foreign_id": 218,
860
+ "f_code": "202501037340",
861
+ "f_grade": "4",
862
+ "f_name": "林一",
863
+ "company_code": "mk1",
864
+ "id": 89,
865
+ "modify_by": "admin",
866
+ "create_date": "2025-01-03 15:02:31",
867
+ "f_flag": "A",
868
+ "modify_date": "2025-01-03 15:02:31"
869
+ },
870
+ {
871
+ "create_by": "admin",
872
+ "object_foreign_id": 219,
873
+ "f_code": "202501037341",
874
+ "f_grade": "3",
875
+ "f_name": "林二",
876
+ "company_code": "mk1",
877
+ "id": 90,
878
+ "modify_by": "admin",
879
+ "create_date": "2025-01-03 15:02:31",
880
+ "f_flag": "A",
881
+ "modify_date": "2025-01-03 15:02:31"
882
+ }
883
+ ];
884
+ let currentId = 0;
885
+ let records = [];
886
+ for(let i=0;i<50;i++){
887
+ let newItems = items.map((item,index)=>{
888
+ let flag = (index+1)%2!=0;
889
+ let line = flag ? index : (index-1)
890
+ let f_code = '10000'+i+''+line;
891
+ currentId++
892
+ return {
893
+ ...item,
894
+ id:currentId,
895
+ f_code
896
+ };
897
+ })
898
+ records.push(...newItems)
899
+ }
900
+
901
+ let res = {
902
+ "time": "2025-03-21 11:24:55",
903
+ "type": "success",
904
+ "content": "success",
905
+ "objx": {
906
+ "records": [],
907
+ "total": 77,
908
+ "size": 100,
909
+ "current": 1,
910
+ "orders": [],
911
+ "optimizeCountSql": true,
912
+ "hitCount": false,
913
+ "countId": null,
914
+ "maxLimit": null,
915
+ "searchCount": true,
916
+ "pages": 1
917
+ },
918
+ "rmid": null
919
+ };
920
+ res.objx.records = records
921
+ resolve(res);
922
+ return*/
923
+ let reqData = {
924
+ ...queryParams,
925
+ };
926
+ if (scriptCode) {
927
+ let index = 0;
928
+ let toDo = () => {
929
+ // let f = new Function("dataId", "formCode", "param", "done", accessScript);
930
+ let done = (res) => {
931
+ resolve(res);
932
+ if (res.type == "success") {
933
+ let rows = res.objx
934
+ ? res.objx.records || res.objx || []
935
+ : [];
936
+ if (that.widget.options.isTreeTable) {
937
+ if (rows.length > 0) {
938
+ let fullAllDataRowMap =
939
+ $grid.$refs.xTable.fullAllDataRowMap;
940
+ let parentField = $grid.treeConfig.parentField;
941
+ let expandAll = $grid.treeConfig.expandAll || false;
942
+ let isLazy = $grid.treeConfig.lazy;
943
+ let expandIds = rows
944
+ .filter((item) => item[parentField])
945
+ .map((item) => item[parentField]);
946
+ let expandRows = expandIds.length
947
+ ? rows.filter((item) =>
948
+ expandIds.includes(item.id)
949
+ )
950
+ : [];
951
+ if (expandAll && expandRows.length) {
952
+ that.$nextTick(() => {
953
+ setTimeout(function () {
954
+ $grid.treeConfig.lazy = false;
955
+ $grid.setTreeExpand(expandRows, true);
956
+ expandRows.forEach((lineData) => {
957
+ if (
958
+ $grid.$refs.xTable.isTreeExpandByRow(
959
+ lineData
960
+ )
961
+ ) {
962
+ let rest =
963
+ fullAllDataRowMap.get(lineData);
964
+ rest.treeLoaded = true;
965
+ }
966
+ });
967
+
968
+ $grid.treeConfig.lazy = isLazy;
969
+ }, 0);
970
+ });
971
+ }
972
+
973
+ let row = rows.find((item) => !item[parentField]);
974
+ if (
975
+ row &&
976
+ (!expandAll || !expandIds.includes(row.id))
977
+ ) {
978
+ let hasChild = $grid.treeConfig.hasChild;
979
+ if (row[hasChild]) {
980
+ that.$nextTick(() => {
981
+ setTimeout(function () {
982
+ $grid.setTreeExpand(row, true);
983
+ }, 0);
984
+ });
985
+ }
986
+ }
987
+ }
988
+ }
989
+ that.$nextTick(() => {
990
+ setTimeout(function () {
991
+ tableOption.callback && tableOption.callback(rows);
992
+ that.handleCustomEvent(
993
+ that.widget.options.formScriptCallback,
994
+ ["rows"],
995
+ [rows]
996
+ );
997
+ }, 0);
998
+ });
999
+ }
1000
+ };
1001
+ this.loadDefaultQueryList(reqData, done, customParam);
1002
+ };
1003
+ let loopHandle = () => {
1004
+ if (index < 500 && $grid.tableFormStop === true) {
1005
+ //阻塞列表查询,或者次数达到500时,自动释放
1006
+ index++;
1007
+ setTimeout(() => {
1008
+ loopHandle();
1009
+ }, 10);
1010
+ } else {
1011
+ if ($grid.tableFormStop) $grid.tableFormStop = false;
1012
+ toDo();
1013
+ }
1014
+ };
1015
+ loopHandle();
1016
+ } else {
1017
+ resolve();
1018
+ }
1019
+ });
1020
+ },
1021
+ },
1022
+ };
1023
+ tableOption.callback = (rows) => {
1024
+ // this.fieldModel = rows;
1025
+ this.formModel[this.fieldKeyName] = rows;
1026
+ };
1027
+ }
1028
+
1029
+ if (isTreeTable) {
1030
+ tableOption.filterType = false;
1031
+ }
1032
+
1033
+ if (this.widget.options.tableConfig) {
1034
+ let tableConfig =
1035
+ this.handleCustomEvent(this.widget.options.tableConfig) || {};
1036
+ tableOption = extendDeeply(tableOption, tableConfig);
1037
+ this.tableConfig = tableConfig;
1038
+ }
1039
+
1040
+ if (tableOption.config.showFooter && !tableOption.config.footerMethod) {
1041
+ let footerColumnIds = columns
1042
+ .filter((item) => !!item.params?.footerDataType)
1043
+ .map((item) => item.params.columnId);
1044
+ if (footerColumnIds.length) {
1045
+ tableOption.config.footerMethod = (param) => {
1046
+ let { columns: column1s, data } = param;
1047
+ return [
1048
+ column1s.map((column, columnIndex) => {
1049
+ let columnId = column.params?.columnId;
1050
+ if (columnId && footerColumnIds.includes(columnId)) {
1051
+ let footerDataType = column.params.footerDataType;
1052
+ if (footerDataType == "1") {
1053
+ //求和
1054
+ return this.sumNum(data, column.field);
1055
+ } else if (footerDataType == "2") {
1056
+ //求平均值
1057
+ return this.meanNum(data, column.field);
1058
+ } else if (footerDataType == "3") {
1059
+ if (column.params.footerMethodConfg) {
1060
+ let n = new Function(
1061
+ "dataId",
1062
+ "formCode",
1063
+ "param",
1064
+ column.params.footerMethodConfg
1065
+ );
1066
+ return n.call(this, dataId, formCode, param) ?? null;
1067
+ }
1068
+ }
1069
+ }
1070
+ return null;
1071
+ }),
1072
+ ];
1073
+ };
1074
+ }
1075
+ }
1076
+ tableOption.vue = this;
1077
+ this.$vxeTableUtil.initVxeTable(tableOption).then((opts) => {
1078
+ this.vxeOption = opts;
1079
+ if (!isQueryTable) {
1080
+ setTimeout(() => {
1081
+ this.loadAccessData(1);
1082
+ }, 20);
1083
+ }
1084
+ });
1085
+ },
1086
+ meanNum(list, field) {
1087
+ let count = this.sumNum(list, field);
1088
+ return this.$baseDiv(count, list.length);
1089
+ },
1090
+ sumNum(list, field) {
1091
+ let count = 0;
1092
+ list.forEach((item) => {
1093
+ count = this.$baseAdd(count, item[field]);
1094
+ });
1095
+ return count;
1096
+ },
1097
+ getSearchFormData() {
1098
+ let map = { condition: [] };
1099
+ let formData = this.globalModel.formModel;
1100
+ let widgetList = this.widget.widgetList;
1101
+ if (!!widgetList && widgetList.length > 0) {
1102
+ let loop = (wItem) => {
1103
+ if (wItem.category === "container") {
1104
+ loop(wItem);
1105
+ } else {
1106
+ let formField = this.getFieldKeyName(wItem);
1107
+ let vaule = formData[formField];
1108
+ if (vaule !== null && vaule !== undefined && vaule !== "") {
1109
+ if (!Array.isArray(vaule) || vaule.length > 0) {
1110
+ let item = {
1111
+ value: vaule,
1112
+ field: formField,
1113
+ filter: null,
1114
+ };
1115
+ let wType = wItem.type;
1116
+ if (["date-range", "time-range"].includes(wType)) {
1117
+ item.filter = "between";
1118
+ } else if (
1119
+ ["input-batch", "checkbox"].includes(wType) ||
1120
+ (wType == "select" && wItem.options.multiple)
1121
+ ) {
1122
+ item.filter = "in";
1123
+ } else if (
1124
+ ["radio", "time", "date"].includes(wType) ||
1125
+ (wType == "select" && !wItem.options.multiple)
1126
+ ) {
1127
+ item.filter = "eq";
1128
+ } else {
1129
+ item.filter = "like";
1130
+ }
1131
+ map.condition.push(item);
1132
+ }
1133
+ }
1134
+ }
1135
+ };
1136
+ widgetList.forEach((wItem) => {
1137
+ loop(wItem);
1138
+ });
1139
+ }
1140
+ return map;
1141
+ },
1142
+ getUrl() {
1143
+ let accessUrl = this.widget.options.accessUrl;
1144
+ return accessUrl || USER_PREFIX + `/form_ins/getFormInsData`;
1145
+ },
1146
+ getAttachmentType() {
1147
+ let vailColumns = this.widget.options.tableColumns.filter(
1148
+ (item) => item.prop && item.label
1149
+ );
1150
+ let result = vailColumns
1151
+ .filter((item) => {
1152
+ return item.formatS == "editAttachment";
1153
+ })
1154
+ .map((item) => item.prop);
1155
+ return result;
1156
+ },
1157
+ getThirdtabm() {
1158
+ let vailColumns = this.widget.options.tableColumns.filter(
1159
+ (item) => item.prop && item.label
1160
+ );
1161
+ let result = vailColumns
1162
+ .filter((item) => {
1163
+ return (
1164
+ item.formatS == "editSearch" && item.columnOption.multipleChoices
1165
+ );
1166
+ })
1167
+ .map((item) => item.prop);
1168
+ return result;
1169
+ },
1170
+
1171
+ loadDefaultViewList() {
1172
+ let dataId = this.formDataId;
1173
+ let reportTemplate = this.getFormRef().reportTemplate;
1174
+ let formCode = reportTemplate.formCode;
1175
+ let accessParam = this.getAccessParam() || {};
1176
+ let otherParam = {};
1177
+ let attachmentType = this.getAttachmentType();
1178
+ if (attachmentType.length) {
1179
+ otherParam.attachmentType = attachmentType;
1180
+ }
1181
+ let thirdtabm = this.getThirdtabm();
1182
+ if (thirdtabm.length) {
1183
+ otherParam.thirdtabm = thirdtabm;
1184
+ }
1185
+ let scriptCode = this.getScriptCode();
1186
+ return this.formHttp({
1187
+ /*url: "/" + reportTemplate.serviceName + "/form_ins/getList",*/
1188
+ scriptCode: scriptCode,
1189
+ data: {
1190
+ formCode: formCode,
1191
+ formVersion: reportTemplate.formVersion,
1192
+ taBm: this.fieldKeyName,
1193
+ data: {
1194
+ id: dataId,
1195
+ ...otherParam,
1196
+ ...accessParam,
1197
+ },
1198
+ },
1199
+ callback: (res) => {
1200
+ let $grid = this.getGridTable();
1201
+ let rows = res.objx ? res.objx.records || res.objx || [] : [];
1202
+ let defaultRow = this.createNewTableData();
1203
+ rows = rows.map((row) => {
1204
+ return {
1205
+ ...defaultRow,
1206
+ ...row,
1207
+ };
1208
+ });
1209
+ this.setValue(rows);
1210
+ this.$nextTick(() => {
1211
+ /*if (this.widget.options.isTreeTable) {
1212
+ let $grid = this.getGridTable();
1213
+ $grid.treeConfig.lazy = false;
1214
+ $grid.setAllTreeExpand(true);
1215
+ }*/
1216
+ this.tableConfig.callback && this.tableConfig.callback(rows);
1217
+ this.handleCustomEvent(
1218
+ this.widget.options.formScriptCallback,
1219
+ ["rows"],
1220
+ [rows]
1221
+ );
1222
+ this.$forceUpdate();
1223
+ });
1224
+ },
1225
+ });
1226
+ },
1227
+ getAccessParam() {
1228
+ if (!this.widget.options.formScriptParam) return;
1229
+ return this.handleCustomEvent(this.widget.options.formScriptParam);
1230
+ },
1231
+ getScriptCode() {
1232
+ let accessReturnType = this.widget.options.accessReturnType;
1233
+ let defaultScriptCode = "getList";
1234
+ if (accessReturnType == 1) {
1235
+ defaultScriptCode = "getList";
1236
+ } else if (accessReturnType == 2) {
1237
+ defaultScriptCode = "getPage";
1238
+ }
1239
+ let scriptCode = this.widget.options.formScriptCode || defaultScriptCode;
1240
+ return scriptCode;
1241
+ },
1242
+ loadDefaultQueryList(reqData, done, customParam) {
1243
+ let reportTemplate = this.getFormRef().reportTemplate;
1244
+ let prefix = "/" + reportTemplate.serviceName;
1245
+ let formCode = reportTemplate.formCode;
1246
+ let formConfig = this.formConfig;
1247
+ let accessReturnType = this.widget.options.accessReturnType;
1248
+ let scriptCode = this.getScriptCode();
1249
+ let accessParam = this.getAccessParam() || {};
1250
+
1251
+ let otherParam = {};
1252
+ let attachmentType = this.getAttachmentType();
1253
+ if (attachmentType.length) {
1254
+ otherParam.attachmentType = attachmentType;
1255
+ }
1256
+
1257
+ let defaultOption = this.getHttpConfigForUser();
1258
+
1259
+ let ajaxConfig = customParam?.config || {};
1260
+
1261
+ return this.formHttp({
1262
+ // url: prefix + "/form_ins/getPage",
1263
+ scriptCode: scriptCode,
1264
+ data: {
1265
+ formCode: formCode,
1266
+ formVersion: reportTemplate.formVersion,
1267
+ taBm: this.fieldKeyName,
1268
+ data: {
1269
+ ...reqData,
1270
+ ...otherParam,
1271
+ ...accessParam,
1272
+ },
1273
+ },
1274
+ ...defaultOption,
1275
+ ...ajaxConfig,
1276
+ callback: (res) => {
1277
+ done(res);
1278
+ },
1279
+ });
1280
+ },
1281
+ loadAccessData(flag) {
1282
+ if (flag === 1) {
1283
+ let tableConfig = this.tableConfig;
1284
+ let accessEnabled = tableConfig.accessEnabled ?? true;
1285
+ if (accessEnabled === false) {
1286
+ return;
1287
+ }
1288
+ if (this.formConfig.isLoadEntity && !this.formDataId) {
1289
+ return;
1290
+ }
1291
+ }
1292
+
1293
+ let scriptCode = this.getScriptCode();
1294
+ if (scriptCode) {
1295
+ this.loadDefaultViewList();
1296
+ }
1297
+ },
1298
+ getReqParam(item, dataId, billData) {
1299
+ let param = {};
1300
+ if (item.accessParam) {
1301
+ if (typeof item.accessParam === "string") {
1302
+ let n = new Function("billData", item.accessParam);
1303
+ param = n.call(this, billData);
1304
+ } else {
1305
+ param = item.accessParam;
1306
+ }
1307
+ } else {
1308
+ param = { id: dataId };
1309
+ }
1310
+ return param;
1311
+ },
1312
+ getTableRef() {
1313
+ let tableRef = this.widget.id;
1314
+ return tableRef;
1315
+ },
1316
+ exportData(option) {
1317
+ let tableRef = this.getTableRef();
1318
+ let serviceName = this.getFormRef().reportTemplate.serviceName;
1319
+ option.prefix = option.prefix || "/" + serviceName;
1320
+ this.$excelExport({ targetRef: tableRef, ...option });
1321
+ },
1322
+ async deleteRow(row, rowIndex) {
1323
+ let isTreeTable = this.widget.options.isTreeTable;
1324
+ if (isTreeTable) {
1325
+ this.removeTreeRow({ row });
1326
+ return;
1327
+ }
1328
+ let $grid = this.getGridTable();
1329
+ $grid.remove(row);
1330
+ let tableData = $grid.getTableData();
1331
+ let isEditTable = this.widget.options.isEditTable;
1332
+ let fullData = !isEditTable ? tableData.fullData : tableData.tableData;
1333
+ await this.$nextTick(() => {
1334
+ this.formModel[this.fieldKeyName] = fullData;
1335
+ this.fieldModel = fullData;
1336
+ });
1337
+ this.$nextTick(() => {
1338
+ this.handleWbs();
1339
+ });
1340
+ },
1341
+ createNewTableData(isEdit) {
1342
+ let vailColumns = this.widget.options.tableColumns.filter(
1343
+ (item) => item.prop && item.label
1344
+ );
1345
+ let newData = {};
1346
+ vailColumns.forEach((item) => {
1347
+ let formatS = !isEdit ? item.formatS : item.editFormatS;
1348
+ let columnOption = !isEdit ? item.columnOption : item.editColumnOption;
1349
+ if (formatS == "editSearch") {
1350
+ newData[item.prop] = null;
1351
+ let vabSearchName = item?.columnOption?.vabSearchName;
1352
+ if (vabSearchName) newData[vabSearchName] = null;
1353
+ }
1354
+ if (formatS == "editAttachment") {
1355
+ newData[item.prop] = [];
1356
+ } else {
1357
+ newData[item.prop] = null;
1358
+ if (
1359
+ columnOption &&
1360
+ columnOption.defaultValue !== undefined &&
1361
+ columnOption.defaultValue !== null &&
1362
+ columnOption.defaultValue !== ""
1363
+ ) {
1364
+ newData[item.prop] = columnOption.defaultValue;
1365
+ }
1366
+ }
1367
+ });
1368
+ return newData;
1369
+ },
1370
+ addTableData(rows, field) {
1371
+ let $grid = this.getGridTable();
1372
+ let formDataModel = this.formModel;
1373
+ let tableRows = formDataModel[this.fieldKeyName] || [];
1374
+ let fullData = $grid.getTableData().fullData;
1375
+ let items;
1376
+ if (field) {
1377
+ let keys = fullData.map((item) => {
1378
+ return item[field] + "";
1379
+ });
1380
+ items = rows.filter((item) => {
1381
+ let value = item[field] + "";
1382
+ return !keys.includes(value);
1383
+ });
1384
+ } else {
1385
+ items = rows;
1386
+ }
1387
+ if (items) {
1388
+ if (items.length) {
1389
+ items.forEach((row) => {
1390
+ let newData = this.createNewTableData();
1391
+ Object.assign(newData, row);
1392
+
1393
+ tableRows.push(newData);
1394
+ });
1395
+ }
1396
+ } else {
1397
+ let newData = this.createNewTableData();
1398
+ tableRows.push(newData);
1399
+ }
1400
+ // this.formModel[this.fieldKeyName] = this.$baseLodash(this.fieldModel)
1401
+ // this.fieldModel = tableRows
1402
+ this.setValue(tableRows);
1403
+ this.$nextTick(() => {
1404
+ this.handleWbs();
1405
+ });
1406
+ // $grid.loadData(tableRows);
1407
+ },
1408
+ getColumnWidgetConfig(row, isEdit) {
1409
+ let formatS = isEdit ? row.editFormatS : row.formatS;
1410
+ let formRef = this.getFormRef();
1411
+ let columnSelectedWidget = null;
1412
+ let columnEditFields = null;
1413
+
1414
+ let type = this.columnFormatMap[formatS];
1415
+ /*if (type == 'date') {
1416
+ columnEditFields = ['type', 'format', 'valueFormat']
1417
+ } else if (type == 'select') {
1418
+
1419
+ }
1420
+ if (type == 'vabsearch') {
1421
+ columnEditFields = ['vabSearchField', 'formCode', 'formVersion', 'required', 'showFormField', 'onSearchConfirm', 'onSearchClear']
1422
+ }*/
1423
+
1424
+ if (type) {
1425
+ columnSelectedWidget = this.$baseLodash.cloneDeep(
1426
+ formRef.getFieldWidgetByType(type)
1427
+ );
1428
+ let tmpId = generateId();
1429
+ let idVal = row.prop ? row.prop : type + tmpId;
1430
+ columnSelectedWidget.id = idVal;
1431
+ columnSelectedWidget.options.name = idVal;
1432
+
1433
+ let columnOption;
1434
+ if (!isEdit) {
1435
+ columnOption = row.columnOption;
1436
+ } else {
1437
+ columnOption = row.editColumnOption;
1438
+ }
1439
+
1440
+ if (columnOption && Object.keys(columnOption).length) {
1441
+ columnOption.required = row.required || false;
1442
+ columnSelectedWidget.options = columnOption;
1443
+ if ("editDelete" == formatS) {
1444
+ columnSelectedWidget.options.hiddenByWf =
1445
+ columnSelectedWidget.options.hiddenByWf ?? true;
1446
+ columnSelectedWidget.options.prefixIcon =
1447
+ columnSelectedWidget.options.prefixIcon || "el-icon-delete";
1448
+ } else if ("editButton" == formatS) {
1449
+ columnSelectedWidget.options.prefixIcon =
1450
+ columnSelectedWidget.options.prefixIcon || "el-icon-edit";
1451
+ }
1452
+ } else {
1453
+ columnSelectedWidget.options.required = row.required || false;
1454
+ if ("editDelete" == formatS) {
1455
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
1456
+ columnSelectedWidget.options.label = "删除";
1457
+ columnSelectedWidget.options.labelHidden = true;
1458
+ columnSelectedWidget.options.hiddenByWf = true;
1459
+ columnSelectedWidget.options.onClick =
1460
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
1461
+ } else if ("editButton" == formatS) {
1462
+ columnSelectedWidget.options.prefixIcon = "el-icon-edit";
1463
+ columnSelectedWidget.options.label = "查看";
1464
+ columnSelectedWidget.options.labelHidden = true;
1465
+ columnSelectedWidget.options.onClick =
1466
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
1467
+ } else if ("addSiblingEditRow" == formatS) {
1468
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1469
+ columnSelectedWidget.options.label = "新增兄弟节点";
1470
+ columnSelectedWidget.options.labelHidden = false;
1471
+ columnSelectedWidget.options.onClick =
1472
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
1473
+ } else if ("addChildTreeRow" == formatS) {
1474
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1475
+ columnSelectedWidget.options.label = "新增子节点";
1476
+ columnSelectedWidget.options.labelHidden = false;
1477
+ columnSelectedWidget.options.onClick =
1478
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
1479
+ } else if ("moveUpRow" == formatS) {
1480
+ // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1481
+ columnSelectedWidget.options.label = "↑上移";
1482
+ columnSelectedWidget.options.labelHidden = false;
1483
+ columnSelectedWidget.options.onClick =
1484
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
1485
+ } else if ("moveDownRow" == formatS) {
1486
+ // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1487
+ columnSelectedWidget.options.label = "↓下移";
1488
+ columnSelectedWidget.options.labelHidden = false;
1489
+ columnSelectedWidget.options.onClick =
1490
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
1491
+ } else if ("removeTreeRow" == formatS) {
1492
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
1493
+ columnSelectedWidget.options.label = "删除";
1494
+ columnSelectedWidget.options.labelHidden = true;
1495
+ columnSelectedWidget.options.onClick =
1496
+ "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
1497
+ }
1498
+ columnOption = columnSelectedWidget.options;
1499
+ }
1500
+ if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
1501
+ columnSelectedWidget.options.keyName = row.prop;
1502
+ columnSelectedWidget.options.keyNameEnabled = true;
1503
+ } else {
1504
+ columnSelectedWidget.options.name = row.prop;
1505
+ }
1506
+ if (type != "button" && type != "a-link") {
1507
+ columnSelectedWidget.options.label = row.label;
1508
+ columnSelectedWidget.options.labelHidden = true;
1509
+ }
1510
+ }
1511
+ return { columnSelectedWidget, columnEditFields };
1512
+ },
1513
+ getColumnProp(widget, obj, isEdit) {
1514
+ if (!widget) {
1515
+ return "false";
1516
+ }
1517
+ /*if(isEdit){
1518
+ return "false"
1519
+ }*/
1520
+
1521
+ let fieldKeyName = this.getFieldKeyName(widget);
1522
+ let rowIndex = Math.max(obj.rowIndex, 0);
1523
+ let isQueryTable = this.widget.options.isQueryTable || false;
1524
+ if (isEdit || !isQueryTable) {
1525
+ let propName =
1526
+ fieldKeyName + "." + rowIndex + "." + obj.column.property;
1527
+ let lineWidget = !isEdit
1528
+ ? obj.column.params.widget
1529
+ : obj.column.params.editWidget;
1530
+ if (!lineWidget) {
1531
+ return "false";
1532
+ }
1533
+ if (lineWidget?.type == "vabsearch") {
1534
+ let fieldName =
1535
+ lineWidget.options.vabSearchName ||
1536
+ this.getFieldKeyName(lineWidget);
1537
+ propName = fieldKeyName + "." + rowIndex + "." + fieldName;
1538
+ }
1539
+
1540
+ return propName;
1541
+ } else {
1542
+ return "false";
1543
+ }
1544
+ },
1545
+ getColumnWidgetName(e) {
1546
+ if (e && e.type) {
1547
+ return e.type + "-widget";
1548
+ }
1549
+ },
1550
+ getGridTable() {
1551
+ let $grid = this.$refs[this.getTableRef()];
1552
+ return $grid;
1553
+ },
1554
+ getContainerWidgetName: function (e) {
1555
+ return "grid" === e.type ? "grid-item" : e.type + "-item";
1556
+ },
1557
+ getWidgetName: function (e) {
1558
+ return (e.targetType || e.type) + "-widget";
1559
+ },
1560
+ handleCheckboxChange(param) {
1561
+ let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
1562
+ let mergeRowKey = this.widget.options.mergeRowKey;
1563
+ if (mergeRowEnabled && mergeRowKey) {
1564
+ let grid = this.getGridTable();
1565
+ let fullData = grid.getTableData().fullData;
1566
+ let row = param.row;
1567
+ let val = row[mergeRowKey];
1568
+ let items = fullData.filter((item) => item[mergeRowKey] === val);
1569
+ if (items.length) {
1570
+ grid.setCheckboxRow(items, param.checked);
1571
+ }
1572
+ }
1573
+ if (this.widget.options.onCheckboxChange) {
1574
+ let t = new Function("param", this.widget.options.onCheckboxChange);
1575
+ t.call(this, param);
1576
+ }
1577
+ let formRef = this.getFormRef();
1578
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
1579
+ dataTableConfig.onCheckboxChange &&
1580
+ dataTableConfig.onCheckboxChange(param);
1581
+ },
1582
+ handleCheckboxAll(param) {
1583
+ if (this.widget.options.onCheckboxAll) {
1584
+ let t = new Function("param", this.widget.options.onCheckboxAll);
1585
+ t.call(this, param);
1586
+ }
1587
+ let formRef = this.getFormRef();
1588
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
1589
+ dataTableConfig.onCheckboxAll && dataTableConfig.onCheckboxAll(param);
1590
+ },
1591
+ handleCellDblclick(param) {
1592
+ if (this.widget.options.onCellDblclick) {
1593
+ let t = new Function("param", this.widget.options.onCellDblclick);
1594
+ t.call(this, param);
1595
+ }
1596
+ let formRef = this.getFormRef();
1597
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
1598
+ dataTableConfig.onCellDblclick && dataTableConfig.onCellDblclick(param);
1599
+ },
1600
+ advancedClear() {
1601
+ let formModel = this.formModel;
1602
+ this.getFormRef().setFormData(formModel);
1603
+ },
1604
+ tableFormSettingConfirm() {
1605
+ let formModel = this.formModel;
1606
+ this.getFormRef().setFormData(formModel);
1607
+ },
1608
+
1609
+ //editTable begin
1610
+ saveEditRow(obj) {
1611
+ let formRef = this.getFormRef();
1612
+ let formConfig = this.formConfig;
1613
+ let entity = formConfig.entity;
1614
+ if (!entity) return;
1615
+ let dataId = formRef?.dataId;
1616
+ let reportTemplate = formRef?.reportTemplate;
1617
+ let formCode = reportTemplate?.formCode;
1618
+ let scriptCode = formConfig.saveScriptCode || "saveUpdate";
1619
+
1620
+ let that = this;
1621
+ let $grid = obj.$table.$xegrid;
1622
+ let originOption = $grid.originOption;
1623
+
1624
+ let formModel = this.formModel;
1625
+ let dataMap = this.getGridTable().getTableData();
1626
+
1627
+ formRef.validate((valid) => {
1628
+ if (valid) {
1629
+ $grid.clearActived().then(() => {
1630
+ $grid.setActiveRow(obj.row);
1631
+ let mainData = commonDataUtil.handleForm(obj.row);
1632
+
1633
+ delete mainData._createNickName;
1634
+ delete mainData._createMobile;
1635
+ delete mainData._modifyNickName;
1636
+ delete mainData._modifyMobile;
1637
+ delete mainData._createBy;
1638
+ delete mainData._modifyBy;
1639
+
1640
+ let formData = {
1641
+ [entity]: mainData,
1642
+ };
1643
+
1644
+ let reqData = {
1645
+ formCode: formCode,
1646
+ formVersion: reportTemplate.formVersion,
1647
+ taBm: entity,
1648
+ data: formData,
1649
+ };
1650
+
1651
+ this.formHttp({
1652
+ scriptCode: scriptCode,
1653
+ data: reqData,
1654
+ successMsg: true,
1655
+ isConfirm: true,
1656
+ confirmText: "您确定要保存吗?",
1657
+ success: (res0) => {
1658
+ this.getRowData(res0.objx, (res) => {
1659
+ if (obj.row.id == res.objx.id) {
1660
+ $grid.clearActived().then(() => {
1661
+ Object.assign(obj.row, res.objx);
1662
+ });
1663
+ } else {
1664
+ $grid.remove(obj.row);
1665
+ $grid.insertAt(res.objx);
1666
+ }
1667
+ delete obj.$table.editCloneRow;
1668
+ });
1669
+ },
1670
+ });
1671
+ });
1672
+ }
1673
+ });
1674
+ },
1675
+ getRowData(dataId, callback) {
1676
+ let reportTemplate = this.getFormRef()?.reportTemplate;
1677
+ let formCode = reportTemplate.formCode;
1678
+ let formConfig = this.formConfig;
1679
+ // let isLoadEntity = formConfig.isLoadEntity;
1680
+ let entity = formConfig.entity;
1681
+ let scriptCode = formConfig.formScriptCode || "getOne";
1682
+ let defaultOption = this.getHttpConfigForUser();
1683
+ this.formHttp({
1684
+ scriptCode: scriptCode,
1685
+ data: {
1686
+ formCode: formCode,
1687
+ formVersion: reportTemplate.formVersion,
1688
+ taBm: entity,
1689
+ data: {
1690
+ id: dataId,
1691
+ },
1692
+ },
1693
+ ...defaultOption,
1694
+ success: (res) => {
1695
+ callback && callback(res);
1696
+ },
1697
+ });
1698
+ },
1699
+ addChildTreeRow(rowData, obj, toTop) {
1700
+ let toEnd = !toTop;
1701
+ this.addTreeRow(rowData, obj, toEnd, null);
1702
+ },
1703
+ addTopTreeRow(rowData, toTop) {
1704
+ let toEnd = !toTop;
1705
+ this.addTreeRow(rowData, null, toEnd, null);
1706
+ },
1707
+ addSiblingTreeRow(rowData, obj) {
1708
+ this.addTreeRow(rowData, obj, null, true);
1709
+ },
1710
+ addTreeRow(rowData, obj, toEnd, toSibling) {
1711
+ let isEditTable = this.widget.options.isEditTable || false;
1712
+ let parent = obj?.row;
1713
+ let $grid = this.getGridTable();
1714
+ if (isEditTable && this.hasEditingRow($grid, 1)) {
1715
+ return false;
1716
+ }
1717
+ let parentField = $grid.treeConfig.parentField;
1718
+ let newRow = {};
1719
+ let originOption = $grid.originOption;
1720
+ let editDefaultRow;
1721
+ if (originOption.editDefaultRow) {
1722
+ if (typeof originOption.editDefaultRow == "function") {
1723
+ editDefaultRow = originOption.editDefaultRow() || {};
1724
+ } else {
1725
+ editDefaultRow = originOption.editDefaultRow || {};
1726
+ }
1727
+ }
1728
+ // Object.assign(newRow, editDefaultRow, rowData);
1729
+ newRow.id =
1730
+ "row_" + new Date().valueOf() + Math.floor(Math.random() * 1000000);
1731
+ if (!toSibling) {
1732
+ newRow[parentField] = parent?.id || 0;
1733
+ } else {
1734
+ newRow[parentField] = obj?.row[parentField] || 0;
1735
+ }
1736
+
1737
+ let newData = this.createNewTableData(isEditTable);
1738
+ newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
1739
+
1740
+ let tableRows = this.formModel[this.fieldKeyName] || [];
1741
+ if (!parent) {
1742
+ if (toEnd === true) {
1743
+ tableRows.push(newRow);
1744
+ } else if (toSibling === true) {
1745
+ let addIndex =
1746
+ tableRows.findIndex(
1747
+ (item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
1748
+ ) + 1;
1749
+ tableRows.splice(addIndex, 0, newRow);
1750
+ } else {
1751
+ tableRows.splice(0, 0, newRow);
1752
+ }
1753
+ this.setValue(tableRows);
1754
+ this.$nextTick(() => {
1755
+ this.handleWbs();
1756
+ if (isEditTable) {
1757
+ $grid.setActiveRow(newRow);
1758
+ }
1759
+ });
1760
+
1761
+ // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
1762
+ } else {
1763
+ $grid.setTreeExpand(obj.row, true).then(() => {
1764
+ if (toEnd === true) {
1765
+ tableRows.push(newRow);
1766
+ } else if (toSibling === true) {
1767
+ let addIndex =
1768
+ tableRows.findIndex(
1769
+ (item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
1770
+ ) + 1;
1771
+ tableRows.splice(addIndex, 0, newRow);
1772
+ } else {
1773
+ tableRows.splice(0, 0, newRow);
1774
+ }
1775
+ this.setValue(tableRows);
1776
+ this.$nextTick(() => {
1777
+ this.handleWbs();
1778
+ $grid.setTreeExpand(obj.row, true).then(() => {
1779
+ if (isEditTable) {
1780
+ $grid.setActiveRow(newRow);
1781
+ }
1782
+ });
1783
+ });
1784
+ });
1785
+ }
1786
+ },
1787
+ removeTreeRow(obj) {
1788
+ let row = obj.row;
1789
+ let $grid = this.getGridTable();
1790
+ let childrenField = $grid.treeConfig.children;
1791
+ let tableRows = this.formModel[this.fieldKeyName];
1792
+ // let index = tableRows.findIndex(item => item.id === row.id)
1793
+ let delIds = [];
1794
+ if (row[childrenField]) {
1795
+ let loopDo = (item) => {
1796
+ if (item.id) delIds.push(item.id);
1797
+ item[childrenField] &&
1798
+ item[childrenField].forEach((subItem) => {
1799
+ loopDo(subItem);
1800
+ });
1801
+ };
1802
+ loopDo(row);
1803
+ }
1804
+ delIds.forEach((id) => {
1805
+ let index = tableRows.findIndex((item) => item.id === id);
1806
+ tableRows.splice(index, 1);
1807
+ });
1808
+ this.$nextTick(() => {
1809
+ this.handleWbs();
1810
+ });
1811
+ },
1812
+ addSiblingEditRow(rowData, obj) {
1813
+ this.addEditRow(rowData, obj, null, true);
1814
+ },
1815
+ addEditRow(rowData, obj, toEnd, toSibling) {
1816
+ let isEditTable = this.widget.options.isEditTable || false;
1817
+ let parent = obj?.row;
1818
+ let $grid = this.getGridTable();
1819
+ if (isEditTable && this.hasEditingRow($grid, 1)) {
1820
+ return false;
1821
+ }
1822
+ let parentField = $grid.treeConfig.parentField;
1823
+ let newRow = {};
1824
+ let originOption = $grid.originOption;
1825
+ let editDefaultRow;
1826
+ if (originOption.editDefaultRow) {
1827
+ if (typeof originOption.editDefaultRow == "function") {
1828
+ editDefaultRow = originOption.editDefaultRow() || {};
1829
+ } else {
1830
+ editDefaultRow = originOption.editDefaultRow || {};
1831
+ }
1832
+ }
1833
+ // Object.assign(newRow, editDefaultRow, rowData);
1834
+ newRow.id =
1835
+ "row_" + new Date().valueOf() + Math.floor(Math.random() * 1000000);
1836
+ if (!toSibling) {
1837
+ newRow[parentField] = parent?.id || 0;
1838
+ } else {
1839
+ newRow[parentField] = obj?.row[parentField] || 0;
1840
+ }
1841
+
1842
+ let newData = this.createNewTableData(isEditTable);
1843
+ newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
1844
+
1845
+ let tableRows = this.formModel[this.fieldKeyName] || [];
1846
+ if (!parent) {
1847
+ if (toEnd === true) {
1848
+ tableRows.push(newRow);
1849
+ } else if (toSibling === true) {
1850
+ let addIndex =
1851
+ tableRows.findIndex(
1852
+ (item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
1853
+ ) + 1;
1854
+ tableRows.splice(addIndex, 0, newRow);
1855
+ } else {
1856
+ tableRows.splice(0, 0, newRow);
1857
+ }
1858
+ this.setValue(tableRows);
1859
+ this.$nextTick(() => {
1860
+ this.handleWbs();
1861
+ if (isEditTable) {
1862
+ $grid.setActiveRow(newRow);
1863
+ }
1864
+ });
1865
+
1866
+ // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
1867
+ } else {
1868
+ $grid.setTreeExpand(obj.row, true).then(() => {
1869
+ if (toEnd === true) {
1870
+ tableRows.push(newRow);
1871
+ } else if (toSibling === true) {
1872
+ let addIndex =
1873
+ tableRows.findIndex(
1874
+ (item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
1875
+ ) + 1;
1876
+ tableRows.splice(addIndex, 0, newRow);
1877
+ } else {
1878
+ tableRows.splice(0, 0, newRow);
1879
+ }
1880
+ this.setValue(tableRows);
1881
+ this.$nextTick(() => {
1882
+ this.handleWbs();
1883
+ $grid.setTreeExpand(obj.row, true).then(() => {
1884
+ if (isEditTable) {
1885
+ $grid.setActiveRow(newRow);
1886
+ }
1887
+ });
1888
+ });
1889
+ });
1890
+ }
1891
+ },
1892
+ async removeEditRow(obj) {
1893
+ this.removeTreeRow(obj);
1894
+ },
1895
+ //editTable end
1896
+ getHttpConfigForUser() {
1897
+ let defaultOption = {
1898
+ addCreateInfo: true,
1899
+ queryCreateInfo: window.$vueRoot.$store.getters.queryCreateInfo || "0",
1900
+ };
1901
+ return defaultOption;
1902
+ },
1903
+ handleWbs() {
1904
+ if (this.widget.options.wbsEnabled) {
1905
+ this.updateWbs();
1906
+ }
1907
+ },
1908
+ updateWbs() {
1909
+ let that = this;
1910
+ let $grid = that.getGridTable();
1911
+ let childrenField = $grid.treeConfig.children;
1912
+ let fullData = $grid.getTableData().fullData;
1913
+ let tableRows = this.formModel[that.fieldKeyName] || [];
1914
+ let map = {};
1915
+ let loopDo = (item, wbs) => {
1916
+ item.f_wbs = wbs;
1917
+ map[item._X_ROW_KEY] = wbs;
1918
+ item[childrenField] &&
1919
+ item[childrenField].forEach((subitem, subindex) => {
1920
+ let sub_wbs = wbs + "." + (subindex + 1) + "";
1921
+ loopDo(subitem, sub_wbs);
1922
+ });
1923
+ };
1924
+ fullData.forEach((item, index) => {
1925
+ let wbs = index + 1 + "";
1926
+ loopDo(item, wbs);
1927
+ });
1928
+ $grid.updateData();
1929
+ },
1930
+ moveUpRow(obj) {
1931
+ let row = obj.row;
1932
+ let $grid = this.getGridTable();
1933
+ let tableRows = this.formModel[this.fieldKeyName] || [];
1934
+ let isTreeTable = this.widget.options.isTreeTable;
1935
+ if (isTreeTable) {
1936
+ let parentField = $grid.treeConfig.parentField;
1937
+ let rowField = $grid.treeConfig.rowField || "id";
1938
+ let paretValue = row[parentField];
1939
+ let siblingRows = tableRows.filter(
1940
+ (item) => item[parentField] === paretValue
1941
+ );
1942
+ if (siblingRows.length > 1) {
1943
+ let currentIndex = tableRows.findIndex(
1944
+ (item) => item[rowField] == row[rowField]
1945
+ );
1946
+ let index1 = siblingRows.findIndex(
1947
+ (item) => item[rowField] == row[rowField]
1948
+ );
1949
+ if (index1 > 0) {
1950
+ let prevRow = siblingRows[index1 - 1];
1951
+ let prevIndex = tableRows.findIndex(
1952
+ (item) => item[rowField] == prevRow[rowField]
1953
+ );
1954
+ tableRows.splice(currentIndex, 1);
1955
+ tableRows.splice(prevIndex, 0, row);
1956
+ this.setValue(tableRows);
1957
+ this.$nextTick(() => {
1958
+ this.handleWbs();
1959
+ });
1960
+ }
1961
+ }
1962
+ } else {
1963
+ let rowIndex = $grid.getRowIndex(row);
1964
+ if (rowIndex >= 0) {
1965
+ tableRows.splice(rowIndex, 1);
1966
+ tableRows.splice(rowIndex - 1, 0, row);
1967
+ this.setValue(tableRows);
1968
+ this.$nextTick(() => {
1969
+ this.handleWbs();
1970
+ });
1971
+ }
1972
+ }
1973
+ },
1974
+ moveDownRow(obj) {
1975
+ let row = obj.row;
1976
+ let $grid = this.getGridTable();
1977
+ let tableRows = this.formModel[this.fieldKeyName] || [];
1978
+ let isTreeTable = this.widget.options.isTreeTable;
1979
+ if (isTreeTable) {
1980
+ let parentField = $grid.treeConfig.parentField;
1981
+ let rowField = $grid.treeConfig.rowField || "id";
1982
+ let paretValue = row[parentField];
1983
+ let siblingRows = tableRows.filter(
1984
+ (item) => item[parentField] === paretValue
1985
+ );
1986
+ if (siblingRows.length > 1) {
1987
+ let currentIndex = tableRows.findIndex(
1988
+ (item) => item[rowField] == row[rowField]
1989
+ );
1990
+ let index1 = siblingRows.findIndex(
1991
+ (item) => item[rowField] == row[rowField]
1992
+ );
1993
+ if (index1 < siblingRows.length - 1) {
1994
+ let nextRow = siblingRows[index1 + 1];
1995
+ let nextIndex = tableRows.findIndex(
1996
+ (item) => item[rowField] == nextRow[rowField]
1997
+ );
1998
+ tableRows.splice(currentIndex, 1);
1999
+ tableRows.splice(nextIndex, 0, row);
2000
+ this.setValue(tableRows);
2001
+ this.$nextTick(() => {
2002
+ this.handleWbs();
2003
+ });
2004
+ }
2005
+ }
2006
+ } else {
2007
+ let rowIndex = $grid.getRowIndex(row);
2008
+ if (rowIndex < tableRows.length - 1) {
2009
+ tableRows.splice(rowIndex, 1);
2010
+ tableRows.splice(rowIndex + 1, 0, row);
2011
+ this.setValue(tableRows);
2012
+ this.$nextTick(() => {
2013
+ this.handleWbs();
2014
+ });
2015
+ }
2016
+ }
2017
+ },
2018
+
2019
+ openSortRowDialog(obj) {
2020
+ let $grid = this.getGridTable();
2021
+ let parentField = $grid.treeConfig.parentField;
2022
+ let rowField = $grid.treeConfig.rowField || "id";
2023
+ let row = obj.row;
2024
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2025
+
2026
+ let sortParentRow = tableRows.find(
2027
+ (item) => item[rowField] === row[parentField]
2028
+ );
2029
+ let sortRows = tableRows.filter(
2030
+ (item) => item[parentField] === row[parentField]
2031
+ );
2032
+ this.sortRows = sortRows;
2033
+ this.sortParentRow = sortParentRow;
2034
+ this.showTreeMoveDialog = true;
2035
+ },
2036
+ confirmTreeMoveDialog(rows) {
2037
+ if (this.widget.options.isEditTable) {
2038
+ let reportTemplate = this.getFormRef().reportTemplate;
2039
+ let formConfig = this.formConfig;
2040
+ let entity = formConfig.entity;
2041
+ let reqData = {
2042
+ formCode: reportTemplate.formCode,
2043
+ formVersion: reportTemplate.formVersion,
2044
+ taBm: entity,
2045
+ data: rows,
2046
+ };
2047
+ let scriptCode = this.widget.options.sortScriptCode;
2048
+ this.formHttp({
2049
+ scriptCode: scriptCode,
2050
+ data: reqData,
2051
+ successMsg: true,
2052
+ isConfirm: true,
2053
+ confirmText: "您确定要保存排序吗?",
2054
+ success: (res) => {
2055
+ this.getGridTable().reloadTreeExpand(this.sortParentRow);
2056
+ },
2057
+ });
2058
+ } else {
2059
+ let $grid = this.getGridTable();
2060
+ let rowField = $grid.treeConfig.rowField || "id";
2061
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2062
+
2063
+ let ids = rows.map((item) => item[rowField]);
2064
+ let index = tableRows.findIndex((item) => ids.includes(item[rowField]));
2065
+ let items = tableRows.filter((item) => !ids.includes(item[rowField]));
2066
+ rows.forEach((row, index1) => {
2067
+ items.splice(index + index1, 0, row);
2068
+ });
2069
+ this.setValue(items);
2070
+ this.$nextTick(() => {
2071
+ this.handleWbs();
2072
+ });
2073
+ }
2074
+ },
2075
+ // 通用行合并函数(将相同多列数据合并为一行)
2076
+ mergeRowMethod(tableParam) {
2077
+ let { row, _rowIndex, column, visibleData } = tableParam;
2078
+ let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
2079
+ let unikey = this.widget.options.mergeRowKey;
2080
+ const cellValue = row[unikey];
2081
+ let isItemLine = column.params?.isItemLine || false;
2082
+ if (mergeRowEnabled && unikey && !isItemLine) {
2083
+ const prevRow = visibleData[_rowIndex - 1];
2084
+ let nextRow = visibleData[_rowIndex + 1];
2085
+ if (prevRow && prevRow[unikey] === cellValue) {
2086
+ return { rowspan: 0, colspan: 0 };
2087
+ } else {
2088
+ let countRowspan = 1;
2089
+ while (nextRow && nextRow[unikey] === cellValue) {
2090
+ nextRow = visibleData[++countRowspan + _rowIndex];
2091
+ }
2092
+ if (countRowspan > 1) {
2093
+ return { rowspan: countRowspan, colspan: 1 };
2094
+ }
2095
+ }
2096
+ } else {
2097
+ // return { rowspan: 1, colspan: 1 }
2098
+ }
2099
+ },
2100
+ mergeRowMethod2({ row, _rowIndex, column, visibleData }) {
2101
+ const fields = ["key"];
2102
+ const cellValue = row[column.field];
2103
+ if (cellValue && fields.includes(column.field)) {
2104
+ const prevRow = visibleData[_rowIndex - 1];
2105
+ let nextRow = visibleData[_rowIndex + 1];
2106
+ if (prevRow && prevRow[column.field] === cellValue) {
2107
+ return { rowspan: 0, colspan: 0 };
2108
+ } else {
2109
+ let countRowspan = 1;
2110
+ while (nextRow && nextRow[column.field] === cellValue) {
2111
+ nextRow = visibleData[++countRowspan + _rowIndex];
2112
+ }
2113
+ if (countRowspan > 1) {
2114
+ return { rowspan: countRowspan, colspan: 1 };
2115
+ }
2116
+ }
2117
+ }
2118
+ },
2119
+ },
2120
+ };
2121
+
2122
+ export default modules;