vxe-table 3.14.0 → 3.14.2
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/style.css +1 -1
- package/es/table/module/edit/mixin.js +95 -65
- package/es/table/module/keyboard/mixin.js +3 -2
- package/es/table/module/validator/mixin.js +2 -5
- package/es/table/src/body.js +6 -7
- package/es/table/src/methods.js +301 -286
- package/es/table/src/table.js +21 -15
- package/es/ui/index.js +1 -1
- package/es/ui/src/dom.js +0 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +501 -498
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/edit/mixin.js +108 -99
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +2 -1
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +3 -9
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/body.js +6 -7
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/methods.js +352 -355
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +21 -15
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/dom.js +0 -2
- package/lib/ui/src/dom.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/module/edit/mixin.ts +129 -89
- package/packages/table/module/keyboard/mixin.ts +4 -2
- package/packages/table/module/validator/mixin.ts +3 -6
- package/packages/table/src/body.ts +6 -7
- package/packages/table/src/methods.ts +345 -301
- package/packages/table/src/table.ts +24 -18
- package/packages/table/src/util.ts +2 -2
- package/packages/ui/src/dom.ts +0 -2
- /package/es/{iconfont.1742955973002.ttf → iconfont.1743125678150.ttf} +0 -0
- /package/es/{iconfont.1742955973002.woff → iconfont.1743125678150.woff} +0 -0
- /package/es/{iconfont.1742955973002.woff2 → iconfont.1743125678150.woff2} +0 -0
- /package/lib/{iconfont.1742955973002.ttf → iconfont.1743125678150.ttf} +0 -0
- /package/lib/{iconfont.1742955973002.woff → iconfont.1743125678150.woff} +0 -0
- /package/lib/{iconfont.1742955973002.woff2 → iconfont.1743125678150.woff2} +0 -0
package/es/table/src/methods.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, getOffsetPos, setScrollTop, setScrollLeft, toCssUnit } 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';
|
|
@@ -7,6 +7,7 @@ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible,
|
|
|
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
|
+
const browseObj = XEUtils.browse();
|
|
10
11
|
const supportMaxRow = 5e6;
|
|
11
12
|
const customStorageKey = 'VXE_CUSTOM_STORE';
|
|
12
13
|
const maxYHeight = 5e6;
|
|
@@ -304,12 +305,12 @@ const updateScrollYStatus = ($xeTable, fullData) => {
|
|
|
304
305
|
const reactData = $xeTable;
|
|
305
306
|
const internalData = $xeTable;
|
|
306
307
|
const { treeConfig } = props;
|
|
307
|
-
const
|
|
308
|
+
const virtualYOpts = $xeTable.computeVirtualYOpts;
|
|
308
309
|
const treeOpts = $xeTable.computeTreeOpts;
|
|
309
310
|
const { transform } = treeOpts;
|
|
310
311
|
const allList = fullData || internalData.tableFullData;
|
|
311
312
|
// 如果gt为0,则总是启用
|
|
312
|
-
const scrollYLoad = (transform || !treeConfig) && !!
|
|
313
|
+
const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length);
|
|
313
314
|
reactData.scrollYLoad = scrollYLoad;
|
|
314
315
|
return scrollYLoad;
|
|
315
316
|
};
|
|
@@ -413,7 +414,7 @@ function updateStyle($xeTable) {
|
|
|
413
414
|
const props = $xeTable;
|
|
414
415
|
const reactData = $xeTable;
|
|
415
416
|
const internalData = $xeTable;
|
|
416
|
-
const {
|
|
417
|
+
const { showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props;
|
|
417
418
|
const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, overflowX, scrollbarWidth, overflowY, scrollbarHeight, scrollXWidth, columnStore, editStore, isAllOverflow, expandColumn } = reactData;
|
|
418
419
|
const { visibleColumn, tableHeight, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData;
|
|
419
420
|
const el = $xeTable.$refs.refElem;
|
|
@@ -566,32 +567,6 @@ function updateStyle($xeTable) {
|
|
|
566
567
|
if (tableElem) {
|
|
567
568
|
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
568
569
|
}
|
|
569
|
-
const listElem = getRefElem(elemStore[`${name}-${layout}-list`]);
|
|
570
|
-
if (isGroup && listElem) {
|
|
571
|
-
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem) => {
|
|
572
|
-
const colNode = $xeTable.getColumnNode(thElem);
|
|
573
|
-
if (colNode) {
|
|
574
|
-
const column = colNode.item;
|
|
575
|
-
const { showHeaderOverflow } = column;
|
|
576
|
-
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
|
|
577
|
-
const showEllipsis = cellOverflow === 'ellipsis';
|
|
578
|
-
const showTitle = cellOverflow === 'title';
|
|
579
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
580
|
-
const hasEllipsis = showTitle || showTooltip || showEllipsis;
|
|
581
|
-
let childWidth = 0;
|
|
582
|
-
let countChild = 0;
|
|
583
|
-
if (hasEllipsis) {
|
|
584
|
-
XEUtils.eachTree(column.children, (item) => {
|
|
585
|
-
if (!item.children || !column.children.length) {
|
|
586
|
-
countChild++;
|
|
587
|
-
}
|
|
588
|
-
childWidth += item.renderWidth;
|
|
589
|
-
}, { children: 'children' });
|
|
590
|
-
}
|
|
591
|
-
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
570
|
}
|
|
596
571
|
else if (layout === 'body') {
|
|
597
572
|
if (currScrollElem) {
|
|
@@ -640,7 +615,7 @@ function updateStyle($xeTable) {
|
|
|
640
615
|
if (tableElem) {
|
|
641
616
|
tableElem.style.width = tWidth ? `${tWidth}px` : '';
|
|
642
617
|
// 兼容性处理
|
|
643
|
-
tableElem.style.paddingRight = osbWidth && fixedType && (
|
|
618
|
+
tableElem.style.paddingRight = osbWidth && fixedType && (browseObj['-moz'] || browseObj.safari) ? `${osbWidth}px` : '';
|
|
644
619
|
}
|
|
645
620
|
const emptyBlockElem = getRefElem(elemStore[`${name}-${layout}-emptyBlock`]);
|
|
646
621
|
if (emptyBlockElem) {
|
|
@@ -720,6 +695,106 @@ function handleChangeCell($xeTable, evnt, params) {
|
|
|
720
695
|
.catch((e) => e);
|
|
721
696
|
});
|
|
722
697
|
}
|
|
698
|
+
function handleDefaultSort($xeTable) {
|
|
699
|
+
const props = $xeTable;
|
|
700
|
+
const { sortConfig } = props;
|
|
701
|
+
if (sortConfig) {
|
|
702
|
+
const sortOpts = $xeTable.computeSortOpts;
|
|
703
|
+
let { defaultSort } = sortOpts;
|
|
704
|
+
if (defaultSort) {
|
|
705
|
+
if (!XEUtils.isArray(defaultSort)) {
|
|
706
|
+
defaultSort = [defaultSort];
|
|
707
|
+
}
|
|
708
|
+
if (defaultSort.length) {
|
|
709
|
+
(sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item, index) => {
|
|
710
|
+
const { field, order } = item;
|
|
711
|
+
if (field && order) {
|
|
712
|
+
const column = $xeTable.getColumnByField(field);
|
|
713
|
+
if (column && column.sortable) {
|
|
714
|
+
column.order = order;
|
|
715
|
+
column.sortTime = Date.now() + index;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
if (!sortOpts.remote) {
|
|
720
|
+
$xeTable.handleTableData(true).then(updateStyle);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* 处理默认勾选
|
|
728
|
+
*/
|
|
729
|
+
function handleDefaultSelectionChecked($xeTable) {
|
|
730
|
+
const props = $xeTable;
|
|
731
|
+
const internalData = $xeTable;
|
|
732
|
+
const { checkboxConfig } = props;
|
|
733
|
+
if (checkboxConfig) {
|
|
734
|
+
const { fullDataRowIdData } = internalData;
|
|
735
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
736
|
+
const { checkAll, checkRowKeys } = checkboxOpts;
|
|
737
|
+
if (checkAll) {
|
|
738
|
+
handleCheckedAllCheckboxRow($xeTable, true, true);
|
|
739
|
+
}
|
|
740
|
+
else if (checkRowKeys) {
|
|
741
|
+
const defSelection = [];
|
|
742
|
+
checkRowKeys.forEach((rowid) => {
|
|
743
|
+
if (fullDataRowIdData[rowid]) {
|
|
744
|
+
defSelection.push(fullDataRowIdData[rowid].row);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
handleCheckedCheckboxRow($xeTable, defSelection, true, true);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* 处理单选框默认勾选
|
|
753
|
+
*/
|
|
754
|
+
function handleDefaultRadioChecked($xeTable) {
|
|
755
|
+
const props = $xeTable;
|
|
756
|
+
const internalData = $xeTable;
|
|
757
|
+
const { radioConfig } = props;
|
|
758
|
+
if (radioConfig) {
|
|
759
|
+
const { fullDataRowIdData } = internalData;
|
|
760
|
+
const radioOpts = $xeTable.computeRadioOpts;
|
|
761
|
+
const { checkRowKey: rowid, reserve } = radioOpts;
|
|
762
|
+
if (rowid) {
|
|
763
|
+
if (fullDataRowIdData[rowid]) {
|
|
764
|
+
handleCheckedRadioRow(fullDataRowIdData[rowid].row, true);
|
|
765
|
+
}
|
|
766
|
+
if (reserve) {
|
|
767
|
+
const rowkey = getRowkey($xeTable);
|
|
768
|
+
internalData.radioReserveRow = { [rowkey]: rowid };
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* 处理默认展开行
|
|
775
|
+
*/
|
|
776
|
+
function handleDefaultRowExpand($xeTable) {
|
|
777
|
+
const props = $xeTable;
|
|
778
|
+
const internalData = $xeTable;
|
|
779
|
+
const { expandConfig } = props;
|
|
780
|
+
if (expandConfig) {
|
|
781
|
+
const { fullDataRowIdData } = internalData;
|
|
782
|
+
const expandOpts = $xeTable.computeExpandOpts;
|
|
783
|
+
const { expandAll, expandRowKeys } = expandOpts;
|
|
784
|
+
if (expandAll) {
|
|
785
|
+
$xeTable.setAllRowExpand(true);
|
|
786
|
+
}
|
|
787
|
+
else if (expandRowKeys) {
|
|
788
|
+
const defExpandeds = [];
|
|
789
|
+
expandRowKeys.forEach((rowid) => {
|
|
790
|
+
if (fullDataRowIdData[rowid]) {
|
|
791
|
+
defExpandeds.push(fullDataRowIdData[rowid].row);
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
$xeTable.setRowExpand(defExpandeds, true);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
723
798
|
function handleRadioReserveRow($xeTable, row) {
|
|
724
799
|
const internalData = $xeTable;
|
|
725
800
|
const radioOpts = $xeTable.computeRadioOpts;
|
|
@@ -1188,17 +1263,17 @@ function calculateMergerOffsetIndex(list, offsetItem, type) {
|
|
|
1188
1263
|
}
|
|
1189
1264
|
}
|
|
1190
1265
|
function setMerges($xeTable, merges, mList, rowList) {
|
|
1191
|
-
const props = $xeTable
|
|
1266
|
+
// const props = $xeTable
|
|
1192
1267
|
const internalData = $xeTable;
|
|
1193
1268
|
if (merges) {
|
|
1194
|
-
const { treeConfig } = props
|
|
1269
|
+
// const { treeConfig } = props
|
|
1195
1270
|
const { visibleColumn } = internalData;
|
|
1196
1271
|
if (!XEUtils.isArray(merges)) {
|
|
1197
1272
|
merges = [merges];
|
|
1198
1273
|
}
|
|
1199
|
-
if (treeConfig && merges.length) {
|
|
1200
|
-
|
|
1201
|
-
}
|
|
1274
|
+
// if (treeConfig && merges.length) {
|
|
1275
|
+
// errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1276
|
+
// }
|
|
1202
1277
|
merges.forEach((item) => {
|
|
1203
1278
|
let { row, col, rowspan, colspan } = item;
|
|
1204
1279
|
if (rowList && XEUtils.isNumber(row)) {
|
|
@@ -1239,18 +1314,18 @@ function setMerges($xeTable, merges, mList, rowList) {
|
|
|
1239
1314
|
}
|
|
1240
1315
|
}
|
|
1241
1316
|
function removeMerges($xeTable, merges, mList, rowList) {
|
|
1242
|
-
const props = $xeTable
|
|
1317
|
+
// const props = $xeTable
|
|
1243
1318
|
const internalData = $xeTable;
|
|
1244
1319
|
const rest = [];
|
|
1245
1320
|
if (merges) {
|
|
1246
|
-
const { treeConfig } = props
|
|
1321
|
+
// const { treeConfig } = props
|
|
1247
1322
|
const { visibleColumn } = internalData;
|
|
1248
1323
|
if (!XEUtils.isArray(merges)) {
|
|
1249
1324
|
merges = [merges];
|
|
1250
1325
|
}
|
|
1251
|
-
if (treeConfig && merges.length) {
|
|
1252
|
-
|
|
1253
|
-
}
|
|
1326
|
+
// if (treeConfig && merges.length) {
|
|
1327
|
+
// errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1328
|
+
// }
|
|
1254
1329
|
merges.forEach((item) => {
|
|
1255
1330
|
let { row, col } = item;
|
|
1256
1331
|
if (rowList && XEUtils.isNumber(row)) {
|
|
@@ -1695,7 +1770,7 @@ function hideDropTip($xeTable) {
|
|
|
1695
1770
|
* @param {Event} evnt 事件
|
|
1696
1771
|
* @param {Row} row 行对象
|
|
1697
1772
|
*/
|
|
1698
|
-
function handleTooltip($xeTable, evnt, tdEl, overflowElem, params) {
|
|
1773
|
+
function handleTooltip($xeTable, evnt, tdEl, overflowElem, tipElem, params) {
|
|
1699
1774
|
const reactData = $xeTable;
|
|
1700
1775
|
const tipOverEl = overflowElem || tdEl;
|
|
1701
1776
|
if (!tipOverEl) {
|
|
@@ -1709,7 +1784,8 @@ function handleTooltip($xeTable, evnt, tdEl, overflowElem, params) {
|
|
|
1709
1784
|
const customContent = contentMethod ? contentMethod(params) : null;
|
|
1710
1785
|
const useCustom = contentMethod && !XEUtils.eqNull(customContent);
|
|
1711
1786
|
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ? tipOverEl.innerText : tipOverEl.textContent).trim();
|
|
1712
|
-
|
|
1787
|
+
const isOver = tipOverEl.scrollWidth > tipOverEl.clientWidth;
|
|
1788
|
+
if (content && (showAll || useCustom || isOver)) {
|
|
1713
1789
|
Object.assign(tooltipStore, {
|
|
1714
1790
|
row,
|
|
1715
1791
|
column,
|
|
@@ -1719,7 +1795,7 @@ function handleTooltip($xeTable, evnt, tdEl, overflowElem, params) {
|
|
|
1719
1795
|
$xeTable.$nextTick(() => {
|
|
1720
1796
|
const $tooltip = $xeTable.$refs.refTooltip;
|
|
1721
1797
|
if ($tooltip && $tooltip.open) {
|
|
1722
|
-
$tooltip.open(tipOverEl, formatText(content));
|
|
1798
|
+
$tooltip.open(isOver ? tipOverEl : tipElem, formatText(content));
|
|
1723
1799
|
}
|
|
1724
1800
|
});
|
|
1725
1801
|
}
|
|
@@ -1734,7 +1810,7 @@ function handleScrollToRowColumn($xeTable, fieldOrColumn, row) {
|
|
|
1734
1810
|
}
|
|
1735
1811
|
return $xeTable.$nextTick();
|
|
1736
1812
|
}
|
|
1737
|
-
|
|
1813
|
+
function handleRowExpandReserve($xeTable, row, expanded) {
|
|
1738
1814
|
const internalData = $xeTable;
|
|
1739
1815
|
const { rowExpandedReserveRowMap } = internalData;
|
|
1740
1816
|
const expandOpts = $xeTable.computeExpandOpts;
|
|
@@ -1747,7 +1823,21 @@ const handleRowExpandReserve = ($xeTable, row, expanded) => {
|
|
|
1747
1823
|
delete rowExpandedReserveRowMap[rowid];
|
|
1748
1824
|
}
|
|
1749
1825
|
}
|
|
1750
|
-
}
|
|
1826
|
+
}
|
|
1827
|
+
function handleDefaultMergeCells($xeTable) {
|
|
1828
|
+
const props = $xeTable;
|
|
1829
|
+
const { mergeCells } = props;
|
|
1830
|
+
if (mergeCells) {
|
|
1831
|
+
$xeTable.setMergeCells(mergeCells);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
function handleDefaultMergeFooterItems($xeTable) {
|
|
1835
|
+
const props = $xeTable;
|
|
1836
|
+
const { mergeFooterItems } = props;
|
|
1837
|
+
if (mergeFooterItems) {
|
|
1838
|
+
$xeTable.setMergeFooterItems(mergeFooterItems);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1751
1841
|
// 计算可视渲染相关数据
|
|
1752
1842
|
function computeScrollLoad($xeTable) {
|
|
1753
1843
|
const reactData = $xeTable;
|
|
@@ -1835,6 +1925,26 @@ function handleRecalculateLayout($xeTable, reFull) {
|
|
|
1835
1925
|
}
|
|
1836
1926
|
});
|
|
1837
1927
|
}
|
|
1928
|
+
/**
|
|
1929
|
+
* 处理数据加载默认行为
|
|
1930
|
+
* 默认执行一次,除非被重置
|
|
1931
|
+
*/
|
|
1932
|
+
function handleLoadDefaults($xeTable) {
|
|
1933
|
+
handleDefaultSelectionChecked($xeTable);
|
|
1934
|
+
handleDefaultRadioChecked($xeTable);
|
|
1935
|
+
handleDefaultRowExpand($xeTable);
|
|
1936
|
+
handleDefaultTreeExpand($xeTable);
|
|
1937
|
+
handleDefaultMergeCells($xeTable);
|
|
1938
|
+
handleDefaultMergeFooterItems($xeTable);
|
|
1939
|
+
$xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()));
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* 处理初始化的默认行为
|
|
1943
|
+
* 只会执行一次
|
|
1944
|
+
*/
|
|
1945
|
+
function handleInitDefaults($xeTable) {
|
|
1946
|
+
handleDefaultSort($xeTable);
|
|
1947
|
+
}
|
|
1838
1948
|
function handleTableColumn($xeTable) {
|
|
1839
1949
|
const reactData = $xeTable;
|
|
1840
1950
|
const internalData = $xeTable;
|
|
@@ -1900,7 +2010,7 @@ function parseColumns($xeTable, isReset) {
|
|
|
1900
2010
|
const centerList = [];
|
|
1901
2011
|
const rightList = [];
|
|
1902
2012
|
const { isGroup, columnStore } = reactData;
|
|
1903
|
-
const
|
|
2013
|
+
const virtualXOpts = $xeTable.computeVirtualXOpts;
|
|
1904
2014
|
const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData;
|
|
1905
2015
|
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
1906
2016
|
if (isGroup) {
|
|
@@ -1964,7 +2074,7 @@ function parseColumns($xeTable, isReset) {
|
|
|
1964
2074
|
}
|
|
1965
2075
|
const visibleColumn = leftList.concat(centerList).concat(rightList);
|
|
1966
2076
|
// 如果gt为0,则总是启用
|
|
1967
|
-
const scrollXLoad = !!
|
|
2077
|
+
const scrollXLoad = !!virtualXOpts.enabled && virtualXOpts.gt > -1 && (virtualXOpts.gt === 0 || virtualXOpts.gt < tableFullColumn.length);
|
|
1968
2078
|
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
|
|
1969
2079
|
Object.assign(columnStore, { leftList, centerList, rightList });
|
|
1970
2080
|
if (scrollXLoad) {
|
|
@@ -2539,9 +2649,14 @@ const Methods = {
|
|
|
2539
2649
|
*/
|
|
2540
2650
|
loadTableData(datas, isReset) {
|
|
2541
2651
|
const $xeTable = this;
|
|
2652
|
+
const props = $xeTable;
|
|
2542
2653
|
const reactData = $xeTable;
|
|
2543
2654
|
const internalData = $xeTable;
|
|
2544
|
-
const { keepSource, treeConfig
|
|
2655
|
+
const { keepSource, treeConfig } = props;
|
|
2656
|
+
const { scrollYLoad: oldScrollYLoad } = reactData;
|
|
2657
|
+
const { scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop } = internalData;
|
|
2658
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
2659
|
+
const { transform } = treeOpts;
|
|
2545
2660
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
2546
2661
|
let treeData = [];
|
|
2547
2662
|
let fullData = datas ? datas.slice(0) : [];
|
|
@@ -2550,7 +2665,7 @@ const Methods = {
|
|
|
2550
2665
|
}
|
|
2551
2666
|
if (treeConfig) {
|
|
2552
2667
|
// 树结构自动转换
|
|
2553
|
-
if (
|
|
2668
|
+
if (transform) {
|
|
2554
2669
|
if (!treeOpts.rowField) {
|
|
2555
2670
|
errLog('vxe.error.reqProp', ['table.tree-config.rowField']);
|
|
2556
2671
|
}
|
|
@@ -2589,8 +2704,8 @@ const Methods = {
|
|
|
2589
2704
|
scrollXStore.endIndex = 1;
|
|
2590
2705
|
reactData.isRowLoading = true;
|
|
2591
2706
|
reactData.scrollVMLoading = false;
|
|
2592
|
-
|
|
2593
|
-
|
|
2707
|
+
internalData.insertRowMaps = {};
|
|
2708
|
+
internalData.removeRowMaps = {};
|
|
2594
2709
|
const sYLoad = updateScrollYStatus($xeTable, fullData);
|
|
2595
2710
|
reactData.isDragColMove = false;
|
|
2596
2711
|
reactData.isDragRowMove = false;
|
|
@@ -2608,15 +2723,15 @@ const Methods = {
|
|
|
2608
2723
|
if (keepSource) {
|
|
2609
2724
|
$xeTable.cacheSourceMap(fullData);
|
|
2610
2725
|
}
|
|
2611
|
-
if (
|
|
2612
|
-
|
|
2613
|
-
|
|
2726
|
+
if ($xeTable.clearCellAreas && props.mouseConfig) {
|
|
2727
|
+
$xeTable.clearCellAreas();
|
|
2728
|
+
$xeTable.clearCopyCellArea();
|
|
2614
2729
|
}
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
return
|
|
2730
|
+
$xeTable.clearMergeCells();
|
|
2731
|
+
$xeTable.clearMergeFooterItems();
|
|
2732
|
+
$xeTable.handleTableData(true);
|
|
2733
|
+
$xeTable.updateFooter();
|
|
2734
|
+
return $xeTable.$nextTick().then(() => {
|
|
2620
2735
|
updateHeight($xeTable);
|
|
2621
2736
|
updateStyle($xeTable);
|
|
2622
2737
|
}).then(() => {
|
|
@@ -2629,49 +2744,51 @@ const Methods = {
|
|
|
2629
2744
|
if (sYLoad) {
|
|
2630
2745
|
// if (showOverflow) {
|
|
2631
2746
|
// if (!rowOpts.height) {
|
|
2632
|
-
// const errColumn =
|
|
2747
|
+
// const errColumn = internalData.tableFullColumn.find((column: any) => column.showOverflow === false)
|
|
2633
2748
|
// if (errColumn) {
|
|
2634
2749
|
// errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
2635
2750
|
// }
|
|
2636
2751
|
// }
|
|
2637
2752
|
// }
|
|
2638
|
-
if (!(
|
|
2753
|
+
if (!(props.height || props.maxHeight)) {
|
|
2639
2754
|
errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}']);
|
|
2640
2755
|
}
|
|
2641
|
-
// if (!
|
|
2756
|
+
// if (!props.showOverflow) {
|
|
2642
2757
|
// warnLog('vxe.error.reqProp', ['table.show-overflow'])
|
|
2643
2758
|
// }
|
|
2644
|
-
if (
|
|
2759
|
+
if (props.spanMethod) {
|
|
2645
2760
|
errLog('vxe.error.scrollErrProp', ['table.span-method']);
|
|
2646
2761
|
}
|
|
2647
2762
|
}
|
|
2648
2763
|
handleReserveStatus($xeTable);
|
|
2649
|
-
|
|
2764
|
+
$xeTable.checkSelectionStatus();
|
|
2650
2765
|
return new Promise(resolve => {
|
|
2651
2766
|
this.$nextTick()
|
|
2652
|
-
.then(() =>
|
|
2767
|
+
.then(() => $xeTable.recalculate())
|
|
2653
2768
|
.then(() => {
|
|
2654
2769
|
let targetScrollLeft = lastScrollLeft;
|
|
2655
2770
|
let targetScrollTop = lastScrollTop;
|
|
2771
|
+
const virtualXOpts = $xeTable.computeVirtualXOpts;
|
|
2772
|
+
const virtualYOpts = $xeTable.computeVirtualYOpts;
|
|
2656
2773
|
// 是否在更新数据之后自动滚动重置滚动条
|
|
2657
|
-
if (
|
|
2774
|
+
if (virtualXOpts.scrollToLeftOnChange) {
|
|
2658
2775
|
targetScrollLeft = 0;
|
|
2659
2776
|
}
|
|
2660
|
-
if (
|
|
2777
|
+
if (virtualYOpts.scrollToTopOnChange) {
|
|
2661
2778
|
targetScrollTop = 0;
|
|
2662
2779
|
}
|
|
2663
2780
|
reactData.isRowLoading = false;
|
|
2664
2781
|
calcCellHeight($xeTable);
|
|
2665
2782
|
// 是否变更虚拟滚动
|
|
2666
2783
|
if (oldScrollYLoad === sYLoad) {
|
|
2667
|
-
restoreScrollLocation(
|
|
2784
|
+
restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
|
|
2668
2785
|
.then(() => {
|
|
2669
2786
|
resolve();
|
|
2670
2787
|
});
|
|
2671
2788
|
}
|
|
2672
2789
|
else {
|
|
2673
2790
|
setTimeout(() => {
|
|
2674
|
-
restoreScrollLocation(
|
|
2791
|
+
restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
|
|
2675
2792
|
.then(() => {
|
|
2676
2793
|
resolve();
|
|
2677
2794
|
});
|
|
@@ -2686,12 +2803,13 @@ const Methods = {
|
|
|
2686
2803
|
* @param {Array} datas 数据
|
|
2687
2804
|
*/
|
|
2688
2805
|
loadData(datas) {
|
|
2806
|
+
const $xeTable = this;
|
|
2689
2807
|
const { initStatus } = this;
|
|
2690
2808
|
return this.loadTableData(datas, false).then(() => {
|
|
2691
2809
|
this.inited = true;
|
|
2692
2810
|
this.initStatus = true;
|
|
2693
2811
|
if (!initStatus) {
|
|
2694
|
-
|
|
2812
|
+
handleLoadDefaults($xeTable);
|
|
2695
2813
|
}
|
|
2696
2814
|
return this.recalculate();
|
|
2697
2815
|
});
|
|
@@ -2701,6 +2819,7 @@ const Methods = {
|
|
|
2701
2819
|
* @param {Array} datas 数据
|
|
2702
2820
|
*/
|
|
2703
2821
|
reloadData(datas) {
|
|
2822
|
+
const $xeTable = this;
|
|
2704
2823
|
return this.clearAll()
|
|
2705
2824
|
.then(() => {
|
|
2706
2825
|
this.inited = true;
|
|
@@ -2708,7 +2827,7 @@ const Methods = {
|
|
|
2708
2827
|
return this.loadTableData(datas, true);
|
|
2709
2828
|
})
|
|
2710
2829
|
.then(() => {
|
|
2711
|
-
|
|
2830
|
+
handleLoadDefaults($xeTable);
|
|
2712
2831
|
return this.recalculate();
|
|
2713
2832
|
});
|
|
2714
2833
|
},
|
|
@@ -2864,11 +2983,17 @@ const Methods = {
|
|
|
2864
2983
|
internalData.tableSourceData = sourceData;
|
|
2865
2984
|
},
|
|
2866
2985
|
getParams() {
|
|
2867
|
-
|
|
2986
|
+
const $xeTable = this;
|
|
2987
|
+
const props = $xeTable;
|
|
2988
|
+
return props.params;
|
|
2868
2989
|
},
|
|
2869
2990
|
loadTreeChildren(row, childRecords) {
|
|
2870
2991
|
const $xeTable = this;
|
|
2871
|
-
const
|
|
2992
|
+
const props = $xeTable;
|
|
2993
|
+
const internalData = $xeTable;
|
|
2994
|
+
const { keepSource } = props;
|
|
2995
|
+
const { tableSourceData, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = internalData;
|
|
2996
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
2872
2997
|
const { transform, mapChildrenField } = treeOpts;
|
|
2873
2998
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
2874
2999
|
const parentRest = fullAllDataRowIdData[getRowid($xeTable, row)];
|
|
@@ -2905,18 +3030,22 @@ const Methods = {
|
|
|
2905
3030
|
* @param {Element} tr 元素
|
|
2906
3031
|
*/
|
|
2907
3032
|
getRowNode(tr) {
|
|
3033
|
+
const $xeTable = this;
|
|
3034
|
+
const internalData = $xeTable;
|
|
2908
3035
|
if (tr) {
|
|
2909
|
-
const { fullAllDataRowIdData } =
|
|
3036
|
+
const { fullAllDataRowIdData } = internalData;
|
|
2910
3037
|
const rowid = tr.getAttribute('rowid');
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
3038
|
+
if (rowid) {
|
|
3039
|
+
const rowRest = fullAllDataRowIdData[rowid];
|
|
3040
|
+
if (rowRest) {
|
|
3041
|
+
return {
|
|
3042
|
+
rowid: rowRest.rowid,
|
|
3043
|
+
item: rowRest.row,
|
|
3044
|
+
index: rowRest.index,
|
|
3045
|
+
items: rowRest.items,
|
|
3046
|
+
parent: rowRest.parent
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
2920
3049
|
}
|
|
2921
3050
|
}
|
|
2922
3051
|
return null;
|
|
@@ -2926,8 +3055,10 @@ const Methods = {
|
|
|
2926
3055
|
* @param {Element} cell 元素
|
|
2927
3056
|
*/
|
|
2928
3057
|
getColumnNode(cell) {
|
|
3058
|
+
const $xeTable = this;
|
|
3059
|
+
const internalData = $xeTable;
|
|
2929
3060
|
if (cell) {
|
|
2930
|
-
const { fullColumnIdData } =
|
|
3061
|
+
const { fullColumnIdData } = internalData;
|
|
2931
3062
|
const colid = cell.getAttribute('colid');
|
|
2932
3063
|
if (colid) {
|
|
2933
3064
|
const colRest = fullColumnIdData[colid];
|
|
@@ -3019,14 +3150,21 @@ const Methods = {
|
|
|
3019
3150
|
* @param {Row} records 行数据
|
|
3020
3151
|
*/
|
|
3021
3152
|
defineField(records) {
|
|
3022
|
-
const
|
|
3153
|
+
const $xeTable = this;
|
|
3154
|
+
const props = $xeTable;
|
|
3155
|
+
const internalData = $xeTable;
|
|
3156
|
+
const { treeConfig } = props;
|
|
3157
|
+
const expandOpts = $xeTable.computeExpandOpts;
|
|
3158
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
3159
|
+
const radioOpts = $xeTable.computeRadioOpts;
|
|
3160
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
3023
3161
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
3024
|
-
const rowkey = getRowkey(
|
|
3162
|
+
const rowkey = getRowkey($xeTable);
|
|
3025
3163
|
if (!XEUtils.isArray(records)) {
|
|
3026
3164
|
records = [records || {}];
|
|
3027
3165
|
}
|
|
3028
3166
|
return records.map((record) => {
|
|
3029
|
-
|
|
3167
|
+
internalData.tableFullColumn.forEach(column => {
|
|
3030
3168
|
const { field, editRender } = column;
|
|
3031
3169
|
if (field && !XEUtils.has(record, field)) {
|
|
3032
3170
|
let cellValue = null;
|
|
@@ -3064,8 +3202,9 @@ const Methods = {
|
|
|
3064
3202
|
* @param {Array} records 新数据
|
|
3065
3203
|
*/
|
|
3066
3204
|
createData(records) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3205
|
+
const $xeTable = this;
|
|
3206
|
+
return $xeTable.$nextTick().then(() => {
|
|
3207
|
+
return $xeTable.defineField(records);
|
|
3069
3208
|
});
|
|
3070
3209
|
},
|
|
3071
3210
|
/**
|
|
@@ -3074,11 +3213,12 @@ const Methods = {
|
|
|
3074
3213
|
* @param {Array/Object} records 新数据
|
|
3075
3214
|
*/
|
|
3076
3215
|
createRow(records) {
|
|
3216
|
+
const $xeTable = this;
|
|
3077
3217
|
const isArr = XEUtils.isArray(records);
|
|
3078
3218
|
if (!isArr) {
|
|
3079
3219
|
records = [records];
|
|
3080
3220
|
}
|
|
3081
|
-
return
|
|
3221
|
+
return $xeTable.createData(records).then((rows) => isArr ? rows : rows[0]);
|
|
3082
3222
|
},
|
|
3083
3223
|
/**
|
|
3084
3224
|
* 还原数据
|
|
@@ -3093,9 +3233,7 @@ const Methods = {
|
|
|
3093
3233
|
const reactData = $xeTable;
|
|
3094
3234
|
const internalData = $xeTable;
|
|
3095
3235
|
const { keepSource, treeConfig } = props;
|
|
3096
|
-
const {
|
|
3097
|
-
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData;
|
|
3098
|
-
const removeTempMaps = Object.assign({}, editStore.removeMaps);
|
|
3236
|
+
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData, removeRowMaps } = internalData;
|
|
3099
3237
|
const treeOpts = $xeTable.computeTreeOpts;
|
|
3100
3238
|
const { transform } = treeOpts;
|
|
3101
3239
|
const { handleGetRowId } = createHandleGetRowId($xeTable);
|
|
@@ -3131,7 +3269,9 @@ const Methods = {
|
|
|
3131
3269
|
XEUtils.destructuring(row, XEUtils.clone(oRow, true));
|
|
3132
3270
|
}
|
|
3133
3271
|
if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
|
|
3134
|
-
|
|
3272
|
+
if (removeRowMaps[rowid]) {
|
|
3273
|
+
delete removeRowMaps[rowid];
|
|
3274
|
+
}
|
|
3135
3275
|
tableFullData.unshift(row);
|
|
3136
3276
|
afterFullData.unshift(row);
|
|
3137
3277
|
reDelFlag = true;
|
|
@@ -3143,7 +3283,7 @@ const Methods = {
|
|
|
3143
3283
|
}
|
|
3144
3284
|
if (rows) {
|
|
3145
3285
|
if (reDelFlag) {
|
|
3146
|
-
|
|
3286
|
+
reactData.removeRowFlag++;
|
|
3147
3287
|
$xeTable.updateFooter();
|
|
3148
3288
|
$xeTable.cacheRowMap(false);
|
|
3149
3289
|
$xeTable.handleTableData(treeConfig && transform);
|
|
@@ -3172,7 +3312,9 @@ const Methods = {
|
|
|
3172
3312
|
* @param {String} field 字段名
|
|
3173
3313
|
*/
|
|
3174
3314
|
clearData(rows, field) {
|
|
3175
|
-
const
|
|
3315
|
+
const $xeTable = this;
|
|
3316
|
+
const internalData = $xeTable;
|
|
3317
|
+
const { tableFullData, visibleColumn } = internalData;
|
|
3176
3318
|
if (!arguments.length) {
|
|
3177
3319
|
rows = tableFullData;
|
|
3178
3320
|
}
|
|
@@ -3191,7 +3333,7 @@ const Methods = {
|
|
|
3191
3333
|
});
|
|
3192
3334
|
});
|
|
3193
3335
|
}
|
|
3194
|
-
return
|
|
3336
|
+
return $xeTable.$nextTick();
|
|
3195
3337
|
},
|
|
3196
3338
|
getCellElement(row, fieldOrColumn) {
|
|
3197
3339
|
const $xeTable = this;
|
|
@@ -3282,16 +3424,16 @@ const Methods = {
|
|
|
3282
3424
|
isInsertByRow(row) {
|
|
3283
3425
|
const $xeTable = this;
|
|
3284
3426
|
const reactData = $xeTable;
|
|
3285
|
-
const
|
|
3427
|
+
const internalData = $xeTable;
|
|
3286
3428
|
const rowid = getRowid($xeTable, row);
|
|
3287
|
-
return !!
|
|
3429
|
+
return !!reactData.insertRowFlag && !!internalData.insertRowMaps[rowid];
|
|
3288
3430
|
},
|
|
3289
3431
|
isRemoveByRow(row) {
|
|
3290
3432
|
const $xeTable = this;
|
|
3291
3433
|
const reactData = $xeTable;
|
|
3292
|
-
const
|
|
3434
|
+
const internalData = $xeTable;
|
|
3293
3435
|
const rowid = getRowid($xeTable, row);
|
|
3294
|
-
return !!
|
|
3436
|
+
return !!reactData.removeRowFlag && !!internalData.removeRowMaps[rowid];
|
|
3295
3437
|
},
|
|
3296
3438
|
/**
|
|
3297
3439
|
* 删除所有新增的临时数据
|
|
@@ -3299,9 +3441,8 @@ const Methods = {
|
|
|
3299
3441
|
*/
|
|
3300
3442
|
removeInsertRow() {
|
|
3301
3443
|
const $xeTable = this;
|
|
3302
|
-
const
|
|
3303
|
-
|
|
3304
|
-
editStore.insertMaps = {};
|
|
3444
|
+
const internalData = $xeTable;
|
|
3445
|
+
internalData.insertRowMaps = {};
|
|
3305
3446
|
return $xeTable.remove($xeTable.getInsertRecords());
|
|
3306
3447
|
},
|
|
3307
3448
|
/**
|
|
@@ -3343,14 +3484,17 @@ const Methods = {
|
|
|
3343
3484
|
* @param {Number} columnIndex 索引
|
|
3344
3485
|
*/
|
|
3345
3486
|
getColumns(columnIndex) {
|
|
3346
|
-
const
|
|
3347
|
-
|
|
3487
|
+
const $xeTable = this;
|
|
3488
|
+
const internalData = $xeTable;
|
|
3489
|
+
const { visibleColumn } = internalData;
|
|
3490
|
+
return XEUtils.isUndefined(columnIndex) ? visibleColumn.slice(0) : visibleColumn[columnIndex];
|
|
3348
3491
|
},
|
|
3349
3492
|
/**
|
|
3350
3493
|
* 根据列获取列的唯一主键
|
|
3351
3494
|
*/
|
|
3352
3495
|
getColid(fieldOrColumn) {
|
|
3353
|
-
const
|
|
3496
|
+
const $xeTable = this;
|
|
3497
|
+
const column = handleFieldOrColumn($xeTable, fieldOrColumn);
|
|
3354
3498
|
return column ? column.id : null;
|
|
3355
3499
|
},
|
|
3356
3500
|
/**
|
|
@@ -3358,7 +3502,9 @@ const Methods = {
|
|
|
3358
3502
|
* @param {String} colid 列主键
|
|
3359
3503
|
*/
|
|
3360
3504
|
getColumnById(colid) {
|
|
3361
|
-
const
|
|
3505
|
+
const $xeTable = this;
|
|
3506
|
+
const internalData = $xeTable;
|
|
3507
|
+
const { fullColumnIdData } = internalData;
|
|
3362
3508
|
return fullColumnIdData[colid] ? fullColumnIdData[colid].column : null;
|
|
3363
3509
|
},
|
|
3364
3510
|
/**
|
|
@@ -3366,7 +3512,9 @@ const Methods = {
|
|
|
3366
3512
|
* @param {String} field 字段名
|
|
3367
3513
|
*/
|
|
3368
3514
|
getColumnByField(field) {
|
|
3369
|
-
const
|
|
3515
|
+
const $xeTable = this;
|
|
3516
|
+
const internalData = $xeTable;
|
|
3517
|
+
const { fullColumnFieldData } = internalData;
|
|
3370
3518
|
return fullColumnFieldData[field] ? fullColumnFieldData[field].column : null;
|
|
3371
3519
|
},
|
|
3372
3520
|
getParentColumn(fieldOrColumn) {
|
|
@@ -3379,11 +3527,14 @@ const Methods = {
|
|
|
3379
3527
|
* 收集到的全量列、全量表头列、处理条件之后的全量表头列、当前渲染中的表头列
|
|
3380
3528
|
*/
|
|
3381
3529
|
getTableColumn() {
|
|
3530
|
+
const $xeTable = this;
|
|
3531
|
+
const reactData = $xeTable;
|
|
3532
|
+
const internalData = $xeTable;
|
|
3382
3533
|
return {
|
|
3383
|
-
collectColumn:
|
|
3384
|
-
fullColumn:
|
|
3385
|
-
visibleColumn:
|
|
3386
|
-
tableColumn:
|
|
3534
|
+
collectColumn: internalData.collectColumn.slice(0),
|
|
3535
|
+
fullColumn: internalData.tableFullColumn.slice(0),
|
|
3536
|
+
visibleColumn: internalData.visibleColumn.slice(0),
|
|
3537
|
+
tableColumn: reactData.tableColumn.slice(0)
|
|
3387
3538
|
};
|
|
3388
3539
|
},
|
|
3389
3540
|
/**
|
|
@@ -3796,9 +3947,14 @@ const Methods = {
|
|
|
3796
3947
|
* 如果存在排序,继续处理
|
|
3797
3948
|
*/
|
|
3798
3949
|
getTableData() {
|
|
3799
|
-
const
|
|
3950
|
+
const $xeTable = this;
|
|
3951
|
+
const props = $xeTable;
|
|
3952
|
+
const reactData = $xeTable;
|
|
3953
|
+
const internalData = $xeTable;
|
|
3954
|
+
const { tableData, footerTableData } = reactData;
|
|
3955
|
+
const { tableFullData, afterFullData, tableFullTreeData } = internalData;
|
|
3800
3956
|
return {
|
|
3801
|
-
fullData: treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
|
|
3957
|
+
fullData: props.treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
|
|
3802
3958
|
visibleData: afterFullData.slice(0),
|
|
3803
3959
|
tableData: tableData.slice(0),
|
|
3804
3960
|
footerData: footerTableData.slice(0)
|
|
@@ -3837,35 +3993,15 @@ const Methods = {
|
|
|
3837
3993
|
*/
|
|
3838
3994
|
handleLoadDefaults() {
|
|
3839
3995
|
const $xeTable = this;
|
|
3840
|
-
|
|
3841
|
-
this.handleDefaultSelectionChecked();
|
|
3842
|
-
}
|
|
3843
|
-
if (this.radioConfig) {
|
|
3844
|
-
this.handleDefaultRadioChecked();
|
|
3845
|
-
}
|
|
3846
|
-
if (this.expandConfig) {
|
|
3847
|
-
this.handleDefaultRowExpand();
|
|
3848
|
-
}
|
|
3849
|
-
if (this.treeConfig) {
|
|
3850
|
-
handleDefaultTreeExpand($xeTable);
|
|
3851
|
-
}
|
|
3852
|
-
if (this.mergeCells) {
|
|
3853
|
-
this.handleDefaultMergeCells();
|
|
3854
|
-
}
|
|
3855
|
-
if (this.mergeFooterItems) {
|
|
3856
|
-
this.handleDefaultMergeFooterItems();
|
|
3857
|
-
}
|
|
3858
|
-
this.$nextTick(() => setTimeout(this.recalculate));
|
|
3996
|
+
handleLoadDefaults($xeTable);
|
|
3859
3997
|
},
|
|
3860
3998
|
/**
|
|
3861
3999
|
* 处理初始化的默认行为
|
|
3862
4000
|
* 只会执行一次
|
|
3863
4001
|
*/
|
|
3864
4002
|
handleInitDefaults() {
|
|
3865
|
-
const
|
|
3866
|
-
|
|
3867
|
-
this.handleDefaultSort();
|
|
3868
|
-
}
|
|
4003
|
+
const $xeTable = this;
|
|
4004
|
+
handleInitDefaults($xeTable);
|
|
3869
4005
|
},
|
|
3870
4006
|
/**
|
|
3871
4007
|
* 设置为固定列
|
|
@@ -4021,64 +4157,30 @@ const Methods = {
|
|
|
4021
4157
|
return this.resetCustom(options);
|
|
4022
4158
|
},
|
|
4023
4159
|
handleCustom() {
|
|
4024
|
-
const
|
|
4160
|
+
const $xeTable = this;
|
|
4161
|
+
const props = $xeTable;
|
|
4162
|
+
const { mouseConfig } = props;
|
|
4025
4163
|
if (mouseConfig) {
|
|
4026
|
-
if (
|
|
4027
|
-
|
|
4164
|
+
if ($xeTable.clearSelected) {
|
|
4165
|
+
$xeTable.clearSelected();
|
|
4028
4166
|
}
|
|
4029
|
-
if (
|
|
4030
|
-
|
|
4031
|
-
|
|
4167
|
+
if ($xeTable.clearCellAreas) {
|
|
4168
|
+
$xeTable.clearCellAreas();
|
|
4169
|
+
$xeTable.clearCopyCellArea();
|
|
4032
4170
|
}
|
|
4033
4171
|
}
|
|
4034
|
-
|
|
4035
|
-
return
|
|
4036
|
-
},
|
|
4037
|
-
handleCustomRestore(storeData) {
|
|
4038
|
-
const $xeTable = this;
|
|
4039
|
-
const reactData = $xeTable;
|
|
4040
|
-
const internalData = $xeTable;
|
|
4041
|
-
let { collectColumn } = internalData;
|
|
4042
|
-
const { resizableData, sortData, visibleData, fixedData } = storeData;
|
|
4043
|
-
let hasCustomSort = false;
|
|
4044
|
-
// 处理还原
|
|
4045
|
-
if (resizableData || sortData || visibleData || fixedData) {
|
|
4046
|
-
XEUtils.eachTree(collectColumn, (column, index, items, path, parentRow) => {
|
|
4047
|
-
const colKey = column.getKey();
|
|
4048
|
-
// 支持一级
|
|
4049
|
-
if (!parentRow) {
|
|
4050
|
-
if (fixedData && fixedData[colKey] !== undefined) {
|
|
4051
|
-
column.fixed = fixedData[colKey];
|
|
4052
|
-
}
|
|
4053
|
-
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
4054
|
-
hasCustomSort = true;
|
|
4055
|
-
column.renderSortNumber = sortData[colKey];
|
|
4056
|
-
}
|
|
4057
|
-
}
|
|
4058
|
-
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
4059
|
-
column.resizeWidth = resizableData[colKey];
|
|
4060
|
-
}
|
|
4061
|
-
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
4062
|
-
column.visible = visibleData[colKey];
|
|
4063
|
-
}
|
|
4064
|
-
});
|
|
4065
|
-
// 如果自定义了顺序
|
|
4066
|
-
if (hasCustomSort) {
|
|
4067
|
-
collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber');
|
|
4068
|
-
internalData.collectColumn = collectColumn;
|
|
4069
|
-
internalData.tableFullColumn = getColumnList(collectColumn);
|
|
4070
|
-
}
|
|
4071
|
-
reactData.isCustomStatus = true;
|
|
4072
|
-
}
|
|
4073
|
-
else {
|
|
4074
|
-
reactData.isCustomStatus = false;
|
|
4075
|
-
}
|
|
4172
|
+
$xeTable.analyColumnWidth();
|
|
4173
|
+
return $xeTable.refreshColumn(true);
|
|
4076
4174
|
},
|
|
4077
4175
|
/**
|
|
4078
4176
|
* 还原自定义列操作状态
|
|
4079
4177
|
*/
|
|
4080
4178
|
restoreCustomStorage() {
|
|
4081
|
-
const
|
|
4179
|
+
const $xeTable = this;
|
|
4180
|
+
const props = $xeTable;
|
|
4181
|
+
const { customConfig } = props;
|
|
4182
|
+
const tableId = $xeTable.computeTableId;
|
|
4183
|
+
const customOpts = $xeTable.computeCustomOpts;
|
|
4082
4184
|
const { storage, restoreStore } = customOpts;
|
|
4083
4185
|
const isAllCustom = storage === true;
|
|
4084
4186
|
const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {});
|
|
@@ -4097,11 +4199,11 @@ const Methods = {
|
|
|
4097
4199
|
if (!storeData) {
|
|
4098
4200
|
return;
|
|
4099
4201
|
}
|
|
4100
|
-
return
|
|
4202
|
+
return handleCustomRestore($xeTable, storeData);
|
|
4101
4203
|
}).catch(e => e);
|
|
4102
4204
|
}
|
|
4103
4205
|
else {
|
|
4104
|
-
return
|
|
4206
|
+
return handleCustomRestore($xeTable, storeData);
|
|
4105
4207
|
}
|
|
4106
4208
|
}
|
|
4107
4209
|
},
|
|
@@ -5440,7 +5542,7 @@ const Methods = {
|
|
|
5440
5542
|
return;
|
|
5441
5543
|
}
|
|
5442
5544
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5443
|
-
handleTooltip($xeTable, evnt, thEl, thEl.querySelector('.vxe-cell--title') || cellEl, params);
|
|
5545
|
+
handleTooltip($xeTable, evnt, thEl, thEl.querySelector('.vxe-cell--wrapper'), thEl.querySelector('.vxe-cell--title') || cellEl, params);
|
|
5444
5546
|
}
|
|
5445
5547
|
},
|
|
5446
5548
|
/**
|
|
@@ -5470,7 +5572,7 @@ const Methods = {
|
|
|
5470
5572
|
}
|
|
5471
5573
|
}
|
|
5472
5574
|
if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
|
|
5473
|
-
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper'), params);
|
|
5575
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector('.vxe-cell--wrapper'), tdEl.querySelector('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper'), params);
|
|
5474
5576
|
}
|
|
5475
5577
|
},
|
|
5476
5578
|
/**
|
|
@@ -5484,7 +5586,7 @@ const Methods = {
|
|
|
5484
5586
|
const tdEl = evnt.currentTarget;
|
|
5485
5587
|
handleTargetEnterEvent($xeTable, tooltipStore.column !== column || !!tooltipStore.row);
|
|
5486
5588
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5487
|
-
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper'), params);
|
|
5589
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector('.vxe-cell--wrapper'), tdEl.querySelector('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper'), params);
|
|
5488
5590
|
}
|
|
5489
5591
|
},
|
|
5490
5592
|
openTooltip(target, content) {
|
|
@@ -5564,26 +5666,6 @@ const Methods = {
|
|
|
5564
5666
|
}
|
|
5565
5667
|
return [];
|
|
5566
5668
|
},
|
|
5567
|
-
/**
|
|
5568
|
-
* 处理默认勾选
|
|
5569
|
-
*/
|
|
5570
|
-
handleDefaultSelectionChecked() {
|
|
5571
|
-
const $xeTable = this;
|
|
5572
|
-
const { fullDataRowIdData, checkboxOpts } = this;
|
|
5573
|
-
const { checkAll, checkRowKeys } = checkboxOpts;
|
|
5574
|
-
if (checkAll) {
|
|
5575
|
-
handleCheckedAllCheckboxRow($xeTable, true, true);
|
|
5576
|
-
}
|
|
5577
|
-
else if (checkRowKeys) {
|
|
5578
|
-
const defSelection = [];
|
|
5579
|
-
checkRowKeys.forEach((rowid) => {
|
|
5580
|
-
if (fullDataRowIdData[rowid]) {
|
|
5581
|
-
defSelection.push(fullDataRowIdData[rowid].row);
|
|
5582
|
-
}
|
|
5583
|
-
});
|
|
5584
|
-
handleCheckedCheckboxRow($xeTable, defSelection, true, true);
|
|
5585
|
-
}
|
|
5586
|
-
},
|
|
5587
5669
|
handleCheckedCheckboxRow(rows, value, isForce) {
|
|
5588
5670
|
const $xeTable = this;
|
|
5589
5671
|
return handleCheckedCheckboxRow($xeTable, rows, value, isForce);
|
|
@@ -6167,23 +6249,6 @@ const Methods = {
|
|
|
6167
6249
|
reactData.updateCheckboxFlag++;
|
|
6168
6250
|
return this.$nextTick();
|
|
6169
6251
|
},
|
|
6170
|
-
/**
|
|
6171
|
-
* 处理单选框默认勾选
|
|
6172
|
-
*/
|
|
6173
|
-
handleDefaultRadioChecked() {
|
|
6174
|
-
const $xeTable = this;
|
|
6175
|
-
const { radioOpts, fullDataRowIdData } = this;
|
|
6176
|
-
const { checkRowKey: rowid, reserve } = radioOpts;
|
|
6177
|
-
if (rowid) {
|
|
6178
|
-
if (fullDataRowIdData[rowid]) {
|
|
6179
|
-
handleCheckedRadioRow($xeTable, fullDataRowIdData[rowid].row, true);
|
|
6180
|
-
}
|
|
6181
|
-
if (reserve) {
|
|
6182
|
-
const rowkey = getRowkey(this);
|
|
6183
|
-
this.radioReserveRow = { [rowkey]: rowid };
|
|
6184
|
-
}
|
|
6185
|
-
}
|
|
6186
|
-
},
|
|
6187
6252
|
/**
|
|
6188
6253
|
* 单选,行选中事件
|
|
6189
6254
|
*/
|
|
@@ -6564,31 +6629,6 @@ const Methods = {
|
|
|
6564
6629
|
}
|
|
6565
6630
|
this.emitEvent('cell-dblclick', params, evnt);
|
|
6566
6631
|
},
|
|
6567
|
-
handleDefaultSort() {
|
|
6568
|
-
const $xeTable = this;
|
|
6569
|
-
const { sortConfig, sortOpts } = this;
|
|
6570
|
-
let { defaultSort } = sortOpts;
|
|
6571
|
-
if (defaultSort) {
|
|
6572
|
-
if (!XEUtils.isArray(defaultSort)) {
|
|
6573
|
-
defaultSort = [defaultSort];
|
|
6574
|
-
}
|
|
6575
|
-
if (defaultSort.length) {
|
|
6576
|
-
(sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item, index) => {
|
|
6577
|
-
const { field, order } = item;
|
|
6578
|
-
if (field && order) {
|
|
6579
|
-
const column = this.getColumnByField(field);
|
|
6580
|
-
if (column && column.sortable) {
|
|
6581
|
-
column.order = order;
|
|
6582
|
-
column.sortTime = Date.now() + index;
|
|
6583
|
-
}
|
|
6584
|
-
}
|
|
6585
|
-
});
|
|
6586
|
-
if (!sortOpts.remote) {
|
|
6587
|
-
this.handleTableData(true).then(() => updateStyle($xeTable));
|
|
6588
|
-
}
|
|
6589
|
-
}
|
|
6590
|
-
}
|
|
6591
|
-
},
|
|
6592
6632
|
handleColumnSortEvent(evnt, column) {
|
|
6593
6633
|
const $xeTable = this;
|
|
6594
6634
|
const props = $xeTable;
|
|
@@ -7704,25 +7744,6 @@ const Methods = {
|
|
|
7704
7744
|
toggleRowExpand(row) {
|
|
7705
7745
|
return this.setRowExpand(row, !this.isRowExpandByRow(row));
|
|
7706
7746
|
},
|
|
7707
|
-
/**
|
|
7708
|
-
* 处理默认展开行
|
|
7709
|
-
*/
|
|
7710
|
-
handleDefaultRowExpand() {
|
|
7711
|
-
const { expandOpts, fullDataRowIdData } = this;
|
|
7712
|
-
const { expandAll, expandRowKeys } = expandOpts;
|
|
7713
|
-
if (expandAll) {
|
|
7714
|
-
this.setAllRowExpand(true);
|
|
7715
|
-
}
|
|
7716
|
-
else if (expandRowKeys) {
|
|
7717
|
-
const defExpandeds = [];
|
|
7718
|
-
expandRowKeys.forEach((rowid) => {
|
|
7719
|
-
if (fullDataRowIdData[rowid]) {
|
|
7720
|
-
defExpandeds.push(fullDataRowIdData[rowid].row);
|
|
7721
|
-
}
|
|
7722
|
-
});
|
|
7723
|
-
this.setRowExpand(defExpandeds, true);
|
|
7724
|
-
}
|
|
7725
|
-
},
|
|
7726
7747
|
/**
|
|
7727
7748
|
* 设置所有行的展开与否
|
|
7728
7749
|
* @param {Boolean} expanded 是否展开
|
|
@@ -8299,8 +8320,8 @@ const Methods = {
|
|
|
8299
8320
|
*/
|
|
8300
8321
|
triggerScrollXEvent() {
|
|
8301
8322
|
const $xeTable = this;
|
|
8302
|
-
const
|
|
8303
|
-
if (
|
|
8323
|
+
const virtualXOpts = $xeTable.computeVirtualXOpts;
|
|
8324
|
+
if (virtualXOpts.immediate) {
|
|
8304
8325
|
loadScrollXData($xeTable);
|
|
8305
8326
|
}
|
|
8306
8327
|
else {
|
|
@@ -8312,8 +8333,8 @@ const Methods = {
|
|
|
8312
8333
|
*/
|
|
8313
8334
|
triggerScrollYEvent() {
|
|
8314
8335
|
const $xeTable = this;
|
|
8315
|
-
const
|
|
8316
|
-
if (
|
|
8336
|
+
const virtualYOpts = $xeTable.computeVirtualYOpts;
|
|
8337
|
+
if (virtualYOpts.immediate) {
|
|
8317
8338
|
loadScrollYData($xeTable);
|
|
8318
8339
|
}
|
|
8319
8340
|
else {
|
|
@@ -8522,8 +8543,8 @@ const Methods = {
|
|
|
8522
8543
|
return;
|
|
8523
8544
|
}
|
|
8524
8545
|
const wheelSpeed = getWheelSpeed(reactData.lastScrollTime);
|
|
8525
|
-
const deltaTop =
|
|
8526
|
-
const deltaLeft = Math.ceil((shiftKey ? deltaY : deltaX) * wheelSpeed);
|
|
8546
|
+
const deltaTop = shiftKey ? 0 : Math.ceil(deltaY * wheelSpeed);
|
|
8547
|
+
const deltaLeft = Math.ceil((shiftKey ? (deltaY || deltaX) : deltaX) * wheelSpeed);
|
|
8527
8548
|
const isTopWheel = deltaTop < 0;
|
|
8528
8549
|
const currScrollTop = bodyScrollElem.scrollTop;
|
|
8529
8550
|
// 如果滚动位置已经是顶部或底部,则不需要触发
|
|
@@ -9023,9 +9044,6 @@ const Methods = {
|
|
|
9023
9044
|
}
|
|
9024
9045
|
});
|
|
9025
9046
|
},
|
|
9026
|
-
handleDefaultMergeCells() {
|
|
9027
|
-
this.setMergeCells(this.mergeCells);
|
|
9028
|
-
},
|
|
9029
9047
|
/**
|
|
9030
9048
|
* 设置合并单元格
|
|
9031
9049
|
* @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
|
|
@@ -9073,9 +9091,6 @@ const Methods = {
|
|
|
9073
9091
|
return updateStyle($xeTable);
|
|
9074
9092
|
});
|
|
9075
9093
|
},
|
|
9076
|
-
handleDefaultMergeFooterItems() {
|
|
9077
|
-
this.setMergeFooterItems(this.mergeFooterItems);
|
|
9078
|
-
},
|
|
9079
9094
|
setMergeFooterItems(merges) {
|
|
9080
9095
|
const $xeTable = this;
|
|
9081
9096
|
if (this.footerSpanMethod) {
|