vxe-table 4.1.0 → 4.1.3
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/README.md +1 -0
- package/README.zh-TW.md +1 -0
- package/es/edit/src/hook.js +2 -2
- package/es/export/src/hook.js +24 -0
- package/es/export/src/util.js +20 -8
- package/es/footer/src/footer.js +4 -4
- package/es/form/src/form.js +13 -6
- package/es/form/src/render.js +4 -4
- package/es/grid/src/grid.js +48 -1
- package/es/header/src/header.js +7 -5
- package/es/select/src/select.js +5 -5
- package/es/table/src/body.js +18 -14
- package/es/table/src/cell.js +70 -54
- package/es/table/src/props.js +4 -1
- package/es/table/src/table.js +208 -97
- package/es/v-x-e-table/src/conf.js +2 -3
- package/es/validator/src/hook.js +12 -5
- package/helper/vetur/attributes.json +16 -8
- package/helper/vetur/tags.json +2 -0
- package/lib/edit/src/hook.js +2 -2
- package/lib/edit/src/hook.min.js +1 -1
- package/lib/export/src/hook.js +28 -0
- package/lib/export/src/hook.min.js +1 -1
- package/lib/export/src/util.js +21 -7
- package/lib/export/src/util.min.js +1 -1
- package/lib/footer/src/footer.js +4 -4
- package/lib/footer/src/footer.min.js +1 -1
- package/lib/form/src/form.js +23 -6
- package/lib/form/src/form.min.js +1 -1
- package/lib/form/src/render.js +4 -4
- package/lib/form/src/render.min.js +1 -1
- package/lib/grid/src/grid.js +56 -1
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/header/src/header.js +7 -5
- package/lib/header/src/header.min.js +1 -1
- package/lib/index.umd.js +536 -220
- package/lib/index.umd.min.js +1 -1
- package/lib/select/src/select.js +5 -5
- package/lib/table/src/body.js +18 -14
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +92 -35
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/props.js +4 -1
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +265 -133
- package/lib/table/src/table.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +2 -3
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/lib/validator/src/hook.js +12 -5
- package/lib/validator/src/hook.min.js +1 -1
- package/package.json +2 -2
- package/packages/edit/src/hook.ts +2 -2
- package/packages/export/src/hook.ts +24 -0
- package/packages/export/src/util.ts +17 -5
- package/packages/footer/src/footer.ts +4 -4
- package/packages/form/src/form.ts +10 -6
- package/packages/form/src/render.ts +4 -4
- package/packages/grid/src/grid.ts +48 -1
- package/packages/header/src/header.ts +7 -5
- package/packages/select/src/select.ts +5 -5
- package/packages/table/src/body.ts +18 -14
- package/packages/table/src/cell.ts +77 -44
- package/packages/table/src/props.ts +4 -1
- package/packages/table/src/table.ts +211 -96
- package/packages/v-x-e-table/src/conf.ts +2 -3
- package/packages/validator/src/hook.ts +9 -5
- package/types/column.d.ts +5 -1
- package/types/form-item.d.ts +5 -1
- package/types/form.d.ts +5 -1
- package/types/modal.d.ts +4 -5
- package/types/table.d.ts +49 -14
- package/types/validator.d.ts +5 -1
package/es/table/src/table.js
CHANGED
|
@@ -266,6 +266,7 @@ export default defineComponent({
|
|
|
266
266
|
treeExpandedReserveRowMap: {},
|
|
267
267
|
// 完整数据、条件处理后
|
|
268
268
|
tableFullData: [],
|
|
269
|
+
treeFullData: [],
|
|
269
270
|
afterFullData: [],
|
|
270
271
|
tableSynchData: [],
|
|
271
272
|
tableSourceData: [],
|
|
@@ -327,7 +328,10 @@ export default defineComponent({
|
|
|
327
328
|
};
|
|
328
329
|
});
|
|
329
330
|
var computeColumnOpts = computed(function () {
|
|
330
|
-
return Object.assign({}, props.columnConfig);
|
|
331
|
+
return Object.assign({}, GlobalConfig.table.columnConfig, props.columnConfig);
|
|
332
|
+
});
|
|
333
|
+
var computeRowOpts = computed(function () {
|
|
334
|
+
return Object.assign({}, GlobalConfig.table.rowConfig, props.rowConfig);
|
|
331
335
|
});
|
|
332
336
|
var computeResizableOpts = computed(function () {
|
|
333
337
|
return Object.assign({}, GlobalConfig.table.resizableConfig, props.resizableConfig);
|
|
@@ -500,6 +504,8 @@ export default defineComponent({
|
|
|
500
504
|
computeValidOpts: computeValidOpts,
|
|
501
505
|
computeSXOpts: computeSXOpts,
|
|
502
506
|
computeSYOpts: computeSYOpts,
|
|
507
|
+
computeColumnOpts: computeColumnOpts,
|
|
508
|
+
computeRowOpts: computeRowOpts,
|
|
503
509
|
computeResizableOpts: computeResizableOpts,
|
|
504
510
|
computeSeqOpts: computeSeqOpts,
|
|
505
511
|
computeRadioOpts: computeRadioOpts,
|
|
@@ -1084,7 +1090,7 @@ export default defineComponent({
|
|
|
1084
1090
|
rest._index = _index;
|
|
1085
1091
|
}
|
|
1086
1092
|
else {
|
|
1087
|
-
fullDataRowIdData[rowid] = { row: row, rowid: rowid, index: -1, $index: -1, _index: _index, items: [], parent: null };
|
|
1093
|
+
fullDataRowIdData[rowid] = { row: row, rowid: rowid, index: -1, $index: -1, _index: _index, items: [], parent: null, level: 0 };
|
|
1088
1094
|
}
|
|
1089
1095
|
});
|
|
1090
1096
|
};
|
|
@@ -1284,7 +1290,7 @@ export default defineComponent({
|
|
|
1284
1290
|
var tWidth = tableWidth;
|
|
1285
1291
|
// 如果是使用优化模式
|
|
1286
1292
|
if (fixedType) {
|
|
1287
|
-
if (
|
|
1293
|
+
if (scrollYLoad || (allColumnOverflow ? isAllOverflow : allColumnOverflow)) {
|
|
1288
1294
|
if (!mergeList.length && !spanMethod && !(keyboardConfig && keyboardOpts.isMerge)) {
|
|
1289
1295
|
tableColumn = fixedColumn;
|
|
1290
1296
|
}
|
|
@@ -1376,16 +1382,9 @@ export default defineComponent({
|
|
|
1376
1382
|
var showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
|
|
1377
1383
|
var hasEllipsis_1 = showTitle || showTooltip || showEllipsis;
|
|
1378
1384
|
var listElem = elemStore[name + "-" + layout + "-list"];
|
|
1379
|
-
//
|
|
1380
|
-
if (
|
|
1381
|
-
|
|
1382
|
-
hasEllipsis_1 = true;
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
else {
|
|
1386
|
-
if ((scrollXLoad || scrollYLoad) && !hasEllipsis_1) {
|
|
1387
|
-
hasEllipsis_1 = true;
|
|
1388
|
-
}
|
|
1385
|
+
// 纵向虚拟滚动不支持动态行高
|
|
1386
|
+
if (scrollYLoad && !hasEllipsis_1) {
|
|
1387
|
+
hasEllipsis_1 = true;
|
|
1389
1388
|
}
|
|
1390
1389
|
if (listElem) {
|
|
1391
1390
|
XEUtils.arrayEach(listElem.querySelectorAll("." + column_2.id), function (elem) {
|
|
@@ -1634,7 +1633,7 @@ export default defineComponent({
|
|
|
1634
1633
|
childRecords = [];
|
|
1635
1634
|
}
|
|
1636
1635
|
if (childRecords) {
|
|
1637
|
-
tableMethods.
|
|
1636
|
+
tableMethods.loadTreeChildren(row, childRecords).then(function (childRows) {
|
|
1638
1637
|
if (childRows.length && $xetable.findRowIndexOf(treeExpandeds, row) === -1) {
|
|
1639
1638
|
treeExpandeds.push(row);
|
|
1640
1639
|
}
|
|
@@ -1755,39 +1754,57 @@ export default defineComponent({
|
|
|
1755
1754
|
var keepSource = props.keepSource, treeConfig = props.treeConfig;
|
|
1756
1755
|
var editStore = reactData.editStore, oldScrollYLoad = reactData.scrollYLoad;
|
|
1757
1756
|
var scrollYStore = internalData.scrollYStore, scrollXStore = internalData.scrollXStore, lastScrollLeft = internalData.lastScrollLeft, lastScrollTop = internalData.lastScrollTop;
|
|
1758
|
-
var sYOpts = computeSYOpts.value;
|
|
1759
1757
|
var treeOpts = computeTreeOpts.value;
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1758
|
+
var transform = treeOpts.transform;
|
|
1759
|
+
var treeData = [];
|
|
1760
|
+
var fullData = datas ? datas.slice(0) : [];
|
|
1761
|
+
if (treeConfig) {
|
|
1762
|
+
if (transform) {
|
|
1763
|
+
// 树结构自动转换
|
|
1764
|
+
if (process.env.NODE_ENV === 'development') {
|
|
1765
|
+
if (!treeOpts.rowField) {
|
|
1766
|
+
errLog('vxe.error.reqProp', ['tree-config.rowField']);
|
|
1767
|
+
}
|
|
1768
|
+
if (!treeOpts.parentField) {
|
|
1769
|
+
errLog('vxe.error.reqProp', ['tree-config.parentField']);
|
|
1770
|
+
}
|
|
1771
|
+
if (!treeOpts.children) {
|
|
1772
|
+
errLog('vxe.error.reqProp', ['tree-config.children']);
|
|
1773
|
+
}
|
|
1774
|
+
fullData.forEach(function (row) {
|
|
1775
|
+
if (row[treeOpts.children] && row[treeOpts.children].length) {
|
|
1776
|
+
warnLog('vxe.error.errConflicts', ['tree-config.transform', "row." + treeOpts.children]);
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1767
1779
|
}
|
|
1780
|
+
treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.rowField, parentKey: treeOpts.parentField, children: treeOpts.children });
|
|
1781
|
+
fullData = treeData.slice(0);
|
|
1782
|
+
}
|
|
1783
|
+
else {
|
|
1784
|
+
treeData = fullData.slice(0);
|
|
1768
1785
|
}
|
|
1769
|
-
datas = XEUtils.toArrayTree(datas, { key: treeOpts.rowtKey, parentKey: treeOpts.parentKey, children: treeOpts.children });
|
|
1770
1786
|
}
|
|
1771
|
-
var tableFullData = datas ? datas.slice(0) : [];
|
|
1772
|
-
var scrollYLoad = !treeConfig && !!sYOpts.enabled && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length;
|
|
1773
1787
|
scrollYStore.startIndex = 0;
|
|
1774
1788
|
scrollYStore.endIndex = 1;
|
|
1775
1789
|
scrollXStore.startIndex = 0;
|
|
1776
1790
|
scrollXStore.endIndex = 1;
|
|
1777
1791
|
editStore.insertList = [];
|
|
1778
1792
|
editStore.removeList = [];
|
|
1793
|
+
var sYLoad = updateScrollYStatus(fullData);
|
|
1794
|
+
reactData.scrollYLoad = sYLoad;
|
|
1779
1795
|
// 全量数据
|
|
1780
|
-
internalData.tableFullData =
|
|
1796
|
+
internalData.tableFullData = fullData;
|
|
1797
|
+
internalData.treeFullData = treeData;
|
|
1781
1798
|
// 缓存数据
|
|
1782
|
-
tablePrivateMethods.
|
|
1799
|
+
tablePrivateMethods.cacheRowMap(true);
|
|
1783
1800
|
// 原始数据
|
|
1784
1801
|
internalData.tableSynchData = datas;
|
|
1802
|
+
// 克隆原数据,用于显示编辑状态,与编辑值做对比
|
|
1785
1803
|
if (keepSource) {
|
|
1786
|
-
internalData.tableSourceData = XEUtils.clone(
|
|
1804
|
+
internalData.tableSourceData = XEUtils.clone(fullData, true);
|
|
1787
1805
|
}
|
|
1788
|
-
reactData.scrollYLoad = scrollYLoad;
|
|
1789
1806
|
if (process.env.NODE_ENV === 'development') {
|
|
1790
|
-
if (
|
|
1807
|
+
if (sYLoad) {
|
|
1791
1808
|
if (!(props.height || props.maxHeight)) {
|
|
1792
1809
|
errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}']);
|
|
1793
1810
|
}
|
|
@@ -1813,8 +1830,8 @@ export default defineComponent({
|
|
|
1813
1830
|
}).then(function () {
|
|
1814
1831
|
computeScrollLoad();
|
|
1815
1832
|
}).then(function () {
|
|
1816
|
-
//
|
|
1817
|
-
if (
|
|
1833
|
+
// 是否启用了虚拟滚动
|
|
1834
|
+
if (sYLoad) {
|
|
1818
1835
|
scrollYStore.endIndex = scrollYStore.visibleSize;
|
|
1819
1836
|
}
|
|
1820
1837
|
handleReserveStatus();
|
|
@@ -1824,7 +1841,7 @@ export default defineComponent({
|
|
|
1824
1841
|
.then(function () { return tableMethods.recalculate(); })
|
|
1825
1842
|
.then(function () {
|
|
1826
1843
|
// 是否变更虚拟滚动
|
|
1827
|
-
if (oldScrollYLoad ===
|
|
1844
|
+
if (oldScrollYLoad === sYLoad) {
|
|
1828
1845
|
restoreScrollLocation($xetable, lastScrollLeft, lastScrollTop).then(resolve);
|
|
1829
1846
|
}
|
|
1830
1847
|
else {
|
|
@@ -2041,6 +2058,95 @@ export default defineComponent({
|
|
|
2041
2058
|
return tableMethods.recalculate();
|
|
2042
2059
|
});
|
|
2043
2060
|
};
|
|
2061
|
+
var updateScrollYStatus = function (fullData) {
|
|
2062
|
+
var treeConfig = props.treeConfig;
|
|
2063
|
+
var sYOpts = computeSYOpts.value;
|
|
2064
|
+
var treeOpts = computeTreeOpts.value;
|
|
2065
|
+
var transform = treeOpts.transform;
|
|
2066
|
+
var scrollYLoad = (transform || !treeConfig) && !!sYOpts.enabled && sYOpts.gt > -1 && sYOpts.gt < fullData.length;
|
|
2067
|
+
reactData.scrollYLoad = scrollYLoad;
|
|
2068
|
+
return scrollYLoad;
|
|
2069
|
+
};
|
|
2070
|
+
var updateVirtualTreeData = function () {
|
|
2071
|
+
var oldScrollYLoad = reactData.scrollYLoad, treeExpandeds = reactData.treeExpandeds;
|
|
2072
|
+
var treeFullData = internalData.treeFullData;
|
|
2073
|
+
var treeOpts = computeTreeOpts.value;
|
|
2074
|
+
var fullData = [];
|
|
2075
|
+
XEUtils.eachTree(treeFullData, function (row, index, items, path, parent) {
|
|
2076
|
+
if (!parent || $xetable.findRowIndexOf(treeExpandeds, parent) > -1) {
|
|
2077
|
+
fullData.push(row);
|
|
2078
|
+
}
|
|
2079
|
+
}, treeOpts);
|
|
2080
|
+
var scrollYLoad = updateScrollYStatus(fullData);
|
|
2081
|
+
internalData.tableFullData = scrollYLoad ? fullData : treeFullData;
|
|
2082
|
+
if (scrollYLoad || oldScrollYLoad !== scrollYLoad) {
|
|
2083
|
+
return tablePrivateMethods.handleTableData(true).then(function () { return tableMethods.recalculate(); });
|
|
2084
|
+
}
|
|
2085
|
+
return nextTick();
|
|
2086
|
+
};
|
|
2087
|
+
/**
|
|
2088
|
+
* 展开与收起树节点
|
|
2089
|
+
* @param rows
|
|
2090
|
+
* @param expanded
|
|
2091
|
+
* @returns
|
|
2092
|
+
*/
|
|
2093
|
+
var handleBaseTreeExpand = function (rows, expanded) {
|
|
2094
|
+
var treeExpandeds = reactData.treeExpandeds, treeLazyLoadeds = reactData.treeLazyLoadeds, treeNodeColumn = reactData.treeNodeColumn;
|
|
2095
|
+
var fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData;
|
|
2096
|
+
var treeOpts = computeTreeOpts.value;
|
|
2097
|
+
var reserve = treeOpts.reserve, lazy = treeOpts.lazy, hasChild = treeOpts.hasChild, children = treeOpts.children, accordion = treeOpts.accordion, toggleMethod = treeOpts.toggleMethod;
|
|
2098
|
+
var result = [];
|
|
2099
|
+
var columnIndex = tableMethods.getColumnIndex(treeNodeColumn);
|
|
2100
|
+
var $columnIndex = tableMethods.getVMColumnIndex(treeNodeColumn);
|
|
2101
|
+
var validRows = toggleMethod ? rows.filter(function (row) { return toggleMethod({ $table: $xetable, expanded: expanded, column: treeNodeColumn, columnIndex: columnIndex, $columnIndex: $columnIndex, row: row }); }) : rows;
|
|
2102
|
+
if (accordion) {
|
|
2103
|
+
validRows = validRows.length ? [validRows[validRows.length - 1]] : [];
|
|
2104
|
+
// 同一级只能展开一个
|
|
2105
|
+
var matchObj_1 = XEUtils.findTree(tableFullData, function (item) { return item === validRows[0]; }, treeOpts);
|
|
2106
|
+
if (matchObj_1) {
|
|
2107
|
+
XEUtils.remove(treeExpandeds, function (item) { return matchObj_1.items.indexOf(item) > -1; });
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
if (expanded) {
|
|
2111
|
+
validRows.forEach(function (row) {
|
|
2112
|
+
if ($xetable.findRowIndexOf(treeExpandeds, row) === -1) {
|
|
2113
|
+
var rest = fullAllDataRowIdData[getRowid($xetable, row)];
|
|
2114
|
+
var isLoad = lazy && row[hasChild] && !rest.treeLoaded && $xetable.findRowIndexOf(treeLazyLoadeds, row) === -1;
|
|
2115
|
+
// 是否使用懒加载
|
|
2116
|
+
if (isLoad) {
|
|
2117
|
+
result.push(handleAsyncTreeExpandChilds(row));
|
|
2118
|
+
}
|
|
2119
|
+
else {
|
|
2120
|
+
if (row[children] && row[children].length) {
|
|
2121
|
+
treeExpandeds.push(row);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
XEUtils.remove(treeExpandeds, function (row) { return $xetable.findRowIndexOf(validRows, row) > -1; });
|
|
2129
|
+
}
|
|
2130
|
+
if (reserve) {
|
|
2131
|
+
validRows.forEach(function (row) { return handleTreeExpandReserve(row, expanded); });
|
|
2132
|
+
}
|
|
2133
|
+
return Promise.all(result).then(function () {
|
|
2134
|
+
return tableMethods.recalculate();
|
|
2135
|
+
});
|
|
2136
|
+
};
|
|
2137
|
+
/**
|
|
2138
|
+
* 虚拟树的展开与收起
|
|
2139
|
+
* @param rows
|
|
2140
|
+
* @param expanded
|
|
2141
|
+
* @returns
|
|
2142
|
+
*/
|
|
2143
|
+
var handleVirtualTreeExpand = function (rows, expanded) {
|
|
2144
|
+
return handleBaseTreeExpand(rows, expanded).then(function () {
|
|
2145
|
+
return updateVirtualTreeData();
|
|
2146
|
+
}).then(function () {
|
|
2147
|
+
return tableMethods.recalculate();
|
|
2148
|
+
});
|
|
2149
|
+
};
|
|
2044
2150
|
/**
|
|
2045
2151
|
* 纵向 Y 可视渲染处理
|
|
2046
2152
|
*/
|
|
@@ -2159,7 +2265,7 @@ export default defineComponent({
|
|
|
2159
2265
|
tableSourceData[rowIndex] = record;
|
|
2160
2266
|
XEUtils.clear(row, undefined);
|
|
2161
2267
|
Object.assign(row, tablePrivateMethods.defineField(Object.assign({}, record)));
|
|
2162
|
-
tablePrivateMethods.
|
|
2268
|
+
tablePrivateMethods.cacheRowMap(true);
|
|
2163
2269
|
}
|
|
2164
2270
|
else {
|
|
2165
2271
|
XEUtils.destructuring(oRow, XEUtils.clone(row, true));
|
|
@@ -2178,13 +2284,14 @@ export default defineComponent({
|
|
|
2178
2284
|
/**
|
|
2179
2285
|
* 用于树结构,给行数据加载子节点
|
|
2180
2286
|
*/
|
|
2181
|
-
|
|
2287
|
+
loadTreeChildren: function (row, childRecords) {
|
|
2288
|
+
var keepSource = props.keepSource;
|
|
2289
|
+
var tableSourceData = internalData.tableSourceData, fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData;
|
|
2290
|
+
var treeOpts = computeTreeOpts.value;
|
|
2291
|
+
var children = treeOpts.children;
|
|
2292
|
+
var rest = fullAllDataRowIdData[getRowid($xetable, row)];
|
|
2293
|
+
var parentLevel = rest ? rest.level : 0;
|
|
2182
2294
|
return tableMethods.createData(childRecords).then(function (rows) {
|
|
2183
|
-
var keepSource = props.keepSource;
|
|
2184
|
-
var fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData;
|
|
2185
|
-
var tableSourceData = internalData.tableSourceData;
|
|
2186
|
-
var treeOpts = computeTreeOpts.value;
|
|
2187
|
-
var children = treeOpts.children;
|
|
2188
2295
|
if (keepSource) {
|
|
2189
2296
|
var rowid_1 = getRowid($xetable, row);
|
|
2190
2297
|
var matchObj = XEUtils.findTree(tableSourceData, function (item) { return rowid_1 === getRowid($xetable, item); }, treeOpts);
|
|
@@ -2192,9 +2299,9 @@ export default defineComponent({
|
|
|
2192
2299
|
matchObj.item[children] = XEUtils.clone(rows, true);
|
|
2193
2300
|
}
|
|
2194
2301
|
}
|
|
2195
|
-
XEUtils.eachTree(rows, function (childRow, index, items, path, parent) {
|
|
2302
|
+
XEUtils.eachTree(rows, function (childRow, index, items, path, parent, nodes) {
|
|
2196
2303
|
var rowid = getRowid($xetable, childRow);
|
|
2197
|
-
var rest = { row: childRow, rowid: rowid, index: -1, _index: -1, $index: -1, items: items, parent: parent };
|
|
2304
|
+
var rest = { row: childRow, rowid: rowid, index: -1, _index: -1, $index: -1, items: items, parent: parent, level: parentLevel + nodes.length };
|
|
2198
2305
|
fullDataRowIdData[rowid] = rest;
|
|
2199
2306
|
fullAllDataRowIdData[rowid] = rest;
|
|
2200
2307
|
}, treeOpts);
|
|
@@ -3254,10 +3361,10 @@ export default defineComponent({
|
|
|
3254
3361
|
return nextTick();
|
|
3255
3362
|
},
|
|
3256
3363
|
/**
|
|
3257
|
-
*
|
|
3364
|
+
* 重新懒加载展开行,并展开内容
|
|
3258
3365
|
* @param {Row} row 行对象
|
|
3259
3366
|
*/
|
|
3260
|
-
|
|
3367
|
+
reloadRowExpand: function (row) {
|
|
3261
3368
|
var expandLazyLoadeds = reactData.expandLazyLoadeds;
|
|
3262
3369
|
var expandOpts = computeExpandOpts.value;
|
|
3263
3370
|
var lazy = expandOpts.lazy;
|
|
@@ -3267,6 +3374,13 @@ export default defineComponent({
|
|
|
3267
3374
|
}
|
|
3268
3375
|
return nextTick();
|
|
3269
3376
|
},
|
|
3377
|
+
reloadExpandContent: function (row) {
|
|
3378
|
+
if (process.env.NODE_ENV === 'development') {
|
|
3379
|
+
warnLog('vxe.error.delFunc', ['reloadExpandContent', 'reloadRowExpand']);
|
|
3380
|
+
}
|
|
3381
|
+
// 即将废弃
|
|
3382
|
+
return tableMethods.reloadRowExpand(row);
|
|
3383
|
+
},
|
|
3270
3384
|
/**
|
|
3271
3385
|
* 切换展开行
|
|
3272
3386
|
*/
|
|
@@ -3389,19 +3503,33 @@ export default defineComponent({
|
|
|
3389
3503
|
return nextTick();
|
|
3390
3504
|
},
|
|
3391
3505
|
/**
|
|
3392
|
-
*
|
|
3506
|
+
* 重新懒加载树节点,并展开该节点
|
|
3393
3507
|
* @param {Row} row 行对象
|
|
3394
3508
|
*/
|
|
3395
|
-
|
|
3509
|
+
reloadTreeExpand: function (row) {
|
|
3396
3510
|
var treeLazyLoadeds = reactData.treeLazyLoadeds;
|
|
3397
3511
|
var treeOpts = computeTreeOpts.value;
|
|
3398
|
-
var lazy = treeOpts.lazy, hasChild = treeOpts.hasChild;
|
|
3512
|
+
var transform = treeOpts.transform, lazy = treeOpts.lazy, hasChild = treeOpts.hasChild;
|
|
3399
3513
|
if (lazy && row[hasChild] && $xetable.findRowIndexOf(treeLazyLoadeds, row) === -1) {
|
|
3400
|
-
tableMethods.clearTreeExpandLoaded(row)
|
|
3401
|
-
|
|
3514
|
+
tableMethods.clearTreeExpandLoaded(row).then(function () {
|
|
3515
|
+
return handleAsyncTreeExpandChilds(row);
|
|
3516
|
+
}).then(function () {
|
|
3517
|
+
if (transform) {
|
|
3518
|
+
return updateVirtualTreeData();
|
|
3519
|
+
}
|
|
3520
|
+
}).then(function () {
|
|
3521
|
+
return tableMethods.recalculate();
|
|
3522
|
+
});
|
|
3402
3523
|
}
|
|
3403
3524
|
return nextTick();
|
|
3404
3525
|
},
|
|
3526
|
+
reloadTreeChilds: function (row) {
|
|
3527
|
+
if (process.env.NODE_ENV === 'development') {
|
|
3528
|
+
warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand']);
|
|
3529
|
+
}
|
|
3530
|
+
// 即将废弃
|
|
3531
|
+
return tableMethods.reloadTreeExpand(row);
|
|
3532
|
+
},
|
|
3405
3533
|
/**
|
|
3406
3534
|
* 切换/展开树节点
|
|
3407
3535
|
*/
|
|
@@ -3433,53 +3561,20 @@ export default defineComponent({
|
|
|
3433
3561
|
* @param {Boolean} expanded 是否展开
|
|
3434
3562
|
*/
|
|
3435
3563
|
setTreeExpand: function (rows, expanded) {
|
|
3436
|
-
var treeExpandeds = reactData.treeExpandeds, treeLazyLoadeds = reactData.treeLazyLoadeds, treeNodeColumn = reactData.treeNodeColumn;
|
|
3437
|
-
var fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData;
|
|
3438
3564
|
var treeOpts = computeTreeOpts.value;
|
|
3439
|
-
var
|
|
3440
|
-
var result = [];
|
|
3441
|
-
var columnIndex = tableMethods.getColumnIndex(treeNodeColumn);
|
|
3442
|
-
var $columnIndex = tableMethods.getVMColumnIndex(treeNodeColumn);
|
|
3565
|
+
var transform = treeOpts.transform;
|
|
3443
3566
|
if (rows) {
|
|
3444
3567
|
if (!XEUtils.isArray(rows)) {
|
|
3445
3568
|
rows = [rows];
|
|
3446
3569
|
}
|
|
3447
3570
|
if (rows.length) {
|
|
3448
|
-
|
|
3449
|
-
if (
|
|
3450
|
-
|
|
3451
|
-
// 同一级只能展开一个
|
|
3452
|
-
var matchObj_1 = XEUtils.findTree(tableFullData, function (item) { return item === validRows_2[0]; }, treeOpts);
|
|
3453
|
-
if (matchObj_1) {
|
|
3454
|
-
XEUtils.remove(treeExpandeds, function (item) { return matchObj_1.items.indexOf(item) > -1; });
|
|
3455
|
-
}
|
|
3456
|
-
}
|
|
3457
|
-
if (expanded) {
|
|
3458
|
-
validRows_2.forEach(function (row) {
|
|
3459
|
-
if ($xetable.findRowIndexOf(treeExpandeds, row) === -1) {
|
|
3460
|
-
var rest = fullAllDataRowIdData[getRowid($xetable, row)];
|
|
3461
|
-
var isLoad = lazy && row[hasChild] && !rest.treeLoaded && $xetable.findRowIndexOf(treeLazyLoadeds, row) === -1;
|
|
3462
|
-
// 是否使用懒加载
|
|
3463
|
-
if (isLoad) {
|
|
3464
|
-
result.push(handleAsyncTreeExpandChilds(row));
|
|
3465
|
-
}
|
|
3466
|
-
else {
|
|
3467
|
-
if (row[children] && row[children].length) {
|
|
3468
|
-
treeExpandeds.push(row);
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
}
|
|
3472
|
-
});
|
|
3571
|
+
// 如果为虚拟树
|
|
3572
|
+
if (transform) {
|
|
3573
|
+
return handleVirtualTreeExpand(rows, expanded);
|
|
3473
3574
|
}
|
|
3474
3575
|
else {
|
|
3475
|
-
|
|
3576
|
+
return handleBaseTreeExpand(rows, expanded);
|
|
3476
3577
|
}
|
|
3477
|
-
if (reserve) {
|
|
3478
|
-
validRows_2.forEach(function (row) { return handleTreeExpandReserve(row, expanded); });
|
|
3479
|
-
}
|
|
3480
|
-
return Promise.all(result).then(function () {
|
|
3481
|
-
return tableMethods.recalculate();
|
|
3482
|
-
});
|
|
3483
3578
|
}
|
|
3484
3579
|
}
|
|
3485
3580
|
return nextTick();
|
|
@@ -3497,15 +3592,15 @@ export default defineComponent({
|
|
|
3497
3592
|
*/
|
|
3498
3593
|
clearTreeExpand: function () {
|
|
3499
3594
|
var treeExpandeds = reactData.treeExpandeds;
|
|
3500
|
-
var
|
|
3595
|
+
var treeFullData = internalData.treeFullData;
|
|
3501
3596
|
var treeOpts = computeTreeOpts.value;
|
|
3502
3597
|
var reserve = treeOpts.reserve;
|
|
3503
3598
|
var isExists = treeExpandeds.length;
|
|
3504
3599
|
reactData.treeExpandeds = [];
|
|
3505
3600
|
if (reserve) {
|
|
3506
|
-
XEUtils.eachTree(
|
|
3601
|
+
XEUtils.eachTree(treeFullData, function (row) { return handleTreeExpandReserve(row, false); }, treeOpts);
|
|
3507
3602
|
}
|
|
3508
|
-
return
|
|
3603
|
+
return updateVirtualTreeData().then(function () {
|
|
3509
3604
|
if (isExists) {
|
|
3510
3605
|
tableMethods.recalculate();
|
|
3511
3606
|
}
|
|
@@ -4352,13 +4447,13 @@ export default defineComponent({
|
|
|
4352
4447
|
* 更新数据行的 Map
|
|
4353
4448
|
* 牺牲数据组装的耗时,用来换取使用过程中的流畅
|
|
4354
4449
|
*/
|
|
4355
|
-
|
|
4450
|
+
cacheRowMap: function (isSource) {
|
|
4356
4451
|
var treeConfig = props.treeConfig;
|
|
4357
4452
|
var treeOpts = computeTreeOpts.value;
|
|
4358
|
-
var fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData;
|
|
4453
|
+
var fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData, treeFullData = internalData.treeFullData;
|
|
4359
4454
|
var rowkey = getRowkey($xetable);
|
|
4360
4455
|
var isLazy = treeConfig && treeOpts.lazy;
|
|
4361
|
-
var handleCache = function (row, index, items, path, parent) {
|
|
4456
|
+
var handleCache = function (row, index, items, path, parent, nodes) {
|
|
4362
4457
|
var rowid = getRowid($xetable, row);
|
|
4363
4458
|
if (eqEmptyValue(rowid)) {
|
|
4364
4459
|
rowid = getRowUniqueId();
|
|
@@ -4367,7 +4462,7 @@ export default defineComponent({
|
|
|
4367
4462
|
if (isLazy && row[treeOpts.hasChild] && XEUtils.isUndefined(row[treeOpts.children])) {
|
|
4368
4463
|
row[treeOpts.children] = null;
|
|
4369
4464
|
}
|
|
4370
|
-
var rest = { row: row, rowid: rowid, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items: items, parent: parent };
|
|
4465
|
+
var rest = { row: row, rowid: rowid, index: treeConfig && parent ? -1 : index, _index: -1, $index: -1, items: items, parent: parent, level: nodes ? nodes.length - 1 : 0 };
|
|
4371
4466
|
if (isSource) {
|
|
4372
4467
|
fullDataRowIdData[rowid] = rest;
|
|
4373
4468
|
}
|
|
@@ -4378,7 +4473,7 @@ export default defineComponent({
|
|
|
4378
4473
|
}
|
|
4379
4474
|
fullAllDataRowIdData = internalData.fullAllDataRowIdData = {};
|
|
4380
4475
|
if (treeConfig) {
|
|
4381
|
-
XEUtils.eachTree(
|
|
4476
|
+
XEUtils.eachTree(treeFullData, handleCache, treeOpts);
|
|
4382
4477
|
}
|
|
4383
4478
|
else {
|
|
4384
4479
|
tableFullData.forEach(handleCache);
|
|
@@ -4663,10 +4758,10 @@ export default defineComponent({
|
|
|
4663
4758
|
triggerHeaderHelpEvent: function (evnt, params) {
|
|
4664
4759
|
var column = params.column;
|
|
4665
4760
|
var titleHelp = column.titleHelp;
|
|
4666
|
-
if (titleHelp.message) {
|
|
4761
|
+
if (titleHelp.content || titleHelp.message) {
|
|
4667
4762
|
var tooltipStore = internalData.tooltipStore;
|
|
4668
4763
|
var $tooltip = refTooltip.value;
|
|
4669
|
-
var content = getFuncText(titleHelp.message);
|
|
4764
|
+
var content = getFuncText(titleHelp.content || titleHelp.message);
|
|
4670
4765
|
handleTargetEnterEvent();
|
|
4671
4766
|
tooltipStore.visible = true;
|
|
4672
4767
|
if ($tooltip) {
|
|
@@ -5260,6 +5355,18 @@ export default defineComponent({
|
|
|
5260
5355
|
return false;
|
|
5261
5356
|
}
|
|
5262
5357
|
};
|
|
5358
|
+
if (process.env.NODE_ENV === 'development') {
|
|
5359
|
+
'openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',').forEach(function (name) {
|
|
5360
|
+
$xetable[name] = function () {
|
|
5361
|
+
errLog('vxe.error.reqModule', ['Export']);
|
|
5362
|
+
};
|
|
5363
|
+
});
|
|
5364
|
+
'clearValidate,fullValidate,validate'.split(',').forEach(function (name) {
|
|
5365
|
+
$xetable[name] = function () {
|
|
5366
|
+
errLog('vxe.error.reqModule', ['Validator']);
|
|
5367
|
+
};
|
|
5368
|
+
});
|
|
5369
|
+
}
|
|
5263
5370
|
Object.assign($xetable, tableMethods, tablePrivateMethods);
|
|
5264
5371
|
/**
|
|
5265
5372
|
* 渲染浮固定列
|
|
@@ -5447,12 +5554,16 @@ export default defineComponent({
|
|
|
5447
5554
|
if (process.env.NODE_ENV === 'development') {
|
|
5448
5555
|
var customOpts = computeCustomOpts.value;
|
|
5449
5556
|
var mouseOpts = computeMouseOpts.value;
|
|
5557
|
+
var rowOpts = computeRowOpts.value;
|
|
5450
5558
|
if (!props.id && props.customConfig && (customOpts.storage === true || (customOpts.storage && customOpts.storage.resizable) || (customOpts.storage && customOpts.storage.visible))) {
|
|
5451
5559
|
errLog('vxe.error.reqProp', ['id']);
|
|
5452
5560
|
}
|
|
5453
5561
|
if (props.treeConfig && checkboxOpts.range) {
|
|
5454
5562
|
errLog('vxe.error.noTree', ['checkbox-config.range']);
|
|
5455
5563
|
}
|
|
5564
|
+
if (rowOpts.height && !props.showOverflow) {
|
|
5565
|
+
warnLog('vxe.error.notProp', ['table.show-overflow']);
|
|
5566
|
+
}
|
|
5456
5567
|
if (!$xetable.handleUpdateCellAreas) {
|
|
5457
5568
|
if (props.clipConfig) {
|
|
5458
5569
|
warnLog('vxe.error.notProp', ['clip-config']);
|
|
@@ -17,7 +17,6 @@ var GlobalConfig = {
|
|
|
17
17
|
// resizeInterval: 500,
|
|
18
18
|
// size: null,
|
|
19
19
|
// zIndex: null,
|
|
20
|
-
// resizable: false,
|
|
21
20
|
// autoResize: false,
|
|
22
21
|
// stripe: false,
|
|
23
22
|
// border: false,
|
|
@@ -63,8 +62,8 @@ var GlobalConfig = {
|
|
|
63
62
|
showIcon: true
|
|
64
63
|
},
|
|
65
64
|
treeConfig: {
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
rowField: 'id',
|
|
66
|
+
parentField: 'parentId',
|
|
68
67
|
children: 'children',
|
|
69
68
|
hasChild: 'hasChild',
|
|
70
69
|
indent: 20,
|
package/es/validator/src/hook.js
CHANGED
|
@@ -30,13 +30,20 @@ var Rule = /** @class */ (function () {
|
|
|
30
30
|
maxWidth: rule.maxWidth
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
Object.defineProperty(Rule.prototype, "
|
|
33
|
+
Object.defineProperty(Rule.prototype, "content", {
|
|
34
34
|
/**
|
|
35
35
|
* 获取校验不通过的消息
|
|
36
36
|
* 支持国际化翻译
|
|
37
37
|
*/
|
|
38
38
|
get: function () {
|
|
39
|
-
return getFuncText(this.$options.message);
|
|
39
|
+
return getFuncText(this.$options.content || this.$options.message);
|
|
40
|
+
},
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(Rule.prototype, "message", {
|
|
45
|
+
get: function () {
|
|
46
|
+
return this.content;
|
|
40
47
|
},
|
|
41
48
|
enumerable: false,
|
|
42
49
|
configurable: true
|
|
@@ -297,13 +304,13 @@ var validatorHook = {
|
|
|
297
304
|
if (customValid) {
|
|
298
305
|
if (XEUtils.isError(customValid)) {
|
|
299
306
|
validRuleErr = true;
|
|
300
|
-
errorRules.push(new Rule({ type: 'custom', trigger: trigger,
|
|
307
|
+
errorRules.push(new Rule({ type: 'custom', trigger: trigger, content: customValid.message, rule: new Rule(rule) }));
|
|
301
308
|
}
|
|
302
309
|
else if (customValid.catch) {
|
|
303
310
|
// 如果为异步校验(注:异步校验是并发无序的)
|
|
304
311
|
syncVailds.push(customValid.catch(function (e) {
|
|
305
312
|
validRuleErr = true;
|
|
306
|
-
errorRules.push(new Rule({ type: 'custom', trigger: trigger,
|
|
313
|
+
errorRules.push(new Rule({ type: 'custom', trigger: trigger, content: e && e.message ? e.message : (rule.content || rule.message), rule: new Rule(rule) }));
|
|
307
314
|
}));
|
|
308
315
|
}
|
|
309
316
|
}
|
|
@@ -376,7 +383,7 @@ var validatorHook = {
|
|
|
376
383
|
var validOpts = computeValidOpts.value;
|
|
377
384
|
var rule = params.rule, row = params.row, column = params.column, cell = params.cell;
|
|
378
385
|
var validTip = refValidTooltip.value;
|
|
379
|
-
var content = rule.
|
|
386
|
+
var content = rule.content;
|
|
380
387
|
return nextTick().then(function () {
|
|
381
388
|
Object.assign(validStore, {
|
|
382
389
|
row: row,
|