vxe-table 3.13.19 → 3.13.21

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 +17 -8
  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 +197 -62
  6. package/es/table/src/util.js +18 -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 +17 -8
  10. package/lib/grid/src/grid.min.js +1 -1
  11. package/lib/index.umd.js +284 -97
  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 +228 -75
  19. package/lib/table/src/methods.min.js +1 -1
  20. package/lib/table/src/util.js +21 -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 +18 -8
  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 +218 -69
  31. package/packages/table/src/util.ts +20 -5
  32. /package/es/{iconfont.1741224103306.ttf → iconfont.1741336846919.ttf} +0 -0
  33. /package/es/{iconfont.1741224103306.woff → iconfont.1741336846919.woff} +0 -0
  34. /package/es/{iconfont.1741224103306.woff2 → iconfont.1741336846919.woff2} +0 -0
  35. /package/lib/{iconfont.1741224103306.ttf → iconfont.1741336846919.ttf} +0 -0
  36. /package/lib/{iconfont.1741224103306.woff → iconfont.1741336846919.woff} +0 -0
  37. /package/lib/{iconfont.1741224103306.woff2 → iconfont.1741336846919.woff2} +0 -0
@@ -189,6 +189,7 @@ function renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel,
189
189
  tdOns.dblclick = (evnt) => {
190
190
  $xeTable.triggerCellDblclickEvent(evnt, cellParams);
191
191
  };
192
+ let isMergeCell = false;
192
193
  // 合并行或列
193
194
  if (mergeList.length) {
194
195
  const spanRest = mergeBodyMethod(mergeList, _rowIndex, _columnIndex);
@@ -198,9 +199,11 @@ function renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel,
198
199
  return null;
199
200
  }
200
201
  if (rowspan > 1) {
202
+ isMergeCell = true;
201
203
  tdAttrs.rowspan = rowspan;
202
204
  }
203
205
  if (colspan > 1) {
206
+ isMergeCell = true;
204
207
  tdAttrs.colspan = colspan;
205
208
  }
206
209
  }
@@ -233,12 +236,14 @@ function renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel,
233
236
  const isLastColumn = $columnIndex === columns.length - 1;
234
237
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
235
238
  let isVNPreEmptyStatus = false;
236
- if (!dragRow || getRowid($xeTable, dragRow) !== rowid) {
237
- if (scrollYLoad && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
238
- isVNPreEmptyStatus = true;
239
- }
240
- else if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
241
- isVNPreEmptyStatus = true;
239
+ if (!isMergeCell) {
240
+ if (!dragRow || getRowid($xeTable, dragRow) !== rowid) {
241
+ if (scrollYLoad && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
242
+ isVNPreEmptyStatus = true;
243
+ }
244
+ else if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
245
+ isVNPreEmptyStatus = true;
246
+ }
242
247
  }
243
248
  }
244
249
  const tcStyle = {};
@@ -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, 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;
@@ -2190,6 +2190,10 @@ const Methods = {
2190
2190
  }
2191
2191
  return [];
2192
2192
  },
2193
+ getEl() {
2194
+ const $xeTable = this;
2195
+ return $xeTable.$refs.refElem;
2196
+ },
2193
2197
  /**
2194
2198
  * 获取父容器元素
2195
2199
  */
@@ -2603,20 +2607,22 @@ const Methods = {
2603
2607
  reactData.treeExpandedMaps = treeTempExpandedMaps;
2604
2608
  },
