vxe-table 3.7.0-beta.11 → 3.7.0-beta.13
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 +257 -207
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.umd.js +312 -234
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/src/body.js +5 -5
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +12 -12
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +41 -14
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +6 -0
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +1 -1
- package/lib/table/src/util.min.js +1 -1
- package/lib/tools/log.js +1 -1
- package/lib/tools/log.min.js +1 -1
- package/lib/v-x-e-table/index.js +1 -1
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/v-x-e-table/src/commands.js +1 -1
- package/lib/v-x-e-table/src/commands.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +2 -2
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/lib/v-x-e-table/src/formats.js +1 -1
- package/lib/v-x-e-table/src/formats.min.js +1 -1
- package/lib/v-x-e-table/src/menus.js +1 -1
- package/lib/v-x-e-table/src/menus.min.js +1 -1
- package/lib/v-x-e-table/src/renderer.js +4 -4
- package/lib/v-x-e-table/src/renderer.min.js +1 -1
- package/package.json +3 -3
- package/packages/edit/src/mixin.js +174 -134
- package/packages/table/src/body.js +5 -5
- package/packages/table/src/cell.js +8 -7
- package/packages/table/src/methods.js +39 -10
- package/packages/table/src/table.js +6 -0
- package/packages/table/src/util.js +1 -1
- package/packages/v-x-e-table/src/commands.js +1 -1
- package/packages/v-x-e-table/src/conf.js +2 -2
- package/packages/v-x-e-table/src/formats.js +1 -1
- package/packages/v-x-e-table/src/menus.js +1 -1
- package/packages/v-x-e-table/src/renderer.js +4 -4
- package/types/table.d.ts +16 -1
- package/types/v-x-e-table/index.d.ts +1 -1
- /package/lib/icon/style/{iconfont.1691021948915.ttf → iconfont.1692439110338.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1691021948915.woff → iconfont.1692439110338.woff} +0 -0
- /package/lib/icon/style/{iconfont.1691021948915.woff2 → iconfont.1692439110338.woff2} +0 -0
- /package/lib/{iconfont.1691021948915.ttf → iconfont.1692439110338.ttf} +0 -0
- /package/lib/{iconfont.1691021948915.woff → iconfont.1692439110338.woff} +0 -0
- /package/lib/{iconfont.1691021948915.woff2 → iconfont.1692439110338.woff2} +0 -0
|
@@ -19,10 +19,15 @@ function insertTreeRow (_vm, newRecords, isAppend) {
|
|
|
19
19
|
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
|
|
20
20
|
const parentLevel = parentRest ? parentRest.level : 0
|
|
21
21
|
let parentChilds = parentRow[childrenField]
|
|
22
|
+
let mapChilds = parentRow[mapChildrenField]
|
|
22
23
|
if (!XEUtils.isArray(parentChilds)) {
|
|
23
24
|
parentChilds = parentRow[childrenField] = []
|
|
24
25
|
}
|
|
26
|
+
if (!XEUtils.isArray(mapChilds)) {
|
|
27
|
+
mapChilds = parentRow[childrenField] = []
|
|
28
|
+
}
|
|
25
29
|
parentChilds[funcName](item)
|
|
30
|
+
mapChilds[funcName](item)
|
|
26
31
|
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
27
32
|
fullDataRowIdData[rowid] = rest
|
|
28
33
|
fullAllDataRowIdData[rowid] = rest
|
|
@@ -41,6 +46,156 @@ function insertTreeRow (_vm, newRecords, isAppend) {
|
|
|
41
46
|
})
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
function handleInsertRowAt (_vm, records, row, isInsertNextRow) {
|
|
50
|
+
const { tableFullTreeData, mergeList, afterFullData, editStore, tableFullData, treeConfig, fullDataRowIdData, fullAllDataRowIdData, treeOpts } = _vm
|
|
51
|
+
const { transform, rowField, mapChildrenField } = treeOpts
|
|
52
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
53
|
+
if (!XEUtils.isArray(records)) {
|
|
54
|
+
records = [records]
|
|
55
|
+
}
|
|
56
|
+
const newRecords = _vm.defineField(records.map(record => Object.assign(treeConfig && transform ? { [mapChildrenField]: [], [childrenField]: [] } : {}, record)))
|
|
57
|
+
if (!row) {
|
|
58
|
+
// 如果为虚拟树
|
|
59
|
+
if (treeConfig && transform) {
|
|
60
|
+
insertTreeRow(_vm, newRecords, false)
|
|
61
|
+
} else {
|
|
62
|
+
afterFullData.unshift(...newRecords)
|
|
63
|
+
tableFullData.unshift(...newRecords)
|
|
64
|
+
// 刷新单元格合并
|
|
65
|
+
mergeList.forEach(mergeItem => {
|
|
66
|
+
const { row: mergeRowIndex } = mergeItem
|
|
67
|
+
if (mergeRowIndex > 0) {
|
|
68
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
if (row === -1) {
|
|
74
|
+
// 如果为虚拟树
|
|
75
|
+
if (treeConfig && transform) {
|
|
76
|
+
insertTreeRow(_vm, newRecords, true)
|
|
77
|
+
} else {
|
|
78
|
+
afterFullData.push(...newRecords)
|
|
79
|
+
tableFullData.push(...newRecords)
|
|
80
|
+
// 刷新单元格合并
|
|
81
|
+
mergeList.forEach(mergeItem => {
|
|
82
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
83
|
+
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
84
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// 如果为虚拟树
|
|
90
|
+
if (treeConfig && transform) {
|
|
91
|
+
const matchMapObj = XEUtils.findTree(tableFullTreeData, item => row[rowField] === item[rowField], { children: mapChildrenField })
|
|
92
|
+
if (matchMapObj) {
|
|
93
|
+
const { parent: parentRow } = matchMapObj
|
|
94
|
+
const parentMapChilds = parentRow ? parentRow[mapChildrenField] : tableFullTreeData
|
|
95
|
+
const parentRest = fullAllDataRowIdData[getRowid(_vm, parentRow)]
|
|
96
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
97
|
+
newRecords.forEach((item, i) => {
|
|
98
|
+
const rowid = getRowid(_vm, item)
|
|
99
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
100
|
+
if (item[treeOpts.parentField]) {
|
|
101
|
+
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
102
|
+
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (parentRow) {
|
|
107
|
+
item[treeOpts.parentField] = parentRow[rowField]
|
|
108
|
+
}
|
|
109
|
+
let targetIndex = matchMapObj.index + i
|
|
110
|
+
if (isInsertNextRow) {
|
|
111
|
+
targetIndex = targetIndex + 1
|
|
112
|
+
}
|
|
113
|
+
parentMapChilds.splice(targetIndex, 0, item)
|
|
114
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1 }
|
|
115
|
+
fullDataRowIdData[rowid] = rest
|
|
116
|
+
fullAllDataRowIdData[rowid] = rest
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
// 源
|
|
120
|
+
if (parentRow) {
|
|
121
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => row[rowField] === item[rowField], { children: childrenField })
|
|
122
|
+
if (matchObj) {
|
|
123
|
+
const parentChilds = matchObj.items
|
|
124
|
+
let targetIndex = matchObj.index
|
|
125
|
+
if (isInsertNextRow) {
|
|
126
|
+
targetIndex = targetIndex + 1
|
|
127
|
+
}
|
|
128
|
+
parentChilds.splice(targetIndex, 0, ...newRecords)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
133
|
+
warnLog('vxe.error.unableInsert')
|
|
134
|
+
}
|
|
135
|
+
insertTreeRow(_vm, newRecords, true)
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
if (treeConfig) {
|
|
139
|
+
throw new Error(getLog('vxe.error.noTree', ['insert']))
|
|
140
|
+
}
|
|
141
|
+
let afIndex = -1
|
|
142
|
+
// 如果是可视索引
|
|
143
|
+
if (XEUtils.isNumber(row)) {
|
|
144
|
+
if (row < afterFullData.length) {
|
|
145
|
+
afIndex = row
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
afIndex = _vm.findRowIndexOf(afterFullData, row)
|
|
149
|
+
}
|
|
150
|
+
// 如果是插入指定行的下一行
|
|
151
|
+
if (isInsertNextRow) {
|
|
152
|
+
afIndex = Math.max(afterFullData.length, afIndex + 1)
|
|
153
|
+
}
|
|
154
|
+
if (afIndex === -1) {
|
|
155
|
+
throw new Error(errLog('vxe.error.unableInsert'))
|
|
156
|
+
}
|
|
157
|
+
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
158
|
+
tableFullData.splice(_vm.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
159
|
+
// 刷新单元格合并
|
|
160
|
+
mergeList.forEach(mergeItem => {
|
|
161
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
162
|
+
if (mergeRowIndex > afIndex) {
|
|
163
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
164
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
165
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const { insertList, insertMaps } = editStore
|
|
172
|
+
newRecords.forEach(newRow => {
|
|
173
|
+
const rowid = getRowid(_vm, newRow)
|
|
174
|
+
insertMaps[rowid] = newRow
|
|
175
|
+
})
|
|
176
|
+
insertList.unshift(...newRecords)
|
|
177
|
+
_vm.cacheRowMap()
|
|
178
|
+
_vm.updateScrollYStatus()
|
|
179
|
+
_vm.handleTableData(treeConfig && transform)
|
|
180
|
+
if (!(treeConfig && transform)) {
|
|
181
|
+
_vm.updateAfterDataIndex()
|
|
182
|
+
}
|
|
183
|
+
_vm.updateFooter()
|
|
184
|
+
_vm.checkSelectionStatus()
|
|
185
|
+
if (_vm.scrollYLoad) {
|
|
186
|
+
_vm.updateScrollYSpace()
|
|
187
|
+
}
|
|
188
|
+
return _vm.$nextTick().then(() => {
|
|
189
|
+
_vm.updateCellAreas()
|
|
190
|
+
return _vm.recalculate()
|
|
191
|
+
}).then(() => {
|
|
192
|
+
return {
|
|
193
|
+
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
194
|
+
rows: newRecords
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
44
199
|
export default {
|
|
45
200
|
methods: {
|
|
46
201
|
/**
|
|
@@ -49,7 +204,7 @@ export default {
|
|
|
49
204
|
* @param {*} records
|
|
50
205
|
*/
|
|
51
206
|
_insert (records) {
|
|
52
|
-
return this
|
|
207
|
+
return handleInsertRowAt(this, records, null)
|
|
53
208
|
},
|
|
54
209
|
/**
|
|
55
210
|
* 往表格指定行中插入临时数据
|
|
@@ -58,133 +213,13 @@ export default {
|
|
|
58
213
|
* 如果 row 为有效行则插入到该行的位置
|
|
59
214
|
* @param {Object/Array} records 新的数据
|
|
60
215
|
* @param {Row} row 指定行
|
|
216
|
+
* @returns
|
|
61
217
|
*/
|
|
62
218
|
_insertAt (records, row) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
const newRecords = this.defineField(records.map(record => Object.assign({}, record)))
|
|
69
|
-
if (!row) {
|
|
70
|
-
// 如果为虚拟树
|
|
71
|
-
if (treeConfig && transform) {
|
|
72
|
-
insertTreeRow(this, newRecords, false)
|
|
73
|
-
} else {
|
|
74
|
-
afterFullData.unshift(...newRecords)
|
|
75
|
-
tableFullData.unshift(...newRecords)
|
|
76
|
-
// 刷新单元格合并
|
|
77
|
-
mergeList.forEach(mergeItem => {
|
|
78
|
-
const { row: mergeRowIndex } = mergeItem
|
|
79
|
-
if (mergeRowIndex > 0) {
|
|
80
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
if (row === -1) {
|
|
86
|
-
// 如果为虚拟树
|
|
87
|
-
if (treeConfig && transform) {
|
|
88
|
-
insertTreeRow(this, newRecords, true)
|
|
89
|
-
} else {
|
|
90
|
-
afterFullData.push(...newRecords)
|
|
91
|
-
tableFullData.push(...newRecords)
|
|
92
|
-
// 刷新单元格合并
|
|
93
|
-
mergeList.forEach(mergeItem => {
|
|
94
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
95
|
-
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
96
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
// 如果为虚拟树
|
|
102
|
-
if (treeConfig && transform) {
|
|
103
|
-
const matchObj = XEUtils.findTree(tableFullTreeData, item => row[rowField] === item[rowField], { children: mapChildrenField })
|
|
104
|
-
if (matchObj) {
|
|
105
|
-
const { parent: parentRow } = matchObj
|
|
106
|
-
const parentChilds = matchObj.items
|
|
107
|
-
const parentRest = fullAllDataRowIdData[getRowid(this, parentRow)]
|
|
108
|
-
const parentLevel = parentRest ? parentRest.level : 0
|
|
109
|
-
newRecords.forEach((item, i) => {
|
|
110
|
-
const rowid = getRowid(this, item)
|
|
111
|
-
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
112
|
-
if (item[treeOpts.parentField]) {
|
|
113
|
-
if (parentRow && item[treeOpts.parentField] !== parentRow[rowField]) {
|
|
114
|
-
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[rowField]}`])
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (parentRow) {
|
|
119
|
-
item[treeOpts.parentField] = parentRow[rowField]
|
|
120
|
-
}
|
|
121
|
-
parentChilds.splice(matchObj.index + i, 0, item)
|
|
122
|
-
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
|
|
123
|
-
fullDataRowIdData[rowid] = rest
|
|
124
|
-
fullAllDataRowIdData[rowid] = rest
|
|
125
|
-
})
|
|
126
|
-
} else {
|
|
127
|
-
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
128
|
-
warnLog('vxe.error.unableInsert')
|
|
129
|
-
}
|
|
130
|
-
insertTreeRow(this, newRecords, true)
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
if (treeConfig) {
|
|
134
|
-
throw new Error(getLog('vxe.error.noTree', ['insert']))
|
|
135
|
-
}
|
|
136
|
-
let afIndex = -1
|
|
137
|
-
// 如果是可视索引
|
|
138
|
-
if (XEUtils.isNumber(row)) {
|
|
139
|
-
if (row < afterFullData.length) {
|
|
140
|
-
afIndex = row
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
afIndex = this.findRowIndexOf(afterFullData, row)
|
|
144
|
-
}
|
|
145
|
-
if (afIndex === -1) {
|
|
146
|
-
throw new Error(errLog('vxe.error.unableInsert'))
|
|
147
|
-
}
|
|
148
|
-
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
149
|
-
tableFullData.splice(this.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
150
|
-
// 刷新单元格合并
|
|
151
|
-
mergeList.forEach(mergeItem => {
|
|
152
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
153
|
-
if (mergeRowIndex > afIndex) {
|
|
154
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
155
|
-
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
156
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const { insertList, insertMaps } = editStore
|
|
163
|
-
newRecords.forEach(newRow => {
|
|
164
|
-
const rowid = getRowid(this, newRow)
|
|
165
|
-
insertMaps[rowid] = newRow
|
|
166
|
-
})
|
|
167
|
-
insertList.unshift(...newRecords)
|
|
168
|
-
this.cacheRowMap()
|
|
169
|
-
this.updateScrollYStatus()
|
|
170
|
-
this.handleTableData(treeConfig && transform)
|
|
171
|
-
if (!(treeConfig && transform)) {
|
|
172
|
-
this.updateAfterDataIndex()
|
|
173
|
-
}
|
|
174
|
-
this.updateFooter()
|
|
175
|
-
this.checkSelectionStatus()
|
|
176
|
-
if (this.scrollYLoad) {
|
|
177
|
-
this.updateScrollYSpace()
|
|
178
|
-
}
|
|
179
|
-
return this.$nextTick().then(() => {
|
|
180
|
-
this.updateCellAreas()
|
|
181
|
-
return this.recalculate()
|
|
182
|
-
}).then(() => {
|
|
183
|
-
return {
|
|
184
|
-
row: newRecords.length ? newRecords[newRecords.length - 1] : null,
|
|
185
|
-
rows: newRecords
|
|
186
|
-
}
|
|
187
|
-
})
|
|
219
|
+
return handleInsertRowAt(this, records, row)
|
|
220
|
+
},
|
|
221
|
+
_insertNextAt (records, row) {
|
|
222
|
+
return handleInsertRowAt(this, records, row, true)
|
|
188
223
|
},
|
|
189
224
|
/**
|
|
190
225
|
* 删除指定行数据
|
|
@@ -194,10 +229,11 @@ export default {
|
|
|
194
229
|
*/
|
|
195
230
|
_remove (rows) {
|
|
196
231
|
const { afterFullData, tableFullData, tableFullTreeData, treeConfig, mergeList, editStore, checkboxOpts, selectCheckboxRows, isInsertByRow, treeOpts } = this
|
|
197
|
-
const { transform } = treeOpts
|
|
232
|
+
const { transform, mapChildrenField } = treeOpts
|
|
233
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
198
234
|
const { actived, removeList, insertList, insertMaps } = editStore
|
|
199
235
|
const { checkField } = checkboxOpts
|
|
200
|
-
let
|
|
236
|
+
let delList = []
|
|
201
237
|
if (!rows) {
|
|
202
238
|
rows = tableFullData
|
|
203
239
|
} else if (!XEUtils.isArray(rows)) {
|
|
@@ -220,7 +256,7 @@ export default {
|
|
|
220
256
|
}
|
|
221
257
|
// 从数据源中移除
|
|
222
258
|
if (tableFullData === rows) {
|
|
223
|
-
rows =
|
|
259
|
+
rows = delList = tableFullData.slice(0)
|
|
224
260
|
this.tableFullData = []
|
|
225
261
|
this.afterFullData = []
|
|
226
262
|
this.clearMergeCells()
|
|
@@ -229,10 +265,14 @@ export default {
|
|
|
229
265
|
if (treeConfig && transform) {
|
|
230
266
|
rows.forEach((row) => {
|
|
231
267
|
const rowid = getRowid(this, row)
|
|
232
|
-
const
|
|
268
|
+
const matchMapObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), { children: mapChildrenField })
|
|
269
|
+
if (matchMapObj) {
|
|
270
|
+
const rItems = matchMapObj.items.splice(matchMapObj.index, 1)
|
|
271
|
+
delList.push(rItems[0])
|
|
272
|
+
}
|
|
273
|
+
const matchObj = XEUtils.findTree(tableFullTreeData, item => rowid === getRowid(this, item), { children: childrenField })
|
|
233
274
|
if (matchObj) {
|
|
234
|
-
|
|
235
|
-
rest.push(rItems[0])
|
|
275
|
+
matchObj.items.splice(matchObj.index, 1)
|
|
236
276
|
}
|
|
237
277
|
const afIndex = this.findRowIndexOf(afterFullData, row)
|
|
238
278
|
if (afIndex > -1) {
|
|
@@ -244,7 +284,7 @@ export default {
|
|
|
244
284
|
const tfIndex = this.findRowIndexOf(tableFullData, row)
|
|
245
285
|
if (tfIndex > -1) {
|
|
246
286
|
const rItems = tableFullData.splice(tfIndex, 1)
|
|
247
|
-
|
|
287
|
+
delList.push(rItems[0])
|
|
248
288
|
}
|
|
249
289
|
const afIndex = this.findRowIndexOf(afterFullData, row)
|
|
250
290
|
if (afIndex > -1) {
|
|
@@ -289,7 +329,7 @@ export default {
|
|
|
289
329
|
this.updateCellAreas()
|
|
290
330
|
return this.recalculate()
|
|
291
331
|
}).then(() => {
|
|
292
|
-
return { row:
|
|
332
|
+
return { row: delList.length ? delList[delList.length - 1] : null, rows: delList }
|
|
293
333
|
})
|
|
294
334
|
},
|
|
295
335
|
/**
|
|
@@ -9,7 +9,7 @@ import { getSlotVNs } from '../../tools/vn'
|
|
|
9
9
|
const renderType = 'body'
|
|
10
10
|
|
|
11
11
|
// 滚动、拖动过程中不需要触发
|
|
12
|
-
function
|
|
12
|
+
function isVMScrollProcess ($xetable) {
|
|
13
13
|
return $xetable._isResize || ($xetable.lastScrollTime && Date.now() < $xetable.lastScrollTime + $xetable.delayHover)
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -122,7 +122,7 @@ function renderColumn (h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, r
|
|
|
122
122
|
// hover 进入事件
|
|
123
123
|
if (showTitle || showTooltip || showAllTip || bindMouseenter || tooltipConfig) {
|
|
124
124
|
tdOns.mouseenter = evnt => {
|
|
125
|
-
if (
|
|
125
|
+
if (isVMScrollProcess($xetable)) {
|
|
126
126
|
return
|
|
127
127
|
}
|
|
128
128
|
if (showTitle) {
|
|
@@ -139,7 +139,7 @@ function renderColumn (h, _vm, $xetable, seq, rowid, fixedType, rowLevel, row, r
|
|
|
139
139
|
// hover 退出事件
|
|
140
140
|
if (showTooltip || showAllTip || bindMouseleave || tooltipConfig) {
|
|
141
141
|
tdOns.mouseleave = evnt => {
|
|
142
|
-
if (
|
|
142
|
+
if (isVMScrollProcess($xetable)) {
|
|
143
143
|
return
|
|
144
144
|
}
|
|
145
145
|
if (showTooltip || showAllTip) {
|
|
@@ -323,13 +323,13 @@ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
|
|
|
323
323
|
// 事件绑定
|
|
324
324
|
if (rowOpts.isHover || highlightHoverRow) {
|
|
325
325
|
trOn.mouseenter = evnt => {
|
|
326
|
-
if (
|
|
326
|
+
if (isVMScrollProcess($xetable)) {
|
|
327
327
|
return
|
|
328
328
|
}
|
|
329
329
|
$xetable.triggerHoverEvent(evnt, { row, rowIndex })
|
|
330
330
|
}
|
|
331
331
|
trOn.mouseleave = () => {
|
|
332
|
-
if (
|
|
332
|
+
if (isVMScrollProcess($xetable)) {
|
|
333
333
|
return
|
|
334
334
|
}
|
|
335
335
|
$xetable.clearHoverRow()
|
|
@@ -471,12 +471,13 @@ export const Cell = {
|
|
|
471
471
|
},
|
|
472
472
|
renderCheckboxCellByProp (h, params) {
|
|
473
473
|
const { $table, row, column, isHidden } = params
|
|
474
|
-
const { treeConfig, treeIndeterminates } = $table
|
|
475
|
-
const { labelField, checkField,
|
|
474
|
+
const { treeConfig, treeIndeterminates, checkboxOpts } = $table
|
|
475
|
+
const { labelField, checkField, checkMethod, visibleMethod } = checkboxOpts
|
|
476
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
476
477
|
const { slots } = column
|
|
477
478
|
const defaultSlot = slots ? slots.default : null
|
|
478
479
|
const checkboxSlot = slots ? slots.checkbox : null
|
|
479
|
-
let
|
|
480
|
+
let isIndeterminate = false
|
|
480
481
|
let isChecked = false
|
|
481
482
|
const isVisible = !visibleMethod || visibleMethod({ row })
|
|
482
483
|
let isDisabled = !!checkMethod
|
|
@@ -495,10 +496,10 @@ export const Cell = {
|
|
|
495
496
|
isDisabled = !checkMethod({ row })
|
|
496
497
|
}
|
|
497
498
|
if (treeConfig) {
|
|
498
|
-
|
|
499
|
+
isIndeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
|
|
499
500
|
}
|
|
500
501
|
}
|
|
501
|
-
const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
|
|
502
|
+
const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate: isIndeterminate }
|
|
502
503
|
if (checkboxSlot) {
|
|
503
504
|
return $table.callSlot(checkboxSlot, checkboxParams, h)
|
|
504
505
|
}
|
|
@@ -506,7 +507,7 @@ export const Cell = {
|
|
|
506
507
|
if (isVisible) {
|
|
507
508
|
checkVNs.push(
|
|
508
509
|
h('span', {
|
|
509
|
-
class: ['vxe-checkbox--icon',
|
|
510
|
+
class: ['vxe-checkbox--icon', isIndeterminate ? GlobalConfig.icon.TABLE_CHECKBOX_INDETERMINATE : (isChecked ? GlobalConfig.icon.TABLE_CHECKBOX_CHECKED : GlobalConfig.icon.TABLE_CHECKBOX_UNCHECKED)]
|
|
510
511
|
})
|
|
511
512
|
)
|
|
512
513
|
}
|
|
@@ -522,7 +523,7 @@ export const Cell = {
|
|
|
522
523
|
class: ['vxe-cell--checkbox', {
|
|
523
524
|
'is--checked': isChecked,
|
|
524
525
|
'is--disabled': isDisabled,
|
|
525
|
-
'is--indeterminate':
|
|
526
|
+
'is--indeterminate': indeterminateField && !isChecked ? row[indeterminateField] : isIndeterminate
|
|
526
527
|
}],
|
|
527
528
|
on
|
|
528
529
|
}, checkVNs)
|
|
@@ -3080,8 +3080,25 @@ const Methods = {
|
|
|
3080
3080
|
}
|
|
3081
3081
|
},
|
|
3082
3082
|
triggerCheckRowEvent (evnt, params, value) {
|
|
3083
|
-
const {
|
|
3084
|
-
|
|
3083
|
+
const { checkboxOpts, afterFullData } = this
|
|
3084
|
+
const { checkMethod } = checkboxOpts
|
|
3085
|
+
const { row } = params
|
|
3086
|
+
if (checkboxOpts.isShiftKey && evnt.shiftKey && !this.treeConfig) {
|
|
3087
|
+
const checkboxRecords = this.getCheckboxRecords()
|
|
3088
|
+
if (checkboxRecords.length) {
|
|
3089
|
+
const firstRow = checkboxRecords[0]
|
|
3090
|
+
const _rowIndex = this.getVTRowIndex(row)
|
|
3091
|
+
const _firstRowIndex = this.getVTRowIndex(firstRow)
|
|
3092
|
+
if (_rowIndex !== _firstRowIndex) {
|
|
3093
|
+
this.setAllCheckboxRow(false)
|
|
3094
|
+
const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
|
|
3095
|
+
this.handleCheckedCheckboxRow(rangeRows, true, false)
|
|
3096
|
+
this.emitEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
|
|
3097
|
+
return
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
if (!checkMethod || checkMethod({ row })) {
|
|
3085
3102
|
this.handleSelectRow(params, value)
|
|
3086
3103
|
this.emitEvent('checkbox-change', Object.assign({
|
|
3087
3104
|
records: this.getCheckboxRecords(),
|
|
@@ -3104,6 +3121,7 @@ const Methods = {
|
|
|
3104
3121
|
handleCheckedAllCheckboxRow (value, isForce) {
|
|
3105
3122
|
const { afterFullData, treeConfig, treeOpts, selectCheckboxRows, checkboxReserveRowMap, checkboxOpts } = this
|
|
3106
3123
|
const { checkField, reserve, checkStrictly, checkMethod } = checkboxOpts
|
|
3124
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
3107
3125
|
let selectRows = []
|
|
3108
3126
|
const beforeSelection = treeConfig ? [] : selectCheckboxRows.filter(row => this.findRowIndexOf(afterFullData, row) === -1)
|
|
3109
3127
|
if (checkStrictly) {
|
|
@@ -3121,6 +3139,9 @@ const Methods = {
|
|
|
3121
3139
|
}
|
|
3122
3140
|
XEUtils.set(row, checkField, value)
|
|
3123
3141
|
}
|
|
3142
|
+
if (treeConfig && indeterminateField) {
|
|
3143
|
+
XEUtils.set(row, indeterminateField, false)
|
|
3144
|
+
}
|
|
3124
3145
|
}
|
|
3125
3146
|
// 如果存在选中方法
|
|
3126
3147
|
// 如果方法成立,则更新值,否则忽略该数据
|
|
@@ -3206,7 +3227,8 @@ const Methods = {
|
|
|
3206
3227
|
},
|
|
3207
3228
|
checkSelectionStatus () {
|
|
3208
3229
|
const { afterFullData, selectCheckboxRows, treeIndeterminates, checkboxOpts, treeConfig } = this
|
|
3209
|
-
const { checkField,
|
|
3230
|
+
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
3231
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
3210
3232
|
if (!checkStrictly) {
|
|
3211
3233
|
const disableRows = []
|
|
3212
3234
|
const checkRows = []
|
|
@@ -3231,14 +3253,14 @@ const Methods = {
|
|
|
3231
3253
|
)
|
|
3232
3254
|
isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
|
|
3233
3255
|
if (treeConfig) {
|
|
3234
|
-
if (
|
|
3235
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row,
|
|
3256
|
+
if (indeterminateField) {
|
|
3257
|
+
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField) || this.findRowIndexOf(treeIndeterminates, row) > -1)
|
|
3236
3258
|
} else {
|
|
3237
3259
|
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || this.findRowIndexOf(treeIndeterminates, row) > -1)
|
|
3238
3260
|
}
|
|
3239
3261
|
} else {
|
|
3240
|
-
if (
|
|
3241
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row,
|
|
3262
|
+
if (indeterminateField) {
|
|
3263
|
+
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField))
|
|
3242
3264
|
} else {
|
|
3243
3265
|
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField))
|
|
3244
3266
|
}
|
|
@@ -3411,11 +3433,18 @@ const Methods = {
|
|
|
3411
3433
|
clearCheckboxRow () {
|
|
3412
3434
|
const { tableFullData, treeConfig, treeOpts, checkboxOpts } = this
|
|
3413
3435
|
const { checkField, reserve } = checkboxOpts
|
|
3436
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
3414
3437
|
if (checkField) {
|
|
3438
|
+
const handleClearChecked = (item) => {
|
|
3439
|
+
if (treeConfig && indeterminateField) {
|
|
3440
|
+
XEUtils.set(item, indeterminateField, false)
|
|
3441
|
+
}
|
|
3442
|
+
XEUtils.set(item, checkField, false)
|
|
3443
|
+
}
|
|
3415
3444
|
if (treeConfig) {
|
|
3416
|
-
XEUtils.eachTree(tableFullData,
|
|
3445
|
+
XEUtils.eachTree(tableFullData, handleClearChecked, treeOpts)
|
|
3417
3446
|
} else {
|
|
3418
|
-
tableFullData.forEach(
|
|
3447
|
+
tableFullData.forEach(handleClearChecked)
|
|
3419
3448
|
}
|
|
3420
3449
|
}
|
|
3421
3450
|
if (reserve) {
|
|
@@ -4911,7 +4940,7 @@ const Methods = {
|
|
|
4911
4940
|
}
|
|
4912
4941
|
|
|
4913
4942
|
// Module methods
|
|
4914
|
-
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',')
|
|
4943
|
+
const funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',')
|
|
4915
4944
|
|
|
4916
4945
|
funcs.forEach(name => {
|
|
4917
4946
|
Methods[name] = function (...args) {
|
|
@@ -885,6 +885,12 @@ export default {
|
|
|
885
885
|
if (this.editConfig && this.editOpts.activeMethod) {
|
|
886
886
|
warnLog('vxe.error.delProp', ['table.edit-config.activeMethod', 'table.edit-config.beforeEditMethod'])
|
|
887
887
|
}
|
|
888
|
+
if (this.treeConfig && this.checkboxOpts.isShiftKey) {
|
|
889
|
+
errLog('vxe.error.errConflicts', ['tree-config', 'checkbox-config.isShiftKey'])
|
|
890
|
+
}
|
|
891
|
+
if (this.checkboxOpts.halfField) {
|
|
892
|
+
warnLog('vxe.error.delProp', ['checkbox-config.halfField', 'checkbox-config.indeterminateField'])
|
|
893
|
+
}
|
|
888
894
|
}
|
|
889
895
|
|
|
890
896
|
// 检查是否有安装需要的模块
|
|
@@ -160,7 +160,7 @@ function countTreeExpand (prevRow, params) {
|
|
|
160
160
|
const { treeOpts } = $table
|
|
161
161
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
162
162
|
const rowChildren = prevRow[childrenField]
|
|
163
|
-
if ($table.isTreeExpandByRow(prevRow)) {
|
|
163
|
+
if (rowChildren && $table.isTreeExpandByRow(prevRow)) {
|
|
164
164
|
for (let index = 0; index < rowChildren.length; index++) {
|
|
165
165
|
count += countTreeExpand(rowChildren[index], params)
|
|
166
166
|
}
|
|
@@ -22,7 +22,7 @@ class VXECommandsStore {
|
|
|
22
22
|
// 兼容
|
|
23
23
|
if (XEUtils.isFunction(render)) {
|
|
24
24
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
25
|
-
warnLog('vxe.error.delProp', ['callback', 'commandMethod'])
|
|
25
|
+
warnLog('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
|
|
26
26
|
}
|
|
27
27
|
render = {
|
|
28
28
|
commandMethod: render
|
|
@@ -22,7 +22,7 @@ class VXEFormatsStore {
|
|
|
22
22
|
// 兼容
|
|
23
23
|
if (XEUtils.isFunction(render)) {
|
|
24
24
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
25
|
-
warnLog('vxe.error.delProp', ['callback', 'cellFormatMethod'])
|
|
25
|
+
warnLog('vxe.error.delProp', ['formats -> callback', 'cellFormatMethod'])
|
|
26
26
|
}
|
|
27
27
|
render = {
|
|
28
28
|
cellFormatMethod: render
|
|
@@ -22,7 +22,7 @@ class VXEMenusStore {
|
|
|
22
22
|
// 兼容
|
|
23
23
|
if (XEUtils.isFunction(render)) {
|
|
24
24
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
25
|
-
warnLog('vxe.error.delProp', ['callback', 'menuMethod'])
|
|
25
|
+
warnLog('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
|
|
26
26
|
}
|
|
27
27
|
render = {
|
|
28
28
|
menuMethod: render
|
|
@@ -104,8 +104,8 @@ function getNativeOns (renderOpts, params) {
|
|
|
104
104
|
XEUtils.objectEach(nativeEvents, (func, key) => {
|
|
105
105
|
nativeOns[key] = function (...args) {
|
|
106
106
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
107
|
-
if (!XEUtils.isFunction(
|
|
108
|
-
errLog('vxe.error.errFunc', [
|
|
107
|
+
if (!XEUtils.isFunction(func)) {
|
|
108
|
+
errLog('vxe.error.errFunc', [func])
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
func(params, ...args)
|
|
@@ -123,8 +123,8 @@ function getOns (renderOpts, params, inputFunc, changeFunc) {
|
|
|
123
123
|
XEUtils.objectEach(events, (func, key) => {
|
|
124
124
|
ons[key] = function (...args) {
|
|
125
125
|
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
126
|
-
if (!XEUtils.isFunction(
|
|
127
|
-
errLog('vxe.error.errFunc', [
|
|
126
|
+
if (!XEUtils.isFunction(func)) {
|
|
127
|
+
errLog('vxe.error.errFunc', [func])
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
func(params, ...args)
|