zmdms-webui 2.7.5 → 2.7.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.
|
@@ -37,7 +37,7 @@ var CommonSearchList = function (props) {
|
|
|
37
37
|
deleteData === null || deleteData === void 0 ? void 0 : deleteData(index);
|
|
38
38
|
};
|
|
39
39
|
return (jsxs("div", __assign({ className: "common-search-list--container" }, { children: [jsx("div", __assign({ className: "common-search-list--title" }, { children: "\u5E38\u7528\u641C\u7D22" })), jsx("div", __assign({ className: "common-search-list--content" }, { children: jsx(Sortable, { children: commonSearchList.map(function (item, index) {
|
|
40
|
-
return (jsx(Sortable.Item, __assign({ onMoveItem: onMoveItem, onMoveEnd: onMoveEnd, index: index, type: sortableType }, { children: jsxs(ButtonCom, __assign({ type: currentCommonSearchKey === item.key ? "primary" : undefined, onClick: function () {
|
|
40
|
+
return (jsx(Sortable.Item, __assign({ onMoveItem: onMoveItem, onMoveEnd: onMoveEnd, index: index, type: sortableType }, { children: jsxs(ButtonCom, __assign({ type: currentCommonSearchKey === item.key ? "primary" : undefined, isWhite: true, onClick: function () {
|
|
41
41
|
handleClick(item);
|
|
42
42
|
if (currentCommonSearchKey === item.key) {
|
|
43
43
|
return;
|
package/dist/es/form/form.js
CHANGED
|
@@ -27,26 +27,33 @@ var FormContext = createContext({});
|
|
|
27
27
|
// 用户配置优先,先从远端获取到 表单配置信息。
|
|
28
28
|
// 给子元素设置好了表单配置信息后 接下来的内容 交给动态列配置接管
|
|
29
29
|
var Form = function (props, ref) {
|
|
30
|
-
var form = props.form, bottomBorder = props.bottomBorder, _a = props.isFlex, isFlex = _a === void 0 ? true : _a, wrapClassName = props.wrapClassName, leftClassName = props.leftClassName; props.itemClassName; var rightWrapVisible = props.rightWrapVisible, rightClassName = props.rightClassName, children = props.children, dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, formPreferences = props.formPreferences, items = props.items, outsideState = props.outsideState, onValuesChange = props.onValuesChange, isResetAndClear = props.isResetAndClear, onResetHandle = props.onResetHandle, onSearchHandle = props.onSearchHandle, type = props.type, directionColumn = props.directionColumn, isToggle = props.isToggle, toggleNum = props.toggleNum, defaultToggle = props.defaultToggle,
|
|
30
|
+
var form = props.form, bottomBorder = props.bottomBorder, _a = props.isFlex, isFlex = _a === void 0 ? true : _a, wrapClassName = props.wrapClassName, leftClassName = props.leftClassName; props.itemClassName; var rightWrapVisible = props.rightWrapVisible, rightClassName = props.rightClassName, children = props.children, dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, formPreferences = props.formPreferences, items = props.items, outsideState = props.outsideState, onValuesChange = props.onValuesChange, isResetAndClear = props.isResetAndClear, onResetHandle = props.onResetHandle, onSearchHandle = props.onSearchHandle, type = props.type, directionColumn = props.directionColumn, isToggle = props.isToggle, toggleNum = props.toggleNum, defaultToggle = props.defaultToggle, isCommonSearch = props.isCommonSearch, restProps = __rest(props, ["form", "bottomBorder", "isFlex", "wrapClassName", "leftClassName", "itemClassName", "rightWrapVisible", "rightClassName", "children", "dynamicKey", "dynamicVersion", "formPreferences", "items", "outsideState", "onValuesChange", "isResetAndClear", "onResetHandle", "onSearchHandle", "type", "directionColumn", "isToggle", "toggleNum", "defaultToggle", "isCommonSearch"]);
|
|
31
31
|
var enableCommonSearch = useBaseContext().enableCommonSearch;
|
|
32
|
+
// 是否开启常用搜索
|
|
33
|
+
// 如果全局开启了默认添加,那么只要没有单独配置关闭,都认为需要打开
|
|
34
|
+
var isCommonSearchEnabled = rightWrapVisible &&
|
|
35
|
+
(enableCommonSearch ? isCommonSearch !== false : !!isCommonSearch);
|
|
32
36
|
// 常用搜索hooks
|
|
33
|
-
var
|
|
37
|
+
var _b = useCommonSearch({
|
|
34
38
|
commonSearchKey: dynamicKey || window.location.pathname,
|
|
35
|
-
|
|
39
|
+
isCommonSearchEnabled: isCommonSearchEnabled,
|
|
40
|
+
}), commonSearchList = _b.commonSearchList, setCommonSearchList = _b.setCommonSearchList, currentCommonSearchKey = _b.currentCommonSearchKey, setCurrentCommonSearchKey = _b.setCurrentCommonSearchKey, setData = _b.setData, deleteData = _b.deleteData, setReplaceData = _b.setReplaceData, reTransformData = _b.reTransformData, updateServerData = _b.updateServerData;
|
|
36
41
|
var onCommonSearchHandle = useCommonSearchModal({
|
|
37
42
|
commonSearchList: commonSearchList,
|
|
38
43
|
currentCommonSearchKey: currentCommonSearchKey,
|
|
39
44
|
form: form,
|
|
40
45
|
setData: setData,
|
|
46
|
+
isCommonSearchEnabled: isCommonSearchEnabled,
|
|
47
|
+
setCurrentCommonSearchKey: setCurrentCommonSearchKey,
|
|
41
48
|
}).onCommonSearchHandle;
|
|
42
49
|
// 获取新的items 如果传入了配置项的话,配置项优先
|
|
43
50
|
var configInfoItems = useFormPreferencesCreateNewItems(formPreferences, items).configInfoItems;
|
|
44
51
|
// 根据items 和 dynamicKey 获取到动态列配置信息
|
|
45
|
-
var
|
|
52
|
+
var _c = useDynamicListByItems(configInfoItems, {
|
|
46
53
|
dynamicKey: dynamicKey,
|
|
47
54
|
formPreferences: formPreferences,
|
|
48
55
|
dynamicVersion: dynamicVersion,
|
|
49
|
-
}), dynamicList =
|
|
56
|
+
}), dynamicList = _c.dynamicList, onCurrentListChange = _c.onCurrentListChange, newItems = _c.newItems, dynamicSettingRef = _c.dynamicSettingRef;
|
|
50
57
|
// 主容器类名
|
|
51
58
|
var wrapClasses = classNames("ztxk-form", wrapClassName, {
|
|
52
59
|
"ztxk-form--bottom-border": bottomBorder,
|
|
@@ -118,22 +125,23 @@ var Form = function (props, ref) {
|
|
|
118
125
|
}
|
|
119
126
|
onValuesChange && onValuesChange(changedValues, allValues);
|
|
120
127
|
}, [onValuesChange, itemsShouldUpdate, form]);
|
|
121
|
-
var
|
|
128
|
+
var _d = useBtnHandle(form, {
|
|
122
129
|
onSearchHandle: onSearchHandle,
|
|
123
130
|
onResetHandle: onResetHandle,
|
|
124
|
-
|
|
131
|
+
setCurrentCommonSearchKey: setCurrentCommonSearchKey,
|
|
132
|
+
}), onSearchHandleInner = _d.onSearchHandleInner, onResetHandleInner = _d.onResetHandleInner, onDropdownResetHandleInner = _d.onDropdownResetHandleInner;
|
|
125
133
|
var leftWrapRef = useRef(null);
|
|
126
|
-
var
|
|
134
|
+
var _e = useToggle(leftWrapRef, {
|
|
127
135
|
isToggle: isToggle,
|
|
128
136
|
toggleNum: toggleNum,
|
|
129
137
|
defaultToggle: defaultToggle,
|
|
130
|
-
}), toggle =
|
|
138
|
+
}), toggle = _e.toggle, onToggleChange = _e.onToggleChange, setToggleHandle = _e.setToggleHandle;
|
|
131
139
|
useImperativeHandle(ref, function () {
|
|
132
140
|
return {
|
|
133
141
|
setToggleHandle: setToggleHandle,
|
|
134
142
|
};
|
|
135
143
|
});
|
|
136
|
-
return (jsxs(FormContext.Provider, __assign({ value: { onSearch: onSearchHandleInner } }, { children: [jsxs(Form$1, __assign({ form: form, onValuesChange: onValuesChangeHandle }, restProps, { className: wrapClasses }, { children: [jsx("div", __assign({ className: leftClasses, ref: leftWrapRef }, { children: items ? (jsx(FormItems, { items: dynamicKey ? newItems : configInfoItems, outsideState: outsideState })) : (children) })), jsxs("div", __assign({ className: "ztxk-form--operation" }, { children: [dynamicKey ? (jsx(DynamicSetting, { dynamicKey: dynamicKey, parentDynamicKey: FORM_DYNAMIC_KEY, defaultList: dynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef })) : null, isToggle ? (jsx(Toggle, { toggle: toggle, onClick: onToggleChange })) : null] })), rightWrapVisible ? (jsxs("div", __assign({ className: rightClasses }, { children: [jsxs("div", __assign({ className: "ztxk-form__right--common-left" }, { children: [isResetAndClear ? (jsx(ResetButton, { onClick: onDropdownResetHandleInner })) : (jsx(ButtonCom, __assign({ type: "default", onClick: onResetHandleInner }, { children: "\u91CD\u7F6E" }))), jsx(ButtonCom, __assign({ type: "primary", onClick: onSearchHandleInner }, { children: "\u67E5\u8BE2" }))] })),
|
|
144
|
+
return (jsxs(FormContext.Provider, __assign({ value: { onSearch: onSearchHandleInner } }, { children: [jsxs(Form$1, __assign({ form: form, onValuesChange: onValuesChangeHandle }, restProps, { className: wrapClasses }, { children: [jsx("div", __assign({ className: leftClasses, ref: leftWrapRef }, { children: items ? (jsx(FormItems, { items: dynamicKey ? newItems : configInfoItems, outsideState: outsideState })) : (children) })), jsxs("div", __assign({ className: "ztxk-form--operation" }, { children: [dynamicKey ? (jsx(DynamicSetting, { dynamicKey: dynamicKey, parentDynamicKey: FORM_DYNAMIC_KEY, defaultList: dynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef })) : null, isToggle ? (jsx(Toggle, { toggle: toggle, onClick: onToggleChange })) : null] })), rightWrapVisible ? (jsxs("div", __assign({ className: rightClasses }, { children: [jsxs("div", __assign({ className: "ztxk-form__right--common-left" }, { children: [isResetAndClear ? (jsx(ResetButton, { onClick: onDropdownResetHandleInner })) : (jsx(ButtonCom, __assign({ type: "default", onClick: onResetHandleInner }, { children: "\u91CD\u7F6E" }))), jsx(ButtonCom, __assign({ type: "primary", onClick: onSearchHandleInner }, { children: "\u67E5\u8BE2" }))] })), isCommonSearchEnabled ? (jsx("div", __assign({ className: "ztxk-form__right--common-right" }, { children: jsx(ButtonCom, __assign({ style: { width: "100%" }, onClick: onCommonSearchHandle }, { children: "\u4FDD\u5B58\u4E3A\u5E38\u7528\u641C\u7D22" })) }))) : null] }))) : null] })), isCommonSearchEnabled ? (jsx(CommonSearchList, { commonSearchList: commonSearchList, setCommonSearchList: setCommonSearchList, currentCommonSearchKey: currentCommonSearchKey, setCurrentCommonSearchKey: setCurrentCommonSearchKey, form: form, reTransformData: reTransformData, deleteData: deleteData, setReplaceData: setReplaceData, updateServerData: updateServerData, onSearchHandle: onSearchHandleInner })) : null] })));
|
|
137
145
|
};
|
|
138
146
|
var MemoForm = memo(forwardRef(Form));
|
|
139
147
|
MemoForm.displayName = "ZTXK_WEBUI_Form";
|
package/dist/es/form/hooks.js
CHANGED
|
@@ -116,20 +116,22 @@ function useDynamicListByItems(items, options) {
|
|
|
116
116
|
}
|
|
117
117
|
// 右侧按钮组
|
|
118
118
|
function useBtnHandle(form, handleObj) {
|
|
119
|
-
var onResetHandle = handleObj.onResetHandle, onSearchHandle = handleObj.onSearchHandle;
|
|
119
|
+
var onResetHandle = handleObj.onResetHandle, onSearchHandle = handleObj.onSearchHandle, setCurrentCommonSearchKey = handleObj.setCurrentCommonSearchKey;
|
|
120
120
|
var onResetHandleInner = useCallback(function () {
|
|
121
121
|
form === null || form === void 0 ? void 0 : form.resetFields();
|
|
122
|
+
setCurrentCommonSearchKey === null || setCurrentCommonSearchKey === void 0 ? void 0 : setCurrentCommonSearchKey("");
|
|
122
123
|
onResetHandle && onResetHandle();
|
|
123
|
-
}, [form, onResetHandle]);
|
|
124
|
+
}, [form, onResetHandle, setCurrentCommonSearchKey]);
|
|
124
125
|
var onDropdownResetHandleInner = useCallback(function (key) {
|
|
125
126
|
form === null || form === void 0 ? void 0 : form.resetFields();
|
|
127
|
+
setCurrentCommonSearchKey === null || setCurrentCommonSearchKey === void 0 ? void 0 : setCurrentCommonSearchKey("");
|
|
126
128
|
if (key === "clear") {
|
|
127
129
|
onResetHandle && onResetHandle({});
|
|
128
130
|
}
|
|
129
131
|
else {
|
|
130
132
|
onResetHandle && onResetHandle();
|
|
131
133
|
}
|
|
132
|
-
}, [form, onResetHandle]);
|
|
134
|
+
}, [form, onResetHandle, setCurrentCommonSearchKey]);
|
|
133
135
|
var onSearchHandleInner = useCallback(function () {
|
|
134
136
|
// 当前表单数据
|
|
135
137
|
var currentFormParams = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
|
|
@@ -14,17 +14,19 @@ var COMMON_SEARCH_KEY = "__zmdms-ui--common-search-key__";
|
|
|
14
14
|
// 常用搜索hooks
|
|
15
15
|
function useCommonSearch(options) {
|
|
16
16
|
var _this = this;
|
|
17
|
-
var commonSearchKey = options.commonSearchKey;
|
|
17
|
+
var commonSearchKey = options.commonSearchKey, isCommonSearchEnabled = options.isCommonSearchEnabled;
|
|
18
18
|
var customConfigFetch = useBaseContext().customConfigFetch;
|
|
19
19
|
// 常用搜索列表存储实例
|
|
20
|
-
var storageRef = useRef(
|
|
20
|
+
var storageRef = useRef(isCommonSearchEnabled
|
|
21
|
+
? new MyStorage({ tableKey: COMMON_SEARCH_KEY })
|
|
22
|
+
: null);
|
|
21
23
|
// 常用搜索列表
|
|
22
24
|
var _a = useState([]), commonSearchList = _a[0], setCommonSearchList = _a[1];
|
|
23
25
|
// 当前选中的常用搜索key值
|
|
24
26
|
var _b = useState(""), currentCommonSearchKey = _b[0], setCurrentCommonSearchKey = _b[1];
|
|
25
27
|
// 初始化常用搜索列表
|
|
26
28
|
useMount(function () {
|
|
27
|
-
if (commonSearchKey) {
|
|
29
|
+
if (commonSearchKey && storageRef.current) {
|
|
28
30
|
storageRef.current
|
|
29
31
|
.getItem(commonSearchKey)
|
|
30
32
|
.then(function (res) { return setCommonSearchList(res || []); });
|
|
@@ -123,7 +125,7 @@ function useCommonSearch(options) {
|
|
|
123
125
|
result[index] = saveData;
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
|
-
result.
|
|
128
|
+
result.unshift(saveData);
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
setCommonSearchList(result);
|
|
@@ -211,10 +213,13 @@ function useCommonSearch(options) {
|
|
|
211
213
|
};
|
|
212
214
|
}
|
|
213
215
|
function useCommonSearchModal(options) {
|
|
214
|
-
var commonSearchList = options.commonSearchList, currentCommonSearchKey = options.currentCommonSearchKey, form = options.form, setData = options.setData;
|
|
216
|
+
var commonSearchList = options.commonSearchList, currentCommonSearchKey = options.currentCommonSearchKey, form = options.form, setData = options.setData, isCommonSearchEnabled = options.isCommonSearchEnabled, setCurrentCommonSearchKey = options.setCurrentCommonSearchKey;
|
|
215
217
|
var iptRef = useRef(null);
|
|
216
218
|
useEffect(function () {
|
|
217
219
|
var _a;
|
|
220
|
+
if (!isCommonSearchEnabled) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
218
223
|
if (!(commonSearchList === null || commonSearchList === void 0 ? void 0 : commonSearchList.length)) {
|
|
219
224
|
return;
|
|
220
225
|
}
|
|
@@ -222,7 +227,7 @@ function useCommonSearchModal(options) {
|
|
|
222
227
|
if (currentCommon) {
|
|
223
228
|
(_a = iptRef.current) === null || _a === void 0 ? void 0 : _a.setValue(currentCommon.title);
|
|
224
229
|
}
|
|
225
|
-
}, [currentCommonSearchKey, commonSearchList]);
|
|
230
|
+
}, [currentCommonSearchKey, commonSearchList, isCommonSearchEnabled]);
|
|
226
231
|
/**
|
|
227
232
|
* 保存为常用搜索事件
|
|
228
233
|
*/
|
|
@@ -233,7 +238,8 @@ function useCommonSearchModal(options) {
|
|
|
233
238
|
}
|
|
234
239
|
ModalComponent.confirm({
|
|
235
240
|
icon: null,
|
|
236
|
-
title: currentCommonSearchKey ? "更新常用搜索" : "保存为常用搜索",
|
|
241
|
+
// title: currentCommonSearchKey ? "更新常用搜索" : "保存为常用搜索",
|
|
242
|
+
title: "保存为常用搜索",
|
|
237
243
|
content: jsx(MyInput, { ref: iptRef }),
|
|
238
244
|
onOk: function () {
|
|
239
245
|
var _a, _b;
|
|
@@ -252,7 +258,8 @@ function useCommonSearchModal(options) {
|
|
|
252
258
|
data = {
|
|
253
259
|
title: currentCommonName,
|
|
254
260
|
value: currentData,
|
|
255
|
-
key: currentCommonSearchKey || Date.now(),
|
|
261
|
+
// key: currentCommonSearchKey || Date.now(),
|
|
262
|
+
key: Date.now(),
|
|
256
263
|
};
|
|
257
264
|
_c.label = 1;
|
|
258
265
|
case 1:
|
|
@@ -260,6 +267,7 @@ function useCommonSearchModal(options) {
|
|
|
260
267
|
return [4 /*yield*/, (setData === null || setData === void 0 ? void 0 : setData(data))];
|
|
261
268
|
case 2:
|
|
262
269
|
_c.sent();
|
|
270
|
+
setCurrentCommonSearchKey === null || setCurrentCommonSearchKey === void 0 ? void 0 : setCurrentCommonSearchKey(data.key);
|
|
263
271
|
myMessage.info("保存成功!");
|
|
264
272
|
(_b = iptRef.current) === null || _b === void 0 ? void 0 : _b.setValue("");
|
|
265
273
|
return [3 /*break*/, 4];
|