cloud-web-corejs 1.1.0-dev.45 → 1.1.0-dev.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/src/app-bootstrap.js +6 -5
  3. package/src/components/Qrcode/fileParse.vue +11 -0
  4. package/src/components/VabUpload/index.js +11 -4
  5. package/src/components/VabUpload/mixins/fileLibraryDialog.js +2 -0
  6. package/src/components/VabUpload/mixins.js +72 -40
  7. package/src/components/VabUpload/partUploadConfig.js +95 -0
  8. package/src/components/VabUpload/privateProfileDialogMixins.js +2 -0
  9. package/src/components/baseInputExport/mixins.js +1 -0
  10. package/src/components/fileLibrary/mixins/indexMixins.js +2 -0
  11. package/src/components/jdPrint/mixins.js +2 -0
  12. package/src/components/obsUpload/index.js +4 -1
  13. package/src/components/obsUpload/mixins.js +45 -15
  14. package/src/components/onlineTalk/mixins.js +11 -0
  15. package/src/components/table/index.js +74 -78
  16. package/src/components/xform/docs/2026-09 /346/265/217/350/247/210/345/231/250/345/264/251/346/272/203/346/262/273/347/220/206P0/344/273/243/347/240/201/350/257/204/345/256/241.md" +255 -0
  17. package/src/components/xform/docs/2026-09 /346/265/217/350/247/210/345/231/250/345/264/251/346/272/203/346/262/273/347/220/206P0/346/265/213/350/257/225/351/252/214/350/257/201/345/256/236/346/226/275/346/226/207/346/241/243.md" +595 -0
  18. package/src/components/xform/docs//346/265/217/350/247/210/345/231/250/345/264/251/346/272/203/346/262/273/347/220/206/344/270/216/344/277/256/345/244/215/350/220/275/345/234/260/346/226/271/346/241/210.md +324 -0
  19. package/src/components/xform/form-designer/form-widget/container-widget/data-table-widget.vue +1 -1
  20. package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +1 -0
  21. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +2 -2
  22. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload2-widget.vue +24 -0
  23. package/src/components/xform/form-render/container-item/data-table-mixin.js +420 -47
  24. package/src/components/xform/form-render/container-item/list-h5-item.vue +109 -38
  25. package/src/components/xform/styles/h5-designer.scss +13 -13
  26. package/src/components/xform/styles/h5-runtime.scss +520 -0
  27. package/src/components/xform/styles/h5.scss +5 -2
  28. package/src/components/xform/utils/util.js +9 -0
  29. package/src/layout/components/TagsView/index.vue +11 -10
  30. package/src/layout/components/TagsView/style.scss +92 -0
  31. package/src/styles/btn.scss +214 -3
  32. package/src/styles/dialog.scss +1710 -0
  33. package/src/styles/element-ui.scss +957 -36
  34. package/src/styles/index.scss +45 -0
  35. package/src/styles/layout-skins.scss +840 -0
  36. package/src/styles/mixin.scss +8 -0
  37. package/src/styles/page-shell.scss +622 -0
  38. package/src/styles/sidebar.scss +15 -0
  39. package/src/styles/utilities.scss +234 -118
  40. package/src/styles/variables.scss +28 -0
  41. package/src/views/user/home/wjl/content.vue +5 -0
  42. package/src/views/user/intf_permission/edit.vue +230 -0
  43. package/src/views/user/intf_permission/list.vue +196 -0
@@ -1,4 +1,5 @@
1
1
  import Vue from "vue";
2
+ import axios from "axios";
2
3
  import emitter from "../../../../components/xform/utils/emitter";
3
4
  import i18n from "../../../../components/xform/utils/i18n";
4
5
  import refMixin from "../../../../components/xform/form-render/refMixin";
@@ -12,6 +13,7 @@ import {
12
13
  assembleAxiosConfig,
13
14
  getReportGlobalMap,
14
15
  generateId,
16
+ createXRowKey,
15
17
  deepClone,
16
18
  loopHandleWidget,
17
19
  columnFormatMap,
@@ -96,6 +98,9 @@ const MAX_SCHEMA_INIT_RETRY = 50;
96
98
  */
97
99
  const LAZY_ROW_SCHEMA_THRESHOLD = 1000;
98
100
 
101
+ /** 自动保存最多允许同时排队的行数;同一行的连续修改会合并。 */
102
+ const MAX_EDIT_AUTO_SAVE_PENDING_ROWS = 20;
103
+
99
104
  let modules = {};
100
105
  const baseRefUtil = {
101
106
  emitter,
@@ -211,7 +216,15 @@ modules = {
211
216
  treeSingleSavePending: false,
212
217
  treeSingleSaveReconcileTask: null,
213
218
  editAutoSaveTimers: {},
214
- editAutoSaveQueue: null,
219
+ editAutoSaveGeneration: 0,
220
+ editAutoSavePendingRows: Object.create(null),
221
+ editAutoSaveOrder: [],
222
+ editAutoSaveWorkerRunning: false,
223
+ editAutoSaveCancelSource: null,
224
+ editAutoSaveActiveRowKey: null,
225
+ tableQuerySeq: 0,
226
+ tableQueryCancelSource: null,
227
+ tableDestroyed: false,
215
228
  // 列/网格未就绪时 setValue 只缓存数据,置此标志延后行 schema 构建
216
229
  pendingSchemaInit: false,
217
230
  };
@@ -314,13 +327,56 @@ modules = {
314
327
  });
315
328
  },
