vxe-table 3.14.0-beta.6 → 3.14.0-beta.8

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 (37) hide show
  1. package/es/grid/src/grid.js +4 -0
  2. package/es/style.css +1 -1
  3. package/es/table/src/body.js +11 -6
  4. package/es/table/src/footer.js +7 -2
  5. package/es/table/src/methods.js +212 -78
  6. package/es/table/src/util.js +35 -5
  7. package/es/ui/index.js +1 -1
  8. package/es/ui/src/log.js +1 -1
  9. package/lib/grid/src/grid.js +4 -0
  10. package/lib/grid/src/grid.min.js +1 -1
  11. package/lib/index.umd.js +299 -103
  12. package/lib/index.umd.min.js +1 -1
  13. package/lib/style.css +1 -1
  14. package/lib/table/src/body.js +10 -5
  15. package/lib/table/src/body.min.js +1 -1
  16. package/lib/table/src/footer.js +7 -2
  17. package/lib/table/src/footer.min.js +1 -1
  18. package/lib/table/src/methods.js +241 -89
  19. package/lib/table/src/methods.min.js +1 -1
  20. package/lib/table/src/util.js +40 -5
  21. package/lib/table/src/util.min.js +1 -1
  22. package/lib/ui/index.js +1 -1
  23. package/lib/ui/index.min.js +1 -1
  24. package/lib/ui/src/log.js +1 -1
  25. package/lib/ui/src/log.min.js +1 -1
  26. package/package.json +2 -2
  27. package/packages/grid/src/grid.ts +5 -0
  28. package/packages/table/src/body.ts +10 -5
  29. package/packages/table/src/footer.ts +7 -2
  30. package/packages/table/src/methods.ts +235 -85
  31. package/packages/table/src/util.ts +39 -5
  32. /package/es/{iconfont.1741224120026.ttf → iconfont.1741333630357.ttf} +0 -0
  33. /package/es/{iconfont.1741224120026.woff → iconfont.1741333630357.woff} +0 -0
  34. /package/es/{iconfont.1741224120026.woff2 → iconfont.1741333630357.woff2} +0 -0
  35. /package/lib/{iconfont.1741224120026.ttf → iconfont.1741333630357.ttf} +0 -0
  36. /package/lib/{iconfont.1741224120026.woff → iconfont.1741333630357.woff} +0 -0
  37. /package/lib/{iconfont.1741224120026.woff2 → iconfont.1741333630357.woff2} +0 -0
@@ -100,6 +100,7 @@ function renderRows(h, _vm, tableColumn, footerTableData, row, $rowIndex, _rowIn
100
100
  tfOns.dblclick = (evnt) => {
101
101
  $xeTable.dispatchEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
102
102
  };
103
+ let isMergeCell = false;
103
104
  // 合并行或列
104
105
  if (mergeFooterList.length) {
105
106
  const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex);
@@ -109,9 +110,11 @@ function renderRows(h, _vm, tableColumn, footerTableData, row, $rowIndex, _rowIn
109
110
  return null;
110
111
  }
111
112
  if (rowspan > 1) {
113
+ isMergeCell = true;
112
114
  attrs.rowspan = rowspan;
113
115
  }
114
116
  if (colspan > 1) {
117
+ isMergeCell = true;
115
118
  attrs.colspan = colspan;
116
119
  }
117
120
  }
@@ -132,8 +135,10 @@ function renderRows(h, _vm, tableColumn, footerTableData, row, $rowIndex, _rowIn
132
135
  const isLastColumn = $columnIndex === tableColumn.length - 1;
133
136
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
134
137
  let isVNPreEmptyStatus = false;
135
- if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
136
- isVNPreEmptyStatus = true;
138
+ if (!isMergeCell) {
139
+ if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
140
+ isVNPreEmptyStatus = true;
141
+ }
137
142
  }
138
143
  const tcStyle = {};
