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
package/es/table/src/body.js
CHANGED
|
@@ -2,32 +2,40 @@ import XEUtils from 'xe-utils';
|
|
|
2
2
|
import { VxeUI } from '../../ui';
|
|
3
3
|
import { isEnableConf, getClass } from '../../ui/src/utils';
|
|
4
4
|
import { getOffsetSize, calcTreeLine, mergeBodyMethod, getRowid } from './util';
|
|
5
|
-
import { updateCellTitle
|
|
5
|
+
import { updateCellTitle } from '../../ui/src/dom';
|
|
6
6
|
import { getSlotVNs } from '../../ui/src/vn';
|
|
7
7
|
const { getI18n, renderer, renderEmptyElement } = VxeUI;
|
|
8
8
|
const renderType = 'body';
|
|
9
9
|
// 滚动、拖动过程中不需要触发
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const isVMScrollProcess = ($xeTable) => {
|
|
11
|
+
const tableProps = $xeTable;
|
|
12
|
+
const tableReactData = $xeTable;
|
|
13
|
+
const { delayHover } = tableProps;
|
|
14
|
+
const { lastScrollTime, _isResize } = tableReactData;
|
|
15
|
+
return !!(_isResize || (lastScrollTime && Date.now() < lastScrollTime + delayHover));
|
|
16
|
+
};
|
|
17
|
+
function renderLine(h, _vm, params) {
|
|
18
|
+
const $xeTable = _vm.$parent;
|
|
19
|
+
const tableProps = $xeTable;
|
|
20
|
+
const tableInternalData = $xeTable;
|
|
14
21
|
const { row, column } = params;
|
|
15
|
-
const { afterFullData
|
|
22
|
+
const { afterFullData } = tableInternalData;
|
|
23
|
+
const { treeConfig } = tableProps;
|
|
24
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
16
25
|
const { slots, treeNode } = column;
|
|
17
|
-
const
|
|
26
|
+
const { fullAllDataRowIdData } = tableInternalData;
|
|
27
|
+
if (slots && slots.line) {
|
|
28
|
+
return $xeTable.callSlot(slots.line, params, h);
|
|
29
|
+
}
|
|
30
|
+
const rowid = getRowid($xeTable, row);
|
|
18
31
|
const rest = fullAllDataRowIdData[rowid];
|
|
19
32
|
let rLevel = 0;
|
|
20
|
-
let
|
|
21
|
-
let items = [];
|
|
33
|
+
let prevRow = null;
|
|
22
34
|
if (rest) {
|
|
23
35
|
rLevel = rest.level;
|
|
24
|
-
|
|
25
|
-
items = rest.items;
|
|
26
|
-
}
|
|
27
|
-
if (slots && slots.line) {
|
|
28
|
-
return $xetable.callSlot(slots.line, params, h);
|
|
36
|
+
prevRow = rest.items[rest._index - 1];
|
|
29
37
|
}
|
|
30
|
-
const isFirstRow = $
|
|
38
|
+
const isFirstRow = $xeTable.eqRow(afterFullData[0], row);
|
|
31
39
|
if (treeConfig && treeNode && (treeOpts.showLine || treeOpts.line)) {
|
|
32
40
|
return [
|
|
33
41
|
h('div', {
|
|
@@ -36,8 +44,8 @@ function renderLine(h, _vm, $xetable, params) {
|
|
|
36
44
|
h('div', {
|
|
37
45
|
class: 'vxe-tree--line',
|
|
38
46
|
style: {
|
|
39
|
-
height: `${isFirstRow ? 1 : calcTreeLine(params,
|
|
40
|
-
left: `${(rLevel * treeOpts.indent) + (rLevel ? 2 - getOffsetSize($
|
|
47
|
+
height: `${isFirstRow ? 1 : calcTreeLine(params, prevRow)}px`,
|
|
48
|
+
left: `${(rLevel * treeOpts.indent) + (rLevel ? 2 - getOffsetSize($xeTable) : 0) + 16}px`
|
|
41
49
|
}
|
|
42
50
|
})
|
|
43
51
|
])
|
|
@@ -48,22 +56,38 @@ function renderLine(h, _vm, $xetable, params) {
|
|
|
48
56
|
/**
|
|
49
57
|
* 渲染列
|
|
50
58
|
*/
|
|
51
|
-
function
|
|
52
|
-
const
|
|
59
|
+
function renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, columns, items) {
|
|
60
|
+
const $xeTable = _vm.$parent;
|
|
61
|
+
const tableProps = $xeTable;
|
|
62
|
+
const tableReactData = $xeTable;
|
|
63
|
+
const tableInternalData = $xeTable;
|
|
64
|
+
const { fullAllDataRowIdData } = tableInternalData;
|
|
65
|
+
const { columnKey, height, showOverflow: allColumnOverflow, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig } = tableProps;
|
|
66
|
+
const { tableData, overflowX, currentColumn, scrollXLoad, scrollYLoad, isCalcCellHeight, mergeList, editStore, isAllOverflow, validErrorMaps } = tableReactData;
|
|
67
|
+
const { afterFullData, scrollXStore, scrollYStore } = tableInternalData;
|
|
68
|
+
const cellOpts = $xeTable.computeCellOpts;
|
|
69
|
+
const validOpts = $xeTable.computeValidOpts;
|
|
70
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
71
|
+
const editOpts = $xeTable.computeEditOpts;
|
|
72
|
+
const tooltipOpts = $xeTable.computeTooltipOpts;
|
|
73
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
53
74
|
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
75
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight;
|
|
54
76
|
const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = rowDragOpts;
|
|
77
|
+
const columnOpts = $xeTable.computeColumnOpts;
|
|
78
|
+
const mouseOpts = $xeTable.computeMouseOpts;
|
|
79
|
+
const areaOpts = $xeTable.computeAreaOpts;
|
|
55
80
|
const { selectCellToRow } = areaOpts;
|
|
56
|
-
const cellOpts = $xeTable.computeCellOpts;
|
|
57
81
|
const { type, cellRender, editRender, align, showOverflow, className, treeNode, slots } = column;
|
|
58
82
|
const { verticalAlign } = cellOpts;
|
|
59
83
|
const { actived } = editStore;
|
|
60
|
-
const {
|
|
61
|
-
const
|
|
84
|
+
const { height: customRHeight } = rowOpts;
|
|
85
|
+
const colid = column.id;
|
|
62
86
|
const renderOpts = editRender || cellRender;
|
|
63
87
|
const compConf = renderOpts ? renderer.get(renderOpts.name) : null;
|
|
64
|
-
const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) :
|
|
88
|
+
const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) : null;
|
|
65
89
|
const compCellStyle = compConf ? (compConf.tableCellStyle || compConf.cellStyle) : '';
|
|
66
|
-
const showAllTip = tooltipOpts.showAll
|
|
90
|
+
const showAllTip = tooltipOpts.showAll;
|
|
67
91
|
const columnIndex = $xeTable.getColumnIndex(column);
|
|
68
92
|
const _columnIndex = $xeTable.getVTColumnIndex(column);
|
|
69
93
|
const isEdit = isEnableConf(editRender);
|
|
@@ -78,13 +102,31 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
78
102
|
const tdOns = {};
|
|
79
103
|
const rest = fullAllDataRowIdData[rowid];
|
|
80
104
|
const cellAlign = align || (compConf ? compConf.tableCellAlign : '') || allAlign;
|
|
81
|
-
const errorValidItem = validErrorMaps[`${rowid}:${
|
|
105
|
+
const errorValidItem = validErrorMaps[`${rowid}:${colid}`];
|
|
82
106
|
const showValidTip = editRules && validOpts.showMessage && (validOpts.message === 'default' ? (height || tableData.length > 1) : validOpts.message === 'inline');
|
|
83
|
-
const attrs = { colid
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
const attrs = { colid };
|
|
108
|
+
const params = {
|
|
109
|
+
$table: $xeTable,
|
|
110
|
+
$grid: $xeTable.xegrid,
|
|
111
|
+
isEdit: false,
|
|
112
|
+
seq,
|
|
113
|
+
rowid,
|
|
114
|
+
row,
|
|
115
|
+
rowIndex,
|
|
116
|
+
$rowIndex,
|
|
117
|
+
_rowIndex,
|
|
118
|
+
column,
|
|
119
|
+
columnIndex,
|
|
120
|
+
$columnIndex,
|
|
121
|
+
_columnIndex,
|
|
122
|
+
fixed: fixedType,
|
|
123
|
+
type: renderType,
|
|
124
|
+
isHidden: !!fixedHiddenColumn,
|
|
125
|
+
level: rowLevel,
|
|
126
|
+
visibleData: afterFullData,
|
|
127
|
+
data: tableData,
|
|
128
|
+
items
|
|
129
|
+
};
|
|
88
130
|
let isRowDragCell = false;
|
|
89
131
|
let isDisabledDrag = false;
|
|
90
132
|
if (rowOpts.drag) {
|
|
@@ -94,7 +136,7 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
94
136
|
isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(params));
|
|
95
137
|
}
|
|
96
138
|
// hover 进入事件
|
|
97
|
-
if (showTitle || showTooltip || showAllTip ||
|
|
139
|
+
if (showTitle || showTooltip || showAllTip || tooltipConfig) {
|
|
98
140
|
tdOns.mouseenter = (evnt) => {
|
|
99
141
|
if (isVMScrollProcess($xeTable)) {
|
|
100
142
|
return;
|
|
@@ -106,13 +148,11 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
106
148
|
// 如果配置了显示 tooltip
|
|
107
149
|
$xeTable.triggerBodyTooltipEvent(evnt, params);
|
|
108
150
|
}
|
|
109
|
-
|
|
110
|
-
$xeTable.emitEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, params), evnt);
|
|
111
|
-
}
|
|
151
|
+
$xeTable.dispatchEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, params), evnt);
|
|
112
152
|
};
|
|
113
153
|
}
|
|
114
154
|
// hover 退出事件
|
|
115
|
-
if (showTooltip || showAllTip ||
|
|
155
|
+
if (showTooltip || showAllTip || tooltipConfig) {
|
|
116
156
|
tdOns.mouseleave = (evnt) => {
|
|
117
157
|
if (isVMScrollProcess($xeTable)) {
|
|
118
158
|
return;
|
|
@@ -120,9 +160,7 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
120
160
|
if (showTooltip || showAllTip) {
|
|
121
161
|
$xeTable.handleTargetLeaveEvent(evnt);
|
|
122
162
|
}
|
|
123
|
-
|
|
124
|
-
$xeTable.emitEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, params), evnt);
|
|
125
|
-
}
|
|
163
|
+
$xeTable.dispatchEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, params), evnt);
|
|
126
164
|
};
|
|
127
165
|
}
|
|
128
166
|
// 按下事件处理
|
|
@@ -136,23 +174,13 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
136
174
|
tdOns.mouseup = $xeTable.triggerCellMouseupEvent;
|
|
137
175
|
}
|
|
138
176
|
// 点击事件处理
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
(expandOpts.trigger === 'row' || (expandOpts.trigger === 'cell')) ||
|
|
143
|
-
(radioOpts.trigger === 'row' || (column.type === 'radio' && radioOpts.trigger === 'cell')) ||
|
|
144
|
-
(checkboxOpts.trigger === 'row' || (column.type === 'checkbox' && checkboxOpts.trigger === 'cell')) ||
|
|
145
|
-
(treeOpts.trigger === 'row' || (column.treeNode && treeOpts.trigger === 'cell'))) {
|
|
146
|
-
tdOns.click = (evnt) => {
|
|
147
|
-
$xeTable.triggerCellClickEvent(evnt, params);
|
|
148
|
-
};
|
|
149
|
-
}
|
|
177
|
+
tdOns.click = (evnt) => {
|
|
178
|
+
$xeTable.triggerCellClickEvent(evnt, params);
|
|
179
|
+
};
|
|
150
180
|
// 双击事件处理
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
155
|
-
}
|
|
181
|
+
tdOns.dblclick = (evnt) => {
|
|
182
|
+
$xeTable.triggerCellDblclickEvent(evnt, params);
|
|
183
|
+
};
|
|
156
184
|
// 合并行或列
|
|
157
185
|
if (mergeList.length) {
|
|
158
186
|
const spanRest = mergeBodyMethod(mergeList, _rowIndex, _columnIndex);
|
|
@@ -201,20 +229,20 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
201
229
|
'c--ellipsis': showEllipsis
|
|
202
230
|
}],
|
|
203
231
|
style: {
|
|
204
|
-
maxHeight: hasEllipsis && (
|
|
232
|
+
maxHeight: hasEllipsis && (customRHeight || defaultRowHeight) ? `${customRHeight || defaultRowHeight}px` : ''
|
|
205
233
|
}
|
|
206
234
|
}));
|
|
207
235
|
}
|
|
208
236
|
else {
|
|
209
237
|
// 渲染单元格
|
|
210
|
-
tdVNs.push(...renderLine(h, _vm,
|
|
238
|
+
tdVNs.push(...renderLine(h, _vm, params), h('div', {
|
|
211
239
|
class: ['vxe-cell', {
|
|
212
240
|
'c--title': showTitle,
|
|
213
241
|
'c--tooltip': showTooltip,
|
|
214
242
|
'c--ellipsis': showEllipsis
|
|
215
243
|
}],
|
|
216
244
|
style: {
|
|
217
|
-
maxHeight: hasEllipsis && (
|
|
245
|
+
maxHeight: hasEllipsis && (customRHeight || defaultRowHeight) ? `${customRHeight || defaultRowHeight}px` : ''
|
|
218
246
|
},
|
|
219
247
|
attrs: {
|
|
220
248
|
title: showTitle ? $xeTable.getCellLabel(row, column) : null
|
|
@@ -230,7 +258,7 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
230
258
|
? {
|
|
231
259
|
width: `${errRule.maxWidth}px`
|
|
232
260
|
}
|
|
233
|
-
:
|
|
261
|
+
: undefined
|
|
234
262
|
}, [
|
|
235
263
|
h('div', {
|
|
236
264
|
class: `vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-${validOpts.theme || 'normal'}`
|
|
@@ -249,15 +277,15 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
249
277
|
let cellHeight = '';
|
|
250
278
|
const vnHeight = isCalcCellHeight ? rest.height : 0;
|
|
251
279
|
if (hasEllipsis) {
|
|
252
|
-
if (
|
|
253
|
-
cellHeight = `${
|
|
280
|
+
if (customRHeight) {
|
|
281
|
+
cellHeight = `${customRHeight}px`;
|
|
254
282
|
}
|
|
255
283
|
else if (!isAllOverflow) {
|
|
256
|
-
cellHeight = `${vnHeight ||
|
|
284
|
+
cellHeight = `${vnHeight || defaultRowHeight || 18}px`;
|
|
257
285
|
}
|
|
258
286
|
}
|
|
259
287
|
else {
|
|
260
|
-
cellHeight = `${vnHeight ||
|
|
288
|
+
cellHeight = `${vnHeight || defaultRowHeight || 18}px`;
|
|
261
289
|
}
|
|
262
290
|
if (mouseConfig && mouseOpts.area && selectCellToRow) {
|
|
263
291
|
if ((!$columnIndex && selectCellToRow === true) ||
|
|
@@ -268,6 +296,13 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
268
296
|
}
|
|
269
297
|
}
|
|
270
298
|
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
|
|
299
|
+
let isPreLoadStatus = false;
|
|
300
|
+
if (scrollYLoad && (_rowIndex < scrollYStore.visibleStartIndex || _rowIndex > scrollYStore.visibleEndIndex)) {
|
|
301
|
+
isPreLoadStatus = true;
|
|
302
|
+
}
|
|
303
|
+
else if (scrollXLoad && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex || _columnIndex > scrollXStore.visibleEndIndex)) {
|
|
304
|
+
isPreLoadStatus = true;
|
|
305
|
+
}
|
|
271
306
|
return h('td', {
|
|
272
307
|
class: [
|
|
273
308
|
'vxe-body--column',
|
|
@@ -299,12 +334,23 @@ function renderColumn(h, _vm, $xeTable, seq, rowid, fixedType, rowLevel, row, ro
|
|
|
299
334
|
height: cellHeight
|
|
300
335
|
}, XEUtils.isFunction(compCellStyle) ? compCellStyle(params) : compCellStyle, XEUtils.isFunction(cellStyle) ? cellStyle(params) : cellStyle),
|
|
301
336
|
on: tdOns
|
|
302
|
-
}, tdVNs);
|
|
337
|
+
}, isPreLoadStatus || (isOptimizeMode && fixedHiddenColumn) ? [] : tdVNs);
|
|
303
338
|
}
|
|
304
|
-
function renderRows(h, _vm,
|
|
339
|
+
function renderRows(h, _vm, fixedType, isOptimizeMode, tableData, tableColumn) {
|
|
340
|
+
const $xeTable = _vm.$parent;
|
|
341
|
+
const tableProps = $xeTable;
|
|
342
|
+
const tableReactData = $xeTable;
|
|
343
|
+
const tableInternalData = $xeTable;
|
|
344
|
+
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, showOverflow: allColumnOverflow, editConfig, treeConfig } = tableProps;
|
|
345
|
+
const { hasFixedColumn, treeExpandedMaps, scrollXLoad, scrollYLoad, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove } = tableReactData;
|
|
346
|
+
const { fullAllDataRowIdData } = tableInternalData;
|
|
347
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
348
|
+
const radioOpts = $xeTable.computeRadioOpts;
|
|
349
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
350
|
+
const editOpts = $xeTable.computeEditOpts;
|
|
351
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
305
352
|
const columnOpts = $xeTable.computeColumnOpts;
|
|
306
353
|
const columnDragOpts = $xeTable.computeColumnDragOpts;
|
|
307
|
-
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, showOverflow: allColumnOverflow, treeConfig, treeOpts, expandOpts, editOpts, treeExpandedMaps, scrollXLoad, scrollYLoad, rowExpandedMaps, radioOpts, checkboxOpts, expandColumn, hasFixedColumn, fullAllDataRowIdData, rowOpts, pendingRowMaps, isDragColMove } = $xeTable;
|
|
308
354
|
const { transform, seqMode } = treeOpts;
|
|
309
355
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
310
356
|
const rows = [];
|
|
@@ -343,7 +389,7 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
|
|
|
343
389
|
}
|
|
344
390
|
_rowIndex = rest._index;
|
|
345
391
|
}
|
|
346
|
-
const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex };
|
|
392
|
+
const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex };
|
|
347
393
|
// 行是否被展开
|
|
348
394
|
const isExpandRow = expandColumn && !!rowExpandedMaps[rowid];
|
|
349
395
|
// 树节点是否被展开
|
|
@@ -373,14 +419,14 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
|
|
|
373
419
|
'is--expand-row': isExpandRow,
|
|
374
420
|
'is--expand-tree': isExpandTree,
|
|
375
421
|
'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
|
|
376
|
-
'row--radio': radioOpts.highlight &&
|
|
422
|
+
'row--radio': radioOpts.highlight && selectRadioRow === row,
|
|
377
423
|
'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
|
|
378
424
|
'row--pending': !!pendingRowMaps[rowid]
|
|
379
425
|
},
|
|
380
426
|
rowClassName ? (XEUtils.isFunction(rowClassName) ? rowClassName(params) : rowClassName) : ''
|
|
381
427
|
];
|
|
382
428
|
const tdVNs = tableColumn.map((column, $columnIndex) => {
|
|
383
|
-
return
|
|
429
|
+
return renderTdColumn(h, _vm, seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData);
|
|
384
430
|
});
|
|
385
431
|
rows.push(columnOpts.drag && columnDragOpts.animation
|
|
386
432
|
? h('transition-group', {
|
|
@@ -392,7 +438,7 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
|
|
|
392
438
|
attrs: {
|
|
393
439
|
rowid
|
|
394
440
|
},
|
|
395
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) :
|
|
441
|
+
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : undefined,
|
|
396
442
|
key: rowKey || scrollXLoad || scrollYLoad || rowOpts.useKey || rowOpts.drag || columnOpts.drag || treeConfig ? rowid : $rowIndex,
|
|
397
443
|
nativeOn: trOn
|
|
398
444
|
}, tdVNs)
|
|
@@ -401,12 +447,13 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
|
|
|
401
447
|
attrs: {
|
|
402
448
|
rowid
|
|
403
449
|
},
|
|
404
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) :
|
|
450
|
+
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : undefined,
|
|
405
451
|
key: rowKey || scrollXLoad || scrollYLoad || rowOpts.useKey || rowOpts.drag || columnOpts.drag || treeConfig ? rowid : $rowIndex,
|
|
406
452
|
on: trOn
|
|
407
453
|
}, tdVNs));
|
|
408
454
|
// 如果行被展开了
|
|
409
455
|
if (isExpandRow) {
|
|
456
|
+
const expandOpts = $xeTable.computeExpandOpts;
|
|
410
457
|
const { height: expandHeight, padding } = expandOpts;
|
|
411
458
|
const cellStyle = {};
|
|
412
459
|
if (expandHeight) {
|
|
@@ -417,13 +464,13 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
|
|
|
417
464
|
}
|
|
418
465
|
const { showOverflow } = expandColumn;
|
|
419
466
|
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? allColumnOverflow : showOverflow;
|
|
420
|
-
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex };
|
|
467
|
+
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex };
|
|
421
468
|
rows.push(h('tr', {
|
|
422
469
|
class: ['vxe-body--expanded-row', {
|
|
423
470
|
'is--padding': padding
|
|
424
471
|
}],
|
|
425
472
|
key: `expand_${rowid}`,
|
|
426
|
-
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(expandParams) : rowStyle) :
|
|
473
|
+
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(expandParams) : rowStyle) : undefined,
|
|
427
474
|
on: trOn
|
|
428
475
|
}, [
|
|
429
476
|
h('td', {
|
|
@@ -450,7 +497,7 @@ function renderRows(h, _vm, $xeTable, fixedType, tableData, tableColumn) {
|
|
|
450
497
|
}
|
|
451
498
|
// 如果是树形表格
|
|
452
499
|
if (isExpandTree) {
|
|
453
|
-
rows.push(...renderRows(h, _vm,
|
|
500
|
+
rows.push(...renderRows(h, _vm, fixedType, isOptimizeMode, rowChildren, tableColumn));
|
|
454
501
|
}
|
|
455
502
|
});
|
|
456
503
|
return rows;
|
|
@@ -461,37 +508,37 @@ export default {
|
|
|
461
508
|
tableData: Array,
|
|
462
509
|
tableColumn: Array,
|
|
463
510
|
fixedColumn: Array,
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
return {
|
|
469
|
-
wheelTime: null,
|
|
470
|
-
wheelYSize: 0,
|
|
471
|
-
wheelYInterval: 0,
|
|
472
|
-
wheelYTotal: 0
|
|
473
|
-
};
|
|
511
|
+
fixedType: {
|
|
512
|
+
type: String,
|
|
513
|
+
default: ''
|
|
514
|
+
}
|
|
474
515
|
},
|
|
475
516
|
mounted() {
|
|
476
|
-
const
|
|
477
|
-
const
|
|
517
|
+
const _vm = this;
|
|
518
|
+
const props = _vm;
|
|
519
|
+
const $xeTable = _vm.$parent;
|
|
520
|
+
const tableInternalData = $xeTable;
|
|
521
|
+
const { fixedType } = props;
|
|
522
|
+
const { elemStore } = tableInternalData;
|
|
478
523
|
const prefix = `${fixedType || 'main'}-body-`;
|
|
479
|
-
elemStore[`${prefix}wrapper`] =
|
|
480
|
-
elemStore[`${prefix}
|
|
481
|
-
elemStore[`${prefix}
|
|
482
|
-
elemStore[`${prefix}
|
|
483
|
-
elemStore[`${prefix}
|
|
484
|
-
elemStore[`${prefix}
|
|
485
|
-
elemStore[`${prefix}
|
|
486
|
-
|
|
487
|
-
beforeDestroy() {
|
|
488
|
-
clearTimeout(this.wheelTime);
|
|
524
|
+
elemStore[`${prefix}wrapper`] = _vm.$refs.refElem;
|
|
525
|
+
elemStore[`${prefix}scroll`] = _vm.$refs.refBodyScroll;
|
|
526
|
+
elemStore[`${prefix}table`] = _vm.$refs.refBodyTable;
|
|
527
|
+
elemStore[`${prefix}colgroup`] = _vm.$refs.refBodyColgroup;
|
|
528
|
+
elemStore[`${prefix}list`] = _vm.$refs.refBodyTBody;
|
|
529
|
+
elemStore[`${prefix}xSpace`] = _vm.$refs.refBodyXSpace;
|
|
530
|
+
elemStore[`${prefix}ySpace`] = _vm.$refs.refBodyYSpace;
|
|
531
|
+
elemStore[`${prefix}emptyBlock`] = _vm.$refs.refBodyEmptyBlock;
|
|
489
532
|
},
|
|
490
533
|
destroyed() {
|
|
491
|
-
const
|
|
492
|
-
const
|
|
534
|
+
const props = this;
|
|
535
|
+
const $xeTable = this.$parent;
|
|
536
|
+
const tableInternalData = $xeTable;
|
|
537
|
+
const { fixedType } = props;
|
|
538
|
+
const { elemStore } = tableInternalData;
|
|
493
539
|
const prefix = `${fixedType || 'main'}-body-`;
|
|
494
540
|
elemStore[`${prefix}wrapper`] = null;
|
|
541
|
+
elemStore[`${prefix}scroll`] = null;
|
|
495
542
|
elemStore[`${prefix}table`] = null;
|
|
496
543
|
elemStore[`${prefix}colgroup`] = null;
|
|
497
544
|
elemStore[`${prefix}list`] = null;
|
|
@@ -505,31 +552,33 @@ export default {
|
|
|
505
552
|
const tableProps = $xeTable;
|
|
506
553
|
const tableReactData = $xeTable;
|
|
507
554
|
const tableInternalData = $xeTable;
|
|
508
|
-
const {
|
|
555
|
+
const { xID, $scopedSlots } = $xeTable;
|
|
509
556
|
const { fixedColumn, fixedType, tableColumn } = props;
|
|
510
557
|
const { showOverflow: allColumnOverflow, spanMethod, footerSpanMethod, mouseConfig } = tableProps;
|
|
511
558
|
const { isGroup, tableData, scrollXLoad, scrollYLoad, isAllOverflow, isDragRowMove, expandColumn, dragRow, dragCol } = tableReactData;
|
|
512
559
|
const { visibleColumn, fullAllDataRowIdData, fullColumnIdData } = tableInternalData;
|
|
513
560
|
const rowOpts = $xeTable.computeRowOpts;
|
|
514
|
-
const sYOpts = $xeTable.computeSYOpts;
|
|
515
561
|
const emptyOpts = $xeTable.computeEmptyOpts;
|
|
516
562
|
const mouseOpts = $xeTable.computeMouseOpts;
|
|
517
563
|
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
564
|
+
const leftFixedWidth = $xeTable.computeLeftFixedWidth;
|
|
565
|
+
const rightFixedWidth = $xeTable.computeRightFixedWidth;
|
|
518
566
|
let renderDataList = tableData;
|
|
519
567
|
let renderColumnList = tableColumn;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
568
|
+
let isOptimizeMode = false;
|
|
569
|
+
// 如果是使用优化模式
|
|
570
|
+
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
571
|
+
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
523
572
|
// 如果不支持优化模式
|
|
524
|
-
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
525
|
-
renderColumnList = visibleColumn;
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
renderColumnList = fixedColumn || [];
|
|
529
|
-
}
|
|
530
573
|
}
|
|
531
574
|
else {
|
|
532
|
-
|
|
575
|
+
isOptimizeMode = true;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (fixedType) {
|
|
579
|
+
renderColumnList = visibleColumn;
|
|
580
|
+
if (isOptimizeMode) {
|
|
581
|
+
renderColumnList = fixedColumn || [];
|
|
533
582
|
}
|
|
534
583
|
}
|
|
535
584
|
// 行拖拽
|
|
@@ -582,7 +631,7 @@ export default {
|
|
|
582
631
|
}
|
|
583
632
|
let emptyContent;
|
|
584
633
|
if ($scopedSlots.empty) {
|
|
585
|
-
emptyContent = $scopedSlots.empty.call(this, { $table: $xeTable, $grid: $xeTable.xegrid }
|
|
634
|
+
emptyContent = $scopedSlots.empty.call(this, { $table: $xeTable, $grid: $xeTable.xegrid });
|
|
586
635
|
}
|
|
587
636
|
else {
|
|
588
637
|
const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null;
|
|
@@ -595,271 +644,121 @@ export default {
|
|
|
595
644
|
}
|
|
596
645
|
}
|
|
597
646
|
const ons = {
|
|
598
|
-
scroll
|
|
647
|
+
scroll(evnt) {
|
|
648
|
+
$xeTable.triggerBodyScrollEvent(evnt, fixedType);
|
|
649
|
+
}
|
|
599
650
|
};
|
|
600
|
-
if (
|
|
601
|
-
ons.wheel =
|
|
651
|
+
if (scrollYLoad || leftFixedWidth || rightFixedWidth) {
|
|
652
|
+
ons.wheel = $xeTable.triggerBodyWheelEvent;
|
|
602
653
|
}
|
|
603
654
|
return h('div', {
|
|
604
655
|
ref: 'refElem',
|
|
605
656
|
class: ['vxe-table--body-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
|
|
606
657
|
attrs: {
|
|
607
|
-
xid:
|
|
608
|
-
}
|
|
609
|
-
on: ons
|
|
658
|
+
xid: xID
|
|
659
|
+
}
|
|
610
660
|
}, [
|
|
611
|
-
fixedType
|
|
612
|
-
? renderEmptyElement($xeTable)
|
|
613
|
-
: h('div', {
|
|
614
|
-
class: 'vxe-body--x-space',
|
|
615
|
-
ref: 'xSpace'
|
|
616
|
-
}),
|
|
617
661
|
h('div', {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
h('table', {
|
|
622
|
-
class: 'vxe-table--body',
|
|
623
|
-
attrs: {
|
|
624
|
-
xid: tId,
|
|
625
|
-
cellspacing: 0,
|
|
626
|
-
cellpadding: 0,
|
|
627
|
-
border: 0
|
|
628
|
-
},
|
|
629
|
-
ref: 'table'
|
|
662
|
+
ref: 'refBodyScroll',
|
|
663
|
+
class: 'vxe-table--body-inner-wrapper',
|
|
664
|
+
on: ons
|
|
630
665
|
}, [
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
tag: 'tbody',
|
|
651
|
-
name: `vxe-body--row-list${isDragRowMove ? '' : '-disabled'}`
|
|
652
|
-
}
|
|
653
|
-
}, renderRows(h, this, $xeTable, fixedType, renderDataList, renderColumnList))
|
|
654
|
-
: h('tbody', {
|
|
655
|
-
ref: 'tbody'
|
|
656
|
-
}, renderRows(h, this, $xeTable, fixedType, renderDataList, renderColumnList))
|
|
657
|
-
]),
|
|
658
|
-
h('div', {
|
|
659
|
-
class: 'vxe-table--checkbox-range'
|
|
660
|
-
}),
|
|
661
|
-
mouseConfig && mouseOpts.area
|
|
662
|
-
? h('div', {
|
|
663
|
-
class: 'vxe-table--cell-area'
|
|
666
|
+
fixedType
|
|
667
|
+
? renderEmptyElement($xeTable)
|
|
668
|
+
: h('div', {
|
|
669
|
+
ref: 'refBodyXSpace',
|
|
670
|
+
class: 'vxe-body--x-space'
|
|
671
|
+
}),
|
|
672
|
+
h('div', {
|
|
673
|
+
ref: 'refBodyYSpace',
|
|
674
|
+
class: 'vxe-body--y-space'
|
|
675
|
+
}),
|
|
676
|
+
h('table', {
|
|
677
|
+
ref: 'refBodyTable',
|
|
678
|
+
class: 'vxe-table--body',
|
|
679
|
+
attrs: {
|
|
680
|
+
xid: xID,
|
|
681
|
+
cellspacing: 0,
|
|
682
|
+
cellpadding: 0,
|
|
683
|
+
border: 0
|
|
684
|
+
}
|
|
664
685
|
}, [
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
686
|
+
/**
|
|
687
|
+
* 列宽
|
|
688
|
+
*/
|
|
689
|
+
h('colgroup', {
|
|
690
|
+
ref: 'refBodyColgroup'
|
|
691
|
+
}, renderColumnList.map((column, $columnIndex) => {
|
|
692
|
+
return h('col', {
|
|
693
|
+
attrs: {
|
|
694
|
+
name: column.id
|
|
695
|
+
},
|
|
696
|
+
key: $columnIndex
|
|
697
|
+
});
|
|
698
|
+
})),
|
|
699
|
+
/**
|
|
700
|
+
* 内容
|
|
701
|
+
*/
|
|
702
|
+
rowOpts.drag && rowDragOpts.animation
|
|
703
|
+
? h('transition-group', {
|
|
704
|
+
ref: 'refBodyTBody',
|
|
705
|
+
props: {
|
|
706
|
+
tag: 'tbody',
|
|
707
|
+
name: `vxe-body--row-list${isDragRowMove ? '' : '-disabled'}`
|
|
708
|
+
}
|
|
709
|
+
}, renderRows(h, this, fixedType, isOptimizeMode, renderDataList, renderColumnList))
|
|
710
|
+
: h('tbody', {
|
|
711
|
+
ref: 'refBodyTBody'
|
|
712
|
+
}, renderRows(h, this, fixedType, isOptimizeMode, renderDataList, renderColumnList))
|
|
713
|
+
]),
|
|
714
|
+
h('div', {
|
|
715
|
+
class: 'vxe-table--checkbox-range'
|
|
716
|
+
}),
|
|
717
|
+
mouseConfig && mouseOpts.area
|
|
718
|
+
? h('div', {
|
|
719
|
+
class: 'vxe-table--cell-area'
|
|
720
|
+
}, [
|
|
721
|
+
h('span', {
|
|
722
|
+
class: 'vxe-table--cell-main-area'
|
|
723
|
+
}, mouseOpts.extension
|
|
724
|
+
? [
|
|
725
|
+
h('span', {
|
|
726
|
+
class: 'vxe-table--cell-main-area-btn',
|
|
727
|
+
on: {
|
|
728
|
+
mousedown(evnt) {
|
|
729
|
+
if ($xeTable.triggerCellAreaExtendMousedownEvent) {
|
|
730
|
+
$xeTable.triggerCellAreaExtendMousedownEvent(evnt, { $table: $xeTable, fixed: fixedType, type: renderType });
|
|
731
|
+
}
|
|
675
732
|
}
|
|
676
733
|
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
734
|
+
})
|
|
735
|
+
]
|
|
736
|
+
: null),
|
|
737
|
+
h('span', {
|
|
738
|
+
class: 'vxe-table--cell-copy-area'
|
|
739
|
+
}),
|
|
740
|
+
h('span', {
|
|
741
|
+
class: 'vxe-table--cell-extend-area'
|
|
742
|
+
}),
|
|
743
|
+
h('span', {
|
|
744
|
+
class: 'vxe-table--cell-multi-area'
|
|
745
|
+
}),
|
|
746
|
+
h('span', {
|
|
747
|
+
class: 'vxe-table--cell-active-area'
|
|
748
|
+
})
|
|
749
|
+
])
|
|
750
|
+
: renderEmptyElement($xeTable),
|
|
751
|
+
!fixedType
|
|
752
|
+
? h('div', {
|
|
753
|
+
class: 'vxe-table--empty-block',
|
|
754
|
+
ref: 'emptyBlock'
|
|
755
|
+
}, [
|
|
756
|
+
h('div', {
|
|
757
|
+
class: 'vxe-table--empty-content'
|
|
758
|
+
}, emptyContent)
|
|
759
|
+
])
|
|
760
|
+
: renderEmptyElement($xeTable)
|
|
761
|
+
])
|
|
705
762
|
]);
|
|
706
|
-
},
|
|
707
|
-
methods: {
|
|
708
|
-
/**
|
|
709
|
-
* 滚动处理
|
|
710
|
-
* 如果存在列固定左侧,同步更新滚动状态
|
|
711
|
-
* 如果存在列固定右侧,同步更新滚动状态
|
|
712
|
-
*/
|
|
713
|
-
scrollEvent(evnt) {
|
|
714
|
-
const $xeTable = this.$parent;
|
|
715
|
-
const tableInternalData = $xeTable;
|
|
716
|
-
const { fixedType } = this;
|
|
717
|
-
const { lastScrollTop, lastScrollLeft, inVirtualScroll, inBodyScroll, bodyScrollType, inFooterScroll } = tableInternalData;
|
|
718
|
-
if (inVirtualScroll) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
if (inFooterScroll) {
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
if (inBodyScroll) {
|
|
725
|
-
if (bodyScrollType !== fixedType) {
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
const { tableHeader, tableBody, leftBody, rightBody, tableFooter } = $xeTable.$refs;
|
|
730
|
-
const scrollBodyElem = this.$el;
|
|
731
|
-
const headerElem = tableHeader ? tableHeader.$el : null;
|
|
732
|
-
const footerElem = tableFooter ? tableFooter.$el : null;
|
|
733
|
-
const bodyElem = tableBody ? tableBody.$el : null;
|
|
734
|
-
if (!bodyElem) {
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
const leftElem = leftBody ? leftBody.$el : null;
|
|
738
|
-
const rightElem = rightBody ? rightBody.$el : null;
|
|
739
|
-
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
740
|
-
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
741
|
-
const scrollTop = scrollBodyElem.scrollTop;
|
|
742
|
-
const scrollLeft = bodyElem.scrollLeft;
|
|
743
|
-
const isRollX = scrollLeft !== lastScrollLeft;
|
|
744
|
-
const isRollY = scrollTop !== lastScrollTop;
|
|
745
|
-
tableInternalData.inBodyScroll = true;
|
|
746
|
-
tableInternalData.bodyScrollType = fixedType;
|
|
747
|
-
if (isRollY) {
|
|
748
|
-
if (leftElem && fixedType === 'left') {
|
|
749
|
-
setScrollTop(bodyElem, scrollTop);
|
|
750
|
-
setScrollTop(rightElem, scrollTop);
|
|
751
|
-
}
|
|
752
|
-
else if (rightElem && fixedType === 'right') {
|
|
753
|
-
setScrollTop(bodyElem, scrollTop);
|
|
754
|
-
setScrollTop(leftElem, scrollTop);
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
setScrollTop(leftElem, scrollTop);
|
|
758
|
-
setScrollTop(rightElem, scrollTop);
|
|
759
|
-
}
|
|
760
|
-
setScrollTop(yHandleEl, scrollTop);
|
|
761
|
-
$xeTable.triggerScrollYEvent(evnt);
|
|
762
|
-
}
|
|
763
|
-
if (isRollX) {
|
|
764
|
-
setScrollLeft(xHandleEl, scrollLeft);
|
|
765
|
-
setScrollLeft(headerElem, scrollLeft);
|
|
766
|
-
setScrollLeft(footerElem, scrollLeft);
|
|
767
|
-
$xeTable.triggerScrollXEvent(evnt);
|
|
768
|
-
}
|
|
769
|
-
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
770
|
-
type: renderType,
|
|
771
|
-
fixed: fixedType
|
|
772
|
-
});
|
|
773
|
-
},
|
|
774
|
-
handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY) {
|
|
775
|
-
const { $parent: $xetable } = this;
|
|
776
|
-
const { $refs, elemStore, scrollYLoad, scrollXLoad } = $xetable;
|
|
777
|
-
const { tableBody, leftBody, rightBody } = $refs;
|
|
778
|
-
const bodyElem = tableBody.$el;
|
|
779
|
-
const leftElem = leftBody ? leftBody.$el : null;
|
|
780
|
-
const rightElem = rightBody ? rightBody.$el : null;
|
|
781
|
-
const remainSize = this.isPrevWheelTop === isTopWheel ? Math.max(0, this.wheelYSize - this.wheelYTotal) : 0;
|
|
782
|
-
const bodyYElem = elemStore['main-body-ySpace'];
|
|
783
|
-
const bodyXElem = elemStore['main-body-xSpace'];
|
|
784
|
-
const bodyHeight = scrollYLoad && bodyYElem ? bodyYElem.clientHeight : bodyElem.clientHeight;
|
|
785
|
-
const bodyWidth = scrollXLoad && bodyXElem ? bodyXElem.clientWidth : bodyElem.clientWidth;
|
|
786
|
-
this.isPrevWheelTop = isTopWheel;
|
|
787
|
-
this.wheelYSize = Math.abs(isTopWheel ? deltaTop - remainSize : deltaTop + remainSize);
|
|
788
|
-
this.wheelYInterval = 0;
|
|
789
|
-
this.wheelYTotal = 0;
|
|
790
|
-
clearTimeout(this.wheelTime);
|
|
791
|
-
const handleSmooth = () => {
|
|
792
|
-
let { fixedType, wheelYTotal, wheelYSize, wheelYInterval } = this;
|
|
793
|
-
if (wheelYTotal < wheelYSize) {
|
|
794
|
-
wheelYInterval = Math.max(5, Math.floor(wheelYInterval * 1.5));
|
|
795
|
-
wheelYTotal = wheelYTotal + wheelYInterval;
|
|
796
|
-
if (wheelYTotal > wheelYSize) {
|
|
797
|
-
wheelYInterval = wheelYInterval - (wheelYTotal - wheelYSize);
|
|
798
|
-
}
|
|
799
|
-
const { scrollTop, clientHeight, scrollHeight } = bodyElem;
|
|
800
|
-
const targetTop = scrollTop + (wheelYInterval * (isTopWheel ? -1 : 1));
|
|
801
|
-
bodyElem.scrollTop = targetTop;
|
|
802
|
-
if (leftElem) {
|
|
803
|
-
leftElem.scrollTop = targetTop;
|
|
804
|
-
}
|
|
805
|
-
if (rightElem) {
|
|
806
|
-
rightElem.scrollTop = targetTop;
|
|
807
|
-
}
|
|
808
|
-
if (isTopWheel ? targetTop < scrollHeight - clientHeight : targetTop >= 0) {
|
|
809
|
-
this.wheelTime = setTimeout(handleSmooth, 10);
|
|
810
|
-
}
|
|
811
|
-
this.wheelYTotal = wheelYTotal;
|
|
812
|
-
this.wheelYInterval = wheelYInterval;
|
|
813
|
-
$xetable.emitEvent('scroll', {
|
|
814
|
-
type: renderType,
|
|
815
|
-
fixed: fixedType,
|
|
816
|
-
scrollTop: bodyElem.scrollTop,
|
|
817
|
-
scrollLeft: bodyElem.scrollLeft,
|
|
818
|
-
scrollHeight: bodyElem.scrollHeight,
|
|
819
|
-
scrollWidth: bodyElem.scrollWidth,
|
|
820
|
-
bodyHeight,
|
|
821
|
-
bodyWidth,
|
|
822
|
-
isX: isRollX,
|
|
823
|
-
isY: isRollY
|
|
824
|
-
}, evnt);
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
handleSmooth();
|
|
828
|
-
},
|
|
829
|
-
/**
|
|
830
|
-
* 滚轮处理
|
|
831
|
-
*/
|
|
832
|
-
wheelEvent(evnt) {
|
|
833
|
-
const { deltaY, deltaX } = evnt;
|
|
834
|
-
const { $el: scrollBodyElem, $parent: $xetable } = this;
|
|
835
|
-
const { $refs, highlightHoverRow, scrollYLoad, lastScrollTop, lastScrollLeft, rowOpts } = $xetable;
|
|
836
|
-
const { tableBody } = $refs;
|
|
837
|
-
const bodyElem = tableBody.$el;
|
|
838
|
-
const deltaTop = deltaY;
|
|
839
|
-
const deltaLeft = deltaX;
|
|
840
|
-
const isTopWheel = deltaTop < 0;
|
|
841
|
-
// 如果滚动位置已经是顶部或底部,则不需要触发
|
|
842
|
-
if (isTopWheel ? scrollBodyElem.scrollTop <= 0 : scrollBodyElem.scrollTop >= scrollBodyElem.scrollHeight - scrollBodyElem.clientHeight) {
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
|
-
const scrollTop = scrollBodyElem.scrollTop + deltaTop;
|
|
846
|
-
const scrollLeft = bodyElem.scrollLeft + deltaLeft;
|
|
847
|
-
const isRollX = scrollLeft !== lastScrollLeft;
|
|
848
|
-
const isRollY = scrollTop !== lastScrollTop;
|
|
849
|
-
// 用于鼠标纵向滚轮处理
|
|
850
|
-
if (isRollY) {
|
|
851
|
-
evnt.preventDefault();
|
|
852
|
-
$xetable.lastScrollTop = scrollTop;
|
|
853
|
-
$xetable.lastScrollLeft = scrollLeft;
|
|
854
|
-
$xetable.lastScrollTime = Date.now();
|
|
855
|
-
if (rowOpts.isHover || highlightHoverRow) {
|
|
856
|
-
$xetable.clearHoverRow();
|
|
857
|
-
}
|
|
858
|
-
this.handleWheel(evnt, isTopWheel, deltaTop, isRollX, isRollY);
|
|
859
|
-
if (scrollYLoad) {
|
|
860
|
-
$xetable.triggerScrollYEvent(evnt);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
763
|
}
|
|
865
764
|
};
|