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

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