vxe-table 3.4.7-beta.0 → 3.4.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.
- package/lib/edit/src/mixin.js +14 -25
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/export/src/mixin.js +4 -8
- package/lib/export/src/mixin.min.js +1 -1
- package/lib/filter/src/mixin.js +1 -1
- package/lib/filter/src/mixin.min.js +1 -1
- package/lib/index.umd.js +515 -345
- 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 +1 -1
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/methods.js +436 -308
- package/lib/table/src/methods.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/edit/src/mixin.js +14 -19
- package/packages/export/src/mixin.js +5 -8
- package/packages/filter/src/mixin.js +1 -1
- package/packages/select/src/select.js +1 -1
- package/packages/table/src/body.js +1 -1
- package/packages/table/src/methods.js +136 -52
- 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
|
@@ -6,12 +6,12 @@ import { browse } from '../../tools/src/dom'
|
|
|
6
6
|
const { getRowid } = UtilTools
|
|
7
7
|
|
|
8
8
|
function insertTreeRow (_vm, newRecords, isAppend) {
|
|
9
|
-
const {
|
|
9
|
+
const { tableFullTreeData, afterFullData, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
|
|
10
10
|
const funcName = isAppend ? 'push' : 'unshift'
|
|
11
11
|
newRecords.forEach(item => {
|
|
12
12
|
const parentRowId = item[treeOpts.parentField]
|
|
13
13
|
const rowid = getRowid(_vm, item)
|
|
14
|
-
const matchObj = parentRowId ? XEUtils.findTree(
|
|
14
|
+
const matchObj = parentRowId ? XEUtils.findTree(tableFullTreeData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
|
|
15
15
|
if (matchObj) {
|
|
16
16
|
const { item: parentRow } = matchObj
|
|
17
17
|
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
|
|
@@ -31,13 +31,12 @@ function insertTreeRow (_vm, newRecords, isAppend) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
afterFullData[funcName](item)
|
|
34
|
-
|
|
35
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items:
|
|
34
|
+
tableFullTreeData[funcName](item)
|
|
35
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: tableFullTreeData, parent: null, level: 0 }
|
|
36
36
|
fullDataRowIdData[rowid] = rest
|
|
37
37
|
fullAllDataRowIdData[rowid] = rest
|
|
38
38
|
}
|
|
39
39
|
})
|
|
40
|
-
_vm.updateVirtualTreeData()
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export default {
|
|
@@ -59,7 +58,7 @@ export default {
|
|
|
59
58
|
* @param {Row} row 指定行
|
|
60
59
|
*/
|
|
61
60
|
_insertAt (records, row) {
|
|
62
|
-
const {
|
|
61
|
+
const { tableFullTreeData, mergeList, afterFullData, editStore, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = this
|
|
63
62
|
const { transform } = treeOpts
|
|
64
63
|
if (!XEUtils.isArray(records)) {
|
|
65
64
|
records = [records]
|
|
@@ -99,7 +98,7 @@ export default {
|
|
|
99
98
|
} else {
|
|
100
99
|
// 如果为虚拟树
|
|
101
100
|
if (treeConfig && transform) {
|
|
102
|
-
const matchObj = XEUtils.findTree(
|
|
101
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
|
|
103
102
|
if (matchObj) {
|
|
104
103
|
const { parent: parentRow } = matchObj
|
|
105
104
|
const parentChilds = matchObj.items
|
|
@@ -122,7 +121,6 @@ export default {
|
|
|
122
121
|
fullDataRowIdData[rowid] = rest
|
|
123
122
|
fullAllDataRowIdData[rowid] = rest
|
|
124
123
|
})
|
|
125
|
-
this.updateVirtualTreeData()
|
|
126
124
|
} else {
|
|
127
125
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
128
126
|
UtilTools.warn('vxe.error.unableInsert')
|
|
@@ -152,13 +150,12 @@ export default {
|
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
editStore.insertList.unshift(...newRecords)
|
|
155
|
-
this.
|
|
156
|
-
this.handleTableData(transform)
|
|
153
|
+
this.handleTableData(treeConfig && treeOpts.transform)
|
|
157
154
|
this.updateFooter()
|
|
158
155
|
this.cacheRowMap()
|
|
159
156
|
this.updateAfterDataIndex()
|
|
160
157
|
this.checkSelectionStatus()
|
|
161
|
-
if (scrollYLoad) {
|
|
158
|
+
if (this.scrollYLoad) {
|
|
162
159
|
this.updateScrollYSpace()
|
|
163
160
|
}
|
|
164
161
|
return this.$nextTick().then(() => {
|
|
@@ -178,7 +175,7 @@ export default {
|
|
|
178
175
|
* 如果为空则删除所有
|
|
179
176
|
*/
|
|
180
177
|
_remove (rows) {
|
|
181
|
-
const { afterFullData, tableFullData,
|
|
178
|
+
const { afterFullData, tableFullData, tableFullTreeData, treeConfig, mergeList, editStore, checkboxOpts, selection, isInsertByRow, treeOpts } = this
|
|
182
179
|
const { transform } = treeOpts
|
|
183
180
|
const { actived, removeList, insertList } = editStore
|
|
184
181
|
const { checkField: property } = checkboxOpts
|
|
@@ -214,7 +211,7 @@ export default {
|
|
|
214
211
|
if (treeConfig && transform) {
|
|
215
212
|
rows.forEach((row) => {
|
|
216
213
|
const rowid = getRowid(this, row)
|
|
217
|
-
const matchObj = XEUtils.findTree(
|
|
214
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), treeOpts)
|
|
218
215
|
if (matchObj) {
|
|
219
216
|
const rItems = matchObj.items.splice(matchObj.index, 1)
|
|
220
217
|
rest.push(rItems[0])
|
|
@@ -223,7 +220,6 @@ export default {
|
|
|
223
220
|
if (afIndex > -1) {
|
|
224
221
|
afterFullData.splice(afIndex, 1)
|
|
225
222
|
}
|
|
226
|
-
this.updateVirtualTreeData()
|
|
227
223
|
})
|
|
228
224
|
} else {
|
|
229
225
|
rows.forEach(row => {
|
|
@@ -259,13 +255,12 @@ export default {
|
|
|
259
255
|
insertList.splice(iIndex, 1)
|
|
260
256
|
}
|
|
261
257
|
})
|
|
262
|
-
this.
|
|
263
|
-
this.handleTableData(transform)
|
|
258
|
+
this.handleTableData(treeConfig && treeOpts.transform)
|
|
264
259
|
this.updateFooter()
|
|
265
260
|
this.cacheRowMap()
|
|
266
261
|
this.updateAfterDataIndex()
|
|
267
262
|
this.checkSelectionStatus()
|
|
268
|
-
if (scrollYLoad) {
|
|
263
|
+
if (this.scrollYLoad) {
|
|
269
264
|
this.updateScrollYSpace()
|
|
270
265
|
}
|
|
271
266
|
return this.$nextTick().then(() => {
|
|
@@ -318,7 +313,7 @@ export default {
|
|
|
318
313
|
* 获取新增的临时数据
|
|
319
314
|
*/
|
|
320
315
|
_getInsertRecords () {
|
|
321
|
-
const { treeConfig,
|
|
316
|
+
const { treeConfig, tableFullTreeData, tableFullData, treeOpts } = this
|
|
322
317
|
const insertList = this.editStore.insertList
|
|
323
318
|
const insertRecords = []
|
|
324
319
|
if (insertList.length) {
|
|
@@ -326,7 +321,7 @@ export default {
|
|
|
326
321
|
if (treeConfig && treeOpts.transform) {
|
|
327
322
|
insertList.forEach(row => {
|
|
328
323
|
const rowid = getRowid(this, row)
|
|
329
|
-
const matchObj = XEUtils.findTree(
|
|
324
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), treeOpts)
|
|
330
325
|
if (matchObj) {
|
|
331
326
|
insertRecords.push(row)
|
|
332
327
|
}
|
|
@@ -2,7 +2,7 @@ import XEUtils from 'xe-utils'
|
|
|
2
2
|
import GlobalConfig from '../../v-x-e-table/src/conf'
|
|
3
3
|
import VXETable from '../../v-x-e-table'
|
|
4
4
|
import { UtilTools } from '../../tools'
|
|
5
|
-
import { mergeBodyMethod
|
|
5
|
+
import { mergeBodyMethod } from '../../table/src/util'
|
|
6
6
|
import { browse } from '../../tools/src/dom'
|
|
7
7
|
|
|
8
8
|
const { formatText } = UtilTools
|
|
@@ -40,16 +40,13 @@ function hasTreeChildren ($xetable, row) {
|
|
|
40
40
|
return row[treeOpts.children] && row[treeOpts.children].length > 0
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function getSeq ($xetable, row, rowIndex, column, columnIndex
|
|
43
|
+
function getSeq ($xetable, row, rowIndex, column, columnIndex) {
|
|
44
44
|
const seqOpts = $xetable.seqOpts
|
|
45
45
|
const seqMethod = seqOpts.seqMethod || column.seqMethod
|
|
46
46
|
if (seqMethod) {
|
|
47
47
|
return seqMethod({ row, rowIndex, column, columnIndex })
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
return toTreePathSeq(path)
|
|
51
|
-
}
|
|
52
|
-
return seqOpts.startIndex + rowIndex + 1
|
|
49
|
+
return $xetable.getRowSeq(row)
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
function defaultFilterExportColumn (column) {
|
|
@@ -106,7 +103,7 @@ function getLabelData ($xetable, opts, columns, datas) {
|
|
|
106
103
|
} else {
|
|
107
104
|
switch (column.type) {
|
|
108
105
|
case 'seq':
|
|
109
|
-
cellValue = getSeq($xetable, row, rowIndex, column, columnIndex
|
|
106
|
+
cellValue = getSeq($xetable, row, rowIndex, column, columnIndex)
|
|
110
107
|
break
|
|
111
108
|
case 'checkbox':
|
|
112
109
|
cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
|
|
@@ -162,7 +159,7 @@ function getLabelData ($xetable, opts, columns, datas) {
|
|
|
162
159
|
} else {
|
|
163
160
|
switch (column.type) {
|
|
164
161
|
case 'seq':
|
|
165
|
-
cellValue = getSeq($xetable, row, rowIndex, column, columnIndex
|
|
162
|
+
cellValue = getSeq($xetable, row, rowIndex, column, columnIndex)
|
|
166
163
|
break
|
|
167
164
|
case 'checkbox':
|
|
168
165
|
cellValue = toBooleanValue($xetable.isCheckedByCheckboxRow(row))
|
|
@@ -104,7 +104,7 @@ export default {
|
|
|
104
104
|
// 判断面板不能大于表格高度
|
|
105
105
|
let maxHeight = null
|
|
106
106
|
if (filterHeight >= bodyElem.clientHeight) {
|
|
107
|
-
maxHeight = Math.max(
|
|
107
|
+
maxHeight = Math.max(60, bodyElem.clientHeight - (filterFootElem ? filterFootElem.offsetHeight : 0) - (filterHeadElem ? filterHeadElem.offsetHeight : 0))
|
|
108
108
|
}
|
|
109
109
|
if (column.fixed === 'left') {
|
|
110
110
|
left = targetElem.offsetLeft + targetElem.offsetParent.offsetLeft - centerWidth
|
|
@@ -377,7 +377,7 @@ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
|
|
|
377
377
|
)
|
|
378
378
|
}
|
|
379
379
|
// 如果是树形表格
|
|
380
|
-
if (treeConfig && !scrollYLoad && treeExpandeds.length) {
|
|
380
|
+
if (treeConfig && !scrollYLoad && !treeOpts.transform && treeExpandeds.length) {
|
|
381
381
|
const rowChildren = row[treeOpts.children]
|
|
382
382
|
if (rowChildren && rowChildren.length && treeExpandeds.indexOf(row) > -1) {
|
|
383
383
|
rows.push(...renderRows(h, _vm, $xetable, fixedType, rowChildren, tableColumn))
|
|
@@ -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,24 @@ 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 { scrollYLoad, scrollYStore, fullDataRowIdData, afterFullData } = this
|
|
305
|
+
let fullList = afterFullData
|
|
306
|
+
// 是否进行数据处理
|
|
307
|
+
if (force) {
|
|
308
|
+
// 更新数据,处理筛选和排序
|
|
309
|
+
this.updateAfterFullData()
|
|
310
|
+
// 如果为虚拟树,将树结构拍平
|
|
311
|
+
fullList = this.handleVirtualTreeToList()
|
|
312
|
+
}
|
|
313
|
+
const tableData = scrollYLoad ? fullList.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullList.slice(0)
|
|
314
|
+
tableData.forEach((row, $index) => {
|
|
315
|
+
const rowid = getRowid(this, row)
|
|
316
|
+
const rest = fullDataRowIdData[rowid]
|
|
317
|
+
if (rest) {
|
|
318
|
+
rest.$index = $index
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
this.tableData = tableData
|
|
307
322
|
return this.$nextTick()
|
|
308
323
|
},
|
|
309
324
|
updateScrollYStatus (fullData) {
|
|
@@ -334,13 +349,24 @@ const Methods = {
|
|
|
334
349
|
if (!treeOpts.children) {
|
|
335
350
|
UtilTools.error('vxe.error.reqProp', ['tree-config.children'])
|
|
336
351
|
}
|
|
352
|
+
if (!treeOpts.mapChildren) {
|
|
353
|
+
UtilTools.error('vxe.error.reqProp', ['tree-config.mapChildren'])
|
|
354
|
+
}
|
|
355
|
+
if (treeOpts.children === treeOpts.mapChildren) {
|
|
356
|
+
UtilTools.error('vxe.error.errConflicts', ['tree-config.children', 'tree-config.mapChildren'])
|
|
357
|
+
}
|
|
337
358
|
fullData.forEach(row => {
|
|
338
359
|
if (row[treeOpts.children] && row[treeOpts.children].length) {
|
|
339
360
|
UtilTools.warn('vxe.error.errConflicts', ['tree-config.transform', `row.${treeOpts.children}`])
|
|
340
361
|
}
|
|
341
362
|
})
|
|
342
363
|
}
|
|
343
|
-
treeData = XEUtils.toArrayTree(fullData, {
|
|
364
|
+
treeData = XEUtils.toArrayTree(fullData, {
|
|
365
|
+
key: treeOpts.rowField,
|
|
366
|
+
parentKey: treeOpts.parentField,
|
|
367
|
+
children: treeOpts.children,
|
|
368
|
+
mapChildren: treeOpts.mapChildren
|
|
369
|
+
})
|
|
344
370
|
fullData = treeData.slice(0)
|
|
345
371
|
} else {
|
|
346
372
|
treeData = fullData.slice(0)
|
|
@@ -356,7 +382,7 @@ const Methods = {
|
|
|
356
382
|
this.scrollYLoad = sYLoad
|
|
357
383
|
// 全量数据
|
|
358
384
|
this.tableFullData = fullData
|
|
359
|
-
this.
|
|
385
|
+
this.tableFullTreeData = treeData
|
|
360
386
|
// 缓存数据
|
|
361
387
|
this.cacheRowMap(true)
|
|
362
388
|
// 原始数据
|
|
@@ -530,7 +556,7 @@ const Methods = {
|
|
|
530
556
|
* 牺牲数据组装的耗时,用来换取使用过程中的流畅
|
|
531
557
|
*/
|
|
532
558
|
cacheRowMap (source) {
|
|
533
|
-
const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap } = this
|
|
559
|
+
const { treeConfig, treeOpts, tableFullData, fullDataRowMap, fullAllDataRowMap, tableFullTreeData } = this
|
|
534
560
|
let { fullDataRowIdData, fullAllDataRowIdData } = this
|
|
535
561
|
const rowkey = getRowkey(this)
|
|
536
562
|
const isLazy = treeConfig && treeOpts.lazy
|
|
@@ -560,14 +586,14 @@ const Methods = {
|
|
|
560
586
|
fullAllDataRowIdData = this.fullAllDataRowIdData = {}
|
|
561
587
|
fullAllDataRowMap.clear()
|
|
562
588
|
if (treeConfig) {
|
|
563
|
-
XEUtils.eachTree(
|
|
589
|
+
XEUtils.eachTree(tableFullTreeData, handleCache, treeOpts)
|
|
564
590
|
} else {
|
|
565
591
|
tableFullData.forEach(handleCache)
|
|
566
592
|
}
|
|
567
593
|
},
|
|
568
594
|
loadTreeChildren (row, childRecords) {
|
|
569
595
|
const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData } = this
|
|
570
|
-
const { children } = treeOpts
|
|
596
|
+
const { transform, children, mapChildren } = treeOpts
|
|
571
597
|
const rest = fullAllDataRowIdData[getRowid(this, row)]
|
|
572
598
|
const parentLevel = rest ? rest.level : 0
|
|
573
599
|
return this.createData(childRecords).then((rows) => {
|
|
@@ -587,6 +613,9 @@ const Methods = {
|
|
|
587
613
|
fullAllDataRowMap.set(childRow, rest)
|
|
588
614
|
}, treeOpts)
|
|
589
615
|
row[children] = rows
|
|
616
|
+
if (transform) {
|
|
617
|
+
row[mapChildren] = rows
|
|
618
|
+
}
|
|
590
619
|
return rows
|
|
591
620
|
})
|
|
592
621
|
},
|
|
@@ -1073,15 +1102,38 @@ const Methods = {
|
|
|
1073
1102
|
}
|
|
1074
1103
|
return rowList
|
|
1075
1104
|
},
|
|
1105
|
+
/**
|
|
1106
|
+
* 如果为虚拟树,将树结构拍平
|
|
1107
|
+
* @returns
|
|
1108
|
+
*/
|
|
1109
|
+
handleVirtualTreeToList () {
|
|
1110
|
+
const { treeOpts, treeConfig, treeExpandeds, afterTreeFullData, afterFullData } = this
|
|
1111
|
+
if (treeConfig && treeOpts.transform) {
|
|
1112
|
+
const fullData = []
|
|
1113
|
+
const expandMaps = new Map()
|
|
1114
|
+
XEUtils.eachTree(afterTreeFullData, (row, index, items, path, parent) => {
|
|
1115
|
+
if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
|
|
1116
|
+
expandMaps.set(row, 1)
|
|
1117
|
+
fullData.push(row)
|
|
1118
|
+
}
|
|
1119
|
+
}, { children: treeOpts.mapChildren })
|
|
1120
|
+
this.afterFullData = fullData
|
|
1121
|
+
this.updateScrollYStatus(fullData)
|
|
1122
|
+
return fullData
|
|
1123
|
+
}
|
|
1124
|
+
return afterFullData
|
|
1125
|
+
},
|
|
1076
1126
|
/**
|
|
1077
1127
|
* 获取处理后全量的表格数据
|
|
1078
1128
|
* 如果存在筛选条件,继续处理
|
|
1079
1129
|
*/
|
|
1080
1130
|
updateAfterFullData () {
|
|
1081
|
-
const { tableFullColumn, tableFullData, filterOpts, sortOpts } = this
|
|
1131
|
+
const { tableFullColumn, tableFullData, filterOpts, sortOpts, treeConfig, treeOpts, tableFullTreeData } = this
|
|
1082
1132
|
const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
1083
1133
|
const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple } = sortOpts
|
|
1084
|
-
|
|
1134
|
+
const { transform } = treeOpts
|
|
1135
|
+
let tableData = []
|
|
1136
|
+
let tableTree = []
|
|
1085
1137
|
const filterColumns = []
|
|
1086
1138
|
const orderColumns = []
|
|
1087
1139
|
tableFullColumn.forEach(column => {
|
|
@@ -1104,7 +1156,7 @@ const Methods = {
|
|
|
1104
1156
|
}
|
|
1105
1157
|
})
|
|
1106
1158
|
if (filterColumns.length) {
|
|
1107
|
-
|
|
1159
|
+
const handleFilter = (row) => {
|
|
1108
1160
|
return filterColumns.every(({ column, valueList, itemList }) => {
|
|
1109
1161
|
if (valueList.length && !allRemoteFilter) {
|
|
1110
1162
|
const { filterMethod, filterRender } = column
|
|
@@ -1125,52 +1177,84 @@ const Methods = {
|
|
|
1125
1177
|
}
|
|
1126
1178
|
return true
|
|
1127
1179
|
})
|
|
1128
|
-
}
|
|
1180
|
+
}
|
|
1181
|
+
if (treeConfig && transform) {
|
|
1182
|
+
// 筛选虚拟树
|
|
1183
|
+
tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, { ...treeOpts, original: true })
|
|
1184
|
+
tableData = tableTree
|
|
1185
|
+
} else {
|
|
1186
|
+
tableData = treeConfig ? tableFullTreeData.filter(handleFilter) : tableFullData.filter(handleFilter)
|
|
1187
|
+
tableTree = tableData
|
|
1188
|
+
}
|
|
1189
|
+
} else {
|
|
1190
|
+
if (treeConfig && transform) {
|
|
1191
|
+
// 还原虚拟树
|
|
1192
|
+
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, { ...treeOpts, original: true })
|
|
1193
|
+
tableData = tableTree
|
|
1194
|
+
} else {
|
|
1195
|
+
tableData = treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0)
|
|
1196
|
+
tableTree = tableData
|
|
1197
|
+
}
|
|
1129
1198
|
}
|
|
1130
1199
|
const firstOrderColumn = orderColumns[0]
|
|
1131
1200
|
if (!allRemoteSort && firstOrderColumn) {
|
|
1132
|
-
if (
|
|
1133
|
-
|
|
1134
|
-
|
|
1201
|
+
if (treeConfig && transform) {
|
|
1202
|
+
// 虚拟树和列表一样,只能排序根级节点
|
|
1203
|
+
if (allSortMethod) {
|
|
1204
|
+
const sortRests = allSortMethod({ data: tableTree, sortList: orderColumns, $table: this })
|
|
1205
|
+
tableTree = XEUtils.isArray(sortRests) ? sortRests : tableTree
|
|
1206
|
+
} else {
|
|
1207
|
+
tableTree = XEUtils.orderBy(tableTree, orderColumns.map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1208
|
+
}
|
|
1209
|
+
tableData = tableTree
|
|
1135
1210
|
} else {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
tableData = XEUtils.
|
|
1211
|
+
if (allSortMethod) {
|
|
1212
|
+
const sortRests = allSortMethod({ data: tableData, column: firstOrderColumn.column, property: firstOrderColumn.property, order: firstOrderColumn.order, sortList: orderColumns, $table: this })
|
|
1213
|
+
tableData = XEUtils.isArray(sortRests) ? sortRests : tableData
|
|
1139
1214
|
} else {
|
|
1140
|
-
// 兼容
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1215
|
+
// 兼容 v4
|
|
1216
|
+
if (sortMultiple) {
|
|
1217
|
+
tableData = XEUtils.orderBy(tableData, orderColumns.map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1218
|
+
} else {
|
|
1219
|
+
// 兼容 v2,在 v4 中废弃, sortBy 不能为数组
|
|
1220
|
+
let sortByConfs
|
|
1221
|
+
if (XEUtils.isArray(firstOrderColumn.sortBy)) {
|
|
1222
|
+
sortByConfs = firstOrderColumn.sortBy.map(item => [item, firstOrderColumn.order])
|
|
1223
|
+
}
|
|
1224
|
+
tableData = XEUtils.orderBy(tableData, sortByConfs || [firstOrderColumn].map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1144
1225
|
}
|
|
1145
|
-
tableData = XEUtils.orderBy(tableData, sortByConfs || [firstOrderColumn].map(({ column, order }) => [getOrderField(this, column), order]))
|
|
1146
1226
|
}
|
|
1227
|
+
tableTree = tableData
|
|
1147
1228
|
}
|
|
1148
1229
|
}
|
|
1149
1230
|
this.afterFullData = tableData
|
|
1150
|
-
|
|
1231
|
+
this.afterTreeFullData = tableTree
|
|
1232
|
+
this.updateAfterDataIndex()
|
|
1151
1233
|
},
|
|
1152
1234
|
/**
|
|
1153
1235
|
* 预编译
|
|
1154
1236
|
* 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
|
|
1155
1237
|
*/
|
|
1156
1238
|
updateAfterDataIndex () {
|
|
1157
|
-
const { treeConfig, afterFullData, fullDataRowIdData, fullAllDataRowIdData,
|
|
1239
|
+
const { treeConfig, afterFullData, fullDataRowIdData, fullAllDataRowIdData, afterTreeFullData, treeOpts } = this
|
|
1158
1240
|
if (treeConfig) {
|
|
1159
|
-
XEUtils.eachTree(
|
|
1241
|
+
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
1160
1242
|
const rowid = getRowid(this, row)
|
|
1161
1243
|
const allrest = fullAllDataRowIdData[rowid]
|
|
1162
1244
|
const fullrest = fullDataRowIdData[rowid]
|
|
1163
1245
|
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
1164
1246
|
if (allrest) {
|
|
1165
1247
|
allrest.seq = seq
|
|
1248
|
+
allrest._index = index
|
|
1166
1249
|
}
|
|
1167
1250
|
if (fullrest) {
|
|
1168
1251
|
fullrest.seq = seq
|
|
1252
|
+
fullrest._index = index
|
|
1169
1253
|
} else {
|
|
1170
1254
|
fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1171
1255
|
fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1172
1256
|
}
|
|
1173
|
-
}, treeOpts)
|
|
1257
|
+
}, { children: treeOpts.mapChildren })
|
|
1174
1258
|
} else {
|
|
1175
1259
|
afterFullData.forEach((row, index) => {
|
|
1176
1260
|
const rowid = getRowid(this, row)
|
|
@@ -1179,6 +1263,7 @@ const Methods = {
|
|
|
1179
1263
|
const seq = index + 1
|
|
1180
1264
|
if (allrest) {
|
|
1181
1265
|
allrest.seq = seq
|
|
1266
|
+
allrest._index = index
|
|
1182
1267
|
}
|
|
1183
1268
|
if (fullrest) {
|
|
1184
1269
|
fullrest.seq = seq
|
|
@@ -3734,12 +3819,16 @@ const Methods = {
|
|
|
3734
3819
|
},
|
|
3735
3820
|
clearTreeExpandLoaded (row) {
|
|
3736
3821
|
const { treeOpts, treeExpandeds, fullAllDataRowMap } = this
|
|
3737
|
-
const { lazy } = treeOpts
|
|
3822
|
+
const { transform, lazy } = treeOpts
|
|
3738
3823
|
const rest = fullAllDataRowMap.get(row)
|
|
3739
3824
|
if (lazy && rest) {
|
|
3740
3825
|
rest.treeLoaded = false
|
|
3741
3826
|
XEUtils.remove(treeExpandeds, item => row === item)
|
|
3742
3827
|
}
|
|
3828
|
+
if (transform) {
|
|
3829
|
+
this.handleVirtualTreeToList()
|
|
3830
|
+
return this.handleTableData()
|
|
3831
|
+
}
|
|
3743
3832
|
return this.$nextTick()
|
|
3744
3833
|
},
|
|
3745
3834
|
/**
|
|
@@ -3754,7 +3843,7 @@ const Methods = {
|
|
|
3754
3843
|
return this.handleAsyncTreeExpandChilds(row)
|
|
3755
3844
|
}).then(() => {
|
|
3756
3845
|
if (transform) {
|
|
3757
|
-
return this.
|
|
3846
|
+
return this.handleTableData()
|
|
3758
3847
|
}
|
|
3759
3848
|
}).then(() => {
|
|
3760
3849
|
return this.recalculate()
|
|
@@ -3814,7 +3903,7 @@ const Methods = {
|
|
|
3814
3903
|
},
|
|
3815
3904
|
handleAsyncTreeExpandChilds (row) {
|
|
3816
3905
|
const { fullAllDataRowMap, treeExpandeds, treeOpts, treeLazyLoadeds, checkboxOpts } = this
|
|
3817
|
-
const { loadMethod } = treeOpts
|
|
3906
|
+
const { transform, loadMethod } = treeOpts
|
|
3818
3907
|
const { checkStrictly } = checkboxOpts
|
|
3819
3908
|
const rest = fullAllDataRowMap.get(row)
|
|
3820
3909
|
return new Promise(resolve => {
|
|
@@ -3834,9 +3923,17 @@ const Methods = {
|
|
|
3834
3923
|
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
3835
3924
|
this.setCheckboxRow(childRows, true)
|
|
3836
3925
|
}
|
|
3926
|
+
this.$nextTick().then(() => {
|
|
3927
|
+
if (transform) {
|
|
3928
|
+
return this.handleTableData()
|
|
3929
|
+
}
|
|
3930
|
+
}).then(() => {
|
|
3931
|
+
return this.recalculate()
|
|
3932
|
+
}).then(() => resolve())
|
|
3837
3933
|
})
|
|
3934
|
+
} else {
|
|
3935
|
+
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
3838
3936
|
}
|
|
3839
|
-
resolve(this.$nextTick().then(this.recalculate))
|
|
3840
3937
|
})
|
|
3841
3938
|
})
|
|
3842
3939
|
},
|
|
@@ -3900,23 +3997,6 @@ const Methods = {
|
|
|
3900
3997
|
}
|
|
3901
3998
|
return Promise.all(result).then(this.recalculate)
|
|
3902
3999
|
},
|
|
3903
|
-
updateVirtualTreeData () {
|
|
3904
|
-
const { scrollYLoad: oldScrollYLoad, treeExpandeds, treeOpts, treeFullData } = this
|
|
3905
|
-
const fullData = []
|
|
3906
|
-
const expandMaps = new Map()
|
|
3907
|
-
XEUtils.eachTree(treeFullData, (row, index, items, path, parent) => {
|
|
3908
|
-
if (!parent || (expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1)) {
|
|
3909
|
-
expandMaps.set(row, 1)
|
|
3910
|
-
fullData.push(row)
|
|
3911
|
-
}
|
|
3912
|
-
}, treeOpts)
|
|
3913
|
-
const scrollYLoad = this.updateScrollYStatus(fullData)
|
|
3914
|
-
this.tableFullData = scrollYLoad ? fullData : treeFullData
|
|
3915
|
-
if (scrollYLoad || oldScrollYLoad !== scrollYLoad) {
|
|
3916
|
-
return this.handleTableData(true).then(() => this.recalculate())
|
|
3917
|
-
}
|
|
3918
|
-
return this.$nextTick()
|
|
3919
|
-
},
|
|
3920
4000
|
/**
|
|
3921
4001
|
* 虚拟树的展开与收起
|
|
3922
4002
|
* @param rows
|
|
@@ -3925,7 +4005,8 @@ const Methods = {
|
|
|
3925
4005
|
*/
|
|
3926
4006
|
handleVirtualTreeExpand (rows, expanded) {
|
|
3927
4007
|
return this.handleBaseTreeExpand(rows, expanded).then(() => {
|
|
3928
|
-
|
|
4008
|
+
this.handleVirtualTreeToList()
|
|
4009
|
+
return this.handleTableData()
|
|
3929
4010
|
}).then(() => {
|
|
3930
4011
|
return this.recalculate()
|
|
3931
4012
|
})
|
|
@@ -3967,13 +4048,16 @@ const Methods = {
|
|
|
3967
4048
|
*/
|
|
3968
4049
|
clearTreeExpand () {
|
|
3969
4050
|
const { treeOpts, treeExpandeds, tableFullData } = this
|
|
3970
|
-
const { reserve } = treeOpts
|
|
4051
|
+
const { transform, reserve } = treeOpts
|
|
3971
4052
|
const isExists = treeExpandeds.length
|
|
3972
4053
|
this.treeExpandeds = []
|
|
3973
4054
|
if (reserve) {
|
|
3974
4055
|
XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), treeOpts)
|
|
3975
4056
|
}
|
|
3976
|
-
return this.
|
|
4057
|
+
return this.handleTableData().then(() => {
|
|
4058
|
+
if (transform) {
|
|
4059
|
+
this.handleVirtualTreeToList()
|
|
4060
|
+
}
|
|
3977
4061
|
if (isExists) {
|
|
3978
4062
|
this.recalculate()
|
|
3979
4063
|
}
|
|
@@ -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
|
},
|