cloud-web-corejs 1.0.54-dev.710 → 1.0.54-dev.712
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.
|
@@ -223,27 +223,42 @@ modules = {
|
|
|
223
223
|
this.unregisterFromRefList();
|
|
224
224
|
},
|
|
225
225
|
methods: {
|
|
226
|
+
/*
|
|
227
|
+
* 数据约定:
|
|
228
|
+
* 1. formModel[fieldKeyName] 是提交与校验使用的表单数据;fieldModel 是 vxe-grid 的绑定数据。
|
|
229
|
+
* 2. _X_ROW_KEY 是前端稳定行主键,业务 id 在新增保存后可能被服务端替换。
|
|
230
|
+
* 3. 编辑表的临时增删改优先调用 VXE API,避免 setValue 全量重载导致行引用和编辑态丢失。
|
|
231
|
+
* 4. 树表提交使用扁平数据,VXE transform 模式内部同时维护树结构数据。
|
|
232
|
+
*/
|
|
226
233
|
initTableCustomEvent() {
|
|
227
234
|
let tableConfig =
|
|
228
235
|
this.handleCustomEvent(this.widget.options.tableConfig) || {};
|
|
229
236
|
this.eventConfig = tableConfig.eventConfig || {};
|
|
230
237
|
},
|
|
238
|
+
/** @param {Object} obj VXE 单元格参数。@returns {String|null} 状态项标签字段名。 */
|
|
231
239
|
getTableColumnStatusWidgetLabelKey(obj) {
|
|
232
240
|
let widget = this.getTableColumnWidget(obj);
|
|
233
241
|
return widget ? this.getOptionItemLabelKey(widget) : null;
|
|
234
242
|
},
|
|
243
|
+
/** @param {Object} widget 字段组件 schema。@returns {String} 选项值字段名。 */
|
|
235
244
|
getOptionItemValueKey(widget) {
|
|
236
245
|
if (widget?.options?.commonAttributeEnabled) {
|
|
237
246
|
return widget.options.valueKey || "sn";
|
|
238
247
|
}
|
|
239
248
|
return widget.options.valueKey || "value";
|
|
240
249
|
},
|
|
250
|
+
/** @param {Object} widget 字段组件 schema。@returns {String} 选项标签字段名。 */
|
|
241
251
|
getOptionItemLabelKey(widget) {
|
|
242
252
|
if (widget?.options?.commonAttributeEnabled) {
|
|
243
253
|
return widget.options.labelKey || "value";
|
|
244
254
|
}
|
|
245
255
|
return widget.options.labelKey || "label";
|
|
246
256
|
},
|
|
257
|
+
/**
|
|
258
|
+
* 获取当前行独立的列组件 schema;缺失时按列模板即时创建。
|
|
259
|
+
* @param {Object} obj VXE 单元格参数。
|
|
260
|
+
* @returns {Object|null}
|
|
261
|
+
*/
|
|
247
262
|
getTableColumnWidget(obj) {
|
|
248
263
|
const rowKey = obj?.row?._X_ROW_KEY;
|
|
249
264
|
const widget = obj?.column?.params?.widget;
|
|
@@ -259,6 +274,7 @@ modules = {
|
|
|
259
274
|
}
|
|
260
275
|
return rowSchema[widget.id] || null;
|
|
261
276
|
},
|
|
277
|
+
/** @param {Object} obj VXE 单元格参数。@param {Object} item 状态选项。@returns {Boolean} */
|
|
262
278
|
isShowColumnStatusWidget(obj, item) {
|
|
263
279
|
let widget = this.getTableColumnWidget(obj);
|
|
264
280
|
let valueKey = this.getOptionItemValueKey(widget);
|
|
@@ -266,10 +282,17 @@ modules = {
|
|
|
266
282
|
obj.row[this.getTableColumnWidgetFieldKeyName(obj)] === item[valueKey]
|
|
267
283
|
);
|
|
268
284
|
},
|
|
285
|
+
/** @param {Object} obj VXE 单元格参数。@returns {String|null} 当前列绑定字段名。 */
|
|
269
286
|
getTableColumnWidgetFieldKeyName(obj) {
|
|
270
287
|
let widget = this.getTableColumnWidget(obj);
|
|
271
288
|
return widget ? this.getFieldKeyName(widget) : null;
|
|
272
289
|
},
|
|
290
|
+
/**
|
|
291
|
+
* 收集列组件的异步配置任务(脚本选项、公共属性字典等)。
|
|
292
|
+
* @param {Array} tableColumns 当前生效的列配置。
|
|
293
|
+
* @param {Object} options forceRefresh=true 时清除组件的同步完成标记。
|
|
294
|
+
* @returns {Promise[]} 可直接交给 Promise.all 的任务列表。
|
|
295
|
+
*/
|
|
273
296
|
collectColumnWidgetConfigRequests(tableColumns, options = {}) {
|
|
274
297
|
const { forceRefresh = false } = options;
|
|
275
298
|
const requests = [];
|
|
@@ -292,11 +315,13 @@ modules = {
|
|
|
292
315
|
});
|
|
293
316
|
return requests.filter(Boolean);
|
|
294
317
|
},
|
|
318
|
+
/** @param {Object} widget 组件 schema。清除其远程选项同步标记。 */
|
|
295
319
|
resetColumnWidgetSyncFlag(widget) {
|
|
296
320
|
if (widget) {
|
|
297
321
|
widget._syncInited = false;
|
|
298
322
|
}
|
|
299
323
|
},
|
|
324
|
+
/** @param {Object} columnRow 列配置。@param {Object} widget 组件 schema。同步列字段名。 */
|
|
300
325
|
syncColumnWidgetFieldKey(columnRow, widget) {
|
|
301
326
|
if (!widget || !columnRow?.prop) {
|
|
302
327
|
return;
|
|
@@ -309,6 +334,7 @@ modules = {
|
|
|
309
334
|
widget.options.name = prop;
|
|
310
335
|
}
|
|
311
336
|
},
|
|
337
|
+
/** @param {Array} tableColumns 当前列配置。将列字段名同步到展示和编辑组件。 */
|
|
312
338
|
syncEffectiveColumnWidgetFieldKeys(tableColumns) {
|
|
313
339
|
this.loodHandleColumns(tableColumns, (row) => {
|
|
314
340
|
applyColumnMetaToColumnRow(row);
|
|
@@ -316,6 +342,11 @@ modules = {
|
|
|
316
342
|
this.syncColumnWidgetFieldKey(row, row.editWidget);
|
|
317
343
|
});
|
|
318
344
|
},
|
|
345
|
+
/**
|
|
346
|
+
* 初始化列组件远程选项。
|
|
347
|
+
* @param {Function} callback 全部配置完成后的回调。
|
|
348
|
+
* @param {Object} options 可指定 columns 和 forceRefresh。
|
|
349
|
+
*/
|
|
319
350
|
initColumnWidgetConfig(callback, options = {}) {
|
|
320
351
|
const tableColumns = options.columns ?? this.getEffectiveTableColumns();
|
|
321
352
|
const requests = this.collectColumnWidgetConfigRequests(
|
|
@@ -330,6 +361,11 @@ modules = {
|
|
|
330
361
|
callback && callback();
|
|
331
362
|
}
|
|
332
363
|
},
|
|
364
|
+
/**
|
|
365
|
+
* 重新加载列组件配置,并在完成后重建每行字段 schema。
|
|
366
|
+
* @param {Object} options 支持 columns、forceRefresh、success、fail、error。
|
|
367
|
+
* @returns {Promise<void>}
|
|
368
|
+
*/
|
|
333
369
|
refreshColumnWidgetConfig(options = {}) {
|
|
334
370
|
const tableColumns = options.columns ?? this.getEffectiveTableColumns();
|
|
335
371
|
const forceRefresh = options.forceRefresh !== false;
|
|
@@ -359,9 +395,11 @@ modules = {
|
|
|
359
395
|
}
|
|
360
396
|
});
|
|
361
397
|
},
|
|
398
|
+
/** @param {Object} options 列组件刷新选项。@returns {Promise<void>} */
|
|
362
399
|
reloadColumnWidgetOptions(options) {
|
|
363
400
|
return this.refreshColumnWidgetConfig(options);
|
|
364
401
|
},
|
|
402
|
+
/** @param {Object} widget 组件 schema。@param {Array} rows 远程选项数据。 */
|
|
365
403
|
fillColumnWidgetOptionItems(widget, rows) {
|
|
366
404
|
let widgetType = widget.type;
|
|
367
405
|
let formScriptEnabledTypes = ["select", "checkbox", "radio"];
|
|
@@ -372,6 +410,12 @@ modules = {
|
|
|
372
410
|
}
|
|
373
411
|
widget._syncInited = true;
|
|
374
412
|
},
|
|
413
|
+
/**
|
|
414
|
+
* 按组件配置加载脚本选项或公共属性字典。
|
|
415
|
+
* @param {Object} widget 组件 schema。
|
|
416
|
+
* @param {Function} callback 兼容保留参数。
|
|
417
|
+
* @returns {Promise|undefined}
|
|
418
|
+
*/
|
|
375
419
|
async handleColumnWidgetConfig(widget, callback) {
|
|
376
420
|
if (!widget) return;
|
|
377
421
|
let widgetType = widget.type;
|
|
@@ -428,6 +472,7 @@ modules = {
|
|
|
428
472
|
});
|
|
429
473
|
}
|
|
430
474
|
},
|
|
475
|
+
/** 根据旧版 formatS/editFormatS 配置补建缺失的列组件 schema。 */
|
|
431
476
|
initConfig() {
|
|
432
477
|
let formRef = this.getFormRef();
|
|
433
478
|
this.widget.options.tableColumns.forEach((row) => {
|
|
@@ -453,14 +498,17 @@ modules = {
|
|
|
453
498
|
}
|
|
454
499
|
});
|
|
455
500
|
},
|
|
501
|
+
/** 按组件名称注册当前数据表实例,供表单脚本和其他组件查找。 */
|
|
456
502
|
registerTableRefList() {
|
|
457
503
|
this.sfRefList[this.widget.options.name] = this;
|
|
458
504
|
},
|
|
505
|
+
/** @param {Object} row 行数据。@param {String} name 组件名。@returns {String} 行组件引用键。 */
|
|
459
506
|
getRowRefKey(row, name) {
|
|
460
507
|
let keyVal = row._X_ROW_KEY;
|
|
461
508
|
let key = name + "_" + keyVal;
|
|
462
509
|
return key;
|
|
463
510
|
},
|
|
511
|
+
/** @param {Number} index 扁平数据行索引。@param {String} name 组件名。@returns {Object} 行组件 schema。 */
|
|
464
512
|
getWidgetByTableRow(index, name) {
|
|
465
513
|
// let target = this.getWidgetRefByTableRow(index, name)
|
|
466
514
|
// let widget = target.field || target.widget;
|
|
@@ -470,22 +518,25 @@ modules = {
|
|
|
470
518
|
let widget = this.getWidgetByTableRowData(row, name);
|
|
471
519
|
return widget;
|
|
472
520
|
},
|
|
521
|
+
/** @param {Number} index 扁平数据行索引。@param {String} name 组件名。@returns {Object} 组件实例。 */
|
|
473
522
|
getWidgetRefByTableRow(index, name) {
|
|
474
523
|
// let row = this.getGridTable().getTableData().fullData[index];
|
|
475
524
|
let formRows = this.formModel[this.fieldKeyName];
|
|
476
525
|
let row = formRows[index];
|
|
477
526
|
return this.getWidgetRefByTableRowData(row, name);
|
|
478
527
|
},
|
|
528
|
+
/** @param {Object} row 行数据。@param {String} name 组件名。@returns {Object} 行组件 schema。 */
|
|
479
529
|
getWidgetByTableRowData(row, name) {
|
|
480
530
|
let target = this.getWidgetRefByTableRowData(row, name);
|
|
481
531
|
let widget = target.field || target.widget;
|
|
482
532
|
return widget;
|
|
483
533
|
},
|
|
534
|
+
/** @param {Object} row 行数据。@param {String} name 组件名。@returns {Object} 组件实例。 */
|
|
484
535
|
getWidgetRefByTableRowData(row, name) {
|
|
485
536
|
let key = this.getRowRefKey(row, name);
|
|
486
537
|
return this.getWidgetRef(key);
|
|
487
538
|
},
|
|
488
|
-
|
|
539
|
+
/** @param {Object} tableParam VXE 单元格参数。@returns {Object} 当前单元格组件实例。 */
|
|
489
540
|
getWidgetRefByTableParam(tableParam) {
|
|
490
541
|
let params = tableParam.column.params;
|
|
491
542
|
let name = params.widget.options.name;
|
|
@@ -493,6 +544,7 @@ modules = {
|
|
|
493
544
|
return this.getWidgetRefByTableRowData(tableParam.row, name);
|
|
494
545
|
// return this.getWidgetRef(key);
|
|
495
546
|
},
|
|
547
|
+
/** @param {Object} rowParam VXE 行参数。@param {Object} fieldWidget 可选组件模板。@returns {Object} 行级 schema。 */
|
|
496
548
|
getRowWidget(rowParam, fieldWidget) {
|
|
497
549
|
let row = rowParam.row;
|
|
498
550
|
let params = rowParam.column.params;
|
|
@@ -500,6 +552,7 @@ modules = {
|
|
|
500
552
|
let widget = this.fieldSchemaMap[row._X_ROW_KEY][widgetId];
|
|
501
553
|
return widget;
|
|
502
554
|
},
|
|
555
|
+
/** @param {String} name 组件名。@param {Function} callback 每行回调。 */
|
|
503
556
|
loopHandleWidgetByName(name, callback) {
|
|
504
557
|
let rows = this.getValue();
|
|
505
558
|
rows.forEach((row, index) => {
|
|
@@ -510,6 +563,7 @@ modules = {
|
|
|
510
563
|
}
|
|
511
564
|
});
|
|
512
565
|
},
|
|
566
|
+
/** @param {Object} rowParam VXE 行参数。@param {Object} fieldWidget 组件模板。@returns {Object} 动态组件绑定对象。 */
|
|
513
567
|
getRowWidgetOption(rowParam, fieldWidget) {
|
|
514
568
|
let widget = this.getRowWidget(rowParam, fieldWidget);
|
|
515
569
|
let field = widget.category === "container" ? "widget" : "field";
|
|
@@ -518,16 +572,19 @@ modules = {
|
|
|
518
572
|
};
|
|
519
573
|
return option;
|
|
520
574
|
},
|
|
575
|
+
/** @param {Object} rowParam VXE 行参数。@param {Object} fieldWidget 组件模板。@returns {String} 行组件渲染 key。 */
|
|
521
576
|
getRowWidgetKey(rowParam, fieldWidget) {
|
|
522
577
|
let widget = this.getRowWidget(rowParam, fieldWidget);
|
|
523
578
|
let key = widget.id;
|
|
524
579
|
return key;
|
|
525
580
|
},
|
|
581
|
+
/** @returns {String} 由表单编码和组件名组成的唯一表格名称。 */
|
|
526
582
|
getGridTableName() {
|
|
527
583
|
let formCode = this.getFormRef().reportTemplate.formCode;
|
|
528
584
|
let tableName = formCode + "_" + this.widget.options.name;
|
|
529
585
|
return tableName;
|
|
530
586
|
},
|
|
587
|
+
/** 将 fieldModel 当前内容同步到表单模型,并尽量保持原数组引用。 */
|
|
531
588
|
updateFormField: function () {
|
|
532
589
|
let rows = this.fieldModel || [];
|
|
533
590
|
let formRows = this.formModel[this.fieldKeyName];
|
|
@@ -538,6 +595,7 @@ modules = {
|
|
|
538
595
|
this.formModel[this.fieldKeyName] = rows;
|
|
539
596
|
}
|
|
540
597
|
},
|
|
598
|
+
/** @param {Array} val 已准备好的数据。初始化数据引用和行级 schema。 */
|
|
541
599
|
initFieldSchema(val) {
|
|
542
600
|
let rows = val || [];
|
|
543
601
|
// 处理树结构数据排序
|
|
@@ -546,6 +604,7 @@ modules = {
|
|
|
546
604
|
this.initRowIdData(true);
|
|
547
605
|
this.initFieldSchemaData();
|
|
548
606
|
},
|
|
607
|
+
/** @param {Array} val 外部传入数据。@returns {Array} 表单与 VXE 共用的标准化行。 */
|
|
549
608
|
initValue(val) {
|
|
550
609
|
// this.clearRowWidgets()
|
|
551
610
|
let rows = this.normalizeTableRows(val || [], false);
|
|
@@ -557,7 +616,13 @@ modules = {
|
|
|
557
616
|
this.fieldModel = rows;
|
|
558
617
|
this.initRowIdData(true);
|
|
559
618
|
this.initFieldSchemaData(true);
|
|
619
|
+
return rows;
|
|
560
620
|
},
|
|
621
|
+
/**
|
|
622
|
+
* 将树表的扁平数据按父子关系排序;非树表原样返回。
|
|
623
|
+
* @param {Array} rows 原始行数据。
|
|
624
|
+
* @returns {Array|undefined} 根节点优先、子节点紧随父节点的扁平数组。
|
|
625
|
+
*/
|
|
561
626
|
handleTreeData(rows) {
|
|
562
627
|
let isTreeTable = this.widget.options.isTreeTable;
|
|
563
628
|
if (isTreeTable) {
|
|
@@ -602,6 +667,7 @@ modules = {
|
|
|
602
667
|
}
|
|
603
668
|
return rows;
|
|
604
669
|
},
|
|
670
|
+
/** @param {*} parentId 父节点 id。@param {Map} nodeMap 节点映射。@param {String} parentField 父字段。@param {Array} sortedRows 输出数组。 */
|
|
605
671
|
addChildNodes(parentId, nodeMap, parentField, sortedRows) {
|
|
606
672
|
// 遍历所有节点,找出当前父节点的子节点
|
|
607
673
|
for (let [id, node] of nodeMap.entries()) {
|
|
@@ -622,6 +688,12 @@ modules = {
|
|
|
622
688
|
}
|
|
623
689
|
}
|
|
624
690
|
},
|
|
691
|
+
/**
|
|
692
|
+
* 补齐列字段和内部行主键。该方法会浅克隆每一行,不保留行对象引用。
|
|
693
|
+
* @param {Array} rows 待标准化数据。
|
|
694
|
+
* @param {Boolean} defaultValueEnabled 是否应用字段默认值。
|
|
695
|
+
* @returns {Array} 标准化后的新数组。
|
|
696
|
+
*/
|
|
625
697
|
normalizeTableRows(rows, defaultValueEnabled = false) {
|
|
626
698
|
if (!Array.isArray(rows) || !rows.length) {
|
|
627
699
|
return rows || [];
|
|
@@ -640,6 +712,11 @@ modules = {
|
|
|
640
712
|
return nextRow;
|
|
641
713
|
});
|
|
642
714
|
},
|
|
715
|
+
/**
|
|
716
|
+
* 全量替换表格数据并重建行级 schema。
|
|
717
|
+
* 注意:该操作会触发 vxe-grid 重载,不用于编辑表的临时新增、保存或删除。
|
|
718
|
+
* @param {Array} val 新的完整数据集。
|
|
719
|
+
*/
|
|
643
720
|
setValue(val) {
|
|
644
721
|
// console.log("rows:",val);
|
|
645
722
|
this.clearRowWidgets();
|
|
@@ -652,13 +729,16 @@ modules = {
|
|
|
652
729
|
this.initFieldSchemaData();
|
|
653
730
|
// $grid.loadData(rows);
|
|
654
731
|
},
|
|
732
|
+
/** @returns {Array} 表单模型中的当前扁平数据。 */
|
|
655
733
|
getValue() {
|
|
656
734
|
return this.formModel[this.fieldKeyName];
|
|
657
735
|
},
|
|
736
|
+
/** @param {Object} widget 组件 schema。@returns {String} 组件实际绑定字段名。 */
|
|
658
737
|
getFieldKeyName(widget) {
|
|
659
738
|
let o = widget.options.name;
|
|
660
739
|
return (widget.options.keyNameEnabled && widget.options.keyName) || o;
|
|
661
740
|
},
|
|
741
|
+
/** @returns {String} 数据集必填校验提示。 */
|
|
662
742
|
getDatasetRequiredHint() {
|
|
663
743
|
if (this.widget.options.requiredHint) {
|
|
664
744
|
return this.$t1(this.widget.options.requiredHint);
|
|
@@ -666,6 +746,7 @@ modules = {
|
|
|
666
746
|
const label = this.$t1(this.widget.options.label || this.fieldKeyName);
|
|
667
747
|
return this.$t1("[{label}]不能为空", { label });
|
|
668
748
|
},
|
|
749
|
+
/** @returns {Boolean} 数据表整体必填校验是否通过。 */
|
|
669
750
|
validateDatasetRequired() {
|
|
670
751
|
if (!this.widget.options.required || this.widget.options.hidden) {
|
|
671
752
|
return null;
|
|
@@ -676,6 +757,7 @@ modules = {
|
|
|
676
757
|
}
|
|
677
758
|
return this.getDatasetRequiredHint();
|
|
678
759
|
},
|
|
760
|
+
/** @returns {Array} 当前参与单元格校验的数据。 */
|
|
679
761
|
getValidationRows() {
|
|
680
762
|
const formRows = this.formModel[this.fieldKeyName];
|
|
681
763
|
if (Array.isArray(formRows) && formRows.length) {
|
|
@@ -687,6 +769,7 @@ modules = {
|
|
|
687
769
|
}
|
|
688
770
|
return [];
|
|
689
771
|
},
|
|
772
|
+
/** @param {Object} row 行数据。@param {Array} rows 校验数据集。@param {Number} fallbackIndex 未匹配时索引。@returns {Number} */
|
|
690
773
|
getValidationRowIndex(row, rows, fallbackIndex = 0) {
|
|
691
774
|
if (!row || !Array.isArray(rows)) {
|
|
692
775
|
return fallbackIndex;
|
|
@@ -703,6 +786,7 @@ modules = {
|
|
|
703
786
|
const index = rows.indexOf(row);
|
|
704
787
|
return index >= 0 ? index : fallbackIndex;
|
|
705
788
|
},
|
|
789
|
+
/** @param {Object} column 列配置。@param {Boolean} isEditTable 是否编辑表。@param {Array} entries 输出数组。 */
|
|
706
790
|
collectColumnValidateEntries(column, isEditTable, entries) {
|
|
707
791
|
if (column.widget) {
|
|
708
792
|
entries.push({
|
|
@@ -725,6 +809,7 @@ modules = {
|
|
|
725
809
|
});
|
|
726
810
|
}
|
|
727
811
|
},
|
|
812
|
+
/** @param {Object} row 行数据。@param {Object} templateWidget 组件模板。@returns {Object} 当前行组件 schema。 */
|
|
728
813
|
resolveRowFieldWidget(row, templateWidget) {
|
|
729
814
|
if (!row || !templateWidget) {
|
|
730
815
|
return templateWidget;
|
|
@@ -735,6 +820,7 @@ modules = {
|
|
|
735
820
|
}
|
|
736
821
|
return templateWidget;
|
|
737
822
|
},
|
|
823
|
+
/** @param {Object} row 错误行。@param {String} propName 字段名。滚动并聚焦首个校验错误。 */
|
|
738
824
|
locateValidationError(row, propName) {
|
|
739
825
|
const $grid = this.getGridTable?.();
|
|
740
826
|
if ($grid && row) {
|
|
@@ -748,6 +834,10 @@ modules = {
|
|
|
748
834
|
renderForm.validateField(propName, () => {});
|
|
749
835
|
}
|
|
750
836
|
},
|
|
837
|
+
/**
|
|
838
|
+
* 按当前有效列逐单元格执行必填校验,并定位首个错误单元格。
|
|
839
|
+
* @returns {Promise<Boolean>} 全部通过时为 true。
|
|
840
|
+
*/
|
|
751
841
|
validateCellsRequired() {
|
|
752
842
|
if (this.widget.options.hidden || this.designState) {
|
|
753
843
|
return null;
|
|
@@ -819,12 +909,15 @@ modules = {
|
|
|
819
909
|
|
|
820
910
|
return null;
|
|
821
911
|
},
|
|
912
|
+
/** @param {Boolean} required 是否将整个数据表设为必填。 */
|
|
822
913
|
setRequired(required) {
|
|
823
914
|
this.$set(this.widget.options, "required", !!required);
|
|
824
915
|
},
|
|
916
|
+
/** @param {Object} e 组件 schema。设计态选择当前组件。 */
|
|
825
917
|
selectWidget: function (e) {
|
|
826
918
|
this.designer.setSelected(e);
|
|
827
919
|
},
|
|
920
|
+
/** @param {*} cellValue 单元格值。@param {String} formatS 格式编码。@param {Boolean} utcTransformEnabled 是否转换 UTC。@returns {*} */
|
|
828
921
|
getFormatterValue(cellValue, formatS, utcTransformEnabled) {
|
|
829
922
|
let value = cellValue;
|
|
830
923
|
if (utcTransformEnabled && value != null && value !== "") {
|
|
@@ -873,6 +966,7 @@ modules = {
|
|
|
873
966
|
}
|
|
874
967
|
return value;
|
|
875
968
|
},
|
|
969
|
+
/** @param {String} formatS 格式编码。@returns {Boolean} 是否由列层处理 UTC。 */
|
|
876
970
|
isColumnLevelUtcFormat(formatS) {
|
|
877
971
|
if (!formatS) {
|
|
878
972
|
return true;
|
|
@@ -888,6 +982,7 @@ modules = {
|
|
|
888
982
|
"modify_date",
|
|
889
983
|
].includes(formatS);
|
|
890
984
|
},
|
|
985
|
+
/** @param {Object} column VXE 列配置。@returns {Boolean} 当前列是否启用 UTC 转换。 */
|
|
891
986
|
getColumnUtcTransformEnabled(column) {
|
|
892
987
|
const formatS = column.params?.formatS;
|
|
893
988
|
if (!this.isColumnLevelUtcFormat(formatS)) {
|
|
@@ -898,6 +993,7 @@ modules = {
|
|
|
898
993
|
column.params.columnConfig?.utcTransformEnabled
|
|
899
994
|
);
|
|
900
995
|
},
|
|
996
|
+
/** @param {Object} params VXE formatter 参数。@returns {*} 格式化后的单元格值。 */
|
|
901
997
|
formatterValue: function ({ cellValue, row, column }) {
|
|
902
998
|
if (cellValue === null || cellValue === undefined) return cellValue;
|
|
903
999
|
if (!column.params) return cellValue;
|
|
@@ -909,15 +1005,19 @@ modules = {
|
|
|
909
1005
|
}
|
|
910
1006
|
return this.getFormatterValue(cellValue, formatS, utcTransformEnabled);
|
|
911
1007
|
},
|
|
1008
|
+
/** @param {Object} e VXE 行参数。@returns {Number} 数据行索引。 */
|
|
912
1009
|
getRowIndex: function (e) {
|
|
913
1010
|
return this.widget.options.tableData.lastIndexOf(e);
|
|
914
1011
|
},
|
|
1012
|
+
/** @returns {Array} 设计器保存的静态列配置。 */
|
|
915
1013
|
getTableColumns() {
|
|
916
1014
|
return this.widget.options.tableColumns || [];
|
|
917
1015
|
},
|
|
1016
|
+
/** @returns {String} 动态列来源:none、script 或 api。 */
|
|
918
1017
|
getDynamicColumnSourceType() {
|
|
919
1018
|
return this.widget.options.dynamicColumnSourceType || "none";
|
|
920
1019
|
},
|
|
1020
|
+
/** @returns {Array} 执行动态列脚本得到的原始列配置。 */
|
|
921
1021
|
getDynamicTableColumnsFromScript() {
|
|
922
1022
|
if (this.getDynamicColumnSourceType() !== "script") {
|
|
923
1023
|
return undefined;
|
|
@@ -932,6 +1032,7 @@ modules = {
|
|
|
932
1032
|
}
|
|
933
1033
|
return this.normalizeDynamicColumnResult(result);
|
|
934
1034
|
},
|
|
1035
|
+
/** @param {*} result 动态列原始结果。@returns {Array} 统一后的列数组。 */
|
|
935
1036
|
normalizeDynamicColumnResult(result) {
|
|
936
1037
|
if (result === null || result === undefined) {
|
|
937
1038
|
return result;
|
|
@@ -948,6 +1049,12 @@ modules = {
|
|
|
948
1049
|
}
|
|
949
1050
|
return normalized;
|
|
950
1051
|
},
|
|
1052
|
+
/**
|
|
1053
|
+
* 按 dynamicColumnMode 合并设计期静态列与运行时动态列。
|
|
1054
|
+
* @param {Array} staticColumns 设计器保存的列。
|
|
1055
|
+
* @param {Array|Object} dynamicResult 动态列脚本或接口的返回结果。
|
|
1056
|
+
* @returns {Array} 合并后的列配置。
|
|
1057
|
+
*/
|
|
951
1058
|
mergeDynamicTableColumns(staticColumns, dynamicResult) {
|
|
952
1059
|
const staticCols = staticColumns || [];
|
|
953
1060
|
if (dynamicResult === undefined || dynamicResult === null) {
|
|
@@ -967,6 +1074,11 @@ modules = {
|
|
|
967
1074
|
}
|
|
968
1075
|
return staticCols;
|
|
969
1076
|
},
|
|
1077
|
+
/**
|
|
1078
|
+
* 获取当前真正用于渲染的列;动态列可用时优先使用动态结果。
|
|
1079
|
+
* @param {Boolean} forceDynamic 是否忽略初始化状态强制采用动态列。
|
|
1080
|
+
* @returns {Array}
|
|
1081
|
+
*/
|
|
970
1082
|
getEffectiveTableColumns(forceDynamic = false) {
|
|
971
1083
|
const staticColumns = this.widget.options.tableColumns || [];
|
|
972
1084
|
const runtimeDynamic = this.dynamicTableColumns || [];
|
|
@@ -986,6 +1098,7 @@ modules = {
|
|
|
986
1098
|
}
|
|
987
1099
|
return staticColumns;
|
|
988
1100
|
},
|
|
1101
|
+
/** @param {Array} tableColumns 列配置。为缺失组件的列补建 widget/editWidget。 */
|
|
989
1102
|
attachTableColumnWidgets(tableColumns) {
|
|
990
1103
|
if (!Array.isArray(tableColumns) || !tableColumns.length) {
|
|
991
1104
|
return tableColumns;
|
|
@@ -1005,12 +1118,14 @@ modules = {
|
|
|
1005
1118
|
this.widget.options.tableColumns = savedColumns;
|
|
1006
1119
|
return tableColumns;
|
|
1007
1120
|
},
|
|
1121
|
+
/** @param {Boolean} forceDynamic 是否强制动态列。@returns {Array} 已补齐组件的有效列。 */
|
|
1008
1122
|
ensureEffectiveColumnWidgets(forceDynamic = false) {
|
|
1009
1123
|
const effectiveColumns = this.getEffectiveTableColumns(forceDynamic);
|
|
1010
1124
|
this.attachTableColumnWidgets(effectiveColumns);
|
|
1011
1125
|
this.syncEffectiveColumnWidgetFieldKeys(effectiveColumns);
|
|
1012
1126
|
this.afterDynamicColumnsCommonWidget(effectiveColumns);
|
|
1013
1127
|
},
|
|
1128
|
+
/** @param {Array} tableColumns 最终列配置。触发公共组件的动态列后处理。 */
|
|
1014
1129
|
afterDynamicColumnsCommonWidget(tableColumns) {
|
|
1015
1130
|
if (this.getDynamicColumnSourceType() === "none") return;
|
|
1016
1131
|
const formRef = this.getFormRef();
|
|
@@ -1021,9 +1136,11 @@ modules = {
|
|
|
1021
1136
|
}
|
|
1022
1137
|
});
|
|
1023
1138
|
},
|
|
1139
|
+
/** @returns {Boolean} 首次初始化是否跳过动态列加载。 */
|
|
1024
1140
|
shouldSkipDynamicColumnsOnInit() {
|
|
1025
1141
|
return this.dynamicColumnsInitResolved && this.dynamicColumnsInitSkipped;
|
|
1026
1142
|
},
|
|
1143
|
+
/** @param {Object} columnConfig 列配置。@returns {Boolean} 列是否可见。 */
|
|
1027
1144
|
getColumnVisible(columnConfig) {
|
|
1028
1145
|
if (columnConfig.show === false) {
|
|
1029
1146
|
return false;
|
|
@@ -1038,6 +1155,7 @@ modules = {
|
|
|
1038
1155
|
}
|
|
1039
1156
|
return true;
|
|
1040
1157
|
},
|
|
1158
|
+
/** @returns {Promise<Array>} 重建并重新加载当前有效列。 */
|
|
1041
1159
|
applyTableColumnsReload() {
|
|
1042
1160
|
this.ensureEffectiveColumnWidgets(true);
|
|
1043
1161
|
const effectiveColumns = this.getEffectiveTableColumns(true);
|
|
@@ -1075,6 +1193,11 @@ modules = {
|
|
|
1075
1193
|
);
|
|
1076
1194
|
});
|
|
1077
1195
|
},
|
|
1196
|
+
/**
|
|
1197
|
+
* 替换列配置并刷新 VXE 列、行 schema 和组件选项。
|
|
1198
|
+
* @param {Array} tableColumns 新列配置。
|
|
1199
|
+
* @returns {Promise<Array>} 实际应用到 VXE 的列配置。
|
|
1200
|
+
*/
|
|
1078
1201
|
reloadTableColumns(tableColumns) {
|
|
1079
1202
|
if (Array.isArray(tableColumns)) {
|
|
1080
1203
|
this.dynamicTableColumns = [];
|
|
@@ -1082,12 +1205,19 @@ modules = {
|
|
|
1082
1205
|
}
|
|
1083
1206
|
return this.applyTableColumnsReload();
|
|
1084
1207
|
},
|
|
1208
|
+
/** @param {Array} tableColumns 新静态列。@returns {Promise<Array>} */
|
|
1085
1209
|
setTableColumns(tableColumns) {
|
|
1086
1210
|
return this.reloadTableColumns(tableColumns);
|
|
1087
1211
|
},
|
|
1212
|
+
/** @param {Array} tableColumns 新静态列。兼容旧版单数方法名。 */
|
|
1088
1213
|
setTableColumn(tableColumns) {
|
|
1089
1214
|
return this.setTableColumns(tableColumns);
|
|
1090
1215
|
},
|
|
1216
|
+
/**
|
|
1217
|
+
* 写入动态列并应用到当前表格。
|
|
1218
|
+
* @param {Array} tableColumns 动态列列表。
|
|
1219
|
+
* @param {Object} options mode 控制 replace/append 等合并方式。
|
|
1220
|
+
*/
|
|
1091
1221
|
setDynamicTableColumns(tableColumns, options = {}) {
|
|
1092
1222
|
const { mode, deferReload } = options;
|
|
1093
1223
|
return this.assignDynamicTableColumns(tableColumns, { mode }).then(
|
|
@@ -1102,9 +1232,11 @@ modules = {
|
|
|
1102
1232
|
}
|
|
1103
1233
|
);
|
|
1104
1234
|
},
|
|
1235
|
+
/** @returns {Promise<Array>} 根据最新显示条件刷新列。 */
|
|
1105
1236
|
refreshColumnVisible() {
|
|
1106
1237
|
return this.applyTableColumnsReload();
|
|
1107
1238
|
},
|
|
1239
|
+
/** @param {Object} options 动态列请求选项。@returns {Object} 接口请求数据。 */
|
|
1108
1240
|
buildDynamicColumnRequestData(options = {}) {
|
|
1109
1241
|
if (options.data !== undefined) {
|
|
1110
1242
|
return options.data;
|
|
@@ -1140,6 +1272,7 @@ modules = {
|
|
|
1140
1272
|
}
|
|
1141
1273
|
);
|
|
1142
1274
|
},
|
|
1275
|
+
/** @param {Object} res 接口响应。@param {Object} options 解析配置。@returns {Array} 动态列。 */
|
|
1143
1276
|
convertDynamicColumnResponse(res, options = {}) {
|
|
1144
1277
|
const convertScript =
|
|
1145
1278
|
options.convertScript ??
|
|
@@ -1151,6 +1284,11 @@ modules = {
|
|
|
1151
1284
|
);
|
|
1152
1285
|
return normalizeDynamicColumnList(items);
|
|
1153
1286
|
},
|
|
1287
|
+
/**
|
|
1288
|
+
* 根据动态列来源(脚本或接口)加载列配置。
|
|
1289
|
+
* @param {Object} options 请求参数及成功、失败回调。
|
|
1290
|
+
* @returns {Promise<Array>} 解析并标准化后的动态列。
|
|
1291
|
+
*/
|
|
1154
1292
|
loadDynamicColumns(options = {}) {
|
|
1155
1293
|
const source = this.getDynamicColumnSourceType();
|
|
1156
1294
|
if (source === "script") {
|
|
@@ -1179,6 +1317,7 @@ modules = {
|
|
|
1179
1317
|
});
|
|
1180
1318
|
});
|
|
1181
1319
|
},
|
|
1320
|
+
/** @returns {Promise<Boolean>} 当前初始化阶段是否需要加载动态列。 */
|
|
1182
1321
|
resolveShouldInitDynamicColumns() {
|
|
1183
1322
|
const source = this.getDynamicColumnSourceType();
|
|
1184
1323
|
if (source === "none") {
|
|
@@ -1209,9 +1348,11 @@ modules = {
|
|
|
1209
1348
|
return Promise.resolve(false);
|
|
1210
1349
|
}
|
|
1211
1350
|
},
|
|
1351
|
+
/** @returns {Boolean} VXE 配置是否已完成初始化。 */
|
|
1212
1352
|
isTableColumnGridInitialized() {
|
|
1213
1353
|
return !!this.vxeOption;
|
|
1214
1354
|
},
|
|
1355
|
+
/** @param {Array} tableColumns 动态列。@param {Object} options 合并模式。@returns {Promise<Array>} */
|
|
1215
1356
|
assignDynamicTableColumns(tableColumns, options = {}) {
|
|
1216
1357
|
const { mode } = options;
|
|
1217
1358
|
if (mode) {
|
|
@@ -1223,6 +1364,7 @@ modules = {
|
|
|
1223
1364
|
this.ensureEffectiveColumnWidgets();
|
|
1224
1365
|
return Promise.resolve(this.dynamicTableColumns);
|
|
1225
1366
|
},
|
|
1367
|
+
/** @param {Object} options 请求与回调配置。@returns {Promise<Object>} 包含响应和列数组。 */
|
|
1226
1368
|
requestDynamicColumnsFromApi(options = {}) {
|
|
1227
1369
|
const scriptCode =
|
|
1228
1370
|
options.scriptCode ?? this.widget.options.dynamicColumnScriptCode;
|
|
@@ -1243,6 +1385,10 @@ modules = {
|
|
|
1243
1385
|
return { res, columns };
|
|
1244
1386
|
});
|
|
1245
1387
|
},
|
|
1388
|
+
/**
|
|
1389
|
+
* 表格初始化前预加载动态列,保证首次创建 VXE 列时即使用最终配置。
|
|
1390
|
+
* @returns {Promise<void>}
|
|
1391
|
+
*/
|
|
1246
1392
|
bootstrapDynamicColumnsBeforeInit() {
|
|
1247
1393
|
return this.resolveShouldInitDynamicColumns().then((shouldInit) => {
|
|
1248
1394
|
this.dynamicColumnsInitResolved = true;
|
|
@@ -1259,6 +1405,7 @@ modules = {
|
|
|
1259
1405
|
});
|
|
1260
1406
|
});
|
|
1261
1407
|
},
|
|
1408
|
+
/** @returns {Promise} 在尚未预加载时尝试自动获取动态列。 */
|
|
1262
1409
|
tryAutoLoadDynamicColumns() {
|
|
1263
1410
|
if (
|
|
1264
1411
|
this.dynamicColumnsPreloaded ||
|
|
@@ -1273,9 +1420,14 @@ modules = {
|
|
|
1273
1420
|
return this.loadDynamicColumns({ isLoading: true }).catch(() => {});
|
|
1274
1421
|
});
|
|
1275
1422
|
},
|
|
1423
|
+
/** @returns {Array} 组件配置中的静态 tableData。 */
|
|
1276
1424
|
getTableData: function () {
|
|
1277
1425
|
return this.widget.options.tableData;
|
|
1278
1426
|
},
|
|
1427
|
+
/**
|
|
1428
|
+
* 重置查询表单,并按配置决定是否立即重新查询。
|
|
1429
|
+
* @param {Object} options 可覆盖默认重置行为。
|
|
1430
|
+
*/
|
|
1279
1431
|
resetForm(options) {
|
|
1280
1432
|
let formData = this.formModel;
|
|
1281
1433
|
let ignoreFields = options?.ignoreFields || [];
|
|
@@ -1291,6 +1443,7 @@ modules = {
|
|
|
1291
1443
|
}
|
|
1292
1444
|
});
|
|
1293
1445
|
},
|
|
1446
|
+
/** 执行查询表单搜索并重置到第一页。 */
|
|
1294
1447
|
searchEvent() {
|
|
1295
1448
|
this.getGridTable().commitProxy("reload");
|
|
1296
1449
|
},
|
|
@@ -1298,6 +1451,7 @@ modules = {
|
|
|
1298
1451
|
this.resetForm(options);
|
|
1299
1452
|
this.getGridTable().commitProxy("reload");
|
|
1300
1453
|
},
|
|
1454
|
+
/** 查询区“搜索”按钮入口,先同步表单数据再发起查询。 */
|
|
1301
1455
|
handleSearchClick() {
|
|
1302
1456
|
if (this.widget.options.onSearchTable) {
|
|
1303
1457
|
this.handleCustomEvent(this.widget.options.onSearchTable);
|
|
@@ -1305,6 +1459,7 @@ modules = {
|
|
|
1305
1459
|
}
|
|
1306
1460
|
this.searchEvent();
|
|
1307
1461
|
},
|
|
1462
|
+
/** 查询区“重置”按钮入口。 */
|
|
1308
1463
|
handleResetClick() {
|
|
1309
1464
|
if (this.widget.options.onResetTable) {
|
|
1310
1465
|
this.handleCustomEvent(this.widget.options.onResetTable);
|
|
@@ -1312,6 +1467,12 @@ modules = {
|
|
|
1312
1467
|
}
|
|
1313
1468
|
this.resetEvent();
|
|
1314
1469
|
},
|
|
1470
|
+
/**
|
|
1471
|
+
* 打开行编辑弹窗。
|
|
1472
|
+
* @param {Object} row 当前行数据。
|
|
1473
|
+
* @param {Object} param 传递给弹窗或脚本的附加参数。
|
|
1474
|
+
* @param {Object} option 弹窗配置覆盖项。
|
|
1475
|
+
*/
|
|
1315
1476
|
openEditDialog(row, param, option) {
|
|
1316
1477
|
let formRef = this.getFormRef();
|
|
1317
1478
|
let formConfig = this.formConfig;
|
|
@@ -1329,7 +1490,9 @@ modules = {
|
|
|
1329
1490
|
...option,
|
|
1330
1491
|
});
|
|
1331
1492
|
},
|
|
1493
|
+
/** Excel 导入扩展入口,由具体业务按需覆盖。 */
|
|
1332
1494
|
importExcel() {},
|
|
1495
|
+
/** @param {Object} that 调用上下文。@param {String} tableRef 表格 ref。@returns {Object} VXE Grid 实例。 */
|
|
1333
1496
|
getGrid(that, tableRef) {
|
|
1334
1497
|
let $grid;
|
|
1335
1498
|
if (Array.isArray(that.$refs[tableRef])) {
|
|
@@ -1339,12 +1502,14 @@ modules = {
|
|
|
1339
1502
|
}
|
|
1340
1503
|
return $grid;
|
|
1341
1504
|
},
|
|
1505
|
+
/** @returns {Object} 当前表格查询条件。 */
|
|
1342
1506
|
getTableCondition: function () {
|
|
1343
1507
|
if (this.widget.options.tableCondition) {
|
|
1344
1508
|
let e = new Function(this.widget.options.tableCondition);
|
|
1345
1509
|
return e.call(this);
|
|
1346
1510
|
}
|
|
1347
1511
|
},
|
|
1512
|
+
/** @returns {Object} 查询区提交条件。 */
|
|
1348
1513
|
getSearchCondition: function () {
|
|
1349
1514
|
let extraAccessData = this.extraAccessData || {};
|
|
1350
1515
|
let searchFormData = this.getSearchFormData();
|
|
@@ -1361,6 +1526,11 @@ modules = {
|
|
|
1361
1526
|
};
|
|
1362
1527
|
return conditions;
|
|
1363
1528
|
},
|
|
1529
|
+
/**
|
|
1530
|
+
* 将设计器列转换成 VXE 列,挂载展示/编辑插槽及列级格式化配置。
|
|
1531
|
+
* 同时收集行级组件模板,供 fieldSchemaMap 为每行克隆独立 schema。
|
|
1532
|
+
* @returns {Array} VXE columns 配置。
|
|
1533
|
+
*/
|
|
1364
1534
|
createColumns() {
|
|
1365
1535
|
let rowWidgetList = [];
|
|
1366
1536
|
let tableColumns = this.attachTableColumnWidgets(
|
|
@@ -1611,6 +1781,7 @@ modules = {
|
|
|
1611
1781
|
return this.$baseLodash.cloneDeep(newColumns);
|
|
1612
1782
|
},
|
|
1613
1783
|
//begin
|
|
1784
|
+
/** @param {Object} fieldWidget 选项组件 schema。@param {*} fieldModel 当前值。@returns {String} 展示标签。 */
|
|
1614
1785
|
getOptionLabel(fieldWidget, fieldModel) {
|
|
1615
1786
|
if (fieldModel === null) {
|
|
1616
1787
|
return null;
|
|
@@ -1629,6 +1800,7 @@ modules = {
|
|
|
1629
1800
|
return resultList.join(",");
|
|
1630
1801
|
}
|
|
1631
1802
|
},
|
|
1803
|
+
/** @param {Object} fieldWidget 状态组件 schema。@param {*} fieldModel 当前值。@returns {String} 状态标签。 */
|
|
1632
1804
|
getStatusOptionLabel(fieldWidget, fieldModel) {
|
|
1633
1805
|
if (fieldModel === null || fieldModel === undefined) {
|
|
1634
1806
|
return null;
|
|
@@ -1641,6 +1813,7 @@ modules = {
|
|
|
1641
1813
|
);
|
|
1642
1814
|
return statusItem ? this.$t1(statusItem[labelField]) : null;
|
|
1643
1815
|
},
|
|
1816
|
+
/** @param {Array} e 数据数组。@param {Function} t 匹配函数。@returns {*} 首个匹配项。 */
|
|
1644
1817
|
findInArray: function (e, t) {
|
|
1645
1818
|
if (!Array.isArray(e)) return -1;
|
|
1646
1819
|
var i = -1;
|
|
@@ -2224,7 +2397,14 @@ modules = {
|
|
|
2224
2397
|
//导出
|
|
2225
2398
|
this.initExportFieldSchemaData(rows);
|
|
2226
2399
|
} else {
|
|
2227
|
-
|
|
2400
|
+
// VXE 与表单必须共用同一批标准化行,否则 _X_ROW_KEY 不一致,
|
|
2401
|
+
// 行虽能进入编辑态,但 editWidget 无法取得对应的行级 schema。
|
|
2402
|
+
rows = this.initValue(rows);
|
|
2403
|
+
if (res.objx?.records !== undefined) {
|
|
2404
|
+
res.objx.records = rows;
|
|
2405
|
+
} else {
|
|
2406
|
+
res.objx = rows;
|
|
2407
|
+
}
|
|
2228
2408
|
}
|
|
2229
2409
|
|
|
2230
2410
|
resolve(res);
|
|
@@ -2397,6 +2577,11 @@ modules = {
|
|
|
2397
2577
|
});
|
|
2398
2578
|
});
|
|
2399
2579
|
},
|
|
2580
|
+
/**
|
|
2581
|
+
* 深度遍历分组列和叶子列。
|
|
2582
|
+
* @param {Array} columns 列配置。
|
|
2583
|
+
* @param {Function} callback 每个列节点的处理函数。
|
|
2584
|
+
*/
|
|
2400
2585
|
loodHandleColumns(columns, callback) {
|
|
2401
2586
|
let columnLoopDo = (t, e) => {
|
|
2402
2587
|
callback && callback(t);
|
|
@@ -2412,10 +2597,12 @@ modules = {
|
|
|
2412
2597
|
}
|
|
2413
2598
|
},
|
|
2414
2599
|
|
|
2600
|
+
/** @param {Array} list 数据列表。@param {String} field 数值字段。@returns {Number} 平均值。 */
|
|
2415
2601
|
meanNum(list, field) {
|
|
2416
2602
|
let count = this.sumNum(list, field);
|
|
2417
2603
|
return this.$baseDiv(count, list.length);
|
|
2418
2604
|
},
|
|
2605
|
+
/** @param {Array} list 数据列表。@param {String} field 数值字段。@returns {Number} 合计值。 */
|
|
2419
2606
|
sumNum(list, field) {
|
|
2420
2607
|
let count = 0;
|
|
2421
2608
|
list.forEach((item) => {
|
|
@@ -2423,6 +2610,7 @@ modules = {
|
|
|
2423
2610
|
});
|
|
2424
2611
|
return count;
|
|
2425
2612
|
},
|
|
2613
|
+
/** @returns {Object} 查询区当前字段值。 */
|
|
2426
2614
|
getSearchFormData() {
|
|
2427
2615
|
let map = { condition: [] };
|
|
2428
2616
|
let formData = this.globalModel.formModel;
|
|
@@ -2468,10 +2656,12 @@ modules = {
|
|
|
2468
2656
|
}
|
|
2469
2657
|
return map;
|
|
2470
2658
|
},
|
|
2659
|
+
/** @returns {String} 当前列表请求 URL。 */
|
|
2471
2660
|
getUrl() {
|
|
2472
2661
|
let accessUrl = this.widget.options.accessUrl;
|
|
2473
2662
|
return accessUrl || USER_PREFIX + `/form_ins/getFormInsData`;
|
|
2474
2663
|
},
|
|
2664
|
+
/** @returns {Array} 当前表格涉及的附件字段类型。 */
|
|
2475
2665
|
getAttachmentType() {
|
|
2476
2666
|
/* let vailColumns = this.widget.options.tableColumns.filter(
|
|
2477
2667
|
(item) => item.prop && item.label
|
|
@@ -2492,6 +2682,7 @@ modules = {
|
|
|
2492
2682
|
});
|
|
2493
2683
|
return result;
|
|
2494
2684
|
},
|
|
2685
|
+
/** @returns {Array} 当前表格使用的三级表字段。 */
|
|
2495
2686
|
getThirdtabm() {
|
|
2496
2687
|
/* let vailColumns = this.widget.options.tableColumns.filter(
|
|
2497
2688
|
(item) => item.prop && item.label
|
|
@@ -2518,6 +2709,10 @@ modules = {
|
|
|
2518
2709
|
return result;
|
|
2519
2710
|
},
|
|
2520
2711
|
|
|
2712
|
+
/**
|
|
2713
|
+
* 加载表格默认数据,统一处理分页结果、树排序、回调及行 schema 初始化。
|
|
2714
|
+
* @param {Object} option 本次查询的覆盖配置。
|
|
2715
|
+
*/
|
|
2521
2716
|
loadDefaultViewList(option) {
|
|
2522
2717
|
let dataId = this.formDataId;
|
|
2523
2718
|
let reportTemplate = this.getFormRef().reportTemplate;
|
|
@@ -2578,10 +2773,12 @@ modules = {
|
|
|
2578
2773
|
},
|
|
2579
2774
|
});
|
|
2580
2775
|
},
|
|
2776
|
+
/** @returns {Object} 当前表格脚本访问参数。 */
|
|
2581
2777
|
getAccessParam() {
|
|
2582
2778
|
if (!this.widget.options.formScriptParam) return;
|
|
2583
2779
|
return this.handleCustomEvent(this.widget.options.formScriptParam);
|
|
2584
2780
|
},
|
|
2781
|
+
/** @returns {String} 当前列表查询脚本编码。 */
|
|
2585
2782
|
getScriptCode() {
|
|
2586
2783
|
let accessReturnType = this.widget.options.accessReturnType;
|
|
2587
2784
|
let defaultScriptCode = "getList";
|
|
@@ -2593,6 +2790,12 @@ modules = {
|
|
|
2593
2790
|
let scriptCode = this.widget.options.formScriptCode || defaultScriptCode;
|
|
2594
2791
|
return scriptCode;
|
|
2595
2792
|
},
|
|
2793
|
+
/**
|
|
2794
|
+
* 执行默认列表查询。
|
|
2795
|
+
* @param {Object} reqData 查询请求数据。
|
|
2796
|
+
* @param {Function} done VXE 代理查询完成回调。
|
|
2797
|
+
* @param {Object} customParam 调用方附加参数。
|
|
2798
|
+
*/
|
|
2596
2799
|
loadDefaultQueryList(reqData, done, customParam) {
|
|
2597
2800
|
let reportTemplate = this.getFormRef().reportTemplate;
|
|
2598
2801
|
let prefix = "/" + reportTemplate.serviceName;
|
|
@@ -2665,6 +2868,7 @@ modules = {
|
|
|
2665
2868
|
},
|
|
2666
2869
|
});
|
|
2667
2870
|
},
|
|
2871
|
+
/** @param {Boolean} flag 是否显示加载状态。重新加载当前表格数据。 */
|
|
2668
2872
|
loadAccessData(flag) {
|
|
2669
2873
|
if (
|
|
2670
2874
|
this.formModel[this.fieldKeyName] &&
|
|
@@ -2688,6 +2892,7 @@ modules = {
|
|
|
2688
2892
|
this.loadDefaultViewList();
|
|
2689
2893
|
}
|
|
2690
2894
|
},
|
|
2895
|
+
/** @param {Object} item 参数配置。@param {*} dataId 主数据 id。@param {Object} billData 单据数据。@returns {Object} */
|
|
2691
2896
|
getReqParam(item, dataId, billData) {
|
|
2692
2897
|
let param = {};
|
|
2693
2898
|
if (item.accessParam) {
|
|
@@ -2702,10 +2907,15 @@ modules = {
|
|
|
2702
2907
|
}
|
|
2703
2908
|
return param;
|
|
2704
2909
|
},
|
|
2910
|
+
/** @returns {String} 当前 vxe-grid 的 ref 名。 */
|
|
2705
2911
|
getTableRef() {
|
|
2706
2912
|
let tableRef = this.widget.id;
|
|
2707
2913
|
return tableRef;
|
|
2708
2914
|
},
|
|
2915
|
+
/**
|
|
2916
|
+
* 使用统一 Excel 导出器导出当前表格。
|
|
2917
|
+
* @param {Object} option 导出参数;prefix 为空时自动使用当前服务前缀。
|
|
2918
|
+
*/
|
|
2709
2919
|
exportData(option) {
|
|
2710
2920
|
let tableRef = this.getTableRef();
|
|
2711
2921
|
let serviceName = this.getFormRef().reportTemplate.serviceName;
|
|
@@ -2735,6 +2945,7 @@ modules = {
|
|
|
2735
2945
|
});
|
|
2736
2946
|
// this.deleteRowWidgets(row);
|
|
2737
2947
|
},
|
|
2948
|
+
/** @param {Object} widget 组件 schema。@returns {Boolean} 是否单值搜索组件。 */
|
|
2738
2949
|
isSingerlSearch(widget) {
|
|
2739
2950
|
let widgetType = widget?.type;
|
|
2740
2951
|
let result =
|
|
@@ -2742,6 +2953,7 @@ modules = {
|
|
|
2742
2953
|
(widgetType === "vabsearch" && !widget.options.multipleChoices);
|
|
2743
2954
|
return result;
|
|
2744
2955
|
},
|
|
2956
|
+
/** @param {Object} widget 组件 schema。@param {Boolean} defaultValueEnabled 是否取默认值。@returns {*} 字段初始值。 */
|
|
2745
2957
|
getColumnNullValue(widget, defaultValueEnabled) {
|
|
2746
2958
|
if (!widget) return null;
|
|
2747
2959
|
let nullValue = null;
|
|
@@ -2778,6 +2990,7 @@ modules = {
|
|
|
2778
2990
|
}
|
|
2779
2991
|
return nullValue;
|
|
2780
2992
|
},
|
|
2993
|
+
/** @param {Object} widget 组件 schema。@returns {Boolean} 是否表单字段组件。 */
|
|
2781
2994
|
getIsFormWidget(widget) {
|
|
2782
2995
|
let widgetTypes = ["baseAttachment"];
|
|
2783
2996
|
let result = false;
|
|
@@ -2786,6 +2999,7 @@ modules = {
|
|
|
2786
2999
|
}
|
|
2787
3000
|
return result;
|
|
2788
3001
|
},
|
|
3002
|
+
/** @param {Object} widget 组件 schema。@param {Object} newData 目标行。@param {Boolean} defaultValueEnabled 是否取默认值。 */
|
|
2789
3003
|
handleWidgetNullValue(widget, newData, defaultValueEnabled = true) {
|
|
2790
3004
|
if (!widget || !newData) return;
|
|
2791
3005
|
if (this.getIsFormWidget(widget)) {
|
|
@@ -2804,6 +3018,12 @@ modules = {
|
|
|
2804
3018
|
}
|
|
2805
3019
|
}
|
|
2806
3020
|
},
|
|
3021
|
+
/**
|
|
3022
|
+
* 根据叶子列创建空行,并按展示/编辑组件补齐字段初始值。
|
|
3023
|
+
* @param {Boolean} isEdit 是否优先采用 editWidget 配置。
|
|
3024
|
+
* @param {Boolean} defaultValueEnabled 是否写入组件默认值。
|
|
3025
|
+
* @returns {Object} 新行数据。
|
|
3026
|
+
*/
|
|
2807
3027
|
createNewTableData(isEdit, defaultValueEnabled = true) {
|
|
2808
3028
|
let newData = {};
|
|
2809
3029
|
this.loodHandleColumns(this.widget.options.tableColumns, (item) => {
|
|
@@ -2832,6 +3052,11 @@ modules = {
|
|
|
2832
3052
|
});
|
|
2833
3053
|
return newData;
|
|
2834
3054
|
},
|
|
3055
|
+
/**
|
|
3056
|
+
* 批量追加数据;field 存在时按该字段去重。
|
|
3057
|
+
* @param {Array} rows 待追加数据。
|
|
3058
|
+
* @param {String} field 可选的唯一性字段。
|
|
3059
|
+
*/
|
|
2835
3060
|
addTableData(rows, field) {
|
|
2836
3061
|
let $grid = this.getGridTable();
|
|
2837
3062
|
let formDataModel = this.formModel;
|
|
@@ -2867,6 +3092,7 @@ modules = {
|
|
|
2867
3092
|
this.handleWbs();
|
|
2868
3093
|
});
|
|
2869
3094
|
},
|
|
3095
|
+
/** @param {Object} fieldWidget 组件 schema。@param {Object} obj VXE 单元格参数。@returns {String} 表单校验 prop。 */
|
|
2870
3096
|
getColumnProp2(fieldWidget, obj) {
|
|
2871
3097
|
let isQueryTable = this.widget.options.isQueryTable || false;
|
|
2872
3098
|
let rowWidget = this.getRowWidget(obj, fieldWidget);
|
|
@@ -2888,6 +3114,7 @@ modules = {
|
|
|
2888
3114
|
}
|
|
2889
3115
|
return propName;
|
|
2890
3116
|
},
|
|
3117
|
+
/** @returns {Boolean} 是否满足表格勾选行要求。 */
|
|
2891
3118
|
validateCheckRow() {
|
|
2892
3119
|
let $grid = this.getGridTable();
|
|
2893
3120
|
let checkRows = $grid.getCheckboxRecords(true);
|
|
@@ -2934,6 +3161,7 @@ modules = {
|
|
|
2934
3161
|
});
|
|
2935
3162
|
return !hasError;
|
|
2936
3163
|
},
|
|
3164
|
+
/** @param {Object} widget 组件 schema。@param {Object} row 行数据。@returns {String} 字段校验 prop。 */
|
|
2937
3165
|
getColumnWidgetProp(widget, row) {
|
|
2938
3166
|
if (!widget) return;
|
|
2939
3167
|
let $grid = this.getGridTable();
|
|
@@ -2949,6 +3177,7 @@ modules = {
|
|
|
2949
3177
|
let propName = fieldKeyName + "." + rowIndex + "." + property;
|
|
2950
3178
|
return propName;
|
|
2951
3179
|
},
|
|
3180
|
+
/** @param {Object} obj VXE 单元格参数。@param {Boolean} isEdit 是否编辑插槽。@returns {String} 字段校验 prop。 */
|
|
2952
3181
|
getColumnProp(obj, isEdit) {
|
|
2953
3182
|
let sourceWidgetId = isEdit
|
|
2954
3183
|
? obj.column?.params?.editWidget?.id
|
|
@@ -2989,6 +3218,7 @@ modules = {
|
|
|
2989
3218
|
return "false";
|
|
2990
3219
|
}
|
|
2991
3220
|
},
|
|
3221
|
+
/** @param {Object} widget 组件 schema。@returns {Boolean} 是否搜索选择类组件。 */
|
|
2992
3222
|
isVabsearchFlagWidget(widget) {
|
|
2993
3223
|
let type = widget?.type;
|
|
2994
3224
|
return (
|
|
@@ -2997,6 +3227,7 @@ modules = {
|
|
|
2997
3227
|
type === "multiSearch"
|
|
2998
3228
|
);
|
|
2999
3229
|
},
|
|
3230
|
+
/** @param {Object} e 组件 schema。@returns {String|undefined} 动态组件名称。 */
|
|
3000
3231
|
getColumnWidgetName(e) {
|
|
3001
3232
|
if (e && e.type) {
|
|
3002
3233
|
if (e.category === "container") {
|
|
@@ -3006,16 +3237,20 @@ modules = {
|
|
|
3006
3237
|
}
|
|
3007
3238
|
}
|
|
3008
3239
|
},
|
|
3240
|
+
/** @returns {Object} 当前 VXE Grid 实例。 */
|
|
3009
3241
|
getGridTable() {
|
|
3010
3242
|
let $grid = this.$refs[this.getTableRef()];
|
|
3011
3243
|
return $grid;
|
|
3012
3244
|
},
|
|
3245
|
+
/** @param {Object} e 容器组件 schema。@returns {String} 动态组件名称。 */
|
|
3013
3246
|
getContainerWidgetName: function (e) {
|
|
3014
3247
|
return "grid" === e.type ? "grid-item" : e.type + "-item";
|
|
3015
3248
|
},
|
|
3249
|
+
/** @param {Object} e 字段组件 schema。@returns {String} 动态组件名称。 */
|
|
3016
3250
|
getWidgetName: function (e) {
|
|
3017
3251
|
return (e.targetType || e.type) + "-widget";
|
|
3018
3252
|
},
|
|
3253
|
+
/** @param {Object} param VXE checkbox-change 参数。同步合并行选择并触发自定义事件。 */
|
|
3019
3254
|
handleCheckboxChange(param) {
|
|
3020
3255
|
let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
|
|
3021
3256
|
let mergeRowKey = this.widget.options.mergeRowKey;
|
|
@@ -3038,6 +3273,7 @@ modules = {
|
|
|
3038
3273
|
dataTableConfig.onCheckboxChange &&
|
|
3039
3274
|
dataTableConfig.onCheckboxChange(param);
|
|
3040
3275
|
},
|
|
3276
|
+
/** @param {Object} param VXE checkbox-all 参数。触发全选自定义事件。 */
|
|
3041
3277
|
handleCheckboxAll(param) {
|
|
3042
3278
|
if (this.widget.options.onCheckboxAll) {
|
|
3043
3279
|
let t = new Function("param", this.widget.options.onCheckboxAll);
|
|
@@ -3047,6 +3283,7 @@ modules = {
|
|
|
3047
3283
|
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
|
3048
3284
|
dataTableConfig.onCheckboxAll && dataTableConfig.onCheckboxAll(param);
|
|
3049
3285
|
},
|
|
3286
|
+
/** @param {Object} param VXE cell-dblclick 参数。执行配置的双击脚本。 */
|
|
3050
3287
|
handleCellDblclick(param) {
|
|
3051
3288
|
if (this.widget.options.onCellDblclick) {
|
|
3052
3289
|
let t = new Function("param", this.widget.options.onCellDblclick);
|
|
@@ -3056,6 +3293,7 @@ modules = {
|
|
|
3056
3293
|
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
|
3057
3294
|
dataTableConfig.onCellDblclick && dataTableConfig.onCellDblclick(param);
|
|
3058
3295
|
},
|
|
3296
|
+
/** 清空高级查询条件并同步对应组件值。 */
|
|
3059
3297
|
advancedClear() {
|
|
3060
3298
|
let formModel = this.formModel;
|
|
3061
3299
|
let searchColumns = this.getGridTable().params.searchColumns;
|
|
@@ -3070,12 +3308,17 @@ modules = {
|
|
|
3070
3308
|
});
|
|
3071
3309
|
// this.getGridTable().$forceUpdate();
|
|
3072
3310
|
},
|
|
3311
|
+
/** 查询字段设置确认后,将当前模型同步到表单。 */
|
|
3073
3312
|
tableFormSettingConfirm() {
|
|
3074
3313
|
let formModel = this.formModel;
|
|
3075
3314
|
this.getFormRef().setFormData(formModel);
|
|
3076
3315
|
},
|
|
3077
3316
|
|
|
3078
3317
|
//editTable begin
|
|
3318
|
+
/**
|
|
3319
|
+
* 保存当前编辑行。成功后仅合并服务端字段,保留 VXE 行引用和 _X_ROW_KEY。
|
|
3320
|
+
* @param {Object} obj VXE 插槽参数,必须包含 row 和 $table。
|
|
3321
|
+
*/
|
|
3079
3322
|
async saveEditRow(obj) {
|
|
3080
3323
|
let formRef = this.getFormRef();
|
|
3081
3324
|
let formConfig = this.formConfig;
|
|
@@ -3149,6 +3392,7 @@ modules = {
|
|
|
3149
3392
|
}
|
|
3150
3393
|
});
|
|
3151
3394
|
},
|
|
3395
|
+
/** @param {*} dataId 行数据 id。@param {Function} callback 查询成功回调。加载保存后的完整行。 */
|
|
3152
3396
|
getRowData(dataId, callback) {
|
|
3153
3397
|
let reportTemplate = this.getFormRef()?.reportTemplate;
|
|
3154
3398
|
let formCode = reportTemplate.formCode;
|
|
@@ -3173,17 +3417,27 @@ modules = {
|
|
|
3173
3417
|
},
|
|
3174
3418
|
});
|
|
3175
3419
|
},
|
|
3420
|
+
/** @param {Object} rowData 新行数据。@param {Object} obj 父行参数。@param {Boolean} toTop 是否插到顶部。 */
|
|
3176
3421
|
addChildTreeRow(rowData, obj, toTop) {
|
|
3177
3422
|
let toEnd = !toTop;
|
|
3178
3423
|
this.addTreeRow(rowData, obj, toEnd, null);
|
|
3179
3424
|
},
|
|
3425
|
+
/** @param {Object} rowData 新行数据。@param {Boolean} toTop 是否插到顶部。新增一级节点。 */
|
|
3180
3426
|
addTopTreeRow(rowData, toTop) {
|
|
3181
3427
|
let toEnd = !toTop;
|
|
3182
3428
|
this.addTreeRow(rowData, null, toEnd, null);
|
|
3183
3429
|
},
|
|
3430
|
+
/** @param {Object} rowData 新行数据。@param {Object} obj 目标行参数。新增同级节点。 */
|
|
3184
3431
|
addSiblingTreeRow(rowData, obj) {
|
|
3185
3432
|
this.addTreeRow(rowData, obj, null, true);
|
|
3186
3433
|
},
|
|
3434
|
+
/**
|
|
3435
|
+
* 通过全量数据源新增普通树节点(非行编辑专用入口)。
|
|
3436
|
+
* @param {Object} rowData 新节点初始值。
|
|
3437
|
+
* @param {Object|null} obj 目标行的 VXE 参数;为空表示一级节点。
|
|
3438
|
+
* @param {Boolean} toEnd 是否追加到同级末尾。
|
|
3439
|
+
* @param {Boolean} toSibling 是否作为目标行的同级节点。
|
|
3440
|
+
*/
|
|
3187
3441
|
addTreeRow(rowData, obj, toEnd, toSibling) {
|
|
3188
3442
|
let isEditTable = this.widget.options.isEditTable || false;
|
|
3189
3443
|
let parent = obj?.row;
|
|
@@ -3261,6 +3515,11 @@ modules = {
|
|
|
3261
3515
|
});
|
|
3262
3516
|
}
|
|
3263
3517
|
},
|
|
3518
|
+
/**
|
|
3519
|
+
* 从普通树表删除节点及全部后代,并通过 setValue 重建树数据。
|
|
3520
|
+
* 编辑表临时行应使用 removeEditRow,避免重载整表。
|
|
3521
|
+
* @param {Object} obj VXE 行参数。
|
|
3522
|
+
*/
|
|
3264
3523
|
removeTreeRow(obj) {
|
|
3265
3524
|
let row = obj.row;
|
|
3266
3525
|
let $grid = this.getGridTable();
|
|
@@ -3312,6 +3571,7 @@ modules = {
|
|
|
3312
3571
|
this.handleWbs();
|
|
3313
3572
|
});
|
|
3314
3573
|
},
|
|
3574
|
+
/** @param {String} authName 行按钮权限名。@returns {String|null} 完整权限编码。 */
|
|
3315
3575
|
getTableRowAuthCode(authName) {
|
|
3316
3576
|
if (!authName) {
|
|
3317
3577
|
return null;
|
|
@@ -3322,6 +3582,7 @@ modules = {
|
|
|
3322
3582
|
}
|
|
3323
3583
|
return null;
|
|
3324
3584
|
},
|
|
3585
|
+
/** @param {String} authName 行按钮权限名。@returns {Boolean} 当前用户是否有权限。 */
|
|
3325
3586
|
hasTableRowPermission(authName) {
|
|
3326
3587
|
if (!authName) {
|
|
3327
3588
|
return true;
|
|
@@ -3333,6 +3594,7 @@ modules = {
|
|
|
3333
3594
|
let dispermissions = this.$store.getters.dispermissions;
|
|
3334
3595
|
return !dispermissions.includes(authCode);
|
|
3335
3596
|
},
|
|
3597
|
+
/** @param {Object} obj VXE 单元格参数。@returns {Object} 行新增/编辑按钮配置。 */
|
|
3336
3598
|
getEditTreeButtonGroupConfig(obj) {
|
|
3337
3599
|
let columnConfig = obj?.column?.params?.columnConfig || {};
|
|
3338
3600
|
let tableOptions = this.widget.options || {};
|
|
@@ -3343,18 +3605,23 @@ modules = {
|
|
|
3343
3605
|
rowEditShow: columnConfig.rowEditShow,
|
|
3344
3606
|
};
|
|
3345
3607
|
},
|
|
3608
|
+
/** @param {Object} obj VXE 单元格参数。@returns {String} 行新增权限名。 */
|
|
3346
3609
|
getRowAddAuthName(obj) {
|
|
3347
3610
|
return this.getEditTreeButtonGroupConfig(obj).rowAddAuthName;
|
|
3348
3611
|
},
|
|
3612
|
+
/** @param {Object} obj VXE 单元格参数。@returns {String} 行编辑权限名。 */
|
|
3349
3613
|
getRowEditAuthName(obj) {
|
|
3350
3614
|
return this.getEditTreeButtonGroupConfig(obj).rowEditAuthName;
|
|
3351
3615
|
},
|
|
3616
|
+
/** @param {Object} obj VXE 单元格参数。@returns {String|Function} 行新增显示脚本。 */
|
|
3352
3617
|
getRowAddShow(obj) {
|
|
3353
3618
|
return this.getEditTreeButtonGroupConfig(obj).rowAddShow;
|
|
3354
3619
|
},
|
|
3620
|
+
/** @param {Object} obj VXE 单元格参数。@returns {String|Function} 行编辑显示脚本。 */
|
|
3355
3621
|
getRowEditShow(obj) {
|
|
3356
3622
|
return this.getEditTreeButtonGroupConfig(obj).rowEditShow;
|
|
3357
3623
|
},
|
|
3624
|
+
/** @param {String|Function} script 显示条件脚本。@param {Object} obj VXE 行参数。@returns {Boolean} */
|
|
3358
3625
|
isRowButtonShow(script, obj) {
|
|
3359
3626
|
if (!script) {
|
|
3360
3627
|
return true;
|
|
@@ -3362,12 +3629,14 @@ modules = {
|
|
|
3362
3629
|
let result = this.handleCustomEvent(script, ["tableParam"], [obj]);
|
|
3363
3630
|
return result !== false;
|
|
3364
3631
|
},
|
|
3632
|
+
/** @param {Object} obj VXE 行参数。@returns {Boolean} 是否显示行新增按钮。 */
|
|
3365
3633
|
canShowRowAdd(obj) {
|
|
3366
3634
|
return (
|
|
3367
3635
|
this.hasTableRowPermission(this.getRowAddAuthName(obj)) &&
|
|
3368
3636
|
this.isRowButtonShow(this.getRowAddShow(obj), obj)
|
|
3369
3637
|
);
|
|
3370
3638
|
},
|
|
3639
|
+
/** @param {Object} obj VXE 行参数。@returns {Boolean} 是否显示行编辑按钮。 */
|
|
3371
3640
|
canShowRowEdit(obj) {
|
|
3372
3641
|
let isAddRow = !this.hasSaveRow(obj?.row);
|
|
3373
3642
|
if (isAddRow) return true;
|
|
@@ -3376,6 +3645,7 @@ modules = {
|
|
|
3376
3645
|
this.isRowButtonShow(this.getRowEditShow(obj), obj)
|
|
3377
3646
|
);
|
|
3378
3647
|
},
|
|
3648
|
+
/** @param {Object} obj VXE 行参数。保存编辑前快照并激活该行。 */
|
|
3379
3649
|
editRowEvent(obj) {
|
|
3380
3650
|
if (!this.canShowRowEdit(obj)) {
|
|
3381
3651
|
return false;
|
|
@@ -3387,9 +3657,18 @@ modules = {
|
|
|
3387
3657
|
obj.$table.editCloneRow = this.$baseLodash.cloneDeep(obj.row);
|
|
3388
3658
|
obj.$table.setActiveRow(row);
|
|
3389
3659
|
},
|
|
3660
|
+
/** @param {Object} rowData 新行数据。@param {Object} obj 目标行参数。新增可编辑同级行。 */
|
|
3390
3661
|
addSiblingEditRow(rowData, obj) {
|
|
3391
3662
|
this.addEditRow(rowData, obj, null, true);
|
|
3392
3663
|
},
|
|
3664
|
+
/**
|
|
3665
|
+
* 新增可编辑行。编辑表使用 VXE insertAt 保持内部行引用,非编辑表走 setValue。
|
|
3666
|
+
* @param {Object|null} rowData 新行初始值;null 表示使用默认空行。
|
|
3667
|
+
* @param {Object|null} obj 目标行参数;树表中为空表示新增一级节点。
|
|
3668
|
+
* @param {Boolean} toEnd 是否追加到末尾。
|
|
3669
|
+
* @param {Boolean} toSibling 是否插入到目标行之后的同级位置。
|
|
3670
|
+
* @returns {Boolean|undefined} 存在未保存行或无权限时返回 false。
|
|
3671
|
+
*/
|
|
3393
3672
|
addEditRow(rowData, obj, toEnd, toSibling) {
|
|
3394
3673
|
if (rowData == null && obj && !this.canShowRowAdd(obj)) {
|
|
3395
3674
|
return false;
|
|
@@ -3515,6 +3794,12 @@ modules = {
|
|
|
3515
3794
|
}
|
|
3516
3795
|
},
|
|
3517
3796
|
// setValue 会生成新的数据行并触发 vxe 异步重载,需等待内部行映射更新后再激活。
|
|
3797
|
+
/**
|
|
3798
|
+
* 数据源重载后按业务 id 找回 VXE 内部行并激活,避免使用失效的外部行引用。
|
|
3799
|
+
* @param {Object} $grid VXE Grid 实例。
|
|
3800
|
+
* @param {String|Number} rowId 业务行 id。
|
|
3801
|
+
* @param {Number} retry 等待 VXE 行映射完成的重试次数。
|
|
3802
|
+
*/
|
|
3518
3803
|
setActiveRowById($grid, rowId, retry = 0) {
|
|
3519
3804
|
if (!$grid || rowId == null) {
|
|
3520
3805
|
return;
|
|
@@ -3540,6 +3825,10 @@ modules = {
|
|
|
3540
3825
|
$grid.setActiveRow(realRow);
|
|
3541
3826
|
}
|
|
3542
3827
|
},
|
|
3828
|
+
/**
|
|
3829
|
+
* 删除未保存的编辑行,不调用 setValue,避免整表重载和编辑状态抖动。
|
|
3830
|
+
* @param {Object} obj VXE 行参数。
|
|
3831
|
+
*/
|
|
3543
3832
|
async removeEditRow(obj) {
|
|
3544
3833
|
let row = obj.row;
|
|
3545
3834
|
let $grid = this.getGridTable();
|
|
@@ -3555,6 +3844,7 @@ modules = {
|
|
|
3555
3844
|
this.handleWbs();
|
|
3556
3845
|
},
|
|
3557
3846
|
//editTable end
|
|
3847
|
+
/** @returns {Object} 行查询通用的创建人信息配置。 */
|
|
3558
3848
|
getHttpConfigForUser() {
|
|
3559
3849
|
let defaultOption = {
|
|
3560
3850
|
addCreateInfo: true,
|
|
@@ -3562,11 +3852,17 @@ modules = {
|
|
|
3562
3852
|
};
|
|
3563
3853
|
return defaultOption;
|
|
3564
3854
|
},
|
|
3855
|
+
/** @returns {Promise|undefined} 启用 WBS 时重算编码,否则不处理。 */
|
|
3565
3856
|
handleWbs() {
|
|
3566
3857
|
if (this.widget.options.wbsEnabled) {
|
|
3567
3858
|
return this.updateWbs();
|
|
3568
3859
|
}
|
|
3569
3860
|
},
|
|
3861
|
+
/**
|
|
3862
|
+
* 按当前树顺序重算 WBS 编码,并同步回编辑表使用的扁平表单数据。
|
|
3863
|
+
* 编辑树表必须读取 tableFullTreeData,因为 insertAt 新增的一级节点不一定进入 fullData。
|
|
3864
|
+
* @returns {Promise} VXE 数据刷新结果。
|
|
3865
|
+
*/
|
|
3570
3866
|
updateWbs() {
|
|
3571
3867
|
let that = this;
|
|
3572
3868
|
let $grid = that.getGridTable();
|
|
@@ -3605,6 +3901,10 @@ modules = {
|
|
|
3605
3901
|
}
|
|
3606
3902
|
return $grid.updateData();
|
|
3607
3903
|
},
|
|
3904
|
+
/**
|
|
3905
|
+
* 将当前节点在同级节点中上移一位,并同步扁平表单数据与 WBS。
|
|
3906
|
+
* @param {Object} obj VXE 行参数。
|
|
3907
|
+
*/
|
|
3608
3908
|
moveUpRow(obj) {
|
|
3609
3909
|
let row = obj.row;
|
|
3610
3910
|
let $grid = this.getGridTable();
|
|
@@ -3649,6 +3949,10 @@ modules = {
|
|
|
3649
3949
|
}
|
|
3650
3950
|
}
|
|
3651
3951
|
},
|
|
3952
|
+
/**
|
|
3953
|
+
* 将当前节点在同级节点中下移一位,并同步扁平表单数据与 WBS。
|
|
3954
|
+
* @param {Object} obj VXE 行参数。
|
|
3955
|
+
*/
|
|
3652
3956
|
moveDownRow(obj) {
|
|
3653
3957
|
let row = obj.row;
|
|
3654
3958
|
let $grid = this.getGridTable();
|
|
@@ -3694,6 +3998,7 @@ modules = {
|
|
|
3694
3998
|
}
|
|
3695
3999
|
},
|
|
3696
4000
|
|
|
4001
|
+
/** @param {Object} obj VXE 行参数。打开当前层级的树节点排序弹窗。 */
|
|
3697
4002
|
openSortRowDialog(obj) {
|
|
3698
4003
|
let $grid = this.getGridTable();
|
|
3699
4004
|
let parentField = $grid.treeConfig.parentField;
|
|
@@ -3711,6 +4016,7 @@ modules = {
|
|
|
3711
4016
|
this.sortParentRow = sortParentRow;
|
|
3712
4017
|
this.showTreeMoveDialog = true;
|
|
3713
4018
|
},
|
|
4019
|
+
/** @param {Array} rows 弹窗确认后的同级节点顺序。同步回表格数据。 */
|
|
3714
4020
|
confirmTreeMoveDialog(rows) {
|
|
3715
4021
|
if (this.widget.options.isEditTable) {
|
|
3716
4022
|
let reportTemplate = this.getFormRef().reportTemplate;
|
|
@@ -3751,6 +4057,11 @@ modules = {
|
|
|
3751
4057
|
}
|
|
3752
4058
|
},
|
|
3753
4059
|
// 通用行合并函数(将相同多列数据合并为一行)
|
|
4060
|
+
/**
|
|
4061
|
+
* 按配置字段计算连续相同值的纵向合并范围。
|
|
4062
|
+
* @param {Object} tableParam VXE span-method 参数。
|
|
4063
|
+
* @returns {Object|undefined} 包含 rowspan、colspan 的合并信息。
|
|
4064
|
+
*/
|
|
3754
4065
|
mergeRowMethod(tableParam) {
|
|
3755
4066
|
let { row, _rowIndex, column, visibleData } = tableParam;
|
|
3756
4067
|
let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
|
|
@@ -3775,6 +4086,11 @@ modules = {
|
|
|
3775
4086
|
// return { rowspan: 1, colspan: 1 }
|
|
3776
4087
|
}
|
|
3777
4088
|
},
|
|
4089
|
+
/**
|
|
4090
|
+
* 合并行算法的解构参数版本。
|
|
4091
|
+
* @param {Object} tableParam 包含 row、_rowIndex、column、visibleData。
|
|
4092
|
+
* @returns {Object|undefined} 合并范围。
|
|
4093
|
+
*/
|
|
3778
4094
|
mergeRowMethod2({ row, _rowIndex, column, visibleData }) {
|
|
3779
4095
|
const fields = ["key"];
|
|
3780
4096
|
const cellValue = row[column.field];
|
|
@@ -3835,9 +4151,11 @@ modules = {
|
|
|
3835
4151
|
newFieldSchema.id = fieldWidget.type + generateId()
|
|
3836
4152
|
return newFieldSchema
|
|
3837
4153
|
},*/
|
|
4154
|
+
/** 清理行组件缓存的兼容入口,当前实现保留缓存。 */
|
|
3838
4155
|
clearRowWidgets() {
|
|
3839
4156
|
// this.widgetMap = {};
|
|
3840
4157
|
},
|
|
4158
|
+
/** @param {Object} row 行数据。删除该行注册的组件引用。 */
|
|
3841
4159
|
deleteRowWidgets(row) {
|
|
3842
4160
|
this.rowWidgetList.forEach((widget) => {
|
|
3843
4161
|
let key = this.getRowRefKey(row, widget.options.name);
|
|
@@ -3847,10 +4165,15 @@ modules = {
|
|
|
3847
4165
|
/**end*/
|
|
3848
4166
|
|
|
3849
4167
|
//begin1
|
|
4168
|
+
/** 重新生成行主键列表和全部行级 schema。 */
|
|
3850
4169
|
initAllFieldSchema() {
|
|
3851
4170
|
this.initRowIdData(true);
|
|
3852
4171
|
this.initFieldSchemaData();
|
|
3853
4172
|
},
|
|
4173
|
+
/**
|
|
4174
|
+
* 根据表单数据刷新行主键列表,并为缺少主键的行生成 _X_ROW_KEY。
|
|
4175
|
+
* @param {Boolean} initFlag 初始化标记,保留给行变化事件扩展使用。
|
|
4176
|
+
*/
|
|
3854
4177
|
initRowIdData(initFlag) {
|
|
3855
4178
|
this.rowIdData.splice(0, this.rowIdData.length); //清除数组必须用splice,length=0不会响应式更新!!
|
|
3856
4179
|
let subFormModel = this.formModel[this.fieldKeyName];
|
|
@@ -3868,6 +4191,10 @@ modules = {
|
|
|
3868
4191
|
}*/
|
|
3869
4192
|
}
|
|
3870
4193
|
},
|
|
4194
|
+
/**
|
|
4195
|
+
* 为每一行创建独立字段 schema,避免组件状态在不同行之间共享。
|
|
4196
|
+
* @param {Boolean} initFlag true 时忽略旧 schema 并全部重新创建。
|
|
4197
|
+
*/
|
|
3871
4198
|
initFieldSchemaData(initFlag) {
|
|
3872
4199
|
//初始化fieldSchemaData!!!
|
|
3873
4200
|
/*if (this.widget.type !== 'sub-form') {
|
|
@@ -3910,6 +4237,7 @@ modules = {
|
|
|
3910
4237
|
}
|
|
3911
4238
|
}
|
|
3912
4239
|
},
|
|
4240
|
+
/** @returns {Array} VXE 当前完整列;实例未就绪时回退到配置列。 */
|
|
3913
4241
|
getTableFullColumns() {
|
|
3914
4242
|
let target = this.getGridTable();
|
|
3915
4243
|
if (target?.getTableColumn) {
|
|
@@ -3920,6 +4248,12 @@ modules = {
|
|
|
3920
4248
|
}
|
|
3921
4249
|
return this.vxeOption?.columns || [];
|
|
3922
4250
|
},
|
|
4251
|
+
/**
|
|
4252
|
+
* 递归提取分组表头下的叶子列。
|
|
4253
|
+
* @param {Array} columns VXE 列树。
|
|
4254
|
+
* @param {Array} result 递归累积数组。
|
|
4255
|
+
* @returns {Array} 叶子列列表。
|
|
4256
|
+
*/
|
|
3923
4257
|
collectLeafTableColumns(columns, result = []) {
|
|
3924
4258
|
if (!Array.isArray(columns)) {
|
|
3925
4259
|
return result;
|
|
@@ -3933,6 +4267,10 @@ modules = {
|
|
|
3933
4267
|
});
|
|
3934
4268
|
return result;
|
|
3935
4269
|
},
|
|
4270
|
+
/**
|
|
4271
|
+
* 根据当前有效叶子列,为单行克隆展示组件、编辑组件和组合组件 schema。
|
|
4272
|
+
* @returns {Object} 以原组件 id 为键的行级 schema 映射。
|
|
4273
|
+
*/
|
|
3936
4274
|
createRowFieldSchemaMap() {
|
|
3937
4275
|
let fullColumn = this.collectLeafTableColumns(
|
|
3938
4276
|
this.getTableFullColumns(),
|
|
@@ -3964,6 +4302,7 @@ modules = {
|
|
|
3964
4302
|
});
|
|
3965
4303
|
return fieldSchemaMap2;
|
|
3966
4304
|
},
|
|
4305
|
+
/** @param {Number} rowIndex 可选插入位置。向旧版 fieldSchemaData 增加一行 schema。 */
|
|
3967
4306
|
addToFieldSchemaData(rowIndex) {
|
|
3968
4307
|
let fieldSchemas = [];
|
|
3969
4308
|
this.widget.widgetList.forEach((swItem) => {
|
|
@@ -3977,16 +4316,19 @@ modules = {
|
|
|
3977
4316
|
}
|
|
3978
4317
|
},
|
|
3979
4318
|
|
|
4319
|
+
/** @param {Number} rowIndex 行索引。从旧版 fieldSchemaData 删除 schema。 */
|
|
3980
4320
|
deleteFromFieldSchemaData(rowIndex) {
|
|
3981
4321
|
this.fieldSchemaData.splice(rowIndex, 1);
|
|
3982
4322
|
},
|
|
3983
4323
|
|
|
4324
|
+
/** @param {Object} fieldWidget 组件模板。@returns {Object} 带新 id 的深克隆 schema。 */
|
|
3984
4325
|
cloneFieldSchema(fieldWidget) {
|
|
3985
4326
|
let newFieldSchema = deepClone(fieldWidget);
|
|
3986
4327
|
newFieldSchema.id = fieldWidget.type + generateId();
|
|
3987
4328
|
return newFieldSchema;
|
|
3988
4329
|
},
|
|
3989
4330
|
//end1
|
|
4331
|
+
/** @param {Array} rows 导出数据。为无行主键的数据创建临时 schema。 */
|
|
3990
4332
|
initExportFieldSchemaData(rows) {
|
|
3991
4333
|
if (!rows) return;
|
|
3992
4334
|
//初始化fieldSchemaData!!!
|
|
@@ -3998,6 +4340,7 @@ modules = {
|
|
|
3998
4340
|
fieldSchemaMap[row._X_ROW_KEY] = fieldSchemaMap2;
|
|
3999
4341
|
}
|
|
4000
4342
|
},
|
|
4343
|
+
/** 注册 setFormData 等组件内部事件。 */
|
|
4001
4344
|
initEventHandler() {
|
|
4002
4345
|
if (this.designState) return;
|
|
4003
4346
|
this.$on("setFormData", (o) => {
|
|
@@ -4005,11 +4348,17 @@ modules = {
|
|
|
4005
4348
|
this.setValue(rows);
|
|
4006
4349
|
});
|
|
4007
4350
|
},
|
|
4351
|
+
/** @param {Object} widget 组件 schema。@param {Array<String>} ignoreFields 忽略字段。@returns {Boolean} 是否处理禁用状态。 */
|
|
4008
4352
|
isDisHandleWidget(widget, ignoreFields) {
|
|
4009
4353
|
let flag1 = widget.options.hasOwnProperty("disabled");
|
|
4010
4354
|
let flag2 = !ignoreFields || !ignoreFields.includes(widget.options.name);
|
|
4011
4355
|
return flag1 && flag2;
|
|
4012
4356
|
},
|
|
4357
|
+
/**
|
|
4358
|
+
* 批量设置表格内按钮、查询字段及单元格组件的禁用状态。
|
|
4359
|
+
* @param {Boolean} disabled 是否禁用。
|
|
4360
|
+
* @param {Array<String>} ignoreFields 不参与切换的字段名。
|
|
4361
|
+
*/
|
|
4013
4362
|
setGridDisabled(disabled, ignoreFields) {
|
|
4014
4363
|
if (!!this.widget.widgetList) {
|
|
4015
4364
|
traverseAllWidgetsNew(this.widget.widgetList, (widget) => {
|
|
@@ -4068,6 +4417,12 @@ modules = {
|
|
|
4068
4417
|
});
|
|
4069
4418
|
}
|
|
4070
4419
|
},
|
|
4420
|
+
/**
|
|
4421
|
+
* 设置指定数据行内组件的禁用状态。
|
|
4422
|
+
* @param {Boolean} disabled 是否禁用。
|
|
4423
|
+
* @param {Number} rowIndex 表单扁平数据中的行索引。
|
|
4424
|
+
* @param {Array<String>} ignoreFields 不参与切换的字段名。
|
|
4425
|
+
*/
|
|
4071
4426
|
setRowDisabled(disabled, rowIndex, ignoreFields) {
|
|
4072
4427
|
let gsfFWList = [];
|
|
4073
4428
|
let fieldListFn = (fw) => {
|
|
@@ -4105,13 +4460,16 @@ modules = {
|
|
|
4105
4460
|
});
|
|
4106
4461
|
},
|
|
4107
4462
|
//xk begin
|
|
4463
|
+
/** 禁用表格内全部可处理组件。 */
|
|
4108
4464
|
disableGridForm() {
|
|
4109
4465
|
this.setGridDisabled(true);
|
|
4110
4466
|
},
|
|
4467
|
+
/** 启用表格内全部可处理组件。 */
|
|
4111
4468
|
enableGridForm() {
|
|
4112
4469
|
this.setGridDisabled(false);
|
|
4113
4470
|
},
|
|
4114
4471
|
//xk end
|
|
4472
|
+
/** @param {Array} rows 行数据。为缺失的列字段补入空值。 */
|
|
4115
4473
|
handleNullValue(rows) {
|
|
4116
4474
|
let newData = this.createNewTableData(true, false);
|
|
4117
4475
|
let keys = Object.keys(newData);
|