zmdms-webui 1.2.8 → 1.3.0

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.
@@ -1 +1 @@
1
- .ztxk-modal .ant-modal-content{border-radius:8px}.ztxk-modal .ant-modal-content>.ant-modal-close{color:#333;height:40px;width:40px}.ztxk-modal .ant-modal-content>.ant-modal-close>.ant-modal-close-x{font-weight:400;height:40px;line-height:40px;width:40px}.ztxk-modal .ant-modal-content>.ant-modal-header{border-bottom:1px solid #f0f0f0;border-radius:8px 8px 0 0;padding:9px 20px 9px 24px}.ztxk-modal .ant-modal-content>.ant-modal-header>.ant-modal-title{color:#333;font-weight:400;line-height:22px;text-align:center}.ztxk-modal .ant-modal-content>.ant-modal-body{padding:10px}.ztxk-modal .ant-modal-content>.ant-modal-footer{border-top:0;padding:10px 0;text-align:center}
1
+ .ztxk-modal{top:8vh}.ztxk-modal .ant-modal-content{border-radius:8px}.ztxk-modal .ant-modal-content>.ant-modal-close{color:#333;height:40px;width:40px}.ztxk-modal .ant-modal-content>.ant-modal-close>.ant-modal-close-x{font-weight:400;height:40px;line-height:40px;width:40px}.ztxk-modal .ant-modal-content>.ant-modal-header{border-bottom:1px solid #f0f0f0;border-radius:8px 8px 0 0;padding:9px 20px 9px 24px}.ztxk-modal .ant-modal-content>.ant-modal-header>.ant-modal-title{color:#333;font-weight:400;line-height:22px;text-align:center}.ztxk-modal .ant-modal-content>.ant-modal-body{max-height:75vh;min-height:200px;overflow:auto;padding:10px}.ztxk-modal .ant-modal-content>.ant-modal-footer{border-top:0;padding:10px 0;text-align:center}
@@ -13,7 +13,7 @@ var Modal = function (_a, ref) {
13
13
  var _c = useState(defaultTitle), title = _c[0], setTitle = _c[1];
14
14
  var _d = useState(), loading = _d[0], setLoading = _d[1];
15
15
  // 二次确认框相关配置
16
- var _e = useState(false), isConfirm = _e[0], setIsConfirm = _e[1];
16
+ var _e = useState(confirmOnOk ? true : false), isConfirm = _e[0], setIsConfirm = _e[1];
17
17
  var _f = useState(defaultConfirmMsg), confirmMsg = _f[0], setConfirmMsg = _f[1];
18
18
  var _g = useState(defaultConfirmOkText), confirmOkText = _g[0], setConfirmOkText = _g[1];
19
19
  // 模态框类型
@@ -142,16 +142,21 @@ var EnhanceCell = function (props) {
142
142
  if (!onEditableSave) {
143
143
  throw Error("如果开启了editable, 那么必须传递 onEditableSave属性 来更改表格数据!");
144
144
  }
145
- toggleEdit();
146
- onEditableSave(__assign(__assign({}, newRecord), (_a = {}, _a[dataIndex] = isIptNumberBooleanRef.current && iptNumberRef.current
145
+ var currentText = isIptNumberBooleanRef.current && iptNumberRef.current
147
146
  ? iptNumberRef.current
148
- : val, _a)), index, dataIndex);
147
+ : val;
148
+ var resultValue = getTrimVal(editableConfig.trimType, currentText);
149
+ if (currentText !== resultValue) {
150
+ setVal(resultValue);
151
+ }
152
+ toggleEdit();
153
+ onEditableSave(__assign(__assign({}, newRecord), (_a = {}, _a[dataIndex] = resultValue, _a)), index, dataIndex);
149
154
  };
150
155
  // 如果开启编辑 那么内部直接代理
151
156
  if (typeof editable === "function" ? editable(newRecord, index) : editable) {
152
157
  var _g = editableConfig || {
153
158
  type: "input",
154
- }, type = _g.type, max = _g.max, min = _g.min, maxHandle = _g.maxHandle, minHandle = _g.minHandle, disabled = _g.disabled, disabledHandle = _g.disabledHandle, resetEditableConfigProps = __rest(_g, ["type", "max", "min", "maxHandle", "minHandle", "disabled", "disabledHandle"]);
159
+ }, _h = _g.type, type = _h === void 0 ? "input" : _h, max = _g.max, min = _g.min, maxHandle = _g.maxHandle, minHandle = _g.minHandle, disabled = _g.disabled, disabledHandle = _g.disabledHandle; _g.trimType; var resetEditableConfigProps = __rest(_g, ["type", "max", "min", "maxHandle", "minHandle", "disabled", "disabledHandle", "trimType"]);
155
160
  var CurrentReactNode = null;
156
161
  // 这里将children 替换成val 要显示的值
157
162
  // let newChildren: any = children;
@@ -320,6 +325,21 @@ function validateHandle(_a) {
320
325
  }
321
326
  });
322
327
  });
