zmdms-webui 2.1.0 → 2.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/dist/es/table/interface.d.ts +5 -1
- package/dist/es/table/table.js +15 -15
- package/dist/es/table/utils.js +43 -35
- package/package.json +1 -1
|
@@ -519,7 +519,7 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
519
519
|
/** 自定义合计的key */
|
|
520
520
|
key: string;
|
|
521
521
|
/** 自定义合计的值 */
|
|
522
|
-
value
|
|
522
|
+
value?: (record: any) => string | number;
|
|
523
523
|
/** 合计方式 */
|
|
524
524
|
summaryType?: "sum" | "first" | "computed";
|
|
525
525
|
/** 当summaryType为computed时,用于计算合计值的函数 */
|
|
@@ -529,6 +529,10 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
529
529
|
* 开启自动合并行
|
|
530
530
|
*/
|
|
531
531
|
isAutoMerge?: boolean;
|
|
532
|
+
/**
|
|
533
|
+
* 导出文件是否添加合计行
|
|
534
|
+
*/
|
|
535
|
+
isExportSummary?: boolean;
|
|
532
536
|
/**
|
|
533
537
|
* table模式
|
|
534
538
|
* 目前index的话会自动加个序号
|
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, 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"]);
|
|
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, _q = props.isExportSummary, isExportSummary = _q === void 0 ? true : _q, 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", "isExportSummary"]);
|
|
45
45
|
var classes = classNames("ztxk-table", className, {
|
|
46
46
|
"ztxk-table--flex": isFlex,
|
|
47
47
|
});
|
|
@@ -53,24 +53,24 @@ var Table = function (props) {
|
|
|
53
53
|
id: menuId,
|
|
54
54
|
}).show;
|
|
55
55
|
// 针对SCU和增减行 做特殊处理
|
|
56
|
-
var
|
|
56
|
+
var _r = useScuRfresh(), refreshScuCell = _r.refreshScuCell, getRefreshScuCell = _r.getRefreshScuCell;
|
|
57
57
|
// 做一些前置处理
|
|
58
58
|
// 比如过滤某些列 不做展示
|
|
59
59
|
var columns = useParseColumns(_columns);
|
|
60
60
|
// 得到动态列配置信息
|
|
61
|
-
var
|
|
61
|
+
var _s = useDynamicListByColumns(columns, {
|
|
62
62
|
dynamicKey: dynamicKey,
|
|
63
63
|
dynamicVersion: dynamicVersion,
|
|
64
64
|
customDynamicListHandle: customDynamicListHandle,
|
|
65
|
-
}), defaultDynamicList =
|
|
65
|
+
}), defaultDynamicList = _s.defaultDynamicList, onCurrentListChange = _s.onCurrentListChange, currentDynamicList = _s.currentDynamicList, dynamicSettingRef = _s.dynamicSettingRef;
|
|
66
66
|
// 因为内部分页需要知晓当前页面的数据展示,要不然数据排序就跟内部分页没关系了
|
|
67
67
|
// 自定义排序方法
|
|
68
|
-
var
|
|
68
|
+
var _t = useCustomSort(dataSource, onTableChange, {
|
|
69
69
|
refreshScuCell: refreshScuCell,
|
|
70
70
|
rowKey: props === null || props === void 0 ? void 0 : props.rowKey,
|
|
71
71
|
serviceOrder: serviceOrder,
|
|
72
72
|
isOrderUpdateData: isOrderUpdateData,
|
|
73
|
-
}), order =
|
|
73
|
+
}), order = _t.order, setOrder = _t.setOrder, customSortHandle = _t.customSortHandle, sortDataSource = _t.sortDataSource;
|
|
74
74
|
// 当前表格展示的数据
|
|
75
75
|
// 如果开启了前端排序的话,排序后的数据,可能会影响到很多地方。
|
|
76
76
|
// 所以后续操作的数据 应该用
|
|
@@ -97,12 +97,12 @@ var Table = function (props) {
|
|
|
97
97
|
return scroll || {};
|
|
98
98
|
}, [scroll, currentTableDataSource, virtualKey, scrolly, isAutoScrollY]);
|
|
99
99
|
// 内部分页相关配置
|
|
100
|
-
var
|
|
100
|
+
var _u = useInnerPagination(isInnerPagination, innerPaginationPageSize, {
|
|
101
101
|
innerPaginationPosition: innerPaginationPosition,
|
|
102
102
|
innerPaginationPageSizeOptions: innerPaginationPageSizeOptions,
|
|
103
103
|
innerPaginationConfig: innerPaginationConfig,
|
|
104
104
|
dataSource: currentTableDataSource,
|
|
105
|
-
}), paginationConfig =
|
|
105
|
+
}), paginationConfig = _u.paginationConfig, currentPage = _u.currentPage, setCurrent = _u.setCurrent, pageSize = _u.pageSize;
|
|
106
106
|
// 内部表格编辑事件
|
|
107
107
|
var onEditableSave = useEditChange(dataSourceRef, onTableChange);
|
|
108
108
|
// 记录表头过滤的一些配置(通过ref记录,key => filter) 复制整列、过滤后修改数据,需要先走过滤
|
|
@@ -130,9 +130,9 @@ var Table = function (props) {
|
|
|
130
130
|
filterConfigRef: filterConfigRef,
|
|
131
131
|
});
|
|
132
132
|
// 表格内部自定义处理过滤,不走antd内部
|
|
133
|
-
var
|
|
133
|
+
var _v = useCustomFilter(currentTableDataSource), filterDataSource = _v[0], handleFilterConfigChange = _v[1];
|
|
134
134
|
// 处理列配置信息 得到新的列配置信息
|
|
135
|
-
var
|
|
135
|
+
var _w = useColumns(columns, {
|
|
136
136
|
// 动态列配置相关信息
|
|
137
137
|
dynamicKey: dynamicKey,
|
|
138
138
|
isRemeberFilter: isRemeberFilter,
|
|
@@ -174,14 +174,14 @@ var Table = function (props) {
|
|
|
174
174
|
mode: mode,
|
|
175
175
|
isAutoMerge: isAutoMerge,
|
|
176
176
|
handleFilterConfigChange: handleFilterConfigChange,
|
|
177
|
-
}), _newColumns =
|
|
177
|
+
}), _newColumns = _w.newColumns, newRowSelection = _w.rowSelection;
|
|
178
178
|
// 处理表格合并和维度
|
|
179
|
-
var
|
|
179
|
+
var _x = useAutoMerge(filterDataSource, _newColumns, {
|
|
180
180
|
isAutoMerge: isAutoMerge,
|
|
181
181
|
isDimensionDynamic: isDimensionDynamic,
|
|
182
182
|
order: order,
|
|
183
183
|
dimensionCustomSumKeys: dimensionCustomSumKeys,
|
|
184
|
-
}), newDataSource =
|
|
184
|
+
}), newDataSource = _x[0], newColumns = _x[1];
|
|
185
185
|
// 内部表格总结栏
|
|
186
186
|
var getSummaryHandle = useSummary(summaryConfig, newColumns, {
|
|
187
187
|
summaryFixed: summaryFixed,
|
|
@@ -191,7 +191,7 @@ var Table = function (props) {
|
|
|
191
191
|
isDel: isDel,
|
|
192
192
|
});
|
|
193
193
|
// 表格验证
|
|
194
|
-
var
|
|
194
|
+
var _y = useTableValidate(), tableRef = _y.tableRef, getCurrentTable = _y.getCurrentTable, clearErrorClass = _y.clearErrorClass;
|
|
195
195
|
// 虚拟滚动选项
|
|
196
196
|
var vComponents = useMemo(function () {
|
|
197
197
|
if (virtualKey) {
|
|
@@ -266,7 +266,7 @@ var Table = function (props) {
|
|
|
266
266
|
var exportExcel = useExcelExport(newDataSource, {
|
|
267
267
|
columns: newColumns,
|
|
268
268
|
isAutoMerge: isAutoMerge,
|
|
269
|
-
summaryConfig: summaryConfig,
|
|
269
|
+
summaryConfig: isExportSummary ? summaryConfig : undefined,
|
|
270
270
|
});
|
|
271
271
|
// 暴露给外部一些方法
|
|
272
272
|
useImperativeHandle(tableRefHandle, function () {
|
package/dist/es/table/utils.js
CHANGED
|
@@ -867,35 +867,39 @@ summaryKeys, dimensionCustomSumKeys) {
|
|
|
867
867
|
return plus(sum, value);
|
|
868
868
|
}, 0);
|
|
869
869
|
}
|
|
870
|
-
else if (typeof customSumKey === "object" &&
|
|
871
|
-
customSumKey.key &&
|
|
872
|
-
typeof customSumKey.value === "function") {
|
|
870
|
+
else if (typeof customSumKey === "object" && customSumKey.key) {
|
|
873
871
|
// 如果是对象,使用自定义的key和value函数
|
|
874
872
|
var key = customSumKey.key, valueFn_1 = customSumKey.value, _f = customSumKey.summaryType, summaryType = _f === void 0 ? "sum" : _f, computedSummary = customSumKey.computedSummary;
|
|
875
873
|
var filteredItems = items.filter(function (item) { return !isSummaryRow(item); }); // 排除已有的合计行
|
|
876
874
|
switch (summaryType) {
|
|
877
875
|
case "sum":
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
var
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
876
|
+
if (valueFn_1) {
|
|
877
|
+
// 默认累加方式
|
|
878
|
+
var customValues = filteredItems.map(function (item) {
|
|
879
|
+
var result = valueFn_1(item);
|
|
880
|
+
return typeof result === "number"
|
|
881
|
+
? result
|
|
882
|
+
: parseFloat(result) || 0;
|
|
883
|
+
});
|
|
884
|
+
var customSum = customValues.reduce(function (sum, value) {
|
|
885
|
+
return plus(sum, value);
|
|
886
|
+
}, 0);
|
|
887
|
+
summaryRow[key] = customSum;
|
|
888
|
+
}
|
|
889
889
|
break;
|
|
890
890
|
case "first":
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
891
|
+
if (valueFn_1) {
|
|
892
|
+
// 使用第一条记录的值
|
|
893
|
+
if (filteredItems.length > 0) {
|
|
894
|
+
var result_1 = valueFn_1(filteredItems[0]);
|
|
895
|
+
summaryRow[key] =
|
|
896
|
+
typeof result_1 === "number"
|
|
897
|
+
? result_1
|
|
898
|
+
: parseFloat(result_1) || 0;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
summaryRow[key] = 0;
|
|
902
|
+
}
|
|
899
903
|
}
|
|
900
904
|
break;
|
|
901
905
|
case "computed":
|
|
@@ -903,7 +907,9 @@ summaryKeys, dimensionCustomSumKeys) {
|
|
|
903
907
|
if (typeof computedSummary === "function") {
|
|
904
908
|
var result_2 = computedSummary(filteredItems, summaryRow);
|
|
905
909
|
summaryRow[key] =
|
|
906
|
-
typeof result_2 === "number"
|
|
910
|
+
typeof result_2 === "number"
|
|
911
|
+
? result_2
|
|
912
|
+
: parseFloat(result_2) || result_2;
|
|
907
913
|
}
|
|
908
914
|
else {
|
|
909
915
|
console.warn("\u5B57\u6BB5 ".concat(key, " \u8BBE\u7F6E\u4E86 summaryType: 'computed' \u4F46\u6CA1\u6709\u63D0\u4F9B computedSummary \u51FD\u6570"));
|
|
@@ -912,18 +918,20 @@ summaryKeys, dimensionCustomSumKeys) {
|
|
|
912
918
|
break;
|
|
913
919
|
default:
|
|
914
920
|
console.warn("\u672A\u77E5\u7684 summaryType: ".concat(summaryType, "\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u7684 sum \u65B9\u5F0F"));
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
var
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
921
|
+
if (valueFn_1) {
|
|
922
|
+
// 回退到默认的 sum 方式
|
|
923
|
+
var defaultValues = filteredItems.map(function (item) {
|
|
924
|
+
var result = valueFn_1(item);
|
|
925
|
+
return typeof result === "number"
|
|
926
|
+
? result
|
|
927
|
+
: parseFloat(result) || 0;
|
|
928
|
+
});
|
|
929
|
+
var defaultSum = defaultValues.reduce(function (sum, value) {
|
|
930
|
+
return plus(sum, value);
|
|
931
|
+
}, 0);
|
|
932
|
+
summaryRow[key] = defaultSum;
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
927
935
|
}
|
|
928
936
|
}
|
|
929
937
|
};
|