zmdms-webui 2.0.6 → 2.0.7
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.
|
@@ -68,9 +68,9 @@ var DynamicDrawer = function (props, ref) {
|
|
|
68
68
|
if (oldGroup !== dragGroup) {
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
71
|
-
if ((oldItem === null || oldItem === void 0 ? void 0 : oldItem.dimensionPriority) !== undefined
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if ((oldItem === null || oldItem === void 0 ? void 0 : oldItem.dimensionPriority) !== undefined &&
|
|
72
|
+
(dragItem === null || dragItem === void 0 ? void 0 : dragItem.dimensionPriority) !== undefined) {
|
|
73
|
+
if ((oldItem === null || oldItem === void 0 ? void 0 : oldItem.dimensionPriority) < (dragItem === null || dragItem === void 0 ? void 0 : dragItem.dimensionPriority)) {
|
|
74
74
|
myMessage.warning("".concat(dragItem === null || dragItem === void 0 ? void 0 : dragItem.label, "\u4E0D\u80FD\u6392\u5E8F\u5230").concat(oldItem === null || oldItem === void 0 ? void 0 : oldItem.label).concat(isUp ? "前面" : "后面"));
|
|
75
75
|
return false;
|
|
76
76
|
}
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -399,7 +399,7 @@ var useNumKeys = function (columns) {
|
|
|
399
399
|
* 自动合并的一些处理
|
|
400
400
|
*/
|
|
401
401
|
function useAutoMerge(dataSource, columns, _a) {
|
|
402
|
-
var isAutoMerge = _a.isAutoMerge, isDimensionDynamic = _a.isDimensionDynamic, order = _a.order;
|
|
402
|
+
var isAutoMerge = _a.isAutoMerge, isDimensionDynamic = _a.isDimensionDynamic, order = _a.order, dimensionCustomSumKeys = _a.dimensionCustomSumKeys;
|
|
403
403
|
// 计算需要合并的字段key集合
|
|
404
404
|
var mergeKeys = useMergeKeys(columns, isAutoMerge);
|
|
405
405
|
var firstMergeKey = mergeKeys === null || mergeKeys === void 0 ? void 0 : mergeKeys[0];
|
|
@@ -423,7 +423,7 @@ function useAutoMerge(dataSource, columns, _a) {
|
|
|
423
423
|
if (!mergeKeys)
|
|
424
424
|
return dataSource;
|
|
425
425
|
else {
|
|
426
|
-
var newDataSource_2 = flattenRecordsOptimized(__spreadArray([], (dataSource || []), true), mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic, order);
|
|
426
|
+
var newDataSource_2 = flattenRecordsOptimized(__spreadArray([], (dataSource || []), true), mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic, order, dimensionCustomSumKeys);
|
|
427
427
|
return newDataSource_2;
|
|
428
428
|
}
|
|
429
429
|
}
|
|
@@ -435,6 +435,7 @@ function useAutoMerge(dataSource, columns, _a) {
|
|
|
435
435
|
summaryKeys,
|
|
436
436
|
isDimensionDynamic,
|
|
437
437
|
order,
|
|
438
|
+
dimensionCustomSumKeys,
|
|
438
439
|
]);
|
|
439
440
|
var newColumns = useMemo(function () {
|
|
440
441
|
var _columns = columns;
|
|
@@ -512,6 +512,19 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
512
512
|
* 开启维度自定义。开启后,会根据columns中的isDimension属性来是否开启维度自定义,需要合并行时,需要开启这个属性isAutoMerge
|
|
513
513
|
*/
|
|
514
514
|
isDimensionDynamic?: boolean;
|
|
515
|
+
/**
|
|
516
|
+
* 开启维度自定义后,开启维度合计的字段,与column中的isSummary相同,主要用于自定义合计字段
|
|
517
|
+
*/
|
|
518
|
+
dimensionCustomSumKeys?: (string | {
|
|
519
|
+
/** 自定义合计的key */
|
|
520
|
+
key: string;
|
|
521
|
+
/** 自定义合计的值 */
|
|
522
|
+
value: (record: any) => string | number;
|
|
523
|
+
/** 合计方式 */
|
|
524
|
+
summaryType?: "sum" | "first" | "computed";
|
|
525
|
+
/** 当summaryType为computed时,用于计算合计值的函数 */
|
|
526
|
+
computedSummary?: (items: any[], summaryRow: any) => string | number;
|
|
527
|
+
})[];
|
|
515
528
|
/**
|
|
516
529
|
* 开启自动合并行
|
|
517
530
|
*/
|
package/dist/es/table/table.js
CHANGED
|
@@ -41,7 +41,7 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
|
|
|
41
41
|
// completed: 实现从execl复制到表格中的功能
|
|
42
42
|
var Table = function (props) {
|
|
43
43
|
// console.log("表格渲染");
|
|
44
|
-
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, customDynamicListHandle = props.customDynamicListHandle, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _o = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _o === void 0 ? 65 : _o, _p = props.isAutoScrollY, isAutoScrollY = _p === void 0 ? false : _p, tableId = props.tableId, extraOnRow = props.onRow, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, headerAlign = props.headerAlign, isDimensionDynamic = props.isDimensionDynamic, isAutoMerge = props.isAutoMerge, mode = props.mode, rowSelection = props.rowSelection, isContextMenu = props.isContextMenu, isFullscreenHandle = props.isFullscreenHandle, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "customDynamicListHandle", "isRemeberFilter", "isOrderUpdateData", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "hiddenAddBtnHandle", "isTheadTitleAdd", "addMode", "addCallback", "isDel", "delPopTitle", "hiddenDelBtnHandle", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "innerPaginationConfig", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn", "isResizableTitleEllipsis", "isRealTimeValidate", "isMarginTop", "isMarginBottom", "scroll", "addAndDelProps", "autoScrollYMarginBottom", "isAutoScrollY", "tableId", "onRow", "fixedRowsCount", "fixedRowsConfig", "headerAlign", "isDimensionDynamic", "isAutoMerge", "mode", "rowSelection", "isContextMenu", "isFullscreenHandle"]);
|
|
44
|
+
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, customDynamicListHandle = props.customDynamicListHandle, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _o = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _o === void 0 ? 65 : _o, _p = props.isAutoScrollY, isAutoScrollY = _p === void 0 ? false : _p, tableId = props.tableId, extraOnRow = props.onRow, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, headerAlign = props.headerAlign, isDimensionDynamic = props.isDimensionDynamic, dimensionCustomSumKeys = props.dimensionCustomSumKeys, isAutoMerge = props.isAutoMerge, mode = props.mode, rowSelection = props.rowSelection, isContextMenu = props.isContextMenu, isFullscreenHandle = props.isFullscreenHandle, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "customDynamicListHandle", "isRemeberFilter", "isOrderUpdateData", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "hiddenAddBtnHandle", "isTheadTitleAdd", "addMode", "addCallback", "isDel", "delPopTitle", "hiddenDelBtnHandle", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "innerPaginationConfig", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn", "isResizableTitleEllipsis", "isRealTimeValidate", "isMarginTop", "isMarginBottom", "scroll", "addAndDelProps", "autoScrollYMarginBottom", "isAutoScrollY", "tableId", "onRow", "fixedRowsCount", "fixedRowsConfig", "headerAlign", "isDimensionDynamic", "dimensionCustomSumKeys", "isAutoMerge", "mode", "rowSelection", "isContextMenu", "isFullscreenHandle"]);
|
|
45
45
|
var classes = classNames("ztxk-table", className, {
|
|
46
46
|
"ztxk-table--flex": isFlex,
|
|
47
47
|
});
|
|
@@ -180,6 +180,7 @@ var Table = function (props) {
|
|
|
180
180
|
isAutoMerge: isAutoMerge,
|
|
181
181
|
isDimensionDynamic: isDimensionDynamic,
|
|
182
182
|
order: order,
|
|
183
|
+
dimensionCustomSumKeys: dimensionCustomSumKeys,
|
|
183
184
|
}), newDataSource = _w[0], newColumns = _w[1];
|
|
184
185
|
// 内部表格总结栏
|
|
185
186
|
var getSummaryHandle = useSummary(summaryConfig, newColumns, {
|
|
@@ -343,7 +343,11 @@ function useColumns(columns, options) {
|
|
|
343
343
|
};
|
|
344
344
|
var __render__1 = _column.render;
|
|
345
345
|
// 代理render方法,像外部传入一些事件给外部调用
|
|
346
|
+
// 自定义合计行,不需要render属性
|
|
346
347
|
_column.render = function (text, record, index) {
|
|
348
|
+
if (record[IS_SUMMARY]) {
|
|
349
|
+
return text;
|
|
350
|
+
}
|
|
347
351
|
return __render__1(text, record, index, options_1);
|
|
348
352
|
};
|
|
349
353
|
}
|
package/dist/es/table/utils.js
CHANGED
|
@@ -449,7 +449,7 @@ function startColumnInsertTableData(options) {
|
|
|
449
449
|
* @param summaryKeys 合计字段
|
|
450
450
|
* @param isDimensionDynamic 维度合并
|
|
451
451
|
*/
|
|
452
|
-
function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic, order) {
|
|
452
|
+
function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summaryKeys, isDimensionDynamic, order, dimensionCustomSumKeys) {
|
|
453
453
|
var _a;
|
|
454
454
|
if (!records ||
|
|
455
455
|
records.length === 0 ||
|
|
@@ -469,7 +469,7 @@ function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summa
|
|
|
469
469
|
}
|
|
470
470
|
// 1. 如果开启了维度合并,按所有 mergeKeys 的组合来计算合计值
|
|
471
471
|
if (isDimensionDynamic && mergeKeys.length > 0) {
|
|
472
|
-
var groupedResult = groupByLastMergeKey(result, mergeKeys, summaryKeys);
|
|
472
|
+
var groupedResult = groupByLastMergeKey(result, mergeKeys, summaryKeys, dimensionCustomSumKeys);
|
|
473
473
|
result = groupedResult;
|
|
474
474
|
}
|
|
475
475
|
// 如果order有排序方向,则按order排序
|
|
@@ -813,7 +813,7 @@ function hasParentGroupChanged(records, currentIndex, mergeKeys, currentKeyIndex
|
|
|
813
813
|
* 确保相同维度组合的记录被正确分组
|
|
814
814
|
*/
|
|
815
815
|
function groupByLastMergeKey(records, mergeKeys, // 改为传入所有合并键
|
|
816
|
-
summaryKeys) {
|
|
816
|
+
summaryKeys, dimensionCustomSumKeys) {
|
|
817
817
|
var groups = new Map();
|
|
818
818
|
var _loop_6 = function (record) {
|
|
819
819
|
var key = mergeKeys.map(function (k) { return record[k]; });
|
|
@@ -855,6 +855,83 @@ summaryKeys) {
|
|
|
855
855
|
var summaryKey = summaryKeys_2[_d];
|
|
856
856
|
_loop_7(summaryKey);
|
|
857
857
|
}
|
|
858
|
+
// 处理dimensionCustomSumKeys的额外合并计算逻辑
|
|
859
|
+
if (dimensionCustomSumKeys && Array.isArray(dimensionCustomSumKeys)) {
|
|
860
|
+
var _loop_8 = function (customSumKey) {
|
|
861
|
+
if (typeof customSumKey === "string") {
|
|
862
|
+
// 如果是字符串,对指定字段进行合计
|
|
863
|
+
summaryRow[customSumKey] = items
|
|
864
|
+
.filter(function (item) { return !isSummaryRow(item); }) // 排除已有的合计行
|
|
865
|
+
.reduce(function (sum, item) {
|
|
866
|
+
var value = parseFloat(item[customSumKey]) || 0;
|
|
867
|
+
return plus(sum, value);
|
|
868
|
+
}, 0);
|
|
869
|
+
}
|
|
870
|
+
else if (typeof customSumKey === "object" &&
|
|
871
|
+
customSumKey.key &&
|
|
872
|
+
typeof customSumKey.value === "function") {
|
|
873
|
+
// 如果是对象,使用自定义的key和value函数
|
|
874
|
+
var key = customSumKey.key, valueFn_1 = customSumKey.value, _f = customSumKey.summaryType, summaryType = _f === void 0 ? "sum" : _f, computedSummary = customSumKey.computedSummary;
|
|
875
|
+
var filteredItems = items.filter(function (item) { return !isSummaryRow(item); }); // 排除已有的合计行
|
|
876
|
+
switch (summaryType) {
|
|
877
|
+
case "sum":
|
|
878
|
+
// 默认累加方式
|
|
879
|
+
var customValues = filteredItems.map(function (item) {
|
|
880
|
+
var result = valueFn_1(item);
|
|
881
|
+
return typeof result === "number"
|
|
882
|
+
? result
|
|
883
|
+
: parseFloat(result) || 0;
|
|
884
|
+
});
|
|
885
|
+
var customSum = customValues.reduce(function (sum, value) {
|
|
886
|
+
return plus(sum, value);
|
|
887
|
+
}, 0);
|
|
888
|
+
summaryRow[key] = customSum;
|
|
889
|
+
break;
|
|
890
|
+
case "first":
|
|
891
|
+
// 使用第一条记录的值
|
|
892
|
+
if (filteredItems.length > 0) {
|
|
893
|
+
var result_1 = valueFn_1(filteredItems[0]);
|
|
894
|
+
summaryRow[key] =
|
|
895
|
+
typeof result_1 === "number" ? result_1 : parseFloat(result_1) || 0;
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
summaryRow[key] = 0;
|
|
899
|
+
}
|
|
900
|
+
break;
|
|
901
|
+
case "computed":
|
|
902
|
+
// 使用自定义计算函数
|
|
903
|
+
if (typeof computedSummary === "function") {
|
|
904
|
+
var result_2 = computedSummary(filteredItems, summaryRow);
|
|
905
|
+
summaryRow[key] =
|
|
906
|
+
typeof result_2 === "number" ? result_2 : parseFloat(result_2) || 0;
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
console.warn("\u5B57\u6BB5 ".concat(key, " \u8BBE\u7F6E\u4E86 summaryType: 'computed' \u4F46\u6CA1\u6709\u63D0\u4F9B computedSummary \u51FD\u6570"));
|
|
910
|
+
summaryRow[key] = 0;
|
|
911
|
+
}
|
|
912
|
+
break;
|
|
913
|
+
default:
|
|
914
|
+
console.warn("\u672A\u77E5\u7684 summaryType: ".concat(summaryType, "\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u7684 sum \u65B9\u5F0F"));
|
|
915
|
+
// 回退到默认的 sum 方式
|
|
916
|
+
var defaultValues = filteredItems.map(function (item) {
|
|
917
|
+
var result = valueFn_1(item);
|
|
918
|
+
return typeof result === "number"
|
|
919
|
+
? result
|
|
920
|
+
: parseFloat(result) || 0;
|
|
921
|
+
});
|
|
922
|
+
var defaultSum = defaultValues.reduce(function (sum, value) {
|
|
923
|
+
return plus(sum, value);
|
|
924
|
+
}, 0);
|
|
925
|
+
summaryRow[key] = defaultSum;
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
for (var _e = 0, dimensionCustomSumKeys_1 = dimensionCustomSumKeys; _e < dimensionCustomSumKeys_1.length; _e++) {
|
|
931
|
+
var customSumKey = dimensionCustomSumKeys_1[_e];
|
|
932
|
+
_loop_8(customSumKey);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
858
935
|
result.push(summaryRow);
|
|
859
936
|
}
|
|
860
937
|
return result;
|