328
+ }
329
+ function getTrimVal(trimType, value) {
330
+ if (trimType === "trim") {
331
+ return typeof value === "string" ? value.trim() : value;
332
+ }
333
+ if (trimType === "trimStart") {
334
+ return typeof value === "string" ? value.trimStart() : value;
335
+ }
336
+ if (trimType === "trimEnd") {
337
+ return typeof value === "string" ? value.trimEnd() : value;
338
+ }
339
+ if (trimType === "trimAll") {
340
+ return typeof value === "string" ? value.replace(/\s+/g, "") : value;
341
+ }
342
+ return value;
323
343
  }
324
344
 
325
345
  export { EnhanceCell as default };
@@ -10,7 +10,7 @@ interface IEditableConfig extends Partial<IEditableConfigOtherProps> {
10
10
  /**
11
11
  * 列编辑类型
12
12
  */
13
- type: "input" | "inputNumber" | "textarea";
13
+ type?: "input" | "inputNumber" | "textarea";
14
14
  /**
15
15
  * 最大值函数
16
16
  */
@@ -23,6 +23,14 @@ interface IEditableConfig extends Partial<IEditableConfigOtherProps> {
23
23
  * 禁用方法
24
24
  */
25
25
  disabledHandle?: (record: any) => boolean;
26
+ /**
27
+ * 去除空格
28
+ * trim 去除前后空格
29
+ * trimStart 去除前面空格
30
+ * trimEnd 去除后面空格
31
+ * trimAll 去除所有空格
32
+ */
33
+ trimType?: "trim" | "trimStart" | "trimEnd" | "trimAll" | ((value: any) => any);
26
34
  /**
27
35
  * 可以传入对应的input inputNumber的所有相关属性
28
36
  */
@@ -17,6 +17,10 @@ interface ITreeSelectProps extends Omit<TreeSelectProps, "onChange"> {
17
17
  */
18
18
  searchType?: "all" | "lazy";
19
19
  lazySearchHandle?: (v: string, setExpandKeys?: any) => void;
20
+ /**
21
+ * 禁用的选项列表 一个dataKey列表
22
+ */
23
+ disabledValues?: string[];
20
24
  }
21
25
  interface TreeSelectComponent extends React__default.ForwardRefExoticComponent<ITreeSelectProps & React__default.RefAttributes<unknown>> {
22
26
  SHOW_ALL: typeof TreeSelect.SHOW_ALL;
@@ -1,6 +1,6 @@
1
1
  import { __rest, __assign } from '../_virtual/_tslib.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { memo, forwardRef } from 'react';
3
+ import { memo, forwardRef, useMemo } from 'react';
4
4
  import { TreeSelect as TreeSelect$1 } from 'antd';
5
5
  import { useBasicInfo, useAllDataHandle, useChange, useSearchHandle } from './hooks.js';
6
6
 
@@ -15,8 +15,8 @@ var DEFAULT_MAX_TAG_COUNT = 3;
15
15
  * treeDataSimpleMode treeData是否为简单格式 即树数据为平级 通过pId关联父子节点
16
16
  */
17
17
  var TreeSelect = function (props, ref) {
18
- var onChange = props.onChange, isAllData = props.isAllData, dataHandle = props.dataHandle, searchType = props.searchType, lazySearchHandle = props.lazySearchHandle, resetProps = __rest(props, ["onChange", "isAllData", "dataHandle", "searchType", "lazySearchHandle"]);
19
- var fieldNames = resetProps.fieldNames, treeNodeLabelProp = resetProps.treeNodeLabelProp, value = resetProps.value, treeData = resetProps.treeData, treeDataSimpleMode = resetProps.treeDataSimpleMode;
18
+ var onChange = props.onChange, isAllData = props.isAllData, dataHandle = props.dataHandle, searchType = props.searchType, lazySearchHandle = props.lazySearchHandle, disabledValues = props.disabledValues, treeData = props.treeData, resetProps = __rest(props, ["onChange", "isAllData", "dataHandle", "searchType", "lazySearchHandle", "disabledValues", "treeData"]);
19
+ var fieldNames = resetProps.fieldNames, treeNodeLabelProp = resetProps.treeNodeLabelProp, value = resetProps.value, treeDataSimpleMode = resetProps.treeDataSimpleMode;
20
20
  // 基础数据
21
21
  var _a = useBasicInfo({
22
22
  fieldNames: fieldNames,
@@ -47,11 +47,52 @@ var TreeSelect = function (props, ref) {
47
47
  childrenKey: childrenKey,
48
48
  titleKey: titleKey,
49
49
  }), searchValue = _b.searchValue, onLazySearchHandle = _b.onLazySearchHandle, filterTreeNode = _b.filterTreeNode, treeExpandedKeys = _b.treeExpandedKeys, onTreeExpand = _b.onTreeExpand;
50
+ var newTreeData = useMemo(function () {
51
+ if (!disabledValues) {
52
+ return treeData;
53
+ }
54
+ if (disabledValues.length === 0) {
55
+ return treeData;
56
+ }
57
+ // 如果数据是扁平模式
58
+ if (treeDataSimpleMode) {
59
+ return treeData === null || treeData === void 0 ? void 0 : treeData.map(function (item) {
60
+ if (valueKey && disabledValues.includes(item[valueKey])) {
61
+ return __assign(__assign({}, item), { disabled: true, disableCheckbox: true });
62
+ }
63
+ return item;
64
+ });
65
+ }
66
+ function cloneAndDisableTree(tree, disabledIds) {
67
+ var _a;
68
+ // 递归函数,用于克隆树结构并添加禁用属性
69
+ function cloneNode(node) {
70
+ // 创建一个新节点作为克隆
71
+ var newNode = __assign({}, node);
72
+ // 如果有子节点,则递归克隆子节点
73
+ if (node === null || node === void 0 ? void 0 : node[childrenKey]) {
74
+ newNode[childrenKey] = node[childrenKey].map(function (child) {
75
+ return cloneNode(child);
76
+ });
77
+ }
78
+ // 检查当前节点的ID是否在禁用列表中
79
+ if (disabledIds.includes(node[valueKey])) {
80
+ // 如果在,则添加禁用属性
81
+ newNode.disabled = true;
82
+ newNode.disableCheckbox = true;
83
+ }
84
+ return newNode;
85
+ }
86
+ // 遍历原始树结构,对每个节点调用cloneNode进行克隆和修改
87
+ return (_a = tree === null || tree === void 0 ? void 0 : tree.map) === null || _a === void 0 ? void 0 : _a.call(tree, function (rootNode) { return cloneNode(rootNode); });
88
+ }
89
+ return cloneAndDisableTree(treeData, disabledValues);
90
+ }, [treeData, valueKey, childrenKey, treeDataSimpleMode, disabledValues]);
50
91
  return (jsx(TreeSelect$1, __assign({ onChange: onChangeHandle,
51
92
  // 当多选模式或treeCheckable 定义回填的模式
52
93
  showCheckedStrategy: TreeSelect$1.SHOW_ALL, maxTagCount: DEFAULT_MAX_TAG_COUNT, searchValue: searchValue, onSearch: onLazySearchHandle, filterTreeNode: filterTreeNode,
53
94
  // 节点展开逻辑
54
- treeExpandedKeys: treeExpandedKeys, onTreeExpand: onTreeExpand, ref: ref }, resetProps)));
95
+ treeExpandedKeys: treeExpandedKeys, onTreeExpand: onTreeExpand, ref: ref, treeData: newTreeData }, resetProps)));
55
96
  };
