vxe-table 3.7.0-beta.14 → 3.7.0-beta.16

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 (35) hide show
  1. package/README.md +1 -1
  2. package/lib/export/src/mixin.js +4 -1
  3. package/lib/export/src/mixin.min.js +1 -1
  4. package/lib/icon/style/style.css +1 -1
  5. package/lib/icon/style/style.min.css +1 -1
  6. package/lib/index.css +1 -1
  7. package/lib/index.umd.js +98 -30
  8. package/lib/index.umd.min.js +1 -1
  9. package/lib/keyboard/src/mixin.js +4 -1
  10. package/lib/keyboard/src/mixin.min.js +1 -1
  11. package/lib/style.css +1 -1
  12. package/lib/style.min.css +1 -1
  13. package/lib/table/src/body.js +4 -2
  14. package/lib/table/src/body.min.js +1 -1
  15. package/lib/table/src/methods.js +79 -23
  16. package/lib/table/src/methods.min.js +1 -1
  17. package/lib/tools/log.js +1 -1
  18. package/lib/tools/log.min.js +1 -1
  19. package/lib/v-x-e-table/index.js +1 -1
  20. package/lib/v-x-e-table/index.min.js +1 -1
  21. package/lib/validator/src/mixin.js +4 -1
  22. package/lib/validator/src/mixin.min.js +1 -1
  23. package/package.json +5 -2
  24. package/packages/export/src/mixin.js +2 -1
  25. package/packages/keyboard/src/mixin.js +2 -1
  26. package/packages/table/src/body.js +4 -2
  27. package/packages/table/src/methods.js +35 -23
  28. package/packages/validator/src/mixin.js +2 -1
  29. package/types/v-x-e-table/index.d.ts +1 -1
  30. /package/lib/icon/style/{iconfont.1692577739980.ttf → iconfont.1693009490086.ttf} +0 -0
  31. /package/lib/icon/style/{iconfont.1692577739980.woff → iconfont.1693009490086.woff} +0 -0
  32. /package/lib/icon/style/{iconfont.1692577739980.woff2 → iconfont.1693009490086.woff2} +0 -0
  33. /package/lib/{iconfont.1692577739980.ttf → iconfont.1693009490086.ttf} +0 -0
  34. /package/lib/{iconfont.1692577739980.woff → iconfont.1693009490086.woff} +0 -0
  35. /package/lib/{iconfont.1692577739980.woff2 → iconfont.1693009490086.woff2} +0 -0
@@ -79,6 +79,7 @@ function toBooleanValue (cellValue) {
79
79
  function getLabelData ($xetable, opts, columns, datas) {
80
80
  const { isAllExpand, mode } = opts
81
81
  const { treeConfig, treeOpts, radioOpts, checkboxOpts, columnOpts } = $xetable
82
+ const childrenField = treeOpts.children || treeOpts.childrenField
82
83
  if (!htmlCellElem) {
83
84
  htmlCellElem = document.createElement('div')
84
85
  }
@@ -149,7 +150,7 @@ function getLabelData ($xetable, opts, columns, datas) {
149
150
  expandMaps.set(row, 1)
150
151
  rest.push(Object.assign(item, row))
151
152
  }
152
- }, treeOpts)
153
+ }, { children: childrenField })
153
154
  return rest
154
155
  }
