vxe-table 4.12.0-beta.6 → 4.12.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 -1
  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/table.js +192 -74
  6. package/es/table/src/util.js +30 -3
  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 -1
  10. package/lib/grid/src/grid.min.js +1 -1
  11. package/lib/index.umd.js +1109 -12140
  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/table.js +213 -77
  19. package/lib/table/src/table.min.js +1 -1
  20. package/lib/table/src/util.js +35 -6
  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 +4 -1
  28. package/packages/table/src/body.ts +10 -5
  29. package/packages/table/src/footer.ts +7 -2
  30. package/packages/table/src/table.ts +196 -75
  31. package/packages/table/src/util.ts +34 -3
  32. /package/es/{iconfont.1741224140308.ttf → iconfont.1741333670965.ttf} +0 -0
  33. /package/es/{iconfont.1741224140308.woff → iconfont.1741333670965.woff} +0 -0
  34. /package/es/{iconfont.1741224140308.woff2 → iconfont.1741333670965.woff2} +0 -0
  35. /package/lib/{iconfont.1741224140308.ttf → iconfont.1741333670965.ttf} +0 -0
  36. /package/lib/{iconfont.1741224140308.woff → iconfont.1741333670965.woff} +0 -0
  37. /package/lib/{iconfont.1741224140308.woff2 → iconfont.1741333670965.woff2} +0 -0
@@ -9,7 +9,7 @@ import TableHeaderComponent from './header'
9
9
  import TableFooterComponent from './footer'
10
10
  import tableProps from './props'
11
11
  import tableEmits from './emits'
12
- import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth } from './util'
12
+ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, updateDeepRowKey, updateFastRowKey } from './util'
13
13
  import { getSlotVNs } from '../../ui/src/vn'
14
14
  import { warnLog, errLog } from '../../ui/src/log'
15
15
  import TableCustomPanelComponent from '../module/custom/panel'
