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