vxe-table 3.4.6 → 3.4.7
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.
- package/lib/button/src/button.js +15 -14
- package/lib/button/src/button.min.js +1 -1
- package/lib/edit/src/mixin.js +19 -25
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/export/src/mixin.js +4 -10
- package/lib/export/src/mixin.min.js +1 -1
- package/lib/filter/src/mixin.js +25 -1
- package/lib/filter/src/mixin.min.js +1 -1
- package/lib/index.umd.js +734 -445
- package/lib/index.umd.min.js +1 -1
- package/lib/select/src/select.js +1 -1
- package/lib/select/src/select.min.js +1 -1
- package/lib/table/src/body.js +9 -17
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +16 -17
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +567 -346
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/util.js +7 -0
- package/lib/table/src/util.min.js +1 -1
- package/lib/tools/src/dom.js +2 -9
- package/lib/tools/src/dom.min.js +1 -1
- package/lib/tools/src/utils.js +1 -1
- package/lib/tools/src/utils.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +2 -1
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/lib/validator/src/mixin.js +1 -1
- package/lib/validator/src/mixin.min.js +1 -1
- package/package.json +3 -4
- package/packages/button/src/button.js +14 -14
- package/packages/edit/src/mixin.js +18 -21
- package/packages/export/src/mixin.js +4 -7
- package/packages/filter/src/mixin.js +20 -1
- package/packages/select/src/select.js +1 -1
- package/packages/table/src/body.js +12 -16
- package/packages/table/src/cell.js +15 -15
- package/packages/table/src/methods.js +173 -51
- package/packages/table/src/util.js +4 -0
- package/packages/tools/src/dom.js +2 -7
- package/packages/tools/src/utils.js +1 -1
- package/packages/v-x-e-table/src/conf.js +2 -1
- package/packages/validator/src/mixin.js +1 -1
- package/types/table.d.ts +1 -0
|
@@ -3,7 +3,7 @@ import GlobalConfig from '../../v-x-e-table/src/conf'
|
|
|
3
3
|
import Cell from './cell'
|
|
4
4
|
import VXETable from '../../v-x-e-table'
|
|
5
5
|
import { UtilTools, DomTools } from '../../tools'
|
|
6
|
-
import { clearTableAllStatus, handleFieldOrColumn, restoreScrollLocation, restoreScrollListener } from './util'
|
|
6
|
+
import { clearTableAllStatus, handleFieldOrColumn, restoreScrollLocation, restoreScrollListener, toTreePathSeq } from './util'
|
|
7
7
|
import { eqEmptyValue, isEnableConf } from '../../tools/src/utils'
|
|
8
8
|
import { browse, getPaddingTopBottomSize, setScrollTop, setScrollLeft } from '../../tools/src/dom'
|
|
9
9
|
import { formats } from '../../v-x-e-table/src/formats'
|
|
@@ -283,7 +283,7 @@ const Methods = {
|
|
|
283
283
|
return clearTableAllStatus(this)
|
|
284
284
|
},
|
|
285
285
|
/**
|
|
286
|
-
* 同步 data
|
|
286
|
+
* 同步 data 数据(即将废弃)
|
|
287
287
|
* 如果用了该方法,那么组件将不再记录增删改的状态,只能自行实现对应逻辑
|
|
288
288
|
* 对于某些特殊的场景,比如深层树节点元素发生变动时可能会用到
|
|
289
289
|
*/
|
|
@@ -301,9 +301,33 @@ const Methods = {
|
|
|
301
301
|
return this.handleTableData(true).then(this.updateFooter).then(this.recalculate)
|
|
302
302
|
},
|
|
303
303
|
handleTableData (force) {
|
|
304
|
-
const { scrollYLoad, scrollYStore } = this
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
const { treeConfig, scrollYLoad, scrollYStore, fullDataRowIdData, treeExpandeds, treeOpts } = this
|
|
305
|
+
let fullList = []
|
|
306
|
+
// 是否进行数据处理
|
|
307
|
+
if (force) {
|
|
308
|
+
this.updateAfterFullData()
|
|
309
|
+
}
|
|
310
|
+
// 如果为虚拟树,将树结构拍平
|
|
311
|
+
if (treeConfig && treeOpts.transform) {
|
|
312
|
+
const expandMaps = new Map()
|
|
313
|
+
XEUtils.eachTree(this.afterTreeFullData, (row, index, items, path, parent) => {
|
|
314
|
+
if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
|
|
315
|
+
expandMaps.set(row, 1)
|
|
316
|
+
fullList.push(row)
|
|
317
|
+
}
|
|
318
|
+
}, { children: treeOpts.mapChildren })
|
|
319
|
+
} else {
|
|
320
|
+
fullList = this.afterFullData
|
|
321
|
+
}
|
|
322
|
+
const tableData = scrollYLoad ? fullList.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullList.slice(0)
|
|
323
|
+
tableData.forEach((row, $index) => {
|
|
324
|
+
const rowid = getRowid(this, row)
|
|
325
|
+
const rest = fullDataRowIdData[rowid]
|
|
326
|
+
if (rest) {
|
|
327
|
+
rest.$index = $index
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
this.tableData = tableData
|
|
307
331
|
return this.$nextTick()
|
|
308
332
|
},
|
|
309
333
|
updateScrollYStatus (fullData) {
|
|
@@ -334,13 +358,24 @@ const Methods = {
|
|
|
334
358
|
if (!treeOpts.children) {
|
|
335
359
|
UtilTools.error('vxe.error.reqProp', ['tree-config.children'])
|
|
336
360
|
}
|
|
361
|
+
if (!treeOpts.mapChildren) {
|
|
362
|
+
UtilTools.error('vxe.error.reqProp', ['tree-config.mapChildren'])
|
|
363
|
+
}
|
|
364
|
+
if (treeOpts.children === treeOpts.mapChildren) {
|
|
365
|
+
UtilTools.error('vxe.error.errConflicts', ['tree-config.children', 'tree-config.mapChildren'])
|
|
366
|
+
}
|
|
337
367
|
fullData.forEach(row => {
|
|
338
368
|
if (row[treeOpts.children] && row[treeOpts.children].length) {
|
|
339
369
|
UtilTools.warn('vxe.error.errConflicts', ['tree-config.transform', `row.${treeOpts.children}`])
|
|
340
370
|
}
|
|
341
371
|
})
|
|
342
372
|
}
|
|
343
|
-
treeData = XEUtils.toArrayTree(fullData, {
|
|
373
|
+
treeData = XEUtils.toArrayTree(fullData, {
|
|
374
|
+
key: treeOpts.rowField,
|
|
375
|
+
parentKey: treeOpts.parentField,
|
|
376
|
+
children: treeOpts.children,
|
|
377
|
+
mapChildren: treeOpts.mapChildren
|
|
378
|
+
})
|
|
344
379
|
fullData = treeData.slice(0)
|
|
345
380
|
} else {
|
|
346
381
|
treeData = fullData.slice(0)
|
|
@@ -356,7 +391,7 @@ const Methods = {
|
|
|
356
391
|
this.scrollYLoad = sYLoad
|
|
357
392
|
// 全量数据
|
|
358
393
|
this.tableFullData = fullData
|
|
359
|
-
this.
|
|
394
|
+
this.tableFullTreeData = treeData
|
|
360
395
|
// 缓存数据
|
|
361
396
|
this.cacheRowMap(true)
|
|
362
397
|
// 原始数据
|
|
@@ -530,12 +565,14 @@ const Methods = {
|
|
|
530
565
|
* 牺牲数据组装的耗时,用来换取使用过程中的流畅
|
|
531
566
|
*/
|
|
532
567
|
cacheRowMap (source) {
|
|
533
|
-
const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap } = this
|
|
568
|
+
const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap, tableFullTreeData } = this
|
|
534
569
|
let { fullDataRowIdData, fullAllDataRowIdData } = this
|
|
535
570
|
const rowkey = getRowkey(this)
|
|
536
571
|
const isLazy = treeConfig && treeOpts.lazy
|
|
537
572
|
const handleCache = (row, index, items, path, parent, nodes) => {
|
|
538
573
|
let rowid = getRowid(this, row)
|
|
574
|
+
const seq = treeConfig && path ? toTreePathSeq(path) : index + 1
|
|
575
|
+
const level = nodes ? nodes.length - 1 : 0
|
|
539
576
|
if (eqEmptyValue(rowid)) {
|
|
540
577
|
rowid = getRowUniqueId()
|
|
541
578
|
XEUtils.set(row, rowkey, rowid)
|
|
@@ -543,7 +580,7 @@ const Methods = {
|
|
|
543
580
|
if (isLazy && row[treeOpts.hasChild] && XEUtils.isUndefined(row[treeOpts.children])) {
|
|
544
581
|
row[treeOpts.children] = null
|
|
545
582
|
}
|
|
546
|
-
const rest = { row, rowid, index: treeConfig && parent ? -1 : index,
|
|
583
|
+
const rest = { row, rowid, seq, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items, parent, level }
|
|
547
584
|
if (source) {
|
|
548
585
|
fullDataRowIdData[rowid] = rest
|
|
549
586
|
fullDataRowMap.set(row, rest)
|
|
@@ -558,14 +595,14 @@ const Methods = {
|
|
|
558
595
|
fullAllDataRowIdData = this.fullAllDataRowIdData = {}
|
|
559
596
|
fullAllDataRowMap.clear()
|
|
560
597
|
if (treeConfig) {
|
|
561
|
-
XEUtils.eachTree(
|
|
598
|
+
XEUtils.eachTree(tableFullTreeData, handleCache, treeOpts)
|
|
562
599
|
} else {
|
|
563
600
|
tableFullData.forEach(handleCache)
|
|
564
601
|
}
|
|
565
602
|
},
|
|
566
603
|
loadTreeChildren (row, childRecords) {
|
|
567
604
|
const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData } = this
|
|
568
|
-
const { children } = treeOpts
|
|
605
|
+
const { transform, children, mapChildren } = treeOpts
|
|
569
606
|
const rest = fullAllDataRowIdData[getRowid(this, row)]
|
|
570
607
|
const parentLevel = rest ? rest.level : 0
|
|
571
608
|
return this.createData(childRecords).then((rows) => {
|
|
@@ -578,13 +615,16 @@ const Methods = {
|
|
|
578
615
|
}
|
|
579
616
|
XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
|
|
580
617
|
const rowid = getRowid(this, childRow)
|
|
581
|
-
const rest = { row: childRow, rowid, index: -1, items, parent, level: parentLevel + nodes.length }
|
|
618
|
+
const rest = { row: childRow, rowid, seq: -1, index: -1, _index: -1, $index: -1, items, parent, level: parentLevel + nodes.length }
|
|
582
619
|
fullDataRowIdData[rowid] = rest
|
|
583
620
|
fullDataRowMap.set(childRow, rest)
|
|
584
621
|
fullAllDataRowIdData[rowid] = rest
|
|
585
622
|
fullAllDataRowMap.set(childRow, rest)
|
|
586
623
|
}, treeOpts)
|
|
587
624
|
row[children] = rows
|
|
625
|
+
if (transform) {
|
|
626
|
+
row[mapChildren] = rows
|
|
627
|
+
}
|
|
588
628
|
return rows
|
|
589
629
|
})
|
|
590
630
|
},
|
|
@@ -724,6 +764,21 @@ const Methods = {
|
|
|
724
764
|
}
|
|
725
765
|
return null
|
|
726
766
|
},
|
|
767
|
+
/**
|
|
768
|
+
* 根据 row 获取序号
|
|
769
|
+
* @param {Row} row 行对象
|
|
770
|
+
*/
|
|
771
|
+
getRowSeq (row) {
|
|
772
|
+
const { fullDataRowIdData } = this
|
|
773
|
+
if (row) {
|
|
774
|
+
const rowid = getRowid(this, row)
|
|
775
|
+
const rest = fullDataRowIdData[rowid]
|
|
776
|
+
if (rest) {
|
|
777
|
+
return rest.seq
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return -1
|
|
781
|
+
},
|
|
727
782
|
/**
|
|
728
783
|
* 根据 row 获取相对于 data 中的索引
|
|
729
784
|
* @param {Row} row 行对象
|
|
@@ -1061,10 +1116,12 @@ const Methods = {
|
|
|
1061
1116
|
* 如果存在筛选条件,继续处理
|
|
1062
1117
|
*/
|
|
1063
1118
|
updateAfterFullData () {
|
|
1064
|
-
const { tableFullColumn, tableFullData, filterOpts, sortOpts } = this
|
|
1119
|
+
const { tableFullColumn, tableFullData, filterOpts, sortOpts, treeConfig, treeOpts, tableFullTreeData } = this
|
|
1065
1120
|
const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
1066
1121
|
const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple } = sortOpts
|
|
1067
|
-
|
|
1122
|
+
const { transform } = treeOpts
|
|
1123
|
+
let tableData = []
|
|
1124
|
+
let tableTree = []
|
|
1068
1125
|
const filterColumns = []
|
|
1069
1126
|
const orderColumns = []
|
|
1070
1127
|
tableFullColumn.forEach(column => {
|
|
@@ -1087,7 +1144,7 @@ const Methods = {
|
|
|
1087
1144
|
}
|
|
1088
1145
|
})
|
|
1089
1146
|
if (filterColumns.length) {
|
|
1090
|
-
|
|
1147
|
+
const handleFilter = (row) => {
|
|
1091
1148
|
return filterColumns.every(({ column, valueList, itemList }) => {
|
|
1092
1149
|
if (valueList.length && !allRemoteFilter) {
|
|
1093
1150
|
const { filterMethod, filterRender } = column
|
|
@@ -1108,29 +1165,103 @@ const Methods = {
|
|
|
1108
1165
|
}
|
|
1109
1166
|
return true
|
|
1110
1167
|
})
|
|
1111
|
-
}
|
|
1168
|
+
}
|
|
1169
|
+
if (treeConfig && transform) {
|
|
1170
|
+
// 筛选虚拟树
|
|
1171
|
+
tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, { ...treeOpts, original: true })
|
|
1172
|
+
tableData = tableTree
|
|
1173
|
+
} else {
|
|
1174
|
+
tableData = treeConfig ? tableFullTreeData.filter(handleFilter) : tableFullData.filter(handleFilter)
|
|
1175
|
+
tableTree = tableData
|
|
1176
|
+
}
|
|
1177
|
+
} else {
|
|
1178
|
+
if (treeConfig && transform) {
|
|
1179
|
+
// 还原虚拟树
|
|
1180
|
+
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, { ...treeOpts, original: true })
|
|
1181
|
+
tableData = tableTree
|
|
1182
|
+
} else {
|
|
1183
|
+
tableData = treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0)
|
|
1184
|
+
tableTree = tableData
|
|
1185
|
+
}
|
|
1112
1186
|
}
|
|
1113
1187
|
const firstOrderColumn = orderColumns[0]
|
|
1114
1188
|
if (!allRemoteSort && firstOrderColumn) {
|
|
1115
|
-
if (
|
|
1116
|
-
|
|
1117
|
-
|
|
1189
|
+
if (treeConfig && transform) {
|
|
1190
|
+
// 虚拟树和列表一样,只能排序根级节点
|
|
1191
|
+
if (allSortMethod) {
|
|
1192
|
+
const sortRests = allSortMethod({ data: tableTree, sortList: orderColumns, $table: this })
|
|
1193
|
+
tableTree = XEUtils.isArray(sortRests) ? sortRests : tableTree
|
|
1194
|
+
} else {
|
|
1195
|
+
tableTree = XEUtils.orderBy(tableTree, orderColumns.map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1196
|
+
}
|
|
1197
|
+
tableData = tableTree
|
|
1118
1198
|
} else {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
tableData = XEUtils.
|
|
1199
|
+
if (allSortMethod) {
|
|
1200
|
+
const sortRests = allSortMethod({ data: tableData, column: firstOrderColumn.column, property: firstOrderColumn.property, order: firstOrderColumn.order, sortList: orderColumns, $table: this })
|
|
1201
|
+
tableData = XEUtils.isArray(sortRests) ? sortRests : tableData
|
|
1122
1202
|
} else {
|
|
1123
|
-
// 兼容
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1203
|
+
// 兼容 v4
|
|
1204
|
+
if (sortMultiple) {
|
|
1205
|
+
tableData = XEUtils.orderBy(tableData, orderColumns.map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1206
|
+
} else {
|
|
1207
|
+
// 兼容 v2,在 v4 中废弃, sortBy 不能为数组
|
|
1208
|
+
let sortByConfs
|
|
1209
|
+
if (XEUtils.isArray(firstOrderColumn.sortBy)) {
|
|
1210
|
+
sortByConfs = firstOrderColumn.sortBy.map(item => [item, firstOrderColumn.order])
|
|
1211
|
+
}
|
|
1212
|
+
tableData = XEUtils.orderBy(tableData, sortByConfs || [firstOrderColumn].map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1127
1213
|
}
|
|
1128
|
-
tableData = XEUtils.orderBy(tableData, sortByConfs || [firstOrderColumn].map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1129
1214
|
}
|
|
1215
|
+
tableTree = tableData
|
|
1130
1216
|
}
|
|
1131
1217
|
}
|
|
1132
1218
|
this.afterFullData = tableData
|
|
1133
|
-
|
|
1219
|
+
this.afterTreeFullData = tableTree
|
|
1220
|
+
this.updateAfterDataIndex()
|
|
1221
|
+
},
|
|
1222
|
+
/**
|
|
1223
|
+
* 预编译
|
|
1224
|
+
* 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
|
|
1225
|
+
*/
|
|
1226
|
+
updateAfterDataIndex () {
|
|
1227
|
+
const { treeConfig, afterFullData, fullDataRowIdData, fullAllDataRowIdData, afterTreeFullData, treeOpts } = this
|
|
1228
|
+
if (treeConfig) {
|
|
1229
|
+
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
1230
|
+
const rowid = getRowid(this, row)
|
|
1231
|
+
const allrest = fullAllDataRowIdData[rowid]
|
|
1232
|
+
const fullrest = fullDataRowIdData[rowid]
|
|
1233
|
+
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
1234
|
+
if (allrest) {
|
|
1235
|
+
allrest.seq = seq
|
|
1236
|
+
allrest._index = index
|
|
1237
|
+
}
|
|
1238
|
+
if (fullrest) {
|
|
1239
|
+
fullrest.seq = seq
|
|
1240
|
+
fullrest._index = index
|
|
1241
|
+
} else {
|
|
1242
|
+
fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1243
|
+
fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1244
|
+
}
|
|
1245
|
+
}, { children: treeOpts.mapChildren })
|
|
1246
|
+
} else {
|
|
1247
|
+
afterFullData.forEach((row, index) => {
|
|
1248
|
+
const rowid = getRowid(this, row)
|
|
1249
|
+
const allrest = fullAllDataRowIdData[rowid]
|
|
1250
|
+
const fullrest = fullDataRowIdData[rowid]
|
|
1251
|
+
const seq = index + 1
|
|
1252
|
+
if (allrest) {
|
|
1253
|
+
allrest.seq = seq
|
|
1254
|
+
allrest._index = index
|
|
1255
|
+
}
|
|
1256
|
+
if (fullrest) {
|
|
1257
|
+
fullrest.seq = seq
|
|
1258
|
+
fullrest._index = index
|
|
1259
|
+
} else {
|
|
1260
|
+
fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1261
|
+
fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1262
|
+
}
|
|
1263
|
+
})
|
|
1264
|
+
}
|
|
1134
1265
|
},
|
|
1135
1266
|
/**
|
|
1136
1267
|
* 根据行的唯一主键获取行
|
|
@@ -3696,7 +3827,7 @@ const Methods = {
|
|
|
3696
3827
|
return this.handleAsyncTreeExpandChilds(row)
|
|
3697
3828
|
}).then(() => {
|
|
3698
3829
|
if (transform) {
|
|
3699
|
-
return this.
|
|
3830
|
+
return this.handleTableData()
|
|
3700
3831
|
}
|
|
3701
3832
|
}).then(() => {
|
|
3702
3833
|
return this.recalculate()
|
|
@@ -3756,7 +3887,7 @@ const Methods = {
|
|
|
3756
3887
|
},
|
|
3757
3888
|
handleAsyncTreeExpandChilds (row) {
|
|
3758
3889
|
const { fullAllDataRowMap, treeExpandeds, treeOpts, treeLazyLoadeds, checkboxOpts } = this
|
|
3759
|
-
const { loadMethod } = treeOpts
|
|
3890
|
+
const { transform, loadMethod } = treeOpts
|
|
3760
3891
|
const { checkStrictly } = checkboxOpts
|
|
3761
3892
|
const rest = fullAllDataRowMap.get(row)
|
|
3762
3893
|
return new Promise(resolve => {
|
|
@@ -3776,9 +3907,17 @@ const Methods = {
|
|
|
3776
3907
|
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
3777
3908
|
this.setCheckboxRow(childRows, true)
|
|
3778
3909
|
}
|
|
3910
|
+
this.$nextTick().then(() => {
|
|
3911
|
+
if (transform) {
|
|
3912
|
+
return this.handleTableData()
|
|
3913
|
+
}
|
|
3914
|
+
}).then(() => {
|
|
3915
|
+
return this.recalculate()
|
|
3916
|
+
}).then(() => resolve())
|
|
3779
3917
|
})
|
|
3918
|
+
} else {
|
|
3919
|
+
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
3780
3920
|
}
|
|
3781
|
-
resolve(this.$nextTick().then(this.recalculate))
|
|
3782
3921
|
})
|
|
3783
3922
|
})
|
|
3784
3923
|
},
|
|
@@ -3842,23 +3981,6 @@ const Methods = {
|
|
|
3842
3981
|
}
|
|
3843
3982
|
return Promise.all(result).then(this.recalculate)
|
|
3844
3983
|
},
|
|
3845
|
-
updateVirtualTreeData () {
|
|
3846
|
-
const { scrollYLoad: oldScrollYLoad, treeExpandeds, treeOpts, treeFullData } = this
|
|
3847
|
-
const fullData = []
|
|
3848
|
-
const expandMaps = new Map()
|
|
3849
|
-
XEUtils.eachTree(treeFullData, (row, index, items, path, parent) => {
|
|
3850
|
-
if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
|
|
3851
|
-
expandMaps.set(row, 1)
|
|
3852
|
-
fullData.push(row)
|
|
3853
|
-
}
|
|
3854
|
-
}, treeOpts)
|
|
3855
|
-
const scrollYLoad = this.updateScrollYStatus(fullData)
|
|
3856
|
-
this.tableFullData = scrollYLoad ? fullData : treeFullData
|
|
3857
|
-
if (scrollYLoad || oldScrollYLoad !== scrollYLoad) {
|
|
3858
|
-
return this.handleTableData(true).then(() => this.recalculate())
|
|
3859
|
-
}
|
|
3860
|
-
return this.$nextTick()
|
|
3861
|
-
},
|
|
3862
3984
|
/**
|
|
3863
3985
|
* 虚拟树的展开与收起
|
|
3864
3986
|
* @param rows
|
|
@@ -3867,7 +3989,7 @@ const Methods = {
|
|
|
3867
3989
|
*/
|
|
3868
3990
|
handleVirtualTreeExpand (rows, expanded) {
|
|
3869
3991
|
return this.handleBaseTreeExpand(rows, expanded).then(() => {
|
|
3870
|
-
return this.
|
|
3992
|
+
return this.handleTableData()
|
|
3871
3993
|
}).then(() => {
|
|
3872
3994
|
return this.recalculate()
|
|
3873
3995
|
})
|
|
@@ -3915,7 +4037,7 @@ const Methods = {
|
|
|
3915
4037
|
if (reserve) {
|
|
3916
4038
|
XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), treeOpts)
|
|
3917
4039
|
}
|
|
3918
|
-
return this.
|
|
4040
|
+
return this.handleTableData().then(() => {
|
|
3919
4041
|
if (isExists) {
|
|
3920
4042
|
this.recalculate()
|
|
3921
4043
|
}
|
|
@@ -4424,7 +4546,7 @@ const Methods = {
|
|
|
4424
4546
|
}
|
|
4425
4547
|
|
|
4426
4548
|
// Module methods
|
|
4427
|
-
const funcs = 'setFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,clearCopyCellArea,setCellAreas,openFind,openReplace,getSelectedCell,clearSelected,insert,insertAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearActived,getActiveRecord,isActiveByRow,setActiveRow,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',')
|
|
4549
|
+
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,clearCopyCellArea,setCellAreas,openFind,openReplace,getSelectedCell,clearSelected,insert,insertAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearActived,getActiveRecord,isActiveByRow,setActiveRow,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',')
|
|
4428
4550
|
|
|
4429
4551
|
funcs.forEach(name => {
|
|
4430
4552
|
Methods[name] = function (...args) {
|
|
@@ -20,6 +20,10 @@ export function restoreScrollLocation (_vm, scrollLeft, scrollTop) {
|
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export function toTreePathSeq (path) {
|
|
24
|
+
return path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
export function removeScrollListener (scrollElem) {
|
|
24
28
|
if (scrollElem && scrollElem._onscroll) {
|
|
25
29
|
scrollElem.onscroll = null
|
|
@@ -204,14 +204,9 @@ export const DomTools = {
|
|
|
204
204
|
}
|
|
205
205
|
},
|
|
206
206
|
triggerEvent (targetElem, type) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
evnt = new Event(type)
|
|
210
|
-
} else {
|
|
211
|
-
evnt = document.createEvent('Event')
|
|
212
|
-
evnt.initEvent(type, true, true)
|
|
207
|
+
if (targetElem) {
|
|
208
|
+
targetElem.dispatchEvent(new Event(type))
|
|
213
209
|
}
|
|
214
|
-
targetElem.dispatchEvent(evnt)
|
|
215
210
|
},
|
|
216
211
|
calcHeight ($xetable, key) {
|
|
217
212
|
const val = $xetable[key]
|
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
// storage: false,
|
|
50
50
|
// checkMethod () {}
|
|
51
51
|
// },
|
|
52
|
-
// rowId: '
|
|
52
|
+
// rowId: '_X_ID', // 行数据的唯一主键字段名
|
|
53
53
|
sortConfig: {
|
|
54
54
|
// remote: false,
|
|
55
55
|
// trigger: 'default',
|
|
@@ -67,6 +67,7 @@ export default {
|
|
|
67
67
|
parentField: 'parentId',
|
|
68
68
|
children: 'children',
|
|
69
69
|
hasChild: 'hasChild',
|
|
70
|
+
mapChildren: '_X_CHILD',
|
|
70
71
|
indent: 20,
|
|
71
72
|
showIcon: true
|
|
72
73
|
},
|