2605
2609
  cacheSourceMap(fullData) {
2606
- let { treeConfig, treeOpts, sourceDataRowIdData } = this;
2610
+ const $xeTable = this;
2611
+ const props = $xeTable;
2612
+ const internalData = $xeTable;
2613
+ const { treeConfig } = props;
2614
+ const treeOpts = $xeTable.computeTreeOpts;
2615
+ let { sourceDataRowIdData } = internalData;
2607
2616
  const sourceData = XEUtils.clone(fullData, true);
2608
- const rowkey = getRowkey(this);
2609
- sourceDataRowIdData = this.sourceDataRowIdData = {};
2617
+ const rowkey = getRowkey($xeTable);
2618
+ sourceDataRowIdData = internalData.sourceDataRowIdData = {};
2610
2619
  const handleSourceRow = (row) => {
2611
- let rowid = getRowid(this, row);
2620
+ let rowid = getRowid($xeTable, row);
2612
2621
  if (eqEmptyValue(rowid)) {
2613
2622
  rowid = getRowUniqueId();
2614
2623
  XEUtils.set(row, rowkey, rowid);
2615
2624
  }
2616
- sourceDataRowIdData[rowid] = {
2617
- row,
2618
- rowid
2619
- };
2625
+ sourceDataRowIdData[rowid] = row;
2620
2626
  };
2621
2627
  // 源数据缓存
2622
2628
  if (treeConfig) {
@@ -2626,7 +2632,7 @@ const Methods = {
2626
2632
  else {
2627
2633
  sourceData.forEach(handleSourceRow);
2628
2634
  }
2629
- this.tableSourceData = sourceData;
2635
+ internalData.tableSourceData = sourceData;
2630
2636
  },
2631
2637
  getParams() {
2632
2638
  return this.params;
@@ -2942,7 +2948,9 @@ const Methods = {
2942
2948
  const reactData = $xeTable;
2943
2949
  const internalData = $xeTable;
2944
2950
  const { keepSource, treeConfig } = props;
2951
+ const { editStore } = reactData;
2945
2952
  const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData;
2953
+ const removeTempMaps = Object.assign({}, editStore.removeMaps);
2946
2954
  const treeOpts = $xeTable.computeTreeOpts;
2947
2955
  const { transform } = treeOpts;
2948
2956
  if (!keepSource) {
@@ -2977,6 +2985,7 @@ const Methods = {
2977
2985
  XEUtils.destructuring(row, XEUtils.clone(oRow, true));
2978
2986
  }
2979
2987
  if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
2988
+ delete removeTempMaps[rowid];
2980
2989
  tableFullData.unshift(row);
2981
2990
  afterFullData.unshift(row);
2982
2991
  reDelFlag = true;
@@ -2988,6 +2997,7 @@ const Methods = {
2988
2997
  }
2989
2998
  if (rows) {
2990
2999
  if (reDelFlag) {
3000
+ editStore.removeMaps = removeTempMaps;
2991
3001
  $xeTable.updateFooter();
2992
3002
  $xeTable.cacheRowMap(false);
2993
3003
  $xeTable.handleTableData(treeConfig && transform);
@@ -3149,20 +3159,25 @@ const Methods = {
3149
3159
  },
3150
3160
  /**
3151
3161
  * 检查行或列数据是否发生改变
3152
- * @param {Row} row 行对象
3162
+ * @param {Row} rowOrId 行对象
3153
3163
  * @param {String} field 字段名
3154
3164
  */
3155
- isUpdateByRow(row, field) {
3156
- const { tableFullColumn, keepSource, sourceDataRowIdData, fullDataRowIdData } = this;
3165
+ isUpdateByRow(rowOrId, field) {
3166
+ const $xeTable = this;
3167
+ const props = $xeTable;
3168
+ const internalData = $xeTable;
3169
+ const { keepSource } = props;
3170
+ const { tableFullColumn, fullDataRowIdData, sourceDataRowIdData } = internalData;
3157
3171
  if (keepSource) {
3158
- const rowid = getRowid(this, row);
3172
+ const rowid = XEUtils.isString(rowOrId) || XEUtils.isNumber(rowOrId) ? rowOrId : getRowid($xeTable, rowOrId);
3173
+ const rowRest = fullDataRowIdData[rowid];
3159
3174
  // 新增的数据不需要检测
3160
- if (!fullDataRowIdData[rowid]) {
3175
+ if (!rowRest) {
3161
3176
  return false;
3162
3177
  }
3163
- const oldRest = sourceDataRowIdData[rowid];
3164
- if (oldRest) {
3165
- const oRow = oldRest.row;
3178
+ const row = rowRest.row;
3179
+ const oRow = sourceDataRowIdData[rowid];
3180
+ if (oRow) {
3166
3181
  if (arguments.length > 1) {
3167
3182
  return !eqCellValue(oRow, row, field);
3168
3183
  }
@@ -3224,6 +3239,99 @@ const Methods = {
3224
3239
  tableColumn: this.tableColumn.slice(0)
3225
3240
  };
3226
3241
  },
3242
+ /**
3243
+ * 移动列到指定列的位置
3244
+ * @param fieldOrColumn
3245
+ * @param targetFieldOrColumn
3246
+ * @param options
3247
+ */
3248
+ moveColumnTo(fieldOrColumn, targetFieldOrColumn, options) {
3249
+ const $xeTable = this;
3250
+ const internalData = $xeTable;
3251
+ const { fullColumnIdData, visibleColumn } = internalData;
3252
+ const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options);
3253
+ const dragCol = handleFieldOrColumn($xeTable, fieldOrColumn);
3254
+ let prevDragCol = null;
3255
+ const colRest = dragCol ? fullColumnIdData[dragCol.id] : null;
3256
+ let defPos = 'left';
3257
+ if (XEUtils.isNumber(targetFieldOrColumn)) {
3258
+ if (colRest && targetFieldOrColumn) {
3259
+ let currList = colRest.items;
3260
+ let offsetIndex = colRest._index + targetFieldOrColumn;
3261
+ if (isCrossDrag) {
3262
+ currList = visibleColumn;
3263
+ offsetIndex = colRest._index + targetFieldOrColumn;
3264
+ }
3265
+ if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
3266
+ prevDragCol = currList[offsetIndex];
3267
+ }
3268
+ if (targetFieldOrColumn > 0) {
3269
+ defPos = 'right';
3270
+ }
3271
+ }
3272
+ }
3273
+ else {
3274
+ prevDragCol = handleFieldOrColumn($xeTable, targetFieldOrColumn);
3275
+ const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null;
3276
+ if (colRest && targetColRest) {
3277
+ if (targetColRest._index > colRest._index) {
3278
+ defPos = 'right';
3279
+ }
3280
+ }
3281
+ }
3282
+ return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true);
3283
+ },
3284
+ /**
3285
+ * 移动行到指定行的位置
3286
+ * @param rowidOrRow
3287
+ * @param targetRowidOrRow
3288
+ * @param options
3289
+ */
3290
+ moveRowTo(rowidOrRow, targetRowidOrRow, options) {
3291
+ const $xeTable = this;
3292
+ const props = $xeTable;
3293
+ const internalData = $xeTable;
3294
+ const { treeConfig } = props;
3295
+ const { fullAllDataRowIdData, afterFullData } = internalData;
3296
+ const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options);
3297
+ const treeOpts = $xeTable.computeTreeOpts;
3298
+ const dragRow = handleRowidOrRow($xeTable, rowidOrRow);
3299
+ let prevDragRow = null;
3300
+ let defPos = 'top';
3301
+ const rowRest = dragRow ? fullAllDataRowIdData[getRowid($xeTable, dragRow)] : null;
3302
+ if (XEUtils.isNumber(targetRowidOrRow)) {
3303
+ if (rowRest && targetRowidOrRow) {
3304
+ let currList = afterFullData;
3305
+ let offsetIndex = rowRest._index + targetRowidOrRow;
3306
+ if (treeConfig) {
3307
+ currList = rowRest.items;
3308
+ if (treeOpts.transform) {
3309
+ offsetIndex = rowRest.treeIndex + targetRowidOrRow;
3310
+ if (isCrossDrag) {
3311
+ currList = afterFullData;
3312
+ offsetIndex = rowRest._index + targetRowidOrRow;
3313
+ }
3314
+ }
3315
+ }
3316
+ if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
3317
+ prevDragRow = currList[offsetIndex];
3318
+ }
3319
+ if (targetRowidOrRow > 0) {
3320
+ defPos = 'bottom';
3321
+ }
3322
+ }
3323
+ }
3324
+ else {
3325
+ prevDragRow = handleRowidOrRow($xeTable, targetRowidOrRow);
3326
+ const targetRowRest = prevDragRow ? fullAllDataRowIdData[getRowid($xeTable, prevDragRow)] : null;
3327
+ if (rowRest && targetRowRest) {
3328
+ if (targetRowRest._index > rowRest._index) {
3329
+ defPos = 'bottom';
3330
+ }
3331
+ }
3332
+ }
3333
+ return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true);
3334
+ },
3227
3335
  /**
3228
3336
  * 获取表格的全量列
3229
3337
  */
@@ -3244,22 +3352,30 @@ const Methods = {
3244
3352
  * 用于多选行,获取已选中的数据
3245
3353
  */
3246
3354
  getCheckboxRecords(isFull) {
3247
- const { tableFullData, afterFullData, treeConfig, treeOpts, checkboxOpts, tableFullTreeData, afterTreeFullData, afterFullRowMaps } = this;
3355
+ const $xeTable = this;
3356
+ const props = $xeTable;
3357
+ const reactData = $xeTable;
3358
+ const internalData = $xeTable;
3359
+ const { treeConfig } = props;
3360
+ const { selectCheckboxMaps } = reactData;
3361
+ const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData;
3362
+ const treeOpts = $xeTable.computeTreeOpts;
3363
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
3248
3364
  const { transform, mapChildrenField } = treeOpts;
3249
3365
  const { checkField } = checkboxOpts;
3250
3366
  const childrenField = treeOpts.children || treeOpts.childrenField;
3251
- const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData);
3252
3367
  let rowList = [];
3253
3368
  if (checkField) {
3254
3369
  if (treeConfig) {
3370
+ const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData);
3255
3371
  rowList = XEUtils.filterTree(currTableData, row => XEUtils.get(row, checkField), { children: transform ? mapChildrenField : childrenField });
3256
3372
  }
3257
3373
  else {
3374
+ const currTableData = isFull ? tableFullData : afterFullData;
3258
3375
  rowList = currTableData.filter((row) => XEUtils.get(row, checkField));
3259
3376
  }
3260
3377
  }
3261
3378
  else {
3262
- const { selectCheckboxMaps, fullDataRowIdData } = this;
3263
3379
  XEUtils.each(selectCheckboxMaps, (row, rowid) => {
3264
3380
  if (isFull) {
3265
3381
  if (fullDataRowIdData[rowid]) {
@@ -6435,6 +6551,9 @@ const Methods = {
6435
6551
  const { afterFullData, tableFullData } = internalData;
6436
6552
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
6437
6553
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
6554
+ const errRest = {
6555
+ status: false
6556
+ };
6438
6557
  if (prevDragRow && dragRow) {
6439
6558
  // 判断是否有拖动
6440
6559
  if (prevDragRow !== dragRow) {
@@ -6449,7 +6568,7 @@ const Methods = {
6449
6568
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
6450
6569
  return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
6451
6570
  if (!status) {
6452
- return;
6571
+ return errRest;
6453
6572
  }
6454
6573
  let oafIndex = -1;
6455
6574
  let nafIndex = -1;
@@ -6474,12 +6593,12 @@ const Methods = {
6474
6593
  if (isPeerDrag && !isCrossDrag) {
6475
6594
  if (oldRest.row[parentField] !== newRest.row[parentField]) {
6476
6595
  // 非同级
6477
- return;
6596
+ return errRest;
6478
6597
  }
6479
6598
  }
6480
6599
  else {
6481
6600
  if (!isCrossDrag) {
6482
- return;
6601
+ return errRest;
6483
6602
  }
6484
6603
  if (oldAllMaps[newRowid]) {
6485
6604
  isSelfToChildStatus = true;
@@ -6490,7 +6609,7 @@ const Methods = {
6490
6609
  content: getI18n('vxe.error.treeDragChild')
6491
6610
  });
6492
6611
  }
6493
- return;
6612
+ return errRest;
6494
6613
  }
6495
6614
  }
6496
6615
  }
@@ -6498,13 +6617,13 @@ const Methods = {
6498
6617
  else if (oldLevel) {
6499
6618
  // 子到根
6500
6619
  if (!isCrossDrag) {
6501
- return;
6620
+ return errRest;
6502
6621
  }
6503
6622
  }
6504
6623
  else if (newLevel) {
6505
6624
  // 根到子
6506
6625
  if (!isCrossDrag) {
6507
- return;
6626
+ return errRest;
6508
6627
  }
6509
6628
  if (oldAllMaps[newRowid]) {
6510
6629
  isSelfToChildStatus = true;
@@ -6515,7 +6634,7 @@ const Methods = {
6515
6634
  content: getI18n('vxe.error.treeDragChild')
6516
6635
  });
6517
6636
  }
6518
- return;
6637
+ return errRest;
6519
6638
  }
6520
6639
  }
6521
6640
  }
@@ -6575,27 +6694,34 @@ const Methods = {
6575
6694
  if (reactData.scrollYLoad) {
6576
6695
  $xeTable.updateScrollYSpace();
6577
6696
  }
6578
- $xeTable.$nextTick().then(() => {
6697
+ if (evnt) {
6698
+ $xeTable.dispatchEvent('row-dragend', {
6699
+ oldRow: dragRow,
6700
+ newRow: prevDragRow,
6701
+ dragRow,
6702
+ dragPos: prevDragPos,
6703
+ dragToChild: isDragToChildFlag,
6704
+ offsetIndex: dragOffsetIndex,
6705
+ _index: {
6706
+ newIndex: nafIndex,
6707
+ oldIndex: oafIndex
6708
+ }
6709
+ }, evnt);
6710
+ }
6711
+ return $xeTable.$nextTick().then(() => {
6579
6712
  $xeTable.updateCellAreas();
6580
6713
  $xeTable.recalculate();
6714
+ }).then(() => {
6715
+ return {
6716
+ status: true
6717
+ };
6581
6718
  });
6582
- $xeTable.dispatchEvent('row-dragend', {
6583
- oldRow: dragRow,
6584
- newRow: prevDragRow,
6585
- dragRow,
6586
- dragPos: prevDragPos,
6587
- dragToChild: isDragToChildFlag,
6588
- offsetIndex: dragOffsetIndex,
6589
- _index: {
6590
- newIndex: nafIndex,
6591
- oldIndex: oafIndex
6592
- }
6593
- }, evnt);
6594
6719
  }).catch(() => {
6720
+ return errRest;
6595
6721
  });
6596
6722
  }
6597
6723
  }
6598
- return Promise.resolve();
6724
+ return Promise.resolve(errRest);
6599
6725
  },
6600
6726
  handleRowDragDragendEvent(evnt) {
6601
6727
  const $xeTable = this;
@@ -6740,6 +6866,9 @@ const Methods = {
6740
6866
  const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts;
6741
6867
  const { collectColumn } = internalData;
6742
6868
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
6869
+ const errRest = {
6870
+ status: false
6871
+ };
6743
6872
  if (prevDragCol && dragCol) {
6744
6873
  // 判断是否有拖动
6745
6874
  if (prevDragCol !== dragCol) {
@@ -6756,7 +6885,7 @@ const Methods = {
6756
6885
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
6757
6886
  return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
6758
6887
  if (!status) {
6759
- return;
6888
+ return errRest;
6760
6889
  }
6761
6890
  let oafIndex = -1;
6762
6891
  let nafIndex = -1;
@@ -6770,12 +6899,12 @@ const Methods = {
6770
6899
  if (isPeerDrag && !isCrossDrag) {
6771
6900
  if (dragColumn.parentId !== newColumn.parentId) {
6772
6901
  // 非同级
6773
- return;
6902
+ return errRest;
6774
6903
  }
6775
6904
  }
6776
6905
  else {
6777
6906
  if (!isCrossDrag) {
6778
- return;
6907
+ return errRest;
6779
6908
  }
6780
6909
  if (oldAllMaps[newColumn.id]) {
6781
6910
  isSelfToChildStatus = true;
@@ -6786,7 +6915,7 @@ const Methods = {
6786
6915
  content: getI18n('vxe.error.treeDragChild')
6787
6916
  });
6788
6917
  }
6789
- return;
6918
+ return errRest;
6790
6919
  }
6791
6920
  }
6792
6921
  }
@@ -6794,13 +6923,13 @@ const Methods = {
6794
6923
  else if (dragColumn.parentId) {
6795
6924
  // 子到根
6796
6925
  if (!isCrossDrag) {
6797
- return;
6926
+ return errRest;
6798
6927
  }
6799
6928
  }
6800
6929
  else if (newColumn.parentId) {
6801
6930
  // 根到子
6802
6931
  if (!isCrossDrag) {
6803
- return;
6932
+ return errRest;
6804
6933
  }
6805
6934
  if (oldAllMaps[newColumn.id]) {
6806
6935
  isSelfToChildStatus = true;
@@ -6811,7 +6940,7 @@ const Methods = {
6811
6940
  content: getI18n('vxe.error.treeDragChild')
6812
6941
  });
6813
6942
  }
6814
- return;
6943
+ return errRest;
6815
6944
  }
6816
6945
  }
6817
6946
  }
@@ -6872,26 +7001,32 @@ const Methods = {
6872
7001
  $xeTable.clearCopyCellArea();
6873
7002
  }
6874
7003
  }
6875
- $xeTable.dispatchEvent('column-dragend', {
6876
- oldColumn: dragColumn,
6877
- newColumn,
6878
- dragColumn,
6879
- dragPos: prevDragPos,
6880
- dragToChild: isDragToChildFlag,
6881
- offsetIndex: dragOffsetIndex,
6882
- _index: {
6883
- newIndex: nafIndex,
6884
- oldIndex: oafIndex
6885
- }
6886
- }, evnt);
7004
+ if (evnt) {
7005
+ $xeTable.dispatchEvent('column-dragend', {
7006
+ oldColumn: dragColumn,
7007
+ newColumn,
7008
+ dragColumn,
7009
+ dragPos: prevDragPos,
7010
+ dragToChild: isDragToChildFlag,
7011
+ offsetIndex: dragOffsetIndex,
7012
+ _index: {
7013
+ newIndex: nafIndex,
7014
+ oldIndex: oafIndex
7015
+ }
7016
+ }, evnt);
7017
+ }
6887
7018
  if (isSyncColumn) {
6888
7019
  $xeTable.handleColDragSwapColumn();
6889
7020
  }
7021
+ return {
7022
+ status: true
7023
+ };
6890
7024
  }).catch(() => {
7025
+ return errRest;
6891
7026
  });
6892
7027
  }
6893
7028
  }
6894
- return Promise.resolve();
7029
+ return Promise.resolve(errRest);
6895
7030
  },
6896
7031
  handleHeaderCellDragDragendEvent(evnt) {
6897
7032
  const $xeTable = this;
@@ -90,13 +90,19 @@ export function getRowUniqueId() {
90
90
  return XEUtils.uniqueId('row_');
91
91
  }
92
92
  // 行主键 key
93
- export function getRowkey($xetable) {
94
- return $xetable.rowOpts.keyField || $xetable.rowId || '_X_ROW_KEY';
93
+ export function getRowkey($xeTable) {
94
+ const props = $xeTable;
95
+ const rowOpts = $xeTable.computeRowOpts;
96
+ return `${props.rowId || rowOpts.keyField || '_X_ROW_KEY'}`;
95
97
  }
96
98
  // 行主键 value
97
99
  export function getRowid($xetable, row) {
98
100
  const rowid = XEUtils.get(row, getRowkey($xetable));
99
- return XEUtils.eqNull(rowid) ? '' : encodeURIComponent(rowid);
101
+ return encodeRowid(rowid);
102
+ }
103
+ // 编码行主键
104
+ export function encodeRowid(rowVal) {
105
+ return XEUtils.eqNull(rowVal) ? '' : encodeURIComponent(rowVal);
100
106
  }
101
107
  function getPaddingLeftRightSize(elem) {
102
108
  if (elem) {
@@ -122,12 +128,19 @@ export function getCellHeight(height) {
122
128
  }
123
129
  return height || 0;
124
130
  }
125
- export function handleFieldOrColumn(_vm, fieldOrColumn) {
131
+ export function handleFieldOrColumn($xeTable, fieldOrColumn) {
126
132
  if (fieldOrColumn) {
127
- return XEUtils.isString(fieldOrColumn) || XEUtils.isNumber(fieldOrColumn) ? _vm.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn;
133
+ return XEUtils.isString(fieldOrColumn) || XEUtils.isNumber(fieldOrColumn) ? $xeTable.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn;
128
134
  }
129
135
  return null;
130
136
  }
137
+ export const handleRowidOrRow = ($xeTable, rowidOrRow) => {
138
+ if (rowidOrRow) {
139
+ const rowid = XEUtils.isString(rowidOrRow) || XEUtils.isNumber(rowidOrRow) ? rowidOrRow : getRowid($xeTable, rowidOrRow);
140
+ return $xeTable.getRowById(rowid);
141
+ }
142
+ return null;
143
+ };
131
144
  // 组装列配置
132
145
  export function assembleColumn(_vm) {
133
146
  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.13.19";
3
+ export const version = "3.13.21";
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.13.19"}`;
3
+ const version = `table v${"3.13.21"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);
@@ -671,6 +671,10 @@ var _default = exports.default = {
671
671
  }
672
672
  return [];
673
673
  },
674
+ getEl() {
675
+ const $xeGrid = this;
676
+ return $xeGrid.$refs.refElem;
677
+ },
674
678
  /**
675
679
  * 获取需要排除的高度
676
680
  */
@@ -681,20 +685,25 @@ var _default = exports.default = {
681
685
  isZMax
682
686
  } = reactData;
683
687
  const el = $xeGrid.$refs.refElem;
684
- const formWrapper = $xeGrid.$refs.refFormWrapper;
685
- const toolbarWrapper = $xeGrid.$refs.refToolbarWrapper;
686
- const topWrapper = $xeGrid.$refs.refTopWrapper;
687
- const bottomWrapper = $xeGrid.$refs.refBottomWrapper;
688
- const pagerWrapper = $xeGrid.$refs.refPagerWrapper;
689
- const parentPaddingSize = isZMax ? 0 : (0, _dom.getPaddingTopBottomSize)(el.parentNode);
690
- return parentPaddingSize + (0, _dom.getPaddingTopBottomSize)(el) + (0, _dom.getOffsetHeight)(formWrapper) + (0, _dom.getOffsetHeight)(toolbarWrapper) + (0, _dom.getOffsetHeight)(topWrapper) + (0, _dom.getOffsetHeight)(bottomWrapper) + (0, _dom.getOffsetHeight)(pagerWrapper);
688
+ if (el) {
689
+ const formWrapper = $xeGrid.$refs.refFormWrapper;
690
+ const toolbarWrapper = $xeGrid.$refs.refToolbarWrapper;
691
+ const topWrapper = $xeGrid.$refs.refTopWrapper;
692
+ const bottomWrapper = $xeGrid.$refs.refBottomWrapper;
693
+ const pagerWrapper = $xeGrid.$refs.refPagerWrapper;
694
+ const parentEl = el.parentElement;
695
+ const parentPaddingSize = isZMax ? 0 : parentEl ? (0, _dom.getPaddingTopBottomSize)(parentEl) : 0;
696
+ return parentPaddingSize + (0, _dom.getPaddingTopBottomSize)(el) + (0, _dom.getOffsetHeight)(formWrapper) + (0, _dom.getOffsetHeight)(toolbarWrapper) + (0, _dom.getOffsetHeight)(topWrapper) + (0, _dom.getOffsetHeight)(bottomWrapper) + (0, _dom.getOffsetHeight)(pagerWrapper);
697
+ }
698
+ return 0;
691
699
  },
692
700
  getParentHeight() {
693
701
  const $xeGrid = this;
694
702
  const reactData = $xeGrid;
695
703
  const el = $xeGrid.$refs.refElem;
696
704
  if (el) {
697
- return (reactData.isZMax ? (0, _dom.getDomNode)().visibleHeight : _xeUtils.default.toNumber(getComputedStyle(el.parentNode).height)) - $xeGrid.getExcludeHeight();
705
+ const parentEl = el.parentElement;
706
+ return (reactData.isZMax ? (0, _dom.getDomNode)().visibleHeight : parentEl ? _xeUtils.default.toNumber(getComputedStyle(parentEl).height) : 0) - $xeGrid.getExcludeHeight();
698
707
  }
699
708
  return 0;
700
709
  },