155
156
  return datas.map((row, $rowIndex) => {
@@ -112,11 +112,12 @@ export default {
112
112
  // 处理当前行方向键移动
113
113
  moveCurrentRow (isUpArrow, isDwArrow, evnt) {
114
114
  const { currentRow, treeConfig, treeOpts, afterFullData } = this
115
+ const childrenField = treeOpts.children || treeOpts.childrenField
115
116
  let targetRow
116
117
  evnt.preventDefault()
117
118
  if (currentRow) {
118
119
  if (treeConfig) {
119
- const { index, items } = XEUtils.findTree(afterFullData, item => item === currentRow, treeOpts)
120
+ const { index, items } = XEUtils.findTree(afterFullData, item => item === currentRow, { children: childrenField })
120
121
  if (isUpArrow && index > 0) {
121
122
  targetRow = items[index - 1]
122
123
  } else if (isDwArrow && index < items.length - 1) {
@@ -504,8 +504,10 @@ export default {
504
504
  },
505
505
  beforeDestroy () {
506
506
  clearTimeout(this.wheelTime)
507
- this.$el._onscroll = null
508
- this.$el.onscroll = null
507
+ if (this.$el) {
508
+ this.$el._onscroll = null
509
+ this.$el.onscroll = null
510
+ }
509
511
  },
510
512
  destroyed () {
511
513
  const { $parent: $xetable, fixedType } = this
@@ -623,7 +623,7 @@ const Methods = {
623
623
  fullAllDataRowIdData = this.fullAllDataRowIdData = {}
624
624
  fullAllDataRowMap.clear()
625
625
  if (treeConfig) {
626
- XEUtils.eachTree(tableFullTreeData, handleCache, treeOpts)
626
+ XEUtils.eachTree(tableFullTreeData, handleCache, { children: childrenField })
627
627
  } else {
628
628
  tableFullData.forEach(handleCache)
629
629
  }
@@ -646,7 +646,8 @@ const Methods = {
646
646
  }
647
647
  // 源数据缓存
648
648
  if (treeConfig && !treeOpts.transform) {
649
- XEUtils.eachTree(sourceData, handleSourceRow, treeOpts)
649
+ const childrenField = treeOpts.children || treeOpts.childrenField
650
+ XEUtils.eachTree(sourceData, handleSourceRow, { children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField })
650
651
  } else {
651
652
  sourceData.forEach(handleSourceRow)
652
653
  }
@@ -661,7 +662,7 @@ const Methods = {
661
662
  return this.createData(childRecords).then((rows) => {
662
663
  if (keepSource) {
663
664
  const rowid = getRowid(this, row)
664
- const matchObj = XEUtils.findTree(tableSourceData, (item) => rowid === getRowid(this, item), treeOpts)
665
+ const matchObj = XEUtils.findTree(tableSourceData, (item) => rowid === getRowid(this, item), { children: childrenField })
665
666
  if (matchObj) {
666
667
  matchObj.item[childrenField] = XEUtils.clone(rows, true)
667
668
  }
@@ -673,7 +674,7 @@ const Methods = {
673
674
  fullDataRowMap.set(childRow, rest)
674
675
  fullAllDataRowIdData[rowid] = rest
675
676
  fullAllDataRowMap.set(childRow, rest)
676
- }, treeOpts)
677
+ }, { children: childrenField })
677
678
  row[childrenField] = rows
678
679
  if (transform) {
679
680
  row[mapChildrenField] = rows
@@ -2520,6 +2521,7 @@ const Methods = {
2520
2521
  const operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow
2521
2522
  const operCtxMenu = isCtxMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow)
2522
2523
  const isEditStatus = isEnableConf(editConfig) && actived.column && actived.row
2524
+ const childrenField = treeOpts.children || treeOpts.childrenField
2523
2525
  let params
2524
2526
  if (filterStore.visible) {
2525
2527
  if (isEsc) {
@@ -2592,7 +2594,7 @@ const Methods = {
2592
2594
  }
2593
2595
  } else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
2594
2596
  // 如果是树形表格当前行回车移动到子节点
2595
- const childrens = currentRow[treeOpts.children]
2597
+ const childrens = currentRow[childrenField]
2596
2598
  if (childrens && childrens.length) {
2597
2599
  evnt.preventDefault()
2598
2600
  const targetRow = childrens[0]
@@ -2654,7 +2656,7 @@ const Methods = {
2654
2656
  }
2655
2657
  } else if (isBack && keyboardOpts.isArrow && treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
2656
2658
  // 如果树形表格回退键关闭当前行返回父节点
2657
- const { parent: parentRow } = XEUtils.findTree(this.afterFullData, item => item === currentRow, treeOpts)
2659
+ const { parent: parentRow } = XEUtils.findTree(this.afterFullData, item => item === currentRow, { children: childrenField })
2658
2660
  if (parentRow) {
2659
2661
  evnt.preventDefault()
2660
2662
  params = { $table: this, row: parentRow }
@@ -2981,6 +2983,7 @@ const Methods = {
2981
2983
  handleSelectRow ({ row }, value, isForce) {
2982
2984
  const { selectCheckboxRows, afterFullData, treeConfig, treeOpts, treeIndeterminates, checkboxOpts } = this
2983
2985
  const { checkField, checkStrictly, checkMethod } = checkboxOpts
2986
+ const childrenField = treeOpts.children || treeOpts.childrenField
2984
2987
  if (checkField) {
2985
2988
  if (treeConfig && !checkStrictly) {
2986
2989
  if (value === -1) {
@@ -2996,10 +2999,10 @@ const Methods = {
2996
2999
  XEUtils.remove(treeIndeterminates, half => this.eqRow(half, item))
2997
3000
  this.handleCheckboxReserveRow(row, value)
2998
3001
  }
2999
- }, treeOpts)
3002
+ }, { children: childrenField })
3000
3003
  }
3001
3004
  // 如果存在父节点,更新父节点状态
3002
- const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), treeOpts)
3005
+ const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
3003
3006
  if (matchObj && matchObj.parent) {
3004
3007
  let parentStatus
3005
3008
  const vItems = !isForce && checkMethod ? matchObj.items.filter((item) => checkMethod({ row: item })) : matchObj.items
@@ -3037,10 +3040,10 @@ const Methods = {
3037
3040
  XEUtils.remove(treeIndeterminates, half => this.eqRow(half, item))
3038
3041
  this.handleCheckboxReserveRow(row, value)
3039
3042
  }
3040
- }, treeOpts)
3043
+ }, { children: childrenField })
3041
3044
  }
3042
3045
  // 如果存在父节点,更新父节点状态
3043
- const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), treeOpts)
3046
+ const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
3044
3047
  if (matchObj && matchObj.parent) {
3045
3048
  let parentStatus
3046
3049
  const vItems = !isForce && checkMethod ? matchObj.items.filter((item) => checkMethod({ row: item })) : matchObj.items
@@ -3122,6 +3125,7 @@ const Methods = {
3122
3125
  const { afterFullData, treeConfig, treeOpts, selectCheckboxRows, checkboxReserveRowMap, checkboxOpts } = this
3123
3126
  const { checkField, reserve, checkStrictly, checkMethod } = checkboxOpts
3124
3127
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
3128
+ const childrenField = treeOpts.children || treeOpts.childrenField
3125
3129
  let selectRows = []
3126
3130
  const beforeSelection = treeConfig ? [] : selectCheckboxRows.filter(row => this.findRowIndexOf(afterFullData, row) === -1)
3127
3131
  if (checkStrictly) {
@@ -3146,7 +3150,7 @@ const Methods = {
3146
3150
  // 如果存在选中方法
3147
3151
  // 如果方法成立,则更新值,否则忽略该数据
3148
3152
  if (treeConfig) {
3149
- XEUtils.eachTree(afterFullData, checkValFn, treeOpts)
3153
+ XEUtils.eachTree(afterFullData, checkValFn, { children: childrenField })
3150
3154
  } else {
3151
3155
  afterFullData.forEach(checkValFn)
3152
3156
  }
@@ -3165,7 +3169,7 @@ const Methods = {
3165
3169
  if (isForce || (!checkMethod || checkMethod({ row }))) {
3166
3170
  selectRows.push(row)
3167
3171
  }
3168
- }, treeOpts)
3172
+ }, { children: childrenField })
3169
3173
  } else {
3170
3174
  /**
3171
3175
  * 如果是树取消
@@ -3176,7 +3180,7 @@ const Methods = {
3176
3180
  if (checkMethod({ row }) ? 0 : this.findRowIndexOf(selectCheckboxRows, row) > -1) {
3177
3181
  selectRows.push(row)
3178
3182
  }
3179
- }, treeOpts)
3183
+ }, { children: childrenField })
3180
3184
  }
3181
3185
  }
3182
3186
  } else {
@@ -3332,6 +3336,7 @@ const Methods = {
3332
3336
  */
3333
3337
  getRadioReserveRecord (isFull) {
3334
3338
  const { fullDataRowIdData, radioReserveRow, radioOpts, afterFullData, treeConfig, treeOpts } = this
3339
+ const childrenField = treeOpts.children || treeOpts.childrenField
3335
3340
  if (radioOpts.reserve && radioReserveRow) {
3336
3341
  const rowid = getRowid(this, radioReserveRow)
3337
3342
  if (isFull) {
@@ -3341,7 +3346,7 @@ const Methods = {
3341
3346
  } else {
3342
3347
  const rowkey = getRowkey(this)
3343
3348
  if (treeConfig) {
3344
- const matchObj = XEUtils.findTree(afterFullData, row => rowid === XEUtils.get(row, rowkey), treeOpts)
3349
+ const matchObj = XEUtils.findTree(afterFullData, row => rowid === XEUtils.get(row, rowkey), { children: childrenField })
3345
3350
  if (matchObj) {
3346
3351
  return radioReserveRow
3347
3352
  }
@@ -3369,13 +3374,14 @@ const Methods = {
3369
3374
  */
3370
3375
  getCheckboxReserveRecords (isFull) {
3371
3376
  const { fullDataRowIdData, afterFullData, checkboxReserveRowMap, checkboxOpts, treeConfig, treeOpts } = this
3377
+ const childrenField = treeOpts.children || treeOpts.childrenField
3372
3378
  const reserveSelection = []
3373
3379
  if (checkboxOpts.reserve) {
3374
3380
  const afterFullIdMaps = {}
3375
3381
  if (treeConfig) {
3376
3382
  XEUtils.eachTree(afterFullData, row => {
3377
3383
  afterFullIdMaps[getRowid(this, row)] = 1
3378
- }, treeOpts)
3384
+ }, { children: childrenField })
3379
3385
  } else {
3380
3386
  afterFullData.forEach(row => {
3381
3387
  afterFullIdMaps[getRowid(this, row)] = 1
@@ -3433,6 +3439,7 @@ const Methods = {
3433
3439
  clearCheckboxRow () {
3434
3440
  const { tableFullData, treeConfig, treeOpts, checkboxOpts } = this
3435
3441
  const { checkField, reserve } = checkboxOpts
3442
+ const childrenField = treeOpts.children || treeOpts.childrenField
3436
3443
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
3437
3444
  if (checkField) {
3438
3445
  const handleClearChecked = (item) => {
@@ -3442,7 +3449,7 @@ const Methods = {
3442
3449
  XEUtils.set(item, checkField, false)
3443
3450
  }
3444
3451
  if (treeConfig) {
3445
- XEUtils.eachTree(tableFullData, handleClearChecked, treeOpts)
3452
+ XEUtils.eachTree(tableFullData, handleClearChecked, { children: childrenField })
3446
3453
  } else {
3447
3454
  tableFullData.forEach(handleClearChecked)
3448
3455
  }
@@ -3567,6 +3574,7 @@ const Methods = {
3567
3574
  */
3568
3575
  getRadioRecord (isFull) {
3569
3576
  const { treeConfig, treeOpts, selectRow, fullDataRowIdData, afterFullData } = this
3577
+ const childrenField = treeOpts.children || treeOpts.childrenField
3570
3578
  if (selectRow) {
3571
3579
  const rowid = getRowid(this, selectRow)
3572
3580
  if (isFull) {
@@ -3576,7 +3584,7 @@ const Methods = {
3576
3584
  } else {
3577
3585
  if (treeConfig) {
3578
3586
  const rowkey = getRowkey(this)
3579
- const matchObj = XEUtils.findTree(afterFullData, row => rowid === XEUtils.get(row, rowkey), treeOpts)
3587
+ const matchObj = XEUtils.findTree(afterFullData, row => rowid === XEUtils.get(row, rowkey), { children: childrenField })
3580
3588
  if (matchObj) {
3581
3589
  return selectRow
3582
3590
  }
@@ -4021,11 +4029,12 @@ const Methods = {
4021
4029
  */
4022
4030
  setAllRowExpand (expanded) {
4023
4031
  const { treeConfig, treeOpts, tableFullData, tableFullTreeData } = this
4032
+ const childrenField = treeOpts.children || treeOpts.childrenField
4024
4033
  let expandedRows = []
4025
4034
  if (treeConfig) {
4026
4035
  XEUtils.eachTree(tableFullTreeData, (row) => {
4027
4036
  expandedRows.push(row)
4028
- }, treeOpts)
4037
+ }, { children: childrenField })
4029
4038
  } else {
4030
4039
  expandedRows = tableFullData
4031
4040
  }
@@ -4229,13 +4238,14 @@ const Methods = {
4229
4238
  const { treeConfig, treeOpts, tableFullData } = this
4230
4239
  if (treeConfig) {
4231
4240
  const { expandAll, expandRowKeys } = treeOpts
4241
+ const childrenField = treeOpts.children || treeOpts.childrenField
4232
4242
  if (expandAll) {
4233
4243
  this.setAllTreeExpand(true)
4234
4244
  } else if (expandRowKeys) {
4235
4245
  const defExpandeds = []
4236
4246
  const rowkey = getRowkey(this)
4237
4247
  expandRowKeys.forEach(rowid => {
4238
- const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), treeOpts)
4248
+ const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
4239
4249
  if (matchObj) {
4240
4250
  defExpandeds.push(matchObj.item)
4241
4251
  }
@@ -4297,7 +4307,7 @@ const Methods = {
4297
4307
  if (lazy || (rowChildren && rowChildren.length)) {
4298
4308
  expandeds.push(row)
4299
4309
  }
4300
- }, treeOpts)
4310
+ }, { children: childrenField })
4301
4311
  return this.setTreeExpand(expandeds, expanded)
4302
4312
  },
4303
4313
  /**
@@ -4318,7 +4328,7 @@ const Methods = {
4318
4328
  if (accordion) {
4319
4329
  validRows = validRows.length ? [validRows[validRows.length - 1]] : []
4320
4330
  // 同一级只能展开一个
4321
- const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], treeOpts)
4331
+ const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
4322
4332
  if (matchObj) {
4323
4333
  XEUtils.remove(treeExpandeds, item => matchObj.items.indexOf(item) > -1)
4324
4334
  }
@@ -4398,10 +4408,11 @@ const Methods = {
4398
4408
  clearTreeExpand () {
4399
4409
  const { treeOpts, treeExpandeds, tableFullData } = this
4400
4410
  const { transform, reserve } = treeOpts
4411
+ const childrenField = treeOpts.children || treeOpts.childrenField
4401
4412
  const isExists = treeExpandeds.length
4402
4413
  this.treeExpandeds = []
4403
4414
  if (reserve) {
4404
- XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), treeOpts)
4415
+ XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), { children: childrenField })
4405
4416
  }
4406
4417
  return this.handleTableData().then(() => {
4407
4418
  if (transform) {
@@ -4678,9 +4689,10 @@ const Methods = {
4678
4689
  */
4679
4690
  scrollToTreeRow (row) {
4680
4691
  const { tableFullData, treeConfig, treeOpts } = this
4692
+ const childrenField = treeOpts.children || treeOpts.childrenField
4681
4693
  const rests = []
4682
4694
  if (treeConfig) {
4683
- const matchObj = XEUtils.findTree(tableFullData, item => item === row, treeOpts)
4695
+ const matchObj = XEUtils.findTree(tableFullData, item => item === row, { children: childrenField })
4684
4696
  if (matchObj) {
4685
4697
  const nodes = matchObj.nodes
4686
4698
  nodes.forEach((row, index) => {
@@ -112,6 +112,7 @@ export default {
112
112
  beginValidate (rows, cb, isFull) {
113
113
  const validRest = {}
114
114
  const { editRules, afterFullData, treeConfig, treeOpts } = this
115
+ const childrenField = treeOpts.children || treeOpts.childrenField
115
116
  let vaildDatas
116
117
  if (rows === true) {
117
118
  vaildDatas = afterFullData
@@ -165,7 +166,7 @@ export default {
165
166
  }
166
167
  }
167
168
  if (treeConfig) {
168
- XEUtils.eachTree(vaildDatas, handleVaild, treeOpts)
169
+ XEUtils.eachTree(vaildDatas, handleVaild, { children: childrenField })
169
170
  } else {
170
171
  vaildDatas.forEach(handleVaild)
171
172
  }
@@ -108,7 +108,7 @@ export interface VXETableCore {
108
108
  }
109
109
 
110
110
  /**
111
- * 一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式为低/零代码而设计...
111
+ * 一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...
112
112
  */
113
113
  export const VXETable: VXETableCore
114
114