vxe-table 4.1.0-beta.0 → 4.1.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/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/props.js +4 -1
- package/es/table/src/table.js +212 -89
- package/es/v-x-e-table/src/conf.js +2 -1
- package/es/validator/src/hook.js +12 -5
- package/helper/vetur/attributes.json +16 -204
- package/helper/vetur/tags.json +3 -65
- 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 +451 -182
- 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/props.js +4 -1
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +272 -120
- package/lib/table/src/table.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +2 -1
- 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 +3 -3
- 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/props.ts +4 -1
- package/packages/table/src/table.ts +215 -88
- package/packages/v-x-e-table/src/conf.ts +2 -1
- 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 +41 -10
- 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,27 +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
|
|
1759
|
-
var
|
|
1760
|
-
var
|
|
1757
|
+
var treeOpts = computeTreeOpts.value;
|
|
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.rowtKey) {
|
|
1766
|
+
errLog('vxe.error.reqProp', ['tree-config.rowtKey']);
|
|
1767
|
+
}
|
|
1768
|
+
if (!treeOpts.parentKey) {
|
|
1769
|
+
errLog('vxe.error.reqProp', ['tree-config.parentKey']);
|
|
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
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
treeData = XEUtils.toArrayTree(fullData, { key: treeOpts.rowtKey, parentKey: treeOpts.parentKey, children: treeOpts.children });
|
|
1781
|
+
fullData = treeData.slice(0);
|
|
1782
|
+
}
|
|
1783
|
+
else {
|
|
1784
|
+
treeData = fullData.slice(0);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1761
1787
|
scrollYStore.startIndex = 0;
|
|
1762
1788
|
scrollYStore.endIndex = 1;
|
|
1763
1789
|
scrollXStore.startIndex = 0;
|
|
1764
1790
|
scrollXStore.endIndex = 1;
|
|
1765
1791
|
editStore.insertList = [];
|
|
1766
1792
|
editStore.removeList = [];
|
|
1793
|
+
var sYLoad = updateScrollYStatus(fullData);
|
|
1794
|
+
reactData.scrollYLoad = sYLoad;
|
|
1767
1795
|
// 全量数据
|
|
1768
|
-
internalData.tableFullData =
|
|
1796
|
+
internalData.tableFullData = fullData;
|
|
1797
|
+
internalData.treeFullData = treeData;
|
|
1769
1798
|
// 缓存数据
|
|
1770
|
-
tablePrivateMethods.
|
|
1799
|
+
tablePrivateMethods.cacheRowMap(true);
|
|
1771
1800
|
// 原始数据
|
|
1772
1801
|
internalData.tableSynchData = datas;
|
|
1802
|
+
// 克隆原数据,用于显示编辑状态,与编辑值做对比
|
|
1773
1803
|
if (keepSource) {
|
|
1774
|
-
internalData.tableSourceData = XEUtils.clone(
|
|
1804
|
+
internalData.tableSourceData = XEUtils.clone(fullData, true);
|
|
1775
1805
|
}
|
|
1776
|
-
reactData.scrollYLoad = scrollYLoad;
|
|
1777
1806
|
if (process.env.NODE_ENV === 'development') {
|
|
1778
|
-
if (
|
|
1807
|
+
if (sYLoad) {
|
|
1779
1808
|
if (!(props.height || props.maxHeight)) {
|
|
1780
1809
|
errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}']);
|
|
1781
1810
|
}
|
|
@@ -1801,8 +1830,8 @@ export default defineComponent({
|
|
|
1801
1830
|
}).then(function () {
|
|
1802
1831
|
computeScrollLoad();
|
|
1803
1832
|
}).then(function () {
|
|
1804
|
-
//
|
|
1805
|
-
if (
|
|
1833
|
+
// 是否启用了虚拟滚动
|
|
1834
|
+
if (sYLoad) {
|
|
1806
1835
|
scrollYStore.endIndex = scrollYStore.visibleSize;
|
|
1807
1836
|
}
|
|
1808
1837
|
handleReserveStatus();
|
|
@@ -1812,7 +1841,7 @@ export default defineComponent({
|
|
|
1812
1841
|
.then(function () { return tableMethods.recalculate(); })
|
|
1813
1842
|
.then(function () {
|
|
1814
1843
|
// 是否变更虚拟滚动
|
|
1815
|
-
if (oldScrollYLoad ===
|
|
1844
|
+
if (oldScrollYLoad === sYLoad) {
|
|
1816
1845
|
restoreScrollLocation($xetable, lastScrollLeft, lastScrollTop).then(resolve);
|
|
1817
1846
|
}
|
|
1818
1847
|
else {
|
|
@@ -2029,6 +2058,95 @@ export default defineComponent({
|
|
|
2029
2058
|
return tableMethods.recalculate();
|
|
2030
2059
|
});
|
|
2031
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
|
+
};
|
|
2032
2150
|
/**
|
|
2033
2151
|
* 纵向 Y 可视渲染处理
|
|
2034
2152
|
*/
|
|
@@ -2147,7 +2265,7 @@ export default defineComponent({
|
|
|
2147
2265
|
tableSourceData[rowIndex] = record;
|
|
2148
2266
|
XEUtils.clear(row, undefined);
|
|
2149
2267
|
Object.assign(row, tablePrivateMethods.defineField(Object.assign({}, record)));
|
|
2150
|
-
tablePrivateMethods.
|
|
2268
|
+
tablePrivateMethods.cacheRowMap(true);
|
|
2151
2269
|
}
|
|
2152
2270
|
else {
|
|
2153
2271
|
XEUtils.destructuring(oRow, XEUtils.clone(row, true));
|
|
@@ -2166,13 +2284,14 @@ export default defineComponent({
|
|
|
2166
2284
|
/**
|
|
2167
2285
|
* 用于树结构,给行数据加载子节点
|
|
2168
2286
|
*/
|
|
2169
|
-
|
|
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;
|
|
2170
2294
|
return tableMethods.createData(childRecords).then(function (rows) {
|
|
2171
|
-
var keepSource = props.keepSource;
|
|
2172
|
-
var fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData;
|
|
2173
|
-
var tableSourceData = internalData.tableSourceData;
|
|
2174
|
-
var treeOpts = computeTreeOpts.value;
|
|
2175
|
-
var children = treeOpts.children;
|
|
2176
2295
|
if (keepSource) {
|
|
2177
2296
|
var rowid_1 = getRowid($xetable, row);
|
|
2178
2297
|
var matchObj = XEUtils.findTree(tableSourceData, function (item) { return rowid_1 === getRowid($xetable, item); }, treeOpts);
|
|
@@ -2180,9 +2299,9 @@ export default defineComponent({
|
|
|
2180
2299
|
matchObj.item[children] = XEUtils.clone(rows, true);
|
|
2181
2300
|
}
|
|
2182
2301
|
}
|
|
2183
|
-
XEUtils.eachTree(rows, function (childRow, index, items, path, parent) {
|
|
2302
|
+
XEUtils.eachTree(rows, function (childRow, index, items, path, parent, nodes) {
|
|
2184
2303
|
var rowid = getRowid($xetable, childRow);
|
|
2185
|
-
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 };
|
|
2186
2305
|
fullDataRowIdData[rowid] = rest;
|
|
2187
2306
|
fullAllDataRowIdData[rowid] = rest;
|
|
2188
2307
|
}, treeOpts);
|
|
@@ -3242,10 +3361,10 @@ export default defineComponent({
|
|
|
3242
3361
|
return nextTick();
|
|
3243
3362
|
},
|
|
3244
3363
|
/**
|
|
3245
|
-
*
|
|
3364
|
+
* 重新懒加载展开行,并展开内容
|
|
3246
3365
|
* @param {Row} row 行对象
|
|
3247
3366
|
*/
|
|
3248
|
-
|
|
3367
|
+
reloadRowExpand: function (row) {
|
|
3249
3368
|
var expandLazyLoadeds = reactData.expandLazyLoadeds;
|
|
3250
3369
|
var expandOpts = computeExpandOpts.value;
|
|
3251
3370
|
var lazy = expandOpts.lazy;
|
|
@@ -3255,6 +3374,13 @@ export default defineComponent({
|
|
|
3255
3374
|
}
|
|
3256
3375
|
return nextTick();
|
|
3257
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
|
+
},
|
|
3258
3384
|
/**
|
|
3259
3385
|
* 切换展开行
|
|
3260
3386
|
*/
|
|
@@ -3377,19 +3503,33 @@ export default defineComponent({
|
|
|
3377
3503
|
return nextTick();
|
|
3378
3504
|
},
|
|
3379
3505
|
/**
|
|
3380
|
-
*
|
|
3506
|
+
* 重新懒加载树节点,并展开该节点
|
|
3381
3507
|
* @param {Row} row 行对象
|
|
3382
3508
|
*/
|
|
3383
|
-
|
|
3509
|
+
reloadTreeExpand: function (row) {
|
|
3384
3510
|
var treeLazyLoadeds = reactData.treeLazyLoadeds;
|
|
3385
3511
|
var treeOpts = computeTreeOpts.value;
|
|
3386
|
-
var lazy = treeOpts.lazy, hasChild = treeOpts.hasChild;
|
|
3512
|
+
var transform = treeOpts.transform, lazy = treeOpts.lazy, hasChild = treeOpts.hasChild;
|
|
3387
3513
|
if (lazy && row[hasChild] && $xetable.findRowIndexOf(treeLazyLoadeds, row) === -1) {
|
|
3388
|
-
tableMethods.clearTreeExpandLoaded(row)
|
|
3389
|
-
|
|
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
|
+
});
|
|
3390
3523
|
}
|
|
3391
3524
|
return nextTick();
|
|
3392
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
|
+
},
|
|
3393
3533
|
/**
|
|
3394
3534
|
* 切换/展开树节点
|
|
3395
3535
|
*/
|
|
@@ -3421,53 +3561,20 @@ export default defineComponent({
|
|
|
3421
3561
|
* @param {Boolean} expanded 是否展开
|
|
3422
3562
|
*/
|
|
3423
3563
|
setTreeExpand: function (rows, expanded) {
|
|
3424
|
-
var treeExpandeds = reactData.treeExpandeds, treeLazyLoadeds = reactData.treeLazyLoadeds, treeNodeColumn = reactData.treeNodeColumn;
|
|
3425
|
-
var fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData;
|
|
3426
3564
|
var treeOpts = computeTreeOpts.value;
|
|
3427
|
-
var
|
|
3428
|
-
var result = [];
|
|
3429
|
-
var columnIndex = tableMethods.getColumnIndex(treeNodeColumn);
|
|
3430
|
-
var $columnIndex = tableMethods.getVMColumnIndex(treeNodeColumn);
|
|
3565
|
+
var transform = treeOpts.transform;
|
|
3431
3566
|
if (rows) {
|
|
3432
3567
|
if (!XEUtils.isArray(rows)) {
|
|
3433
3568
|
rows = [rows];
|
|
3434
3569
|
}
|
|
3435
3570
|
if (rows.length) {
|
|
3436
|
-
|
|
3437
|
-
if (
|
|
3438
|
-
|
|
3439
|
-
// 同一级只能展开一个
|
|
3440
|
-
var matchObj_1 = XEUtils.findTree(tableFullData, function (item) { return item === validRows_2[0]; }, treeOpts);
|
|
3441
|
-
if (matchObj_1) {
|
|
3442
|
-
XEUtils.remove(treeExpandeds, function (item) { return matchObj_1.items.indexOf(item) > -1; });
|
|
3443
|
-
}
|
|
3444
|
-
}
|
|
3445
|
-
if (expanded) {
|
|
3446
|
-
validRows_2.forEach(function (row) {
|
|
3447
|
-
if ($xetable.findRowIndexOf(treeExpandeds, row) === -1) {
|
|
3448
|
-
var rest = fullAllDataRowIdData[getRowid($xetable, row)];
|
|
3449
|
-
var isLoad = lazy && row[hasChild] && !rest.treeLoaded && $xetable.findRowIndexOf(treeLazyLoadeds, row) === -1;
|
|
3450
|
-
// 是否使用懒加载
|
|
3451
|
-
if (isLoad) {
|
|
3452
|
-
result.push(handleAsyncTreeExpandChilds(row));
|
|
3453
|
-
}
|
|
3454
|
-
else {
|
|
3455
|
-
if (row[children] && row[children].length) {
|
|
3456
|
-
treeExpandeds.push(row);
|
|
3457
|
-
}
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
});
|
|
3571
|
+
// 如果为虚拟树
|
|
3572
|
+
if (transform) {
|
|
3573
|
+
return handleVirtualTreeExpand(rows, expanded);
|
|
3461
3574
|
}
|
|
3462
3575
|
else {
|
|
3463
|
-
|
|
3464
|
-
}
|
|
3465
|
-
if (reserve) {
|
|
3466
|
-
validRows_2.forEach(function (row) { return handleTreeExpandReserve(row, expanded); });
|
|
3576
|
+
return handleBaseTreeExpand(rows, expanded);
|
|
3467
3577
|
}
|
|
3468
|
-
return Promise.all(result).then(function () {
|
|
3469
|
-
return tableMethods.recalculate();
|
|
3470
|
-
});
|
|
3471
3578
|
}
|
|
3472
3579
|
}
|
|
3473
3580
|
return nextTick();
|
|
@@ -3485,15 +3592,15 @@ export default defineComponent({
|
|
|
3485
3592
|
*/
|
|
3486
3593
|
clearTreeExpand: function () {
|
|
3487
3594
|
var treeExpandeds = reactData.treeExpandeds;
|
|
3488
|
-
var
|
|
3595
|
+
var treeFullData = internalData.treeFullData;
|
|
3489
3596
|
var treeOpts = computeTreeOpts.value;
|
|
3490
3597
|
var reserve = treeOpts.reserve;
|
|
3491
3598
|
var isExists = treeExpandeds.length;
|
|
3492
3599
|
reactData.treeExpandeds = [];
|
|
3493
3600
|
if (reserve) {
|
|
3494
|
-
XEUtils.eachTree(
|
|
3601
|
+
XEUtils.eachTree(treeFullData, function (row) { return handleTreeExpandReserve(row, false); }, treeOpts);
|
|
3495
3602
|
}
|
|
3496
|
-
return
|
|
3603
|
+
return updateVirtualTreeData().then(function () {
|
|
3497
3604
|
if (isExists) {
|
|
3498
3605
|
tableMethods.recalculate();
|
|
3499
3606
|
}
|
|
@@ -4340,13 +4447,13 @@ export default defineComponent({
|
|
|
4340
4447
|
* 更新数据行的 Map
|
|
4341
4448
|
* 牺牲数据组装的耗时,用来换取使用过程中的流畅
|
|
4342
4449
|
*/
|
|
4343
|
-
|
|
4450
|
+
cacheRowMap: function (isSource) {
|
|
4344
4451
|
var treeConfig = props.treeConfig;
|
|
4345
4452
|
var treeOpts = computeTreeOpts.value;
|
|
4346
|
-
var fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData;
|
|
4453
|
+
var fullDataRowIdData = internalData.fullDataRowIdData, fullAllDataRowIdData = internalData.fullAllDataRowIdData, tableFullData = internalData.tableFullData, treeFullData = internalData.treeFullData;
|
|
4347
4454
|
var rowkey = getRowkey($xetable);
|
|
4348
4455
|
var isLazy = treeConfig && treeOpts.lazy;
|
|
4349
|
-
var handleCache = function (row, index, items, path, parent) {
|
|
4456
|
+
var handleCache = function (row, index, items, path, parent, nodes) {
|
|
4350
4457
|
var rowid = getRowid($xetable, row);
|
|
4351
4458
|
if (eqEmptyValue(rowid)) {
|
|
4352
4459
|
rowid = getRowUniqueId();
|
|
@@ -4355,7 +4462,7 @@ export default defineComponent({
|
|
|
4355
4462
|
if (isLazy && row[treeOpts.hasChild] && XEUtils.isUndefined(row[treeOpts.children])) {
|
|
4356
4463
|
row[treeOpts.children] = null;
|
|
4357
4464
|
}
|
|
4358
|
-
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 };
|
|
4359
4466
|
if (isSource) {
|
|
4360
4467
|
fullDataRowIdData[rowid] = rest;
|
|
4361
4468
|
}
|
|
@@ -4366,7 +4473,7 @@ export default defineComponent({
|
|
|
4366
4473
|
}
|
|
4367
4474
|
fullAllDataRowIdData = internalData.fullAllDataRowIdData = {};
|
|
4368
4475
|
if (treeConfig) {
|
|
4369
|
-
XEUtils.eachTree(
|
|
4476
|
+
XEUtils.eachTree(treeFullData, handleCache, treeOpts);
|
|
4370
4477
|
}
|
|
4371
4478
|
else {
|
|
4372
4479
|
tableFullData.forEach(handleCache);
|
|
@@ -4651,10 +4758,10 @@ export default defineComponent({
|
|
|
4651
4758
|
triggerHeaderHelpEvent: function (evnt, params) {
|
|
4652
4759
|
var column = params.column;
|
|
4653
4760
|
var titleHelp = column.titleHelp;
|
|
4654
|
-
if (titleHelp.message) {
|
|
4761
|
+
if (titleHelp.content || titleHelp.message) {
|
|
4655
4762
|
var tooltipStore = internalData.tooltipStore;
|
|
4656
4763
|
var $tooltip = refTooltip.value;
|
|
4657
|
-
var content = getFuncText(titleHelp.message);
|
|
4764
|
+
var content = getFuncText(titleHelp.content || titleHelp.message);
|
|
4658
4765
|
handleTargetEnterEvent();
|
|
4659
4766
|
tooltipStore.visible = true;
|
|
4660
4767
|
if ($tooltip) {
|
|
@@ -5248,6 +5355,18 @@ export default defineComponent({
|
|
|
5248
5355
|
return false;
|
|
5249
5356
|
}
|
|
5250
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
|
+
}
|
|
5251
5370
|
Object.assign($xetable, tableMethods, tablePrivateMethods);
|
|
5252
5371
|
/**
|
|
5253
5372
|
* 渲染浮固定列
|
|
@@ -5435,12 +5554,16 @@ export default defineComponent({
|
|
|
5435
5554
|
if (process.env.NODE_ENV === 'development') {
|
|
5436
5555
|
var customOpts = computeCustomOpts.value;
|
|
5437
5556
|
var mouseOpts = computeMouseOpts.value;
|
|
5557
|
+
var rowOpts = computeRowOpts.value;
|
|
5438
5558
|
if (!props.id && props.customConfig && (customOpts.storage === true || (customOpts.storage && customOpts.storage.resizable) || (customOpts.storage && customOpts.storage.visible))) {
|
|
5439
5559
|
errLog('vxe.error.reqProp', ['id']);
|
|
5440
5560
|
}
|
|
5441
5561
|
if (props.treeConfig && checkboxOpts.range) {
|
|
5442
5562
|
errLog('vxe.error.noTree', ['checkbox-config.range']);
|
|
5443
5563
|
}
|
|
5564
|
+
if (rowOpts.height && !props.showOverflow) {
|
|
5565
|
+
warnLog('vxe.error.notProp', ['table.show-overflow']);
|
|
5566
|
+
}
|
|
5444
5567
|
if (!$xetable.handleUpdateCellAreas) {
|
|
5445
5568
|
if (props.clipConfig) {
|
|
5446
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,6 +62,8 @@ var GlobalConfig = {
|
|
|
63
62
|
showIcon: true
|
|
64
63
|
},
|
|
65
64
|
treeConfig: {
|
|
65
|
+
rowtKey: 'id',
|
|
66
|
+
parentKey: 'parentId',
|
|
66
67
|
children: 'children',
|
|
67
68
|
hasChild: 'hasChild',
|
|
68
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,
|