316
329
  beforeDestroy: function () {
330
+ this.tableDestroyed = true;
331
+ this.cancelActiveTableQuery("table destroyed");
332
+ this.editAutoSaveGeneration += 1;
333
+ if (this.editAutoSaveCancelSource) {
334
+ this.editAutoSaveCancelSource.cancel("table destroyed");
335
+ this.editAutoSaveCancelSource = null;
336
+ }
337
+ this.editAutoSaveActiveRowKey = null;
317
338
  Object.values(this.editAutoSaveTimers || {}).forEach((timer) => {
318
339
  clearTimeout(timer);
319
340
  });
320
341
  this.editAutoSaveTimers = {};
342
+ this.editAutoSavePendingRows = Object.create(null);
343
+ this.editAutoSaveOrder = [];
344
+ this.fieldSchemaMap = {};
345
+ this.rowIdData.splice(0, this.rowIdData.length);
321
346
  this.unregisterFromRefList();
322
347
  },
323
348
  methods: {
349
+ /** @param {String} reason 取消原因。取消当前普通查询并使旧响应失效。 */
350
+ cancelActiveTableQuery(reason = "query cancelled") {
351
+ this.tableQuerySeq += 1;
352
+ if (this.tableQueryCancelSource) {
353
+ this.tableQueryCancelSource.cancel(reason);
354
+ this.tableQueryCancelSource = null;
355
+ }
356
+ },
357
+ /** @returns {Object} 本次普通查询上下文;导出查询不走此通道。 */
358
+ startTableQuery() {
359
+ this.cancelActiveTableQuery("superseded by a newer query");
360
+ const context = {
361
+ seq: this.tableQuerySeq,
362
+ source: axios.CancelToken.source(),
363
+ };
364
+ this.tableQueryCancelSource = context.source;
365
+ return context;
366
+ },
367
+ /** @param {Object} context 查询上下文。@returns {Boolean} 是否仍是当前有效查询。 */
368
+ isCurrentTableQuery(context) {
369
+ return !!context
370
+ && !this.tableDestroyed
371
+ && context.seq === this.tableQuerySeq
372
+ && context.source === this.tableQueryCancelSource;
373
+ },
374
+ /** @param {Object} context 查询上下文。释放已完成查询的取消句柄。 */
375
+ finishTableQuery(context) {
376
+ if (context && context.source === this.tableQueryCancelSource) {
377
+ this.tableQueryCancelSource = null;
378
+ }
379
+ },
324
380
  /*
325
381
  * 数据约定:
326
382
  * 1. formModel[fieldKeyName] 是提交与校验使用的表单数据;fieldModel 是 vxe-grid 的绑定数据。
@@ -680,6 +736,102 @@ modules = {
680
736
  let key = name + "_" + keyVal;
681
737
  return key;
682
738
  },
739
+ /**
740
+ * 查询整体替换后清理仍挂在表单 refList 中的旧行引用。
741
+ * 正常情况下字段组件会在 beforeDestroy 自行注销;这里仅处理异常残留。
742
+ * @param {Array<String>} previousRowKeys 查询前的行键。
743
+ * @param {Array<Object>} currentRows 查询后的行数据。
744
+ */
745
+ pruneStaleRowRefs(previousRowKeys, currentRows) {
746
+ const validKeys = new Set(
747
+ (currentRows || []).map((row) => row?._X_ROW_KEY).filter(Boolean)
748
+ );
749
+ const staleKeys = (previousRowKeys || []).filter(
750
+ (rowKey) => rowKey && !validKeys.has(rowKey)
751
+ );
752
+ if (!staleKeys.length) return;
753
+ const staleKeySet = new Set(staleKeys);
754
+
755
+ const names = new Set(
756
+ (this.rowWidgetList || [])
757
+ .map((widget) => widget?.options?.name)
758
+ .filter(Boolean)
759
+ );
760
+
761
+ const cleanupStaleRefs = () => {
762
+ if (this.tableDestroyed || !this.refList || !names.size) return;
763
+ let removedCount = 0;
764
+ Object.keys(this.refList).forEach((refKey) => {
765
+ const target = this.refList[refKey];
766
+ const targetRowKey = target?.tableParam?.row?._X_ROW_KEY;
767
+ if (!targetRowKey || !staleKeySet.has(targetRowKey)) return;
768
+ const targetWidget = target.field || target.widget;
769
+ const targetName = targetWidget?.options?.name;
770
+ if (!targetName || !names.has(targetName)) return;
771
+ delete this.refList[refKey];
772
+ removedCount += 1;
773
+ });
774
+ if (removedCount && process.env.NODE_ENV !== "production") {
775
+ console.warn(
776
+ `[data-table] 已清理 ${removedCount} 个查询后残留的行组件引用`
777
+ );
778
+ }
779
+ };
780
+ const compactFieldSchemaMap = () => {
781
+ if (this.tableDestroyed) return;
782
+ const liveKeys = new Set(this.rowIdData || []);
783
+ const currentMap = this.fieldSchemaMap || {};
784
+ const nextMap = {};
785
+ let changed = false;
786
+ Object.keys(currentMap).forEach((rowKey) => {
787
+ if (liveKeys.has(rowKey)) {
788
+ nextMap[rowKey] = currentMap[rowKey];
789
+ } else {
790
+ changed = true;
791
+ }
792
+ });
793
+ // 一次替换只触发一次响应更新,避免逐行 $delete 导致多轮重渲染。
794
+ if (changed) this.fieldSchemaMap = nextMap;
795
+ };
796
+ this.$nextTick(() => {
797
+ cleanupStaleRefs();
798
+ // 查询 Promise resolve 后 VXE 才会提交新数据。旧行在这一小段卸载窗口内
799
+ // 仍可能触发 render,并通过 getRowFieldSchema 把刚清空的 schema 懒建回来。
800
+ // 下一宏任务按实际存活行键整体压缩一次;不再重复扫描 ref。
801
+ setTimeout(compactFieldSchemaMap, 0);
802
+ });
803
+ },
804
+ /** @param {String} rowKey 行键。释放该行的 schema 与自动保存任务。 */
805
+ releaseRowRuntime(rowKey) {
806
+ if (!rowKey) return;
807
+ if (this.fieldSchemaMap[rowKey]) {
808
+ this.$delete(this.fieldSchemaMap, rowKey);
809
+ }
810
+ if (this.editAutoSaveTimers[rowKey]) {
811
+ clearTimeout(this.editAutoSaveTimers[rowKey]);
812
+ delete this.editAutoSaveTimers[rowKey];
813
+ }
814
+ const pendingEntry = this.editAutoSavePendingRows[rowKey];
815
+ if (pendingEntry) {
816
+ pendingEntry.cancelled = true;
817
+ delete this.editAutoSavePendingRows[rowKey];
818
+ }
819
+ this.editAutoSaveOrder = this.editAutoSaveOrder.filter(
820
+ (pendingRowKey) => pendingRowKey !== rowKey
821
+ );
822
+ if (
823
+ this.editAutoSaveActiveRowKey === rowKey
824
+ && this.editAutoSaveCancelSource
825
+ ) {
826
+ this.editAutoSaveCancelSource.cancel("table row removed");
827
+ this.editAutoSaveCancelSource = null;
828
+ }
829
+ },
830
+ /** @param {Iterable<String>} rowKeys 行键集合。批量释放行运行时状态。 */
831
+ releaseRowsRuntime(rowKeys) {
832
+ if (!rowKeys) return;
833
+ Array.from(rowKeys).forEach((rowKey) => this.releaseRowRuntime(rowKey));
834
+ },
683
835
  /** @param {Number} index 扁平数据行索引。@param {String} name 组件名。@returns {Object} 行组件 schema。 */
684
836
  getWidgetByTableRow(index, name) {
685
837
  // let target = this.getWidgetRefByTableRow(index, name)
@@ -794,7 +946,7 @@ modules = {
794
946
  rows = this.normalizeTableRows(rows, false);
795
947
  // this.handleNullValue(rows);
796
948
  rows.forEach((row) => {
797
- row._X_ROW_KEY = "row_" + generateId();
949
+ row._X_ROW_KEY = createXRowKey();
798
950
  });
799
951
  this.registerTreeKeys(rows);
800
952
  this.formModel[this.fieldKeyName] = rows;
@@ -894,7 +1046,7 @@ modules = {
894
1046
  }
895
1047
  });
896
1048
  if (!nextRow._X_ROW_KEY) {
897
- nextRow._X_ROW_KEY = "row_" + generateId();
1049
+ nextRow._X_ROW_KEY = createXRowKey();
898
1050
  }
899
1051
  return nextRow;
900
1052
  });