139
144
  if (hasEllipsis) {
@@ -3,7 +3,7 @@ import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEv
3
3
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
4
4
  import { VxeUI } from '../../ui';
5
5
  import Cell from './cell';
6
- import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getRefElem } from './util';
6
+ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, updateDeepRowKey, updateFastRowKey, getRefElem } from './util';
7
7
  import { getSlotVNs } from '../../ui/src/vn';
8
8
  import { warnLog, errLog } from '../../ui/src/log';
9
9
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI;
@@ -800,6 +800,7 @@ function handleCheckedAllCheckboxRow($xeTable, checked, isForce) {
800
800
  const childrenField = treeOpts.children || treeOpts.childrenField;
801
801
  const checkboxOpts = $xeTable.computeCheckboxOpts;
802
802
  const { checkField, reserve, checkMethod } = checkboxOpts;
803
+ // indeterminateField 仅支持读取
803
804
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
804
805
  const selectRowMaps = {};
805
806
  /**
@@ -2263,6 +2264,10 @@ const Methods = {
2263
2264
  }
2264
2265
  return [];
2265
2266
  },
2267
+ getEl() {
2268
+ const $xeTable = this;
2269
+ return $xeTable.$refs.refElem;
2270
+ },
2266
2271
  /**
2267
2272
  * 获取父容器元素
2268
2273
  */
@@ -2628,32 +2633,19 @@ const Methods = {
2628
2633
  const treeOpts = $xeTable.computeTreeOpts;
2629
2634
  const childrenField = treeOpts.children || treeOpts.childrenField;
2630
2635
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
2636
+ const { lazy } = treeOpts;
2631
2637
  const rowkey = getRowkey($xeTable);
2638
+ const isDeepKey = rowkey.indexOf('.') > -1;
2632
2639
  const fullAllDataRowIdMaps = Object.assign({}, fullAllDataRowIdData); // 存在已删除数据
2633
2640
  const fullDataRowIdMaps = {};
2634
2641
  const treeTempExpandedMaps = Object.assign({}, treeExpandedMaps);
2635
- const handleRow = (row, index, items, path, parentRow, nodes) => {
2636
- let rowid = getRowid($xeTable, row);
2637
- const seq = treeConfig && path ? toTreePathSeq(path) : index + 1;
2638
- const level = nodes ? nodes.length - 1 : 0;
2639
- if (eqEmptyValue(rowid)) {
2640
- rowid = getRowUniqueId();
2641
- XEUtils.set(row, rowkey, rowid);
2642
- }
2643
- if (treeConfig && treeOpts.lazy) {
2644
- const treeExpRest = treeExpandedMaps[rowid];
2645
- if (row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
2646
- row[childrenField] = null;
2647
- }
2648
- if (treeExpRest) {
2649
- if (!row[childrenField] || !row[childrenField].length) {
2650
- delete treeTempExpandedMaps[rowid];
2651
- }
2652
- }
2653
- }
2654
- let rowRest = fullAllDataRowIdData[rowid];
2642
+ const handleRowId = isDeepKey ? updateDeepRowKey : updateFastRowKey;
2643
+ const handleRowCache = (row, index, items, currIndex, parentRow, rowid, level, seq) => {
2644
+ let rowRest = fullAllDataRowIdMaps[rowid];
2655
2645
  if (!rowRest) {
2656
2646
  rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
2647
+ fullDataRowIdMaps[rowid] = rowRest;
2648
+ fullAllDataRowIdMaps[rowid] = rowRest;
2657
2649
  }
2658
2650
  rowRest.treeLoaded = false;
2659
2651
  rowRest.expandLoaded = false;
@@ -2661,15 +2653,30 @@ const Methods = {
2661
2653
  rowRest.items = items;
2662
2654
  rowRest.parent = parentRow;
2663
2655
  rowRest.level = level;
2664
- rowRest.index = treeConfig && parentRow ? -1 : index;
2665
- fullDataRowIdMaps[rowid] = rowRest;
2666
- fullAllDataRowIdMaps[rowid] = rowRest;
2656
+ rowRest.index = currIndex;
2657
+ rowRest.treeIndex = index;
2667
2658
  };
2668
2659
  if (treeConfig) {
2669
- XEUtils.eachTree(tableFullTreeData, handleRow, { children: childrenField });
2660
+ XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
2661
+ const rowid = handleRowId(row, rowkey);
2662
+ if (treeConfig && lazy) {
2663
+ const treeExpRest = treeTempExpandedMaps[rowid];
2664
+ if (row[hasChildField] && row[childrenField] === undefined) {
2665
+ row[childrenField] = null;
2666
+ }
2667
+ if (treeExpRest) {
2668
+ if (!row[childrenField] || !row[childrenField].length) {
2669
+ delete treeTempExpandedMaps[rowid];
2670
+ }
2671
+ }
2672
+ }
2673
+ handleRowCache(row, index, items, parentRow ? -1 : index, parentRow, rowid, nodes.length - 1, toTreePathSeq(path));
2674
+ }, { children: childrenField });
2670
2675
  }
2671
2676
  else {
2672
- tableFullData.forEach(handleRow);
2677
+ tableFullData.forEach((row, index, items) => {
2678
+ handleRowCache(row, index, items, index, null, handleRowId(row, rowkey), 0, index + 1);
2679
+ });
2673
2680
  }
2674
2681
  internalData.fullDataRowIdData = fullDataRowIdMaps;
2675
2682
  internalData.fullAllDataRowIdData = fullAllDataRowIdMaps;
@@ -3206,20 +3213,25 @@ const Methods = {
3206
3213
  },
3207
3214
  /**
3208
3215
  * 检查行或列数据是否发生改变
3209
- * @param {Row} row 行对象
3216
+ * @param {Row} rowOrId 行对象
3210
3217
  * @param {String} field 字段名
3211
3218
  */
3212
- isUpdateByRow(row, field) {
3213
- const { tableFullColumn, keepSource, sourceDataRowIdData, fullDataRowIdData } = this;
3219
+ isUpdateByRow(rowOrId, field) {
3220
+ const $xeTable = this;
3221
+ const props = $xeTable;
3222
+ const internalData = $xeTable;
3223
+ const { keepSource } = props;
3224
+ const { tableFullColumn, fullDataRowIdData, sourceDataRowIdData } = internalData;
3214
3225
  if (keepSource) {
3215
- const rowid = getRowid(this, row);
3226
+ const rowid = XEUtils.isString(rowOrId) || XEUtils.isNumber(rowOrId) ? rowOrId : getRowid($xeTable, rowOrId);
3227
+ const rowRest = fullDataRowIdData[rowid];
3216
3228
  // 新增的数据不需要检测
3217
- if (!fullDataRowIdData[rowid]) {
3229
+ if (!rowRest) {
3218
3230
  return false;
3219
3231
  }
3220
- const oldRest = sourceDataRowIdData[rowid];
3221
- if (oldRest) {
3222
- const oRow = oldRest.row;
3232
+ const row = rowRest.row;
3233
+ const oRow = sourceDataRowIdData[rowid];
3234
+ if (oRow) {
3223
3235
  if (arguments.length > 1) {
3224
3236
  return !eqCellValue(oRow, row, field);
3225
3237
  }
@@ -3281,6 +3293,99 @@ const Methods = {
3281
3293
  tableColumn: this.tableColumn.slice(0)
3282
3294
  };
3283
3295
  },
3296
+ /**
3297
+ * 移动列到指定列的位置
3298
+ * @param fieldOrColumn
3299
+ * @param targetFieldOrColumn
3300
+ * @param options
3301
+ */
3302
+ moveColumnTo(fieldOrColumn, targetFieldOrColumn, options) {
3303
+ const $xeTable = this;
3304
+ const internalData = $xeTable;
3305
+ const { fullColumnIdData, visibleColumn } = internalData;
3306
+ const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options);
3307
+ const dragCol = handleFieldOrColumn($xeTable, fieldOrColumn);
3308
+ let prevDragCol = null;
3309
+ const colRest = dragCol ? fullColumnIdData[dragCol.id] : null;
3310
+ let defPos = 'left';
3311
+ if (XEUtils.isNumber(targetFieldOrColumn)) {
3312
+ if (colRest && targetFieldOrColumn) {
3313
+ let currList = colRest.items;
3314
+ let offsetIndex = colRest._index + targetFieldOrColumn;
3315
+ if (isCrossDrag) {
3316
+ currList = visibleColumn;
3317
+ offsetIndex = colRest._index + targetFieldOrColumn;
3318
+ }
3319
+ if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
3320
+ prevDragCol = currList[offsetIndex];
3321
+ }
3322
+ if (targetFieldOrColumn > 0) {
3323
+ defPos = 'right';
3324
+ }
3325
+ }
3326
+ }
3327
+ else {
3328
+ prevDragCol = handleFieldOrColumn($xeTable, targetFieldOrColumn);
3329
+ const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null;
3330
+ if (colRest && targetColRest) {
3331
+ if (targetColRest._index > colRest._index) {
3332
+ defPos = 'right';
3333
+ }
3334
+ }
3335
+ }
3336
+ return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true);
3337
+ },
3338
+ /**
3339
+ * 移动行到指定行的位置
3340
+ * @param rowidOrRow
3341
+ * @param targetRowidOrRow
3342
+ * @param options
3343
+ */
3344
+ moveRowTo(rowidOrRow, targetRowidOrRow, options) {
3345
+ const $xeTable = this;
3346
+ const props = $xeTable;
3347
+ const internalData = $xeTable;
3348
+ const { treeConfig } = props;
3349
+ const { fullAllDataRowIdData, afterFullData } = internalData;
3350
+ const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options);
3351
+ const treeOpts = $xeTable.computeTreeOpts;
3352
+ const dragRow = handleRowidOrRow($xeTable, rowidOrRow);
3353
+ let prevDragRow = null;
3354
+ let defPos = 'top';
3355
+ const rowRest = dragRow ? fullAllDataRowIdData[getRowid($xeTable, dragRow)] : null;
3356
+ if (XEUtils.isNumber(targetRowidOrRow)) {
3357
+ if (rowRest && targetRowidOrRow) {
3358
+ let currList = afterFullData;
3359
+ let offsetIndex = rowRest._index + targetRowidOrRow;
3360
+ if (treeConfig) {
3361
+ currList = rowRest.items;
3362
+ if (treeOpts.transform) {
3363
+ offsetIndex = rowRest.treeIndex + targetRowidOrRow;
3364
+ if (isCrossDrag) {
3365
+ currList = afterFullData;
3366
+ offsetIndex = rowRest._index + targetRowidOrRow;
3367
+ }
3368
+ }
3369
+ }
3370
+ if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
3371
+ prevDragRow = currList[offsetIndex];
3372
+ }
3373
+ if (targetRowidOrRow > 0) {
3374
+ defPos = 'bottom';
3375
+ }
3376
+ }
3377
+ }
3378
+ else {
3379
+ prevDragRow = handleRowidOrRow($xeTable, targetRowidOrRow);
3380
+ const targetRowRest = prevDragRow ? fullAllDataRowIdData[getRowid($xeTable, prevDragRow)] : null;
3381
+ if (rowRest && targetRowRest) {
3382
+ if (targetRowRest._index > rowRest._index) {
3383
+ defPos = 'bottom';
3384
+ }
3385
+ }
3386
+ }
3387
+ return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true);
3388
+ },
3284
3389
  /**
3285
3390
  * 获取表格的全量列
3286
3391
  */
@@ -3301,22 +3406,30 @@ const Methods = {
3301
3406
  * 用于多选行,获取已选中的数据
3302
3407
  */
3303
3408
  getCheckboxRecords(isFull) {
3304
- const { tableFullData, afterFullData, treeConfig, treeOpts, checkboxOpts, tableFullTreeData, afterTreeFullData, afterFullRowMaps } = this;
3409
+ const $xeTable = this;
3410
+ const props = $xeTable;
3411
+ const reactData = $xeTable;
3412
+ const internalData = $xeTable;
3413
+ const { treeConfig } = props;
3414
+ const { selectCheckboxMaps } = reactData;
3415
+ const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData;
3416
+ const treeOpts = $xeTable.computeTreeOpts;
3417
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
3305
3418
  const { transform, mapChildrenField } = treeOpts;
3306
3419
  const { checkField } = checkboxOpts;
3307
3420
  const childrenField = treeOpts.children || treeOpts.childrenField;
3308
- const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData);
3309
3421
  let rowList = [];
3310
3422
  if (checkField) {
3311
3423
  if (treeConfig) {
3424
+ const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData);
3312
3425
  rowList = XEUtils.filterTree(currTableData, row => XEUtils.get(row, checkField), { children: transform ? mapChildrenField : childrenField });
3313
3426
  }
3314
3427
  else {
3428
+ const currTableData = isFull ? tableFullData : afterFullData;
3315
3429
  rowList = currTableData.filter((row) => XEUtils.get(row, checkField));
3316
3430
  }
3317
3431
  }
3318
3432
  else {
3319
- const { selectCheckboxMaps, fullDataRowIdData } = this;
3320
3433
  XEUtils.each(selectCheckboxMaps, (row, rowid) => {
3321
3434
  if (isFull) {
3322
3435
  if (fullDataRowIdData[rowid]) {
@@ -5445,6 +5558,7 @@ const Methods = {
5445
5558
  const childrenField = treeOpts.children || treeOpts.childrenField;
5446
5559
  const checkboxOpts = $xeTable.computeCheckboxOpts;
5447
5560
  const { checkField, checkStrictly, checkMethod } = checkboxOpts;
5561
+ // indeterminateField 仅支持读取
5448
5562
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
5449
5563
  if (checkField) {
5450
5564
  // 树结构
@@ -5890,6 +6004,7 @@ const Methods = {
5890
6004
  const { tableFullData, treeConfig, treeOpts, checkboxOpts } = this;
5891
6005
  const { checkField, reserve } = checkboxOpts;
5892
6006
  const childrenField = treeOpts.children || treeOpts.childrenField;
6007
+ // indeterminateField 仅支持读取
5893
6008
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
5894
6009
  if (checkField) {
5895
6010
  const handleClearChecked = (item) => {
@@ -6497,6 +6612,9 @@ const Methods = {
6497
6612
  const { afterFullData, tableFullData } = internalData;
6498
6613
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
6499
6614
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
6615
+ const errRest = {
6616
+ status: false
6617
+ };
6500
6618
  if (prevDragRow && dragRow) {
6501
6619
  // 判断是否有拖动
6502
6620
  if (prevDragRow !== dragRow) {
@@ -6511,7 +6629,7 @@ const Methods = {
6511
6629
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
6512
6630
  return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
6513
6631
  if (!status) {
6514
- return;
6632
+ return errRest;
6515
6633
  }
6516
6634
  let oafIndex = -1;
6517
6635
  let nafIndex = -1;
@@ -6536,12 +6654,12 @@ const Methods = {
6536
6654
  if (isPeerDrag && !isCrossDrag) {
6537
6655
  if (oldRest.row[parentField] !== newRest.row[parentField]) {
6538
6656
  // 非同级
6539
- return;
6657
+ return errRest;
6540
6658
  }
6541
6659
  }
6542
6660
  else {
6543
6661
  if (!isCrossDrag) {
6544
- return;
6662
+ return errRest;
6545
6663
  }
6546
6664
  if (oldAllMaps[newRowid]) {
6547
6665
  isSelfToChildStatus = true;
@@ -6552,7 +6670,7 @@ const Methods = {
6552
6670
  content: getI18n('vxe.error.treeDragChild')
6553
6671
  });
6554
6672
  }
6555
- return;
6673
+ return errRest;
6556
6674
  }
6557
6675
  }
6558
6676
  }
@@ -6560,13 +6678,13 @@ const Methods = {
6560
6678
  else if (oldLevel) {
6561
6679
  // 子到根
6562
6680
  if (!isCrossDrag) {
6563
- return;
6681
+ return errRest;
6564
6682
  }
6565
6683
  }
6566
6684
  else if (newLevel) {
6567
6685
  // 根到子
6568
6686
  if (!isCrossDrag) {
6569
- return;
6687
+ return errRest;
6570
6688
  }
6571
6689
  if (oldAllMaps[newRowid]) {
6572
6690
  isSelfToChildStatus = true;
@@ -6577,7 +6695,7 @@ const Methods = {
6577
6695
  content: getI18n('vxe.error.treeDragChild')
6578
6696
  });
6579
6697
  }
6580
- return;
6698
+ return errRest;
6581
6699
  }
6582
6700
  }
6583
6701
  }
@@ -6637,27 +6755,34 @@ const Methods = {
6637
6755
  if (reactData.scrollYLoad) {
6638
6756
  $xeTable.updateScrollYSpace();
6639
6757
  }
6640
- $xeTable.$nextTick().then(() => {
6758
+ if (evnt) {
6759
+ $xeTable.dispatchEvent('row-dragend', {
6760
+ oldRow: dragRow,
6761
+ newRow: prevDragRow,
6762
+ dragRow,
6763
+ dragPos: prevDragPos,
6764
+ dragToChild: isDragToChildFlag,
6765
+ offsetIndex: dragOffsetIndex,
6766
+ _index: {
6767
+ newIndex: nafIndex,
6768
+ oldIndex: oafIndex
6769
+ }
6770
+ }, evnt);
6771
+ }
6772
+ return $xeTable.$nextTick().then(() => {
6641
6773
  $xeTable.updateCellAreas();
6642
6774
  $xeTable.recalculate();
6775
+ }).then(() => {
6776
+ return {
6777
+ status: true
6778
+ };
6643
6779
  });
6644
- $xeTable.dispatchEvent('row-dragend', {
6645
- oldRow: dragRow,
6646
- newRow: prevDragRow,
6647
- dragRow,
6648
- dragPos: prevDragPos,
6649
- dragToChild: isDragToChildFlag,
6650
- offsetIndex: dragOffsetIndex,
6651
- _index: {
6652
- newIndex: nafIndex,
6653
- oldIndex: oafIndex
6654
- }
6655
- }, evnt);
6656
6780
  }).catch(() => {
6781
+ return errRest;
6657
6782
  });
6658
6783
  }
6659
6784
  }
6660
- return Promise.resolve();
6785
+ return Promise.resolve(errRest);
6661
6786
  },
6662
6787
  handleRowDragDragendEvent(evnt) {
6663
6788
  const $xeTable = this;
@@ -6802,6 +6927,9 @@ const Methods = {
6802
6927
  const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts;
6803
6928
  const { collectColumn } = internalData;
6804
6929
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
6930
+ const errRest = {
6931
+ status: false
6932
+ };
6805
6933
  if (prevDragCol && dragCol) {
6806
6934
  // 判断是否有拖动
6807
6935
  if (prevDragCol !== dragCol) {
@@ -6818,7 +6946,7 @@ const Methods = {
6818
6946
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
6819
6947
  return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
6820
6948
  if (!status) {
6821
- return;
6949
+ return errRest;
6822
6950
  }
6823
6951
  let oafIndex = -1;
6824
6952
  let nafIndex = -1;
@@ -6832,12 +6960,12 @@ const Methods = {
6832
6960
  if (isPeerDrag && !isCrossDrag) {
6833
6961
  if (dragColumn.parentId !== newColumn.parentId) {
6834
6962
  // 非同级
6835
- return;
6963
+ return errRest;
6836
6964
  }
6837
6965
  }
6838
6966
  else {
6839
6967
  if (!isCrossDrag) {
6840
- return;
6968
+ return errRest;
6841
6969
  }
6842
6970
  if (oldAllMaps[newColumn.id]) {
6843
6971
  isSelfToChildStatus = true;
@@ -6848,7 +6976,7 @@ const Methods = {
6848
6976
  content: getI18n('vxe.error.treeDragChild')
6849
6977
  });
6850
6978
  }
6851
- return;
6979
+ return errRest;
6852
6980
  }
6853
6981
  }
6854
6982
  }
@@ -6856,13 +6984,13 @@ const Methods = {
6856
6984
  else if (dragColumn.parentId) {
6857
6985
  // 子到根
6858
6986
  if (!isCrossDrag) {
6859
- return;
6987
+ return errRest;
6860
6988
  }
6861
6989
  }
6862
6990
  else if (newColumn.parentId) {
6863
6991
  // 根到子
6864
6992
  if (!isCrossDrag) {
6865
- return;
6993
+ return errRest;
6866
6994
  }
6867
6995
  if (oldAllMaps[newColumn.id]) {
6868
6996
  isSelfToChildStatus = true;
@@ -6873,7 +7001,7 @@ const Methods = {
6873
7001
  content: getI18n('vxe.error.treeDragChild')
6874
7002
  });
6875
7003
  }
6876
- return;
7004
+ return errRest;
6877
7005
  }
6878
7006
  }
6879
7007
  }
@@ -6934,26 +7062,32 @@ const Methods = {
6934
7062
  $xeTable.clearCopyCellArea();
6935
7063
  }
6936
7064
  }
6937
- $xeTable.dispatchEvent('column-dragend', {
6938
- oldColumn: dragColumn,
6939
- newColumn,
6940
- dragColumn,
6941
- dragPos: prevDragPos,
6942
- dragToChild: isDragToChildFlag,
6943
- offsetIndex: dragOffsetIndex,
6944
- _index: {
6945
- newIndex: nafIndex,
6946
- oldIndex: oafIndex
6947
- }
6948
- }, evnt);
7065
+ if (evnt) {
7066
+ $xeTable.dispatchEvent('column-dragend', {
7067
+ oldColumn: dragColumn,
7068
+ newColumn,
7069
+ dragColumn,
7070
+ dragPos: prevDragPos,
7071
+ dragToChild: isDragToChildFlag,
7072
+ offsetIndex: dragOffsetIndex,
7073
+ _index: {
7074
+ newIndex: nafIndex,
7075
+ oldIndex: oafIndex
7076
+ }
7077
+ }, evnt);
7078
+ }
6949
7079
  if (isSyncColumn) {
6950
7080
  $xeTable.handleColDragSwapColumn();
6951
7081
  }
7082
+ return {
7083
+ status: true
7084
+ };
6952
7085
  }).catch(() => {
7086
+ return errRest;
6953
7087
  });
6954
7088
  }
6955
7089
  }
6956
- return Promise.resolve();
7090
+ return Promise.resolve(errRest);
6957
7091
  },
6958
7092
  handleHeaderCellDragDragendEvent(evnt) {
6959
7093
  const $xeTable = this;
@@ -2,6 +2,7 @@ import XEUtils from 'xe-utils';
2
2
  import { ColumnInfo } from './columnInfo';
3
3
  import { isScale, isPx } from '../../ui/src/dom';
4
4
  import { warnLog, errLog } from '../../ui/src/log';
5
+ import { eqEmptyValue } from '../../ui/src/utils';
5
6
  const getAllConvertColumns = (columns, parentColumn) => {
6
7
  const result = [];
7
8
  columns.forEach((column) => {
@@ -90,13 +91,35 @@ export function getRowUniqueId() {
90
91
  return XEUtils.uniqueId('row_');
91
92
  }
92
93
  // 行主键 key
93
- export function getRowkey($xetable) {
94
- return $xetable.rowOpts.keyField || $xetable.rowId || '_X_ROW_KEY';
94
+ export function getRowkey($xeTable) {
95
+ const props = $xeTable;
96
+ const rowOpts = $xeTable.computeRowOpts;
97
+ return `${props.rowId || rowOpts.keyField || '_X_ROW_KEY'}`;
95
98
  }
96
99
  // 行主键 value
97
100
  export function getRowid($xetable, row) {
98
101
  const rowid = XEUtils.get(row, getRowkey($xetable));
99
- return XEUtils.eqNull(rowid) ? '' : encodeURIComponent(rowid);
102
+ return encodeRowid(rowid);
103
+ }
104
+ // 编码行主键
105
+ export function encodeRowid(rowVal) {
106
+ return XEUtils.eqNull(rowVal) ? '' : encodeURIComponent(rowVal);
107
+ }
108
+ export function updateDeepRowKey(row, rowkey) {
109
+ let rowid = XEUtils.get(row, rowkey);
110
+ if (eqEmptyValue(rowid)) {
111
+ rowid = getRowUniqueId();
112
+ XEUtils.set(row, rowkey, rowid);
113
+ }
114
+ return rowid;
115
+ }
116
+ export function updateFastRowKey(row, rowkey) {
117
+ let rowid = row[rowkey];
118
+ if (eqEmptyValue(rowid)) {
119
+ rowid = getRowUniqueId();
120
+ row[rowkey] = rowid;
121
+ }
122
+ return rowid;
100
123
  }
101
124
  function getPaddingLeftRightSize(elem) {
102
125
  if (elem) {
@@ -122,12 +145,19 @@ export function getCellHeight(height) {
122
145
  }
123
146
  return height || 0;
124
147
  }
125
- export function handleFieldOrColumn(_vm, fieldOrColumn) {
148
+ export function handleFieldOrColumn($xeTable, fieldOrColumn) {
126
149
  if (fieldOrColumn) {
127
- return XEUtils.isString(fieldOrColumn) || XEUtils.isNumber(fieldOrColumn) ? _vm.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn;
150
+ return XEUtils.isString(fieldOrColumn) || XEUtils.isNumber(fieldOrColumn) ? $xeTable.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn;
128
151
  }
129
152
  return null;
130
153
  }
154
+ export const handleRowidOrRow = ($xeTable, rowidOrRow) => {
155
+ if (rowidOrRow) {
156
+ const rowid = XEUtils.isString(rowidOrRow) || XEUtils.isNumber(rowidOrRow) ? rowidOrRow : getRowid($xeTable, rowidOrRow);
157
+ return $xeTable.getRowById(rowid);
158
+ }
159
+ return null;
160
+ };
131
161
  // 组装列配置
132
162
  export function assembleColumn(_vm) {
133
163
  const { $el, $xetable, $xecolumn, columnConfig } = _vm;
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "3.14.0-beta.6";
3
+ export const version = "3.14.0-beta.8";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"3.14.0-beta.6"}`;
3
+ const version = `table v${"3.14.0-beta.8"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);
@@ -674,6 +674,10 @@ var _default = exports.default = {
674
674
  }
675
675
  return [];
676
676
  },
677
+ getEl() {
678
+ const $xeGrid = this;
679
+ return $xeGrid.$refs.refElem;
680
+ },
677
681
  /**
678
682
  * 获取需要排除的高度
679
683
  */