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/methods.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils';
|
|
2
|
-
import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft
|
|
2
|
+
import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft } from '../../ui/src/dom';
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
|
|
4
4
|
import { VxeUI } from '../../ui';
|
|
5
5
|
import Cell from './cell';
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth } from './util';
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getRefElem } from './util';
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn';
|
|
8
8
|
import { warnLog, errLog } from '../../ui/src/log';
|
|
9
9
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI;
|
|
10
10
|
const customStorageKey = 'VXE_CUSTOM_STORE';
|
|
11
|
-
// 获取所有的列,排除分组
|
|
12
|
-
const getColumnList = (columns) => {
|
|
13
|
-
const result = [];
|
|
14
|
-
columns.forEach((column) => {
|
|
15
|
-
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
|
|
16
|
-
});
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
11
|
function eqCellValue(row1, row2, field) {
|
|
20
12
|
const val1 = XEUtils.get(row1, field);
|
|
21
13
|
const val2 = XEUtils.get(row2, field);
|
|
@@ -68,18 +60,20 @@ function handleReserveRow(_vm, reserveRowMap) {
|
|
|
68
60
|
}
|
|
69
61
|
function handleVirtualXVisible($xeTable) {
|
|
70
62
|
const internalData = $xeTable;
|
|
71
|
-
const { visibleColumn } = internalData;
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
63
|
+
const { elemStore, visibleColumn } = internalData;
|
|
64
|
+
const leftFixedWidth = $xeTable.computeLeftFixedWidth;
|
|
65
|
+
const rightFixedWidth = $xeTable.computeRightFixedWidth;
|
|
66
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
67
|
+
if (bodyScrollElem) {
|
|
68
|
+
const { scrollLeft, clientWidth } = bodyScrollElem;
|
|
69
|
+
const startWidth = scrollLeft + leftFixedWidth;
|
|
70
|
+
const endWidth = scrollLeft + clientWidth - rightFixedWidth;
|
|
77
71
|
let toVisibleIndex = -1;
|
|
78
72
|
let cWidth = 0;
|
|
79
73
|
let visibleSize = 0;
|
|
80
74
|
for (let colIndex = 0, colLen = visibleColumn.length; colIndex < colLen; colIndex++) {
|
|
81
75
|
cWidth += visibleColumn[colIndex].renderWidth;
|
|
82
|
-
if (toVisibleIndex === -1 &&
|
|
76
|
+
if (toVisibleIndex === -1 && startWidth < cWidth) {
|
|
83
77
|
toVisibleIndex = colIndex;
|
|
84
78
|
}
|
|
85
79
|
if (toVisibleIndex >= 0) {
|
|
@@ -89,14 +83,87 @@ function handleVirtualXVisible($xeTable) {
|
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
}
|
|
92
|
-
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(
|
|
86
|
+
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(1, visibleSize) };
|
|
93
87
|
}
|
|
94
88
|
return { toVisibleIndex: 0, visibleSize: 6 };
|
|
95
89
|
}
|
|
90
|
+
function handleCustomRestore($xeTable, storeData) {
|
|
91
|
+
const reactData = $xeTable;
|
|
92
|
+
const internalData = $xeTable;
|
|
93
|
+
let { collectColumn } = internalData;
|
|
94
|
+
const { resizableData, sortData, visibleData, fixedData } = storeData;
|
|
95
|
+
let hasCustomSort = false;
|
|
96
|
+
// 处理还原
|
|
97
|
+
if (resizableData || sortData || visibleData || fixedData) {
|
|
98
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
99
|
+
const colKey = column.getKey();
|
|
100
|
+
// 支持一级
|
|
101
|
+
if (!parentColumn) {
|
|
102
|
+
if (fixedData && fixedData[colKey] !== undefined) {
|
|
103
|
+
column.fixed = fixedData[colKey];
|
|
104
|
+
}
|
|
105
|
+
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
106
|
+
hasCustomSort = true;
|
|
107
|
+
column.renderSortNumber = sortData[colKey];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
111
|
+
column.resizeWidth = resizableData[colKey];
|
|
112
|
+
}
|
|
113
|
+
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
114
|
+
column.visible = visibleData[colKey];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
// 如果自定义了顺序
|
|
118
|
+
if (hasCustomSort) {
|
|
119
|
+
collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber');
|
|
120
|
+
internalData.collectColumn = collectColumn;
|
|
121
|
+
internalData.tableFullColumn = getColumnList(collectColumn);
|
|
122
|
+
}
|
|
123
|
+
reactData.isCustomStatus = true;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
reactData.isCustomStatus = false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 还原自定义列操作状态
|
|
131
|
+
*/
|
|
132
|
+
function restoreCustomStorage($xeTable) {
|
|
133
|
+
const props = $xeTable;
|
|
134
|
+
const { customConfig } = props;
|
|
135
|
+
const tableId = $xeTable.computeTableId;
|
|
136
|
+
const customOpts = $xeTable.computeCustomOpts;
|
|
137
|
+
const { storage, restoreStore } = customOpts;
|
|
138
|
+
const isAllCustom = storage === true;
|
|
139
|
+
const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {});
|
|
140
|
+
const isCustomResizable = isAllCustom || storageOpts.resizable;
|
|
141
|
+
const isCustomVisible = isAllCustom || storageOpts.visible;
|
|
142
|
+
const isCustomFixed = isAllCustom || storageOpts.fixed;
|
|
143
|
+
const isCustomSort = isAllCustom || storageOpts.sort;
|
|
144
|
+
if ((customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
|
|
145
|
+
if (!tableId) {
|
|
146
|
+
errLog('vxe.error.reqProp', ['id']);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const storeData = getCustomStorageMap(tableId);
|
|
150
|
+
if (restoreStore) {
|
|
151
|
+
return Promise.resolve(restoreStore({ id: tableId, type: 'restore', storeData })).then(storeData => {
|
|
152
|
+
if (!storeData) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
return handleCustomRestore($xeTable, storeData);
|
|
156
|
+
}).catch(e => e);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
return handleCustomRestore($xeTable, storeData);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
96
163
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
164
|
+
* 更新数据列的 Map
|
|
165
|
+
* 牺牲数据组装的耗时,用来换取使用过程中的流畅
|
|
166
|
+
*/
|
|
100
167
|
function cacheColumnMap($xeTable) {
|
|
101
168
|
const props = $xeTable;
|
|
102
169
|
const reactData = $xeTable;
|
|
@@ -129,7 +196,7 @@ function cacheColumnMap($xeTable) {
|
|
|
129
196
|
fullColumnFieldData[field] = rest;
|
|
130
197
|
}
|
|
131
198
|
else {
|
|
132
|
-
if (storage || isCrossDrag || isSelfToChildDrag) {
|
|
199
|
+
if (storage || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
|
|
133
200
|
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field`]);
|
|
134
201
|
}
|
|
135
202
|
}
|
|
@@ -262,12 +329,323 @@ function handleVirtualTreeToList($xeTable) {
|
|
|
262
329
|
}
|
|
263
330
|
return internalData.afterFullData;
|
|
264
331
|
}
|
|
332
|
+
function updateStyle($xeTable) {
|
|
333
|
+
const props = $xeTable;
|
|
334
|
+
const reactData = $xeTable;
|
|
335
|
+
const internalData = $xeTable;
|
|
336
|
+
const { border, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props;
|
|
337
|
+
const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, scrollbarWidth, scrollbarHeight, columnStore, editStore, isAllOverflow, expandColumn } = reactData;
|
|
338
|
+
const { visibleColumn, fullColumnIdData, tableHeight, tableWidth, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData;
|
|
339
|
+
const el = $xeTable.$refs.refElem;
|
|
340
|
+
if (!el) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const containerList = ['main', 'left', 'right'];
|
|
344
|
+
const emptyPlaceholderElem = $xeTable.$refs.refEmptyPlaceholder;
|
|
345
|
+
const cellOffsetWidth = $xeTable.computeCellOffsetWidth;
|
|
346
|
+
const mouseOpts = $xeTable.computeMouseOpts;
|
|
347
|
+
const bodyWrapperElem = getRefElem(elemStore['main-body-wrapper']);
|
|
348
|
+
const bodyTableElem = getRefElem(elemStore['main-body-table']);
|
|
349
|
+
if (emptyPlaceholderElem) {
|
|
350
|
+
emptyPlaceholderElem.style.top = `${headerHeight}px`;
|
|
351
|
+
emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
|
|
352
|
+
}
|
|
353
|
+
let bodyHeight = 0;
|
|
354
|
+
let bodyMaxHeight = 0;
|
|
355
|
+
const bodyMinHeight = customMinHeight - headerHeight - footerHeight - scrollbarHeight;
|
|
356
|
+
if (customMaxHeight) {
|
|
357
|
+
bodyMaxHeight = Math.max(bodyMinHeight, customMaxHeight - headerHeight - footerHeight - scrollbarHeight);
|
|
358
|
+
}
|
|
359
|
+
if (customHeight) {
|
|
360
|
+
bodyHeight = customHeight - headerHeight - footerHeight - scrollbarHeight;
|
|
361
|
+
}
|
|
362
|
+
if (!bodyHeight) {
|
|
363
|
+
if (bodyTableElem) {
|
|
364
|
+
bodyHeight = bodyTableElem.clientHeight;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (bodyHeight) {
|
|
368
|
+
if (bodyMaxHeight) {
|
|
369
|
+
bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
|
|
370
|
+
}
|
|
371
|
+
bodyHeight = Math.max(bodyMinHeight, bodyHeight);
|
|
372
|
+
}
|
|
373
|
+
const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
|
|
374
|
+
if (scrollXVirtualEl) {
|
|
375
|
+
scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
|
|
376
|
+
scrollXVirtualEl.style.visibility = scrollbarHeight ? 'visible' : 'hidden';
|
|
377
|
+
}
|
|
378
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
379
|
+
if (xHandleEl) {
|
|
380
|
+
xHandleEl.style.width = `${el.clientWidth - scrollbarWidth}px`;
|
|
381
|
+
}
|
|
382
|
+
const xRightCornerEl = $xeTable.$refs.refScrollXRightCornerElem;
|
|
383
|
+
if (xRightCornerEl) {
|
|
384
|
+
xRightCornerEl.style.width = `${scrollbarWidth}px`;
|
|
385
|
+
xRightCornerEl.style.display = scrollbarWidth && scrollbarHeight ? 'block' : '';
|
|
386
|
+
}
|
|
387
|
+
const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
|
|
388
|
+
if (scrollYVirtualEl) {
|
|
389
|
+
scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
|
|
390
|
+
scrollYVirtualEl.style.height = `${bodyHeight + headerHeight + footerHeight}px`;
|
|
391
|
+
scrollYVirtualEl.style.visibility = scrollbarWidth ? 'visible' : 'hidden';
|
|
392
|
+
}
|
|
393
|
+
const yTopCornerEl = $xeTable.$refs.refScrollYTopCornerElem;
|
|
394
|
+
if (yTopCornerEl) {
|
|
395
|
+
yTopCornerEl.style.height = `${headerHeight}px`;
|
|
396
|
+
yTopCornerEl.style.display = headerHeight ? 'block' : '';
|
|
397
|
+
}
|
|
398
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
399
|
+
if (yHandleEl) {
|
|
400
|
+
yHandleEl.style.height = `${bodyHeight}px`;
|
|
401
|
+
yHandleEl.style.top = `${headerHeight}px`;
|
|
402
|
+
}
|
|
403
|
+
const yBottomCornerEl = $xeTable.$refs.refScrollYBottomCornerElem;
|
|
404
|
+
if (yBottomCornerEl) {
|
|
405
|
+
yBottomCornerEl.style.height = `${footerHeight}px`;
|
|
406
|
+
yBottomCornerEl.style.top = `${headerHeight + bodyHeight}px`;
|
|
407
|
+
yBottomCornerEl.style.display = footerHeight ? 'block' : '';
|
|
408
|
+
}
|
|
409
|
+
containerList.forEach((name, index) => {
|
|
410
|
+
const fixedType = index > 0 ? name : '';
|
|
411
|
+
const layoutList = ['header', 'body', 'footer'];
|
|
412
|
+
const isFixedLeft = fixedType === 'left';
|
|
413
|
+
let fixedColumn = [];
|
|
414
|
+
let fixedWrapperElem;
|
|
415
|
+
if (fixedType) {
|
|
416
|
+
fixedColumn = isFixedLeft ? columnStore.leftList : columnStore.rightList;
|
|
417
|
+
fixedWrapperElem = (isFixedLeft ? $xeTable.$refs.refLeftContainer : $xeTable.$refs.refRightContainer);
|
|
418
|
+
}
|
|
419
|
+
layoutList.forEach(layout => {
|
|
420
|
+
const wrapperElem = getRefElem(elemStore[`${name}-${layout}-wrapper`]);
|
|
421
|
+
const currScrollElem = getRefElem(elemStore[`${name}-${layout}-scroll`]);
|
|
422
|
+
const tableElem = getRefElem(elemStore[`${name}-${layout}-table`]);
|
|
423
|
+
if (layout === 'header') {
|
|
424
|
+
// 表头体样式处理
|
|
425
|
+
// 横向滚动渲染
|
|
426
|
+
let tWidth = tableWidth;
|
|
427
|
+
let renderColumnList = tableColumn;
|
|
428
|
+
let isOptimizeMode = false;
|
|
429
|
+
if (isGroup) {
|
|
430
|
+
renderColumnList = visibleColumn;
|
|
431
|
+
if (fixedType) {
|
|
432
|
+
if (wrapperElem) {
|
|
433
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
// 如果是使用优化模式
|
|
439
|
+
if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
|
|
440
|
+
if (spanMethod || footerSpanMethod) {
|
|
441
|
+
// 如果不支持优化模式
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
isOptimizeMode = true;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (fixedType) {
|
|
448
|
+
renderColumnList = visibleColumn;
|
|
449
|
+
// 如果是使用优化模式
|
|
450
|
+
if (isOptimizeMode) {
|
|
451
|
+
renderColumnList = fixedColumn || [];
|
|
452
|
+
}
|
|
453
|
+
if (!isOptimizeMode) {
|
|
454
|
+
if (wrapperElem) {
|
|
455
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
461
|
+
if (currScrollElem) {
|
|
462
|
+
currScrollElem.style.height = `${headerHeight}px`;
|
|
463
|
+
}
|
|
464
|
+
if (tableElem) {
|
|
465
|
+
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
466
|
+
}
|
|
467
|
+
const repairElem = getRefElem(elemStore[`${name}-${layout}-repair`]);
|
|
468
|
+
if (repairElem) {
|
|
469
|
+
repairElem.style.width = `${tableWidth}px`;
|
|
470
|
+
}
|
|
471
|
+
const listElem = getRefElem(elemStore[`${name}-${layout}-list`]);
|
|
472
|
+
if (isGroup && listElem) {
|
|
473
|
+
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem) => {
|
|
474
|
+
const colNode = $xeTable.getColumnNode(thElem);
|
|
475
|
+
if (colNode) {
|
|
476
|
+
const column = colNode.item;
|
|
477
|
+
const { showHeaderOverflow } = column;
|
|
478
|
+
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
|
|
479
|
+
const showEllipsis = cellOverflow === 'ellipsis';
|
|
480
|
+
const showTitle = cellOverflow === 'title';
|
|
481
|
+
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
482
|
+
const hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
483
|
+
let childWidth = 0;
|
|
484
|
+
let countChild = 0;
|
|
485
|
+
if (hasEllipsis) {
|
|
486
|
+
XEUtils.eachTree(column.children, (item) => {
|
|
487
|
+
if (!item.children || !column.children.length) {
|
|
488
|
+
countChild++;
|
|
489
|
+
}
|
|
490
|
+
childWidth += item.renderWidth;
|
|
491
|
+
}, { children: 'children' });
|
|
492
|
+
}
|
|
493
|
+
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else if (layout === 'body') {
|
|
499
|
+
if (currScrollElem) {
|
|
500
|
+
currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : '';
|
|
501
|
+
currScrollElem.style.height = customHeight ? `${bodyHeight}px` : '';
|
|
502
|
+
currScrollElem.style.minHeight = `${bodyMinHeight}px`;
|
|
503
|
+
}
|
|
504
|
+
// 如果是固定列
|
|
505
|
+
if (fixedWrapperElem) {
|
|
506
|
+
if (wrapperElem) {
|
|
507
|
+
wrapperElem.style.top = `${headerHeight}px`;
|
|
508
|
+
}
|
|
509
|
+
fixedWrapperElem.style.height = `${customHeight > 0 ? customHeight : (tableHeight + headerHeight + footerHeight + scrollbarHeight)}px`;
|
|
510
|
+
fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, 0)}px`;
|
|
511
|
+
}
|
|
512
|
+
let tWidth = tableWidth;
|
|
513
|
+
let renderColumnList = tableColumn;
|
|
514
|
+
let isOptimizeMode = false;
|
|
515
|
+
// 如果是使用优化模式
|
|
516
|
+
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
517
|
+
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
518
|
+
// 如果不支持优化模式
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
isOptimizeMode = true;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (fixedType) {
|
|
525
|
+
renderColumnList = visibleColumn;
|
|
526
|
+
if (isOptimizeMode) {
|
|
527
|
+
renderColumnList = fixedColumn || [];
|
|
528
|
+
}
|
|
529
|
+
if (!isOptimizeMode) {
|
|
530
|
+
if (wrapperElem) {
|
|
531
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
536
|
+
if (tableElem) {
|
|
537
|
+
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
538
|
+
// 兼容性处理
|
|
539
|
+
tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : '';
|
|
540
|
+
}
|
|
541
|
+
const emptyBlockElem = getRefElem(elemStore[`${name}-${layout}-emptyBlock`]);
|
|
542
|
+
if (emptyBlockElem) {
|
|
543
|
+
emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
else if (layout === 'footer') {
|
|
547
|
+
let tWidth = tableWidth;
|
|
548
|
+
let renderColumnList = tableColumn;
|
|
549
|
+
let isOptimizeMode = false;
|
|
550
|
+
// 如果是使用优化模式
|
|
551
|
+
if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
|
|
552
|
+
if (spanMethod || footerSpanMethod) {
|
|
553
|
+
// 如果不支持优化模式
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
isOptimizeMode = true;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (fixedType) {
|
|
560
|
+
renderColumnList = visibleColumn;
|
|
561
|
+
if (isOptimizeMode) {
|
|
562
|
+
renderColumnList = fixedColumn || [];
|
|
563
|
+
}
|
|
564
|
+
if (!isOptimizeMode) {
|
|
565
|
+
if (wrapperElem) {
|
|
566
|
+
wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
571
|
+
if (currScrollElem) {
|
|
572
|
+
currScrollElem.style.height = `${footerHeight}px`;
|
|
573
|
+
// 如果是固定列
|
|
574
|
+
if (fixedWrapperElem) {
|
|
575
|
+
if (wrapperElem) {
|
|
576
|
+
wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight - scrollbarHeight : tableHeight + headerHeight}px`;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (tableElem) {
|
|
581
|
+
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const colgroupElem = getRefElem(elemStore[`${name}-${layout}-colgroup`]);
|
|
585
|
+
if (colgroupElem) {
|
|
586
|
+
XEUtils.arrayEach(colgroupElem.children, (colElem) => {
|
|
587
|
+
const colid = colElem.getAttribute('name');
|
|
588
|
+
if (fullColumnIdData[colid]) {
|
|
589
|
+
const colRest = fullColumnIdData[colid];
|
|
590
|
+
const column = colRest.column;
|
|
591
|
+
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column;
|
|
592
|
+
let cellOverflow;
|
|
593
|
+
colElem.style.width = `${column.renderWidth}px`;
|
|
594
|
+
if (layout === 'header') {
|
|
595
|
+
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
|
|
596
|
+
}
|
|
597
|
+
else if (layout === 'footer') {
|
|
598
|
+
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow;
|
|
602
|
+
}
|
|
603
|
+
const showEllipsis = cellOverflow === 'ellipsis';
|
|
604
|
+
const showTitle = cellOverflow === 'title';
|
|
605
|
+
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
606
|
+
let hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
607
|
+
const listElem = getRefElem(elemStore[`${name}-${layout}-list`]);
|
|
608
|
+
// 纵向虚拟滚动不支持动态行高
|
|
609
|
+
if (scrollYLoad && !hasEllipsis) {
|
|
610
|
+
hasEllipsis = true;
|
|
611
|
+
}
|
|
612
|
+
if (listElem) {
|
|
613
|
+
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem) => {
|
|
614
|
+
const colspan = parseInt(elem.getAttribute('colspan') || 1);
|
|
615
|
+
const cellElem = elem.querySelector('.vxe-cell');
|
|
616
|
+
let colWidth = column.renderWidth;
|
|
617
|
+
if (cellElem) {
|
|
618
|
+
if (colspan > 1) {
|
|
619
|
+
const columnIndex = $xeTable.getColumnIndex(column);
|
|
620
|
+
for (let index = 1; index < colspan; index++) {
|
|
621
|
+
const nextColumn = $xeTable.getColumns(columnIndex + index);
|
|
622
|
+
if (nextColumn) {
|
|
623
|
+
colWidth += nextColumn.renderWidth;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : '';
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
if (currentRow) {
|
|
637
|
+
$xeTable.setCurrentRow(currentRow);
|
|
638
|
+
}
|
|
639
|
+
if (mouseConfig && mouseOpts.selected && editStore.selected.row && editStore.selected.column) {
|
|
640
|
+
$xeTable.addCellSelectedClass();
|
|
641
|
+
}
|
|
642
|
+
return $xeTable.$nextTick();
|
|
643
|
+
}
|
|
265
644
|
function computeRowHeight($xeTable) {
|
|
266
|
-
const tableHeader = $xeTable.$refs.
|
|
267
|
-
const tableBody = $xeTable.$refs.
|
|
645
|
+
const tableHeader = $xeTable.$refs.refTableHeader;
|
|
646
|
+
const tableBody = $xeTable.$refs.refTableBody;
|
|
268
647
|
const tableBodyElem = tableBody ? tableBody.$el : null;
|
|
269
|
-
const
|
|
270
|
-
const rowHeightMaps = $xeTable.computeRowHeightMaps;
|
|
648
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight;
|
|
271
649
|
let rowHeight = 0;
|
|
272
650
|
if (tableBodyElem) {
|
|
273
651
|
const tableHeaderElem = tableHeader ? tableHeader.$el : null;
|
|
@@ -281,21 +659,21 @@ function computeRowHeight($xeTable) {
|
|
|
281
659
|
}
|
|
282
660
|
}
|
|
283
661
|
if (!rowHeight) {
|
|
284
|
-
rowHeight =
|
|
662
|
+
rowHeight = defaultRowHeight;
|
|
285
663
|
}
|
|
286
664
|
// 最低支持 18px 行高
|
|
287
665
|
return Math.max(18, rowHeight);
|
|
288
666
|
}
|
|
289
667
|
function handleVirtualYVisible($xeTable) {
|
|
290
668
|
const props = $xeTable;
|
|
669
|
+
const reactData = $xeTable;
|
|
291
670
|
const internalData = $xeTable;
|
|
292
671
|
const { showOverflow } = props;
|
|
293
|
-
const {
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const { scrollTop, clientHeight } = tableBodyElem;
|
|
672
|
+
const { rowHeight } = reactData;
|
|
673
|
+
const { elemStore, afterFullData, fullAllDataRowIdData } = internalData;
|
|
674
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
675
|
+
if (bodyScrollElem) {
|
|
676
|
+
const { scrollTop, clientHeight } = bodyScrollElem;
|
|
299
677
|
const endHeight = scrollTop + clientHeight;
|
|
300
678
|
let toVisibleIndex = -1;
|
|
301
679
|
let offsetTop = 0;
|
|
@@ -321,9 +699,9 @@ function handleVirtualYVisible($xeTable) {
|
|
|
321
699
|
}
|
|
322
700
|
}
|
|
323
701
|
}
|
|
324
|
-
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(
|
|
702
|
+
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(6, visibleSize) };
|
|
325
703
|
}
|
|
326
|
-
return { toVisibleIndex: 0, visibleSize:
|
|
704
|
+
return { toVisibleIndex: 0, visibleSize: 6 };
|
|
327
705
|
}
|
|
328
706
|
function calculateMergerOffsetIndex(list, offsetItem, type) {
|
|
329
707
|
for (let mcIndex = 0, len = list.length; mcIndex < len; mcIndex++) {
|
|
@@ -457,18 +835,24 @@ function autoCellWidth($xeTable) {
|
|
|
457
835
|
const props = $xeTable;
|
|
458
836
|
const reactData = $xeTable;
|
|
459
837
|
const internalData = $xeTable;
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
const
|
|
838
|
+
const { elemStore } = internalData;
|
|
839
|
+
const scrollbarOpts = $xeTable.computeScrollbarOpts;
|
|
840
|
+
const tableBody = $xeTable.$refs.refTableBody;
|
|
463
841
|
const bodyElem = tableBody ? tableBody.$el : null;
|
|
464
|
-
const headerElem = tableHeader ? tableHeader.$el : null;
|
|
465
|
-
const footerElem = tableFooter ? tableFooter.$el : null;
|
|
466
842
|
if (!bodyElem) {
|
|
467
843
|
return;
|
|
468
844
|
}
|
|
845
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
846
|
+
if (!yHandleEl) {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
850
|
+
if (!xHandleEl) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
469
853
|
let tableWidth = 0;
|
|
470
854
|
const minCellWidth = 40; // 列宽最少限制 40px
|
|
471
|
-
const bodyWidth = bodyElem.clientWidth
|
|
855
|
+
const bodyWidth = bodyElem.clientWidth;
|
|
472
856
|
let remainWidth = bodyWidth;
|
|
473
857
|
let meanWidth = remainWidth / 100;
|
|
474
858
|
const { fit } = props;
|
|
@@ -537,16 +921,16 @@ function autoCellWidth($xeTable) {
|
|
|
537
921
|
});
|
|
538
922
|
if (fit) {
|
|
539
923
|
/**
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
924
|
+
* 偏移量算法
|
|
925
|
+
* 如果所有列足够放的情况下,从最后动态列开始分配
|
|
926
|
+
*/
|
|
543
927
|
const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList);
|
|
544
928
|
let dynamicSize = dynamicList.length - 1;
|
|
545
929
|
if (dynamicSize > 0) {
|
|
546
|
-
let
|
|
547
|
-
if (
|
|
548
|
-
while (
|
|
549
|
-
|
|
930
|
+
let i = bodyWidth - tableWidth;
|
|
931
|
+
if (i > 0) {
|
|
932
|
+
while (i > 0 && dynamicSize >= 0) {
|
|
933
|
+
i--;
|
|
550
934
|
dynamicList[dynamicSize--].renderWidth++;
|
|
551
935
|
}
|
|
552
936
|
tableWidth = bodyWidth;
|
|
@@ -554,41 +938,20 @@ function autoCellWidth($xeTable) {
|
|
|
554
938
|
}
|
|
555
939
|
}
|
|
556
940
|
const tableHeight = bodyElem.offsetHeight;
|
|
557
|
-
const overflowY =
|
|
558
|
-
|
|
559
|
-
if (overflowY) {
|
|
560
|
-
scrollbarWidth = Math.max(bodyElem.offsetWidth - bodyElem.clientWidth, 0);
|
|
561
|
-
}
|
|
562
|
-
reactData.scrollbarWidth = scrollbarWidth;
|
|
941
|
+
const overflowY = yHandleEl.scrollHeight > yHandleEl.clientHeight;
|
|
942
|
+
reactData.scrollbarWidth = overflowY ? Math.max(scrollbarOpts.width || 0, yHandleEl.offsetWidth - yHandleEl.clientWidth) : 0;
|
|
563
943
|
reactData.overflowY = overflowY;
|
|
564
944
|
internalData.tableWidth = tableWidth;
|
|
565
945
|
internalData.tableHeight = tableHeight;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
headerElem.scrollLeft = bodyElem.scrollLeft;
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
}
|
|
946
|
+
const headerTableElem = getRefElem(elemStore['main-header-table']);
|
|
947
|
+
const footerTableElem = getRefElem(elemStore['main-footer-table']);
|
|
948
|
+
const headerHeight = headerTableElem ? headerTableElem.clientHeight : 0;
|
|
949
|
+
const overflowX = tableWidth > bodyWidth;
|
|
950
|
+
const footerHeight = footerTableElem ? footerTableElem.clientHeight : 0;
|
|
951
|
+
reactData.scrollbarHeight = overflowX ? Math.max(scrollbarOpts.height || 0, xHandleEl.offsetHeight - xHandleEl.clientHeight) : 0;
|
|
576
952
|
internalData.headerHeight = headerHeight;
|
|
577
|
-
let overflowX = false;
|
|
578
|
-
let footerHeight = 0;
|
|
579
|
-
let scrollbarHeight = 0;
|
|
580
|
-
if (footerElem) {
|
|
581
|
-
footerHeight = footerElem.offsetHeight;
|
|
582
|
-
overflowX = tableWidth > footerElem.clientWidth;
|
|
583
|
-
scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0);
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
overflowX = tableWidth > bodyWidth;
|
|
587
|
-
scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0);
|
|
588
|
-
}
|
|
589
953
|
internalData.footerHeight = footerHeight;
|
|
590
954
|
reactData.overflowX = overflowX;
|
|
591
|
-
reactData.scrollbarHeight = scrollbarHeight;
|
|
592
955
|
updateHeight($xeTable);
|
|
593
956
|
reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight());
|
|
594
957
|
if (overflowX) {
|
|
@@ -802,9 +1165,9 @@ function showDropTip($xeTable, evnt, trEl, thEl, showLine, dragPos) {
|
|
|
802
1165
|
const cdLineEl = $xeTable.$refs.refDragColLineElem;
|
|
803
1166
|
if (cdLineEl) {
|
|
804
1167
|
if (showLine) {
|
|
805
|
-
const leftContainerElem = $xeTable.$refs.
|
|
1168
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer;
|
|
806
1169
|
const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
|
|
807
|
-
const rightContainerElem = $xeTable.$refs.
|
|
1170
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer;
|
|
808
1171
|
const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
|
|
809
1172
|
const thRect = thEl.getBoundingClientRect();
|
|
810
1173
|
let thWidth = thEl.clientWidth;
|
|
@@ -879,11 +1242,14 @@ function computeScrollLoad($xeTable) {
|
|
|
879
1242
|
const sXOpts = $xeTable.computeSXOpts;
|
|
880
1243
|
// 计算 X 逻辑
|
|
881
1244
|
if (scrollXLoad) {
|
|
882
|
-
const { visibleSize: visibleXSize } = handleVirtualXVisible($xeTable);
|
|
883
|
-
const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) :
|
|
1245
|
+
const { toVisibleIndex: toXVisibleIndex, visibleSize: visibleXSize } = handleVirtualXVisible($xeTable);
|
|
1246
|
+
const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : 0);
|
|
1247
|
+
scrollXStore.preloadSize = 4;
|
|
884
1248
|
scrollXStore.offsetSize = offsetXSize;
|
|
885
1249
|
scrollXStore.visibleSize = visibleXSize;
|
|
886
1250
|
scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex);
|
|
1251
|
+
scrollXStore.visibleStartIndex = Math.max(scrollXStore.startIndex, toXVisibleIndex);
|
|
1252
|
+
scrollXStore.visibleEndIndex = Math.min(scrollXStore.endIndex, toXVisibleIndex + visibleXSize);
|
|
887
1253
|
$xeTable.updateScrollXData().then(() => {
|
|
888
1254
|
loadScrollXData($xeTable);
|
|
889
1255
|
});
|
|
@@ -896,12 +1262,15 @@ function computeScrollLoad($xeTable) {
|
|
|
896
1262
|
const rowHeight = computeRowHeight($xeTable);
|
|
897
1263
|
scrollYStore.rowHeight = rowHeight;
|
|
898
1264
|
reactData.rowHeight = rowHeight;
|
|
899
|
-
const { visibleSize: visibleYSize } = handleVirtualYVisible($xeTable);
|
|
1265
|
+
const { toVisibleIndex: toYVisibleIndex, visibleSize: visibleYSize } = handleVirtualYVisible($xeTable);
|
|
900
1266
|
if (scrollYLoad) {
|
|
901
|
-
const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) :
|
|
1267
|
+
const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : 0);
|
|
1268
|
+
scrollYStore.preloadSize = 2;
|
|
902
1269
|
scrollYStore.offsetSize = offsetYSize;
|
|
903
1270
|
scrollYStore.visibleSize = visibleYSize;
|
|
904
1271
|
scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex);
|
|
1272
|
+
scrollYStore.visibleStartIndex = Math.max(scrollYStore.startIndex, toYVisibleIndex);
|
|
1273
|
+
scrollYStore.visibleEndIndex = Math.min(scrollYStore.endIndex, toYVisibleIndex + visibleYSize);
|
|
905
1274
|
$xeTable.updateScrollYData().then(() => {
|
|
906
1275
|
loadScrollYData($xeTable);
|
|
907
1276
|
});
|
|
@@ -910,7 +1279,7 @@ function computeScrollLoad($xeTable) {
|
|
|
910
1279
|
$xeTable.updateScrollYSpace();
|
|
911
1280
|
}
|
|
912
1281
|
$xeTable.$nextTick(() => {
|
|
913
|
-
$xeTable
|
|
1282
|
+
updateStyle($xeTable);
|
|
914
1283
|
});
|
|
915
1284
|
});
|
|
916
1285
|
}
|
|
@@ -933,17 +1302,42 @@ function handleRecalculateLayout($xeTable, reFull) {
|
|
|
933
1302
|
}
|
|
934
1303
|
});
|
|
935
1304
|
}
|
|
1305
|
+
function handleTableColumn($xeTable) {
|
|
1306
|
+
const reactData = $xeTable;
|
|
1307
|
+
const internalData = $xeTable;
|
|
1308
|
+
const { scrollXLoad } = reactData;
|
|
1309
|
+
const { visibleColumn, scrollXStore, fullColumnIdData } = internalData;
|
|
1310
|
+
const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
|
|
1311
|
+
tableColumn.forEach((column, $index) => {
|
|
1312
|
+
const colid = column.id;
|
|
1313
|
+
const colRest = fullColumnIdData[colid];
|
|
1314
|
+
if (colRest) {
|
|
1315
|
+
colRest.$index = $index;
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
reactData.tableColumn = tableColumn;
|
|
1319
|
+
}
|
|
1320
|
+
function handleUpdateColumn($xeTable) {
|
|
1321
|
+
const internalData = $xeTable;
|
|
1322
|
+
const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber');
|
|
1323
|
+
internalData.collectColumn = columnList;
|
|
1324
|
+
const tableFullColumn = getColumnList(columnList);
|
|
1325
|
+
internalData.tableFullColumn = tableFullColumn;
|
|
1326
|
+
cacheColumnMap($xeTable);
|
|
1327
|
+
}
|
|
936
1328
|
function loadScrollXData($xeTable) {
|
|
937
1329
|
const reactData = $xeTable;
|
|
938
1330
|
const internalData = $xeTable;
|
|
939
1331
|
const { mergeList, mergeFooterList } = reactData;
|
|
940
1332
|
const { scrollXStore } = internalData;
|
|
941
|
-
const { startIndex, endIndex, offsetSize } = scrollXStore;
|
|
1333
|
+
const { preloadSize, startIndex, endIndex, offsetSize } = scrollXStore;
|
|
942
1334
|
const { toVisibleIndex, visibleSize } = handleVirtualXVisible($xeTable);
|
|
943
1335
|
const offsetItem = {
|
|
944
|
-
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
|
|
945
|
-
endIndex: toVisibleIndex + visibleSize + offsetSize
|
|
1336
|
+
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
|
|
1337
|
+
endIndex: toVisibleIndex + visibleSize + offsetSize + preloadSize
|
|
946
1338
|
};
|
|
1339
|
+
scrollXStore.visibleStartIndex = toVisibleIndex;
|
|
1340
|
+
scrollXStore.visibleEndIndex = toVisibleIndex + visibleSize;
|
|
947
1341
|
calculateMergerOffsetIndex(mergeList.concat(mergeFooterList), offsetItem, 'col');
|
|
948
1342
|
const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem;
|
|
949
1343
|
if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
|
|
@@ -955,6 +1349,198 @@ function loadScrollXData($xeTable) {
|
|
|
955
1349
|
}
|
|
956
1350
|
$xeTable.closeTooltip();
|
|
957
1351
|
}
|
|
1352
|
+
// 获取所有的列,排除分组
|
|
1353
|
+
function getColumnList(columns) {
|
|
1354
|
+
const result = [];
|
|
1355
|
+
columns.forEach((column) => {
|
|
1356
|
+
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
|
|
1357
|
+
});
|
|
1358
|
+
return result;
|
|
1359
|
+
}
|
|
1360
|
+
function parseColumns($xeTable, isReset) {
|
|
1361
|
+
const props = $xeTable;
|
|
1362
|
+
const reactData = $xeTable;
|
|
1363
|
+
const internalData = $xeTable;
|
|
1364
|
+
const { showOverflow } = props;
|
|
1365
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
1366
|
+
const leftList = [];
|
|
1367
|
+
const centerList = [];
|
|
1368
|
+
const rightList = [];
|
|
1369
|
+
const { isGroup, columnStore } = reactData;
|
|
1370
|
+
const sXOpts = $xeTable.computeSXOpts;
|
|
1371
|
+
const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData;
|
|
1372
|
+
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
1373
|
+
if (isGroup) {
|
|
1374
|
+
const leftGroupList = [];
|
|
1375
|
+
const centerGroupList = [];
|
|
1376
|
+
const rightGroupList = [];
|
|
1377
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
1378
|
+
const isColGroup = hasChildrenList(column);
|
|
1379
|
+
// 如果是分组,必须按组设置固定列,不允许给子列设置固定
|
|
1380
|
+
if (parentColumn && parentColumn.fixed) {
|
|
1381
|
+
column.fixed = parentColumn.fixed;
|
|
1382
|
+
}
|
|
1383
|
+
if (parentColumn && column.fixed !== parentColumn.fixed) {
|
|
1384
|
+
errLog('vxe.error.groupFixed');
|
|
1385
|
+
}
|
|
1386
|
+
if (isColGroup) {
|
|
1387
|
+
column.visible = !!XEUtils.findTree(column.children, (subColumn) => hasChildrenList(subColumn) ? false : subColumn.visible);
|
|
1388
|
+
}
|
|
1389
|
+
else if (column.visible) {
|
|
1390
|
+
if (column.fixed === 'left') {
|
|
1391
|
+
leftList.push(column);
|
|
1392
|
+
}
|
|
1393
|
+
else if (column.fixed === 'right') {
|
|
1394
|
+
rightList.push(column);
|
|
1395
|
+
}
|
|
1396
|
+
else {
|
|
1397
|
+
centerList.push(column);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
collectColumn.forEach((column) => {
|
|
1402
|
+
if (column.visible) {
|
|
1403
|
+
if (column.fixed === 'left') {
|
|
1404
|
+
leftGroupList.push(column);
|
|
1405
|
+
}
|
|
1406
|
+
else if (column.fixed === 'right') {
|
|
1407
|
+
rightGroupList.push(column);
|
|
1408
|
+
}
|
|
1409
|
+
else {
|
|
1410
|
+
centerGroupList.push(column);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
reactData.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
|
|
1415
|
+
}
|
|
1416
|
+
else {
|
|
1417
|
+
// 重新分配列
|
|
1418
|
+
tableFullColumn.forEach((column) => {
|
|
1419
|
+
if (column.visible) {
|
|
1420
|
+
if (column.fixed === 'left') {
|
|
1421
|
+
leftList.push(column);
|
|
1422
|
+
}
|
|
1423
|
+
else if (column.fixed === 'right') {
|
|
1424
|
+
rightList.push(column);
|
|
1425
|
+
}
|
|
1426
|
+
else {
|
|
1427
|
+
centerList.push(column);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
const visibleColumn = leftList.concat(centerList).concat(rightList);
|
|
1433
|
+
// 如果gt为0,则总是启用
|
|
1434
|
+
const scrollXLoad = !!sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt < tableFullColumn.length);
|
|
1435
|
+
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
|
|
1436
|
+
Object.assign(columnStore, { leftList, centerList, rightList });
|
|
1437
|
+
if (scrollXLoad) {
|
|
1438
|
+
if (showOverflow) {
|
|
1439
|
+
if (!rowOpts.height) {
|
|
1440
|
+
const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false);
|
|
1441
|
+
if (errColumn) {
|
|
1442
|
+
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1447
|
+
// if (props.showHeader && !props.showHeaderOverflow) {
|
|
1448
|
+
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
1449
|
+
// }
|
|
1450
|
+
// if (props.showFooter && !props.showFooterOverflow) {
|
|
1451
|
+
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
1452
|
+
// }
|
|
1453
|
+
if (props.spanMethod) {
|
|
1454
|
+
warnLog('vxe.error.scrollErrProp', ['span-method']);
|
|
1455
|
+
}
|
|
1456
|
+
if (props.footerSpanMethod) {
|
|
1457
|
+
warnLog('vxe.error.scrollErrProp', ['footer-span-method']);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (isReset) {
|
|
1461
|
+
const { visibleSize } = handleVirtualXVisible($xeTable);
|
|
1462
|
+
scrollXStore.startIndex = 0;
|
|
1463
|
+
scrollXStore.endIndex = visibleSize;
|
|
1464
|
+
scrollXStore.visibleSize = visibleSize;
|
|
1465
|
+
scrollXStore.visibleStartIndex = 0;
|
|
1466
|
+
scrollXStore.visibleEndIndex = visibleSize;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
// 如果列被显示/隐藏,则清除合并状态
|
|
1470
|
+
// 如果列被设置为固定,则清除合并状态
|
|
1471
|
+
if (visibleColumn.length !== internalData.visibleColumn.length || !internalData.visibleColumn.every((column, index) => column === visibleColumn[index])) {
|
|
1472
|
+
$xeTable.clearMergeCells();
|
|
1473
|
+
$xeTable.clearMergeFooterItems();
|
|
1474
|
+
}
|
|
1475
|
+
reactData.scrollXLoad = scrollXLoad;
|
|
1476
|
+
visibleColumn.forEach((column, index) => {
|
|
1477
|
+
const colid = column.id;
|
|
1478
|
+
const colRest = fullColumnIdData[colid];
|
|
1479
|
+
if (colRest) {
|
|
1480
|
+
colRest._index = index;
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
internalData.visibleColumn = visibleColumn;
|
|
1484
|
+
handleTableColumn($xeTable);
|
|
1485
|
+
if (isReset) {
|
|
1486
|
+
return $xeTable.updateFooter().then(() => {
|
|
1487
|
+
return $xeTable.recalculate();
|
|
1488
|
+
}).then(() => {
|
|
1489
|
+
$xeTable.updateCellAreas();
|
|
1490
|
+
return $xeTable.recalculate();
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
return $xeTable.updateFooter();
|
|
1494
|
+
}
|
|
1495
|
+
function initColumnSort($xeTable) {
|
|
1496
|
+
const internalData = $xeTable;
|
|
1497
|
+
const { collectColumn } = internalData;
|
|
1498
|
+
collectColumn.forEach((column, index) => {
|
|
1499
|
+
const sortIndex = index + 1;
|
|
1500
|
+
column.sortNumber = sortIndex;
|
|
1501
|
+
column.renderSortNumber = sortIndex;
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
function handleColumn($xeTable, collectColumn) {
|
|
1505
|
+
const $xeToolbar = $xeTable.$refs.$xeToolbar;
|
|
1506
|
+
const reactData = $xeTable;
|
|
1507
|
+
const internalData = $xeTable;
|
|
1508
|
+
internalData.collectColumn = collectColumn;
|
|
1509
|
+
const tableFullColumn = getColumnList(collectColumn);
|
|
1510
|
+
internalData.tableFullColumn = tableFullColumn;
|
|
1511
|
+
reactData.isLoading = true;
|
|
1512
|
+
reactData.isDragColMove = false;
|
|
1513
|
+
initColumnSort($xeTable);
|
|
1514
|
+
return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
|
|
1515
|
+
reactData.isLoading = false;
|
|
1516
|
+
cacheColumnMap($xeTable);
|
|
1517
|
+
parseColumns($xeTable, true).then(() => {
|
|
1518
|
+
if (reactData.scrollXLoad) {
|
|
1519
|
+
loadScrollXData($xeTable);
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
$xeTable.clearMergeCells();
|
|
1523
|
+
$xeTable.clearMergeFooterItems();
|
|
1524
|
+
$xeTable.handleTableData(true);
|
|
1525
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1526
|
+
if ((reactData.scrollXLoad || reactData.scrollYLoad) && reactData.expandColumn) {
|
|
1527
|
+
warnLog('vxe.error.scrollErrProp', ['column.type=expand']);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
return $xeTable.$nextTick().then(() => {
|
|
1531
|
+
if ($xeToolbar) {
|
|
1532
|
+
$xeToolbar.syncUpdate({
|
|
1533
|
+
collectColumn: internalData.collectColumn,
|
|
1534
|
+
$table: $xeTable
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
if ($xeTable.handleUpdateCustomColumn) {
|
|
1538
|
+
$xeTable.handleUpdateCustomColumn();
|
|
1539
|
+
}
|
|
1540
|
+
return $xeTable.recalculate();
|
|
1541
|
+
});
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
958
1544
|
/**
|
|
959
1545
|
* 纵向 Y 可视渲染处理
|
|
960
1546
|
*/
|
|
@@ -964,14 +1550,16 @@ function loadScrollYData($xeTable) {
|
|
|
964
1550
|
const internalData = $xeTable;
|
|
965
1551
|
const { showOverflow } = props;
|
|
966
1552
|
const { mergeList } = reactData;
|
|
967
|
-
const {
|
|
968
|
-
const { startIndex, endIndex, offsetSize } = scrollYStore;
|
|
969
|
-
const autoOffsetYSize = showOverflow ? offsetSize : offsetSize +
|
|
1553
|
+
const { scrollYStore } = internalData;
|
|
1554
|
+
const { preloadSize, startIndex, endIndex, offsetSize } = scrollYStore;
|
|
1555
|
+
const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + 1;
|
|
970
1556
|
const { toVisibleIndex, visibleSize } = handleVirtualYVisible($xeTable);
|
|
971
1557
|
const offsetItem = {
|
|
972
|
-
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
|
|
973
|
-
endIndex: toVisibleIndex + visibleSize + autoOffsetYSize
|
|
1558
|
+
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
|
|
1559
|
+
endIndex: toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize
|
|
974
1560
|
};
|
|
1561
|
+
scrollYStore.visibleStartIndex = toVisibleIndex;
|
|
1562
|
+
scrollYStore.visibleEndIndex = toVisibleIndex + visibleSize;
|
|
975
1563
|
calculateMergerOffsetIndex(mergeList, offsetItem, 'row');
|
|
976
1564
|
const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem;
|
|
977
1565
|
if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
|
|
@@ -994,16 +1582,20 @@ function checkLastSyncScroll($xeTable, isRollX, isRollY) {
|
|
|
994
1582
|
internalData.lcsRunTime = Date.now();
|
|
995
1583
|
internalData.lcsTimeout = undefined;
|
|
996
1584
|
internalData.inVirtualScroll = false;
|
|
1585
|
+
internalData.inWheelScroll = false;
|
|
1586
|
+
internalData.inHeaderScroll = false;
|
|
997
1587
|
internalData.inBodyScroll = false;
|
|
998
1588
|
internalData.inFooterScroll = false;
|
|
999
|
-
internalData.
|
|
1589
|
+
internalData.scrollRenderType = '';
|
|
1000
1590
|
if (isRollX && scrollXLoad) {
|
|
1001
1591
|
$xeTable.updateScrollXData().then(() => {
|
|
1592
|
+
calcCellHeight($xeTable);
|
|
1002
1593
|
loadScrollXData($xeTable);
|
|
1003
1594
|
});
|
|
1004
1595
|
}
|
|
1005
1596
|
if (isRollY && scrollYLoad) {
|
|
1006
1597
|
$xeTable.updateScrollYData().then(() => {
|
|
1598
|
+
calcCellHeight($xeTable);
|
|
1007
1599
|
loadScrollYData($xeTable);
|
|
1008
1600
|
});
|
|
1009
1601
|
}
|
|
@@ -1271,7 +1863,7 @@ const Methods = {
|
|
|
1271
1863
|
this.updateFooter();
|
|
1272
1864
|
return this.$nextTick().then(() => {
|
|
1273
1865
|
updateHeight($xeTable);
|
|
1274
|
-
|
|
1866
|
+
updateStyle($xeTable);
|
|
1275
1867
|
}).then(() => {
|
|
1276
1868
|
computeScrollLoad($xeTable);
|
|
1277
1869
|
}).then(() => {
|
|
@@ -1296,10 +1888,18 @@ const Methods = {
|
|
|
1296
1888
|
}
|
|
1297
1889
|
// 是否变更虚拟滚动
|
|
1298
1890
|
if (oldScrollYLoad === sYLoad) {
|
|
1299
|
-
restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
|
|
1891
|
+
restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
|
|
1892
|
+
.then(() => {
|
|
1893
|
+
resolve();
|
|
1894
|
+
});
|
|
1300
1895
|
}
|
|
1301
1896
|
else {
|
|
1302
|
-
setTimeout(() =>
|
|
1897
|
+
setTimeout(() => {
|
|
1898
|
+
restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
|
|
1899
|
+
.then(() => {
|
|
1900
|
+
resolve();
|
|
1901
|
+
});
|
|
1902
|
+
});
|
|
1303
1903
|
}
|
|
1304
1904
|
});
|
|
1305
1905
|
});
|
|
@@ -1387,8 +1987,9 @@ const Methods = {
|
|
|
1387
1987
|
* @param {ColumnInfo} columns 列配置
|
|
1388
1988
|
*/
|
|
1389
1989
|
loadColumn(columns) {
|
|
1990
|
+
const $xeTable = this;
|
|
1390
1991
|
const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn(this, column), { children: 'children' });
|
|
1391
|
-
return
|
|
1992
|
+
return handleColumn($xeTable, collectColumn);
|
|
1392
1993
|
},
|
|
1393
1994
|
/**
|
|
1394
1995
|
* 加载列配置并恢复到初始状态
|
|
@@ -1400,51 +2001,9 @@ const Methods = {
|
|
|
1400
2001
|
return this.loadColumn(columns);
|
|
1401
2002
|
});
|
|
1402
2003
|
},
|
|
1403
|
-
initColumnSort() {
|
|
1404
|
-
const { collectColumn } = this;
|
|
1405
|
-
collectColumn.forEach((column, index) => {
|
|
1406
|
-
const sortIndex = index + 1;
|
|
1407
|
-
column.sortNumber = sortIndex;
|
|
1408
|
-
column.renderSortNumber = sortIndex;
|
|
1409
|
-
});
|
|
1410
|
-
},
|
|
1411
2004
|
handleColumn(collectColumn) {
|
|
1412
2005
|
const $xeTable = this;
|
|
1413
|
-
|
|
1414
|
-
const tableFullColumn = getColumnList(collectColumn);
|
|
1415
|
-
this.tableFullColumn = tableFullColumn;
|
|
1416
|
-
this._isLoading = true;
|
|
1417
|
-
this.isDragColMove = false;
|
|
1418
|
-
this.initColumnSort();
|
|
1419
|
-
return Promise.resolve(this.restoreCustomStorage()).then(() => {
|
|
1420
|
-
this._isLoading = false;
|
|
1421
|
-
cacheColumnMap($xeTable);
|
|
1422
|
-
this.parseColumns(true).then(() => {
|
|
1423
|
-
if (this.scrollXLoad) {
|
|
1424
|
-
loadScrollXData($xeTable);
|
|
1425
|
-
}
|
|
1426
|
-
});
|
|
1427
|
-
this.clearMergeCells();
|
|
1428
|
-
this.clearMergeFooterItems();
|
|
1429
|
-
this.handleTableData(true);
|
|
1430
|
-
if (process.env.NODE_ENV === 'development') {
|
|
1431
|
-
if ((this.scrollXLoad || this.scrollYLoad) && this.expandColumn) {
|
|
1432
|
-
warnLog('vxe.error.scrollErrProp', ['column.type=expand']);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
return this.$nextTick().then(() => {
|
|
1436
|
-
if (this.$toolbar) {
|
|
1437
|
-
this.$toolbar.syncUpdate({
|
|
1438
|
-
collectColumn: this.collectColumn,
|
|
1439
|
-
$table: this
|
|
1440
|
-
});
|
|
1441
|
-
}
|
|
1442
|
-
if ($xeTable.handleUpdateCustomColumn) {
|
|
1443
|
-
$xeTable.handleUpdateCustomColumn();
|
|
1444
|
-
}
|
|
1445
|
-
return this.recalculate();
|
|
1446
|
-
});
|
|
1447
|
-
});
|
|
2006
|
+
return handleColumn($xeTable, collectColumn);
|
|
1448
2007
|
},
|
|
1449
2008
|
/**
|
|
1450
2009
|
* 更新数据行的 Map
|
|
@@ -1909,7 +2468,7 @@ const Methods = {
|
|
|
1909
2468
|
const rowid = getRowid(this, row);
|
|
1910
2469
|
let bodyElem = null;
|
|
1911
2470
|
if (column) {
|
|
1912
|
-
bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.
|
|
2471
|
+
bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.refTableBody;
|
|
1913
2472
|
}
|
|
1914
2473
|
if (bodyElem && bodyElem.$el) {
|
|
1915
2474
|
return bodyElem.$el.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`);
|
|
@@ -2550,8 +3109,8 @@ const Methods = {
|
|
|
2550
3109
|
const colWidth = XEUtils.toInteger(width);
|
|
2551
3110
|
let rdWidth = colWidth;
|
|
2552
3111
|
if (isScale(width)) {
|
|
2553
|
-
const
|
|
2554
|
-
const bodyElem =
|
|
3112
|
+
const refTableBody = $xeTable.$refs.refTableBody;
|
|
3113
|
+
const bodyElem = refTableBody ? refTableBody.$el : null;
|
|
2555
3114
|
const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
|
|
2556
3115
|
rdWidth = Math.floor(colWidth * bodyWidth);
|
|
2557
3116
|
}
|
|
@@ -2797,150 +3356,16 @@ const Methods = {
|
|
|
2797
3356
|
* 刷新列配置
|
|
2798
3357
|
*/
|
|
2799
3358
|
refreshColumn(initSort) {
|
|
3359
|
+
const $xeTable = this;
|
|
2800
3360
|
if (initSort) {
|
|
2801
|
-
|
|
3361
|
+
handleUpdateColumn($xeTable);
|
|
2802
3362
|
}
|
|
2803
|
-
return
|
|
3363
|
+
return parseColumns($xeTable, true).then(() => {
|
|
2804
3364
|
return this.refreshScroll();
|
|
2805
3365
|
}).then(() => {
|
|
2806
3366
|
return this.recalculate();
|
|
2807
3367
|
});
|
|
2808
3368
|
},
|
|
2809
|
-
/**
|
|
2810
|
-
* 刷新列信息
|
|
2811
|
-
* 将固定的列左边、右边分别靠边
|
|
2812
|
-
*/
|
|
2813
|
-
parseColumns(isReset) {
|
|
2814
|
-
const $xeTable = this;
|
|
2815
|
-
const props = $xeTable;
|
|
2816
|
-
const internalData = $xeTable;
|
|
2817
|
-
const { showOverflow } = props;
|
|
2818
|
-
const rowOpts = $xeTable.computeRowOpts;
|
|
2819
|
-
const leftList = [];
|
|
2820
|
-
const centerList = [];
|
|
2821
|
-
const rightList = [];
|
|
2822
|
-
const { collectColumn, tableFullColumn, isGroup, columnStore, sXOpts, scrollXStore, fullColumnIdData } = this;
|
|
2823
|
-
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
2824
|
-
if (isGroup) {
|
|
2825
|
-
const leftGroupList = [];
|
|
2826
|
-
const centerGroupList = [];
|
|
2827
|
-
const rightGroupList = [];
|
|
2828
|
-
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
2829
|
-
const isColGroup = hasChildrenList(column);
|
|
2830
|
-
// 如果是分组,必须按组设置固定列,不允许给子列设置固定
|
|
2831
|
-
if (parentColumn && parentColumn.fixed) {
|
|
2832
|
-
column.fixed = parentColumn.fixed;
|
|
2833
|
-
}
|
|
2834
|
-
if (parentColumn && column.fixed !== parentColumn.fixed) {
|
|
2835
|
-
errLog('vxe.error.groupFixed');
|
|
2836
|
-
}
|
|
2837
|
-
if (isColGroup) {
|
|
2838
|
-
column.visible = !!XEUtils.findTree(column.children, (subColumn) => hasChildrenList(subColumn) ? null : subColumn.visible);
|
|
2839
|
-
}
|
|
2840
|
-
else if (column.visible) {
|
|
2841
|
-
if (column.fixed === 'left') {
|
|
2842
|
-
leftList.push(column);
|
|
2843
|
-
}
|
|
2844
|
-
else if (column.fixed === 'right') {
|
|
2845
|
-
rightList.push(column);
|
|
2846
|
-
}
|
|
2847
|
-
else {
|
|
2848
|
-
centerList.push(column);
|
|
2849
|
-
}
|
|
2850
|
-
}
|
|
2851
|
-
});
|
|
2852
|
-
collectColumn.forEach((column) => {
|
|
2853
|
-
if (column.visible) {
|
|
2854
|
-
if (column.fixed === 'left') {
|
|
2855
|
-
leftGroupList.push(column);
|
|
2856
|
-
}
|
|
2857
|
-
else if (column.fixed === 'right') {
|
|
2858
|
-
rightGroupList.push(column);
|
|
2859
|
-
}
|
|
2860
|
-
else {
|
|
2861
|
-
centerGroupList.push(column);
|
|
2862
|
-
}
|
|
2863
|
-
}
|
|
2864
|
-
});
|
|
2865
|
-
this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
|
|
2866
|
-
}
|
|
2867
|
-
else {
|
|
2868
|
-
// 重新分配列
|
|
2869
|
-
tableFullColumn.forEach((column) => {
|
|
2870
|
-
if (column.visible) {
|
|
2871
|
-
if (column.fixed === 'left') {
|
|
2872
|
-
leftList.push(column);
|
|
2873
|
-
}
|
|
2874
|
-
else if (column.fixed === 'right') {
|
|
2875
|
-
rightList.push(column);
|
|
2876
|
-
}
|
|
2877
|
-
else {
|
|
2878
|
-
centerList.push(column);
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
});
|
|
2882
|
-
}
|
|
2883
|
-
const visibleColumn = leftList.concat(centerList).concat(rightList);
|
|
2884
|
-
// 如果gt为0,则总是启用
|
|
2885
|
-
const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length);
|
|
2886
|
-
this.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
|
|
2887
|
-
Object.assign(columnStore, { leftList, centerList, rightList });
|
|
2888
|
-
if (scrollXLoad) {
|
|
2889
|
-
if (showOverflow) {
|
|
2890
|
-
if (!rowOpts.height) {
|
|
2891
|
-
const errColumn = internalData.tableFullColumn.find((column) => column.showOverflow === false);
|
|
2892
|
-
if (errColumn) {
|
|
2893
|
-
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
if (process.env.NODE_ENV === 'development') {
|
|
2898
|
-
// if (this.showHeader && !this.showHeaderOverflow) {
|
|
2899
|
-
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
2900
|
-
// }
|
|
2901
|
-
// if (this.showFooter && !this.showFooterOverflow) {
|
|
2902
|
-
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
2903
|
-
// }
|
|
2904
|
-
if (this.spanMethod) {
|
|
2905
|
-
warnLog('vxe.error.scrollErrProp', ['span-method']);
|
|
2906
|
-
}
|
|
2907
|
-
if (this.footerSpanMethod) {
|
|
2908
|
-
warnLog('vxe.error.scrollErrProp', ['footer-span-method']);
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
if (isReset) {
|
|
2912
|
-
const { visibleSize } = handleVirtualXVisible(this);
|
|
2913
|
-
scrollXStore.startIndex = 0;
|
|
2914
|
-
scrollXStore.endIndex = visibleSize;
|
|
2915
|
-
scrollXStore.visibleSize = visibleSize;
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
// 如果列被显示/隐藏,则清除合并状态
|
|
2919
|
-
// 如果列被设置为固定,则清除合并状态
|
|
2920
|
-
if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column, index) => column === visibleColumn[index])) {
|
|
2921
|
-
this.clearMergeCells();
|
|
2922
|
-
this.clearMergeFooterItems();
|
|
2923
|
-
}
|
|
2924
|
-
this.scrollXLoad = scrollXLoad;
|
|
2925
|
-
visibleColumn.forEach((column, index) => {
|
|
2926
|
-
const colid = column.id;
|
|
2927
|
-
const colRest = fullColumnIdData[colid];
|
|
2928
|
-
if (colRest) {
|
|
2929
|
-
colRest._index = index;
|
|
2930
|
-
}
|
|
2931
|
-
});
|
|
2932
|
-
this.visibleColumn = visibleColumn;
|
|
2933
|
-
this.handleTableColumn();
|
|
2934
|
-
if (isReset) {
|
|
2935
|
-
return this.updateFooter().then(() => {
|
|
2936
|
-
return this.recalculate();
|
|
2937
|
-
}).then(() => {
|
|
2938
|
-
this.updateCellAreas();
|
|
2939
|
-
return this.recalculate();
|
|
2940
|
-
});
|
|
2941
|
-
}
|
|
2942
|
-
return this.updateFooter();
|
|
2943
|
-
},
|
|
2944
3369
|
/**
|
|
2945
3370
|
* 指定列宽的列进行拆分
|
|
2946
3371
|
*/
|
|
@@ -3019,377 +3444,115 @@ const Methods = {
|
|
|
3019
3444
|
$xeTable.saveCustomStore('update:visible');
|
|
3020
3445
|
$xeTable.updateCellAreas();
|
|
3021
3446
|
$xeTable.dispatchEvent('resizable-change', Object.assign(Object.assign({}, params), { resizeWidth }), evnt);
|
|
3022
|
-
setTimeout(() => $xeTable.recalculate(true), 300);
|
|
3023
|
-
});
|
|
3024
|
-
}
|
|
3025
|
-
},
|
|
3026
|
-
/**
|
|
3027
|
-
* 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
|
|
3028
|
-
*/
|
|
3029
|
-
refreshScroll() {
|
|
3030
|
-
const
|
|
3031
|
-
const
|
|
3032
|
-
const {
|
|
3033
|
-
const
|
|
3034
|
-
const
|
|
3035
|
-
const
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
internalData.rceTimeout = undefined;
|
|
3085
|
-
handleRecalculateLayout($xeTable, !!reFull);
|
|
3086
|
-
}, refreshDelay);
|
|
3087
|
-
});
|
|
3088
|
-
},
|
|
3089
|
-
updateStyle() {
|
|
3090
|
-
const $xeTable = this;
|
|
3091
|
-
let { $refs, isGroup, fullColumnIdData, tableColumn, customHeight, customMinHeight, customMaxHeight, border, headerHeight, showFooter, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, footerHeight, tableHeight, tableWidth, scrollbarHeight, scrollbarWidth, scrollXLoad, scrollYLoad, overflowX, cellOffsetWidth, columnStore, elemStore, editStore, currentRow, mouseConfig, spanMethod, expandColumn, footerSpanMethod, isAllOverflow, visibleColumn } = $xeTable;
|
|
3092
|
-
const containerList = ['main', 'left', 'right'];
|
|
3093
|
-
const emptyPlaceholderElem = $refs.emptyPlaceholder;
|
|
3094
|
-
const bodyWrapperElem = elemStore['main-body-wrapper'];
|
|
3095
|
-
if (emptyPlaceholderElem) {
|
|
3096
|
-
emptyPlaceholderElem.style.top = `${headerHeight}px`;
|
|
3097
|
-
emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
|
|
3098
|
-
}
|
|
3099
|
-
if (customHeight > 0) {
|
|
3100
|
-
if (showFooter) {
|
|
3101
|
-
customHeight += scrollbarHeight;
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
|
|
3105
|
-
if (scrollXVirtualEl) {
|
|
3106
|
-
scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
|
|
3107
|
-
}
|
|
3108
|
-
const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
|
|
3109
|
-
if (scrollYVirtualEl) {
|
|
3110
|
-
let bodyHeight = 0;
|
|
3111
|
-
let bodyMaxHeight = 0;
|
|
3112
|
-
const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
|
|
3113
|
-
if (customMaxHeight) {
|
|
3114
|
-
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
|
|
3115
|
-
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
|
|
3116
|
-
}
|
|
3117
|
-
if (customHeight) {
|
|
3118
|
-
bodyHeight = customHeight - headerHeight - footerHeight;
|
|
3119
|
-
if (bodyMaxHeight) {
|
|
3120
|
-
bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
|
|
3121
|
-
}
|
|
3122
|
-
bodyHeight = Math.max(bodyMinHeight, bodyHeight);
|
|
3123
|
-
}
|
|
3124
|
-
scrollYVirtualEl.style.top = `${headerHeight}px`;
|
|
3125
|
-
scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
|
|
3126
|
-
scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`;
|
|
3127
|
-
}
|
|
3128
|
-
containerList.forEach((name, index) => {
|
|
3129
|
-
const fixedType = index > 0 ? name : '';
|
|
3130
|
-
const layoutList = ['header', 'body', 'footer'];
|
|
3131
|
-
const fixedColumn = columnStore[`${fixedType}List`];
|
|
3132
|
-
const fixedWrapperElem = $refs[`${fixedType}Container`];
|
|
3133
|
-
layoutList.forEach(layout => {
|
|
3134
|
-
const wrapperElem = elemStore[`${name}-${layout}-wrapper`];
|
|
3135
|
-
const tableElem = elemStore[`${name}-${layout}-table`];
|
|
3136
|
-
if (layout === 'header') {
|
|
3137
|
-
// 表头体样式处理
|
|
3138
|
-
// 横向滚动渲染
|
|
3139
|
-
let tWidth = tableWidth;
|
|
3140
|
-
let renderColumnList = tableColumn;
|
|
3141
|
-
if (isGroup) {
|
|
3142
|
-
renderColumnList = visibleColumn;
|
|
3143
|
-
}
|
|
3144
|
-
else {
|
|
3145
|
-
if (fixedType) {
|
|
3146
|
-
// 如果是使用优化模式
|
|
3147
|
-
if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
|
|
3148
|
-
// 如果不支持优化模式
|
|
3149
|
-
if (spanMethod || footerSpanMethod) {
|
|
3150
|
-
renderColumnList = visibleColumn;
|
|
3151
|
-
}
|
|
3152
|
-
else {
|
|
3153
|
-
renderColumnList = fixedColumn || [];
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
else {
|
|
3157
|
-
renderColumnList = visibleColumn;
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
}
|
|
3161
|
-
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
3162
|
-
if (tableElem) {
|
|
3163
|
-
tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
|
|
3164
|
-
// 修复 IE 中高度无法自适应问题
|
|
3165
|
-
if (browse.msie) {
|
|
3166
|
-
XEUtils.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), (resizeElem) => {
|
|
3167
|
-
resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`;
|
|
3168
|
-
});
|
|
3169
|
-
}
|
|
3170
|
-
}
|
|
3171
|
-
const repairElem = elemStore[`${name}-${layout}-repair`];
|
|
3172
|
-
if (repairElem) {
|
|
3173
|
-
repairElem.style.width = `${tableWidth}px`;
|
|
3174
|
-
}
|
|
3175
|
-
const listElem = elemStore[`${name}-${layout}-list`];
|
|
3176
|
-
if (isGroup && listElem) {
|
|
3177
|
-
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem) => {
|
|
3178
|
-
const colNode = this.getColumnNode(thElem);
|
|
3179
|
-
if (colNode) {
|
|
3180
|
-
const column = colNode.item;
|
|
3181
|
-
const { showHeaderOverflow } = column;
|
|
3182
|
-
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
|
|
3183
|
-
const showEllipsis = cellOverflow === 'ellipsis';
|
|
3184
|
-
const showTitle = cellOverflow === 'title';
|
|
3185
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
3186
|
-
const hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
3187
|
-
let childWidth = 0;
|
|
3188
|
-
let countChild = 0;
|
|
3189
|
-
if (hasEllipsis) {
|
|
3190
|
-
XEUtils.eachTree(column.children, item => {
|
|
3191
|
-
if (!item.children || !column.children.length) {
|
|
3192
|
-
countChild++;
|
|
3193
|
-
}
|
|
3194
|
-
childWidth += item.renderWidth;
|
|
3195
|
-
});
|
|
3196
|
-
}
|
|
3197
|
-
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
|
|
3198
|
-
}
|
|
3199
|
-
});
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
else if (layout === 'body') {
|
|
3203
|
-
const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`];
|
|
3204
|
-
if (isNodeElement(wrapperElem)) {
|
|
3205
|
-
let bodyMaxHeight = 0;
|
|
3206
|
-
const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
|
|
3207
|
-
if (customMaxHeight) {
|
|
3208
|
-
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
|
|
3209
|
-
// 如果是固定列
|
|
3210
|
-
if (fixedType) {
|
|
3211
|
-
bodyMaxHeight -= (showFooter ? 0 : scrollbarHeight);
|
|
3212
|
-
}
|
|
3213
|
-
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
|
|
3214
|
-
wrapperElem.style.maxHeight = `${bodyMaxHeight}px`;
|
|
3215
|
-
}
|
|
3216
|
-
if (customHeight) {
|
|
3217
|
-
let bodyHeight = customHeight - headerHeight - footerHeight;
|
|
3218
|
-
// 如果是固定列
|
|
3219
|
-
if (fixedType) {
|
|
3220
|
-
bodyHeight -= (showFooter ? 0 : scrollbarHeight);
|
|
3221
|
-
}
|
|
3222
|
-
if (bodyMaxHeight) {
|
|
3223
|
-
bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
|
|
3224
|
-
}
|
|
3225
|
-
wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`;
|
|
3226
|
-
}
|
|
3227
|
-
else {
|
|
3228
|
-
wrapperElem.style.height = '';
|
|
3229
|
-
}
|
|
3230
|
-
wrapperElem.style.minHeight = `${bodyMinHeight}px`;
|
|
3231
|
-
}
|
|
3232
|
-
// 如果是固定列
|
|
3233
|
-
if (fixedWrapperElem) {
|
|
3234
|
-
const isRightFixed = fixedType === 'right';
|
|
3235
|
-
const fixedColumn = columnStore[`${fixedType}List`];
|
|
3236
|
-
if (isNodeElement(wrapperElem)) {
|
|
3237
|
-
wrapperElem.style.top = `${headerHeight}px`;
|
|
3238
|
-
}
|
|
3239
|
-
fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`;
|
|
3240
|
-
fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`;
|
|
3241
|
-
}
|
|
3242
|
-
let tWidth = tableWidth;
|
|
3243
|
-
let renderColumnList = tableColumn;
|
|
3244
|
-
if (fixedType) {
|
|
3245
|
-
// 如果是使用优化模式
|
|
3246
|
-
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
3247
|
-
// 如果不支持优化模式
|
|
3248
|
-
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
3249
|
-
renderColumnList = visibleColumn;
|
|
3250
|
-
}
|
|
3251
|
-
else {
|
|
3252
|
-
renderColumnList = fixedColumn || [];
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
else {
|
|
3256
|
-
renderColumnList = visibleColumn;
|
|
3257
|
-
}
|
|
3258
|
-
}
|
|
3259
|
-
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
3260
|
-
if (tableElem) {
|
|
3261
|
-
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
3262
|
-
// 兼容性处理
|
|
3263
|
-
tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : '';
|
|
3264
|
-
}
|
|
3265
|
-
if (emptyBlockElem) {
|
|
3266
|
-
emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
3267
|
-
}
|
|
3268
|
-
}
|
|
3269
|
-
else if (layout === 'footer') {
|
|
3270
|
-
let tWidth = tableWidth;
|
|
3271
|
-
let renderColumnList = tableColumn;
|
|
3272
|
-
if (fixedType) {
|
|
3273
|
-
// 如果是使用优化模式
|
|
3274
|
-
if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
|
|
3275
|
-
// 如果不支持优化模式
|
|
3276
|
-
if (spanMethod || footerSpanMethod) {
|
|
3277
|
-
renderColumnList = visibleColumn;
|
|
3278
|
-
}
|
|
3279
|
-
else {
|
|
3280
|
-
renderColumnList = fixedColumn || [];
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
else {
|
|
3284
|
-
renderColumnList = visibleColumn;
|
|
3285
|
-
}
|
|
3286
|
-
}
|
|
3287
|
-
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
3288
|
-
if (isNodeElement(wrapperElem)) {
|
|
3289
|
-
// 如果是固定列
|
|
3290
|
-
if (fixedWrapperElem) {
|
|
3291
|
-
wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`;
|
|
3292
|
-
}
|
|
3293
|
-
wrapperElem.style.marginTop = `${-scrollbarHeight}px`;
|
|
3294
|
-
}
|
|
3295
|
-
if (tableElem) {
|
|
3296
|
-
tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
|
|
3297
|
-
}
|
|
3447
|
+
setTimeout(() => $xeTable.recalculate(true), 300);
|
|
3448
|
+
});
|
|
3449
|
+
}
|
|
3450
|
+
},
|
|
3451
|
+
/**
|
|
3452
|
+
* 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
|
|
3453
|
+
*/
|
|
3454
|
+
refreshScroll() {
|
|
3455
|
+
const $xeTable = this;
|
|
3456
|
+
const internalData = $xeTable;
|
|
3457
|
+
const { elemStore, lastScrollLeft, lastScrollTop } = internalData;
|
|
3458
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
3459
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
3460
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
|
|
3461
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
|
|
3462
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
|
|
3463
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
3464
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
3465
|
+
return new Promise(resolve => {
|
|
3466
|
+
// 还原滚动条位置
|
|
3467
|
+
if (lastScrollLeft || lastScrollTop) {
|
|
3468
|
+
return restoreScrollLocation($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
|
|
3469
|
+
// 存在滚动行为未结束情况
|
|
3470
|
+
setTimeout(resolve, 10);
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
internalData.intoRunScroll = true;
|
|
3474
|
+
// 重置
|
|
3475
|
+
setScrollTop(yHandleEl, lastScrollTop);
|
|
3476
|
+
setScrollTop(bodyScrollElem, lastScrollTop);
|
|
3477
|
+
setScrollTop(leftScrollElem, lastScrollTop);
|
|
3478
|
+
setScrollTop(rightScrollElem, lastScrollTop);
|
|
3479
|
+
setScrollLeft(xHandleEl, lastScrollLeft);
|
|
3480
|
+
setScrollLeft(bodyScrollElem, lastScrollLeft);
|
|
3481
|
+
setScrollLeft(headerScrollElem, lastScrollLeft);
|
|
3482
|
+
setScrollLeft(footerScrollElem, lastScrollLeft);
|
|
3483
|
+
// 存在滚动行为未结束情况
|
|
3484
|
+
setTimeout(() => {
|
|
3485
|
+
internalData.intoRunScroll = false;
|
|
3486
|
+
resolve();
|
|
3487
|
+
}, 10);
|
|
3488
|
+
});
|
|
3489
|
+
},
|
|
3490
|
+
/**
|
|
3491
|
+
* 重新渲染布局
|
|
3492
|
+
* 刷新布局
|
|
3493
|
+
*/
|
|
3494
|
+
recalculate(reFull) {
|
|
3495
|
+
const $xeTable = this;
|
|
3496
|
+
const internalData = $xeTable;
|
|
3497
|
+
return new Promise(resolve => {
|
|
3498
|
+
const { rceTimeout, rceRunTime } = internalData;
|
|
3499
|
+
const resizeOpts = $xeTable.computeResizeOpts;
|
|
3500
|
+
const refreshDelay = resizeOpts.refreshDelay || 20;
|
|
3501
|
+
const el = $xeTable.$refs.refElem;
|
|
3502
|
+
if (el && el.clientWidth) {
|
|
3503
|
+
autoCellWidth($xeTable);
|
|
3504
|
+
}
|
|
3505
|
+
if (rceTimeout) {
|
|
3506
|
+
clearTimeout(rceTimeout);
|
|
3507
|
+
if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
|
|
3508
|
+
resolve(handleRecalculateLayout($xeTable, !!reFull));
|
|
3298
3509
|
}
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
const colid = colElem.getAttribute('name');
|
|
3303
|
-
if (colid === 'col_gutter') {
|
|
3304
|
-
colElem.style.width = `${scrollbarWidth}px`;
|
|
3305
|
-
}
|
|
3306
|
-
if (fullColumnIdData[colid]) {
|
|
3307
|
-
const colRest = fullColumnIdData[colid];
|
|
3308
|
-
const column = colRest.column;
|
|
3309
|
-
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column;
|
|
3310
|
-
let cellOverflow;
|
|
3311
|
-
colElem.style.width = `${column.renderWidth}px`;
|
|
3312
|
-
if (layout === 'header') {
|
|
3313
|
-
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
|
|
3314
|
-
}
|
|
3315
|
-
else if (layout === 'footer') {
|
|
3316
|
-
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
|
|
3317
|
-
}
|
|
3318
|
-
else {
|
|
3319
|
-
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow;
|
|
3320
|
-
}
|
|
3321
|
-
const showEllipsis = cellOverflow === 'ellipsis';
|
|
3322
|
-
const showTitle = cellOverflow === 'title';
|
|
3323
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
3324
|
-
let hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
3325
|
-
const listElem = elemStore[`${name}-${layout}-list`];
|
|
3326
|
-
// 滚动的渲染不支持动态行高
|
|
3327
|
-
if (layout === 'header' || layout === 'footer') {
|
|
3328
|
-
if (scrollXLoad && !hasEllipsis) {
|
|
3329
|
-
hasEllipsis = true;
|
|
3330
|
-
}
|
|
3331
|
-
}
|
|
3332
|
-
else {
|
|
3333
|
-
if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
|
|
3334
|
-
hasEllipsis = true;
|
|
3335
|
-
}
|
|
3336
|
-
}
|
|
3337
|
-
if (listElem) {
|
|
3338
|
-
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem) => {
|
|
3339
|
-
const colspan = parseInt(elem.getAttribute('colspan') || 1);
|
|
3340
|
-
const cellElem = elem.querySelector('.vxe-cell');
|
|
3341
|
-
let colWidth = column.renderWidth;
|
|
3342
|
-
if (cellElem) {
|
|
3343
|
-
if (colspan > 1) {
|
|
3344
|
-
const columnIndex = this.getColumnIndex(column);
|
|
3345
|
-
for (let index = 1; index < colspan; index++) {
|
|
3346
|
-
const nextColumn = this.getColumns(columnIndex + index);
|
|
3347
|
-
if (nextColumn) {
|
|
3348
|
-
colWidth += nextColumn.renderWidth;
|
|
3349
|
-
}
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : '';
|
|
3353
|
-
}
|
|
3354
|
-
});
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3510
|
+
else {
|
|
3511
|
+
$xeTable.$nextTick(() => {
|
|
3512
|
+
resolve();
|
|
3357
3513
|
});
|
|
3358
3514
|
}
|
|
3359
|
-
}
|
|
3515
|
+
}
|
|
3516
|
+
else {
|
|
3517
|
+
resolve(handleRecalculateLayout($xeTable, !!reFull));
|
|
3518
|
+
}
|
|
3519
|
+
internalData.rceTimeout = setTimeout(() => {
|
|
3520
|
+
internalData.rceTimeout = undefined;
|
|
3521
|
+
handleRecalculateLayout($xeTable, !!reFull);
|
|
3522
|
+
}, refreshDelay);
|
|
3360
3523
|
});
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
this.addColSdCls();
|
|
3366
|
-
}
|
|
3367
|
-
return this.$nextTick();
|
|
3524
|
+
},
|
|
3525
|
+
updateStyle() {
|
|
3526
|
+
const $xeTable = this;
|
|
3527
|
+
return updateStyle($xeTable);
|
|
3368
3528
|
},
|
|
3369
3529
|
/**
|
|
3370
3530
|
* 处理固定列的显示状态
|
|
3371
3531
|
*/
|
|
3372
3532
|
checkScrolling() {
|
|
3373
3533
|
const $xeTable = this;
|
|
3374
|
-
const
|
|
3375
|
-
const
|
|
3534
|
+
const internalData = $xeTable;
|
|
3535
|
+
const { elemStore } = internalData;
|
|
3536
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
3537
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer;
|
|
3538
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer;
|
|
3376
3539
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
3377
|
-
const bodtTargetEl = xHandleEl ||
|
|
3540
|
+
const bodtTargetEl = xHandleEl || bodyScrollElem;
|
|
3378
3541
|
if (bodtTargetEl) {
|
|
3379
|
-
if (
|
|
3542
|
+
if (leftContainerElem) {
|
|
3380
3543
|
if (bodtTargetEl.scrollLeft > 0) {
|
|
3381
|
-
addClass(
|
|
3544
|
+
addClass(leftContainerElem, 'scrolling--middle');
|
|
3382
3545
|
}
|
|
3383
3546
|
else {
|
|
3384
|
-
removeClass(
|
|
3547
|
+
removeClass(leftContainerElem, 'scrolling--middle');
|
|
3385
3548
|
}
|
|
3386
3549
|
}
|
|
3387
|
-
if (
|
|
3550
|
+
if (rightContainerElem) {
|
|
3388
3551
|
if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
|
|
3389
|
-
addClass(
|
|
3552
|
+
addClass(rightContainerElem, 'scrolling--middle');
|
|
3390
3553
|
}
|
|
3391
3554
|
else {
|
|
3392
|
-
removeClass(
|
|
3555
|
+
removeClass(rightContainerElem, 'scrolling--middle');
|
|
3393
3556
|
}
|
|
3394
3557
|
}
|
|
3395
3558
|
}
|
|
@@ -3423,7 +3586,7 @@ const Methods = {
|
|
|
3423
3586
|
handleGlobalMousedownEvent(evnt) {
|
|
3424
3587
|
const { $el, $refs, $xegrid, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this;
|
|
3425
3588
|
const { actived } = editStore;
|
|
3426
|
-
const {
|
|
3589
|
+
const { refTableMenu, filterWrapper, customWrapper, refValidTooltip } = $refs;
|
|
3427
3590
|
// 筛选
|
|
3428
3591
|
if (filterWrapper) {
|
|
3429
3592
|
if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {
|
|
@@ -3458,7 +3621,7 @@ const Methods = {
|
|
|
3458
3621
|
// 如果是激活状态,点击了单元格之外
|
|
3459
3622
|
const cell = actived.args.cell;
|
|
3460
3623
|
if ((!cell || !getEventTargetNode(evnt, cell).flag)) {
|
|
3461
|
-
if (
|
|
3624
|
+
if (refValidTooltip && getEventTargetNode(evnt, refValidTooltip.$el).flag) {
|
|
3462
3625
|
// 如果是激活状态,且点击了校验提示框
|
|
3463
3626
|
}
|
|
3464
3627
|
else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
|
|
@@ -3509,7 +3672,7 @@ const Methods = {
|
|
|
3509
3672
|
}
|
|
3510
3673
|
}
|
|
3511
3674
|
else if (mouseConfig) {
|
|
3512
|
-
if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(
|
|
3675
|
+
if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(refTableMenu && getEventTargetNode(evnt, refTableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
|
|
3513
3676
|
if (this.clearSelected) {
|
|
3514
3677
|
this.clearSelected();
|
|
3515
3678
|
}
|
|
@@ -3528,7 +3691,7 @@ const Methods = {
|
|
|
3528
3691
|
}
|
|
3529
3692
|
}
|
|
3530
3693
|
// 如果配置了快捷菜单且,点击了其他地方则关闭
|
|
3531
|
-
if (ctxMenuStore.visible &&
|
|
3694
|
+
if (ctxMenuStore.visible && refTableMenu && !getEventTargetNode(evnt, refTableMenu.$el).flag) {
|
|
3532
3695
|
this.closeMenu();
|
|
3533
3696
|
}
|
|
3534
3697
|
const isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag;
|
|
@@ -3665,8 +3828,8 @@ const Methods = {
|
|
|
3665
3828
|
else if (isContextMenu) {
|
|
3666
3829
|
// 如果按下上下文键
|
|
3667
3830
|
this._keyCtx = selected.row && selected.column && bodyCtxMenu.length;
|
|
3668
|
-
clearTimeout(
|
|
3669
|
-
|
|
3831
|
+
clearTimeout(internalData.keyCtxTimeout);
|
|
3832
|
+
internalData.keyCtxTimeout = setTimeout(() => {
|
|
3670
3833
|
this._keyCtx = false;
|
|
3671
3834
|
}, 1000);
|
|
3672
3835
|
}
|
|
@@ -4031,6 +4194,10 @@ const Methods = {
|
|
|
4031
4194
|
* @param {Row} row 行对象
|
|
4032
4195
|
*/
|
|
4033
4196
|
handleTooltip(evnt, cell, overflowElem, tipElem, params) {
|
|
4197
|
+
const $xeTable = this;
|
|
4198
|
+
if (!overflowElem) {
|
|
4199
|
+
return $xeTable.$nextTick();
|
|
4200
|
+
}
|
|
4034
4201
|
params.cell = cell;
|
|
4035
4202
|
const { $refs, tooltipOpts, tooltipStore } = this;
|
|
4036
4203
|
const { column, row } = params;
|
|
@@ -4057,7 +4224,7 @@ const Methods = {
|
|
|
4057
4224
|
},
|
|
4058
4225
|
openTooltip(target, content) {
|
|
4059
4226
|
const { $refs } = this;
|
|
4060
|
-
const commTip = $refs.
|
|
4227
|
+
const commTip = $refs.refCommTooltip;
|
|
4061
4228
|
if (commTip) {
|
|
4062
4229
|
return commTip.open(target, content);
|
|
4063
4230
|
}
|
|
@@ -4069,7 +4236,7 @@ const Methods = {
|
|
|
4069
4236
|
closeTooltip() {
|
|
4070
4237
|
const { $refs, tooltipStore } = this;
|
|
4071
4238
|
const tooltip = $refs.tooltip;
|
|
4072
|
-
const commTip = $refs.
|
|
4239
|
+
const commTip = $refs.refCommTooltip;
|
|
4073
4240
|
if (tooltipStore.visible) {
|
|
4074
4241
|
Object.assign(tooltipStore, {
|
|
4075
4242
|
row: null,
|
|
@@ -5250,6 +5417,7 @@ const Methods = {
|
|
|
5250
5417
|
this.emitEvent('cell-dblclick', params, evnt);
|
|
5251
5418
|
},
|
|
5252
5419
|
handleDefaultSort() {
|
|
5420
|
+
const $xeTable = this;
|
|
5253
5421
|
const { sortConfig, sortOpts } = this;
|
|
5254
5422
|
let { defaultSort } = sortOpts;
|
|
5255
5423
|
if (defaultSort) {
|
|
@@ -5268,7 +5436,7 @@ const Methods = {
|
|
|
5268
5436
|
}
|
|
5269
5437
|
});
|
|
5270
5438
|
if (!sortOpts.remote) {
|
|
5271
|
-
this.handleTableData(true).then(
|
|
5439
|
+
this.handleTableData(true).then(() => updateStyle($xeTable));
|
|
5272
5440
|
}
|
|
5273
5441
|
}
|
|
5274
5442
|
}
|
|
@@ -5689,8 +5857,8 @@ const Methods = {
|
|
|
5689
5857
|
},
|
|
5690
5858
|
handleColDragSwapColumn() {
|
|
5691
5859
|
const $xeTable = this;
|
|
5692
|
-
$xeTable
|
|
5693
|
-
$xeTable
|
|
5860
|
+
handleUpdateColumn($xeTable);
|
|
5861
|
+
parseColumns($xeTable, false).then(() => {
|
|
5694
5862
|
$xeTable.updateCellAreas();
|
|
5695
5863
|
$xeTable.saveCustomStore('update:sort');
|
|
5696
5864
|
});
|
|
@@ -5916,15 +6084,15 @@ const Methods = {
|
|
|
5916
6084
|
return;
|
|
5917
6085
|
}
|
|
5918
6086
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
5919
|
-
const
|
|
5920
|
-
const tableBodyElem =
|
|
6087
|
+
const refTableBody = $xeTable.$refs.refTableBody;
|
|
6088
|
+
const tableBodyElem = refTableBody ? refTableBody.$el : null;
|
|
5921
6089
|
const scrollTargetEl = xHandleEl || tableBodyElem;
|
|
5922
6090
|
if (scrollTargetEl) {
|
|
5923
6091
|
const wrapperRect = el.getBoundingClientRect();
|
|
5924
6092
|
const tableWidth = el.clientWidth;
|
|
5925
|
-
const leftContainerElem = $xeTable.$refs.
|
|
6093
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer;
|
|
5926
6094
|
const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
|
|
5927
|
-
const rightContainerElem = $xeTable.$refs.
|
|
6095
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer;
|
|
5928
6096
|
const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
|
|
5929
6097
|
const srartX = wrapperRect.x + leftContainerWidth;
|
|
5930
6098
|
const endX = wrapperRect.x + tableWidth - rightContainerWidth;
|
|
@@ -6048,6 +6216,7 @@ const Methods = {
|
|
|
6048
6216
|
return this.$nextTick();
|
|
6049
6217
|
},
|
|
6050
6218
|
sort(sortConfs, sortOrder) {
|
|
6219
|
+
const $xeTable = this;
|
|
6051
6220
|
const { sortOpts } = this;
|
|
6052
6221
|
const { multiple, remote, orders } = sortOpts;
|
|
6053
6222
|
if (sortConfs) {
|
|
@@ -6090,7 +6259,7 @@ const Methods = {
|
|
|
6090
6259
|
}
|
|
6091
6260
|
return this.$nextTick().then(() => {
|
|
6092
6261
|
this.updateCellAreas();
|
|
6093
|
-
return
|
|
6262
|
+
return updateStyle($xeTable);
|
|
6094
6263
|
});
|
|
6095
6264
|
}
|
|
6096
6265
|
return this.$nextTick();
|
|
@@ -6135,7 +6304,7 @@ const Methods = {
|
|
|
6135
6304
|
}
|
|
6136
6305
|
return $xeTable.$nextTick().then(() => {
|
|
6137
6306
|
$xeTable.updateCellAreas();
|
|
6138
|
-
return $xeTable
|
|
6307
|
+
return updateStyle($xeTable);
|
|
6139
6308
|
});
|
|
6140
6309
|
}
|
|
6141
6310
|
return $xeTable.$nextTick();
|
|
@@ -6146,6 +6315,7 @@ const Methods = {
|
|
|
6146
6315
|
* @param {String} column 列或字段名
|
|
6147
6316
|
*/
|
|
6148
6317
|
clearSort(fieldOrColumn) {
|
|
6318
|
+
const $xeTable = this;
|
|
6149
6319
|
const { sortOpts } = this;
|
|
6150
6320
|
if (fieldOrColumn) {
|
|
6151
6321
|
const column = handleFieldOrColumn(this, fieldOrColumn);
|
|
@@ -6159,7 +6329,7 @@ const Methods = {
|
|
|
6159
6329
|
if (!sortOpts.remote) {
|
|
6160
6330
|
this.handleTableData(true);
|
|
6161
6331
|
}
|
|
6162
|
-
return this.$nextTick().then(
|
|
6332
|
+
return this.$nextTick().then(() => updateStyle($xeTable));
|
|
6163
6333
|
},
|
|
6164
6334
|
// 在 v3 中废弃
|
|
6165
6335
|
getSortColumn() {
|
|
@@ -6864,7 +7034,7 @@ const Methods = {
|
|
|
6864
7034
|
*/
|
|
6865
7035
|
getScroll() {
|
|
6866
7036
|
const { $refs, scrollXLoad, scrollYLoad } = this;
|
|
6867
|
-
const bodyElem = $refs.
|
|
7037
|
+
const bodyElem = $refs.refTableBody.$el;
|
|
6868
7038
|
return {
|
|
6869
7039
|
virtualX: scrollXLoad,
|
|
6870
7040
|
virtualY: scrollYLoad,
|
|
@@ -6879,15 +7049,18 @@ const Methods = {
|
|
|
6879
7049
|
const internalData = $xeTable;
|
|
6880
7050
|
const { highlightHoverRow } = props;
|
|
6881
7051
|
const { lastScrollLeft, lastScrollTop } = internalData;
|
|
6882
|
-
const
|
|
6883
|
-
const
|
|
7052
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7053
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7054
|
+
if (!xHandleEl || !yHandleEl) {
|
|
7055
|
+
return;
|
|
7056
|
+
}
|
|
6884
7057
|
const rowOpts = $xeTable.computeRowOpts;
|
|
6885
|
-
const validTip = $xeTable.$refs.
|
|
6886
|
-
const tooltip = $xeTable.$refs.
|
|
6887
|
-
const bodyHeight =
|
|
6888
|
-
const bodyWidth =
|
|
6889
|
-
const scrollHeight =
|
|
6890
|
-
const scrollWidth =
|
|
7058
|
+
const validTip = $xeTable.$refs.refValidTooltip;
|
|
7059
|
+
const tooltip = $xeTable.$refs.refTooltip;
|
|
7060
|
+
const bodyHeight = yHandleEl.clientHeight;
|
|
7061
|
+
const bodyWidth = xHandleEl.clientWidth;
|
|
7062
|
+
const scrollHeight = yHandleEl.scrollHeight;
|
|
7063
|
+
const scrollWidth = xHandleEl.scrollWidth;
|
|
6891
7064
|
let isTop = false;
|
|
6892
7065
|
let isBottom = false;
|
|
6893
7066
|
let isLeft = false;
|
|
@@ -6955,10 +7128,10 @@ const Methods = {
|
|
|
6955
7128
|
if (rowOpts.isHover || highlightHoverRow) {
|
|
6956
7129
|
$xeTable.clearHoverRow();
|
|
6957
7130
|
}
|
|
6958
|
-
if (validTip && validTip.visible) {
|
|
7131
|
+
if (validTip && validTip.reactData.visible) {
|
|
6959
7132
|
validTip.close();
|
|
6960
7133
|
}
|
|
6961
|
-
if (tooltip && tooltip.visible) {
|
|
7134
|
+
if (tooltip && tooltip.reactData.visible) {
|
|
6962
7135
|
tooltip.close();
|
|
6963
7136
|
}
|
|
6964
7137
|
if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
|
|
@@ -6971,7 +7144,7 @@ const Methods = {
|
|
|
6971
7144
|
const internalData = $xeTable;
|
|
6972
7145
|
const { lxTimeout, lxRunTime, scrollXStore } = internalData;
|
|
6973
7146
|
const { visibleSize } = scrollXStore;
|
|
6974
|
-
const fpsTime = Math.min(80, Math.floor(visibleSize * 3));
|
|
7147
|
+
const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)));
|
|
6975
7148
|
if (lxTimeout) {
|
|
6976
7149
|
clearTimeout(lxTimeout);
|
|
6977
7150
|
}
|
|
@@ -6987,10 +7160,12 @@ const Methods = {
|
|
|
6987
7160
|
},
|
|
6988
7161
|
lazyScrollYData() {
|
|
6989
7162
|
const $xeTable = this;
|
|
7163
|
+
const props = $xeTable;
|
|
6990
7164
|
const internalData = $xeTable;
|
|
7165
|
+
const { showOverflow } = props;
|
|
6991
7166
|
const { lyTimeout, lyRunTime, scrollYStore } = internalData;
|
|
6992
7167
|
const { visibleSize } = scrollYStore;
|
|
6993
|
-
const fpsTime = Math.min(80, Math.floor(visibleSize));
|
|
7168
|
+
const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)));
|
|
6994
7169
|
if (lyTimeout) {
|
|
6995
7170
|
clearTimeout(lyTimeout);
|
|
6996
7171
|
}
|
|
@@ -7030,28 +7205,254 @@ const Methods = {
|
|
|
7030
7205
|
$xeTable.lazyScrollYData();
|
|
7031
7206
|
}
|
|
7032
7207
|
},
|
|
7033
|
-
|
|
7208
|
+
triggerBodyScrollEvent(evnt, fixedType) {
|
|
7034
7209
|
const $xeTable = this;
|
|
7035
7210
|
const internalData = $xeTable;
|
|
7036
|
-
const {
|
|
7037
|
-
|
|
7038
|
-
|
|
7211
|
+
const { elemStore, lastScrollTop, lastScrollLeft, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll, scrollRenderType, inFooterScroll } = internalData;
|
|
7212
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7213
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7214
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
|
|
7215
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7216
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
|
|
7217
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
7218
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
|
|
7219
|
+
if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
|
|
7220
|
+
return;
|
|
7221
|
+
}
|
|
7222
|
+
if (!bodyScrollElem) {
|
|
7223
|
+
return;
|
|
7224
|
+
}
|
|
7225
|
+
if (!xHandleEl) {
|
|
7226
|
+
return;
|
|
7227
|
+
}
|
|
7228
|
+
if (!yHandleEl) {
|
|
7229
|
+
return;
|
|
7230
|
+
}
|
|
7231
|
+
if (inBodyScroll) {
|
|
7232
|
+
if (scrollRenderType !== fixedType) {
|
|
7039
7233
|
return;
|
|
7040
7234
|
}
|
|
7041
|
-
|
|
7042
|
-
|
|
7235
|
+
}
|
|
7236
|
+
let scrollTop = yHandleEl.scrollTop;
|
|
7237
|
+
let scrollLeft = xHandleEl.scrollLeft;
|
|
7238
|
+
if (leftScrollElem && fixedType === 'left') {
|
|
7239
|
+
scrollTop = leftScrollElem.scrollTop;
|
|
7240
|
+
}
|
|
7241
|
+
else if (rightScrollElem && fixedType === 'right') {
|
|
7242
|
+
scrollTop = rightScrollElem.scrollTop;
|
|
7243
|
+
}
|
|
7244
|
+
else {
|
|
7245
|
+
scrollTop = bodyScrollElem.scrollTop;
|
|
7246
|
+
scrollLeft = bodyScrollElem.scrollLeft;
|
|
7247
|
+
}
|
|
7248
|
+
const isRollX = scrollLeft !== lastScrollLeft;
|
|
7249
|
+
const isRollY = scrollTop !== lastScrollTop;
|
|
7250
|
+
internalData.inBodyScroll = true;
|
|
7251
|
+
internalData.scrollRenderType = fixedType;
|
|
7252
|
+
if (isRollY) {
|
|
7253
|
+
if (fixedType === 'left') {
|
|
7254
|
+
setScrollTop(bodyScrollElem, scrollTop);
|
|
7255
|
+
setScrollTop(rightScrollElem, scrollTop);
|
|
7256
|
+
}
|
|
7257
|
+
else if (fixedType === 'right') {
|
|
7258
|
+
setScrollTop(bodyScrollElem, scrollTop);
|
|
7259
|
+
setScrollTop(leftScrollElem, scrollTop);
|
|
7260
|
+
}
|
|
7261
|
+
else {
|
|
7262
|
+
setScrollTop(leftScrollElem, scrollTop);
|
|
7263
|
+
setScrollTop(rightScrollElem, scrollTop);
|
|
7043
7264
|
}
|
|
7265
|
+
setScrollTop(yHandleEl, scrollTop);
|
|
7266
|
+
$xeTable.triggerScrollYEvent(evnt);
|
|
7267
|
+
}
|
|
7268
|
+
if (isRollX) {
|
|
7269
|
+
setScrollLeft(xHandleEl, scrollLeft);
|
|
7270
|
+
setScrollLeft(headerScrollElem, scrollLeft);
|
|
7271
|
+
setScrollLeft(footerScrollElem, scrollLeft);
|
|
7272
|
+
$xeTable.triggerScrollXEvent(evnt);
|
|
7273
|
+
}
|
|
7274
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7275
|
+
type: 'body',
|
|
7276
|
+
fixed: fixedType
|
|
7277
|
+
});
|
|
7278
|
+
},
|
|
7279
|
+
triggerHeaderScrollEvent(evnt, fixedType) {
|
|
7280
|
+
const $xeTable = this;
|
|
7281
|
+
const internalData = $xeTable;
|
|
7282
|
+
const { elemStore, inWheelScroll, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData;
|
|
7283
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7284
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7285
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7286
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
7287
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
|
|
7288
|
+
if (inWheelScroll) {
|
|
7289
|
+
return;
|
|
7290
|
+
}
|
|
7291
|
+
if (inVirtualScroll) {
|
|
7292
|
+
return;
|
|
7293
|
+
}
|
|
7294
|
+
if (inBodyScroll) {
|
|
7295
|
+
return;
|
|
7296
|
+
}
|
|
7297
|
+
if (inFooterScroll) {
|
|
7298
|
+
return;
|
|
7299
|
+
}
|
|
7300
|
+
if (!headerScrollElem) {
|
|
7301
|
+
return;
|
|
7302
|
+
}
|
|
7303
|
+
if (!xHandleEl) {
|
|
7304
|
+
return;
|
|
7305
|
+
}
|
|
7306
|
+
if (!yHandleEl) {
|
|
7307
|
+
return;
|
|
7308
|
+
}
|
|
7309
|
+
const scrollTop = yHandleEl.scrollTop;
|
|
7310
|
+
const scrollLeft = headerScrollElem.scrollLeft;
|
|
7311
|
+
const isRollX = true;
|
|
7312
|
+
const isRollY = false;
|
|
7313
|
+
internalData.inHeaderScroll = true;
|
|
7314
|
+
setScrollLeft(xHandleEl, scrollLeft);
|
|
7315
|
+
setScrollLeft(footerScrollElem, scrollLeft);
|
|
7316
|
+
setScrollLeft(bodyScrollElem, scrollLeft);
|
|
7317
|
+
$xeTable.triggerScrollXEvent(evnt);
|
|
7318
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7319
|
+
type: 'header',
|
|
7320
|
+
fixed: fixedType
|
|
7321
|
+
});
|
|
7322
|
+
},
|
|
7323
|
+
triggerFooterScrollEvent(evnt, fixedType) {
|
|
7324
|
+
const $xeTable = this;
|
|
7325
|
+
const internalData = $xeTable;
|
|
7326
|
+
const { elemStore, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData;
|
|
7327
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7328
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7329
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7330
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
7331
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
|
|
7332
|
+
if (inWheelScroll) {
|
|
7333
|
+
return;
|
|
7334
|
+
}
|
|
7335
|
+
if (inVirtualScroll) {
|
|
7336
|
+
return;
|
|
7337
|
+
}
|
|
7338
|
+
if (inHeaderScroll) {
|
|
7339
|
+
return;
|
|
7340
|
+
}
|
|
7341
|
+
if (inBodyScroll) {
|
|
7342
|
+
return;
|
|
7343
|
+
}
|
|
7344
|
+
if (!footerScrollElem) {
|
|
7345
|
+
return;
|
|
7346
|
+
}
|
|
7347
|
+
if (!xHandleEl) {
|
|
7348
|
+
return;
|
|
7349
|
+
}
|
|
7350
|
+
if (!yHandleEl) {
|
|
7351
|
+
return;
|
|
7352
|
+
}
|
|
7353
|
+
const scrollTop = yHandleEl.scrollTop;
|
|
7354
|
+
const scrollLeft = footerScrollElem.scrollLeft;
|
|
7355
|
+
const isRollX = true;
|
|
7356
|
+
const isRollY = false;
|
|
7357
|
+
internalData.inFooterScroll = true;
|
|
7358
|
+
setScrollLeft(xHandleEl, scrollLeft);
|
|
7359
|
+
setScrollLeft(headerScrollElem, scrollLeft);
|
|
7360
|
+
setScrollLeft(bodyScrollElem, scrollLeft);
|
|
7361
|
+
$xeTable.triggerScrollXEvent(evnt);
|
|
7362
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7363
|
+
type: 'footer',
|
|
7364
|
+
fixed: fixedType
|
|
7365
|
+
});
|
|
7366
|
+
},
|
|
7367
|
+
triggerBodyWheelEvent(evnt) {
|
|
7368
|
+
const $xeTable = this;
|
|
7369
|
+
const tableProps = $xeTable;
|
|
7370
|
+
const reactData = $xeTable;
|
|
7371
|
+
const internalData = $xeTable;
|
|
7372
|
+
const { deltaY, deltaX } = evnt;
|
|
7373
|
+
const { highlightHoverRow } = tableProps;
|
|
7374
|
+
const { elemStore, lastScrollTop, lastScrollLeft } = internalData;
|
|
7375
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
7376
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7377
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7378
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
|
|
7379
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7380
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
|
|
7381
|
+
if (!xHandleEl) {
|
|
7382
|
+
return;
|
|
7383
|
+
}
|
|
7384
|
+
if (!yHandleEl) {
|
|
7385
|
+
return;
|
|
7386
|
+
}
|
|
7387
|
+
if (!bodyScrollElem) {
|
|
7388
|
+
return;
|
|
7389
|
+
}
|
|
7390
|
+
let multiple = 1;
|
|
7391
|
+
if (reactData.lastScrollTime + 25 > Date.now()) {
|
|
7392
|
+
multiple = 1.18;
|
|
7393
|
+
}
|
|
7394
|
+
else if (reactData.lastScrollTime + 30 > Date.now()) {
|
|
7395
|
+
multiple = 1.15;
|
|
7396
|
+
}
|
|
7397
|
+
else if (reactData.lastScrollTime + 40 > Date.now()) {
|
|
7398
|
+
multiple = 1.12;
|
|
7399
|
+
}
|
|
7400
|
+
else if (reactData.lastScrollTime + 55 > Date.now()) {
|
|
7401
|
+
multiple = 1.09;
|
|
7402
|
+
}
|
|
7403
|
+
else if (reactData.lastScrollTime + 75 > Date.now()) {
|
|
7404
|
+
multiple = 1.06;
|
|
7405
|
+
}
|
|
7406
|
+
else if (reactData.lastScrollTime + 100 > Date.now()) {
|
|
7407
|
+
multiple = 1.03;
|
|
7408
|
+
}
|
|
7409
|
+
const deltaTop = deltaY * multiple;
|
|
7410
|
+
const deltaLeft = deltaX * multiple;
|
|
7411
|
+
const isTopWheel = deltaTop < 0;
|
|
7412
|
+
const currScrollTop = yHandleEl.scrollTop;
|
|
7413
|
+
// 如果滚动位置已经是顶部或底部,则不需要触发
|
|
7414
|
+
if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
|
|
7415
|
+
return;
|
|
7416
|
+
}
|
|
7417
|
+
const scrollTop = bodyScrollElem.scrollTop + deltaTop;
|
|
7418
|
+
const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft;
|
|
7419
|
+
const isRollX = scrollLeft !== lastScrollLeft;
|
|
7420
|
+
const isRollY = scrollTop !== lastScrollTop;
|
|
7421
|
+
// 用于鼠标纵向滚轮处理
|
|
7422
|
+
if (isRollY) {
|
|
7423
|
+
evnt.preventDefault();
|
|
7424
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
7425
|
+
$xeTable.clearHoverRow();
|
|
7426
|
+
}
|
|
7427
|
+
internalData.inWheelScroll = true;
|
|
7428
|
+
setScrollTop(yHandleEl, scrollTop);
|
|
7429
|
+
setScrollTop(bodyScrollElem, scrollTop);
|
|
7430
|
+
setScrollTop(leftScrollElem, scrollTop);
|
|
7431
|
+
setScrollTop(rightScrollElem, scrollTop);
|
|
7432
|
+
$xeTable.triggerScrollYEvent(evnt);
|
|
7433
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7434
|
+
type: 'footer',
|
|
7435
|
+
fixed: ''
|
|
7436
|
+
});
|
|
7437
|
+
}
|
|
7438
|
+
},
|
|
7439
|
+
scrollXEvent(evnt) {
|
|
7440
|
+
const $xeTable = this;
|
|
7441
|
+
const internalData = $xeTable;
|
|
7442
|
+
const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
|
|
7443
|
+
if (inHeaderScroll || inBodyScroll || inFooterScroll) {
|
|
7444
|
+
return;
|
|
7445
|
+
}
|
|
7446
|
+
if (inWheelScroll) {
|
|
7447
|
+
return;
|
|
7044
7448
|
}
|
|
7045
|
-
const
|
|
7046
|
-
const
|
|
7047
|
-
const
|
|
7048
|
-
const bodyElem = tableBody.$el;
|
|
7049
|
-
const headerElem = tableHeader ? tableHeader.$el : null;
|
|
7050
|
-
const footerElem = tableFooter ? tableFooter.$el : null;
|
|
7449
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
7450
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7451
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
|
|
7051
7452
|
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7052
7453
|
const wrapperEl = evnt.currentTarget;
|
|
7053
7454
|
const { scrollLeft } = wrapperEl;
|
|
7054
|
-
const yBodyEl = yHandleEl ||
|
|
7455
|
+
const yBodyEl = yHandleEl || bodyScrollElem;
|
|
7055
7456
|
let scrollTop = 0;
|
|
7056
7457
|
if (yBodyEl) {
|
|
7057
7458
|
scrollTop = yBodyEl.scrollTop;
|
|
@@ -7059,9 +7460,9 @@ const Methods = {
|
|
|
7059
7460
|
const isRollX = true;
|
|
7060
7461
|
const isRollY = scrollTop !== lastScrollTop;
|
|
7061
7462
|
internalData.inVirtualScroll = true;
|
|
7062
|
-
setScrollLeft(
|
|
7063
|
-
setScrollLeft(
|
|
7064
|
-
setScrollLeft(
|
|
7463
|
+
setScrollLeft(bodyScrollElem, scrollLeft);
|
|
7464
|
+
setScrollLeft(headerScrollElem, scrollLeft);
|
|
7465
|
+
setScrollLeft(footerScrollElem, scrollLeft);
|
|
7065
7466
|
$xeTable.triggerScrollXEvent(evnt);
|
|
7066
7467
|
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7067
7468
|
type: 'table',
|
|
@@ -7071,25 +7472,20 @@ const Methods = {
|
|
|
7071
7472
|
scrollYEvent(evnt) {
|
|
7072
7473
|
const $xeTable = this;
|
|
7073
7474
|
const internalData = $xeTable;
|
|
7074
|
-
const {
|
|
7075
|
-
if (
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
return;
|
|
7081
|
-
}
|
|
7475
|
+
const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
|
|
7476
|
+
if (inHeaderScroll || inBodyScroll || inFooterScroll) {
|
|
7477
|
+
return;
|
|
7478
|
+
}
|
|
7479
|
+
if (inWheelScroll) {
|
|
7480
|
+
return;
|
|
7082
7481
|
}
|
|
7083
|
-
const
|
|
7084
|
-
const
|
|
7085
|
-
const
|
|
7086
|
-
const bodyElem = tableBody.$el;
|
|
7087
|
-
const leftElem = leftBody ? leftBody.$el : null;
|
|
7088
|
-
const rightElem = rightBody ? rightBody.$el : null;
|
|
7482
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
|
|
7483
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7484
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
|
|
7089
7485
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7090
7486
|
const wrapperEl = evnt.currentTarget;
|
|
7091
7487
|
const { scrollTop } = wrapperEl;
|
|
7092
|
-
const xBodyEl = xHandleEl ||
|
|
7488
|
+
const xBodyEl = xHandleEl || bodyScrollElem;
|
|
7093
7489
|
let scrollLeft = 0;
|
|
7094
7490
|
if (xBodyEl) {
|
|
7095
7491
|
scrollLeft = xBodyEl.scrollLeft;
|
|
@@ -7097,45 +7493,24 @@ const Methods = {
|
|
|
7097
7493
|
const isRollX = scrollLeft !== lastScrollLeft;
|
|
7098
7494
|
const isRollY = true;
|
|
7099
7495
|
internalData.inVirtualScroll = true;
|
|
7100
|
-
setScrollTop(
|
|
7101
|
-
setScrollTop(
|
|
7102
|
-
setScrollTop(
|
|
7496
|
+
setScrollTop(bodyScrollElem, scrollTop);
|
|
7497
|
+
setScrollTop(leftScrollElem, scrollTop);
|
|
7498
|
+
setScrollTop(rightScrollElem, scrollTop);
|
|
7103
7499
|
$xeTable.triggerScrollYEvent(evnt);
|
|
7104
7500
|
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7105
7501
|
type: 'table',
|
|
7106
7502
|
fixed: ''
|
|
7107
7503
|
});
|
|
7108
7504
|
},
|
|
7109
|
-
handleTableColumn() {
|
|
7110
|
-
const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this;
|
|
7111
|
-
const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
|
|
7112
|
-
tableColumn.forEach((column, $index) => {
|
|
7113
|
-
const colid = column.id;
|
|
7114
|
-
const colRest = fullColumnIdData[colid];
|
|
7115
|
-
if (colRest) {
|
|
7116
|
-
colRest.$index = $index;
|
|
7117
|
-
}
|
|
7118
|
-
});
|
|
7119
|
-
this.tableColumn = tableColumn;
|
|
7120
|
-
},
|
|
7121
|
-
handleUpdateColumn() {
|
|
7122
|
-
const $xeTable = this;
|
|
7123
|
-
const internalData = $xeTable;
|
|
7124
|
-
const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber');
|
|
7125
|
-
internalData.collectColumn = columnList;
|
|
7126
|
-
const tableFullColumn = getColumnList(columnList);
|
|
7127
|
-
internalData.tableFullColumn = tableFullColumn;
|
|
7128
|
-
cacheColumnMap($xeTable);
|
|
7129
|
-
},
|
|
7130
7505
|
updateScrollXData() {
|
|
7131
7506
|
const $xeTable = this;
|
|
7132
7507
|
const props = $xeTable;
|
|
7133
7508
|
const { showOverflow } = props;
|
|
7134
|
-
$xeTable
|
|
7135
|
-
calcCellHeight(
|
|
7509
|
+
handleTableColumn($xeTable);
|
|
7510
|
+
// calcCellHeight()
|
|
7136
7511
|
return $xeTable.$nextTick().then(() => {
|
|
7137
|
-
calcCellHeight(
|
|
7138
|
-
$xeTable
|
|
7512
|
+
// calcCellHeight()
|
|
7513
|
+
handleTableColumn($xeTable);
|
|
7139
7514
|
$xeTable.updateScrollXSpace();
|
|
7140
7515
|
if (!showOverflow) {
|
|
7141
7516
|
$xeTable.updateScrollYSpace();
|
|
@@ -7145,8 +7520,13 @@ const Methods = {
|
|
|
7145
7520
|
// 更新横向 X 可视渲染上下剩余空间大小
|
|
7146
7521
|
updateScrollXSpace() {
|
|
7147
7522
|
const $xeTable = this;
|
|
7148
|
-
const
|
|
7149
|
-
const
|
|
7523
|
+
const reactData = $xeTable;
|
|
7524
|
+
const internalData = $xeTable;
|
|
7525
|
+
const { isGroup, scrollXLoad } = reactData;
|
|
7526
|
+
const { visibleColumn, scrollXStore, elemStore, tableWidth } = internalData;
|
|
7527
|
+
const tableHeader = $xeTable.$refs.refTableHeader;
|
|
7528
|
+
const tableBody = $xeTable.$refs.refTableBody;
|
|
7529
|
+
const tableFooter = $xeTable.$refs.refTableFooter;
|
|
7150
7530
|
const tableBodyElem = tableBody ? tableBody.$el : null;
|
|
7151
7531
|
if (tableBodyElem) {
|
|
7152
7532
|
const tableHeaderElem = tableHeader ? tableHeader.$el : null;
|
|
@@ -7170,25 +7550,27 @@ const Methods = {
|
|
|
7170
7550
|
containerList.forEach(name => {
|
|
7171
7551
|
const layoutList = ['header', 'body', 'footer'];
|
|
7172
7552
|
layoutList.forEach(layout => {
|
|
7173
|
-
const xSpaceElem = elemStore[`${name}-${layout}-xSpace`];
|
|
7553
|
+
const xSpaceElem = getRefElem(elemStore[`${name}-${layout}-xSpace`]);
|
|
7174
7554
|
if (xSpaceElem) {
|
|
7175
|
-
xSpaceElem.style.width = scrollXLoad ? `${tableWidth
|
|
7555
|
+
xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : '';
|
|
7176
7556
|
}
|
|
7177
7557
|
});
|
|
7178
7558
|
});
|
|
7179
7559
|
const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem;
|
|
7180
7560
|
if (scrollXSpaceEl) {
|
|
7181
|
-
scrollXSpaceEl.style.width = `${tableWidth
|
|
7561
|
+
scrollXSpaceEl.style.width = `${tableWidth}px`;
|
|
7182
7562
|
}
|
|
7183
|
-
|
|
7563
|
+
$xeTable.$nextTick(() => {
|
|
7564
|
+
updateStyle($xeTable);
|
|
7565
|
+
});
|
|
7184
7566
|
}
|
|
7185
7567
|
},
|
|
7186
7568
|
updateScrollYData() {
|
|
7187
7569
|
const $xeTable = this;
|
|
7188
7570
|
$xeTable.handleTableData();
|
|
7189
|
-
calcCellHeight(
|
|
7571
|
+
// calcCellHeight()
|
|
7190
7572
|
return $xeTable.$nextTick().then(() => {
|
|
7191
|
-
calcCellHeight(
|
|
7573
|
+
// calcCellHeight()
|
|
7192
7574
|
$xeTable.handleTableData();
|
|
7193
7575
|
$xeTable.updateScrollYSpace();
|
|
7194
7576
|
});
|
|
@@ -7196,16 +7578,20 @@ const Methods = {
|
|
|
7196
7578
|
// 更新纵向 Y 可视渲染上下剩余空间大小
|
|
7197
7579
|
updateScrollYSpace() {
|
|
7198
7580
|
const $xeTable = this;
|
|
7199
|
-
const
|
|
7200
|
-
const
|
|
7201
|
-
|
|
7202
|
-
|
|
7581
|
+
const props = $xeTable;
|
|
7582
|
+
const reactData = $xeTable;
|
|
7583
|
+
const internalData = $xeTable;
|
|
7584
|
+
const { showOverflow } = props;
|
|
7585
|
+
const { scrollYLoad, rowHeight } = reactData;
|
|
7586
|
+
const { scrollYStore, elemStore, afterFullData, fullAllDataRowIdData } = internalData;
|
|
7587
|
+
const { startIndex } = scrollYStore;
|
|
7588
|
+
const bodyTableElem = getRefElem(elemStore['main-body-table']);
|
|
7203
7589
|
const containerList = ['main', 'left', 'right'];
|
|
7204
|
-
let
|
|
7205
|
-
let ySpaceHeight =
|
|
7590
|
+
let topSpaceHeight = 0;
|
|
7591
|
+
let ySpaceHeight = 0;
|
|
7206
7592
|
if (scrollYLoad) {
|
|
7207
7593
|
if (showOverflow) {
|
|
7208
|
-
|
|
7594
|
+
ySpaceHeight = afterFullData.length * rowHeight;
|
|
7209
7595
|
topSpaceHeight = Math.max(0, startIndex * rowHeight);
|
|
7210
7596
|
}
|
|
7211
7597
|
else {
|
|
@@ -7214,7 +7600,7 @@ const Methods = {
|
|
|
7214
7600
|
const rowid = getRowid($xeTable, row);
|
|
7215
7601
|
const rowRest = fullAllDataRowIdData[rowid];
|
|
7216
7602
|
if (rowRest) {
|
|
7217
|
-
|
|
7603
|
+
ySpaceHeight += rowRest.height || rowHeight;
|
|
7218
7604
|
}
|
|
7219
7605
|
}
|
|
7220
7606
|
for (let i = 0; i < startIndex; i++) {
|
|
@@ -7226,27 +7612,32 @@ const Methods = {
|
|
|
7226
7612
|
}
|
|
7227
7613
|
}
|
|
7228
7614
|
}
|
|
7229
|
-
|
|
7230
|
-
|
|
7615
|
+
}
|
|
7616
|
+
else {
|
|
7617
|
+
if (bodyTableElem) {
|
|
7618
|
+
ySpaceHeight = bodyTableElem.clientHeight;
|
|
7619
|
+
}
|
|
7231
7620
|
}
|
|
7232
7621
|
containerList.forEach(name => {
|
|
7233
7622
|
const layoutList = ['header', 'body', 'footer'];
|
|
7234
|
-
const tableElem = elemStore[`${name}-body-table`];
|
|
7623
|
+
const tableElem = getRefElem(elemStore[`${name}-body-table`]);
|
|
7235
7624
|
if (tableElem) {
|
|
7236
|
-
tableElem.style.marginTop =
|
|
7625
|
+
tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : '';
|
|
7237
7626
|
}
|
|
7238
7627
|
layoutList.forEach(layout => {
|
|
7239
|
-
const ySpaceElem = elemStore[`${name}-${layout}-ySpace`];
|
|
7628
|
+
const ySpaceElem = getRefElem(elemStore[`${name}-${layout}-ySpace`]);
|
|
7240
7629
|
if (ySpaceElem) {
|
|
7241
|
-
ySpaceElem.style.height = ySpaceHeight;
|
|
7630
|
+
ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
|
|
7242
7631
|
}
|
|
7243
7632
|
});
|
|
7244
7633
|
});
|
|
7245
7634
|
const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem;
|
|
7246
7635
|
if (scrollYSpaceEl) {
|
|
7247
|
-
scrollYSpaceEl.style.height = ySpaceHeight;
|
|
7636
|
+
scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
|
|
7248
7637
|
}
|
|
7249
|
-
|
|
7638
|
+
$xeTable.$nextTick(() => {
|
|
7639
|
+
updateStyle($xeTable);
|
|
7640
|
+
});
|
|
7250
7641
|
},
|
|
7251
7642
|
updateScrollYStatus() {
|
|
7252
7643
|
const $xeTable = this;
|
|
@@ -7261,12 +7652,12 @@ const Methods = {
|
|
|
7261
7652
|
const $xeTable = this;
|
|
7262
7653
|
const internalData = $xeTable;
|
|
7263
7654
|
const { $refs } = this;
|
|
7264
|
-
const {
|
|
7265
|
-
const tableBodyElem =
|
|
7655
|
+
const { refTableBody, refTableHeader, leftBody, rightBody, refTableFooter } = $refs;
|
|
7656
|
+
const tableBodyElem = refTableBody ? refTableBody.$el : null;
|
|
7266
7657
|
const leftBodyElem = leftBody ? leftBody.$el : null;
|
|
7267
7658
|
const rightBodyElem = rightBody ? rightBody.$el : null;
|
|
7268
|
-
const tableHeaderElem =
|
|
7269
|
-
const tableFooterElem =
|
|
7659
|
+
const tableHeaderElem = refTableHeader ? refTableHeader.$el : null;
|
|
7660
|
+
const tableFooterElem = refTableFooter ? refTableFooter.$el : null;
|
|
7270
7661
|
internalData.intoRunScroll = true;
|
|
7271
7662
|
if (XEUtils.isNumber(scrollLeft)) {
|
|
7272
7663
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
@@ -7371,46 +7762,33 @@ const Methods = {
|
|
|
7371
7762
|
clearScroll() {
|
|
7372
7763
|
const $xeTable = this;
|
|
7373
7764
|
const internalData = $xeTable;
|
|
7374
|
-
const { scrollXStore, scrollYStore } = internalData;
|
|
7375
|
-
const
|
|
7376
|
-
const
|
|
7377
|
-
const
|
|
7378
|
-
const
|
|
7379
|
-
const
|
|
7380
|
-
const leftBodyElem = leftBody ? leftBody.$el : null;
|
|
7381
|
-
const tableBodyElem = tableBody ? tableBody.$el : null;
|
|
7382
|
-
const rightBodyElem = rightBody ? rightBody.$el : null;
|
|
7383
|
-
const tableHeaderElem = tableHeader ? tableHeader.$el : null;
|
|
7384
|
-
const tableFooterElem = tableFooter ? tableFooter.$el : null;
|
|
7765
|
+
const { elemStore, scrollXStore, scrollYStore } = internalData;
|
|
7766
|
+
const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
|
|
7767
|
+
const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
|
|
7768
|
+
const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
|
|
7769
|
+
const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
|
|
7770
|
+
const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
|
|
7385
7771
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7386
|
-
if (xHandleEl) {
|
|
7387
|
-
setScrollLeft(xHandleEl, 0);
|
|
7388
|
-
}
|
|
7389
|
-
else {
|
|
7390
|
-
setScrollLeft(tableBodyElem, 0);
|
|
7391
|
-
setScrollLeft(tableHeaderElem, 0);
|
|
7392
|
-
setScrollLeft(tableFooterElem, 0);
|
|
7393
|
-
}
|
|
7394
7772
|
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7773
|
+
internalData.intoRunScroll = true;
|
|
7774
|
+
setScrollLeft(xHandleEl, 0);
|
|
7775
|
+
setScrollLeft(bodyScrollElem, 0);
|
|
7776
|
+
setScrollLeft(headerScrollElem, 0);
|
|
7777
|
+
setScrollLeft(footerScrollElem, 0);
|
|
7778
|
+
setScrollTop(yHandleEl, 0);
|
|
7779
|
+
setScrollTop(bodyScrollElem, 0);
|
|
7780
|
+
setScrollTop(leftScrollElem, 0);
|
|
7781
|
+
setScrollTop(rightScrollElem, 0);
|
|
7403
7782
|
scrollXStore.startIndex = 0;
|
|
7783
|
+
scrollXStore.visibleStartIndex = 0;
|
|
7404
7784
|
scrollXStore.endIndex = scrollXStore.visibleSize;
|
|
7785
|
+
scrollXStore.visibleEndIndex = scrollXStore.visibleSize;
|
|
7405
7786
|
scrollYStore.startIndex = 0;
|
|
7787
|
+
scrollYStore.visibleStartIndex = 0;
|
|
7406
7788
|
scrollYStore.endIndex = scrollYStore.visibleSize;
|
|
7789
|
+
scrollYStore.visibleEndIndex = scrollYStore.visibleSize;
|
|
7407
7790
|
return $xeTable.$nextTick().then(() => {
|
|
7408
|
-
|
|
7409
|
-
setScrollLeft(tableHeaderElem, 0);
|
|
7410
|
-
setScrollLeft(tableFooterElem, 0);
|
|
7411
|
-
setScrollTop(tableBodyElem, 0);
|
|
7412
|
-
setScrollTop(leftBodyElem, 0);
|
|
7413
|
-
setScrollTop(rightBodyElem, 0);
|
|
7791
|
+
internalData.intoRunScroll = false;
|
|
7414
7792
|
});
|
|
7415
7793
|
},
|
|
7416
7794
|
/**
|
|
@@ -7437,8 +7815,8 @@ const Methods = {
|
|
|
7437
7815
|
const customVal = !XEUtils.isUndefined(cellValue);
|
|
7438
7816
|
return this.$nextTick().then(() => {
|
|
7439
7817
|
const { $refs, editRules, validStore } = this;
|
|
7440
|
-
const
|
|
7441
|
-
if (slotParams &&
|
|
7818
|
+
const refTableBody = $refs.refTableBody;
|
|
7819
|
+
if (slotParams && refTableBody && editRules) {
|
|
7442
7820
|
const { row, column } = slotParams;
|
|
7443
7821
|
const type = 'change';
|
|
7444
7822
|
if (this.hasCellRules) {
|
|
@@ -7472,13 +7850,14 @@ const Methods = {
|
|
|
7472
7850
|
* @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
|
|
7473
7851
|
*/
|
|
7474
7852
|
setMergeCells(merges) {
|
|
7853
|
+
const $xeTable = this;
|
|
7475
7854
|
if (this.spanMethod) {
|
|
7476
7855
|
errLog('vxe.error.errConflicts', ['merge-cells', 'span-method']);
|
|
7477
7856
|
}
|
|
7478
7857
|
setMerges(this, merges, this.mergeList, this.afterFullData);
|
|
7479
7858
|
return this.$nextTick().then(() => {
|
|
7480
7859
|
this.updateCellAreas();
|
|
7481
|
-
return
|
|
7860
|
+
return updateStyle($xeTable);
|
|
7482
7861
|
});
|
|
7483
7862
|
},
|
|
7484
7863
|
/**
|
|
@@ -7486,13 +7865,14 @@ const Methods = {
|
|
|
7486
7865
|
* @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
|
|
7487
7866
|
*/
|
|
7488
7867
|
removeMergeCells(merges) {
|
|
7868
|
+
const $xeTable = this;
|
|
7489
7869
|
if (this.spanMethod) {
|
|
7490
7870
|
errLog('vxe.error.errConflicts', ['merge-cells', 'span-method']);
|
|
7491
7871
|
}
|
|
7492
7872
|
const rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
|
|
7493
7873
|
return this.$nextTick().then(() => {
|
|
7494
7874
|
this.updateCellAreas();
|
|
7495
|
-
|
|
7875
|
+
updateStyle($xeTable);
|
|
7496
7876
|
return rest;
|
|
7497
7877
|
});
|
|
7498
7878
|
},
|
|
@@ -7506,32 +7886,35 @@ const Methods = {
|
|
|
7506
7886
|
* 清除所有单元格合并
|
|
7507
7887
|
*/
|
|
7508
7888
|
clearMergeCells() {
|
|
7889
|
+
const $xeTable = this;
|
|
7509
7890
|
this.mergeList = [];
|
|
7510
7891
|
return this.$nextTick().then(() => {
|
|
7511
|
-
return
|
|
7892
|
+
return updateStyle($xeTable);
|
|
7512
7893
|
});
|
|
7513
7894
|
},
|
|
7514
7895
|
handleDefaultMergeFooterItems() {
|
|
7515
7896
|
this.setMergeFooterItems(this.mergeFooterItems);
|
|
7516
7897
|
},
|
|
7517
7898
|
setMergeFooterItems(merges) {
|
|
7899
|
+
const $xeTable = this;
|
|
7518
7900
|
if (this.footerSpanMethod) {
|
|
7519
7901
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
|
|
7520
7902
|
}
|
|
7521
7903
|
setMerges(this, merges, this.mergeFooterList, null);
|
|
7522
7904
|
return this.$nextTick().then(() => {
|
|
7523
7905
|
this.updateCellAreas();
|
|
7524
|
-
return
|
|
7906
|
+
return updateStyle($xeTable);
|
|
7525
7907
|
});
|
|
7526
7908
|
},
|
|
7527
7909
|
removeMergeFooterItems(merges) {
|
|
7910
|
+
const $xeTable = this;
|
|
7528
7911
|
if (this.footerSpanMethod) {
|
|
7529
7912
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
|
|
7530
7913
|
}
|
|
7531
7914
|
const rest = removeMerges(this, merges, this.mergeFooterList, null);
|
|
7532
7915
|
return this.$nextTick().then(() => {
|
|
7533
7916
|
this.updateCellAreas();
|
|
7534
|
-
|
|
7917
|
+
updateStyle($xeTable);
|
|
7535
7918
|
return rest;
|
|
7536
7919
|
});
|
|
7537
7920
|
},
|
|
@@ -7545,9 +7928,10 @@ const Methods = {
|
|
|
7545
7928
|
* 清除所有表尾合并
|
|
7546
7929
|
*/
|
|
7547
7930
|
clearMergeFooterItems() {
|
|
7931
|
+
const $xeTable = this;
|
|
7548
7932
|
this.mergeFooterList = [];
|
|
7549
7933
|
return this.$nextTick().then(() => {
|
|
7550
|
-
return
|
|
7934
|
+
return updateStyle($xeTable);
|
|
7551
7935
|
});
|
|
7552
7936
|
},
|
|
7553
7937
|
updateZindex() {
|