@@ -2367,6 +2367,7 @@ export default defineComponent({
2367
2367
  const childrenField = treeOpts.children || treeOpts.childrenField
2368
2368
  const checkboxOpts = computeCheckboxOpts.value
2369
2369
  const { checkField, reserve, checkMethod } = checkboxOpts
2370
+ // indeterminateField 仅支持读取
2370
2371
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
2371
2372
  const selectRowMaps: Record<string, any> = {}
2372
2373
  /**
@@ -2780,7 +2781,7 @@ export default defineComponent({
2780
2781
  const { transform } = treeOpts
2781
2782
  const childrenField = treeOpts.children || treeOpts.childrenField
2782
2783
  let treeData = []
2783
- let fullData = reactive(datas ? datas.slice(0) : []) // 转为响应式
2784
+ let fullData = reactive(datas ? datas.slice(0) : []) // 转为响应式数据
2784
2785
  if (treeConfig) {
2785
2786
  if (transform) {
2786
2787
  // 树结构自动转换
@@ -3589,6 +3590,9 @@ export default defineComponent({
3589
3590
 
3590
3591
  tableMethods = {
3591
3592
  dispatchEvent,
3593
+ getEl () {
3594
+ return refElem.value
3595
+ },
3592
3596
  /**
3593
3597
  * 重置表格的一切数据状态
3594
3598
  */
@@ -4080,18 +4084,20 @@ export default defineComponent({
4080
4084
  },
4081
4085
  /**
4082
4086
  * 检查行或列数据是否发生改变
4083
- * @param {Row} row 行对象
4087
+ * @param {Row} rowOrId 行对象、行主键
4084
4088
  * @param {String} field 字段名
4085
4089
  */
4086
- isUpdateByRow (row, field) {
4090
+ isUpdateByRow (rowOrId, field) {
4087
4091
  const { keepSource } = props
4088
4092
  const { tableFullColumn, fullDataRowIdData, sourceDataRowIdData } = internalData
4089
4093
  if (keepSource) {
4090
- const rowid = getRowid($xeTable, row)
4094
+ const rowid = XEUtils.isString(rowOrId) || XEUtils.isNumber(rowOrId) ? rowOrId : getRowid($xeTable, rowOrId)
4095
+ const rowRest = fullDataRowIdData[rowid]
4091
4096
  // 新增的数据不需要检测
4092
- if (!fullDataRowIdData[rowid]) {
4097
+ if (!rowRest) {
4093
4098
  return false
4094
4099
  }
4100
+ const row = rowRest.row
4095
4101
  const oRow = sourceDataRowIdData[rowid]
4096
4102
  if (oRow) {
4097
4103
  if (arguments.length > 1) {
@@ -4155,6 +4161,92 @@ export default defineComponent({
4155
4161
  tableColumn: reactData.tableColumn.slice(0)
4156
4162
  }
4157
4163
  },
4164
+ /**
4165
+ * 移动列到指定列的位置
4166
+ * @param fieldOrColumn
4167
+ * @param targetFieldOrColumn
4168
+ * @param options
4169
+ */
4170
+ moveColumnTo (fieldOrColumn, targetFieldOrColumn, options) {
4171
+ const { fullColumnIdData, visibleColumn } = internalData
4172
+ const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options)
4173
+ const dragCol = handleFieldOrColumn($xeTable, fieldOrColumn)
4174
+ let prevDragCol: VxeTableDefines.ColumnInfo | null = null
4175
+ const colRest = dragCol ? fullColumnIdData[dragCol.id] : null
4176
+ let defPos: 'left' | 'right' = 'left'
4177
+ if (XEUtils.isNumber(targetFieldOrColumn)) {
4178
+ if (colRest && targetFieldOrColumn) {
4179
+ let currList = colRest.items
4180
+ let offsetIndex = colRest._index + targetFieldOrColumn
4181
+ if (isCrossDrag) {
4182
+ currList = visibleColumn
4183
+ offsetIndex = colRest._index + targetFieldOrColumn
4184
+ }
4185
+ if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
4186
+ prevDragCol = currList[offsetIndex]
4187
+ }
4188
+ if (targetFieldOrColumn > 0) {
4189
+ defPos = 'right'
4190
+ }
4191
+ }
4192
+ } else {
4193
+ prevDragCol = handleFieldOrColumn($xeTable, targetFieldOrColumn)
4194
+ const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null
4195
+ if (colRest && targetColRest) {
4196
+ if (targetColRest._index > colRest._index) {
4197
+ defPos = 'right'
4198
+ }
4199
+ }
4200
+ }
4201
+ return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true)
4202
+ },
4203
+ /**
4204
+ * 移动行到指定行的位置
4205
+ * @param rowidOrRow
4206
+ * @param targetRowidOrRow
4207
+ * @param options
4208
+ */
4209
+ moveRowTo (rowidOrRow, targetRowidOrRow, options) {
4210
+ const { treeConfig } = props
4211
+ const { fullAllDataRowIdData, afterFullData } = internalData
4212
+ const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options)
4213
+ const treeOpts = computeTreeOpts.value
4214
+ const dragRow = handleRowidOrRow($xeTable, rowidOrRow)
4215
+ let prevDragRow: any = null
4216
+ let defPos: 'top' | 'bottom' = 'top'
4217
+ const rowRest = dragRow ? fullAllDataRowIdData[getRowid($xeTable, dragRow)] : null
4218
+ if (XEUtils.isNumber(targetRowidOrRow)) {
4219
+ if (rowRest && targetRowidOrRow) {
4220
+ let currList = afterFullData
4221
+ let offsetIndex = rowRest._index + targetRowidOrRow
4222
+ if (treeConfig) {
4223
+ currList = rowRest.items
4224
+ if (treeOpts.transform) {
4225
+ offsetIndex = rowRest.treeIndex + targetRowidOrRow
4226
+ if (isCrossDrag) {
4227
+ currList = afterFullData
4228
+ offsetIndex = rowRest._index + targetRowidOrRow
4229
+ }
4230
+ }
4231
+ }
4232
+ if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
4233
+ prevDragRow = currList[offsetIndex]
4234
+ }
4235
+ if (targetRowidOrRow > 0) {
4236
+ defPos = 'bottom'
4237
+ }
4238
+ }
4239
+ } else {
4240
+ prevDragRow = handleRowidOrRow($xeTable, targetRowidOrRow)
4241
+ const targetRowRest = prevDragRow ? fullAllDataRowIdData[getRowid($xeTable, prevDragRow)] : null
4242
+ if (rowRest && targetRowRest) {
4243
+ if (targetRowRest._index > rowRest._index) {
4244
+ defPos = 'bottom'
4245
+ }
4246
+ }
4247
+ }
4248
+ return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true)
4249
+ },
4158
4250
  /**
4159
4251
  * 获取表格的全量列
4160
4252
  */
@@ -4174,6 +4266,7 @@ export default defineComponent({
4174
4266
  */
4175
4267
  getCheckboxRecords (isFull) {
4176
4268
  const { treeConfig } = props
4269
+ const { selectCheckboxMaps } = reactData
4177
4270
  const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData
4178
4271
  const treeOpts = computeTreeOpts.value
4179
4272
  const checkboxOpts = computeCheckboxOpts.value
@@ -4181,15 +4274,15 @@ export default defineComponent({
4181
4274
  const { checkField } = checkboxOpts
4182
4275
  const childrenField = treeOpts.children || treeOpts.childrenField
4183
4276
  let rowList: any[] = []
4184
- const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData)
4185
4277
  if (checkField) {
4186
4278
  if (treeConfig) {
4279
+ const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData)
4187
4280
  rowList = XEUtils.filterTree(currTableData, row => XEUtils.get(row, checkField), { children: transform ? mapChildrenField : childrenField })
4188
4281
  } else {
4282
+ const currTableData = isFull ? tableFullData : afterFullData
4189
4283
  rowList = currTableData.filter((row) => XEUtils.get(row, checkField))
4190
4284
  }
4191
4285
  } else {
4192
- const { selectCheckboxMaps } = reactData
4193
4286
  XEUtils.each(selectCheckboxMaps, (row, rowid) => {
4194
4287
  if (isFull) {
4195
4288
  if (fullDataRowIdData[rowid]) {
@@ -4873,6 +4966,7 @@ export default defineComponent({
4873
4966
  const childrenField = treeOpts.children || treeOpts.childrenField
4874
4967
  const checkboxOpts = computeCheckboxOpts.value
4875
4968
  const { checkField, reserve } = checkboxOpts
4969
+ // indeterminateField 仅支持读取
4876
4970
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
4877
4971
  if (checkField) {
4878
4972
  const handleClearChecked = (item: any) => {
@@ -6865,32 +6959,20 @@ export default defineComponent({
6865
6959
  const treeOpts = computeTreeOpts.value
6866
6960
  const childrenField = treeOpts.children || treeOpts.childrenField
6867
6961
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
6962
+ const { lazy } = treeOpts
6868
6963
  const rowkey = getRowkey($xeTable)
6964
+ const isDeepKey = rowkey.indexOf('.') > -1
6869
6965
  const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
6870
6966
  const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
6871
6967
  const treeTempExpandedMaps = { ...treeExpandedMaps }
6872
- const handleRow = (row: any, index: number, items: any, path?: any[], parentRow?: any, nodes?: any[]) => {
6873
- let rowid = getRowid($xeTable, row)
6874
- const seq = treeConfig && path ? toTreePathSeq(path) : index + 1
6875
- const level = nodes ? nodes.length - 1 : 0
6876
- if (eqEmptyValue(rowid)) {
6877
- rowid = getRowUniqueId()
6878
- XEUtils.set(row, rowkey, rowid)
6879
- }
6880
- if (treeConfig && treeOpts.lazy) {
6881
- const treeExpRest = treeExpandedMaps[rowid]
6882
- if (row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
6883
- row[childrenField] = null
6884
- }
6885
- if (treeExpRest) {
6886
- if (!row[childrenField] || !row[childrenField].length) {
6887
- delete treeTempExpandedMaps[rowid]
6888
- }
6889
- }
6890
- }
6891
- let rowRest = fullAllDataRowIdData[rowid]
6968
+
6969
+ const handleRowId = isDeepKey ? updateDeepRowKey : updateFastRowKey
6970
+ const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
6971
+ let rowRest = fullAllDataRowIdMaps[rowid]
6892
6972
  if (!rowRest) {
6893
6973
  rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
6974
+ fullDataRowIdMaps[rowid] = rowRest
6975
+ fullAllDataRowIdMaps[rowid] = rowRest
6894
6976
  }
6895
6977
  rowRest.treeLoaded = false
6896
6978
  rowRest.expandLoaded = false
@@ -6899,15 +6981,32 @@ export default defineComponent({
6899
6981
  rowRest.items = items
6900
6982
  rowRest.parent = parentRow
6901
6983
  rowRest.level = level
6902
- rowRest.index = treeConfig && parentRow ? -1 : index
6903
- fullDataRowIdMaps[rowid] = rowRest
6904
- fullAllDataRowIdMaps[rowid] = rowRest
6984
+ rowRest.index = currIndex
6985
+ rowRest.treeIndex = index
6905
6986
  }
6987
+
6906
6988
  if (treeConfig) {
6907
- XEUtils.eachTree(tableFullTreeData, handleRow, { children: childrenField })
6989
+ XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
6990
+ const rowid = handleRowId(row, rowkey)
6991
+ if (treeConfig && lazy) {
6992
+ const treeExpRest = treeTempExpandedMaps[rowid]
6993
+ if (row[hasChildField] && row[childrenField] === undefined) {
6994
+ row[childrenField] = null
6995
+ }
6996
+ if (treeExpRest) {
6997
+ if (!row[childrenField] || !row[childrenField].length) {
6998
+ delete treeTempExpandedMaps[rowid]
6999
+ }
7000
+ }
7001
+ }
7002
+ handleRowCache(row, index, items, parentRow ? -1 : index, parentRow, rowid, nodes.length - 1, toTreePathSeq(path))
7003
+ }, { children: childrenField })
6908
7004
  } else {
6909
- tableFullData.forEach(handleRow)
7005
+ tableFullData.forEach((row, index, items) => {
7006
+ handleRowCache(row, index, items, index, null, handleRowId(row, rowkey), 0, index + 1)
7007
+ })
6910
7008
  }
7009
+
6911
7010
  internalData.fullDataRowIdData = fullDataRowIdMaps
6912
7011
  internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
6913
7012
  reactData.treeExpandedMaps = treeTempExpandedMaps
@@ -7556,6 +7655,7 @@ export default defineComponent({
7556
7655
  const childrenField = treeOpts.children || treeOpts.childrenField
7557
7656
  const checkboxOpts = computeCheckboxOpts.value
7558
7657
  const { checkField, checkStrictly, checkMethod } = checkboxOpts
7658
+ // indeterminateField 仅支持读取
7559
7659
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
7560
7660
  if (checkField) {
7561
7661
  // 树结构
@@ -8193,6 +8293,9 @@ export default defineComponent({
8193
8293
  const { afterFullData, tableFullData } = internalData
8194
8294
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
8195
8295
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
8296
+ const errRest = {
8297
+ status: false
8298
+ }
8196
8299
  if (prevDragRow && dragRow) {
8197
8300
  // 判断是否有拖动
8198
8301
  if (prevDragRow !== dragRow) {
@@ -8207,7 +8310,7 @@ export default defineComponent({
8207
8310
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
8208
8311
  return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
8209
8312
  if (!status) {
8210
- return
8313
+ return errRest
8211
8314
  }
8212
8315
 
8213
8316
  let oafIndex = -1
@@ -8238,11 +8341,11 @@ export default defineComponent({
8238
8341
  if (isPeerDrag && !isCrossDrag) {
8239
8342
  if (oldRest.row[parentField] !== newRest.row[parentField]) {
8240
8343
  // 非同级
8241
- return
8344
+ return errRest
8242
8345
  }
8243
8346
  } else {
8244
8347
  if (!isCrossDrag) {
8245
- return
8348
+ return errRest
8246
8349
  }
8247
8350
  if (oldAllMaps[newRowid]) {
8248
8351
  isSelfToChildStatus = true
@@ -8253,7 +8356,7 @@ export default defineComponent({
8253
8356
  content: getI18n('vxe.error.treeDragChild')
8254
8357
  })
8255
8358
  }
8256
- return
8359
+ return errRest
8257
8360
  }
8258
8361
  }
8259
8362
  }
@@ -8261,13 +8364,13 @@ export default defineComponent({
8261
8364
  // 子到根
8262
8365
 
8263
8366
  if (!isCrossDrag) {
8264
- return
8367
+ return errRest
8265
8368
  }
8266
8369
  } else if (newLevel) {
8267
8370
  // 根到子
8268
8371
 
8269
8372
  if (!isCrossDrag) {
8270
- return
8373
+ return errRest
8271
8374
  }
8272
8375
  if (oldAllMaps[newRowid]) {
8273
8376
  isSelfToChildStatus = true
@@ -8278,7 +8381,7 @@ export default defineComponent({
8278
8381
  content: getI18n('vxe.error.treeDragChild')
8279
8382
  })
8280
8383
  }
8281
- return
8384
+ return errRest
8282
8385
  }
8283
8386
  }
8284
8387
  } else {
@@ -8342,28 +8445,36 @@ export default defineComponent({
8342
8445
  if (reactData.scrollYLoad) {
8343
8446
  $xeTable.updateScrollYSpace()
8344
8447
  }
8345
- nextTick().then(() => {
8448
+
8449
+ if (evnt) {
8450
+ dispatchEvent('row-dragend', {
8451
+ oldRow: dragRow,
8452
+ newRow: prevDragRow,
8453
+ dragRow,
8454
+ dragPos: prevDragPos as any,
8455
+ dragToChild: isDragToChildFlag,
8456
+ offsetIndex: dragOffsetIndex,
8457
+ _index: {
8458
+ newIndex: nafIndex,
8459
+ oldIndex: oafIndex
8460
+ }
8461
+ }, evnt)
8462
+ }
8463
+
8464
+ return nextTick().then(() => {
8346
8465
  $xeTable.updateCellAreas()
8347
8466
  $xeTable.recalculate()
8348
- })
8349
-
8350
- dispatchEvent('row-dragend', {
8351
- oldRow: dragRow,
8352
- newRow: prevDragRow,
8353
- dragRow,
8354
- dragPos: prevDragPos as any,
8355
- dragToChild: isDragToChildFlag,
8356
- offsetIndex: dragOffsetIndex,
8357
- _index: {
8358
- newIndex: nafIndex,
8359
- oldIndex: oafIndex
8467
+ }).then(() => {
8468
+ return {
8469
+ status: true
8360
8470
  }
8361
- }, evnt)
8471
+ })
8362
8472
  }).catch(() => {
8473
+ return errRest
8363
8474
  })
8364
8475
  }
8365
8476
  }
8366
- return Promise.resolve()
8477
+ return Promise.resolve(errRest)
8367
8478
  },
8368
8479
  handleRowDragDragendEvent (evnt) {
8369
8480
  const { treeConfig } = props
@@ -8488,6 +8599,9 @@ export default defineComponent({
8488
8599
  const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
8489
8600
  const { collectColumn } = internalData
8490
8601
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
8602
+ const errRest = {
8603
+ status: false
8604
+ }
8491
8605
  if (prevDragCol && dragCol) {
8492
8606
  // 判断是否有拖动
8493
8607
  if (prevDragCol !== dragCol) {
@@ -8504,7 +8618,7 @@ export default defineComponent({
8504
8618
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
8505
8619
  return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
8506
8620
  if (!status) {
8507
- return
8621
+ return errRest
8508
8622
  }
8509
8623
 
8510
8624
  let oafIndex = -1
@@ -8523,11 +8637,11 @@ export default defineComponent({
8523
8637
  if (isPeerDrag && !isCrossDrag) {
8524
8638
  if (dragColumn.parentId !== newColumn.parentId) {
8525
8639
  // 非同级
8526
- return
8640
+ return errRest
8527
8641
  }
8528
8642
  } else {
8529
8643
  if (!isCrossDrag) {
8530
- return
8644
+ return errRest
8531
8645
  }
8532
8646
 
8533
8647
  if (oldAllMaps[newColumn.id]) {
@@ -8539,7 +8653,7 @@ export default defineComponent({
8539
8653
  content: getI18n('vxe.error.treeDragChild')
8540
8654
  })
8541
8655
  }
8542
- return
8656
+ return errRest
8543
8657
  }
8544
8658
  }
8545
8659
  }
@@ -8547,13 +8661,13 @@ export default defineComponent({
8547
8661
  // 子到根
8548
8662
 
8549
8663
  if (!isCrossDrag) {
8550
- return
8664
+ return errRest
8551
8665
  }
8552
8666
  } else if (newColumn.parentId) {
8553
8667
  // 根到子
8554
8668
 
8555
8669
  if (!isCrossDrag) {
8556
- return
8670
+ return errRest
8557
8671
  }
8558
8672
  if (oldAllMaps[newColumn.id]) {
8559
8673
  isSelfToChildStatus = true
@@ -8564,7 +8678,7 @@ export default defineComponent({
8564
8678
  content: getI18n('vxe.error.treeDragChild')
8565
8679
  })
8566
8680
  }
8567
- return
8681
+ return errRest
8568
8682
  }
8569
8683
  }
8570
8684
  } else {
@@ -8628,27 +8742,34 @@ export default defineComponent({
8628
8742
  }
8629
8743
  }
8630
8744
 
8631
- dispatchEvent('column-dragend', {
8632
- oldColumn: dragColumn,
8633
- newColumn,
8634
- dragColumn,
8635
- dragPos: prevDragPos,
8636
- dragToChild: isDragToChildFlag,
8637
- offsetIndex: dragOffsetIndex,
8638
- _index: {
8639
- newIndex: nafIndex,
8640
- oldIndex: oafIndex
8641
- }
8642
- }, evnt)
8745
+ if (evnt) {
8746
+ dispatchEvent('column-dragend', {
8747
+ oldColumn: dragColumn,
8748
+ newColumn,
8749
+ dragColumn,
8750
+ dragPos: prevDragPos,
8751
+ dragToChild: isDragToChildFlag,
8752
+ offsetIndex: dragOffsetIndex,
8753
+ _index: {
8754
+ newIndex: nafIndex,
8755
+ oldIndex: oafIndex
8756
+ }
8757
+ }, evnt)
8758
+ }
8643
8759
 
8644
8760
  if (isSyncColumn) {
8645
8761
  $xeTable.handleColDragSwapColumn()
8646
8762
  }
8763
+
8764
+ return {
8765
+ status: true
8766
+ }
8647
8767
  }).catch(() => {
8768
+ return errRest
8648
8769
  })
8649
8770
  }
8650
8771
  }
8651
- return Promise.resolve()
8772
+ return Promise.resolve(errRest)
8652
8773
  },
8653
8774
  handleHeaderCellDragDragendEvent (evnt) {
8654
8775
  const { dragCol } = reactData
@@ -2,6 +2,7 @@ import { watch, reactive } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { ColumnInfo } from './columnInfo'
4
4
  import { isPx, isScale } from '../../ui/src/dom'
5
+ import { eqEmptyValue } from '../../ui/src/utils'
5
6
 
6
7
  import type { VxeTableConstructor, VxeTablePrivateMethods, VxeTableDefines } from '../../../types'
7
8
 
@@ -101,15 +102,37 @@ export function getRowUniqueId () {
101
102
  export function getRowkey ($xeTable: VxeTableConstructor) {
102
103
  const { props } = $xeTable
103
104
  const { computeRowOpts } = $xeTable.getComputeMaps()
104
- const { rowId } = props
105
105
  const rowOpts = computeRowOpts.value
106
- return rowId || rowOpts.keyField || '_X_ROW_KEY'
106
+ return `${props.rowId || rowOpts.keyField || '_X_ROW_KEY'}`
107
107
  }
108
108
 
109
109
  // 行主键 value
110
110
  export function getRowid ($xeTable: VxeTableConstructor, row: any) {
111
111
  const rowid = XEUtils.get(row, getRowkey($xeTable))
112
- return XEUtils.eqNull(rowid) ? '' : encodeURIComponent(rowid)
112
+ return encodeRowid(rowid)
113
+ }
114
+
115
+ // 编码行主键
116
+ export function encodeRowid (rowVal: string) {
117
+ return XEUtils.eqNull(rowVal) ? '' : encodeURIComponent(rowVal)
118
+ }
119
+
120
+ export function updateDeepRowKey (row: any, rowkey: string) {
121
+ let rowid = XEUtils.get(row, rowkey)
122
+ if (eqEmptyValue(rowid)) {
123
+ rowid = getRowUniqueId()
124
+ XEUtils.set(row, rowkey, rowid)
125
+ }
126
+ return rowid
127
+ }
128
+
129
+ export function updateFastRowKey (row: any, rowkey: string) {
130
+ let rowid = row[rowkey]
131
+ if (eqEmptyValue(rowid)) {
132
+ rowid = getRowUniqueId()
133
+ row[rowkey] = rowid
134
+ }
135
+ return rowid
113
136
  }
114
137
 
115
138
  export interface XEColumnInstance {
@@ -123,6 +146,14 @@ export const handleFieldOrColumn = ($xeTable: VxeTableConstructor, fieldOrColumn
123
146
  return null
124
147
  }
125
148
 
149
+ export const handleRowidOrRow = ($xeTable: VxeTableConstructor, rowidOrRow: any) => {
150
+ if (rowidOrRow) {
151
+ const rowid = XEUtils.isString(rowidOrRow) || XEUtils.isNumber(rowidOrRow) ? rowidOrRow : getRowid($xeTable, rowidOrRow)
152
+ return $xeTable.getRowById(rowid)
153
+ }
154
+ return null
155
+ }
156
+
126
157
  function getPaddingLeftRightSize (elem: HTMLElement | null) {
127
158
  if (elem) {
128
159
  const computedStyle = getComputedStyle(elem)