vxe-table 3.12.9 → 3.12.10-beta.0
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/grid/src/grid.js +6 -1
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/export/mixin.js +3 -3
- package/es/table/module/filter/mixin.js +3 -3
- package/es/table/module/keyboard/mixin.js +4 -4
- package/es/table/module/menu/mixin.js +2 -2
- package/es/table/module/validator/mixin.js +2 -2
- package/es/table/src/body.js +247 -351
- package/es/table/src/footer.js +135 -154
- package/es/table/src/header.js +120 -100
- package/es/table/src/methods.js +1174 -790
- package/es/table/src/props.js +9 -3
- package/es/table/src/table.js +187 -103
- package/es/table/src/util.js +16 -7
- package/es/table/style.css +146 -63
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +14 -4
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +146 -63
- package/es/vxe-table/style.min.css +1 -1
- package/lib/grid/src/grid.js +4 -1
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +1896 -1543
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/export/mixin.js +3 -3
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/filter/mixin.js +4 -4
- package/lib/table/module/filter/mixin.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +5 -5
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +2 -2
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +2 -2
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/body.js +185 -365
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/footer.js +124 -151
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +97 -74
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +1258 -830
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +9 -3
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +171 -90
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +17 -7
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +146 -63
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +14 -4
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +146 -63
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/grid/src/grid.ts +6 -1
- package/packages/table/module/export/mixin.ts +3 -3
- package/packages/table/module/filter/mixin.ts +3 -3
- package/packages/table/module/keyboard/mixin.ts +4 -4
- package/packages/table/module/menu/mixin.ts +2 -2
- package/packages/table/module/validator/mixin.ts +2 -2
- package/packages/table/src/body.ts +281 -427
- package/packages/table/src/footer.ts +148 -164
- package/packages/table/src/header.ts +135 -111
- package/packages/table/src/methods.ts +1246 -845
- package/packages/table/src/props.ts +9 -3
- package/packages/table/src/table.ts +195 -146
- package/packages/table/src/util.ts +17 -7
- package/packages/ui/index.ts +13 -3
- package/styles/components/table.scss +164 -74
- /package/es/{iconfont.1736414871619.ttf → iconfont.1736688976404.ttf} +0 -0
- /package/es/{iconfont.1736414871619.woff → iconfont.1736688976404.woff} +0 -0
- /package/es/{iconfont.1736414871619.woff2 → iconfont.1736688976404.woff2} +0 -0
- /package/lib/{iconfont.1736414871619.ttf → iconfont.1736688976404.ttf} +0 -0
- /package/lib/{iconfont.1736414871619.woff → iconfont.1736688976404.woff} +0 -0
- /package/lib/{iconfont.1736414871619.woff2 → iconfont.1736688976404.woff2} +0 -0
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { CreateElement } from 'vue'
|
|
1
|
+
import { PropType, CreateElement } from 'vue'
|
|
2
2
|
import XEUtils from 'xe-utils'
|
|
3
3
|
import { VxeUI } from '../../ui'
|
|
4
4
|
import { isEnableConf, getClass } from '../../ui/src/utils'
|
|
5
5
|
import { getOffsetSize, calcTreeLine, mergeBodyMethod, getRowid } from './util'
|
|
6
|
-
import { updateCellTitle
|
|
6
|
+
import { updateCellTitle } from '../../ui/src/dom'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
|
|
9
|
-
import type { VxeTableConstructor, TableInternalData, VxeTablePrivateMethods } from '../../../types'
|
|
9
|
+
import type { VxeTableConstructor, VxeTableDefines, TableInternalData, VxeTablePrivateMethods, TableReactData, VxeColumnPropTypes, VxeComponentStyleType } from '../../../types'
|
|
10
10
|
|
|
11
11
|
const { getI18n, renderer, renderEmptyElement } = VxeUI
|
|
12
12
|
|
|
13
13
|
const renderType = 'body'
|
|
14
14
|
|
|
15
15
|
// 滚动、拖动过程中不需要触发
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const isVMScrollProcess = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) => {
|
|
17
|
+
const tableProps = $xeTable
|
|
18
|
+
const tableReactData = $xeTable as unknown as TableReactData
|
|
19
|
+
|
|
20
|
+
const { delayHover } = tableProps
|
|
21
|
+
const { lastScrollTime, _isResize } = tableReactData
|
|
22
|
+
return !!(_isResize || (lastScrollTime && Date.now() < lastScrollTime + (delayHover as number)))
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
function renderLine (h: CreateElement, _vm: any,
|
|
25
|
+
function renderLine (h: CreateElement, _vm: any, params: VxeTableDefines.CellRenderBodyParams) {
|
|
26
|
+
const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
|
|
21
27
|
const tableProps = $xeTable
|
|
22
28
|
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
23
29
|
|
|
@@ -27,8 +33,8 @@ function renderLine (h: CreateElement, _vm: any, $xeTable: VxeTableConstructor &
|
|
|
27
33
|
const treeOpts = $xeTable.computeTreeOpts
|
|
28
34
|
const { slots, treeNode } = column
|
|
29
35
|
const { fullAllDataRowIdData } = tableInternalData
|
|
30
|
-
if (slots && slots.line) {
|
|
31
|
-
return $xeTable.callSlot(slots.line, params, h)
|
|
36
|
+
if (slots && (slots as any).line) {
|
|
37
|
+
return $xeTable.callSlot((slots as any).line, params, h)
|
|
32
38
|
}
|
|
33
39
|
const rowid = getRowid($xeTable, row)
|
|
34
40
|
const rest = fullAllDataRowIdData[rowid]
|
|
@@ -60,60 +66,55 @@ function renderLine (h: CreateElement, _vm: any, $xeTable: VxeTableConstructor &
|
|
|
60
66
|
/**
|
|
61
67
|
* 渲染列
|
|
62
68
|
*/
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
editStore,
|
|
96
|
-
tooltipConfig,
|
|
97
|
-
rowOpts,
|
|
98
|
-
columnOpts,
|
|
99
|
-
mouseOpts,
|
|
100
|
-
areaOpts,
|
|
101
|
-
validErrorMaps
|
|
102
|
-
} = $xeTable
|
|
69
|
+
function renderTdColumn (
|
|
70
|
+
h: CreateElement,
|
|
71
|
+
_vm: any,
|
|
72
|
+
seq: number | string,
|
|
73
|
+
rowid: string,
|
|
74
|
+
fixedType: VxeColumnPropTypes.Fixed,
|
|
75
|
+
isOptimizeMode: boolean,
|
|
76
|
+
rowLevel: number,
|
|
77
|
+
row: any,
|
|
78
|
+
rowIndex: number,
|
|
79
|
+
$rowIndex: number,
|
|
80
|
+
_rowIndex: number,
|
|
81
|
+
column: VxeTableDefines.ColumnInfo,
|
|
82
|
+
$columnIndex: number,
|
|
83
|
+
columns: VxeTableDefines.ColumnInfo[],
|
|
84
|
+
items: any[]
|
|
85
|
+
) {
|
|
86
|
+
const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
|
|
87
|
+
const tableProps = $xeTable
|
|
88
|
+
const tableReactData = $xeTable as unknown as TableReactData
|
|
89
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
90
|
+
|
|
91
|
+
const { fullAllDataRowIdData } = tableInternalData
|
|
92
|
+
const { columnKey, height, showOverflow: allColumnOverflow, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig } = tableProps
|
|
93
|
+
const { tableData, overflowX, currentColumn, scrollXLoad, scrollYLoad, isCalcCellHeight, mergeList, editStore, isAllOverflow, validErrorMaps } = tableReactData
|
|
94
|
+
const { afterFullData, scrollXStore, scrollYStore } = tableInternalData
|
|
95
|
+
const cellOpts = $xeTable.computeCellOpts
|
|
96
|
+
const validOpts = $xeTable.computeValidOpts
|
|
97
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
98
|
+
const editOpts = $xeTable.computeEditOpts
|
|
99
|
+
const tooltipOpts = $xeTable.computeTooltipOpts
|
|
100
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
103
101
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
102
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
104
103
|
const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = rowDragOpts
|
|
104
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
105
|
+
const mouseOpts = $xeTable.computeMouseOpts
|
|
106
|
+
const areaOpts = $xeTable.computeAreaOpts
|
|
105
107
|
const { selectCellToRow } = areaOpts
|
|
106
|
-
const cellOpts = $xeTable.computeCellOpts
|
|
107
108
|
const { type, cellRender, editRender, align, showOverflow, className, treeNode, slots } = column
|
|
108
109
|
const { verticalAlign } = cellOpts
|
|
109
110
|
const { actived } = editStore
|
|
110
|
-
const {
|
|
111
|
-
const
|
|
111
|
+
const { height: customRHeight } = rowOpts
|
|
112
|
+
const colid = column.id
|
|
112
113
|
const renderOpts = editRender || cellRender
|
|
113
114
|
const compConf = renderOpts ? renderer.get(renderOpts.name) : null
|
|
114
|
-
const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) :
|
|
115
|
+
const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) : null
|
|
115
116
|
const compCellStyle = compConf ? (compConf.tableCellStyle || compConf.cellStyle) : ''
|
|
116
|
-
const showAllTip = tooltipOpts.showAll
|
|
117
|
+
const showAllTip = tooltipOpts.showAll
|
|
117
118
|
const columnIndex = $xeTable.getColumnIndex(column)
|
|
118
119
|
const _columnIndex = $xeTable.getVTColumnIndex(column)
|
|
119
120
|
const isEdit = isEnableConf(editRender)
|
|
@@ -124,17 +125,35 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
124
125
|
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
125
126
|
// 如果表格加上 showOverflow 则不再支持列单独设置
|
|
126
127
|
const hasEllipsis = allColumnOverflow || showTitle || showTooltip || showEllipsis
|
|
127
|
-
let isDirty
|
|
128
|
+
let isDirty
|
|
128
129
|
const tdOns: any = {}
|
|
129
130
|
const rest = fullAllDataRowIdData[rowid]
|
|
130
131
|
const cellAlign = align || (compConf ? compConf.tableCellAlign : '') || allAlign
|
|
131
|
-
const errorValidItem = validErrorMaps[`${rowid}:${
|
|
132
|
+
const errorValidItem = validErrorMaps[`${rowid}:${colid}`]
|
|
132
133
|
const showValidTip = editRules && validOpts.showMessage && (validOpts.message === 'default' ? (height || tableData.length > 1) : validOpts.message === 'inline')
|
|
133
|
-
const attrs: any = { colid
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
const attrs: any = { colid }
|
|
135
|
+
const params: VxeTableDefines.CellRenderBodyParams = {
|
|
136
|
+
$table: $xeTable,
|
|
137
|
+
$grid: $xeTable.xegrid,
|
|
138
|
+
isEdit: false,
|
|
139
|
+
seq,
|
|
140
|
+
rowid,
|
|
141
|
+
row,
|
|
142
|
+
rowIndex,
|
|
143
|
+
$rowIndex,
|
|
144
|
+
_rowIndex,
|
|
145
|
+
column,
|
|
146
|
+
columnIndex,
|
|
147
|
+
$columnIndex,
|
|
148
|
+
_columnIndex,
|
|
149
|
+
fixed: fixedType,
|
|
150
|
+
type: renderType,
|
|
151
|
+
isHidden: !!fixedHiddenColumn,
|
|
152
|
+
level: rowLevel,
|
|
153
|
+
visibleData: afterFullData,
|
|
154
|
+
data: tableData,
|
|
155
|
+
items
|
|
156
|
+
}
|
|
138
157
|
let isRowDragCell = false
|
|
139
158
|
let isDisabledDrag = false
|
|
140
159
|
if (rowOpts.drag) {
|
|
@@ -144,8 +163,8 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
144
163
|
isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(params))
|
|
145
164
|
}
|
|
146
165
|
// hover 进入事件
|
|
147
|
-
if (showTitle || showTooltip || showAllTip ||
|
|
148
|
-
tdOns.mouseenter = (evnt:
|
|
166
|
+
if (showTitle || showTooltip || showAllTip || tooltipConfig) {
|
|
167
|
+
tdOns.mouseenter = (evnt: MouseEvent) => {
|
|
149
168
|
if (isVMScrollProcess($xeTable)) {
|
|
150
169
|
return
|
|
151
170
|
}
|
|
@@ -155,28 +174,24 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
155
174
|
// 如果配置了显示 tooltip
|
|
156
175
|
$xeTable.triggerBodyTooltipEvent(evnt, params)
|
|
157
176
|
}
|
|
158
|
-
|
|
159
|
-
$xeTable.emitEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, params), evnt)
|
|
160
|
-
}
|
|
177
|
+
$xeTable.dispatchEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, params), evnt)
|
|
161
178
|
}
|
|
162
179
|
}
|
|
163
180
|
// hover 退出事件
|
|
164
|
-
if (showTooltip || showAllTip ||
|
|
165
|
-
tdOns.mouseleave = (evnt:
|
|
181
|
+
if (showTooltip || showAllTip || tooltipConfig) {
|
|
182
|
+
tdOns.mouseleave = (evnt: MouseEvent) => {
|
|
166
183
|
if (isVMScrollProcess($xeTable)) {
|
|
167
184
|
return
|
|
168
185
|
}
|
|
169
186
|
if (showTooltip || showAllTip) {
|
|
170
187
|
$xeTable.handleTargetLeaveEvent(evnt)
|
|
171
188
|
}
|
|
172
|
-
|
|
173
|
-
$xeTable.emitEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, params), evnt)
|
|
174
|
-
}
|
|
189
|
+
$xeTable.dispatchEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, params), evnt)
|
|
175
190
|
}
|
|
176
191
|
}
|
|
177
192
|
// 按下事件处理
|
|
178
193
|
if (isRowDragCell || checkboxOpts.range || mouseConfig) {
|
|
179
|
-
tdOns.mousedown = (evnt:
|
|
194
|
+
tdOns.mousedown = (evnt: MouseEvent) => {
|
|
180
195
|
$xeTable.triggerCellMousedownEvent(evnt, params)
|
|
181
196
|
}
|
|
182
197
|
}
|
|
@@ -185,22 +200,12 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
185
200
|
tdOns.mouseup = $xeTable.triggerCellMouseupEvent
|
|
186
201
|
}
|
|
187
202
|
// 点击事件处理
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
(editRender && editConfig) ||
|
|
191
|
-
(expandOpts.trigger === 'row' || (expandOpts.trigger === 'cell')) ||
|
|
192
|
-
(radioOpts.trigger === 'row' || (column.type === 'radio' && radioOpts.trigger === 'cell')) ||
|
|
193
|
-
(checkboxOpts.trigger === 'row' || (column.type === 'checkbox' && checkboxOpts.trigger === 'cell')) ||
|
|
194
|
-
(treeOpts.trigger === 'row' || (column.treeNode && treeOpts.trigger === 'cell'))) {
|
|
195
|
-
tdOns.click = (evnt: any) => {
|
|
196
|
-
$xeTable.triggerCellClickEvent(evnt, params)
|
|
197
|
-
}
|
|
203
|
+
tdOns.click = (evnt: MouseEvent) => {
|
|
204
|
+
$xeTable.triggerCellClickEvent(evnt, params)
|
|
198
205
|
}
|
|
199
206
|
// 双击事件处理
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
$xeTable.triggerCellDblclickEvent(evnt, params)
|
|
203
|
-
}
|
|
207
|
+
tdOns.dblclick = (evnt: MouseEvent) => {
|
|
208
|
+
$xeTable.triggerCellDblclickEvent(evnt, params)
|
|
204
209
|
}
|
|
205
210
|
// 合并行或列
|
|
206
211
|
if (mergeList.length) {
|
|
@@ -250,14 +255,14 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
250
255
|
'c--ellipsis': showEllipsis
|
|
251
256
|
}],
|
|
252
257
|
style: {
|
|
253
|
-
maxHeight: hasEllipsis && (
|
|
258
|
+
maxHeight: hasEllipsis && (customRHeight || defaultRowHeight) ? `${customRHeight || defaultRowHeight}px` : ''
|
|
254
259
|
}
|
|
255
260
|
})
|
|
256
261
|
)
|
|
257
262
|
} else {
|
|
258
263
|
// 渲染单元格
|
|
259
264
|
tdVNs.push(
|
|
260
|
-
...renderLine(h, _vm,
|
|
265
|
+
...renderLine(h, _vm, params),
|
|
261
266
|
h('div', {
|
|
262
267
|
class: ['vxe-cell', {
|
|
263
268
|
'c--title': showTitle,
|
|
@@ -265,7 +270,7 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
265
270
|
'c--ellipsis': showEllipsis
|
|
266
271
|
}],
|
|
267
272
|
style: {
|
|
268
|
-
maxHeight: hasEllipsis && (
|
|
273
|
+
maxHeight: hasEllipsis && (customRHeight || defaultRowHeight) ? `${customRHeight || defaultRowHeight}px` : ''
|
|
269
274
|
},
|
|
270
275
|
attrs: {
|
|
271
276
|
title: showTitle ? $xeTable.getCellLabel(row, column) : null
|
|
@@ -283,7 +288,7 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
283
288
|
? {
|
|
284
289
|
width: `${errRule.maxWidth}px`
|
|
285
290
|
}
|
|
286
|
-
:
|
|
291
|
+
: undefined
|
|
287
292
|
}, [
|
|
288
293
|
h('div', {
|
|
289
294
|
class: `vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-${validOpts.theme || 'normal'}`
|
|
@@ -303,13 +308,13 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
303
308
|
let cellHeight = ''
|
|
304
309
|
const vnHeight = isCalcCellHeight ? rest.height : 0
|
|
305
310
|
if (hasEllipsis) {
|
|
306
|
-
if (
|
|
307
|
-
cellHeight = `${
|
|
311
|
+
if (customRHeight) {
|
|
312
|
+
cellHeight = `${customRHeight}px`
|
|
308
313
|
} else if (!isAllOverflow) {
|
|
309
|
-
cellHeight = `${vnHeight ||
|
|
314
|
+
cellHeight = `${vnHeight || defaultRowHeight || 18}px`
|
|
310
315
|
}
|
|
311
316
|
} else {
|
|
312
|
-
cellHeight = `${vnHeight ||
|
|
317
|
+
cellHeight = `${vnHeight || defaultRowHeight || 18}px`
|
|
313
318
|
}
|
|
314
319
|
|
|
315
320
|
if (mouseConfig && mouseOpts.area && selectCellToRow) {
|
|
@@ -326,6 +331,13 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
326
331
|
}
|
|
327
332
|
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
|
|
328
333
|
|
|
334
|
+
let isPreLoadStatus = false
|
|
335
|
+
if (scrollYLoad && (_rowIndex < scrollYStore.visibleStartIndex || _rowIndex > scrollYStore.visibleEndIndex)) {
|
|
336
|
+
isPreLoadStatus = true
|
|
337
|
+
} else if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex || _columnIndex > scrollXStore.visibleEndIndex)) {
|
|
338
|
+
isPreLoadStatus = true
|
|
339
|
+
}
|
|
340
|
+
|
|
329
341
|
return h('td', {
|
|
330
342
|
class: [
|
|
331
343
|
'vxe-body--column',
|
|
@@ -357,48 +369,36 @@ function renderColumn (h: any, _vm: any, $xeTable: any, seq: any, rowid: any, fi
|
|
|
357
369
|
height: cellHeight
|
|
358
370
|
}, XEUtils.isFunction(compCellStyle) ? compCellStyle(params) : compCellStyle, XEUtils.isFunction(cellStyle) ? cellStyle(params) : cellStyle),
|
|
359
371
|
on: tdOns
|
|
360
|
-
}, tdVNs)
|
|
372
|
+
}, isPreLoadStatus || (isOptimizeMode && fixedHiddenColumn) ? [] : tdVNs)
|
|
361
373
|
}
|
|
362
374
|
|
|
363
|
-
function renderRows (h: CreateElement, _vm: any,
|
|
375
|
+
function renderRows (h: CreateElement, _vm: any, fixedType: VxeColumnPropTypes.Fixed, isOptimizeMode: boolean, tableData: any[], tableColumn: VxeTableDefines.ColumnInfo[]) {
|
|
376
|
+
const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
|
|
377
|
+
const tableProps = $xeTable
|
|
378
|
+
const tableReactData = $xeTable as unknown as TableReactData
|
|
379
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
380
|
+
|
|
381
|
+
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, showOverflow: allColumnOverflow, editConfig, treeConfig } = tableProps
|
|
382
|
+
const { hasFixedColumn, treeExpandedMaps, scrollXLoad, scrollYLoad, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove } = tableReactData
|
|
383
|
+
const { fullAllDataRowIdData } = tableInternalData
|
|
384
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
385
|
+
const radioOpts = $xeTable.computeRadioOpts
|
|
386
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
387
|
+
const editOpts = $xeTable.computeEditOpts
|
|
388
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
364
389
|
const columnOpts = $xeTable.computeColumnOpts
|
|
365
390
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
366
|
-
const {
|
|
367
|
-
stripe,
|
|
368
|
-
rowKey,
|
|
369
|
-
highlightHoverRow,
|
|
370
|
-
rowClassName,
|
|
371
|
-
rowStyle,
|
|
372
|
-
editConfig,
|
|
373
|
-
showOverflow: allColumnOverflow,
|
|
374
|
-
treeConfig,
|
|
375
|
-
treeOpts,
|
|
376
|
-
expandOpts,
|
|
377
|
-
editOpts,
|
|
378
|
-
treeExpandedMaps,
|
|
379
|
-
scrollXLoad,
|
|
380
|
-
scrollYLoad,
|
|
381
|
-
rowExpandedMaps,
|
|
382
|
-
radioOpts,
|
|
383
|
-
checkboxOpts,
|
|
384
|
-
expandColumn,
|
|
385
|
-
hasFixedColumn,
|
|
386
|
-
fullAllDataRowIdData,
|
|
387
|
-
rowOpts,
|
|
388
|
-
pendingRowMaps,
|
|
389
|
-
isDragColMove
|
|
390
|
-
} = $xeTable
|
|
391
391
|
const { transform, seqMode } = treeOpts
|
|
392
392
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
393
393
|
const rows: any[] = []
|
|
394
|
-
tableData.forEach((row
|
|
395
|
-
const trOn: any = {}
|
|
394
|
+
tableData.forEach((row, $rowIndex) => {
|
|
395
|
+
const trOn: Record<string, any> = {}
|
|
396
396
|
let rowIndex = $rowIndex
|
|
397
397
|
// 确保任何情况下 rowIndex 都精准指向真实 data 索引
|
|
398
398
|
rowIndex = $xeTable.getRowIndex(row)
|
|
399
399
|
// 当前行事件
|
|
400
400
|
if (rowOpts.isHover || highlightHoverRow) {
|
|
401
|
-
trOn.mouseenter = (evnt:
|
|
401
|
+
trOn.mouseenter = (evnt: MouseEvent) => {
|
|
402
402
|
if (isVMScrollProcess($xeTable)) {
|
|
403
403
|
return
|
|
404
404
|
}
|
|
@@ -414,7 +414,7 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
414
414
|
const rowid = getRowid($xeTable, row)
|
|
415
415
|
const rest = fullAllDataRowIdData[rowid]
|
|
416
416
|
let rowLevel = 0
|
|
417
|
-
let seq = -1
|
|
417
|
+
let seq: string | number = -1
|
|
418
418
|
let _rowIndex = 0
|
|
419
419
|
if (rest) {
|
|
420
420
|
rowLevel = rest.level
|
|
@@ -425,7 +425,7 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
425
425
|
}
|
|
426
426
|
_rowIndex = rest._index
|
|
427
427
|
}
|
|
428
|
-
const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
|
|
428
|
+
const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
|
|
429
429
|
// 行是否被展开
|
|
430
430
|
const isExpandRow = expandColumn && !!rowExpandedMaps[rowid]
|
|
431
431
|
// 树节点是否被展开
|
|
@@ -455,14 +455,14 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
455
455
|
'is--expand-row': isExpandRow,
|
|
456
456
|
'is--expand-tree': isExpandTree,
|
|
457
457
|
'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
|
|
458
|
-
'row--radio': radioOpts.highlight &&
|
|
458
|
+
'row--radio': radioOpts.highlight && selectRadioRow === row,
|
|
459
459
|
'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
|
|
460
460
|
'row--pending': !!pendingRowMaps[rowid]
|
|
461
461
|
},
|
|
462
462
|
rowClassName ? (XEUtils.isFunction(rowClassName) ? rowClassName(params) : rowClassName) : ''
|
|
463
463
|
]
|
|
464
464
|
const tdVNs = tableColumn.map((column: any, $columnIndex: any) => {
|
|
465
|
-
return
|
|
465
|
+
return renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
|
|
466
466
|
})
|
|
467
467
|
rows.push(
|
|
468
468
|
columnOpts.drag && columnDragOpts.animation
|
|
@@ -475,7 +475,7 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
475
475
|
attrs: {
|
|
476
476
|
rowid
|
|
477
477
|
},
|
|
478
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) :
|
|
478
|
+
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) as VxeComponentStyleType : undefined,
|
|
479
479
|
key: rowKey || scrollXLoad || scrollYLoad || rowOpts.useKey || rowOpts.drag || columnOpts.drag || treeConfig ? rowid : $rowIndex,
|
|
480
480
|
nativeOn: trOn
|
|
481
481
|
}, tdVNs)
|
|
@@ -484,13 +484,14 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
484
484
|
attrs: {
|
|
485
485
|
rowid
|
|
486
486
|
},
|
|
487
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) :
|
|
487
|
+
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) as VxeComponentStyleType : undefined,
|
|
488
488
|
key: rowKey || scrollXLoad || scrollYLoad || rowOpts.useKey || rowOpts.drag || columnOpts.drag || treeConfig ? rowid : $rowIndex,
|
|
489
489
|
on: trOn
|
|
490
490
|
}, tdVNs)
|
|
491
491
|
)
|
|
492
492
|
// 如果行被展开了
|
|
493
493
|
if (isExpandRow) {
|
|
494
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
494
495
|
const { height: expandHeight, padding } = expandOpts
|
|
495
496
|
const cellStyle: any = {}
|
|
496
497
|
if (expandHeight) {
|
|
@@ -501,14 +502,14 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
501
502
|
}
|
|
502
503
|
const { showOverflow } = expandColumn
|
|
503
504
|
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? allColumnOverflow : showOverflow
|
|
504
|
-
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex }
|
|
505
|
+
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
|
|
505
506
|
rows.push(
|
|
506
507
|
h('tr', {
|
|
507
508
|
class: ['vxe-body--expanded-row', {
|
|
508
509
|
'is--padding': padding
|
|
509
510
|
}],
|
|
510
511
|
key: `expand_${rowid}`,
|
|
511
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(expandParams) : rowStyle) :
|
|
512
|
+
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(expandParams) : rowStyle) as VxeComponentStyleType : undefined,
|
|
512
513
|
on: trOn
|
|
513
514
|
}, [
|
|
514
515
|
h('td', {
|
|
@@ -536,7 +537,7 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
536
537
|
}
|
|
537
538
|
// 如果是树形表格
|
|
538
539
|
if (isExpandTree) {
|
|
539
|
-
rows.push(...renderRows(h, _vm,
|
|
540
|
+
rows.push(...renderRows(h, _vm, fixedType, isOptimizeMode, rowChildren, tableColumn))
|
|
540
541
|
}
|
|
541
542
|
})
|
|
542
543
|
return rows
|
|
@@ -545,40 +546,42 @@ function renderRows (h: CreateElement, _vm: any, $xeTable: any, fixedType: any,
|
|
|
545
546
|
export default {
|
|
546
547
|
name: 'VxeTableBody',
|
|
547
548
|
props: {
|
|
548
|
-
tableData: Array
|
|
549
|
-
tableColumn: Array
|
|
550
|
-
fixedColumn: Array
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
data () {
|
|
555
|
-
return {
|
|
556
|
-
wheelTime: null,
|
|
557
|
-
wheelYSize: 0,
|
|
558
|
-
wheelYInterval: 0,
|
|
559
|
-
wheelYTotal: 0
|
|
549
|
+
tableData: Array as PropType<any[]>,
|
|
550
|
+
tableColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
|
|
551
|
+
fixedColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
|
|
552
|
+
fixedType: {
|
|
553
|
+
type: String as PropType<'right' | 'left' | ''>,
|
|
554
|
+
default: ''
|
|
560
555
|
}
|
|
561
556
|
},
|
|
562
557
|
mounted (this: any) {
|
|
563
|
-
const
|
|
564
|
-
const
|
|
558
|
+
const _vm = this
|
|
559
|
+
const props = _vm
|
|
560
|
+
const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
|
|
561
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
562
|
+
|
|
563
|
+
const { fixedType } = props
|
|
564
|
+
const { elemStore } = tableInternalData
|
|
565
565
|
const prefix = `${fixedType || 'main'}-body-`
|
|
566
|
-
elemStore[`${prefix}wrapper`] =
|
|
567
|
-
elemStore[`${prefix}
|
|
568
|
-
elemStore[`${prefix}
|
|
569
|
-
elemStore[`${prefix}
|
|
570
|
-
elemStore[`${prefix}
|
|
571
|
-
elemStore[`${prefix}
|
|
572
|
-
elemStore[`${prefix}
|
|
573
|
-
|
|
574
|
-
beforeDestroy (this: any) {
|
|
575
|
-
clearTimeout(this.wheelTime)
|
|
566
|
+
elemStore[`${prefix}wrapper`] = _vm.$refs.refElem
|
|
567
|
+
elemStore[`${prefix}scroll`] = _vm.$refs.refBodyScroll
|
|
568
|
+
elemStore[`${prefix}table`] = _vm.$refs.refBodyTable
|
|
569
|
+
elemStore[`${prefix}colgroup`] = _vm.$refs.refBodyColgroup
|
|
570
|
+
elemStore[`${prefix}list`] = _vm.$refs.refBodyTBody
|
|
571
|
+
elemStore[`${prefix}xSpace`] = _vm.$refs.refBodyXSpace
|
|
572
|
+
elemStore[`${prefix}ySpace`] = _vm.$refs.refBodyYSpace
|
|
573
|
+
elemStore[`${prefix}emptyBlock`] = _vm.$refs.refBodyEmptyBlock
|
|
576
574
|
},
|
|
577
575
|
destroyed (this: any) {
|
|
578
|
-
const
|
|
579
|
-
const
|
|
576
|
+
const props = this
|
|
577
|
+
const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
|
|
578
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
579
|
+
|
|
580
|
+
const { fixedType } = props
|
|
581
|
+
const { elemStore } = tableInternalData
|
|
580
582
|
const prefix = `${fixedType || 'main'}-body-`
|
|
581
583
|
elemStore[`${prefix}wrapper`] = null
|
|
584
|
+
elemStore[`${prefix}scroll`] = null
|
|
582
585
|
elemStore[`${prefix}table`] = null
|
|
583
586
|
elemStore[`${prefix}colgroup`] = null
|
|
584
587
|
elemStore[`${prefix}list`] = null
|
|
@@ -588,37 +591,40 @@ export default {
|
|
|
588
591
|
},
|
|
589
592
|
render (this: any, h: CreateElement) {
|
|
590
593
|
const props = this
|
|
591
|
-
const $xeTable = this.$parent
|
|
594
|
+
const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
|
|
592
595
|
const tableProps = $xeTable
|
|
593
|
-
const tableReactData = $xeTable
|
|
594
|
-
const tableInternalData = $xeTable
|
|
596
|
+
const tableReactData = $xeTable as unknown as TableReactData
|
|
597
|
+
const tableInternalData = $xeTable as unknown as TableInternalData
|
|
595
598
|
|
|
596
|
-
const {
|
|
599
|
+
const { xID, $scopedSlots } = $xeTable
|
|
597
600
|
const { fixedColumn, fixedType, tableColumn } = props
|
|
598
601
|
|
|
599
602
|
const { showOverflow: allColumnOverflow, spanMethod, footerSpanMethod, mouseConfig } = tableProps
|
|
600
603
|
const { isGroup, tableData, scrollXLoad, scrollYLoad, isAllOverflow, isDragRowMove, expandColumn, dragRow, dragCol } = tableReactData
|
|
601
604
|
const { visibleColumn, fullAllDataRowIdData, fullColumnIdData } = tableInternalData
|
|
602
605
|
const rowOpts = $xeTable.computeRowOpts
|
|
603
|
-
const sYOpts = $xeTable.computeSYOpts
|
|
604
606
|
const emptyOpts = $xeTable.computeEmptyOpts
|
|
605
607
|
const mouseOpts = $xeTable.computeMouseOpts
|
|
606
608
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
609
|
+
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
610
|
+
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
607
611
|
|
|
608
612
|
let renderDataList = tableData
|
|
609
|
-
let renderColumnList = tableColumn
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if (
|
|
613
|
+
let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
|
|
614
|
+
let isOptimizeMode = false
|
|
615
|
+
// 如果是使用优化模式
|
|
616
|
+
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
617
|
+
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
614
618
|
// 如果不支持优化模式
|
|
615
|
-
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
616
|
-
renderColumnList = visibleColumn
|
|
617
|
-
} else {
|
|
618
|
-
renderColumnList = fixedColumn || []
|
|
619
|
-
}
|
|
620
619
|
} else {
|
|
621
|
-
|
|
620
|
+
isOptimizeMode = true
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (fixedType) {
|
|
625
|
+
renderColumnList = visibleColumn
|
|
626
|
+
if (isOptimizeMode) {
|
|
627
|
+
renderColumnList = fixedColumn || []
|
|
622
628
|
}
|
|
623
629
|
}
|
|
624
630
|
|
|
@@ -672,7 +678,7 @@ export default {
|
|
|
672
678
|
|
|
673
679
|
let emptyContent
|
|
674
680
|
if ($scopedSlots.empty) {
|
|
675
|
-
emptyContent = $scopedSlots.empty.call(this, { $table: $xeTable, $grid: $xeTable.xegrid }
|
|
681
|
+
emptyContent = $scopedSlots.empty.call(this, { $table: $xeTable, $grid: $xeTable.xegrid })
|
|
676
682
|
} else {
|
|
677
683
|
const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null
|
|
678
684
|
const rtEmptyView = compConf ? (compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty) : null
|
|
@@ -684,274 +690,122 @@ export default {
|
|
|
684
690
|
}
|
|
685
691
|
|
|
686
692
|
const ons: Record<string, any> = {
|
|
687
|
-
scroll:
|
|
693
|
+
scroll (evnt: Event) {
|
|
694
|
+
$xeTable.triggerBodyScrollEvent(evnt, fixedType)
|
|
695
|
+
}
|
|
688
696
|
}
|
|
689
|
-
if (
|
|
690
|
-
ons.wheel =
|
|
697
|
+
if (scrollYLoad || leftFixedWidth || rightFixedWidth) {
|
|
698
|
+
ons.wheel = $xeTable.triggerBodyWheelEvent
|
|
691
699
|
}
|
|
692
700
|
|
|
693
701
|
return h('div', {
|
|
694
702
|
ref: 'refElem',
|
|
695
703
|
class: ['vxe-table--body-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
|
|
696
704
|
attrs: {
|
|
697
|
-
xid:
|
|
698
|
-
}
|
|
699
|
-
on: ons
|
|
705
|
+
xid: xID
|
|
706
|
+
}
|
|
700
707
|
}, [
|
|
701
|
-
fixedType
|
|
702
|
-
? renderEmptyElement($xeTable)
|
|
703
|
-
: h('div', {
|
|
704
|
-
class: 'vxe-body--x-space',
|
|
705
|
-
ref: 'xSpace'
|
|
706
|
-
}),
|
|
707
708
|
h('div', {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
h('table', {
|
|
712
|
-
class: 'vxe-table--body',
|
|
713
|
-
attrs: {
|
|
714
|
-
xid: tId,
|
|
715
|
-
cellspacing: 0,
|
|
716
|
-
cellpadding: 0,
|
|
717
|
-
border: 0
|
|
718
|
-
},
|
|
719
|
-
ref: 'table'
|
|
709
|
+
ref: 'refBodyScroll',
|
|
710
|
+
class: 'vxe-table--body-inner-wrapper',
|
|
711
|
+
on: ons
|
|
720
712
|
}, [
|
|
713
|
+
fixedType
|
|
714
|
+
? renderEmptyElement($xeTable)
|
|
715
|
+
: h('div', {
|
|
716
|
+
ref: 'refBodyXSpace',
|
|
717
|
+
class: 'vxe-body--x-space'
|
|
718
|
+
}),
|
|
719
|
+
h('div', {
|
|
720
|
+
ref: 'refBodyYSpace',
|
|
721
|
+
class: 'vxe-body--y-space'
|
|
722
|
+
}),
|
|
723
|
+
h('table', {
|
|
724
|
+
ref: 'refBodyTable',
|
|
725
|
+
class: 'vxe-table--body',
|
|
726
|
+
attrs: {
|
|
727
|
+
xid: xID,
|
|
728
|
+
cellspacing: 0,
|
|
729
|
+
cellpadding: 0,
|
|
730
|
+
border: 0
|
|
731
|
+
}
|
|
732
|
+
}, [
|
|
721
733
|
/**
|
|
722
734
|
* 列宽
|
|
723
735
|
*/
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
736
|
+
h('colgroup', {
|
|
737
|
+
ref: 'refBodyColgroup'
|
|
738
|
+
}, renderColumnList.map((column: any, $columnIndex: any) => {
|
|
739
|
+
return h('col', {
|
|
740
|
+
attrs: {
|
|
741
|
+
name: column.id
|
|
742
|
+
},
|
|
743
|
+
key: $columnIndex
|
|
744
|
+
})
|
|
745
|
+
})),
|
|
746
|
+
/**
|
|
735
747
|
* 内容
|
|
736
748
|
*/
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
$xeTable.triggerCellAreaExtendMousedownEvent
|
|
749
|
+
rowOpts.drag && rowDragOpts.animation
|
|
750
|
+
? h('transition-group', {
|
|
751
|
+
ref: 'refBodyTBody',
|
|
752
|
+
props: {
|
|
753
|
+
tag: 'tbody',
|
|
754
|
+
name: `vxe-body--row-list${isDragRowMove ? '' : '-disabled'}`
|
|
755
|
+
}
|
|
756
|
+
}, renderRows(h, this, fixedType, isOptimizeMode, renderDataList, renderColumnList))
|
|
757
|
+
: h('tbody', {
|
|
758
|
+
ref: 'refBodyTBody'
|
|
759
|
+
}, renderRows(h, this, fixedType, isOptimizeMode, renderDataList, renderColumnList))
|
|
760
|
+
]),
|
|
761
|
+
h('div', {
|
|
762
|
+
class: 'vxe-table--checkbox-range'
|
|
763
|
+
}),
|
|
764
|
+
mouseConfig && mouseOpts.area
|
|
765
|
+
? h('div', {
|
|
766
|
+
class: 'vxe-table--cell-area'
|
|
767
|
+
}, [
|
|
768
|
+
h('span', {
|
|
769
|
+
class: 'vxe-table--cell-main-area'
|
|
770
|
+
}, mouseOpts.extension
|
|
771
|
+
? [
|
|
772
|
+
h('span', {
|
|
773
|
+
class: 'vxe-table--cell-main-area-btn',
|
|
774
|
+
on: {
|
|
775
|
+
mousedown (evnt: any) {
|
|
776
|
+
if ($xeTable.triggerCellAreaExtendMousedownEvent) {
|
|
777
|
+
$xeTable.triggerCellAreaExtendMousedownEvent(evnt, { $table: $xeTable, fixed: fixedType, type: renderType })
|
|
778
|
+
}
|
|
765
779
|
}
|
|
766
780
|
}
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
781
|
+
})
|
|
782
|
+
]
|
|
783
|
+
: null),
|
|
784
|
+
h('span', {
|
|
785
|
+
class: 'vxe-table--cell-copy-area'
|
|
786
|
+
}),
|
|
787
|
+
h('span', {
|
|
788
|
+
class: 'vxe-table--cell-extend-area'
|
|
789
|
+
}),
|
|
790
|
+
h('span', {
|
|
791
|
+
class: 'vxe-table--cell-multi-area'
|
|
792
|
+
}),
|
|
793
|
+
h('span', {
|
|
794
|
+
class: 'vxe-table--cell-active-area'
|
|
795
|
+
})
|
|
796
|
+
])
|
|
797
|
+
: renderEmptyElement($xeTable),
|
|
798
|
+
!fixedType
|
|
799
|
+
? h('div', {
|
|
800
|
+
class: 'vxe-table--empty-block',
|
|
801
|
+
ref: 'emptyBlock'
|
|
802
|
+
}, [
|
|
803
|
+
h('div', {
|
|
804
|
+
class: 'vxe-table--empty-content'
|
|
805
|
+
}, emptyContent)
|
|
806
|
+
])
|
|
807
|
+
: renderEmptyElement($xeTable)
|
|
808
|
+
])
|
|
795
809
|
])
|
|
796
|
-
}
|
|
797
|
-
methods: {
|
|
798
|
-
/**
|
|
799
|
-
* 滚动处理
|
|
800
|
-
* 如果存在列固定左侧,同步更新滚动状态
|
|
801
|
-
* 如果存在列固定右侧,同步更新滚动状态
|
|
802
|
-
*/
|
|
803
|
-
scrollEvent (evnt: Event) {
|
|
804
|
-
const $xeTable = this.$parent
|
|
805
|
-
const tableInternalData = $xeTable
|
|
806
|
-
|
|
807
|
-
const { fixedType } = this
|
|
808
|
-
const { lastScrollTop, lastScrollLeft, inVirtualScroll, inBodyScroll, bodyScrollType, inFooterScroll } = tableInternalData
|
|
809
|
-
if (inVirtualScroll) {
|
|
810
|
-
return
|
|
811
|
-
}
|
|
812
|
-
if (inFooterScroll) {
|
|
813
|
-
return
|
|
814
|
-
}
|
|
815
|
-
if (inBodyScroll) {
|
|
816
|
-
if (bodyScrollType !== fixedType) {
|
|
817
|
-
return
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
const { tableHeader, tableBody, leftBody, rightBody, tableFooter } = $xeTable.$refs
|
|
821
|
-
const scrollBodyElem = this.$el as HTMLDivElement
|
|
822
|
-
const headerElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
|
|
823
|
-
const footerElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
|
|
824
|
-
const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
|
|
825
|
-
if (!bodyElem) {
|
|
826
|
-
return
|
|
827
|
-
}
|
|
828
|
-
const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
|
|
829
|
-
const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
|
|
830
|
-
const xHandleEl = $xeTable.$refs.refScrollXHandleElem as HTMLDivElement
|
|
831
|
-
const yHandleEl = $xeTable.$refs.refScrollYHandleElem as HTMLDivElement
|
|
832
|
-
const scrollTop = scrollBodyElem.scrollTop
|
|
833
|
-
const scrollLeft = bodyElem.scrollLeft
|
|
834
|
-
const isRollX = scrollLeft !== lastScrollLeft
|
|
835
|
-
const isRollY = scrollTop !== lastScrollTop
|
|
836
|
-
tableInternalData.inBodyScroll = true
|
|
837
|
-
tableInternalData.bodyScrollType = fixedType
|
|
838
|
-
if (isRollY) {
|
|
839
|
-
if (leftElem && fixedType === 'left') {
|
|
840
|
-
setScrollTop(bodyElem, scrollTop)
|
|
841
|
-
setScrollTop(rightElem, scrollTop)
|
|
842
|
-
} else if (rightElem && fixedType === 'right') {
|
|
843
|
-
setScrollTop(bodyElem, scrollTop)
|
|
844
|
-
setScrollTop(leftElem, scrollTop)
|
|
845
|
-
} else {
|
|
846
|
-
setScrollTop(leftElem, scrollTop)
|
|
847
|
-
setScrollTop(rightElem, scrollTop)
|
|
848
|
-
}
|
|
849
|
-
setScrollTop(yHandleEl, scrollTop)
|
|
850
|
-
$xeTable.triggerScrollYEvent(evnt)
|
|
851
|
-
}
|
|
852
|
-
if (isRollX) {
|
|
853
|
-
setScrollLeft(xHandleEl, scrollLeft)
|
|
854
|
-
setScrollLeft(headerElem, scrollLeft)
|
|
855
|
-
setScrollLeft(footerElem, scrollLeft)
|
|
856
|
-
$xeTable.triggerScrollXEvent(evnt)
|
|
857
|
-
}
|
|
858
|
-
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
859
|
-
type: renderType,
|
|
860
|
-
fixed: fixedType
|
|
861
|
-
})
|
|
862
|
-
},
|
|
863
|
-
handleWheel (evnt: any, isTopWheel: any, deltaTop: any, isRollX: any, isRollY: any) {
|
|
864
|
-
const { $parent: $xetable } = this
|
|
865
|
-
const { $refs, elemStore, scrollYLoad, scrollXLoad } = $xetable
|
|
866
|
-
const { tableBody, leftBody, rightBody } = $refs
|
|
867
|
-
const bodyElem = tableBody.$el
|
|
868
|
-
const leftElem = leftBody ? leftBody.$el : null
|
|
869
|
-
const rightElem = rightBody ? rightBody.$el : null
|
|
870
|
-
const remainSize = this.isPrevWheelTop === isTopWheel ? Math.max(0, this.wheelYSize - this.wheelYTotal) : 0
|
|
871
|
-
const bodyYElem = elemStore['main-body-ySpace']
|
|
872
|
-
const bodyXElem = elemStore['main-body-xSpace']
|
|
873
|
-
const bodyHeight = scrollYLoad && bodyYElem ? bodyYElem.clientHeight : bodyElem.clientHeight
|
|
874
|
-
const bodyWidth = scrollXLoad && bodyXElem ? bodyXElem.clientWidth : bodyElem.clientWidth
|
|
875
|
-
this.isPrevWheelTop = isTopWheel
|
|
876
|
-
this.wheelYSize = Math.abs(isTopWheel ? deltaTop - remainSize : deltaTop + remainSize)
|
|
877
|
-
this.wheelYInterval = 0
|
|
878
|
-
this.wheelYTotal = 0
|
|
879
|
-
clearTimeout(this.wheelTime)
|
|
880
|
-
const handleSmooth = () => {
|
|
881
|
-
let { fixedType, wheelYTotal, wheelYSize, wheelYInterval } = this
|
|
882
|
-
if (wheelYTotal < wheelYSize) {
|
|
883
|
-
wheelYInterval = Math.max(5, Math.floor(wheelYInterval * 1.5))
|
|
884
|
-
wheelYTotal = wheelYTotal + wheelYInterval
|
|
885
|
-
if (wheelYTotal > wheelYSize) {
|
|
886
|
-
wheelYInterval = wheelYInterval - (wheelYTotal - wheelYSize)
|
|
887
|
-
}
|
|
888
|
-
const { scrollTop, clientHeight, scrollHeight } = bodyElem
|
|
889
|
-
const targetTop = scrollTop + (wheelYInterval * (isTopWheel ? -1 : 1))
|
|
890
|
-
bodyElem.scrollTop = targetTop
|
|
891
|
-
if (leftElem) {
|
|
892
|
-
leftElem.scrollTop = targetTop
|
|
893
|
-
}
|
|
894
|
-
if (rightElem) {
|
|
895
|
-
rightElem.scrollTop = targetTop
|
|
896
|
-
}
|
|
897
|
-
if (isTopWheel ? targetTop < scrollHeight - clientHeight : targetTop >= 0) {
|
|
898
|
-
this.wheelTime = setTimeout(handleSmooth, 10)
|
|
899
|
-
}
|
|
900
|
-
this.wheelYTotal = wheelYTotal
|
|
901
|
-
this.wheelYInterval = wheelYInterval
|
|
902
|
-
$xetable.emitEvent('scroll', {
|
|
903
|
-
type: renderType,
|
|
904
|
-
fixed: fixedType,
|
|
905
|
-
scrollTop: bodyElem.scrollTop,
|
|
906
|
-
scrollLeft: bodyElem.scrollLeft,
|
|
907
|
-
scrollHeight: bodyElem.scrollHeight,
|
|
908
|
-
scrollWidth: bodyElem.scrollWidth,
|
|
909
|
-
bodyHeight,
|
|
910
|
-
bodyWidth,
|
|
911
|
-
isX: isRollX,
|
|
912
|
-
isY: isRollY
|
|
913
|
-
}, evnt)
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
handleSmooth()
|
|
917
|
-
},
|
|
918
|
-
/**
|
|
919
|
-
* 滚轮处理
|
|
920
|
-
*/
|
|
921
|
-
wheelEvent (evnt: any) {
|
|
922
|
-
const { deltaY, deltaX } = evnt
|
|
923
|
-
const { $el: scrollBodyElem, $parent: $xetable } = this
|
|
924
|
-
const { $refs, highlightHoverRow, scrollYLoad, lastScrollTop, lastScrollLeft, rowOpts } = $xetable
|
|
925
|
-
const { tableBody } = $refs
|
|
926
|
-
const bodyElem = tableBody.$el
|
|
927
|
-
|
|
928
|
-
const deltaTop = deltaY
|
|
929
|
-
const deltaLeft = deltaX
|
|
930
|
-
const isTopWheel = deltaTop < 0
|
|
931
|
-
// 如果滚动位置已经是顶部或底部,则不需要触发
|
|
932
|
-
if (isTopWheel ? scrollBodyElem.scrollTop <= 0 : scrollBodyElem.scrollTop >= scrollBodyElem.scrollHeight - scrollBodyElem.clientHeight) {
|
|
933
|
-
return
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
const scrollTop = scrollBodyElem.scrollTop + deltaTop
|
|
937
|
-
const scrollLeft = bodyElem.scrollLeft + deltaLeft
|
|
938
|
-
const isRollX = scrollLeft !== lastScrollLeft
|
|
939
|
-
const isRollY = scrollTop !== lastScrollTop
|
|
940
|
-
|
|
941
|
-
// 用于鼠标纵向滚轮处理
|
|
942
|
-
if (isRollY) {
|
|
943
|
-
evnt.preventDefault()
|
|
944
|
-
$xetable.lastScrollTop = scrollTop
|
|
945
|
-
$xetable.lastScrollLeft = scrollLeft
|
|
946
|
-
$xetable.lastScrollTime = Date.now()
|
|
947
|
-
if (rowOpts.isHover || highlightHoverRow) {
|
|
948
|
-
$xetable.clearHoverRow()
|
|
949
|
-
}
|
|
950
|
-
this.handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY)
|
|
951
|
-
if (scrollYLoad) {
|
|
952
|
-
$xetable.triggerScrollYEvent(evnt)
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
} as any
|
|
810
|
+
}
|
|
957
811
|
}
|