zmdms-webui 1.7.4 → 1.7.5
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/dynamicsetting/dynamicDrawer.js +95 -34
- package/dist/es/dynamicsetting/dynamicSetting.js +2 -2
- package/dist/es/dynamicsetting/index.css +1 -1
- package/dist/es/dynamicsetting/interface.d.ts +5 -0
- package/dist/es/dynamicsetting/moreConfig.js +14 -3
- package/dist/es/dynamicsetting/useDynamic.js +3 -0
- package/dist/es/table/constant.js +6 -2
- package/dist/es/table/hooks.js +101 -3
- package/dist/es/table/interface.d.ts +37 -0
- package/dist/es/table/table.js +12 -6
- package/dist/es/table/useColumns.js +17 -1
- package/dist/es/table/useDynamicListByColumns.js +5 -1
- package/dist/es/table/utils.js +227 -3
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __assign, __spreadArray } from '../_virtual/_tslib.js';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, forwardRef, useImperativeHandle, useMemo, useCallback } from 'react';
|
|
4
4
|
import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
|
|
@@ -10,15 +10,25 @@ import MoreConfig from './moreConfig.js';
|
|
|
10
10
|
import SettingOutlined from '../node_modules/@ant-design/icons/es/icons/SettingOutlined.js';
|
|
11
11
|
import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js';
|
|
12
12
|
import ButtonCom from '../button/button.js';
|
|
13
|
-
import { Drawer, Checkbox } from 'antd';
|
|
13
|
+
import { message, Drawer, Checkbox } from 'antd';
|
|
14
14
|
|
|
15
|
+
// 工具函数,排序分区
|
|
16
|
+
var sortDynamicListByType = function (list) {
|
|
17
|
+
var dimensionList = list.filter(function (item) { return item.isDimension; });
|
|
18
|
+
var fieldList = list.filter(function (item) { return !item.isDimension; });
|
|
19
|
+
var leftList = fieldList.filter(function (item) { return item.fixed === "left"; });
|
|
20
|
+
var middleList = fieldList.filter(function (item) { return !item.fixed; });
|
|
21
|
+
var rightList = fieldList.filter(function (item) { return item.fixed === "right"; });
|
|
22
|
+
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], dimensionList, true), leftList, true), middleList, true), rightList, true);
|
|
23
|
+
};
|
|
15
24
|
// 这里操作的一直都是内部设置的list
|
|
16
25
|
var DynamicDrawer = function (props, ref) {
|
|
17
|
-
var list = props.list, dynamicKey = props.dynamicKey, parentDynamicKey = props.parentDynamicKey, _a = props.title, title = _a === void 0 ? "自定义配置" : _a, onCurrentListChange = props.onCurrentListChange, isMore = props.isMore, isFixed = props.isFixed;
|
|
26
|
+
var list = props.list, dynamicKey = props.dynamicKey, parentDynamicKey = props.parentDynamicKey, _a = props.title, title = _a === void 0 ? "自定义配置" : _a, onCurrentListChange = props.onCurrentListChange, isMore = props.isMore, isFixed = props.isFixed, isDimensionDynamic = props.isDimensionDynamic;
|
|
18
27
|
// 根据外部传入的list 和本地存储信息 生成一个内部的currentDynamicList
|
|
19
28
|
// 这个currentDynamicList 是可以是负责显示最终结果的
|
|
20
29
|
// tempDynamicList 是操作时的临时变量 可能操作后不点击确认 直接点击取消 那么需要重置到之前的状态
|
|
21
30
|
var _b = useDynamic(dynamicKey, parentDynamicKey, list), currentDynamicList = _b.currentDynamicList, setCurrentDynamicList = _b.setCurrentDynamicList, tempDynamicList = _b.tempDynamicList, setTempDynamicList = _b.setTempDynamicList;
|
|
31
|
+
console.log("tempDynamicList", tempDynamicList);
|
|
22
32
|
var _c = useDrawer(currentDynamicList, setCurrentDynamicList, dynamicKey, parentDynamicKey, setTempDynamicList, list, onCurrentListChange), visible = _c.visible, setVisible = _c.setVisible, onClose = _c.onClose, onReset = _c.onReset, onSure = _c.onSure;
|
|
23
33
|
// 像外部暴露方法
|
|
24
34
|
useImperativeHandle(ref, function () {
|
|
@@ -38,8 +48,34 @@ var DynamicDrawer = function (props, ref) {
|
|
|
38
48
|
});
|
|
39
49
|
return _checkedValues;
|
|
40
50
|
}, [tempDynamicList]);
|
|
51
|
+
// 根据isDimension分区
|
|
52
|
+
var _d = useMemo(function () {
|
|
53
|
+
var dimensionList = tempDynamicList.filter(function (item) { return item.isDimension; });
|
|
54
|
+
var fieldList = tempDynamicList.filter(function (item) { return !item.isDimension; });
|
|
55
|
+
return { dimensionList: dimensionList, fieldList: fieldList };
|
|
56
|
+
}, [tempDynamicList]), dimensionList = _d.dimensionList, fieldList = _d.fieldList;
|
|
57
|
+
// 排序优先级判断
|
|
58
|
+
var isDimensionPriority = useCallback(function (dragIndex, hoverIndex) {
|
|
59
|
+
// 从上到下还是从下到上拖动
|
|
60
|
+
var isUp = dragIndex < hoverIndex;
|
|
61
|
+
var startIndex = isUp ? dragIndex : hoverIndex;
|
|
62
|
+
var endIndex = isUp ? hoverIndex : dragIndex;
|
|
63
|
+
var oldItem = tempDynamicList[startIndex];
|
|
64
|
+
var dragItem = tempDynamicList[endIndex];
|
|
65
|
+
if ((oldItem === null || oldItem === void 0 ? void 0 : oldItem.dimensionPriority) !== undefined) {
|
|
66
|
+
if ((dragItem === null || dragItem === void 0 ? void 0 : dragItem.dimensionPriority) === undefined ||
|
|
67
|
+
(oldItem === null || oldItem === void 0 ? void 0 : oldItem.dimensionPriority) < (dragItem === null || dragItem === void 0 ? void 0 : dragItem.dimensionPriority)) {
|
|
68
|
+
message.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 ? "前面" : "后面"));
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}, [tempDynamicList]);
|
|
41
74
|
// 拖拽
|
|
42
75
|
var onMoveItem = useCallback(function (dragIndex, hoverIndex) {
|
|
76
|
+
if (!isDimensionPriority(dragIndex, hoverIndex)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
43
79
|
// 由于对于固定列,不能进行拖拽排序,所以需要找出所有包含固定列的属性出来
|
|
44
80
|
setTempDynamicList(function (preDynamicList) {
|
|
45
81
|
var dragCard = preDynamicList[dragIndex];
|
|
@@ -50,15 +86,15 @@ var DynamicDrawer = function (props, ref) {
|
|
|
50
86
|
],
|
|
51
87
|
});
|
|
52
88
|
// 处理左浮动 右浮动数据。需要重新排序
|
|
53
|
-
|
|
54
|
-
var middleList = currentList.filter(function (item) { return !item.fixed; });
|
|
55
|
-
var rightList = currentList.filter(function (item) { return item.fixed === "right"; });
|
|
56
|
-
return __spreadArray(__spreadArray(__spreadArray([], leftList, true), middleList, true), rightList, true);
|
|
89
|
+
return sortDynamicListByType(currentList);
|
|
57
90
|
});
|
|
58
|
-
}, [setTempDynamicList]);
|
|
91
|
+
}, [setTempDynamicList, isDimensionPriority]);
|
|
59
92
|
// 子元素拖拽
|
|
60
93
|
var onChildMoveItem = useCallback(function (pIndex, pKey) {
|
|
61
94
|
return function (dragIndex, hoverIndex) {
|
|
95
|
+
if (!isDimensionPriority(dragIndex, hoverIndex)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
62
98
|
// 由于对于固定列,不能进行拖拽排序,所以需要找出所有包含固定列的属性出来
|
|
63
99
|
setTempDynamicList(function (preDynamicList) {
|
|
64
100
|
var newDynamicList = preDynamicList.map(function (item) { return (__assign({}, item)); }) || [];
|
|
@@ -79,21 +115,42 @@ var DynamicDrawer = function (props, ref) {
|
|
|
79
115
|
return __spreadArray(__spreadArray(__spreadArray([], leftList, true), middleList, true), rightList, true);
|
|
80
116
|
});
|
|
81
117
|
};
|
|
82
|
-
}, [setTempDynamicList]);
|
|
118
|
+
}, [setTempDynamicList, isDimensionPriority]);
|
|
83
119
|
// 确认
|
|
84
120
|
var onSureHandle = function () {
|
|
85
121
|
onSure && onSure(tempDynamicList);
|
|
86
122
|
};
|
|
87
123
|
var onCheckboxChange = function (checkedValues) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
124
|
+
// 1. 构建互斥关系映射
|
|
125
|
+
var exclusiveMap = {};
|
|
126
|
+
tempDynamicList.forEach(function (item) {
|
|
127
|
+
var key = item.key;
|
|
128
|
+
var exclusiveKeys = (item.dimensionExclusive || "")
|
|
129
|
+
.split(",")
|
|
130
|
+
.map(function (k) { return k.trim(); })
|
|
131
|
+
.filter(Boolean);
|
|
132
|
+
exclusiveMap[key] = new Set(__spreadArray([key], exclusiveKeys, true));
|
|
96
133
|
});
|
|
134
|
+
// 2. 检查本次勾选是否有互斥
|
|
135
|
+
var hasConflict = false;
|
|
136
|
+
for (var i = 0; i < checkedValues.length; i++) {
|
|
137
|
+
for (var j = i + 1; j < checkedValues.length; j++) {
|
|
138
|
+
var keyA = checkedValues[i];
|
|
139
|
+
var keyB = checkedValues[j];
|
|
140
|
+
if (exclusiveMap[keyA] && exclusiveMap[keyA].has(keyB)) {
|
|
141
|
+
hasConflict = true;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (hasConflict)
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
if (hasConflict) {
|
|
149
|
+
message.warning("所选项存在互斥关系,不能同时勾选!");
|
|
150
|
+
return; // 拦截本次勾选
|
|
151
|
+
}
|
|
152
|
+
// 3. 正常更新
|
|
153
|
+
var newDynamicList = tempDynamicList.map(function (item) { return (__assign(__assign({}, item), { checked: checkedValues.includes(item.key) })); });
|
|
97
154
|
setTempDynamicList(newDynamicList);
|
|
98
155
|
};
|
|
99
156
|
var onChildCheckboxChange = function (checkedValues, pIndex) {
|
|
@@ -112,7 +169,7 @@ var DynamicDrawer = function (props, ref) {
|
|
|
112
169
|
}
|
|
113
170
|
});
|
|
114
171
|
newDynamicList[pIndex].children = changeCList;
|
|
115
|
-
setTempDynamicList(newDynamicList);
|
|
172
|
+
setTempDynamicList(sortDynamicListByType(newDynamicList));
|
|
116
173
|
};
|
|
117
174
|
// 后期可能需要拓展功能
|
|
118
175
|
var onMoreChange = function (key, result) {
|
|
@@ -120,22 +177,22 @@ var DynamicDrawer = function (props, ref) {
|
|
|
120
177
|
var currentIndex = newDynamicList.findIndex(function (item) { return key === item.key; });
|
|
121
178
|
var currentItem = newDynamicList[currentIndex];
|
|
122
179
|
// 如果什么都没改
|
|
123
|
-
if (currentItem.fixed === result.fixed
|
|
180
|
+
if (currentItem.fixed === result.fixed &&
|
|
181
|
+
currentItem.isDimensionSum === result.isDimensionSum) {
|
|
124
182
|
return;
|
|
125
183
|
}
|
|
126
184
|
// 可固定的列 只能是首尾的列
|
|
127
185
|
currentItem.fixed = result.fixed;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var rightList = newDynamicList.filter(function (item) { return item.fixed === "right"; });
|
|
131
|
-
setTempDynamicList(__spreadArray(__spreadArray(__spreadArray([], leftList, true), middleList, true), rightList, true));
|
|
186
|
+
currentItem.isDimensionSum = result.isDimensionSum;
|
|
187
|
+
setTempDynamicList(sortDynamicListByType(newDynamicList));
|
|
132
188
|
};
|
|
133
|
-
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
189
|
+
// 渲染区块
|
|
190
|
+
var renderSection = function (list, indexOffset, title) {
|
|
191
|
+
if (indexOffset === void 0) { indexOffset = 0; }
|
|
192
|
+
if (!list.length)
|
|
193
|
+
return null;
|
|
194
|
+
return (jsxs("div", { children: [title && jsx("div", __assign({ className: "dynamic-drawer-section-title" }, { children: title })), list.map(function (item, index) {
|
|
195
|
+
var key = item.key, disabled = item.disabled, label = item.label, fixed = item.fixed, children = item.children, isDimensionSum = item.isDimensionSum, isDimension = item.isDimension;
|
|
139
196
|
var childrenCheckedValues = [];
|
|
140
197
|
if (Array.isArray(children)) {
|
|
141
198
|
children.forEach(function (item) {
|
|
@@ -144,15 +201,19 @@ var DynamicDrawer = function (props, ref) {
|
|
|
144
201
|
}
|
|
145
202
|
});
|
|
146
203
|
}
|
|
147
|
-
return (jsxs(Sortable, __assign({ type: "search-drawer", index: index, onMoveItem: onMoveItem }, { children: [jsxs("div", __assign({ className: "zt-sortable--item" }, { children: [jsx(Checkbox, __assign({ value: key, disabled: disabled }, { children: label || key })), isMore && (!children || children.length === 0) && (jsx(MoreConfig, { fixed: fixed || "", onChange: function (result) {
|
|
204
|
+
return (jsxs(Sortable, __assign({ type: "search-drawer", index: indexOffset + index, onMoveItem: onMoveItem }, { children: [jsxs("div", __assign({ className: "zt-sortable--item dynamic-drawer-card" }, { children: [jsx(Checkbox, __assign({ value: key, disabled: disabled }, { children: label || key })), isMore && (!children || children.length === 0) && (jsx(MoreConfig, { fixed: fixed || "", isDimensionSum: isDimensionSum, onChange: function (result) {
|
|
148
205
|
onMoreChange(key, result);
|
|
149
|
-
}, isFixed: isFixed }))] })), Array.isArray(children) && children.length > 0 ? (jsx("div", __assign({ className: "zt-sortable--children" }, { children: jsx(Checkbox.Group, __assign({ value: childrenCheckedValues, onChange: function (checkedValues) {
|
|
150
|
-
onChildCheckboxChange(checkedValues,
|
|
206
|
+
}, isSum: isDimension, isFixed: isFixed }))] })), Array.isArray(children) && children.length > 0 ? (jsx("div", __assign({ className: "zt-sortable--children dynamic-drawer-children", style: { marginLeft: 32, marginBottom: 8 } }, { children: jsx(Checkbox.Group, __assign({ value: childrenCheckedValues, onChange: function (checkedValues) {
|
|
207
|
+
onChildCheckboxChange(checkedValues, tempDynamicList.indexOf(item));
|
|
151
208
|
} }, { children: children.map(function (cItem, cIndex) {
|
|
152
209
|
var cKey = cItem.key, cLabel = cItem.label, cDisabled = cItem.disabled;
|
|
153
|
-
return (jsx(Sortable, __assign({ type: "search-drawer-".concat(key), index: cIndex, onMoveItem: onChildMoveItem(
|
|
210
|
+
return (jsx(Sortable, __assign({ type: "search-drawer-".concat(key), index: cIndex, onMoveItem: onChildMoveItem(tempDynamicList.indexOf(item), key) }, { children: jsx("div", __assign({ className: "dynamic-drawer-card dynamic-drawer-child-card" }, { children: jsx(Checkbox, __assign({ value: cKey, disabled: cDisabled }, { children: cLabel || cKey })) })) }), cKey));
|
|
154
211
|
}) })) }))) : null] }), key));
|
|
155
|
-
}) }))
|
|
212
|
+
})] }));
|
|
213
|
+
};
|
|
214
|
+
/**底部按钮 */
|
|
215
|
+
var renderFooter = function () { return (jsxs(Fragment, { children: [jsx(ButtonCom, __assign({ type: "default", onClick: onClose }, { children: "\u53D6\u6D88" })), jsx(ButtonCom, __assign({ type: "default", onClick: onReset }, { children: "\u91CD\u7F6E" })), jsx(ButtonCom, __assign({ type: "primary", onClick: onSureHandle }, { children: "\u786E\u5B9A" }))] })); };
|
|
216
|
+
return (jsx(Drawer, __assign({ className: "dynamic-drawer", title: jsxs("div", { children: [jsx(SettingOutlined, { style: { fontSize: 16 } }), jsxs("span", __assign({ className: "search-drawer--title-text" }, { children: [title, jsx("span", { children: "\uFF08\u62D6\u62FD\u6392\u5E8F\uFF09" })] }))] }), width: 300, placement: "right", open: visible, closable: false, maskClosable: false, footer: renderFooter() }, { children: jsx(Checkbox.Group, __assign({ value: checkedValues, onChange: onCheckboxChange }, { children: jsxs(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: [isDimensionDynamic && renderSection(dimensionList, 0, "维度配置"), renderSection(fieldList, dimensionList.length, isDimensionDynamic ? "字段配置" : undefined)] })) })) })));
|
|
156
217
|
};
|
|
157
218
|
DynamicDrawer.displayName = "ZTXK_WEBUI_DynamicDrawer";
|
|
158
219
|
var DynamicDrawer$1 = memo(forwardRef(DynamicDrawer));
|
|
@@ -11,7 +11,7 @@ import SettingOutlined from '../node_modules/@ant-design/icons/es/icons/SettingO
|
|
|
11
11
|
// 内部根据这个list初始值,生成一个内部的currentDynamicList 作为操作 显示的数据
|
|
12
12
|
// 当内部的currentDynamicList 发生改变的时候 触发currentDynamicListChange事件 通知外部,数据发生改变了
|
|
13
13
|
var DynamicSetting = function (props, ref) {
|
|
14
|
-
var dynamicKey = props.dynamicKey, parentDynamicKey = props.parentDynamicKey, defaultList = props.defaultList, children = props.children, title = props.title, onCurrentListChange = props.onCurrentListChange, hiddenOperationIcon = props.hiddenOperationIcon, isMore = props.isMore, isFixed = props.isFixed;
|
|
14
|
+
var dynamicKey = props.dynamicKey, parentDynamicKey = props.parentDynamicKey, defaultList = props.defaultList, children = props.children, title = props.title, onCurrentListChange = props.onCurrentListChange, hiddenOperationIcon = props.hiddenOperationIcon, isMore = props.isMore, isFixed = props.isFixed, isDimensionDynamic = props.isDimensionDynamic;
|
|
15
15
|
// 内部初始list
|
|
16
16
|
var _a = useState(defaultList), list = _a[0], setList = _a[1];
|
|
17
17
|
var drawerRef = useRef({});
|
|
@@ -40,7 +40,7 @@ var DynamicSetting = function (props, ref) {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
|
-
return Array.isArray(list) && list.length > 0 ? (jsxs("div", __assign({ className: "ztxk-dynamic-setting" }, { children: [hiddenOperationIcon ? null : (jsx("div", __assign({ onClick: function () { var _a; return (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.setVisible(true); } }, { children: children ? (children) : (jsx(SettingOutlined, { style: { fontSize: 18, color: "#768696" } })) }))), jsx(DynamicDrawer, { list: list, dynamicKey: dynamicKey, parentDynamicKey: parentDynamicKey, ref: drawerRef, title: title, onCurrentListChange: onCurrentListChange, isFixed: isFixed, isMore: isMore })] }))) : null;
|
|
43
|
+
return Array.isArray(list) && list.length > 0 ? (jsxs("div", __assign({ className: "ztxk-dynamic-setting" }, { children: [hiddenOperationIcon ? null : (jsx("div", __assign({ onClick: function () { var _a; return (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.setVisible(true); } }, { children: children ? (children) : (jsx(SettingOutlined, { style: { fontSize: 18, color: "#768696" } })) }))), jsx(DynamicDrawer, { list: list, dynamicKey: dynamicKey, parentDynamicKey: parentDynamicKey, ref: drawerRef, title: title, onCurrentListChange: onCurrentListChange, isFixed: isFixed, isMore: isMore, isDimensionDynamic: isDimensionDynamic })] }))) : null;
|
|
44
44
|
};
|
|
45
45
|
DynamicSetting.displayName = "ZTXK_WEBUI_DynamicSetting";
|
|
46
46
|
var DynamicSetting$1 = memo(forwardRef(DynamicSetting));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.zt-sortable{cursor:move;font-size:13px;line-height:38px;overflow:hidden;text-align:left}.zt-sortable .zt-sortable--item{align-items:center;display:flex;justify-content:space-between;padding:0 16px}.zt-sortable .zt-sortable--children{display:flex}.zt-sortable .zt-sortable--children .zt-sortable{border-bottom:none;padding:0 26px}.zt-sortable.no-move{cursor:no-drop}.zt-sortable .zt-checkbox{font-size:13px}.zt-sortable:hover{background-color:#ebf3fe}.ztxk-dynamic--more{cursor:pointer;height:20px}.ant-dropdown-show-arrow.ztxk-dynamic--more--drop{padding-top:0}.ztxk-dynamic--more--drop.ant-dropdown-placement-bottomRight>.ant-dropdown-arrow{top:-5px}.dynamic-drawer .ant-drawer-header{padding:10px 12px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div{align-items:center;color:#768696;display:flex;font-size:16px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div .search-drawer--title-text{font-size:14px;margin-left:10px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div .search-drawer--title-text>span{font-size:13px}.dynamic-drawer .ant-drawer-body{padding:0}.dynamic-drawer .ant-drawer-body .ant-checkbox-group{width:100%}.dynamic-drawer .ant-drawer-footer{border-top:none;display:flex;justify-content:space-between;padding:0}.dynamic-drawer .ant-drawer-footer>button{border:none;border-radius:0;height:40px;width:33%}
|
|
1
|
+
.zt-sortable{cursor:move;font-size:13px;line-height:38px;overflow:hidden;text-align:left}.zt-sortable .zt-sortable--item{align-items:center;display:flex;justify-content:space-between;padding:0 16px}.zt-sortable .zt-sortable--children{display:flex}.zt-sortable .zt-sortable--children .zt-sortable{border-bottom:none;padding:0 26px}.zt-sortable.no-move{cursor:no-drop}.zt-sortable .zt-checkbox{font-size:13px}.zt-sortable:hover{background-color:#ebf3fe}.ztxk-dynamic--more{cursor:pointer;height:20px}.ant-dropdown-show-arrow.ztxk-dynamic--more--drop{padding-top:0}.ztxk-dynamic--more--drop.ant-dropdown-placement-bottomRight>.ant-dropdown-arrow{top:-5px}.dynamic-drawer .ant-drawer-header{padding:10px 12px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div{align-items:center;color:#768696;display:flex;font-size:16px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div .search-drawer--title-text{font-size:14px;margin-left:10px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div .search-drawer--title-text>span{font-size:13px}.dynamic-drawer .ant-drawer-body{padding:0}.dynamic-drawer .ant-drawer-body .ant-checkbox-group{width:100%}.dynamic-drawer .ant-drawer-footer{border-top:none;display:flex;justify-content:space-between;padding:0}.dynamic-drawer .ant-drawer-footer>button{border:none;border-radius:0;height:40px;width:33%}.dynamic-drawer-section-title{background:#f5f5f5;border-radius:6px;font-size:14px;font-weight:700;padding:4px}
|
|
@@ -8,6 +8,10 @@ interface IDynamicItem {
|
|
|
8
8
|
children?: IDynamicItem[];
|
|
9
9
|
indexs?: number[];
|
|
10
10
|
filter?: IFilter;
|
|
11
|
+
isDimension?: boolean;
|
|
12
|
+
dimensionPriority?: number;
|
|
13
|
+
dimensionExclusive?: string;
|
|
14
|
+
isDimensionSum?: boolean;
|
|
11
15
|
[props: string]: any;
|
|
12
16
|
}
|
|
13
17
|
interface IFilter {
|
|
@@ -24,6 +28,7 @@ interface IDynamicSettingProps {
|
|
|
24
28
|
hiddenOperationIcon?: boolean;
|
|
25
29
|
isMore?: boolean;
|
|
26
30
|
isFixed?: boolean;
|
|
31
|
+
isDimensionDynamic?: boolean;
|
|
27
32
|
}
|
|
28
33
|
interface IRef {
|
|
29
34
|
getCurrentDynamicList: (list: IDynamicItem[]) => IDynamicItem[];
|
|
@@ -3,16 +3,20 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { memo, useState } from 'react';
|
|
4
4
|
import { useLatest } from 'ahooks';
|
|
5
5
|
import MenuOutlined from '../node_modules/@ant-design/icons/es/icons/MenuOutlined.js';
|
|
6
|
-
import { Radio, Dropdown } from 'antd';
|
|
6
|
+
import { Radio, Switch, Dropdown } from 'antd';
|
|
7
7
|
|
|
8
8
|
var MoreConfig = function (_a) {
|
|
9
|
-
var fixed = _a.fixed, onChange = _a.onChange, isFixed = _a.isFixed;
|
|
9
|
+
var fixed = _a.fixed, onChange = _a.onChange, isFixed = _a.isFixed, isSum = _a.isSum, isDimensionSum = _a.isDimensionSum;
|
|
10
|
+
var onChangeLastestRef = useLatest(onChange);
|
|
10
11
|
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
11
12
|
var _c = useState(fixed), fixedValue = _c[0], setFixedValue = _c[1];
|
|
12
|
-
var onChangeLastestRef = useLatest(onChange);
|
|
13
13
|
var onFixedChange = function (e) {
|
|
14
14
|
setFixedValue(e.target.value);
|
|
15
15
|
};
|
|
16
|
+
var _d = useState(isDimensionSum || false), sumChecked = _d[0], setSumChecked = _d[1];
|
|
17
|
+
var onSumChange = function (checked) {
|
|
18
|
+
setSumChecked(checked);
|
|
19
|
+
};
|
|
16
20
|
var fixedItem = {
|
|
17
21
|
label: (jsxs("div", { children: ["\u56FA\u5B9A\uFF1A", jsxs(Radio.Group, __assign({ name: "dynamic-fixed", value: fixedValue, onChange: onFixedChange, optionType: "button", buttonStyle: "solid" }, { children: [jsx(Radio, __assign({ value: "left" }, { children: "\u5DE6" })), jsx(Radio, __assign({ value: "right" }, { children: "\u53F3" })), jsx(Radio, __assign({ value: "" }, { children: "\u65E0" }))] }))] })),
|
|
18
22
|
key: "0",
|
|
@@ -21,12 +25,19 @@ var MoreConfig = function (_a) {
|
|
|
21
25
|
if (isFixed) {
|
|
22
26
|
items.push(fixedItem);
|
|
23
27
|
}
|
|
28
|
+
if (isSum) {
|
|
29
|
+
items.push({
|
|
30
|
+
label: (jsxs("div", { children: ["\u5408\u8BA1\uFF1A", jsx(Switch, { checked: sumChecked, onChange: onSumChange })] })),
|
|
31
|
+
key: "1",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
24
34
|
return (jsx(Dropdown, __assign({ menu: { items: items }, trigger: ["click"], open: open, onOpenChange: function (open) {
|
|
25
35
|
setOpen(open);
|
|
26
36
|
if (!open) {
|
|
27
37
|
onChangeLastestRef.current &&
|
|
28
38
|
onChangeLastestRef.current({
|
|
29
39
|
fixed: fixedValue,
|
|
40
|
+
isDimensionSum: sumChecked,
|
|
30
41
|
});
|
|
31
42
|
}
|
|
32
43
|
}, placement: "bottomLeft", arrow: true, overlayClassName: "ztxk-dynamic--more--drop" }, { children: jsx(MenuOutlined, { className: "ztxk-dynamic--more" }) })));
|
|
@@ -15,6 +15,9 @@ function recursionDynamicItems(list, currentDynamicList) {
|
|
|
15
15
|
currentData.label = result.label;
|
|
16
16
|
currentData.isFind = true; // 代表当前这个字段被找到
|
|
17
17
|
currentData.disabled = result.disabled;
|
|
18
|
+
currentData.isDimension = result.isDimension;
|
|
19
|
+
currentData.dimensionPriority = result.dimensionPriority;
|
|
20
|
+
currentData.dimensionExclusive = result.dimensionExclusive;
|
|
18
21
|
// 判断是否是多级表头,这里的逻辑处理是为了兼容
|
|
19
22
|
// 后面改造成多级表头的情况
|
|
20
23
|
if (item.children) {
|
|
@@ -4,6 +4,10 @@ var INNER_TABLE_PAGINATION_POSITION = ["bottomLeft"];
|
|
|
4
4
|
var INNER_TABLE_PAGINATION_PAGESIZEOPTIONS = ["10", "20", "30", "40"];
|
|
5
5
|
var ERROR_TD_CLASSNAME = "error-td";
|
|
6
6
|
var ASCEND = "ascend"; // 升序
|
|
7
|
-
var DESCEND = "descend"; // 降序
|
|
7
|
+
var DESCEND = "descend"; // 降序
|
|
8
|
+
// 合并后数据标识
|
|
9
|
+
var MERGE_KEY = "__row_id";
|
|
10
|
+
var MERGE_ROW_SPANS = "__row_spans";
|
|
11
|
+
var MERGE_INDEX = "__row_index";
|
|
8
12
|
|
|
9
|
-
export { ASCEND, DESCEND, ERROR_TD_CLASSNAME, INNER_TABLE_PAGINATION_PAGESIZEOPTIONS, INNER_TABLE_PAGINATION_POSITION, TABLE_DRAG_ROW_TYPE, TABLE_DYNAMIC_KEY };
|
|
13
|
+
export { ASCEND, DESCEND, ERROR_TD_CLASSNAME, INNER_TABLE_PAGINATION_PAGESIZEOPTIONS, INNER_TABLE_PAGINATION_POSITION, MERGE_INDEX, MERGE_KEY, MERGE_ROW_SPANS, TABLE_DRAG_ROW_TYPE, TABLE_DYNAMIC_KEY };
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
-
import { useCallback, useRef, useState, useEffect } from 'react';
|
|
1
|
+
import { __assign, __spreadArray } from '../_virtual/_tslib.js';
|
|
2
|
+
import { useCallback, useRef, useState, useEffect, useMemo } from 'react';
|
|
3
3
|
import update from '../node_modules/immutability-helper/index.js';
|
|
4
4
|
import { getInnerIndex } from './useInnerPagination.js';
|
|
5
|
+
import { flattenRecordsOptimized } from './utils.js';
|
|
6
|
+
import { MERGE_INDEX, MERGE_ROW_SPANS } from './constant.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* @param dataSourceRef 数据引用
|
|
@@ -326,6 +328,102 @@ function useCalcScrollY(isAutoScrollY, subHeight, id) {
|
|
|
326
328
|
}
|
|
327
329
|
}, [isAutoScrollY, subHeight, id]);
|
|
328
330
|
return tableHeight;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 自动合并的一些处理
|
|
334
|
+
*/
|
|
335
|
+
function useAutoMerge(dataSource, columns, _a) {
|
|
336
|
+
var mode = _a.mode, isAutoMerge = _a.isAutoMerge;
|
|
337
|
+
// 计算需要合并的字段key集合
|
|
338
|
+
var mergeKeys = useMemo(function () {
|
|
339
|
+
if (isAutoMerge) {
|
|
340
|
+
return columns
|
|
341
|
+
.filter(function (item) { return item.isMerge && item.key !== MERGE_INDEX; })
|
|
342
|
+
.map(function (item) { return item.key; });
|
|
343
|
+
}
|
|
344
|
+
return undefined;
|
|
345
|
+
}, [isAutoMerge, columns]);
|
|
346
|
+
var firstMergeKey = mergeKeys === null || mergeKeys === void 0 ? void 0 : mergeKeys[0];
|
|
347
|
+
// 需要合计的字段
|
|
348
|
+
var summaryKeys = useMemo(function () {
|
|
349
|
+
return columns.filter(function (item) { return item.isSummary; }).map(function (item) { return item.key; });
|
|
350
|
+
}, [columns]);
|
|
351
|
+
// 开启维度合并的维度字段
|
|
352
|
+
var dimensionSummaryKeys = useMemo(function () {
|
|
353
|
+
return columns
|
|
354
|
+
.filter(function (item) { return item.isDimensionSum; })
|
|
355
|
+
.map(function (item) { return item.key; });
|
|
356
|
+
}, [columns]);
|
|
357
|
+
var newDataSource = useMemo(function () {
|
|
358
|
+
if (!isAutoMerge)
|
|
359
|
+
return dataSource;
|
|
360
|
+
else {
|
|
361
|
+
// 多字段合并
|
|
362
|
+
if (!mergeKeys)
|
|
363
|
+
return dataSource;
|
|
364
|
+
else {
|
|
365
|
+
var newDataSource_2 = flattenRecordsOptimized(__spreadArray([], (dataSource || []), true), mergeKeys, dimensionSummaryKeys, summaryKeys);
|
|
366
|
+
return newDataSource_2;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}, [dataSource, isAutoMerge, mergeKeys, dimensionSummaryKeys, summaryKeys]);
|
|
370
|
+
var newColumns = useMemo(function () {
|
|
371
|
+
var _columns = columns;
|
|
372
|
+
if (mode === "index") {
|
|
373
|
+
// 自动添加序号列,支持合并不参与自定义配置
|
|
374
|
+
_columns = __spreadArray([
|
|
375
|
+
{
|
|
376
|
+
title: "序号",
|
|
377
|
+
width: 60,
|
|
378
|
+
key: "index",
|
|
379
|
+
fixed: "left",
|
|
380
|
+
align: "center",
|
|
381
|
+
isMerge: isAutoMerge,
|
|
382
|
+
isFilter: false,
|
|
383
|
+
render: function (value, record, index) {
|
|
384
|
+
if (isAutoMerge) {
|
|
385
|
+
return record[MERGE_INDEX] + 1;
|
|
386
|
+
}
|
|
387
|
+
return "".concat(index + 1);
|
|
388
|
+
},
|
|
389
|
+
}
|
|
390
|
+
], _columns, true);
|
|
391
|
+
}
|
|
392
|
+
// 递归处理多级表头,自动补充render/合并/编辑等逻辑
|
|
393
|
+
var newColumns = _columns.map(function (item) {
|
|
394
|
+
return getColumnItem(item);
|
|
395
|
+
});
|
|
396
|
+
return newColumns;
|
|
397
|
+
// 处理单个列配置
|
|
398
|
+
function getItem(item) {
|
|
399
|
+
// 合并单元格处理
|
|
400
|
+
if (isAutoMerge && item.isMerge) {
|
|
401
|
+
item.onCell = function (record) {
|
|
402
|
+
var _a;
|
|
403
|
+
var key = item.key;
|
|
404
|
+
if (item.key === MERGE_INDEX) {
|
|
405
|
+
key = firstMergeKey;
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
rowSpan: (_a = record === null || record === void 0 ? void 0 : record[MERGE_ROW_SPANS]) === null || _a === void 0 ? void 0 : _a[key],
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
return item;
|
|
413
|
+
}
|
|
414
|
+
// 递归处理多级表头
|
|
415
|
+
function getColumnItem(item) {
|
|
416
|
+
if (item.children) {
|
|
417
|
+
return __assign(__assign({}, item), { children: item.children.map(function (item) {
|
|
418
|
+
return getItem(item);
|
|
419
|
+
}) });
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
return getItem(item);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}, [columns, mode, isAutoMerge, firstMergeKey]);
|
|
426
|
+
return [newDataSource, newColumns];
|
|
329
427
|
}
|
|
330
428
|
|
|
331
|
-
export { useAddAndDelChange, useCalcScrollY, useCustomSort, useEditChange, useMoveRowChange, useScuRfresh };
|
|
429
|
+
export { useAddAndDelChange, useAutoMerge, useCalcScrollY, useCustomSort, useEditChange, useMoveRowChange, useScuRfresh };
|
|
@@ -191,6 +191,30 @@ interface IColumnType<RecordType> extends Omit<ColumnType<RecordType>, "render">
|
|
|
191
191
|
* }
|
|
192
192
|
*/
|
|
193
193
|
render?: (text: any, record: any, index: number, options: IRenderOptions) => any;
|
|
194
|
+
/**
|
|
195
|
+
* 是否开启维度自定义
|
|
196
|
+
*/
|
|
197
|
+
isDimension?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* 自定义排序的优先级,数字越小,优先级越高,比如2的不能排序到1的前面
|
|
200
|
+
*/
|
|
201
|
+
dimensionPriority?: number;
|
|
202
|
+
/**
|
|
203
|
+
* 自定义维度互斥的字段,多个需要逗号分隔,比如:name,age
|
|
204
|
+
*/
|
|
205
|
+
dimensionExclusive?: string;
|
|
206
|
+
/**
|
|
207
|
+
* 维度是否开启合计
|
|
208
|
+
*/
|
|
209
|
+
isDimensionSum?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* 是否合并
|
|
212
|
+
*/
|
|
213
|
+
isMerge?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* 开启合计
|
|
216
|
+
*/
|
|
217
|
+
isSummary?: boolean;
|
|
194
218
|
}
|
|
195
219
|
interface IRenderOptions {
|
|
196
220
|
insertTableFromClipboard: IFuncInsertTableFromClipboard;
|
|
@@ -442,6 +466,19 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
442
466
|
* 表头对齐方式
|
|
443
467
|
*/
|
|
444
468
|
headerAlign?: "left" | "center" | "right";
|
|
469
|
+
/**
|
|
470
|
+
* 开启维度自定义。开启后,会根据columns中的isDimension属性来是否开启维度自定义,需要合并行时,需要开启这个属性isAutoMerge
|
|
471
|
+
*/
|
|
472
|
+
isDimensionDynamic?: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* 开启自动合并行
|
|
475
|
+
*/
|
|
476
|
+
isAutoMerge?: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* table模式
|
|
479
|
+
* 目前index的话会自动加个序号
|
|
480
|
+
*/
|
|
481
|
+
mode?: "index";
|
|
445
482
|
}
|
|
446
483
|
interface IFields {
|
|
447
484
|
/**
|
package/dist/es/table/table.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useColumns } from './useColumns.js';
|
|
|
17
17
|
import { useDynamicListByColumns } from './useDynamicListByColumns.js';
|
|
18
18
|
import useSummary from './useSummary.js';
|
|
19
19
|
import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
|
|
20
|
-
import { useScuRfresh, useCustomSort, useCalcScrollY, useEditChange, useMoveRowChange, useAddAndDelChange } from './hooks.js';
|
|
20
|
+
import { useScuRfresh, useCustomSort, useCalcScrollY, useEditChange, useMoveRowChange, useAddAndDelChange, useAutoMerge } from './hooks.js';
|
|
21
21
|
import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
|
|
22
22
|
import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
|
|
23
23
|
import useTableValidate, { tableValidate } from './useTableValidate.js';
|
|
@@ -38,7 +38,7 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
|
|
|
38
38
|
// completed: 实现从execl复制到表格中的功能
|
|
39
39
|
var Table = function (props) {
|
|
40
40
|
// console.log("表格渲染");
|
|
41
|
-
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, 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, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "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"]);
|
|
41
|
+
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, 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, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "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"]);
|
|
42
42
|
var classes = classNames("ztxk-table", className, {
|
|
43
43
|
"ztxk-table--flex": isFlex,
|
|
44
44
|
});
|
|
@@ -115,7 +115,7 @@ var Table = function (props) {
|
|
|
115
115
|
filterConfigRef: filterConfigRef,
|
|
116
116
|
});
|
|
117
117
|
// 处理列配置信息 得到新的列配置信息
|
|
118
|
-
var
|
|
118
|
+
var _newColumns = useColumns(columns, {
|
|
119
119
|
// 动态列配置相关信息
|
|
120
120
|
dynamicKey: dynamicKey,
|
|
121
121
|
isRemeberFilter: isRemeberFilter,
|
|
@@ -153,7 +153,13 @@ var Table = function (props) {
|
|
|
153
153
|
filterConfigRef: filterConfigRef,
|
|
154
154
|
addAndDelProps: addAndDelProps,
|
|
155
155
|
headerAlign: headerAlign,
|
|
156
|
+
mode: mode,
|
|
157
|
+
isAutoMerge: isAutoMerge,
|
|
156
158
|
}).newColumns;
|
|
159
|
+
// 处理表格合并和维度
|
|
160
|
+
var _u = useAutoMerge(currentTableDataSource, _newColumns, {
|
|
161
|
+
isAutoMerge: isAutoMerge,
|
|
162
|
+
}), newDataSource = _u[0], newColumns = _u[1];
|
|
157
163
|
// 内部表格总结栏
|
|
158
164
|
var getSummaryHandle = useSummary(summaryConfig, newColumns, {
|
|
159
165
|
summaryFixed: summaryFixed,
|
|
@@ -163,7 +169,7 @@ var Table = function (props) {
|
|
|
163
169
|
isDel: isDel,
|
|
164
170
|
});
|
|
165
171
|
// 表格验证
|
|
166
|
-
var
|
|
172
|
+
var _v = useTableValidate(), tableRef = _v.tableRef, getCurrentTable = _v.getCurrentTable, clearErrorClass = _v.clearErrorClass;
|
|
167
173
|
// 虚拟滚动选项
|
|
168
174
|
var vComponents = useMemo(function () {
|
|
169
175
|
if (virtualKey) {
|
|
@@ -289,7 +295,7 @@ var Table = function (props) {
|
|
|
289
295
|
};
|
|
290
296
|
});
|
|
291
297
|
// 表格
|
|
292
|
-
var SingleTable = (jsx(Table$1, __assign({ className: classes, bordered: bordered, dataSource:
|
|
298
|
+
var SingleTable = (jsx(Table$1, __assign({ className: classes, bordered: bordered, dataSource: newDataSource, columns: newColumns, components: componentsMemo, onRow: onRow, summary: getSummaryHandle, pagination: isInnerPagination
|
|
293
299
|
? pagination
|
|
294
300
|
? pagination
|
|
295
301
|
: paginationConfig
|
|
@@ -309,7 +315,7 @@ var Table = function (props) {
|
|
|
309
315
|
overflow: "hidden",
|
|
310
316
|
marginTop: isMarginTop ? 10 : 0,
|
|
311
317
|
marginBottom: isMarginBottom ? 10 : 0,
|
|
312
|
-
}, ref: tableRef, id: tableId }, { children: [isMove ? (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: SingleTable }))) : (SingleTable), dynamicKey ? (jsx(DynamicSetting, { parentDynamicKey: TABLE_DYNAMIC_KEY, dynamicKey: dynamicKey, defaultList: defaultDynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef, hiddenOperationIcon: true, isMore: true, isFixed: true })) : null] })));
|
|
318
|
+
}, ref: tableRef, id: tableId }, { children: [isMove ? (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: SingleTable }))) : (SingleTable), dynamicKey ? (jsx(DynamicSetting, { parentDynamicKey: TABLE_DYNAMIC_KEY, dynamicKey: dynamicKey, defaultList: defaultDynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef, hiddenOperationIcon: true, isMore: true, isFixed: true, isDimensionDynamic: isDimensionDynamic })) : null] })));
|
|
313
319
|
};
|
|
314
320
|
var MemoTable = memo(Table);
|
|
315
321
|
MemoTable.displayName = "ZTXK_WEBUI_Table";
|
|
@@ -3,6 +3,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { getTableColumns, parsePasteData, getFilterRecords, startColumnInsertTableData } from './utils.js';
|
|
5
5
|
import '../node_modules/classnames/index.js';
|
|
6
|
+
import { MERGE_INDEX } from './constant.js';
|
|
6
7
|
import 'ahooks';
|
|
7
8
|
import './components/EnhanceHeaderCell.js';
|
|
8
9
|
import ColumnDynamic from './components/ColumnDynamic.js';
|
|
@@ -21,7 +22,7 @@ import ModalComponent from '../modal/modal.js';
|
|
|
21
22
|
function useColumns(columns, options) {
|
|
22
23
|
var _this = this;
|
|
23
24
|
var _a, _b;
|
|
24
|
-
var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey, filterConfigRef = options.filterConfigRef, addAndDelProps = options.addAndDelProps, headerAlign = options.headerAlign;
|
|
25
|
+
var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey, filterConfigRef = options.filterConfigRef, addAndDelProps = options.addAndDelProps, headerAlign = options.headerAlign, mode = options.mode, isAutoMerge = options.isAutoMerge;
|
|
25
26
|
var newColumns = getTableColumns(columns, currentDynamicList).columns;
|
|
26
27
|
// 表头过滤的一些配置(获取表头过滤的input的输入框的引用)
|
|
27
28
|
var searchValueInputRef = useRef(null);
|
|
@@ -382,6 +383,21 @@ function useColumns(columns, options) {
|
|
|
382
383
|
} }, addAndDelProps);
|
|
383
384
|
myNewColumns.unshift(newColumn);
|
|
384
385
|
}
|
|
386
|
+
if (mode === "index") {
|
|
387
|
+
myNewColumns.unshift({
|
|
388
|
+
title: "序号",
|
|
389
|
+
width: 60,
|
|
390
|
+
key: MERGE_INDEX,
|
|
391
|
+
fixed: "left",
|
|
392
|
+
align: "center",
|
|
393
|
+
isFilter: false,
|
|
394
|
+
isMerge: isAutoMerge,
|
|
395
|
+
render: function (value, record, index) {
|
|
396
|
+
var v = record[MERGE_INDEX] !== undefined ? record[MERGE_INDEX] : index;
|
|
397
|
+
return "".concat(v + 1);
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
}
|
|
385
401
|
// 如果配置了动态列配置
|
|
386
402
|
// 处理一些配置放置的位置
|
|
387
403
|
if (dynamicKey && !hiddenDynamicIcon) {
|