56
97
  var MemoTreeSelect = memo(forwardRef(TreeSelect));
57
98
  MemoTreeSelect.displayName = "ZTXK_WEBUI_TreeSelect";
@@ -134,7 +134,9 @@ function useOnChange(props) {
134
134
  var _b, _c;
135
135
  var size = item.size, name = item.name, response = item.response;
136
136
  var attachId = ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachId) || (item === null || item === void 0 ? void 0 : item[ATTACH_ID_KEY]);
137
- return __assign(__assign((_a = {}, _a[ATTACH_ID_KEY] = attachId, _a[ATTACH_NAME_KEY] = name ? name : (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.originalName, _a[ATTACH_SIZE_KEY] = size, _a[UPLOAD_TIME_KEY] = Date.now(), _a[UPLOAD_USER_KEY] = userName, _a), item), { uid: attachId ? attachId : item.uid });
137
+ return __assign(__assign((_a = {}, _a[ATTACH_ID_KEY] = attachId, _a[ATTACH_NAME_KEY] = name ? name : (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.originalName, _a[ATTACH_SIZE_KEY] = size, _a[UPLOAD_TIME_KEY] = item.createTime ? item.createTime : Date.now(), _a[UPLOAD_USER_KEY] = item.createUserName
138
+ ? item.createUserName
139
+ : userName, _a), item), { uid: attachId ? attachId : item.uid });
138
140
  });