@@ -1162,11 +1314,19 @@ modules = {
1162
1314
  /**
1163
1315
  * @param {Object} $table VXE Table 实例。
1164
1316
  * @param {Array<Object>} rows 本次粘贴实际修改的行。
1165
- * @description 按顺序复用单行保存,避免并发触发行保存锁。
1317
+ * @description 粘贴保存也进入统一 worker,和失焦/变更保存共享串行与合并规则。
1166
1318
  */
1167
1319
  async autoSaveClipboardRows($table, rows) {
1320
+ const generation = this.editAutoSaveGeneration;
1168
1321
  const savedKeys = new Set();
1322
+ let allQueued = true;
1169
1323
  for (const sourceRow of rows || []) {
1324
+ if (
1325
+ this.tableDestroyed
1326
+ || generation !== this.editAutoSaveGeneration
1327
+ ) {
1328
+ return false;
1329
+ }
1170
1330
  const rowKey = sourceRow?._X_ROW_KEY;
1171
1331
  if (rowKey && savedKeys.has(rowKey)) continue;
1172
1332
  if (rowKey) savedKeys.add(rowKey);
@@ -1174,11 +1334,11 @@ modules = {
1174
1334
  const row = rowKey
1175
1335
  ? formRows.find((item) => item?._X_ROW_KEY === rowKey) || sourceRow
1176
1336
  : sourceRow;
1177
- await this.saveEditRow(
1178
- { row, $table },
1179
- { skipConfirm: true }
1180
- );
1337
+ if (!this.enqueueEditRowAutoSave({ row, $table })) {
1338
+ allQueued = false;
1339
+ }
1181
1340
  }
1341
+ return allQueued;
1182
1342
  },
1183
1343
  /** @returns {Boolean} 是否开启编辑表格自动保存,兼容早期粘贴专用配置名。 */
1184
1344
  isTableAutoSaveEnabled() {
@@ -1227,27 +1387,145 @@ modules = {
1227
1387
  clearTimeout(this.editAutoSaveTimers[rowKey]);
1228
1388
  this.editAutoSaveTimers[rowKey] = setTimeout(() => {
1229
1389
  delete this.editAutoSaveTimers[rowKey];
1230
- const runSave = async () => {
1231
- const rows = this.formModel[this.fieldKeyName] || [];
1232
- const currentRow = obj.row._X_ROW_KEY
1233
- ? rows.find((row) => row?._X_ROW_KEY === obj.row._X_ROW_KEY)
1234
- || obj.row
1235
- : obj.row;
1236
- return this.saveEditRow(
1237
- { ...obj, row: currentRow },
1238
- { skipConfirm: true }
1239
- );
1240
- };
1241
- this.editAutoSaveQueue = Promise.resolve(this.editAutoSaveQueue)
1242
- .catch(() => false)
1243
- .then(runSave)
1244
- .catch((error) => {
1245
- this.$message.error(error?.message || "失焦自动保存失败。");
1246
- return false;
1247
- });
1390
+ this.enqueueEditRowAutoSave(obj);
1248
1391
  }, autoSaveDelay);
1249
1392
  return true;
1250
1393
  },
1394
+ /**
1395
+ * @param {Object} obj VXE 单元格参数。
1396
+ * @returns {Boolean} 是否进入统一自动保存 worker。
1397
+ */
1398
+ enqueueEditRowAutoSave(obj) {
1399
+ if (this.tableDestroyed || !obj?.row || !obj?.$table) return false;
1400
+ const rowKey = obj.row._X_ROW_KEY || "current";
1401
+ let pendingEntry = this.editAutoSavePendingRows[rowKey];
1402
+ if (pendingEntry) {
1403
+ pendingEntry.obj = obj;
1404
+ pendingEntry.version += 1;
1405
+ return true;
1406
+ }
1407
+ if (
1408
+ Object.keys(this.editAutoSavePendingRows).length
1409
+ >= MAX_EDIT_AUTO_SAVE_PENDING_ROWS
1410
+ ) {
1411
+ this.$message.warning("自动保存任务较多,请稍后再编辑。");
1412
+ return false;
1413
+ }
1414
+ pendingEntry = {
1415
+ obj,
1416
+ version: 0,
1417
+ cancelled: false,
1418
+ };
1419
+ this.editAutoSavePendingRows[rowKey] = pendingEntry;
1420
+ this.editAutoSaveOrder.push(rowKey);
1421
+ this.runEditAutoSaveWorker();
1422
+ return true;
1423
+ },
1424
+ /** @returns {Promise<Boolean>} 串行消费自动保存等待行。 */
1425
+ async runEditAutoSaveWorker() {
1426
+ if (this.editAutoSaveWorkerRunning || this.tableDestroyed) return false;
1427
+ this.editAutoSaveWorkerRunning = true;
1428
+ const generation = this.editAutoSaveGeneration;
1429
+ try {
1430
+ while (
1431
+ !this.tableDestroyed
1432
+ && generation === this.editAutoSaveGeneration
1433
+ && this.editAutoSaveOrder.length
1434
+ ) {
1435
+ const rowKey = this.editAutoSaveOrder.shift();
1436
+ const pendingEntry = this.editAutoSavePendingRows[rowKey];
1437
+ if (!pendingEntry) continue;
1438
+ try {
1439
+ await this.runEditAutoSaveEntry(
1440
+ rowKey,
1441
+ pendingEntry,
1442
+ generation
1443
+ );
1444
+ } catch (error) {
1445
+ if (
1446
+ !axios.isCancel(error)
1447
+ && !this.tableDestroyed
1448
+ && generation === this.editAutoSaveGeneration
1449
+ ) {
1450
+ this.$message.error(error?.message || "自动保存失败。");
1451
+ }
1452
+ } finally {
1453
+ if (this.editAutoSavePendingRows[rowKey] === pendingEntry) {
1454
+ delete this.editAutoSavePendingRows[rowKey];
1455
+ }
1456
+ }
1457
+ }
1458
+ return true;
1459
+ } finally {
1460
+ this.editAutoSaveWorkerRunning = false;
1461
+ if (
1462
+ !this.tableDestroyed
1463
+ && generation === this.editAutoSaveGeneration
1464
+ && this.editAutoSaveOrder.length
1465
+ ) {
1466
+ this.$nextTick(() => this.runEditAutoSaveWorker());
1467
+ }
1468
+ }
1469
+ },
1470
+ /**
1471
+ * @param {String} rowKey 行键。
1472
+ * @param {Object} pendingEntry 当前行合并项。
1473
+ * @param {Number} generation worker 代次。
1474
+ * @returns {Promise<Boolean>} 是否保存完当前行的最新版本。
1475
+ */
1476
+ async runEditAutoSaveEntry(rowKey, pendingEntry, generation) {
1477
+ let savedVersion = -1;
1478
+ while (
1479
+ !this.tableDestroyed
1480
+ && !pendingEntry.cancelled
1481
+ && generation === this.editAutoSaveGeneration
1482
+ && savedVersion !== pendingEntry.version
1483
+ ) {
1484
+ while (
1485
+ this.treeSingleSavePending
1486
+ && !this.tableDestroyed
1487
+ && !pendingEntry.cancelled
1488
+ && generation === this.editAutoSaveGeneration
1489
+ ) {
1490
+ await new Promise((resolve) => setTimeout(resolve, 100));
1491
+ }
1492
+ if (
1493
+ this.tableDestroyed
1494
+ || pendingEntry.cancelled
1495
+ || generation !== this.editAutoSaveGeneration
1496
+ ) {
1497
+ return false;
1498
+ }
1499
+ const targetVersion = pendingEntry.version;
1500
+ const latestObj = pendingEntry.obj;
1501
+ const rows = this.formModel[this.fieldKeyName] || [];
1502
+ const currentRow = latestObj.row._X_ROW_KEY
1503
+ ? rows.find(
1504
+ (row) => row?._X_ROW_KEY === latestObj.row._X_ROW_KEY
1505
+ ) || latestObj.row
1506
+ : latestObj.row;
1507
+ const cancelSource = axios.CancelToken.source();
1508
+ this.editAutoSaveActiveRowKey = rowKey;
1509
+ this.editAutoSaveCancelSource = cancelSource;
1510
+ let saveResult;
1511
+ try {
1512
+ saveResult = await this.saveEditRow(
1513
+ { ...latestObj, row: currentRow },
1514
+ { skipConfirm: true, cancelToken: cancelSource.token }
1515
+ );
1516
+ } finally {
1517
+ if (this.editAutoSaveCancelSource === cancelSource) {
1518
+ this.editAutoSaveCancelSource = null;
1519
+ }
1520
+ if (this.editAutoSaveActiveRowKey === rowKey) {
1521
+ this.editAutoSaveActiveRowKey = null;
1522
+ }
1523
+ }
1524
+ if (saveResult !== true) return false;
1525
+ savedVersion = targetVersion;
1526
+ }
1527
+ return true;
1528
+ },
1251
1529
  /**
1252
1530
  * @param {Object} $table VXE 表实例。
1253
1531
  * @param {Array<String>} insertedRowKeys 本次粘贴自动补出的稳定行键。
@@ -1336,7 +1614,7 @@ modules = {
1336
1614
  const rows = insertRows.map(() => {
1337
1615
  const row = {
1338
1616
  ...this.createNewTableData(true),
1339
- _X_ROW_KEY: "row_" + generateId(),
1617
+ _X_ROW_KEY: createXRowKey(),
1340
1618
  };
1341
1619
  if (treeContext) {
1342
1620
  row[treeContext.identityConfig.physicalIdField] = null;
@@ -3314,6 +3592,18 @@ modules = {
3314
3592
  let reqPath = typeof path === "function" ? path() : path;
3315
3593
  let accessReturnType =
3316
3594
  this.widget.options.accessReturnType || "2";
3595
+ const isExportQuery = !!customParam?.export;
3596
+ const queryContext
3597
+ = isExportQuery ? null : this.startTableQuery();
3598
+ if (queryContext) {
3599
+ customParam = {
3600
+ ...(customParam || {}),
3601
+ config: {
3602
+ ...(customParam?.config || {}),
3603
+ cancelToken: queryContext.source.token,
3604
+ },
3605
+ };
3606
+ }
3317
3607
 
3318
3608
  return new Promise((resolve, reject) => {
3319
3609
  if (scriptCode) {
@@ -3321,8 +3611,17 @@ modules = {
3321
3611
  let reqData = buildReqData();
3322
3612
  // let f = new Function("dataId", "formCode", "param", "done", accessScript);
3323
3613
  let done = (res) => {
3614
+ if (
3615
+ queryContext
3616
+ && !this.isCurrentTableQuery(queryContext)
3617
+ ) {
3618
+ reject(new axios.Cancel("stale table query response"));
3619
+ return;
3620
+ }
3324
3621
  // this.clearRowWidgets();
3325
3622
 
3623
+ const previousRowKeys = this.rowIdData.slice();
3624
+
3326
3625
  let items = this.handleTreeData(
3327
3626
  res.objx?.records || res.objx || []
3328
3627
  );
@@ -3347,8 +3646,10 @@ modules = {
3347
3646
  } else {
3348
3647
  res.objx = rows;
3349
3648
  }
3649
+ this.pruneStaleRowRefs(previousRowKeys, rows);
3350
3650
  }
3351
3651
 
3652
+ this.finishTableQuery(queryContext);
3352
3653
  resolve(res);
3353
3654
  if (that.shouldEmitQueryLoaded(res, customParam)) {
3354
3655
  if (that.widget.options.isTreeTable) {
@@ -3376,6 +3677,12 @@ modules = {
3376
3677
  if (expandAll && expandRows.length) {
3377
3678
  that.$nextTick(() => {
3378
3679
  setTimeout(function () {
3680
+ if (
3681
+ that.tableDestroyed ||
3682
+ queryContext?.seq !== that.tableQuerySeq
3683
+ ) {
3684
+ return;
3685
+ }
3379
3686
  $grid.treeConfig.lazy = false;
3380
3687
  $grid.setTreeExpand(expandRows, true);
3381
3688
  expandRows.forEach((lineData) => {
@@ -3409,6 +3716,12 @@ modules = {
3409
3716
  if (row[hasChild]) {
3410
3717
  that.$nextTick(() => {
3411
3718
  setTimeout(function () {
3719
+ if (
3720
+ that.tableDestroyed ||
3721
+ queryContext?.seq !== that.tableQuerySeq
3722
+ ) {
3723
+ return;
3724
+ }
3412
3725
  $grid.setTreeExpand(row, true);
3413
3726
  }, 0);
3414
3727
  });
@@ -3416,13 +3729,26 @@ modules = {
3416
3729
  }
3417
3730
  }
3418
3731
  }
3419
- that.emitTableDataLoaded(rows, tableOption);
3732
+ that.emitTableDataLoaded(
3733
+ rows,
3734
+ tableOption,
3735
+ queryContext?.seq
3736
+ );
3420
3737
  }
3421
3738
  };
3422
- this.loadDefaultQueryList(reqData, done, customParam);
3739
+ const requestTask = this.loadDefaultQueryList(
3740
+ reqData,
3741
+ done,
3742
+ customParam
3743
+ );
3744
+ Promise.resolve(requestTask).catch((error) => {
3745
+ this.finishTableQuery(queryContext);
3746
+ reject(error);
3747
+ });
3423
3748
  };
3424
3749
  this.runAfterTableFormReady($grid, toDo);
3425
3750
  } else {
3751
+ this.finishTableQuery(queryContext);
3426
3752
  resolve();
3427
3753
  }
3428
3754
  });
@@ -3748,6 +4074,7 @@ modules = {
3748
4074
  * @param {Object} option 本次查询的覆盖配置。
3749
4075
  */
3750
4076
  loadDefaultViewList(option) {
4077
+ const queryContext = this.startTableQuery();
3751
4078
  let dataId = this.formDataId;
3752
4079
  let reportTemplate = this.getFormRef().reportTemplate;
3753
4080
  let formCode = reportTemplate.formCode;
@@ -3762,9 +4089,10 @@ modules = {
3762
4089
  otherParam.thirdtabm = thirdtabm;
3763
4090
  }
3764
4091
  let scriptCode = this.getScriptCode();
3765
- return this.formHttp({
4092
+ const requestTask = this.formHttp({
3766
4093
  /*url: "/" + reportTemplate.serviceName + "/form_ins/getList",*/
3767
4094
  scriptCode: scriptCode,
4095
+ cancelToken: queryContext.source.token,
3768
4096
  data: {
3769
4097
  formCode: formCode,
3770
4098
  formVersion: reportTemplate.formVersion,
@@ -3776,6 +4104,7 @@ modules = {
3776
4104
  },
3777
4105
  },
3778
4106
  callback: (res) => {
4107
+ if (!this.isCurrentTableQuery(queryContext)) return;
3779
4108
  let $grid = this.getGridTable();
3780
4109
  // let rows = res.objx ? res.objx.records || res.objx || [] : [];
3781
4110
 
@@ -3790,7 +4119,10 @@ modules = {
3790
4119
  // that.handleNullValue(rows);
3791
4120
  rows = this.normalizeTableRows(rows, false);
3792
4121
  this.initValue(rows);
4122
+ const querySeq = queryContext.seq;
4123
+ this.finishTableQuery(queryContext);
3793
4124
  this.$nextTick(() => {
4125
+ if (this.tableDestroyed || querySeq !== this.tableQuerySeq) return;
3794
4126
  /*if (this.widget.options.isTreeTable) {
3795
4127
  let $grid = this.getGridTable();
3796
4128
  $grid.treeConfig.lazy = false;
@@ -3806,6 +4138,10 @@ modules = {
3806
4138
  });
3807
4139
  },
3808
4140
  });
4141
+ return Promise.resolve(requestTask).catch((error) => {
4142
+ this.finishTableQuery(queryContext);
4143
+ throw error;
4144
+ });
3809
4145
  },
3810
4146
  /** @returns {Object} 当前表格脚本访问参数。 */
3811
4147
  getAccessParam() {
@@ -3856,10 +4192,17 @@ modules = {
3856
4192
  * 是否该派发由 shouldEmitQueryLoaded 判定,这里只负责发。
3857
4193
  * @param {Array} rows 本次加载的行。
3858
4194
  * @param {Object} tableOption 表格配置(callback 挂在它上面)。
4195
+ * @param {Number} querySeq 普通查询代次;延迟回调执行前再次核验。
3859
4196
  */
3860
- emitTableDataLoaded(rows, tableOption) {
4197
+ emitTableDataLoaded(rows, tableOption, querySeq) {
3861
4198
  this.$nextTick(() => {
3862
4199
  setTimeout(() => {
4200
+ if (
4201
+ this.tableDestroyed
4202
+ || (querySeq != null && querySeq !== this.tableQuerySeq)
4203
+ ) {
4204
+ return;
4205
+ }
3863
4206
  let dataTableConfig = this.dataTableConfig || {};
3864
4207
  dataTableConfig.callback && dataTableConfig.callback(rows);
3865
4208
  tableOption && tableOption.callback && tableOption.callback(rows);
@@ -3991,7 +4334,11 @@ modules = {
3991
4334
 
3992
4335
  let scriptCode = this.getScriptCode();
3993
4336
  if (scriptCode) {
3994
- this.loadDefaultViewList();
4337
+ this.loadDefaultViewList().catch((error) => {
4338
+ if (!axios.isCancel(error) && !this.tableDestroyed) {
4339
+ console.error("[data-table] default view query failed", error);
4340
+ }
4341
+ });
3995
4342
  }
3996
4343
  },
3997
4344
  /** @param {Object} item 参数配置。@param {*} dataId 主数据 id。@param {Object} billData 单据数据。@returns {Object} */
@@ -4153,7 +4500,7 @@ modules = {
4153
4500
  if (!this.canDeleteTableRow({ row, rowIndex })) {
4154
4501
  return false;
4155
4502
  }
4156
- delete this.fieldSchemaMap[row._X_ROW_KEY];
4503
+ this.releaseRowRuntime(row._X_ROW_KEY);
4157
4504
  let $grid = this.getGridTable();
4158
4505
  $grid.remove(row);
4159
4506
  let tableData = $grid.getTableData();
@@ -4161,6 +4508,7 @@ modules = {
4161
4508
  let fullData = !isEditTable ? tableData.fullData : tableData.tableData;
4162
4509
  this.formModel[this.fieldKeyName] = fullData;
4163
4510
  this.fieldModel = fullData;
4511
+ this.initRowIdData();
4164
4512
  this.$nextTick(() => {
4165
4513
  this.handleWbs();
4166
4514
  });
@@ -4956,9 +5304,10 @@ modules = {
4956
5304
  /**
4957
5305
  * 保存当前编辑行。持久化行原位合并;新身份以回查结果重建树关系。
4958
5306
  * @param {Object} obj VXE 插槽参数,必须包含 row 和 $table。
4959
- * @param {Object} options 保存选项;skipConfirm 用于粘贴后的自动保存。
5307
+ * @param {Object} options 保存选项;skipConfirm 跳过确认,cancelToken 用于自动保存失效时取消请求。
4960
5308
  */
4961
5309
  async saveEditRow(obj, options = {}) {
5310
+ if (this.tableDestroyed) return false;
4962
5311
  let formRef = this.getFormRef();
4963
5312
  let formConfig = this.formConfig;
4964
5313
  let entity = formConfig.entity;
@@ -4974,7 +5323,9 @@ modules = {
4974
5323
  return this.treeSingleSaveReconcileTask();
4975
5324
  }
4976
5325
  if (this.treeSingleSavePending) {
4977
- this.$message.warning("当前行正在保存,请勿重复操作。");
5326
+ if (!this.tableDestroyed) {
5327
+ this.$message.warning("当前行正在保存,请勿重复操作。");
5328
+ }
4978
5329
  return false;
4979
5330
  }
4980
5331
  this.treeSingleSavePending = true;
@@ -4991,9 +5342,11 @@ modules = {
4991
5342
  this.treeSingleSavePending = false;
4992
5343
  return true;
4993
5344
  } catch (error) {
4994
- this.$message.error(
4995
- "重新加载仍未成功,请手动刷新后再操作。"
4996
- );
5345
+ if (!this.tableDestroyed) {
5346
+ this.$message.error(
5347
+ "重新加载仍未成功,请手动刷新后再操作。"
5348
+ );
5349
+ }
4997
5350
  return false;
4998
5351
  } finally {
4999
5352
  retryPromise = null;
@@ -5140,6 +5493,7 @@ modules = {
5140
5493
  let requestTask = this.formHttp({
5141
5494
  scriptCode: scriptCode,
5142
5495
  data: reqData,
5496
+ cancelToken: options.cancelToken,
5143
5497
  successMsg: true,
5144
5498
  isConfirm: false,
5145
5499
  success: resolve,
@@ -5152,6 +5506,7 @@ modules = {
5152
5506
  requestTask.catch(reject);
5153
5507
  }
5154
5508
  });
5509
+ if (this.tableDestroyed) return false;
5155
5510
 
5156
5511
  let querySavedRow = () =>
5157
5512
  new Promise((resolve, reject) => {
@@ -5161,13 +5516,15 @@ modules = {
5161
5516
  (res) => {
5162
5517
  reject(new Error(res?.content || "保存结果重新查询失败。"));
5163
5518
  },
5164
- reject
5519
+ reject,
5520
+ options.cancelToken
5165
5521
  );
5166
5522
  if (requestTask && typeof requestTask.catch === "function") {
5167
5523
  requestTask.catch(reject);
5168
5524
  }
5169
5525
  });
5170
5526
  let reconcileSavedRow = async (rowResponse) => {
5527
+ if (this.tableDestroyed) return false;
5171
5528
  let responseRow = { ...(rowResponse?.objx || {}) };
5172
5529
  if (treeContext) {
5173
5530
  let { rowField } = treeContext.fields;
@@ -5345,6 +5702,8 @@ modules = {
5345
5702
  try {
5346
5703
  return await runRowReconcile();
5347
5704
  } catch (error) {
5705
+ if (axios.isCancel(error)) return false;
5706
+ if (this.tableDestroyed) return false;
5348
5707
  this.handleRowSaveError(error, obj.row);
5349
5708
  keepSaveLocked = true;
5350
5709
  let retryPromise = null;
@@ -5357,10 +5716,13 @@ modules = {
5357
5716
  return result;
5358
5717
  })
5359
5718
  .catch((retryError) => {
5360
- this.$message.error(
5361
- retryError?.message
5362
- || "保存结果仍未能重新加载,请手动刷新后再操作。"
5363
- );
5719
+ if (axios.isCancel(retryError)) return false;
5720
+ if (!this.tableDestroyed) {
5721
+ this.$message.error(
5722
+ retryError?.message
5723
+ || "保存结果仍未能重新加载,请手动刷新后再操作。"
5724
+ );
5725
+ }
5364
5726
  return false;
5365
5727
  })
5366
5728
  .finally(() => {
@@ -5375,6 +5737,8 @@ modules = {
5375
5737
  return false;
5376
5738
  }
5377
5739
  } catch (error) {
5740
+ if (axios.isCancel(error)) return false;
5741
+ if (this.tableDestroyed) return false;
5378
5742
  this.handleRowSaveError(error, obj.row);
5379
5743
  if (error?.treeReloadFailed) {
5380
5744
  keepSaveLocked = true;
@@ -5409,7 +5773,7 @@ modules = {
5409
5773
  }
5410
5774
  },
5411
5775
  /** @param {*} dataId 行数据 id。@param {Function} callback 查询成功回调。加载保存后的完整行。 */
5412
- getRowData(dataId, callback, fail, error) {
5776
+ getRowData(dataId, callback, fail, error, cancelToken) {
5413
5777
  let reportTemplate = this.getFormRef()?.reportTemplate;
5414
5778
  let formCode = reportTemplate.formCode;
5415
5779
  let formConfig = this.formConfig;
@@ -5427,6 +5791,7 @@ modules = {
5427
5791
  id: dataId,
5428
5792
  },
5429
5793
  },
5794
+ cancelToken,
5430
5795
  ...defaultOption,
5431
5796
  success: (res) => {
5432
5797
  callback && callback(res);
@@ -5727,6 +6092,7 @@ modules = {
5727
6092
  }
5728
6093
  });
5729
6094
  }
6095
+ this.releaseRowsRuntime(delKeys);
5730
6096
  let newRows = tableRows.filter((item) => !delKeys.has(item._X_ROW_KEY));
5731
6097
  this.setValue(this.stripTreeContainerRows(newRows));
5732
6098
  this.$nextTick(() => {
@@ -6162,6 +6528,7 @@ modules = {
6162
6528
  let row = obj.row;
6163
6529
  let $grid = this.getGridTable();
6164
6530
  await $grid.remove(row);
6531
+ this.releaseRowRuntime(row?._X_ROW_KEY);
6165
6532
  if (this.widget.options.isTreeTable) {
6166
6533
  let { rowField } = this.getTreeFields($grid);
6167
6534
  this.unregisterTreeKey(
@@ -6532,7 +6899,7 @@ modules = {
6532
6899
  let subFormModel = this.formModel[this.fieldKeyName];
6533
6900
  if (!!subFormModel && subFormModel.length > 0) {
6534
6901
  subFormModel.forEach((row) => {
6535
- if (!row._X_ROW_KEY) row._X_ROW_KEY = "row_" + generateId();
6902
+ if (!row._X_ROW_KEY) row._X_ROW_KEY = createXRowKey();
6536
6903
  this.rowIdData.push(row._X_ROW_KEY);
6537
6904
  });
6538
6905
 
@@ -6557,6 +6924,12 @@ modules = {
6557
6924
 
6558
6925
  let rowIdData = this.rowIdData;
6559
6926
  let rowLength = this.rowIdData.length;
6927
+ // 查询/赋值结果为空时也必须释放上一次的行级 schema。原逻辑只在
6928
+ // rowLength > 0 时重建,导致空结果页面仍常驻上一批数据的全部 schema。
6929
+ if (rowLength === 0) {
6930
+ this.fieldSchemaMap = {};
6931
+ return;
6932
+ }
6560
6933
  // this.fieldSchemaData.splice(0, this.fieldSchemaData.length) //清除数组必须用splice,length=0不会响应式更新!!
6561
6934
  // if(initFlag)this.fieldSchemaMap = {};
6562
6935
  if (rowLength > 0) {
@@ -6722,7 +7095,7 @@ modules = {
6722
7095
  initExportRows(rows) {
6723
7096
  if (!rows) return;
6724
7097
  for (let row of rows) {
6725
- if (!row._X_ROW_KEY) row._X_ROW_KEY = "row_" + generateId();
7098
+ if (!row._X_ROW_KEY) row._X_ROW_KEY = createXRowKey();
6726
7099
  row._X_EXPORT_ROW = true;
6727
7100
  }
6728
7101
  },
@@ -6732,7 +7105,7 @@ modules = {
6732
7105
  //初始化fieldSchemaData!!!
6733
7106
  let fieldSchemaMap = this.fieldSchemaMap;
6734
7107
  for (let row of rows) {
6735
- if (!row._X_ROW_KEY) row._X_ROW_KEY = "row_" + generateId();
7108
+ if (!row._X_ROW_KEY) row._X_ROW_KEY = createXRowKey();
6736
7109
  this.rowIdData.push(row._X_ROW_KEY);
6737
7110
  let fieldSchemaMap2 = this.createRowFieldSchemaMap();
6738
7111
  fieldSchemaMap[row._X_ROW_KEY] = fieldSchemaMap2;