vxe-table 4.1.2 → 4.1.5
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/README.en.md +3 -3
- package/README.md +3 -3
- package/README.zh-TW.md +2 -3
- package/es/edit/src/hook.js +189 -69
- package/es/input/src/input.js +8 -2
- package/es/table/src/body.js +6 -3
- package/es/table/src/cell.js +70 -54
- package/es/table/src/table.js +36 -30
- package/es/v-x-e-table/src/conf.js +2 -2
- package/lib/edit/src/hook.js +243 -70
- package/lib/edit/src/hook.min.js +1 -1
- package/lib/index.umd.js +853 -140
- package/lib/index.umd.min.js +1 -1
- package/lib/input/src/input.js +10 -2
- package/lib/input/src/input.min.js +1 -1
- package/lib/table/src/body.js +6 -3
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +92 -35
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/table.js +38 -30
- package/lib/table/src/table.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/package.json +3 -3
- package/packages/edit/src/hook.ts +183 -69
- package/packages/input/src/input.ts +9 -2
- package/packages/table/src/body.ts +6 -3
- package/packages/table/src/cell.ts +77 -44
- package/packages/table/src/table.ts +36 -29
- package/packages/v-x-e-table/src/conf.ts +2 -2
- package/types/edit.d.ts +6 -3
- package/types/index.d.ts +1 -1
- package/types/plugins/pro.d.ts +6 -6
- package/types/table.d.ts +18 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { nextTick } from 'vue'
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
3
|
import { renderer } from '../../v-x-e-table'
|
|
4
|
-
import { errLog, getLog, isEnableConf } from '../../tools/utils'
|
|
5
|
-
import { getCellValue, setCellValue } from '../../table/src/util'
|
|
4
|
+
import { errLog, getLog, isEnableConf, warnLog } from '../../tools/utils'
|
|
5
|
+
import { getCellValue, setCellValue, getRowid } from '../../table/src/util'
|
|
6
6
|
import { browse, removeClass, addClass } from '../../tools/dom'
|
|
7
7
|
|
|
8
8
|
import { VxeGlobalHooksHandles, TableEditMethods, TableEditPrivateMethods } from '../../../types/all'
|
|
@@ -59,6 +59,42 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
function insertTreeRow (newRecords: any[], isAppend: boolean) {
|
|
63
|
+
const { treeFullData, afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
64
|
+
const treeOpts = computeTreeOpts.value
|
|
65
|
+
const funcName = isAppend ? 'push' : 'unshift'
|
|
66
|
+
newRecords.forEach(item => {
|
|
67
|
+
const parentRowId = item[treeOpts.parentField]
|
|
68
|
+
const rowid = getRowid($xetable, item)
|
|
69
|
+
const matchObj = parentRowId ? XEUtils.findTree(treeFullData, item => parentRowId === item[treeOpts.rowField], treeOpts) : null
|
|
70
|
+
if (matchObj) {
|
|
71
|
+
const { item: parentRow } = matchObj
|
|
72
|
+
const parentRest = fullAllDataRowIdData[getRowid($xetable, parentRow)]
|
|
73
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
74
|
+
let parentChilds = parentRow[treeOpts.children]
|
|
75
|
+
if (!XEUtils.isArray(parentChilds)) {
|
|
76
|
+
parentChilds = parentRow[treeOpts.children] = []
|
|
77
|
+
}
|
|
78
|
+
parentChilds[funcName](item)
|
|
79
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
80
|
+
fullDataRowIdData[rowid] = rest
|
|
81
|
+
fullAllDataRowIdData[rowid] = rest
|
|
82
|
+
} else {
|
|
83
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
84
|
+
if (parentRowId) {
|
|
85
|
+
warnLog('vxe.error.unableInsert')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
afterFullData[funcName](item)
|
|
89
|
+
treeFullData[funcName](item)
|
|
90
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: treeFullData, parent: null, level: 0 }
|
|
91
|
+
fullDataRowIdData[rowid] = rest
|
|
92
|
+
fullAllDataRowIdData[rowid] = rest
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
$xetable.updateVirtualTreeData()
|
|
96
|
+
}
|
|
97
|
+
|
|
62
98
|
editMethods = {
|
|
63
99
|
/**
|
|
64
100
|
* 往表格中插入临时数据
|
|
@@ -70,68 +106,114 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
70
106
|
},
|
|
71
107
|
/**
|
|
72
108
|
* 往表格指定行中插入临时数据
|
|
73
|
-
* 如果 row
|
|
74
|
-
* 如果 row 为 -1
|
|
75
|
-
* 如果 row
|
|
109
|
+
* 如果 row 为空则从插入到顶部,如果为树结构,则插入到目标节点顶部
|
|
110
|
+
* 如果 row 为 -1 则从插入到底部,如果为树结构,则插入到目标节点底部
|
|
111
|
+
* 如果 row 为有效行则插入到该行的位置,如果为树结构,则有插入到效的目标节点该行的位置
|
|
76
112
|
* @param {Object/Array} records 新的数据
|
|
77
113
|
* @param {Row} row 指定行
|
|
78
114
|
*/
|
|
79
115
|
insertAt (records: any, row: any) {
|
|
80
116
|
const { treeConfig } = props
|
|
81
117
|
const { mergeList, editStore, scrollYLoad } = reactData
|
|
82
|
-
const { afterFullData, tableFullData } = internalData
|
|
118
|
+
const { treeFullData, afterFullData, tableFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
83
119
|
const sYOpts = computeSYOpts.value
|
|
120
|
+
const treeOpts = computeTreeOpts.value
|
|
121
|
+
const { transform } = treeOpts
|
|
84
122
|
if (!XEUtils.isArray(records)) {
|
|
85
123
|
records = [records]
|
|
86
124
|
}
|
|
87
|
-
const newRecords = records.map((record: any) => $xetable.defineField(Object.assign({}, record)))
|
|
125
|
+
const newRecords: any[] = records.map((record: any) => $xetable.defineField(Object.assign({}, record)))
|
|
88
126
|
if (!row) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
mergeList.forEach((mergeItem: any) => {
|
|
93
|
-
const { row: mergeRowIndex } = mergeItem
|
|
94
|
-
if (mergeRowIndex > 0) {
|
|
95
|
-
mergeItem.row = mergeRowIndex + newRecords.length
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
} else {
|
|
99
|
-
if (row === -1) {
|
|
100
|
-
afterFullData.push(...newRecords)
|
|
101
|
-
tableFullData.push(...newRecords)
|
|
102
|
-
// 刷新单元格合并
|
|
103
|
-
mergeList.forEach((mergeItem: any) => {
|
|
104
|
-
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
105
|
-
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
106
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
107
|
-
}
|
|
108
|
-
})
|
|
127
|
+
// 如果为虚拟树
|
|
128
|
+
if (treeConfig && transform) {
|
|
129
|
+
insertTreeRow(newRecords, false)
|
|
109
130
|
} else {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
114
|
-
if (afIndex === -1) {
|
|
115
|
-
throw new Error(errLog('vxe.error.unableInsert'))
|
|
116
|
-
}
|
|
117
|
-
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
118
|
-
tableFullData.splice($xetable.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
131
|
+
afterFullData.unshift(...newRecords)
|
|
132
|
+
tableFullData.unshift(...newRecords)
|
|
119
133
|
// 刷新单元格合并
|
|
120
134
|
mergeList.forEach((mergeItem: any) => {
|
|
121
|
-
const { row: mergeRowIndex
|
|
122
|
-
if (mergeRowIndex >
|
|
135
|
+
const { row: mergeRowIndex } = mergeItem
|
|
136
|
+
if (mergeRowIndex > 0) {
|
|
123
137
|
mergeItem.row = mergeRowIndex + newRecords.length
|
|
124
|
-
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
125
|
-
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
126
138
|
}
|
|
127
139
|
})
|
|
128
140
|
}
|
|
141
|
+
} else {
|
|
142
|
+
if (row === -1) {
|
|
143
|
+
// 如果为虚拟树
|
|
144
|
+
if (treeConfig && transform) {
|
|
145
|
+
insertTreeRow(newRecords, true)
|
|
146
|
+
} else {
|
|
147
|
+
afterFullData.push(...newRecords)
|
|
148
|
+
tableFullData.push(...newRecords)
|
|
149
|
+
// 刷新单元格合并
|
|
150
|
+
mergeList.forEach((mergeItem: any) => {
|
|
151
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
152
|
+
if (mergeRowIndex + mergeRowspan > afterFullData.length) {
|
|
153
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
// 如果为虚拟树
|
|
159
|
+
if (treeConfig && transform) {
|
|
160
|
+
const matchObj = XEUtils.findTree(treeFullData, item => row[treeOpts.rowField] === item[treeOpts.rowField], treeOpts)
|
|
161
|
+
if (matchObj) {
|
|
162
|
+
const { parent: parentRow } = matchObj
|
|
163
|
+
const parentChilds = matchObj.items
|
|
164
|
+
const parentRest = fullAllDataRowIdData[getRowid($xetable, parentRow)]
|
|
165
|
+
const parentLevel = parentRest ? parentRest.level : 0
|
|
166
|
+
newRecords.forEach((item, i) => {
|
|
167
|
+
const rowid = getRowid($xetable, item)
|
|
168
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
169
|
+
if (item[treeOpts.parentField]) {
|
|
170
|
+
if (parentRow && item[treeOpts.parentField] !== parentRow[treeOpts.rowField]) {
|
|
171
|
+
errLog('vxe.error.errProp', [`${treeOpts.parentField}=${item[treeOpts.parentField]}`, `${treeOpts.parentField}=${parentRow[treeOpts.rowField]}`])
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (parentRow) {
|
|
176
|
+
item[treeOpts.parentField] = parentRow[treeOpts.rowField]
|
|
177
|
+
}
|
|
178
|
+
parentChilds.splice(matchObj.index + i, 0, item)
|
|
179
|
+
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
|
|
180
|
+
fullDataRowIdData[rowid] = rest
|
|
181
|
+
fullAllDataRowIdData[rowid] = rest
|
|
182
|
+
})
|
|
183
|
+
$xetable.updateVirtualTreeData()
|
|
184
|
+
} else {
|
|
185
|
+
if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
|
|
186
|
+
warnLog('vxe.error.unableInsert')
|
|
187
|
+
}
|
|
188
|
+
insertTreeRow(newRecords, true)
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
if (treeConfig) {
|
|
192
|
+
throw new Error(getLog('vxe.error.noTree', ['insert']))
|
|
193
|
+
}
|
|
194
|
+
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
195
|
+
if (afIndex === -1) {
|
|
196
|
+
throw new Error(errLog('vxe.error.unableInsert'))
|
|
197
|
+
}
|
|
198
|
+
afterFullData.splice(afIndex, 0, ...newRecords)
|
|
199
|
+
tableFullData.splice($xetable.findRowIndexOf(tableFullData, row), 0, ...newRecords)
|
|
200
|
+
// 刷新单元格合并
|
|
201
|
+
mergeList.forEach((mergeItem: any) => {
|
|
202
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
203
|
+
if (mergeRowIndex > afIndex) {
|
|
204
|
+
mergeItem.row = mergeRowIndex + newRecords.length
|
|
205
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
206
|
+
mergeItem.rowspan = mergeRowspan + newRecords.length
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
}
|
|
129
211
|
}
|
|
130
212
|
editStore.insertList.unshift(...newRecords)
|
|
131
213
|
reactData.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
|
|
132
214
|
$xetable.updateFooter()
|
|
133
215
|
$xetable.cacheRowMap()
|
|
134
|
-
$xetable.handleTableData()
|
|
216
|
+
$xetable.handleTableData(transform)
|
|
135
217
|
$xetable.updateAfterDataIndex()
|
|
136
218
|
$xetable.checkSelectionStatus()
|
|
137
219
|
if (scrollYLoad) {
|
|
@@ -156,9 +238,11 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
156
238
|
remove (rows: any) {
|
|
157
239
|
const { treeConfig } = props
|
|
158
240
|
const { mergeList, editStore, selection, scrollYLoad } = reactData
|
|
159
|
-
const { afterFullData, tableFullData } = internalData
|
|
241
|
+
const { treeFullData, afterFullData, tableFullData } = internalData
|
|
160
242
|
const checkboxOpts = computeCheckboxOpts.value
|
|
161
243
|
const sYOpts = computeSYOpts.value
|
|
244
|
+
const treeOpts = computeTreeOpts.value
|
|
245
|
+
const { transform } = treeOpts
|
|
162
246
|
const { actived, removeList, insertList } = editStore
|
|
163
247
|
const { checkField: property } = checkboxOpts
|
|
164
248
|
let rest: any[] = []
|
|
@@ -189,26 +273,43 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
189
273
|
internalData.afterFullData = []
|
|
190
274
|
$xetable.clearMergeCells()
|
|
191
275
|
} else {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
276
|
+
// 如果为虚拟树
|
|
277
|
+
if (treeConfig && transform) {
|
|
278
|
+
rows.forEach((row: any) => {
|
|
279
|
+
const rowid = getRowid($xetable, row)
|
|
280
|
+
const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid($xetable, item), treeOpts)
|
|
281
|
+
if (matchObj) {
|
|
282
|
+
const rItems = matchObj.items.splice(matchObj.index, 1)
|
|
283
|
+
rest.push(rItems[0])
|
|
284
|
+
}
|
|
285
|
+
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
286
|
+
if (afIndex > -1) {
|
|
287
|
+
afterFullData.splice(afIndex, 1)
|
|
288
|
+
}
|
|
289
|
+
$xetable.updateVirtualTreeData()
|
|
290
|
+
})
|
|
291
|
+
} else {
|
|
292
|
+
rows.forEach((row: any) => {
|
|
293
|
+
const tfIndex = $xetable.findRowIndexOf(tableFullData, row)
|
|
294
|
+
if (tfIndex > -1) {
|
|
295
|
+
const rItems = tableFullData.splice(tfIndex, 1)
|
|
296
|
+
rest.push(rItems[0])
|
|
297
|
+
}
|
|
298
|
+
const afIndex = $xetable.findRowIndexOf(afterFullData, row)
|
|
299
|
+
if (afIndex > -1) {
|
|
300
|
+
// 刷新单元格合并
|
|
301
|
+
mergeList.forEach((mergeItem: any) => {
|
|
302
|
+
const { row: mergeRowIndex, rowspan: mergeRowspan } = mergeItem
|
|
303
|
+
if (mergeRowIndex > afIndex) {
|
|
304
|
+
mergeItem.row = mergeRowIndex - 1
|
|
305
|
+
} else if (mergeRowIndex + mergeRowspan > afIndex) {
|
|
306
|
+
mergeItem.rowspan = mergeRowspan - 1
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
afterFullData.splice(afIndex, 1)
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
}
|
|
212
313
|
}
|
|
213
314
|
// 如果当前行被激活编辑,则清除激活状态
|
|
214
315
|
if (actived.row && $xetable.findRowIndexOf(rows, actived.row) > -1) {
|
|
@@ -224,7 +325,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
224
325
|
reactData.scrollYLoad = !treeConfig && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length
|
|
225
326
|
$xetable.updateFooter()
|
|
226
327
|
$xetable.cacheRowMap()
|
|
227
|
-
$xetable.handleTableData()
|
|
328
|
+
$xetable.handleTableData(transform)
|
|
228
329
|
$xetable.updateAfterDataIndex()
|
|
229
330
|
$xetable.checkSelectionStatus()
|
|
230
331
|
if (scrollYLoad) {
|
|
@@ -280,16 +381,29 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
280
381
|
* 获取新增的临时数据
|
|
281
382
|
*/
|
|
282
383
|
getInsertRecords () {
|
|
384
|
+
const { treeConfig } = props
|
|
283
385
|
const { editStore } = reactData
|
|
284
|
-
const { tableFullData } = internalData
|
|
386
|
+
const { treeFullData, tableFullData } = internalData
|
|
387
|
+
const treeOpts = computeTreeOpts.value
|
|
285
388
|
const insertList = editStore.insertList
|
|
286
389
|
const insertRecords: any[] = []
|
|
287
390
|
if (insertList.length) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
391
|
+
// 如果为虚拟树
|
|
392
|
+
if (treeConfig && treeOpts.transform) {
|
|
393
|
+
insertList.forEach(row => {
|
|
394
|
+
const rowid = getRowid($xetable, row)
|
|
395
|
+
const matchObj = XEUtils.findTree(treeFullData, item => rowid === getRowid($xetable, item), treeOpts)
|
|
396
|
+
if (matchObj) {
|
|
397
|
+
insertRecords.push(row)
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
} else {
|
|
401
|
+
insertList.forEach(row => {
|
|
402
|
+
if ($xetable.findRowIndexOf(tableFullData, row) > -1) {
|
|
403
|
+
insertRecords.push(row)
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
}
|
|
293
407
|
}
|
|
294
408
|
return insertRecords
|
|
295
409
|
},
|
|
@@ -601,11 +601,18 @@ export default defineComponent({
|
|
|
601
601
|
return immediate || !(type === 'text' || type === 'number' || type === 'integer' || type === 'float')
|
|
602
602
|
})
|
|
603
603
|
|
|
604
|
+
function toFloatValueFixed (inputValue: string | number, digitsValue: number) {
|
|
605
|
+
if (/^-/.test('' + inputValue)) {
|
|
606
|
+
return XEUtils.toFixed(XEUtils.ceil(inputValue, digitsValue), digitsValue)
|
|
607
|
+
}
|
|
608
|
+
return XEUtils.toFixed(XEUtils.floor(inputValue, digitsValue), digitsValue)
|
|
609
|
+
}
|
|
610
|
+
|
|
604
611
|
function getNumberValue (val: any) {
|
|
605
612
|
const { type, exponential } = props
|
|
606
613
|
const inpMaxlength = computeInpMaxlength.value
|
|
607
614
|
const digitsValue = computeDigitsValue.value
|
|
608
|
-
const restVal = (type === 'float' ?
|
|
615
|
+
const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : XEUtils.toValueString(val))
|
|
609
616
|
if (exponential && (val === restVal || XEUtils.toValueString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
|
|
610
617
|
return val
|
|
611
618
|
}
|
|
@@ -746,7 +753,7 @@ export default defineComponent({
|
|
|
746
753
|
changeValue()
|
|
747
754
|
} else if (type === 'float') {
|
|
748
755
|
if (inputValue) {
|
|
749
|
-
const validValue =
|
|
756
|
+
const validValue = toFloatValueFixed(inputValue, digitsValue)
|
|
750
757
|
if (inputValue !== validValue) {
|
|
751
758
|
emitModel(validValue, { type: 'init' })
|
|
752
759
|
}
|
|
@@ -299,6 +299,7 @@ export default defineComponent({
|
|
|
299
299
|
const radioOpts = computeRadioOpts.value
|
|
300
300
|
const treeOpts = computeTreeOpts.value
|
|
301
301
|
const editOpts = computeEditOpts.value
|
|
302
|
+
const rowOpts = computeRowOpts.value
|
|
302
303
|
const rows: any[] = []
|
|
303
304
|
tableData.forEach((row: any, $rowIndex: any) => {
|
|
304
305
|
const trOn: any = {}
|
|
@@ -311,7 +312,7 @@ export default defineComponent({
|
|
|
311
312
|
// 确保任何情况下 rowIndex 都精准指向真实 data 索引
|
|
312
313
|
rowIndex = $xetable.getRowIndex(row)
|
|
313
314
|
// 事件绑定
|
|
314
|
-
if (highlightHoverRow) {
|
|
315
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
315
316
|
trOn.onMouseenter = (evnt: any) => {
|
|
316
317
|
if (isOperateMouse()) {
|
|
317
318
|
return
|
|
@@ -428,6 +429,7 @@ export default defineComponent({
|
|
|
428
429
|
const { highlightHoverRow } = tableProps
|
|
429
430
|
const { scrollXLoad, scrollYLoad } = tableReactData
|
|
430
431
|
const { elemStore, lastScrollTop, lastScrollLeft } = tableInternalData
|
|
432
|
+
const rowOpts = computeRowOpts.value
|
|
431
433
|
const tableHeader = refTableHeader.value
|
|
432
434
|
const tableBody = refTableBody.value
|
|
433
435
|
const tableFooter = refTableFooter.value
|
|
@@ -451,7 +453,7 @@ export default defineComponent({
|
|
|
451
453
|
tableInternalData.lastScrollTop = scrollTop
|
|
452
454
|
tableInternalData.lastScrollLeft = scrollLeft
|
|
453
455
|
tableInternalData.lastScrollTime = Date.now()
|
|
454
|
-
if (highlightHoverRow) {
|
|
456
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
455
457
|
$xetable.clearHoverRow()
|
|
456
458
|
}
|
|
457
459
|
if (leftElem && fixedType === 'left') {
|
|
@@ -546,6 +548,7 @@ export default defineComponent({
|
|
|
546
548
|
const { highlightHoverRow } = tableProps
|
|
547
549
|
const { scrollYLoad } = tableReactData
|
|
548
550
|
const { lastScrollTop, lastScrollLeft } = tableInternalData
|
|
551
|
+
const rowOpts = computeRowOpts.value
|
|
549
552
|
const tableBody = refTableBody.value
|
|
550
553
|
const scrollBodyElem = refElem.value
|
|
551
554
|
const bodyElem = tableBody.$el as HTMLDivElement
|
|
@@ -569,7 +572,7 @@ export default defineComponent({
|
|
|
569
572
|
tableInternalData.lastScrollTop = scrollTop
|
|
570
573
|
tableInternalData.lastScrollLeft = scrollLeft
|
|
571
574
|
tableInternalData.lastScrollTime = Date.now()
|
|
572
|
-
if (highlightHoverRow) {
|
|
575
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
573
576
|
$xetable.clearHoverRow()
|
|
574
577
|
}
|
|
575
578
|
handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY)
|
|
@@ -312,17 +312,18 @@ export const Cell = {
|
|
|
312
312
|
const { selectRow } = reactData
|
|
313
313
|
const radioOpts = computeRadioOpts.value
|
|
314
314
|
const { slots } = column
|
|
315
|
-
const { labelField, checkMethod } = radioOpts
|
|
315
|
+
const { labelField, checkMethod, visibleMethod } = radioOpts
|
|
316
316
|
const { row } = params
|
|
317
317
|
const defaultSlot = slots ? slots.default : null
|
|
318
318
|
const radioSlot = slots ? slots.radio : null
|
|
319
319
|
const isChecked = row === selectRow
|
|
320
|
+
const isVisible = !visibleMethod || visibleMethod({ row })
|
|
320
321
|
let isDisabled = !!checkMethod
|
|
321
322
|
let ons
|
|
322
323
|
if (!isHidden) {
|
|
323
324
|
ons = {
|
|
324
325
|
onClick (evnt: Event) {
|
|
325
|
-
if (!isDisabled) {
|
|
326
|
+
if (!isDisabled && isVisible) {
|
|
326
327
|
$table.triggerRadioRowEvent(evnt, params)
|
|
327
328
|
}
|
|
328
329
|
}
|
|
@@ -331,26 +332,36 @@ export const Cell = {
|
|
|
331
332
|
isDisabled = !checkMethod({ row })
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
|
-
const radioParams = { ...params, checked: isChecked, disabled: isDisabled }
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
...ons
|
|
342
|
-
}, [
|
|
335
|
+
const radioParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible }
|
|
336
|
+
if (radioSlot) {
|
|
337
|
+
return $table.callSlot(radioSlot, radioParams)
|
|
338
|
+
}
|
|
339
|
+
const radioVNs = []
|
|
340
|
+
if (isVisible) {
|
|
341
|
+
radioVNs.push(
|
|
343
342
|
h('span', {
|
|
344
343
|
class: 'vxe-radio--icon vxe-radio--checked-icon'
|
|
345
344
|
}),
|
|
346
345
|
h('span', {
|
|
347
346
|
class: 'vxe-radio--icon vxe-radio--unchecked-icon'
|
|
348
347
|
})
|
|
349
|
-
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
if (defaultSlot || labelField) {
|
|
351
|
+
radioVNs.push(
|
|
350
352
|
h('span', {
|
|
351
353
|
class: 'vxe-radio--label'
|
|
352
354
|
}, defaultSlot ? $table.callSlot(defaultSlot, radioParams) : XEUtils.get(row, labelField as string))
|
|
353
|
-
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
return [
|
|
358
|
+
h('span', {
|
|
359
|
+
class: ['vxe-cell--radio', {
|
|
360
|
+
'is--checked': isChecked,
|
|
361
|
+
'is--disabled': isDisabled
|
|
362
|
+
}],
|
|
363
|
+
...ons
|
|
364
|
+
}, radioVNs)
|
|
354
365
|
]
|
|
355
366
|
},
|
|
356
367
|
renderTreeRadioCell (params: VxeTableDefines.CellRenderBodyParams) {
|
|
@@ -427,19 +438,20 @@ export const Cell = {
|
|
|
427
438
|
const { selection, treeIndeterminates } = reactData
|
|
428
439
|
const { computeCheckboxOpts } = $table.getComputeMaps()
|
|
429
440
|
const checkboxOpts = computeCheckboxOpts.value
|
|
430
|
-
const { labelField, checkMethod } = checkboxOpts
|
|
441
|
+
const { labelField, checkMethod, visibleMethod } = checkboxOpts
|
|
431
442
|
const { slots } = column
|
|
432
443
|
const defaultSlot = slots ? slots.default : null
|
|
433
444
|
const checkboxSlot = slots ? slots.checkbox : null
|
|
434
445
|
let indeterminate = false
|
|
435
446
|
let isChecked = false
|
|
447
|
+
const isVisible = !visibleMethod || visibleMethod({ row })
|
|
436
448
|
let isDisabled = !!checkMethod
|
|
437
449
|
let ons
|
|
438
450
|
if (!isHidden) {
|
|
439
451
|
isChecked = $table.findRowIndexOf(selection, row) > -1
|
|
440
452
|
ons = {
|
|
441
453
|
onClick (evnt: MouseEvent) {
|
|
442
|
-
if (!isDisabled) {
|
|
454
|
+
if (!isDisabled && isVisible) {
|
|
443
455
|
$table.triggerCheckRowEvent(evnt, params, !isChecked)
|
|
444
456
|
}
|
|
445
457
|
}
|
|
@@ -451,16 +463,13 @@ export const Cell = {
|
|
|
451
463
|
indeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
|
|
452
464
|
}
|
|
453
465
|
}
|
|
454
|
-
const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, indeterminate }
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}],
|
|
462
|
-
...ons
|
|
463
|
-
}, [
|
|
466
|
+
const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
|
|
467
|
+
if (checkboxSlot) {
|
|
468
|
+
return $table.callSlot(checkboxSlot, checkboxParams)
|
|
469
|
+
}
|
|
470
|
+
const checkVNs = []
|
|
471
|
+
if (isVisible) {
|
|
472
|
+
checkVNs.push(
|
|
464
473
|
h('span', {
|
|
465
474
|
class: 'vxe-checkbox--icon vxe-checkbox--checked-icon'
|
|
466
475
|
}),
|
|
@@ -470,11 +479,24 @@ export const Cell = {
|
|
|
470
479
|
h('span', {
|
|
471
480
|
class: 'vxe-checkbox--icon vxe-checkbox--indeterminate-icon'
|
|
472
481
|
})
|
|
473
|
-
|
|
482
|
+
)
|
|
483
|
+
}
|
|
484
|
+
if (defaultSlot || labelField) {
|
|
485
|
+
checkVNs.push(
|
|
474
486
|
h('span', {
|
|
475
487
|
class: 'vxe-checkbox--label'
|
|
476
488
|
}, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : XEUtils.get(row, labelField as string))
|
|
477
|
-
|
|
489
|
+
)
|
|
490
|
+
}
|
|
491
|
+
return [
|
|
492
|
+
h('span', {
|
|
493
|
+
class: ['vxe-cell--checkbox', {
|
|
494
|
+
'is--checked': isChecked,
|
|
495
|
+
'is--disabled': isDisabled,
|
|
496
|
+
'is--indeterminate': indeterminate
|
|
497
|
+
}],
|
|
498
|
+
...ons
|
|
499
|
+
}, checkVNs)
|
|
478
500
|
]
|
|
479
501
|
},
|
|
480
502
|
renderTreeSelectionCell (params: VxeTableDefines.CellRenderBodyParams) {
|
|
@@ -487,19 +509,20 @@ export const Cell = {
|
|
|
487
509
|
const { treeIndeterminates } = reactData
|
|
488
510
|
const { computeCheckboxOpts } = $table.getComputeMaps()
|
|
489
511
|
const checkboxOpts = computeCheckboxOpts.value
|
|
490
|
-
const { labelField, checkField: property, halfField, checkMethod } = checkboxOpts
|
|
512
|
+
const { labelField, checkField: property, halfField, checkMethod, visibleMethod } = checkboxOpts
|
|
491
513
|
const { slots } = column
|
|
492
514
|
const defaultSlot = slots ? slots.default : null
|
|
493
515
|
const checkboxSlot = slots ? slots.checkbox : null
|
|
494
516
|
let indeterminate = false
|
|
495
517
|
let isChecked = false
|
|
518
|
+
const isVisible = !visibleMethod || visibleMethod({ row })
|
|
496
519
|
let isDisabled = !!checkMethod
|
|
497
520
|
let ons
|
|
498
521
|
if (!isHidden) {
|
|
499
522
|
isChecked = XEUtils.get(row, property as string)
|
|
500
523
|
ons = {
|
|
501
524
|
onClick (evnt: MouseEvent) {
|
|
502
|
-
if (!isDisabled) {
|
|
525
|
+
if (!isDisabled && isVisible) {
|
|
503
526
|
$table.triggerCheckRowEvent(evnt, params, !isChecked)
|
|
504
527
|
}
|
|
505
528
|
}
|
|
@@ -511,16 +534,13 @@ export const Cell = {
|
|
|
511
534
|
indeterminate = $table.findRowIndexOf(treeIndeterminates, row) > -1
|
|
512
535
|
}
|
|
513
536
|
}
|
|
514
|
-
const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, indeterminate }
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}],
|
|
522
|
-
...ons
|
|
523
|
-
}, [
|
|
537
|
+
const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
|
|
538
|
+
if (checkboxSlot) {
|
|
539
|
+
return $table.callSlot(checkboxSlot, checkboxParams)
|
|
540
|
+
}
|
|
541
|
+
const checkVNs = []
|
|
542
|
+
if (isVisible) {
|
|
543
|
+
checkVNs.push(
|
|
524
544
|
h('span', {
|
|
525
545
|
class: 'vxe-checkbox--icon vxe-checkbox--checked-icon'
|
|
526
546
|
}),
|
|
@@ -530,11 +550,24 @@ export const Cell = {
|
|
|
530
550
|
h('span', {
|
|
531
551
|
class: 'vxe-checkbox--icon vxe-checkbox--indeterminate-icon'
|
|
532
552
|
})
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
553
|
+
)
|
|
554
|
+
if (defaultSlot || labelField) {
|
|
555
|
+
checkVNs.push(
|
|
556
|
+
h('span', {
|
|
557
|
+
class: 'vxe-checkbox--label'
|
|
558
|
+
}, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams) : XEUtils.get(row, labelField as string))
|
|
559
|
+
)
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return [
|
|
563
|
+
h('span', {
|
|
564
|
+
class: ['vxe-cell--checkbox', {
|
|
565
|
+
'is--checked': isChecked,
|
|
566
|
+
'is--disabled': isDisabled,
|
|
567
|
+
'is--indeterminate': halfField && !isChecked ? row[halfField] : indeterminate
|
|
568
|
+
}],
|
|
569
|
+
...ons
|
|
570
|
+
}, checkVNs)
|
|
538
571
|
]
|
|
539
572
|
},
|
|
540
573
|
renderTreeSelectionCellByProp (params: VxeTableDefines.CellRenderBodyParams) {
|