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