vxe-table 4.1.8 → 4.1.9
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/es/button/src/button.js +14 -14
- package/es/edit/src/hook.js +3 -3
- package/es/export/src/hook.js +4 -4
- package/es/filter/src/hook.js +20 -1
- package/es/table/src/body.js +11 -14
- package/es/table/src/cell.js +16 -14
- package/es/table/src/table.js +90 -80
- package/es/table/src/util.js +3 -0
- package/es/tools/dom.js +2 -8
- package/lib/button/src/button.js +15 -14
- package/lib/button/src/button.min.js +1 -1
- package/lib/edit/src/hook.js +3 -0
- package/lib/edit/src/hook.min.js +1 -1
- package/lib/export/src/hook.js +3 -5
- package/lib/export/src/hook.min.js +1 -1
- package/lib/filter/src/hook.js +23 -0
- package/lib/filter/src/hook.min.js +1 -1
- package/lib/index.umd.js +242 -179
- package/lib/index.umd.min.js +1 -1
- package/lib/table/src/body.js +8 -16
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +16 -16
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/table.js +144 -104
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +7 -0
- package/lib/table/src/util.min.js +1 -1
- package/lib/tools/dom.js +2 -9
- package/lib/tools/dom.min.js +1 -1
- package/package.json +1 -1
- package/packages/button/src/button.ts +14 -14
- package/packages/edit/src/hook.ts +3 -3
- package/packages/export/src/hook.ts +4 -4
- package/packages/filter/src/hook.ts +20 -1
- package/packages/table/src/body.ts +11 -14
- package/packages/table/src/cell.ts +16 -14
- package/packages/table/src/table.ts +90 -80
- package/packages/table/src/util.ts +4 -0
- package/packages/tools/dom.ts +2 -7
- package/types/filter.d.ts +5 -0
- package/types/plugins/pro.d.ts +5 -0
- package/types/table.d.ts +8 -2
|
@@ -142,38 +142,38 @@ export default defineComponent({
|
|
|
142
142
|
const panelStyle: { [key: string]: string | number } = {
|
|
143
143
|
zIndex: panelIndex
|
|
144
144
|
}
|
|
145
|
-
const {
|
|
145
|
+
const { top, left, boundingTop, visibleHeight, visibleWidth } = getAbsolutePos(targetElem)
|
|
146
146
|
let panelPlacement = 'bottom'
|
|
147
147
|
if (transfer) {
|
|
148
|
-
let
|
|
149
|
-
let
|
|
148
|
+
let btnLeft = left + targetWidth - panelWidth
|
|
149
|
+
let btnTop = top + targetHeight
|
|
150
150
|
if (placement === 'top') {
|
|
151
151
|
panelPlacement = 'top'
|
|
152
|
-
|
|
152
|
+
btnTop = top - panelHeight
|
|
153
153
|
} else if (!placement) {
|
|
154
154
|
// 如果下面不够放,则向上
|
|
155
|
-
if (
|
|
155
|
+
if (boundingTop + targetHeight + panelHeight + marginSize > visibleHeight) {
|
|
156
156
|
panelPlacement = 'top'
|
|
157
|
-
|
|
157
|
+
btnTop = top - panelHeight
|
|
158
158
|
}
|
|
159
159
|
// 如果上面不够放,则向下(优先)
|
|
160
|
-
if (
|
|
160
|
+
if (btnTop < marginSize) {
|
|
161
161
|
panelPlacement = 'bottom'
|
|
162
|
-
|
|
162
|
+
btnTop = top + targetHeight
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
// 如果溢出右边
|
|
166
|
-
if (
|
|
167
|
-
|
|
166
|
+
if (btnLeft + panelWidth + marginSize > visibleWidth) {
|
|
167
|
+
btnLeft -= btnLeft + panelWidth + marginSize - visibleWidth
|
|
168
168
|
}
|
|
169
169
|
// 如果溢出左边
|
|
170
|
-
if (
|
|
171
|
-
|
|
170
|
+
if (btnLeft < marginSize) {
|
|
171
|
+
btnLeft = marginSize
|
|
172
172
|
}
|
|
173
173
|
Object.assign(panelStyle, {
|
|
174
|
-
left: `${
|
|
174
|
+
left: `${btnLeft}px`,
|
|
175
175
|
right: 'auto',
|
|
176
|
-
top: `${
|
|
176
|
+
top: `${btnTop}px`,
|
|
177
177
|
minWidth: `${targetWidth}px`
|
|
178
178
|
})
|
|
179
179
|
} else {
|
|
@@ -76,7 +76,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
76
76
|
parentChilds = parentRow[treeOpts.children] = []
|
|
77
77
|
}
|
|
78
78
|
parentChilds[funcName](item)
|
|
79
|
-
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
79
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent, level: parentLevel + 1 }
|
|
80
80
|
fullDataRowIdData[rowid] = rest
|
|
81
81
|
fullAllDataRowIdData[rowid] = rest
|
|
82
82
|
} else {
|
|
@@ -87,7 +87,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
87
87
|
}
|
|
88
88
|
afterFullData[funcName](item)
|
|
89
89
|
treeFullData[funcName](item)
|
|
90
|
-
const rest = { row: item, rowid, index: -1, _index: -1, $index: -1, items: treeFullData, parent: null, level: 0 }
|
|
90
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: treeFullData, parent: null, level: 0 }
|
|
91
91
|
fullDataRowIdData[rowid] = rest
|
|
92
92
|
fullAllDataRowIdData[rowid] = rest
|
|
93
93
|
}
|
|
@@ -176,7 +176,7 @@ const editHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
176
176
|
item[treeOpts.parentField] = parentRow[treeOpts.rowField]
|
|
177
177
|
}
|
|
178
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 }
|
|
179
|
+
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1 }
|
|
180
180
|
fullDataRowIdData[rowid] = rest
|
|
181
181
|
fullAllDataRowIdData[rowid] = rest
|
|
182
182
|
})
|
|
@@ -2,7 +2,7 @@ import { inject, nextTick } from 'vue'
|
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
3
|
import GlobalConfig from '../../v-x-e-table/src/conf'
|
|
4
4
|
import { VXETable } from '../../v-x-e-table'
|
|
5
|
-
import { isColumnInfo, mergeBodyMethod, getCellValue } from '../../table/src/util'
|
|
5
|
+
import { isColumnInfo, mergeBodyMethod, getCellValue, toTreePathSeq } from '../../table/src/util'
|
|
6
6
|
import { errLog, warnLog, parseFile, formatText } from '../../tools/utils'
|
|
7
7
|
import { readLocalFile, handlePrint, saveLocalFile, createHtmlPage, getExportBlobByContent } from './util'
|
|
8
8
|
|
|
@@ -295,14 +295,14 @@ const tableExportHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
295
295
|
return row[treeOpts.children] && row[treeOpts.children].length
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
const getSeq = (row: any, rowIndex: any, column: any, columnIndex: any,
|
|
298
|
+
const getSeq = (row: any, rowIndex: any, column: any, columnIndex: any, path: string[] | null) => {
|
|
299
299
|
const seqOpts = computeSeqOpts.value
|
|
300
300
|
const seqMethod = seqOpts.seqMethod || column.seqMethod
|
|
301
301
|
if (seqMethod) {
|
|
302
302
|
return seqMethod({ row, rowIndex, column, columnIndex })
|
|
303
303
|
}
|
|
304
|
-
if (
|
|
305
|
-
return
|
|
304
|
+
if (path) {
|
|
305
|
+
return toTreePathSeq(path)
|
|
306
306
|
}
|
|
307
307
|
return seqOpts.startIndex + rowIndex + 1
|
|
308
308
|
}
|
|
@@ -2,7 +2,7 @@ import { nextTick } from 'vue'
|
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
3
|
import { VXETable } from '../../v-x-e-table'
|
|
4
4
|
import { toFilters, handleFieldOrColumn } from '../../table/src/util'
|
|
5
|
-
import { getDomNode } from '../../tools/dom'
|
|
5
|
+
import { getDomNode, triggerEvent } from '../../tools/dom'
|
|
6
6
|
|
|
7
7
|
import { VxeGlobalHooksHandles, TableFilterMethods, TableFilterPrivateMethods } from '../../../types/all'
|
|
8
8
|
|
|
@@ -172,6 +172,25 @@ const tableFilterHook: VxeGlobalHooksHandles.HookOptions = {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
const filterMethods: TableFilterMethods = {
|
|
175
|
+
/**
|
|
176
|
+
* 手动弹出筛选面板
|
|
177
|
+
* @param column
|
|
178
|
+
*/
|
|
179
|
+
openFilter (fieldOrColumn) {
|
|
180
|
+
const column = handleFieldOrColumn($xetable, fieldOrColumn)
|
|
181
|
+
if (column && column.filters) {
|
|
182
|
+
const { elemStore } = internalData
|
|
183
|
+
const { fixed } = column
|
|
184
|
+
return $xetable.scrollToColumn(column).then(() => {
|
|
185
|
+
const headerWrapperElem = elemStore[`${fixed || 'main'}-header-wrapper`] || elemStore['main-header-wrapper']
|
|
186
|
+
if (headerWrapperElem) {
|
|
187
|
+
const filterBtnElem = headerWrapperElem.querySelector(`.vxe-header--column.${column.id} .vxe-filter--btn`)
|
|
188
|
+
triggerEvent(filterBtnElem, 'click')
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
return nextTick()
|
|
193
|
+
},
|
|
175
194
|
/**
|
|
176
195
|
* 修改筛选条件列表
|
|
177
196
|
* @param {ColumnInfo} fieldOrColumn 列或字段名
|
|
@@ -108,7 +108,7 @@ export default defineComponent({
|
|
|
108
108
|
/**
|
|
109
109
|
* 渲染列
|
|
110
110
|
*/
|
|
111
|
-
const renderColumn = (
|
|
111
|
+
const renderColumn = (seq: number | string, rowid: string, fixedType: any, rowLevel: number, row: any, rowIndex: number, $rowIndex: number, _rowIndex: number, column: any, $columnIndex: number, columns: any, items: any[]) => {
|
|
112
112
|
const { columnKey, height, showOverflow: allColumnOverflow, cellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig } = tableProps
|
|
113
113
|
const { tableData, overflowX, scrollYLoad, currentColumn, mergeList, editStore, validStore, isAllOverflow } = tableReactData
|
|
114
114
|
const { afterFullData } = tableInternalData
|
|
@@ -138,7 +138,7 @@ export default defineComponent({
|
|
|
138
138
|
const hasValidError = validStore.row === row && validStore.column === column
|
|
139
139
|
const showValidTip = editRules && validOpts.showMessage && (validOpts.message === 'default' ? (height || tableData.length > 1) : validOpts.message === 'inline')
|
|
140
140
|
const attrs: any = { colid: column.id }
|
|
141
|
-
const params: VxeTableDefines.CellRenderBodyParams = { $table: $xetable,
|
|
141
|
+
const params: VxeTableDefines.CellRenderBodyParams = { $table: $xetable, seq, rowid, row, rowIndex, $rowIndex, _rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, level: rowLevel, visibleData: afterFullData, data: tableData, items }
|
|
142
142
|
// 虚拟滚动不支持动态高度
|
|
143
143
|
if (scrollYLoad && !hasEllipsis) {
|
|
144
144
|
showEllipsis = hasEllipsis = true
|
|
@@ -291,10 +291,10 @@ export default defineComponent({
|
|
|
291
291
|
}, tdVNs)
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
const renderRows = (
|
|
294
|
+
const renderRows = (fixedType: any, tableData: any, tableColumn: any) => {
|
|
295
295
|
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, showOverflow: allColumnOverflow, editConfig, treeConfig } = tableProps
|
|
296
296
|
const { hasFixedColumn, treeExpandeds, scrollYLoad, editStore, rowExpandeds, expandColumn, selectRow } = tableReactData
|
|
297
|
-
const {
|
|
297
|
+
const { fullDataRowIdData } = tableInternalData
|
|
298
298
|
const checkboxOpts = computeCheckboxOpts.value
|
|
299
299
|
const radioOpts = computeRadioOpts.value
|
|
300
300
|
const treeOpts = computeTreeOpts.value
|
|
@@ -304,10 +304,6 @@ export default defineComponent({
|
|
|
304
304
|
tableData.forEach((row: any, $rowIndex: any) => {
|
|
305
305
|
const trOn: any = {}
|
|
306
306
|
let rowIndex = $rowIndex
|
|
307
|
-
let seq = rowIndex + 1
|
|
308
|
-
if (scrollYLoad) {
|
|
309
|
-
seq += scrollYStore.startIndex
|
|
310
|
-
}
|
|
311
307
|
const _rowIndex = $xetable.getVTRowIndex(row)
|
|
312
308
|
// 确保任何情况下 rowIndex 都精准指向真实 data 索引
|
|
313
309
|
rowIndex = $xetable.getRowIndex(row)
|
|
@@ -327,9 +323,10 @@ export default defineComponent({
|
|
|
327
323
|
}
|
|
328
324
|
}
|
|
329
325
|
const rowid = getRowid($xetable, row)
|
|
330
|
-
const rest =
|
|
326
|
+
const rest = fullDataRowIdData[rowid]
|
|
331
327
|
const rowLevel = rest ? rest.level : 0
|
|
332
|
-
const
|
|
328
|
+
const seq = rest ? rest.seq : -1
|
|
329
|
+
const params = { $table: $xetable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
|
|
333
330
|
let isNewRow = false
|
|
334
331
|
if (editConfig) {
|
|
335
332
|
isNewRow = $xetable.findRowIndexOf(editStore.insertList, row) > -1
|
|
@@ -348,7 +345,7 @@ export default defineComponent({
|
|
|
348
345
|
key: rowKey || treeConfig ? rowid : $rowIndex,
|
|
349
346
|
...trOn
|
|
350
347
|
}, tableColumn.map((column: any, $columnIndex: any) => {
|
|
351
|
-
return renderColumn(
|
|
348
|
+
return renderColumn(seq, rowid, fixedType, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
|
|
352
349
|
}))
|
|
353
350
|
)
|
|
354
351
|
// 如果行被展开了
|
|
@@ -361,7 +358,7 @@ export default defineComponent({
|
|
|
361
358
|
}
|
|
362
359
|
const { showOverflow } = expandColumn
|
|
363
360
|
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? allColumnOverflow : showOverflow
|
|
364
|
-
const expandParams = { $table: $xetable,
|
|
361
|
+
const expandParams = { $table: $xetable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
|
|
365
362
|
rows.push(
|
|
366
363
|
h('tr', {
|
|
367
364
|
class: 'vxe-body--expanded-row',
|
|
@@ -390,7 +387,7 @@ export default defineComponent({
|
|
|
390
387
|
if (treeConfig && !scrollYLoad && treeExpandeds.length) {
|
|
391
388
|
const rowChildren = row[treeOpts.children]
|
|
392
389
|
if (rowChildren && rowChildren.length && $xetable.findRowIndexOf(treeExpandeds, row) > -1) {
|
|
393
|
-
rows.push(...renderRows(
|
|
390
|
+
rows.push(...renderRows(fixedType, rowChildren, tableColumn))
|
|
394
391
|
}
|
|
395
392
|
}
|
|
396
393
|
})
|
|
@@ -689,7 +686,7 @@ export default defineComponent({
|
|
|
689
686
|
*/
|
|
690
687
|
h('tbody', {
|
|
691
688
|
ref: refBodyTBody
|
|
692
|
-
}, renderRows(
|
|
689
|
+
}, renderRows(fixedType, tableData, tableColumn))
|
|
693
690
|
]),
|
|
694
691
|
h('div', {
|
|
695
692
|
class: 'vxe-table--checkbox-range'
|
|
@@ -107,16 +107,16 @@ export const Cell = {
|
|
|
107
107
|
}
|
|
108
108
|
switch (type) {
|
|
109
109
|
case 'seq':
|
|
110
|
-
renConfs.renderHeader = Cell.
|
|
111
|
-
renConfs.renderCell = treeNode ? Cell.renderTreeIndexCell : Cell.
|
|
110
|
+
renConfs.renderHeader = Cell.renderSeqHeader
|
|
111
|
+
renConfs.renderCell = treeNode ? Cell.renderTreeIndexCell : Cell.renderSeqCell
|
|
112
112
|
break
|
|
113
113
|
case 'radio':
|
|
114
114
|
renConfs.renderHeader = Cell.renderRadioHeader
|
|
115
115
|
renConfs.renderCell = treeNode ? Cell.renderTreeRadioCell : Cell.renderRadioCell
|
|
116
116
|
break
|
|
117
117
|
case 'checkbox':
|
|
118
|
-
renConfs.renderHeader = Cell.
|
|
119
|
-
renConfs.renderCell = checkboxOpts.checkField ? (treeNode ? Cell.renderTreeSelectionCellByProp : Cell.
|
|
118
|
+
renConfs.renderHeader = Cell.renderCheckboxHeader
|
|
119
|
+
renConfs.renderCell = checkboxOpts.checkField ? (treeNode ? Cell.renderTreeSelectionCellByProp : Cell.renderCheckboxCellByProp) : (treeNode ? Cell.renderTreeSelectionCell : Cell.renderCheckboxCell)
|
|
120
120
|
break
|
|
121
121
|
case 'expand':
|
|
122
122
|
renConfs.renderCell = Cell.renderExpandCell
|
|
@@ -268,14 +268,16 @@ export const Cell = {
|
|
|
268
268
|
/**
|
|
269
269
|
* 索引
|
|
270
270
|
*/
|
|
271
|
-
|
|
271
|
+
renderSeqHeader (params: VxeTableDefines.CellRenderHeaderParams) {
|
|
272
272
|
const { $table, column } = params
|
|
273
273
|
const { slots } = column
|
|
274
274
|
const headerSlot = slots ? slots.header : null
|
|
275
275
|
return renderTitleContent(params, headerSlot ? $table.callSlot(headerSlot, params) : formatText(column.getTitle(), 1))
|
|
276
276
|
},
|
|
277
|
-
|
|
277
|
+
renderSeqCell (params: VxeTableDefines.CellRenderBodyParams) {
|
|
278
278
|
const { $table, column } = params
|
|
279
|
+
const { props } = $table
|
|
280
|
+
const { treeConfig } = props
|
|
279
281
|
const { computeSeqOpts } = $table.getComputeMaps()
|
|
280
282
|
const seqOpts = computeSeqOpts.value
|
|
281
283
|
const { slots } = column
|
|
@@ -283,12 +285,12 @@ export const Cell = {
|
|
|
283
285
|
if (defaultSlot) {
|
|
284
286
|
return $table.callSlot(defaultSlot, params)
|
|
285
287
|
}
|
|
286
|
-
const {
|
|
288
|
+
const { seq } = params
|
|
287
289
|
const seqMethod = seqOpts.seqMethod
|
|
288
|
-
return [formatText(seqMethod ? seqMethod(params) :
|
|
290
|
+
return [formatText(seqMethod ? seqMethod(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + (seq as number), 1)]
|
|
289
291
|
},
|
|
290
292
|
renderTreeIndexCell (params: VxeTableDefines.CellRenderBodyParams) {
|
|
291
|
-
return Cell.renderTreeIcon(params, Cell.
|
|
293
|
+
return Cell.renderTreeIcon(params, Cell.renderSeqCell(params) as VNode[])
|
|
292
294
|
},
|
|
293
295
|
|
|
294
296
|
/**
|
|
@@ -371,7 +373,7 @@ export const Cell = {
|
|
|
371
373
|
/**
|
|
372
374
|
* 多选
|
|
373
375
|
*/
|
|
374
|
-
|
|
376
|
+
renderCheckboxHeader (params: VxeTableDefines.CellRenderHeaderParams) {
|
|
375
377
|
const { $table, column, isHidden } = params
|
|
376
378
|
const { reactData } = $table
|
|
377
379
|
const { computeIsAllCheckboxDisabled, computeCheckboxOpts } = $table.getComputeMaps()
|
|
@@ -431,7 +433,7 @@ export const Cell = {
|
|
|
431
433
|
] : []))
|
|
432
434
|
])
|
|
433
435
|
},
|
|
434
|
-
|
|
436
|
+
renderCheckboxCell (params: VxeTableDefines.CellRenderBodyParams) {
|
|
435
437
|
const { $table, row, column, isHidden } = params
|
|
436
438
|
const { props, reactData } = $table
|
|
437
439
|
const { treeConfig } = props
|
|
@@ -500,9 +502,9 @@ export const Cell = {
|
|
|
500
502
|
]
|
|
501
503
|
},
|
|
502
504
|
renderTreeSelectionCell (params: VxeTableDefines.CellRenderBodyParams) {
|
|
503
|
-
return Cell.renderTreeIcon(params, Cell.
|
|
505
|
+
return Cell.renderTreeIcon(params, Cell.renderCheckboxCell(params))
|
|
504
506
|
},
|
|
505
|
-
|
|
507
|
+
renderCheckboxCellByProp (params: VxeTableDefines.CellRenderBodyParams) {
|
|
506
508
|
const { $table, row, column, isHidden } = params
|
|
507
509
|
const { props, reactData } = $table
|
|
508
510
|
const { treeConfig } = props
|
|
@@ -571,7 +573,7 @@ export const Cell = {
|
|
|
571
573
|
]
|
|
572
574
|
},
|
|
573
575
|
renderTreeSelectionCellByProp (params: VxeTableDefines.CellRenderBodyParams) {
|
|
574
|
-
return Cell.renderTreeIcon(params, Cell.
|
|
576
|
+
return Cell.renderTreeIcon(params, Cell.renderCheckboxCellByProp(params))
|
|
575
577
|
},
|
|
576
578
|
|
|
577
579
|
/**
|
|
@@ -11,7 +11,7 @@ import Cell from './cell'
|
|
|
11
11
|
import TableBodyComponent from './body'
|
|
12
12
|
import tableProps from './props'
|
|
13
13
|
import tableEmits from './emits'
|
|
14
|
-
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, restoreScrollLocation, restoreScrollListener, XEBodyScrollElement } from './util'
|
|
14
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, restoreScrollListener, XEBodyScrollElement } from './util'
|
|
15
15
|
|
|
16
16
|
import { VxeGridConstructor, VxeGridPrivateMethods, VxeTableConstructor, TableReactData, TableInternalData, VxeTablePropTypes, VxeToolbarConstructor, VxeTooltipInstance, TablePrivateMethods, VxeTablePrivateRef, VxeTablePrivateComputed, VxeTablePrivateMethods, VxeTableMethods, TableMethods, VxeMenuPanelInstance, VxeTableDefines, VxeTableProps } from '../../../types/all'
|
|
17
17
|
|
|
@@ -271,8 +271,9 @@ export default defineComponent({
|
|
|
271
271
|
tableFullColumn: [],
|
|
272
272
|
// 渲染所有列
|
|
273
273
|
visibleColumn: [],
|
|
274
|
-
//
|
|
274
|
+
// 总的缓存数据集
|
|
275
275
|
fullAllDataRowIdData: {},
|
|
276
|
+
// 渲染中缓存数据
|
|
276
277
|
fullDataRowIdData: {},
|
|
277
278
|
fullColumnIdData: {},
|
|
278
279
|
fullColumnFieldData: {},
|
|
@@ -1130,17 +1131,49 @@ export default defineComponent({
|
|
|
1130
1131
|
}
|
|
1131
1132
|
}
|
|
1132
1133
|
|
|
1134
|
+
/**
|
|
1135
|
+
* 预编译
|
|
1136
|
+
* 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
|
|
1137
|
+
*/
|
|
1133
1138
|
const updateAfterDataIndex = () => {
|
|
1134
|
-
const {
|
|
1135
|
-
afterFullData
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1139
|
+
const { treeConfig } = props
|
|
1140
|
+
const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
1141
|
+
const { treeFullData } = internalData
|
|
1142
|
+
const treeOpts = computeTreeOpts.value
|
|
1143
|
+
if (treeConfig) {
|
|
1144
|
+
XEUtils.eachTree(treeFullData, (row, index, items, path) => {
|
|
1145
|
+
const rowid = getRowid($xetable, row)
|
|
1146
|
+
const allrest = fullAllDataRowIdData[rowid]
|
|
1147
|
+
const fullrest = fullDataRowIdData[rowid]
|
|
1148
|
+
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
1149
|
+
if (allrest) {
|
|
1150
|
+
allrest.seq = seq
|
|
1151
|
+
}
|
|
1152
|
+
if (fullrest) {
|
|
1153
|
+
fullrest.seq = seq
|
|
1154
|
+
} else {
|
|
1155
|
+
fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1156
|
+
fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1157
|
+
}
|
|
1158
|
+
}, treeOpts)
|
|
1159
|
+
} else {
|
|
1160
|
+
afterFullData.forEach((row, index) => {
|
|
1161
|
+
const rowid = getRowid($xetable, row)
|
|
1162
|
+
const allrest = fullAllDataRowIdData[rowid]
|
|
1163
|
+
const fullrest = fullDataRowIdData[rowid]
|
|
1164
|
+
const seq = index + 1
|
|
1165
|
+
if (allrest) {
|
|
1166
|
+
allrest.seq = seq
|
|
1167
|
+
}
|
|
1168
|
+
if (fullrest) {
|
|
1169
|
+
fullrest.seq = seq
|
|
1170
|
+
fullrest._index = index
|
|
1171
|
+
} else {
|
|
1172
|
+
fullAllDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1173
|
+
fullDataRowIdData[rowid] = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1174
|
+
}
|
|
1175
|
+
})
|
|
1176
|
+
}
|
|
1144
1177
|
}
|
|
1145
1178
|
|
|
1146
1179
|
/**
|
|
@@ -2062,11 +2095,11 @@ export default defineComponent({
|
|
|
2062
2095
|
tableMethods.clearMergeFooterItems()
|
|
2063
2096
|
}
|
|
2064
2097
|
reactData.scrollXLoad = scrollXLoad
|
|
2065
|
-
visibleColumn.forEach((column,
|
|
2098
|
+
visibleColumn.forEach((column, index) => {
|
|
2066
2099
|
const colid = column.id
|
|
2067
2100
|
const rest = fullColumnIdData[colid]
|
|
2068
2101
|
if (rest) {
|
|
2069
|
-
rest._index =
|
|
2102
|
+
rest._index = index
|
|
2070
2103
|
}
|
|
2071
2104
|
})
|
|
2072
2105
|
internalData.visibleColumn = visibleColumn
|
|
@@ -2224,6 +2257,33 @@ export default defineComponent({
|
|
|
2224
2257
|
}
|
|
2225
2258
|
}
|
|
2226
2259
|
|
|
2260
|
+
const createGetRowCacheProp = (prop: 'seq' | 'index' | '_index' | '$index') => {
|
|
2261
|
+
return function (row: any) {
|
|
2262
|
+
const { fullDataRowIdData } = internalData
|
|
2263
|
+
if (row) {
|
|
2264
|
+
const rowid = getRowid($xetable, row)
|
|
2265
|
+
const rest = fullDataRowIdData[rowid]
|
|
2266
|
+
if (rest) {
|
|
2267
|
+
return rest[prop]
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
return -1
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
const createGetColumnCacheProp = (prop: 'index' | '_index' | '$index') => {
|
|
2275
|
+
return function (column: VxeTableDefines.ColumnInfo) {
|
|
2276
|
+
const { fullColumnIdData } = internalData
|
|
2277
|
+
if (column) {
|
|
2278
|
+
const rest = fullColumnIdData[column.id]
|
|
2279
|
+
if (rest) {
|
|
2280
|
+
return rest[prop]
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
return -1
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2227
2287
|
const debounceScrollY = XEUtils.debounce(function (evnt: Event) {
|
|
2228
2288
|
loadScrollYData(evnt)
|
|
2229
2289
|
}, 20, { leading: false, trailing: true })
|
|
@@ -2349,7 +2409,7 @@ export default defineComponent({
|
|
|
2349
2409
|
}
|
|
2350
2410
|
XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
|
|
2351
2411
|
const rowid = getRowid($xetable, childRow)
|
|
2352
|
-
const rest = { row: childRow, rowid, index: -1, _index: -1, $index: -1, items, parent, level: parentLevel + nodes.length }
|
|
2412
|
+
const rest = { row: childRow, rowid, seq: -1, index: -1, _index: -1, $index: -1, items, parent, level: parentLevel + nodes.length }
|
|
2353
2413
|
fullDataRowIdData[rowid] = rest
|
|
2354
2414
|
fullAllDataRowIdData[rowid] = rest
|
|
2355
2415
|
}, treeOpts)
|
|
@@ -2410,93 +2470,41 @@ export default defineComponent({
|
|
|
2410
2470
|
}
|
|
2411
2471
|
return null
|
|
2412
2472
|
},
|
|
2473
|
+
/**
|
|
2474
|
+
* 根据 row 获取序号
|
|
2475
|
+
* @param {Row} row 行对象
|
|
2476
|
+
*/
|
|
2477
|
+
getRowSeq: createGetRowCacheProp('seq'),
|
|
2413
2478
|
/**
|
|
2414
2479
|
* 根据 row 获取相对于 data 中的索引
|
|
2415
2480
|
* @param {Row} row 行对象
|
|
2416
2481
|
*/
|
|
2417
|
-
getRowIndex (row)
|
|
2418
|
-
const { fullDataRowIdData } = internalData
|
|
2419
|
-
if (row) {
|
|
2420
|
-
const rowid = getRowid($xetable, row)
|
|
2421
|
-
const rest = fullDataRowIdData[rowid]
|
|
2422
|
-
if (rest) {
|
|
2423
|
-
return rest.index
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
return -1
|
|
2427
|
-
},
|
|
2482
|
+
getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
|
|
2428
2483
|
/**
|
|
2429
2484
|
* 根据 row 获取相对于当前数据中的索引
|
|
2430
2485
|
* @param {Row} row 行对象
|
|
2431
2486
|
*/
|
|
2432
|
-
getVTRowIndex (row)
|
|
2433
|
-
const { fullDataRowIdData } = internalData
|
|
2434
|
-
if (row) {
|
|
2435
|
-
const rowid = getRowid($xetable, row)
|
|
2436
|
-
const rest = fullDataRowIdData[rowid]
|
|
2437
|
-
if (rest) {
|
|
2438
|
-
return rest._index
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
return -1
|
|
2442
|
-
},
|
|
2487
|
+
getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
|
|
2443
2488
|
/**
|
|
2444
2489
|
* 根据 row 获取渲染中的虚拟索引
|
|
2445
2490
|
* @param {Row} row 行对象
|
|
2446
2491
|
*/
|
|
2447
|
-
getVMRowIndex (row)
|
|
2448
|
-
const { fullDataRowIdData } = internalData
|
|
2449
|
-
if (row) {
|
|
2450
|
-
const rowid = getRowid($xetable, row)
|
|
2451
|
-
const rest = fullDataRowIdData[rowid]
|
|
2452
|
-
if (rest) {
|
|
2453
|
-
return rest.$index
|
|
2454
|
-
}
|
|
2455
|
-
}
|
|
2456
|
-
return -1
|
|
2457
|
-
},
|
|
2492
|
+
getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
|
|
2458
2493
|
/**
|
|
2459
2494
|
* 根据 column 获取相对于 columns 中的索引
|
|
2460
2495
|
* @param {ColumnInfo} column 列配置
|
|
2461
2496
|
*/
|
|
2462
|
-
getColumnIndex (
|
|
2463
|
-
const { fullColumnIdData } = internalData
|
|
2464
|
-
if (column) {
|
|
2465
|
-
const rest = fullColumnIdData[column.id]
|
|
2466
|
-
if (rest) {
|
|
2467
|
-
return rest.index
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
return -1
|
|
2471
|
-
},
|
|
2497
|
+
getColumnIndex: createGetColumnCacheProp('index'),
|
|
2472
2498
|
/**
|
|
2473
2499
|
* 根据 column 获取相对于当前表格列中的索引
|
|
2474
2500
|
* @param {ColumnInfo} column 列配置
|
|
2475
2501
|
*/
|
|
2476
|
-
getVTColumnIndex (
|
|
2477
|
-
const { fullColumnIdData } = internalData
|
|
2478
|
-
if (column) {
|
|
2479
|
-
const rest = fullColumnIdData[column.id]
|
|
2480
|
-
if (rest) {
|
|
2481
|
-
return rest._index
|
|
2482
|
-
}
|
|
2483
|
-
}
|
|
2484
|
-
return -1
|
|
2485
|
-
},
|
|
2502
|
+
getVTColumnIndex: createGetColumnCacheProp('_index'),
|
|
2486
2503
|
/**
|
|
2487
2504
|
* 根据 column 获取渲染中的虚拟索引
|
|
2488
2505
|
* @param {ColumnInfo} column 列配置
|
|
2489
2506
|
*/
|
|
2490
|
-
getVMColumnIndex (
|
|
2491
|
-
const { fullColumnIdData } = internalData
|
|
2492
|
-
if (column) {
|
|
2493
|
-
const rest = fullColumnIdData[column.id]
|
|
2494
|
-
if (rest) {
|
|
2495
|
-
return rest.$index
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
return -1
|
|
2499
|
-
},
|
|
2507
|
+
getVMColumnIndex: createGetColumnCacheProp('$index'),
|
|
2500
2508
|
/**
|
|
2501
2509
|
* 创建 data 对象
|
|
2502
2510
|
* 对于某些特殊场景可能会用到,会自动对数据的字段名进行检测,如果不存在就自动定义
|
|
@@ -4464,8 +4472,10 @@ export default defineComponent({
|
|
|
4464
4472
|
let { fullDataRowIdData, fullAllDataRowIdData, tableFullData, treeFullData } = internalData
|
|
4465
4473
|
const rowkey = getRowkey($xetable)
|
|
4466
4474
|
const isLazy = treeConfig && treeOpts.lazy
|
|
4467
|
-
const handleCache = (row: any, index: any, items: any, path?: any, parent?: any, nodes?: any[]) => {
|
|
4475
|
+
const handleCache = (row: any, index: any, items: any, path?: any[], parent?: any, nodes?: any[]) => {
|
|
4468
4476
|
let rowid = getRowid($xetable, row)
|
|
4477
|
+
const seq = treeConfig && path ? toTreePathSeq(path) : index + 1
|
|
4478
|
+
const level = nodes ? nodes.length - 1 : 0
|
|
4469
4479
|
if (eqEmptyValue(rowid)) {
|
|
4470
4480
|
rowid = getRowUniqueId()
|
|
4471
4481
|
XEUtils.set(row, rowkey, rowid)
|
|
@@ -4473,7 +4483,7 @@ export default defineComponent({
|
|
|
4473
4483
|
if (isLazy && row[treeOpts.hasChild] && XEUtils.isUndefined(row[treeOpts.children])) {
|
|
4474
4484
|
row[treeOpts.children] = null
|
|
4475
4485
|
}
|
|
4476
|
-
const rest = { row, rowid, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items, parent, level
|
|
4486
|
+
const rest = { row, rowid, seq, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items, parent, level }
|
|
4477
4487
|
if (isSource) {
|
|
4478
4488
|
fullDataRowIdData[rowid] = rest
|
|
4479
4489
|
}
|
|
@@ -98,6 +98,10 @@ export function toFilters (filters: any) {
|
|
|
98
98
|
return filters
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
export function toTreePathSeq (path: any[]) {
|
|
102
|
+
return path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
103
|
+
}
|
|
104
|
+
|
|
101
105
|
export function getCellValue (row: any, column: any) {
|
|
102
106
|
return XEUtils.get(row, column.property)
|
|
103
107
|
}
|
package/packages/tools/dom.ts
CHANGED
|
@@ -142,12 +142,7 @@ export function scrollToView (elem: any) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export function triggerEvent (targetElem: Element, type: string) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
evnt = new Event(type)
|
|
148
|
-
} else {
|
|
149
|
-
evnt = document.createEvent('Event')
|
|
150
|
-
evnt.initEvent(type, true, true)
|
|
145
|
+
if (targetElem) {
|
|
146
|
+
targetElem.dispatchEvent(new Event(type))
|
|
151
147
|
}
|
|
152
|
-
targetElem.dispatchEvent(evnt)
|
|
153
148
|
}
|
package/types/filter.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface VxeFilterPanel {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface TableFilterMethods {
|
|
35
|
+
/**
|
|
36
|
+
* 手动弹出筛选
|
|
37
|
+
* @param fieldOrColumn
|
|
38
|
+
*/
|
|
39
|
+
openFilter(fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo):Promise<any>;
|
|
35
40
|
/**
|
|
36
41
|
* 用于 filters,修改筛选列表
|
|
37
42
|
* 在筛选条件更新之后可以调用 updateData 函数处理表格数据
|
package/types/plugins/pro.d.ts
CHANGED
|
@@ -81,6 +81,11 @@ declare module '../table' {
|
|
|
81
81
|
interface VxeTablePrivateMethods extends VxeTableProPrivateMethods { }
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
declare module '../grid' {
|
|
85
|
+
interface VxeGridMethods extends VxeTableProMethods { }
|
|
86
|
+
interface VxeGridPrivateMethods extends VxeTableProPrivateMethods { }
|
|
87
|
+
}
|
|
88
|
+
|
|
84
89
|
export interface VXETableProClipboard {
|
|
85
90
|
text?: string;
|
|
86
91
|
html?: string;
|