vxe-table 3.12.8 → 3.12.10-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid/src/grid.js +6 -1
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/export/mixin.js +3 -3
- package/es/table/module/filter/mixin.js +3 -3
- package/es/table/module/keyboard/mixin.js +4 -4
- package/es/table/module/menu/mixin.js +2 -2
- package/es/table/module/validator/mixin.js +2 -2
- package/es/table/src/body.js +262 -363
- package/es/table/src/footer.js +135 -154
- package/es/table/src/header.js +120 -100
- package/es/table/src/methods.js +1175 -816
- package/es/table/src/props.js +9 -3
- package/es/table/src/table.js +187 -103
- package/es/table/src/util.js +35 -21
- package/es/table/style.css +146 -63
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +14 -4
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +146 -63
- package/es/vxe-table/style.min.css +1 -1
- package/lib/grid/src/grid.js +4 -1
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +1920 -1599
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/export/mixin.js +3 -3
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/filter/mixin.js +4 -4
- package/lib/table/module/filter/mixin.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +5 -5
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +2 -2
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +2 -2
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/body.js +205 -381
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/footer.js +124 -151
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +97 -74
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +1261 -875
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +9 -3
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +171 -90
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +38 -22
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +146 -63
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +14 -4
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +146 -63
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/grid/src/grid.ts +6 -1
- package/packages/table/module/export/mixin.ts +3 -3
- package/packages/table/module/filter/mixin.ts +3 -3
- package/packages/table/module/keyboard/mixin.ts +4 -4
- package/packages/table/module/menu/mixin.ts +2 -2
- package/packages/table/module/validator/mixin.ts +2 -2
- package/packages/table/src/body.ts +296 -436
- package/packages/table/src/footer.ts +148 -164
- package/packages/table/src/header.ts +135 -111
- package/packages/table/src/methods.ts +1249 -873
- package/packages/table/src/props.ts +9 -3
- package/packages/table/src/table.ts +195 -146
- package/packages/table/src/util.ts +40 -23
- package/packages/ui/index.ts +13 -3
- package/styles/components/table.scss +164 -74
- /package/es/{iconfont.1736406699090.ttf → iconfont.1736688976404.ttf} +0 -0
- /package/es/{iconfont.1736406699090.woff → iconfont.1736688976404.woff} +0 -0
- /package/es/{iconfont.1736406699090.woff2 → iconfont.1736688976404.woff2} +0 -0
- /package/lib/{iconfont.1736406699090.ttf → iconfont.1736688976404.ttf} +0 -0
- /package/lib/{iconfont.1736406699090.woff → iconfont.1736688976404.woff} +0 -0
- /package/lib/{iconfont.1736406699090.woff2 → iconfont.1736688976404.woff2} +0 -0
package/es/table/src/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}`);
|
|
@@ -2242,30 +2801,6 @@ const Methods = {
|
|
|
2242
2801
|
this.afterTreeFullData = tableTree;
|
|
2243
2802
|
this.updateAfterDataIndex();
|
|
2244
2803
|
},
|
|
2245
|
-
updateTreeDataIndex() {
|
|
2246
|
-
const $xeTable = this;
|
|
2247
|
-
const props = $xeTable;
|
|
2248
|
-
const internalData = $xeTable;
|
|
2249
|
-
const { treeConfig } = props;
|
|
2250
|
-
const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData;
|
|
2251
|
-
const treeOpts = $xeTable.computeTreeOpts;
|
|
2252
|
-
if (treeConfig) {
|
|
2253
|
-
if (treeOpts.transform) {
|
|
2254
|
-
afterFullData.forEach((row, index) => {
|
|
2255
|
-
const rowid = getRowid($xeTable, row);
|
|
2256
|
-
const rowRest = fullAllDataRowIdData[rowid];
|
|
2257
|
-
if (rowRest) {
|
|
2258
|
-
rowRest._index = index;
|
|
2259
|
-
}
|
|
2260
|
-
else {
|
|
2261
|
-
const rest = { row, rowid, seq: '-1', index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0, oTop: 0 };
|
|
2262
|
-
fullAllDataRowIdData[rowid] = rest;
|
|
2263
|
-
fullDataRowIdData[rowid] = rest;
|
|
2264
|
-
}
|
|
2265
|
-
});
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
},
|
|
2269
2804
|
/**
|
|
2270
2805
|
* 预编译
|
|
2271
2806
|
* 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
|
|
@@ -2295,7 +2830,6 @@ const Methods = {
|
|
|
2295
2830
|
}
|
|
2296
2831
|
fullMaps[rowid] = row;
|
|
2297
2832
|
}, { children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField });
|
|
2298
|
-
$xeTable.updateTreeDataIndex();
|
|
2299
2833
|
}
|
|
2300
2834
|
else {
|
|
2301
2835
|
afterFullData.forEach((row, index) => {
|
|
@@ -2575,8 +3109,8 @@ const Methods = {
|
|
|
2575
3109
|
const colWidth = XEUtils.toInteger(width);
|
|
2576
3110
|
let rdWidth = colWidth;
|
|
2577
3111
|
if (isScale(width)) {
|
|
2578
|
-
const
|
|
2579
|
-
const bodyElem =
|
|
3112
|
+
const refTableBody = $xeTable.$refs.refTableBody;
|
|
3113
|
+
const bodyElem = refTableBody ? refTableBody.$el : null;
|
|
2580
3114
|
const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
|
|
2581
3115
|
rdWidth = Math.floor(colWidth * bodyWidth);
|
|
2582
3116
|
}
|
|
@@ -2822,150 +3356,16 @@ const Methods = {
|
|
|
2822
3356
|
* 刷新列配置
|
|
2823
3357
|
*/
|
|
2824
3358
|
refreshColumn(initSort) {
|
|
3359
|
+
const $xeTable = this;
|
|
2825
3360
|
if (initSort) {
|
|
2826
|
-
|
|
3361
|
+
handleUpdateColumn($xeTable);
|
|
2827
3362
|
}
|
|
2828
|
-
return
|
|
3363
|
+
return parseColumns($xeTable, true).then(() => {
|
|
2829
3364
|
return this.refreshScroll();
|
|
2830
3365
|
}).then(() => {
|
|
2831
3366
|
return this.recalculate();
|
|
2832
3367
|
});
|
|
2833
3368
|
},
|
|
2834
|
-
/**
|
|
2835
|
-
* 刷新列信息
|
|
2836
|
-
* 将固定的列左边、右边分别靠边
|
|
2837
|
-
*/
|
|
2838
|
-
parseColumns(isReset) {
|
|
2839
|
-
const $xeTable = this;
|
|
2840
|
-
const props = $xeTable;
|
|
2841
|
-
const internalData = $xeTable;
|
|
2842
|
-
const { showOverflow } = props;
|
|
2843
|
-
const rowOpts = $xeTable.computeRowOpts;
|
|
2844
|
-
const leftList = [];
|
|
2845
|
-
const centerList = [];
|
|
2846
|
-
const rightList = [];
|
|
2847
|
-
const { collectColumn, tableFullColumn, isGroup, columnStore, sXOpts, scrollXStore, fullColumnIdData } = this;
|
|
2848
|
-
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
2849
|
-
if (isGroup) {
|
|
2850
|
-
const leftGroupList = [];
|
|
2851
|
-
const centerGroupList = [];
|
|
2852
|
-
const rightGroupList = [];
|
|
2853
|
-
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
2854
|
-
const isColGroup = hasChildrenList(column);
|
|
2855
|
-
// 如果是分组,必须按组设置固定列,不允许给子列设置固定
|
|
2856
|
-
if (parentColumn && parentColumn.fixed) {
|
|
2857
|
-
column.fixed = parentColumn.fixed;
|
|
2858
|
-
}
|
|
2859
|
-
if (parentColumn && column.fixed !== parentColumn.fixed) {
|
|
2860
|
-
errLog('vxe.error.groupFixed');
|
|
2861
|
-
}
|
|
2862
|
-
if (isColGroup) {
|
|
2863
|
-
column.visible = !!XEUtils.findTree(column.children, (subColumn) => hasChildrenList(subColumn) ? null : subColumn.visible);
|
|
2864
|
-
}
|
|
2865
|
-
else if (column.visible) {
|
|
2866
|
-
if (column.fixed === 'left') {
|
|
2867
|
-
leftList.push(column);
|
|
2868
|
-
}
|
|
2869
|
-
else if (column.fixed === 'right') {
|
|
2870
|
-
rightList.push(column);
|
|
2871
|
-
}
|
|
2872
|
-
else {
|
|
2873
|
-
centerList.push(column);
|
|
2874
|
-
}
|
|
2875
|
-
}
|
|
2876
|
-
});
|
|
2877
|
-
collectColumn.forEach((column) => {
|
|
2878
|
-
if (column.visible) {
|
|
2879
|
-
if (column.fixed === 'left') {
|
|
2880
|
-
leftGroupList.push(column);
|
|
2881
|
-
}
|
|
2882
|
-
else if (column.fixed === 'right') {
|
|
2883
|
-
rightGroupList.push(column);
|
|
2884
|
-
}
|
|
2885
|
-
else {
|
|
2886
|
-
centerGroupList.push(column);
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
});
|
|
2890
|
-
this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
|
|
2891
|
-
}
|
|
2892
|
-
else {
|
|
2893
|
-
// 重新分配列
|
|
2894
|
-
tableFullColumn.forEach((column) => {
|
|
2895
|
-
if (column.visible) {
|
|
2896
|
-
if (column.fixed === 'left') {
|
|
2897
|
-
leftList.push(column);
|
|
2898
|
-
}
|
|
2899
|
-
else if (column.fixed === 'right') {
|
|
2900
|
-
rightList.push(column);
|
|
2901
|
-
}
|
|
2902
|
-
else {
|
|
2903
|
-
centerList.push(column);
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
});
|
|
2907
|
-
}
|
|
2908
|
-
const visibleColumn = leftList.concat(centerList).concat(rightList);
|
|
2909
|
-
// 如果gt为0,则总是启用
|
|
2910
|
-
const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length);
|
|
2911
|
-
this.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
|
|
2912
|
-
Object.assign(columnStore, { leftList, centerList, rightList });
|
|
2913
|
-
if (scrollXLoad) {
|
|
2914
|
-
if (showOverflow) {
|
|
2915
|
-
if (!rowOpts.height) {
|
|
2916
|
-
const errColumn = internalData.tableFullColumn.find((column) => column.showOverflow === false);
|
|
2917
|
-
if (errColumn) {
|
|
2918
|
-
errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
if (process.env.NODE_ENV === 'development') {
|
|
2923
|
-
// if (this.showHeader && !this.showHeaderOverflow) {
|
|
2924
|
-
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
2925
|
-
// }
|
|
2926
|
-
// if (this.showFooter && !this.showFooterOverflow) {
|
|
2927
|
-
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
2928
|
-
// }
|
|
2929
|
-
if (this.spanMethod) {
|
|
2930
|
-
warnLog('vxe.error.scrollErrProp', ['span-method']);
|
|
2931
|
-
}
|
|
2932
|
-
if (this.footerSpanMethod) {
|
|
2933
|
-
warnLog('vxe.error.scrollErrProp', ['footer-span-method']);
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
if (isReset) {
|
|
2937
|
-
const { visibleSize } = handleVirtualXVisible(this);
|
|
2938
|
-
scrollXStore.startIndex = 0;
|
|
2939
|
-
scrollXStore.endIndex = visibleSize;
|
|
2940
|
-
scrollXStore.visibleSize = visibleSize;
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
// 如果列被显示/隐藏,则清除合并状态
|
|
2944
|
-
// 如果列被设置为固定,则清除合并状态
|
|
2945
|
-
if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column, index) => column === visibleColumn[index])) {
|
|
2946
|
-
this.clearMergeCells();
|
|
2947
|
-
this.clearMergeFooterItems();
|
|
2948
|
-
}
|
|
2949
|
-
this.scrollXLoad = scrollXLoad;
|
|
2950
|
-
visibleColumn.forEach((column, index) => {
|
|
2951
|
-
const colid = column.id;
|
|
2952
|
-
const colRest = fullColumnIdData[colid];
|
|
2953
|
-
if (colRest) {
|
|
2954
|
-
colRest._index = index;
|
|
2955
|
-
}
|
|
2956
|
-
});
|
|
2957
|
-
this.visibleColumn = visibleColumn;
|
|
2958
|
-
this.handleTableColumn();
|
|
2959
|
-
if (isReset) {
|
|
2960
|
-
return this.updateFooter().then(() => {
|
|
2961
|
-
return this.recalculate();
|
|
2962
|
-
}).then(() => {
|
|
2963
|
-
this.updateCellAreas();
|
|
2964
|
-
return this.recalculate();
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2967
|
-
return this.updateFooter();
|
|
2968
|
-
},
|
|
2969
3369
|
/**
|
|
2970
3370
|
* 指定列宽的列进行拆分
|
|
2971
3371
|
*/
|
|
@@ -3045,376 +3445,114 @@ const Methods = {
|
|
|
3045
3445
|
$xeTable.updateCellAreas();
|
|
3046
3446
|
$xeTable.dispatchEvent('resizable-change', Object.assign(Object.assign({}, params), { resizeWidth }), evnt);
|
|
3047
3447
|
setTimeout(() => $xeTable.recalculate(true), 300);
|
|
3048
|
-
});
|
|
3049
|
-
}
|
|
3050
|
-
},
|
|
3051
|
-
/**
|
|
3052
|
-
* 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
|
|
3053
|
-
*/
|
|
3054
|
-
refreshScroll() {
|
|
3055
|
-
const
|
|
3056
|
-
const
|
|
3057
|
-
const {
|
|
3058
|
-
const
|
|
3059
|
-
const
|
|
3060
|
-
const
|
|
3061
|
-
const
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
}
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
internalData.rceTimeout = undefined;
|
|
3110
|
-
handleRecalculateLayout($xeTable, !!reFull);
|
|
3111
|
-
}, refreshDelay);
|
|
3112
|
-
});
|
|
3113
|
-
},
|
|
3114
|
-
updateStyle() {
|
|
3115
|
-
const $xeTable = this;
|
|
3116
|
-
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;
|
|
3117
|
-
const containerList = ['main', 'left', 'right'];
|
|
3118
|
-
const emptyPlaceholderElem = $refs.emptyPlaceholder;
|
|
3119
|
-
const bodyWrapperElem = elemStore['main-body-wrapper'];
|
|
3120
|
-
if (emptyPlaceholderElem) {
|
|
3121
|
-
emptyPlaceholderElem.style.top = `${headerHeight}px`;
|
|
3122
|
-
emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
|
|
3123
|
-
}
|
|
3124
|
-
if (customHeight > 0) {
|
|
3125
|
-
if (showFooter) {
|
|
3126
|
-
customHeight += scrollbarHeight;
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
|
|
3130
|
-
if (scrollXVirtualEl) {
|
|
3131
|
-
scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
|
|
3132
|
-
}
|
|
3133
|
-
const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
|
|
3134
|
-
if (scrollYVirtualEl) {
|
|
3135
|
-
let bodyHeight = 0;
|
|
3136
|
-
let bodyMaxHeight = 0;
|
|
3137
|
-
const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
|
|
3138
|
-
if (customMaxHeight) {
|
|
3139
|
-
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
|
|
3140
|
-
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
|
|
3141
|
-
}
|
|
3142
|
-
if (customHeight) {
|
|
3143
|
-
bodyHeight = customHeight - headerHeight - footerHeight;
|
|
3144
|
-
if (bodyMaxHeight) {
|
|
3145
|
-
bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
|
|
3146
|
-
}
|
|
3147
|
-
bodyHeight = Math.max(bodyMinHeight, bodyHeight);
|
|
3148
|
-
}
|
|
3149
|
-
scrollYVirtualEl.style.top = `${headerHeight}px`;
|
|
3150
|
-
scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
|
|
3151
|
-
scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`;
|
|
3152
|
-
}
|
|
3153
|
-
containerList.forEach((name, index) => {
|
|
3154
|
-
const fixedType = index > 0 ? name : '';
|
|
3155
|
-
const layoutList = ['header', 'body', 'footer'];
|
|
3156
|
-
const fixedColumn = columnStore[`${fixedType}List`];
|
|
3157
|
-
const fixedWrapperElem = $refs[`${fixedType}Container`];
|
|
3158
|
-
layoutList.forEach(layout => {
|
|
3159
|
-
const wrapperElem = elemStore[`${name}-${layout}-wrapper`];
|
|
3160
|
-
const tableElem = elemStore[`${name}-${layout}-table`];
|
|
3161
|
-
if (layout === 'header') {
|
|
3162
|
-
// 表头体样式处理
|
|
3163
|
-
// 横向滚动渲染
|
|
3164
|
-
let tWidth = tableWidth;
|
|
3165
|
-
let renderColumnList = tableColumn;
|
|
3166
|
-
if (isGroup) {
|
|
3167
|
-
renderColumnList = visibleColumn;
|
|
3168
|
-
}
|
|
3169
|
-
else {
|
|
3170
|
-
if (fixedType) {
|
|
3171
|
-
// 如果是使用优化模式
|
|
3172
|
-
if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
|
|
3173
|
-
// 如果不支持优化模式
|
|
3174
|
-
if (spanMethod || footerSpanMethod) {
|
|
3175
|
-
renderColumnList = visibleColumn;
|
|
3176
|
-
}
|
|
3177
|
-
else {
|
|
3178
|
-
renderColumnList = fixedColumn || [];
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
else {
|
|
3182
|
-
renderColumnList = visibleColumn;
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
}
|
|
3186
|
-
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
3187
|
-
if (tableElem) {
|
|
3188
|
-
tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
|
|
3189
|
-
// 修复 IE 中高度无法自适应问题
|
|
3190
|
-
if (browse.msie) {
|
|
3191
|
-
XEUtils.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), (resizeElem) => {
|
|
3192
|
-
resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`;
|
|
3193
|
-
});
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
3196
|
-
const repairElem = elemStore[`${name}-${layout}-repair`];
|
|
3197
|
-
if (repairElem) {
|
|
3198
|
-
repairElem.style.width = `${tableWidth}px`;
|
|
3199
|
-
}
|
|
3200
|
-
const listElem = elemStore[`${name}-${layout}-list`];
|
|
3201
|
-
if (isGroup && listElem) {
|
|
3202
|
-
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem) => {
|
|
3203
|
-
const colNode = this.getColumnNode(thElem);
|
|
3204
|
-
if (colNode) {
|
|
3205
|
-
const column = colNode.item;
|
|
3206
|
-
const { showHeaderOverflow } = column;
|
|
3207
|
-
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
|
|
3208
|
-
const showEllipsis = cellOverflow === 'ellipsis';
|
|
3209
|
-
const showTitle = cellOverflow === 'title';
|
|
3210
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
3211
|
-
const hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
3212
|
-
let childWidth = 0;
|
|
3213
|
-
let countChild = 0;
|
|
3214
|
-
if (hasEllipsis) {
|
|
3215
|
-
XEUtils.eachTree(column.children, item => {
|
|
3216
|
-
if (!item.children || !column.children.length) {
|
|
3217
|
-
countChild++;
|
|
3218
|
-
}
|
|
3219
|
-
childWidth += item.renderWidth;
|
|
3220
|
-
});
|
|
3221
|
-
}
|
|
3222
|
-
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
|
|
3223
|
-
}
|
|
3224
|
-
});
|
|
3225
|
-
}
|
|
3226
|
-
}
|
|
3227
|
-
else if (layout === 'body') {
|
|
3228
|
-
const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`];
|
|
3229
|
-
if (isNodeElement(wrapperElem)) {
|
|
3230
|
-
let bodyMaxHeight = 0;
|
|
3231
|
-
const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
|
|
3232
|
-
if (customMaxHeight) {
|
|
3233
|
-
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
|
|
3234
|
-
// 如果是固定列
|
|
3235
|
-
if (fixedType) {
|
|
3236
|
-
bodyMaxHeight -= (showFooter ? 0 : scrollbarHeight);
|
|
3237
|
-
}
|
|
3238
|
-
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
|
|
3239
|
-
wrapperElem.style.maxHeight = `${bodyMaxHeight}px`;
|
|
3240
|
-
}
|
|
3241
|
-
if (customHeight) {
|
|
3242
|
-
let bodyHeight = customHeight - headerHeight - footerHeight;
|
|
3243
|
-
// 如果是固定列
|
|
3244
|
-
if (fixedType) {
|
|
3245
|
-
bodyHeight -= (showFooter ? 0 : scrollbarHeight);
|
|
3246
|
-
}
|
|
3247
|
-
if (bodyMaxHeight) {
|
|
3248
|
-
bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
|
|
3249
|
-
}
|
|
3250
|
-
wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`;
|
|
3251
|
-
}
|
|
3252
|
-
else {
|
|
3253
|
-
wrapperElem.style.height = '';
|
|
3254
|
-
}
|
|
3255
|
-
wrapperElem.style.minHeight = `${bodyMinHeight}px`;
|
|
3256
|
-
}
|
|
3257
|
-
// 如果是固定列
|
|
3258
|
-
if (fixedWrapperElem) {
|
|
3259
|
-
const isRightFixed = fixedType === 'right';
|
|
3260
|
-
const fixedColumn = columnStore[`${fixedType}List`];
|
|
3261
|
-
if (isNodeElement(wrapperElem)) {
|
|
3262
|
-
wrapperElem.style.top = `${headerHeight}px`;
|
|
3263
|
-
}
|
|
3264
|
-
fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`;
|
|
3265
|
-
fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`;
|
|
3266
|
-
}
|
|
3267
|
-
let tWidth = tableWidth;
|
|
3268
|
-
let renderColumnList = tableColumn;
|
|
3269
|
-
if (fixedType) {
|
|
3270
|
-
// 如果是使用优化模式
|
|
3271
|
-
if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
|
|
3272
|
-
// 如果不支持优化模式
|
|
3273
|
-
if (expandColumn || spanMethod || footerSpanMethod) {
|
|
3274
|
-
renderColumnList = visibleColumn;
|
|
3275
|
-
}
|
|
3276
|
-
else {
|
|
3277
|
-
renderColumnList = fixedColumn || [];
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
else {
|
|
3281
|
-
renderColumnList = visibleColumn;
|
|
3282
|
-
}
|
|
3283
|
-
}
|
|
3284
|
-
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
3285
|
-
if (tableElem) {
|
|
3286
|
-
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
3287
|
-
// 兼容性处理
|
|
3288
|
-
tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : '';
|
|
3289
|
-
}
|
|
3290
|
-
if (emptyBlockElem) {
|
|
3291
|
-
emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
3292
|
-
}
|
|
3293
|
-
}
|
|
3294
|
-
else if (layout === 'footer') {
|
|
3295
|
-
let tWidth = tableWidth;
|
|
3296
|
-
let renderColumnList = tableColumn;
|
|
3297
|
-
if (fixedType) {
|
|
3298
|
-
// 如果是使用优化模式
|
|
3299
|
-
if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
|
|
3300
|
-
// 如果不支持优化模式
|
|
3301
|
-
if (spanMethod || footerSpanMethod) {
|
|
3302
|
-
renderColumnList = visibleColumn;
|
|
3303
|
-
}
|
|
3304
|
-
else {
|
|
3305
|
-
renderColumnList = fixedColumn || [];
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
else {
|
|
3309
|
-
renderColumnList = visibleColumn;
|
|
3310
|
-
}
|
|
3311
|
-
}
|
|
3312
|
-
tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
|
|
3313
|
-
if (isNodeElement(wrapperElem)) {
|
|
3314
|
-
// 如果是固定列
|
|
3315
|
-
if (fixedWrapperElem) {
|
|
3316
|
-
wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`;
|
|
3317
|
-
}
|
|
3318
|
-
wrapperElem.style.marginTop = `${-scrollbarHeight}px`;
|
|
3319
|
-
}
|
|
3320
|
-
if (tableElem) {
|
|
3321
|
-
tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
|
|
3322
|
-
}
|
|
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));
|
|
3323
3509
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
const colid = colElem.getAttribute('name');
|
|
3328
|
-
if (colid === 'col_gutter') {
|
|
3329
|
-
colElem.style.width = `${scrollbarWidth}px`;
|
|
3330
|
-
}
|
|
3331
|
-
if (fullColumnIdData[colid]) {
|
|
3332
|
-
const colRest = fullColumnIdData[colid];
|
|
3333
|
-
const column = colRest.column;
|
|
3334
|
-
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column;
|
|
3335
|
-
let cellOverflow;
|
|
3336
|
-
colElem.style.width = `${column.renderWidth}px`;
|
|
3337
|
-
if (layout === 'header') {
|
|
3338
|
-
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
|
|
3339
|
-
}
|
|
3340
|
-
else if (layout === 'footer') {
|
|
3341
|
-
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
|
|
3342
|
-
}
|
|
3343
|
-
else {
|
|
3344
|
-
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow;
|
|
3345
|
-
}
|
|
3346
|
-
const showEllipsis = cellOverflow === 'ellipsis';
|
|
3347
|
-
const showTitle = cellOverflow === 'title';
|
|
3348
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
3349
|
-
let hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
3350
|
-
const listElem = elemStore[`${name}-${layout}-list`];
|
|
3351
|
-
// 滚动的渲染不支持动态行高
|
|
3352
|
-
if (layout === 'header' || layout === 'footer') {
|
|
3353
|
-
if (scrollXLoad && !hasEllipsis) {
|
|
3354
|
-
hasEllipsis = true;
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
else {
|
|
3358
|
-
if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
|
|
3359
|
-
hasEllipsis = true;
|
|
3360
|
-
}
|
|
3361
|
-
}
|
|
3362
|
-
if (listElem) {
|
|
3363
|
-
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem) => {
|
|
3364
|
-
const colspan = parseInt(elem.getAttribute('colspan') || 1);
|
|
3365
|
-
const cellElem = elem.querySelector('.vxe-cell');
|
|
3366
|
-
let colWidth = column.renderWidth;
|
|
3367
|
-
if (cellElem) {
|
|
3368
|
-
if (colspan > 1) {
|
|
3369
|
-
const columnIndex = this.getColumnIndex(column);
|
|
3370
|
-
for (let index = 1; index < colspan; index++) {
|
|
3371
|
-
const nextColumn = this.getColumns(columnIndex + index);
|
|
3372
|
-
if (nextColumn) {
|
|
3373
|
-
colWidth += nextColumn.renderWidth;
|
|
3374
|
-
}
|
|
3375
|
-
}
|
|
3376
|
-
}
|
|
3377
|
-
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : '';
|
|
3378
|
-
}
|
|
3379
|
-
});
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3510
|
+
else {
|
|
3511
|
+
$xeTable.$nextTick(() => {
|
|
3512
|
+
resolve();
|
|
3382
3513
|
});
|
|
3383
3514
|
}
|
|
3384
|
-
}
|
|
3515
|
+
}
|
|
3516
|
+
else {
|
|
3517
|
+
resolve(handleRecalculateLayout($xeTable, !!reFull));
|
|
3518
|
+
}
|
|
3519
|
+
internalData.rceTimeout = setTimeout(() => {
|
|
3520
|
+
internalData.rceTimeout = undefined;
|
|
3521
|
+
handleRecalculateLayout($xeTable, !!reFull);
|
|
3522
|
+
}, refreshDelay);
|
|
3385
3523
|
});
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
this.addColSdCls();
|
|
3391
|
-
}
|
|
3392
|
-
return this.$nextTick();
|
|
3524
|
+
},
|
|
3525
|
+
updateStyle() {
|
|
3526
|
+
const $xeTable = this;
|
|
3527
|
+
return updateStyle($xeTable);
|
|
3393
3528
|
},
|
|
3394
3529
|
/**
|
|
3395
3530
|
* 处理固定列的显示状态
|
|
3396
3531
|
*/
|
|
3397
3532
|
checkScrolling() {
|
|
3398
3533
|
const $xeTable = this;
|
|
3399
|
-
const
|
|
3400
|
-
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;
|
|
3401
3539
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
3402
|
-
const bodtTargetEl = xHandleEl ||
|
|
3540
|
+
const bodtTargetEl = xHandleEl || bodyScrollElem;
|
|
3403
3541
|
if (bodtTargetEl) {
|
|
3404
|
-
if (
|
|
3542
|
+
if (leftContainerElem) {
|
|
3405
3543
|
if (bodtTargetEl.scrollLeft > 0) {
|
|
3406
|
-
addClass(
|
|
3544
|
+
addClass(leftContainerElem, 'scrolling--middle');
|
|
3407
3545
|
}
|
|
3408
3546
|
else {
|
|
3409
|
-
removeClass(
|
|
3547
|
+
removeClass(leftContainerElem, 'scrolling--middle');
|
|
3410
3548
|
}
|
|
3411
3549
|
}
|
|
3412
|
-
if (
|
|
3550
|
+
if (rightContainerElem) {
|
|
3413
3551
|
if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
|
|
3414
|
-
addClass(
|
|
3552
|
+
addClass(rightContainerElem, 'scrolling--middle');
|
|
3415
3553
|
}
|
|
3416
3554
|
else {
|
|
3417
|
-
removeClass(
|
|
3555
|
+
removeClass(rightContainerElem, 'scrolling--middle');
|
|
3418
3556
|
}
|
|
3419
3557
|
}
|
|
3420
3558
|
}
|
|
@@ -3448,7 +3586,7 @@ const Methods = {
|
|
|
3448
3586
|
handleGlobalMousedownEvent(evnt) {
|
|
3449
3587
|
const { $el, $refs, $xegrid, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this;
|
|
3450
3588
|
const { actived } = editStore;
|
|
3451
|
-
const {
|
|
3589
|
+
const { refTableMenu, filterWrapper, customWrapper, refValidTooltip } = $refs;
|
|
3452
3590
|
// 筛选
|
|
3453
3591
|
if (filterWrapper) {
|
|
3454
3592
|
if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {
|
|
@@ -3483,7 +3621,7 @@ const Methods = {
|
|
|
3483
3621
|
// 如果是激活状态,点击了单元格之外
|
|
3484
3622
|
const cell = actived.args.cell;
|
|
3485
3623
|
if ((!cell || !getEventTargetNode(evnt, cell).flag)) {
|
|
3486
|
-
if (
|
|
3624
|
+
if (refValidTooltip && getEventTargetNode(evnt, refValidTooltip.$el).flag) {
|
|
3487
3625
|
// 如果是激活状态,且点击了校验提示框
|
|
3488
3626
|
}
|
|
3489
3627
|
else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
|
|
@@ -3534,7 +3672,7 @@ const Methods = {
|
|
|
3534
3672
|
}
|
|
3535
3673
|
}
|
|
3536
3674
|
else if (mouseConfig) {
|
|
3537
|
-
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)) {
|
|
3538
3676
|
if (this.clearSelected) {
|
|
3539
3677
|
this.clearSelected();
|
|
3540
3678
|
}
|
|
@@ -3553,7 +3691,7 @@ const Methods = {
|
|
|
3553
3691
|
}
|
|
3554
3692
|
}
|
|
3555
3693
|
// 如果配置了快捷菜单且,点击了其他地方则关闭
|
|
3556
|
-
if (ctxMenuStore.visible &&
|
|
3694
|
+
if (ctxMenuStore.visible && refTableMenu && !getEventTargetNode(evnt, refTableMenu.$el).flag) {
|
|
3557
3695
|
this.closeMenu();
|
|
3558
3696
|
}
|
|
3559
3697
|
const isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag;
|
|
@@ -3690,8 +3828,8 @@ const Methods = {
|
|
|
3690
3828
|
else if (isContextMenu) {
|
|
3691
3829
|
// 如果按下上下文键
|
|
3692
3830
|
this._keyCtx = selected.row && selected.column && bodyCtxMenu.length;
|
|
3693
|
-
clearTimeout(
|
|
3694
|
-
|
|
3831
|
+
clearTimeout(internalData.keyCtxTimeout);
|
|
3832
|
+
internalData.keyCtxTimeout = setTimeout(() => {
|
|
3695
3833
|
this._keyCtx = false;
|
|
3696
3834
|
}, 1000);
|
|
3697
3835
|
}
|
|
@@ -4056,6 +4194,10 @@ const Methods = {
|
|
|
4056
4194
|
* @param {Row} row 行对象
|
|
4057
4195
|
*/
|
|
4058
4196
|
handleTooltip(evnt, cell, overflowElem, tipElem, params) {
|
|
4197
|
+
const $xeTable = this;
|
|
4198
|
+
if (!overflowElem) {
|
|
4199
|
+
return $xeTable.$nextTick();
|
|
4200
|
+
}
|
|
4059
4201
|
params.cell = cell;
|
|
4060
4202
|
const { $refs, tooltipOpts, tooltipStore } = this;
|
|
4061
4203
|
const { column, row } = params;
|
|
@@ -4082,7 +4224,7 @@ const Methods = {
|
|
|
4082
4224
|
},
|
|
4083
4225
|
openTooltip(target, content) {
|
|
4084
4226
|
const { $refs } = this;
|
|
4085
|
-
const commTip = $refs.
|
|
4227
|
+
const commTip = $refs.refCommTooltip;
|
|
4086
4228
|
if (commTip) {
|
|
4087
4229
|
return commTip.open(target, content);
|
|
4088
4230
|
}
|
|
@@ -4094,7 +4236,7 @@ const Methods = {
|
|
|
4094
4236
|
closeTooltip() {
|
|
4095
4237
|
const { $refs, tooltipStore } = this;
|
|
4096
4238
|
const tooltip = $refs.tooltip;
|
|
4097
|
-
const commTip = $refs.
|
|
4239
|
+
const commTip = $refs.refCommTooltip;
|
|
4098
4240
|
if (tooltipStore.visible) {
|
|
4099
4241
|
Object.assign(tooltipStore, {
|
|
4100
4242
|
row: null,
|
|
@@ -5275,6 +5417,7 @@ const Methods = {
|
|
|
5275
5417
|
this.emitEvent('cell-dblclick', params, evnt);
|
|
5276
5418
|
},
|
|
5277
5419
|
handleDefaultSort() {
|
|
5420
|
+
const $xeTable = this;
|
|
5278
5421
|
const { sortConfig, sortOpts } = this;
|
|
5279
5422
|
let { defaultSort } = sortOpts;
|
|
5280
5423
|
if (defaultSort) {
|
|
@@ -5293,7 +5436,7 @@ const Methods = {
|
|
|
5293
5436
|
}
|
|
5294
5437
|
});
|
|
5295
5438
|
if (!sortOpts.remote) {
|
|
5296
|
-
this.handleTableData(true).then(
|
|
5439
|
+
this.handleTableData(true).then(() => updateStyle($xeTable));
|
|
5297
5440
|
}
|
|
5298
5441
|
}
|
|
5299
5442
|
}
|
|
@@ -5714,8 +5857,8 @@ const Methods = {
|
|
|
5714
5857
|
},
|
|
5715
5858
|
handleColDragSwapColumn() {
|
|
5716
5859
|
const $xeTable = this;
|
|
5717
|
-
$xeTable
|
|
5718
|
-
$xeTable
|
|
5860
|
+
handleUpdateColumn($xeTable);
|
|
5861
|
+
parseColumns($xeTable, false).then(() => {
|
|
5719
5862
|
$xeTable.updateCellAreas();
|
|
5720
5863
|
$xeTable.saveCustomStore('update:sort');
|
|
5721
5864
|
});
|
|
@@ -5941,15 +6084,15 @@ const Methods = {
|
|
|
5941
6084
|
return;
|
|
5942
6085
|
}
|
|
5943
6086
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
5944
|
-
const
|
|
5945
|
-
const tableBodyElem =
|
|
6087
|
+
const refTableBody = $xeTable.$refs.refTableBody;
|
|
6088
|
+
const tableBodyElem = refTableBody ? refTableBody.$el : null;
|
|
5946
6089
|
const scrollTargetEl = xHandleEl || tableBodyElem;
|
|
5947
6090
|
if (scrollTargetEl) {
|
|
5948
6091
|
const wrapperRect = el.getBoundingClientRect();
|
|
5949
6092
|
const tableWidth = el.clientWidth;
|
|
5950
|
-
const leftContainerElem = $xeTable.$refs.
|
|
6093
|
+
const leftContainerElem = $xeTable.$refs.refLeftContainer;
|
|
5951
6094
|
const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
|
|
5952
|
-
const rightContainerElem = $xeTable.$refs.
|
|
6095
|
+
const rightContainerElem = $xeTable.$refs.refRightContainer;
|
|
5953
6096
|
const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
|
|
5954
6097
|
const srartX = wrapperRect.x + leftContainerWidth;
|
|
5955
6098
|
const endX = wrapperRect.x + tableWidth - rightContainerWidth;
|
|
@@ -6073,6 +6216,7 @@ const Methods = {
|
|
|
6073
6216
|
return this.$nextTick();
|
|
6074
6217
|
},
|
|
6075
6218
|
sort(sortConfs, sortOrder) {
|
|
6219
|
+
const $xeTable = this;
|
|
6076
6220
|
const { sortOpts } = this;
|
|
6077
6221
|
const { multiple, remote, orders } = sortOpts;
|
|
6078
6222
|
if (sortConfs) {
|
|
@@ -6115,7 +6259,7 @@ const Methods = {
|
|
|
6115
6259
|
}
|
|
6116
6260
|
return this.$nextTick().then(() => {
|
|
6117
6261
|
this.updateCellAreas();
|
|
6118
|
-
return
|
|
6262
|
+
return updateStyle($xeTable);
|
|
6119
6263
|
});
|
|
6120
6264
|
}
|
|
6121
6265
|
return this.$nextTick();
|
|
@@ -6160,7 +6304,7 @@ const Methods = {
|
|
|
6160
6304
|
}
|
|
6161
6305
|
return $xeTable.$nextTick().then(() => {
|
|
6162
6306
|
$xeTable.updateCellAreas();
|
|
6163
|
-
return $xeTable
|
|
6307
|
+
return updateStyle($xeTable);
|
|
6164
6308
|
});
|
|
6165
6309
|
}
|
|
6166
6310
|
return $xeTable.$nextTick();
|
|
@@ -6171,6 +6315,7 @@ const Methods = {
|
|
|
6171
6315
|
* @param {String} column 列或字段名
|
|
6172
6316
|
*/
|
|
6173
6317
|
clearSort(fieldOrColumn) {
|
|
6318
|
+
const $xeTable = this;
|
|
6174
6319
|
const { sortOpts } = this;
|
|
6175
6320
|
if (fieldOrColumn) {
|
|
6176
6321
|
const column = handleFieldOrColumn(this, fieldOrColumn);
|
|
@@ -6184,7 +6329,7 @@ const Methods = {
|
|
|
6184
6329
|
if (!sortOpts.remote) {
|
|
6185
6330
|
this.handleTableData(true);
|
|
6186
6331
|
}
|
|
6187
|
-
return this.$nextTick().then(
|
|
6332
|
+
return this.$nextTick().then(() => updateStyle($xeTable));
|
|
6188
6333
|
},
|
|
6189
6334
|
// 在 v3 中废弃
|
|
6190
6335
|
getSortColumn() {
|
|
@@ -6685,7 +6830,7 @@ const Methods = {
|
|
|
6685
6830
|
return this.$nextTick().then(() => {
|
|
6686
6831
|
if (transform) {
|
|
6687
6832
|
this.handleTableData();
|
|
6688
|
-
this.
|
|
6833
|
+
this.updateAfterDataIndex();
|
|
6689
6834
|
return this.$nextTick();
|
|
6690
6835
|
}
|
|
6691
6836
|
});
|
|
@@ -6801,7 +6946,7 @@ const Methods = {
|
|
|
6801
6946
|
return this.handleBaseTreeExpand(rows, expanded).then(() => {
|
|
6802
6947
|
handleVirtualTreeToList($xeTable);
|
|
6803
6948
|
this.handleTableData();
|
|
6804
|
-
this.
|
|
6949
|
+
this.updateAfterDataIndex();
|
|
6805
6950
|
}).then(() => {
|
|
6806
6951
|
return this.recalculate();
|
|
6807
6952
|
}).then(() => {
|
|
@@ -6889,7 +7034,7 @@ const Methods = {
|
|
|
6889
7034
|
*/
|
|
6890
7035
|
getScroll() {
|
|
6891
7036
|
const { $refs, scrollXLoad, scrollYLoad } = this;
|
|
6892
|
-
const bodyElem = $refs.
|
|
7037
|
+
const bodyElem = $refs.refTableBody.$el;
|
|
6893
7038
|
return {
|
|
6894
7039
|
virtualX: scrollXLoad,
|
|
6895
7040
|
virtualY: scrollYLoad,
|
|
@@ -6904,15 +7049,18 @@ const Methods = {
|
|
|
6904
7049
|
const internalData = $xeTable;
|
|
6905
7050
|
const { highlightHoverRow } = props;
|
|
6906
7051
|
const { lastScrollLeft, lastScrollTop } = internalData;
|
|
6907
|
-
const
|
|
6908
|
-
const
|
|
7052
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7053
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7054
|
+
if (!xHandleEl || !yHandleEl) {
|
|
7055
|
+
return;
|
|
7056
|
+
}
|
|
6909
7057
|
const rowOpts = $xeTable.computeRowOpts;
|
|
6910
|
-
const validTip = $xeTable.$refs.
|
|
6911
|
-
const tooltip = $xeTable.$refs.
|
|
6912
|
-
const bodyHeight =
|
|
6913
|
-
const bodyWidth =
|
|
6914
|
-
const scrollHeight =
|
|
6915
|
-
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;
|
|
6916
7064
|
let isTop = false;
|
|
6917
7065
|
let isBottom = false;
|
|
6918
7066
|
let isLeft = false;
|
|
@@ -6980,10 +7128,10 @@ const Methods = {
|
|
|
6980
7128
|
if (rowOpts.isHover || highlightHoverRow) {
|
|
6981
7129
|
$xeTable.clearHoverRow();
|
|
6982
7130
|
}
|
|
6983
|
-
if (validTip && validTip.visible) {
|
|
7131
|
+
if (validTip && validTip.reactData.visible) {
|
|
6984
7132
|
validTip.close();
|
|
6985
7133
|
}
|
|
6986
|
-
if (tooltip && tooltip.visible) {
|
|
7134
|
+
if (tooltip && tooltip.reactData.visible) {
|
|
6987
7135
|
tooltip.close();
|
|
6988
7136
|
}
|
|
6989
7137
|
if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
|
|
@@ -6996,7 +7144,7 @@ const Methods = {
|
|
|
6996
7144
|
const internalData = $xeTable;
|
|
6997
7145
|
const { lxTimeout, lxRunTime, scrollXStore } = internalData;
|
|
6998
7146
|
const { visibleSize } = scrollXStore;
|
|
6999
|
-
const fpsTime = Math.min(80, Math.floor(visibleSize * 3));
|
|
7147
|
+
const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)));
|
|
7000
7148
|
if (lxTimeout) {
|
|
7001
7149
|
clearTimeout(lxTimeout);
|
|
7002
7150
|
}
|
|
@@ -7012,10 +7160,12 @@ const Methods = {
|
|
|
7012
7160
|
},
|
|
7013
7161
|
lazyScrollYData() {
|
|
7014
7162
|
const $xeTable = this;
|
|
7163
|
+
const props = $xeTable;
|
|
7015
7164
|
const internalData = $xeTable;
|
|
7165
|
+
const { showOverflow } = props;
|
|
7016
7166
|
const { lyTimeout, lyRunTime, scrollYStore } = internalData;
|
|
7017
7167
|
const { visibleSize } = scrollYStore;
|
|
7018
|
-
const fpsTime = Math.min(80, Math.floor(visibleSize));
|
|
7168
|
+
const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)));
|
|
7019
7169
|
if (lyTimeout) {
|
|
7020
7170
|
clearTimeout(lyTimeout);
|
|
7021
7171
|
}
|
|
@@ -7055,28 +7205,254 @@ const Methods = {
|
|
|
7055
7205
|
$xeTable.lazyScrollYData();
|
|
7056
7206
|
}
|
|
7057
7207
|
},
|
|
7058
|
-
|
|
7208
|
+
triggerBodyScrollEvent(evnt, fixedType) {
|
|
7059
7209
|
const $xeTable = this;
|
|
7060
7210
|
const internalData = $xeTable;
|
|
7061
|
-
const {
|
|
7062
|
-
|
|
7063
|
-
|
|
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) {
|
|
7064
7233
|
return;
|
|
7065
7234
|
}
|
|
7066
|
-
|
|
7067
|
-
|
|
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);
|
|
7068
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;
|
|
7069
7448
|
}
|
|
7070
|
-
const
|
|
7071
|
-
const
|
|
7072
|
-
const
|
|
7073
|
-
const bodyElem = tableBody.$el;
|
|
7074
|
-
const headerElem = tableHeader ? tableHeader.$el : null;
|
|
7075
|
-
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']);
|
|
7076
7452
|
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7077
7453
|
const wrapperEl = evnt.currentTarget;
|
|
7078
7454
|
const { scrollLeft } = wrapperEl;
|
|
7079
|
-
const yBodyEl = yHandleEl ||
|
|
7455
|
+
const yBodyEl = yHandleEl || bodyScrollElem;
|
|
7080
7456
|
let scrollTop = 0;
|
|
7081
7457
|
if (yBodyEl) {
|
|
7082
7458
|
scrollTop = yBodyEl.scrollTop;
|
|
@@ -7084,9 +7460,9 @@ const Methods = {
|
|
|
7084
7460
|
const isRollX = true;
|
|
7085
7461
|
const isRollY = scrollTop !== lastScrollTop;
|
|
7086
7462
|
internalData.inVirtualScroll = true;
|
|
7087
|
-
setScrollLeft(
|
|
7088
|
-
setScrollLeft(
|
|
7089
|
-
setScrollLeft(
|
|
7463
|
+
setScrollLeft(bodyScrollElem, scrollLeft);
|
|
7464
|
+
setScrollLeft(headerScrollElem, scrollLeft);
|
|
7465
|
+
setScrollLeft(footerScrollElem, scrollLeft);
|
|
7090
7466
|
$xeTable.triggerScrollXEvent(evnt);
|
|
7091
7467
|
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7092
7468
|
type: 'table',
|
|
@@ -7096,25 +7472,20 @@ const Methods = {
|
|
|
7096
7472
|
scrollYEvent(evnt) {
|
|
7097
7473
|
const $xeTable = this;
|
|
7098
7474
|
const internalData = $xeTable;
|
|
7099
|
-
const {
|
|
7100
|
-
if (
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
return;
|
|
7106
|
-
}
|
|
7475
|
+
const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
|
|
7476
|
+
if (inHeaderScroll || inBodyScroll || inFooterScroll) {
|
|
7477
|
+
return;
|
|
7478
|
+
}
|
|
7479
|
+
if (inWheelScroll) {
|
|
7480
|
+
return;
|
|
7107
7481
|
}
|
|
7108
|
-
const
|
|
7109
|
-
const
|
|
7110
|
-
const
|
|
7111
|
-
const bodyElem = tableBody.$el;
|
|
7112
|
-
const leftElem = leftBody ? leftBody.$el : null;
|
|
7113
|
-
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']);
|
|
7114
7485
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7115
7486
|
const wrapperEl = evnt.currentTarget;
|
|
7116
7487
|
const { scrollTop } = wrapperEl;
|
|
7117
|
-
const xBodyEl = xHandleEl ||
|
|
7488
|
+
const xBodyEl = xHandleEl || bodyScrollElem;
|
|
7118
7489
|
let scrollLeft = 0;
|
|
7119
7490
|
if (xBodyEl) {
|
|
7120
7491
|
scrollLeft = xBodyEl.scrollLeft;
|
|
@@ -7122,45 +7493,24 @@ const Methods = {
|
|
|
7122
7493
|
const isRollX = scrollLeft !== lastScrollLeft;
|
|
7123
7494
|
const isRollY = true;
|
|
7124
7495
|
internalData.inVirtualScroll = true;
|
|
7125
|
-
setScrollTop(
|
|
7126
|
-
setScrollTop(
|
|
7127
|
-
setScrollTop(
|
|
7496
|
+
setScrollTop(bodyScrollElem, scrollTop);
|
|
7497
|
+
setScrollTop(leftScrollElem, scrollTop);
|
|
7498
|
+
setScrollTop(rightScrollElem, scrollTop);
|
|
7128
7499
|
$xeTable.triggerScrollYEvent(evnt);
|
|
7129
7500
|
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
|
|
7130
7501
|
type: 'table',
|
|
7131
7502
|
fixed: ''
|
|
7132
7503
|
});
|
|
7133
7504
|
},
|
|
7134
|
-
handleTableColumn() {
|
|
7135
|
-
const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this;
|
|
7136
|
-
const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
|
|
7137
|
-
tableColumn.forEach((column, $index) => {
|
|
7138
|
-
const colid = column.id;
|
|
7139
|
-
const colRest = fullColumnIdData[colid];
|
|
7140
|
-
if (colRest) {
|
|
7141
|
-
colRest.$index = $index;
|
|
7142
|
-
}
|
|
7143
|
-
});
|
|
7144
|
-
this.tableColumn = tableColumn;
|
|
7145
|
-
},
|
|
7146
|
-
handleUpdateColumn() {
|
|
7147
|
-
const $xeTable = this;
|
|
7148
|
-
const internalData = $xeTable;
|
|
7149
|
-
const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber');
|
|
7150
|
-
internalData.collectColumn = columnList;
|
|
7151
|
-
const tableFullColumn = getColumnList(columnList);
|
|
7152
|
-
internalData.tableFullColumn = tableFullColumn;
|
|
7153
|
-
cacheColumnMap($xeTable);
|
|
7154
|
-
},
|
|
7155
7505
|
updateScrollXData() {
|
|
7156
7506
|
const $xeTable = this;
|
|
7157
7507
|
const props = $xeTable;
|
|
7158
7508
|
const { showOverflow } = props;
|
|
7159
|
-
$xeTable
|
|
7160
|
-
calcCellHeight(
|
|
7509
|
+
handleTableColumn($xeTable);
|
|
7510
|
+
// calcCellHeight()
|
|
7161
7511
|
return $xeTable.$nextTick().then(() => {
|
|
7162
|
-
calcCellHeight(
|
|
7163
|
-
$xeTable
|
|
7512
|
+
// calcCellHeight()
|
|
7513
|
+
handleTableColumn($xeTable);
|
|
7164
7514
|
$xeTable.updateScrollXSpace();
|
|
7165
7515
|
if (!showOverflow) {
|
|
7166
7516
|
$xeTable.updateScrollYSpace();
|
|
@@ -7170,8 +7520,13 @@ const Methods = {
|
|
|
7170
7520
|
// 更新横向 X 可视渲染上下剩余空间大小
|
|
7171
7521
|
updateScrollXSpace() {
|
|
7172
7522
|
const $xeTable = this;
|
|
7173
|
-
const
|
|
7174
|
-
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;
|
|
7175
7530
|
const tableBodyElem = tableBody ? tableBody.$el : null;
|
|
7176
7531
|
if (tableBodyElem) {
|
|
7177
7532
|
const tableHeaderElem = tableHeader ? tableHeader.$el : null;
|
|
@@ -7195,25 +7550,27 @@ const Methods = {
|
|
|
7195
7550
|
containerList.forEach(name => {
|
|
7196
7551
|
const layoutList = ['header', 'body', 'footer'];
|
|
7197
7552
|
layoutList.forEach(layout => {
|
|
7198
|
-
const xSpaceElem = elemStore[`${name}-${layout}-xSpace`];
|
|
7553
|
+
const xSpaceElem = getRefElem(elemStore[`${name}-${layout}-xSpace`]);
|
|
7199
7554
|
if (xSpaceElem) {
|
|
7200
|
-
xSpaceElem.style.width = scrollXLoad ? `${tableWidth
|
|
7555
|
+
xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : '';
|
|
7201
7556
|
}
|
|
7202
7557
|
});
|
|
7203
7558
|
});
|
|
7204
7559
|
const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem;
|
|
7205
7560
|
if (scrollXSpaceEl) {
|
|
7206
|
-
scrollXSpaceEl.style.width = `${tableWidth
|
|
7561
|
+
scrollXSpaceEl.style.width = `${tableWidth}px`;
|
|
7207
7562
|
}
|
|
7208
|
-
|
|
7563
|
+
$xeTable.$nextTick(() => {
|
|
7564
|
+
updateStyle($xeTable);
|
|
7565
|
+
});
|
|
7209
7566
|
}
|
|
7210
7567
|
},
|
|
7211
7568
|
updateScrollYData() {
|
|
7212
7569
|
const $xeTable = this;
|
|
7213
7570
|
$xeTable.handleTableData();
|
|
7214
|
-
calcCellHeight(
|
|
7571
|
+
// calcCellHeight()
|
|
7215
7572
|
return $xeTable.$nextTick().then(() => {
|
|
7216
|
-
calcCellHeight(
|
|
7573
|
+
// calcCellHeight()
|
|
7217
7574
|
$xeTable.handleTableData();
|
|
7218
7575
|
$xeTable.updateScrollYSpace();
|
|
7219
7576
|
});
|
|
@@ -7221,16 +7578,20 @@ const Methods = {
|
|
|
7221
7578
|
// 更新纵向 Y 可视渲染上下剩余空间大小
|
|
7222
7579
|
updateScrollYSpace() {
|
|
7223
7580
|
const $xeTable = this;
|
|
7224
|
-
const
|
|
7225
|
-
const
|
|
7226
|
-
|
|
7227
|
-
|
|
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']);
|
|
7228
7589
|
const containerList = ['main', 'left', 'right'];
|
|
7229
|
-
let
|
|
7230
|
-
let ySpaceHeight =
|
|
7590
|
+
let topSpaceHeight = 0;
|
|
7591
|
+
let ySpaceHeight = 0;
|
|
7231
7592
|
if (scrollYLoad) {
|
|
7232
7593
|
if (showOverflow) {
|
|
7233
|
-
|
|
7594
|
+
ySpaceHeight = afterFullData.length * rowHeight;
|
|
7234
7595
|
topSpaceHeight = Math.max(0, startIndex * rowHeight);
|
|
7235
7596
|
}
|
|
7236
7597
|
else {
|
|
@@ -7239,7 +7600,7 @@ const Methods = {
|
|
|
7239
7600
|
const rowid = getRowid($xeTable, row);
|
|
7240
7601
|
const rowRest = fullAllDataRowIdData[rowid];
|
|
7241
7602
|
if (rowRest) {
|
|
7242
|
-
|
|
7603
|
+
ySpaceHeight += rowRest.height || rowHeight;
|
|
7243
7604
|
}
|
|
7244
7605
|
}
|
|
7245
7606
|
for (let i = 0; i < startIndex; i++) {
|
|
@@ -7251,27 +7612,32 @@ const Methods = {
|
|
|
7251
7612
|
}
|
|
7252
7613
|
}
|
|
7253
7614
|
}
|
|
7254
|
-
|
|
7255
|
-
|
|
7615
|
+
}
|
|
7616
|
+
else {
|
|
7617
|
+
if (bodyTableElem) {
|
|
7618
|
+
ySpaceHeight = bodyTableElem.clientHeight;
|
|
7619
|
+
}
|
|
7256
7620
|
}
|
|
7257
7621
|
containerList.forEach(name => {
|
|
7258
7622
|
const layoutList = ['header', 'body', 'footer'];
|
|
7259
|
-
const tableElem = elemStore[`${name}-body-table`];
|
|
7623
|
+
const tableElem = getRefElem(elemStore[`${name}-body-table`]);
|
|
7260
7624
|
if (tableElem) {
|
|
7261
|
-
tableElem.style.marginTop =
|
|
7625
|
+
tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : '';
|
|
7262
7626
|
}
|
|
7263
7627
|
layoutList.forEach(layout => {
|
|
7264
|
-
const ySpaceElem = elemStore[`${name}-${layout}-ySpace`];
|
|
7628
|
+
const ySpaceElem = getRefElem(elemStore[`${name}-${layout}-ySpace`]);
|
|
7265
7629
|
if (ySpaceElem) {
|
|
7266
|
-
ySpaceElem.style.height = ySpaceHeight;
|
|
7630
|
+
ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
|
|
7267
7631
|
}
|
|
7268
7632
|
});
|
|
7269
7633
|
});
|
|
7270
7634
|
const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem;
|
|
7271
7635
|
if (scrollYSpaceEl) {
|
|
7272
|
-
scrollYSpaceEl.style.height = ySpaceHeight;
|
|
7636
|
+
scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
|
|
7273
7637
|
}
|
|
7274
|
-
|
|
7638
|
+
$xeTable.$nextTick(() => {
|
|
7639
|
+
updateStyle($xeTable);
|
|
7640
|
+
});
|
|
7275
7641
|
},
|
|
7276
7642
|
updateScrollYStatus() {
|
|
7277
7643
|
const $xeTable = this;
|
|
@@ -7286,12 +7652,12 @@ const Methods = {
|
|
|
7286
7652
|
const $xeTable = this;
|
|
7287
7653
|
const internalData = $xeTable;
|
|
7288
7654
|
const { $refs } = this;
|
|
7289
|
-
const {
|
|
7290
|
-
const tableBodyElem =
|
|
7655
|
+
const { refTableBody, refTableHeader, leftBody, rightBody, refTableFooter } = $refs;
|
|
7656
|
+
const tableBodyElem = refTableBody ? refTableBody.$el : null;
|
|
7291
7657
|
const leftBodyElem = leftBody ? leftBody.$el : null;
|
|
7292
7658
|
const rightBodyElem = rightBody ? rightBody.$el : null;
|
|
7293
|
-
const tableHeaderElem =
|
|
7294
|
-
const tableFooterElem =
|
|
7659
|
+
const tableHeaderElem = refTableHeader ? refTableHeader.$el : null;
|
|
7660
|
+
const tableFooterElem = refTableFooter ? refTableFooter.$el : null;
|
|
7295
7661
|
internalData.intoRunScroll = true;
|
|
7296
7662
|
if (XEUtils.isNumber(scrollLeft)) {
|
|
7297
7663
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
@@ -7396,46 +7762,33 @@ const Methods = {
|
|
|
7396
7762
|
clearScroll() {
|
|
7397
7763
|
const $xeTable = this;
|
|
7398
7764
|
const internalData = $xeTable;
|
|
7399
|
-
const { scrollXStore, scrollYStore } = internalData;
|
|
7400
|
-
const
|
|
7401
|
-
const
|
|
7402
|
-
const
|
|
7403
|
-
const
|
|
7404
|
-
const
|
|
7405
|
-
const leftBodyElem = leftBody ? leftBody.$el : null;
|
|
7406
|
-
const tableBodyElem = tableBody ? tableBody.$el : null;
|
|
7407
|
-
const rightBodyElem = rightBody ? rightBody.$el : null;
|
|
7408
|
-
const tableHeaderElem = tableHeader ? tableHeader.$el : null;
|
|
7409
|
-
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']);
|
|
7410
7771
|
const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
|
|
7411
|
-
if (xHandleEl) {
|
|
7412
|
-
setScrollLeft(xHandleEl, 0);
|
|
7413
|
-
}
|
|
7414
|
-
else {
|
|
7415
|
-
setScrollLeft(tableBodyElem, 0);
|
|
7416
|
-
setScrollLeft(tableHeaderElem, 0);
|
|
7417
|
-
setScrollLeft(tableFooterElem, 0);
|
|
7418
|
-
}
|
|
7419
7772
|
const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
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);
|
|
7428
7782
|
scrollXStore.startIndex = 0;
|
|
7783
|
+
scrollXStore.visibleStartIndex = 0;
|
|
7429
7784
|
scrollXStore.endIndex = scrollXStore.visibleSize;
|
|
7785
|
+
scrollXStore.visibleEndIndex = scrollXStore.visibleSize;
|
|
7430
7786
|
scrollYStore.startIndex = 0;
|
|
7787
|
+
scrollYStore.visibleStartIndex = 0;
|
|
7431
7788
|
scrollYStore.endIndex = scrollYStore.visibleSize;
|
|
7789
|
+
scrollYStore.visibleEndIndex = scrollYStore.visibleSize;
|
|
7432
7790
|
return $xeTable.$nextTick().then(() => {
|
|
7433
|
-
|
|
7434
|
-
setScrollLeft(tableHeaderElem, 0);
|
|
7435
|
-
setScrollLeft(tableFooterElem, 0);
|
|
7436
|
-
setScrollTop(tableBodyElem, 0);
|
|
7437
|
-
setScrollTop(leftBodyElem, 0);
|
|
7438
|
-
setScrollTop(rightBodyElem, 0);
|
|
7791
|
+
internalData.intoRunScroll = false;
|
|
7439
7792
|
});
|
|
7440
7793
|
},
|
|
7441
7794
|
/**
|
|
@@ -7462,8 +7815,8 @@ const Methods = {
|
|
|
7462
7815
|
const customVal = !XEUtils.isUndefined(cellValue);
|
|
7463
7816
|
return this.$nextTick().then(() => {
|
|
7464
7817
|
const { $refs, editRules, validStore } = this;
|
|
7465
|
-
const
|
|
7466
|
-
if (slotParams &&
|
|
7818
|
+
const refTableBody = $refs.refTableBody;
|
|
7819
|
+
if (slotParams && refTableBody && editRules) {
|
|
7467
7820
|
const { row, column } = slotParams;
|
|
7468
7821
|
const type = 'change';
|
|
7469
7822
|
if (this.hasCellRules) {
|
|
@@ -7497,13 +7850,14 @@ const Methods = {
|
|
|
7497
7850
|
* @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
|
|
7498
7851
|
*/
|
|
7499
7852
|
setMergeCells(merges) {
|
|
7853
|
+
const $xeTable = this;
|
|
7500
7854
|
if (this.spanMethod) {
|
|
7501
7855
|
errLog('vxe.error.errConflicts', ['merge-cells', 'span-method']);
|
|
7502
7856
|
}
|
|
7503
7857
|
setMerges(this, merges, this.mergeList, this.afterFullData);
|
|
7504
7858
|
return this.$nextTick().then(() => {
|
|
7505
7859
|
this.updateCellAreas();
|
|
7506
|
-
return
|
|
7860
|
+
return updateStyle($xeTable);
|
|
7507
7861
|
});
|
|
7508
7862
|
},
|
|
7509
7863
|
/**
|
|
@@ -7511,13 +7865,14 @@ const Methods = {
|
|
|
7511
7865
|
* @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
|
|
7512
7866
|
*/
|
|
7513
7867
|
removeMergeCells(merges) {
|
|
7868
|
+
const $xeTable = this;
|
|
7514
7869
|
if (this.spanMethod) {
|
|
7515
7870
|
errLog('vxe.error.errConflicts', ['merge-cells', 'span-method']);
|
|
7516
7871
|
}
|
|
7517
7872
|
const rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
|
|
7518
7873
|
return this.$nextTick().then(() => {
|
|
7519
7874
|
this.updateCellAreas();
|
|
7520
|
-
|
|
7875
|
+
updateStyle($xeTable);
|
|
7521
7876
|
return rest;
|
|
7522
7877
|
});
|
|
7523
7878
|
},
|
|
@@ -7531,32 +7886,35 @@ const Methods = {
|
|
|
7531
7886
|
* 清除所有单元格合并
|
|
7532
7887
|
*/
|
|
7533
7888
|
clearMergeCells() {
|
|
7889
|
+
const $xeTable = this;
|
|
7534
7890
|
this.mergeList = [];
|
|
7535
7891
|
return this.$nextTick().then(() => {
|
|
7536
|
-
return
|
|
7892
|
+
return updateStyle($xeTable);
|
|
7537
7893
|
});
|
|
7538
7894
|
},
|
|
7539
7895
|
handleDefaultMergeFooterItems() {
|
|
7540
7896
|
this.setMergeFooterItems(this.mergeFooterItems);
|
|
7541
7897
|
},
|
|
7542
7898
|
setMergeFooterItems(merges) {
|
|
7899
|
+
const $xeTable = this;
|
|
7543
7900
|
if (this.footerSpanMethod) {
|
|
7544
7901
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
|
|
7545
7902
|
}
|
|
7546
7903
|
setMerges(this, merges, this.mergeFooterList, null);
|
|
7547
7904
|
return this.$nextTick().then(() => {
|
|
7548
7905
|
this.updateCellAreas();
|
|
7549
|
-
return
|
|
7906
|
+
return updateStyle($xeTable);
|
|
7550
7907
|
});
|
|
7551
7908
|
},
|
|
7552
7909
|
removeMergeFooterItems(merges) {
|
|
7910
|
+
const $xeTable = this;
|
|
7553
7911
|
if (this.footerSpanMethod) {
|
|
7554
7912
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
|
|
7555
7913
|
}
|
|
7556
7914
|
const rest = removeMerges(this, merges, this.mergeFooterList, null);
|
|
7557
7915
|
return this.$nextTick().then(() => {
|
|
7558
7916
|
this.updateCellAreas();
|
|
7559
|
-
|
|
7917
|
+
updateStyle($xeTable);
|
|
7560
7918
|
return rest;
|
|
7561
7919
|
});
|
|
7562
7920
|
},
|
|
@@ -7570,9 +7928,10 @@ const Methods = {
|
|
|
7570
7928
|
* 清除所有表尾合并
|
|
7571
7929
|
*/
|
|
7572
7930
|
clearMergeFooterItems() {
|
|
7931
|
+
const $xeTable = this;
|
|
7573
7932
|
this.mergeFooterList = [];
|
|
7574
7933
|
return this.$nextTick().then(() => {
|
|
7575
|
-
return
|
|
7934
|
+
return updateStyle($xeTable);
|
|
7576
7935
|
});
|
|
7577
7936
|
},
|
|
7578
7937
|
updateZindex() {
|