139
141
  // antd 4 再React 18下的一个bug
140
142
  // 暂时先这么修复 强制更新
@@ -156,7 +158,9 @@ function useOnChange(props) {
156
158
  var _b, _c, _d;
157
159
  var size = item.size, name = item.name, response = item.response;
158
160
  var attachId = ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachId) || (item === null || item === void 0 ? void 0 : item[ATTACH_ID_KEY]);
159
- return __assign(__assign((_a = {}, _a[ATTACH_ID_KEY] = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.attachId, _a[ATTACH_NAME_KEY] = name ? name : (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.originalName, _a[ATTACH_SIZE_KEY] = size, _a[UPLOAD_TIME_KEY] = Date.now(), _a[UPLOAD_USER_KEY] = userName, _a), item), { uid: attachId ? attachId : item.uid });
161
+ return __assign(__assign((_a = {}, _a[ATTACH_ID_KEY] = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.attachId, _a[ATTACH_NAME_KEY] = name ? name : (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.originalName, _a[ATTACH_SIZE_KEY] = size, _a[UPLOAD_TIME_KEY] = item.createTime ? item.createTime : Date.now(), _a[UPLOAD_USER_KEY] = item.createUserName
162
+ ? item.createUserName
163
+ : userName, _a), item), { uid: attachId ? attachId : item.uid });
160
164
  });
161
165
  var errorFileList = fileList
162
166
  .filter(function (item) { return isErrorFile(item); })
@@ -165,7 +169,9 @@ function useOnChange(props) {
165
169
  var _b, _c;
166
170
  var size = item.size, name = item.name, response = item.response;
167
171
  var attachId = ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachId) || (item === null || item === void 0 ? void 0 : item[ATTACH_ID_KEY]);
168
- return __assign(__assign((_a = {}, _a[ATTACH_ID_KEY] = attachId, _a[ATTACH_NAME_KEY] = name ? name : (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.originalName, _a[ATTACH_SIZE_KEY] = size, _a[UPLOAD_TIME_KEY] = Date.now(), _a[UPLOAD_USER_KEY] = userName, _a), item), { uid: attachId ? attachId : item.uid });
172
+ return __assign(__assign((_a = {}, _a[ATTACH_ID_KEY] = attachId, _a[ATTACH_NAME_KEY] = name ? name : (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.originalName, _a[ATTACH_SIZE_KEY] = size, _a[UPLOAD_TIME_KEY] = item.createTime ? item.createTime : Date.now(), _a[UPLOAD_USER_KEY] = item.createUserName
173
+ ? item.createUserName
174
+ : userName, _a), item), { uid: attachId ? attachId : item.uid });
169
175
  });
170
176
  onChange &&
171
177
  onChange({
@@ -272,7 +278,11 @@ function useUploadTableData(props) {
272
278
  // 附件大小 同理
273
279
  attachSize: attachSize ? attachSize : size,
274
280
  // 上传时间
275
- uploadTime: uploadTime ? uploadTime : Date.now(),
281
+ uploadTime: uploadTime
282
+ ? uploadTime
283
+ : item.createTime
284
+ ? item.createTime
285
+ : Date.now(),
276
286
  // 上传人
277
287
  uploadUser: uploadUser
278
288
  ? uploadUser
@@ -127,8 +127,9 @@ var UploadTable = function (_a, ref) {
127
127
  dataIndex: "uploadTime",
128
128
  key: "uploadTime",
129
129
  align: "left",
130
- render: function (text) {
131
- return dayjs(text).format("YYYY-MM-DD HH:mm");
130
+ render: function (text, record) {
131
+ var time = text ? text : record.createTime;
132
+ return dayjs(time).format("YYYY-MM-DD HH:mm");
132
133
  },
133
134
  };
134
135
  var createUserColumn = {