zmdms-webui 2.7.5 → 2.7.6
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/form/form.js
CHANGED
|
@@ -27,26 +27,32 @@ 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,
|
|
41
47
|
}).onCommonSearchHandle;
|
|
42
48
|
// 获取新的items 如果传入了配置项的话,配置项优先
|
|
43
49
|
var configInfoItems = useFormPreferencesCreateNewItems(formPreferences, items).configInfoItems;
|
|
44
50
|
// 根据items 和 dynamicKey 获取到动态列配置信息
|
|
45
|
-
var
|
|
51
|
+
var _c = useDynamicListByItems(configInfoItems, {
|
|
46
52
|
dynamicKey: dynamicKey,
|
|
47
53
|
formPreferences: formPreferences,
|
|
48
54
|
dynamicVersion: dynamicVersion,
|
|
49
|
-
}), dynamicList =
|
|
55
|
+
}), dynamicList = _c.dynamicList, onCurrentListChange = _c.onCurrentListChange, newItems = _c.newItems, dynamicSettingRef = _c.dynamicSettingRef;
|
|
50
56
|
// 主容器类名
|
|
51
57
|
var wrapClasses = classNames("ztxk-form", wrapClassName, {
|
|
52
58
|
"ztxk-form--bottom-border": bottomBorder,
|
|
@@ -118,22 +124,22 @@ var Form = function (props, ref) {
|
|
|
118
124
|
}
|
|
119
125
|
onValuesChange && onValuesChange(changedValues, allValues);
|
|
120
126
|
}, [onValuesChange, itemsShouldUpdate, form]);
|
|
121
|
-
var
|
|
127
|
+
var _d = useBtnHandle(form, {
|
|
122
128
|
onSearchHandle: onSearchHandle,
|
|
123
129
|
onResetHandle: onResetHandle,
|
|
124
|
-
}), onSearchHandleInner =
|
|
130
|
+
}), onSearchHandleInner = _d.onSearchHandleInner, onResetHandleInner = _d.onResetHandleInner, onDropdownResetHandleInner = _d.onDropdownResetHandleInner;
|
|
125
131
|
var leftWrapRef = useRef(null);
|
|
126
|
-
var
|
|
132
|
+
var _e = useToggle(leftWrapRef, {
|
|
127
133
|
isToggle: isToggle,
|
|
128
134
|
toggleNum: toggleNum,
|
|
129
135
|
defaultToggle: defaultToggle,
|
|
130
|
-
}), toggle =
|
|
136
|
+
}), toggle = _e.toggle, onToggleChange = _e.onToggleChange, setToggleHandle = _e.setToggleHandle;
|
|
131
137
|
useImperativeHandle(ref, function () {
|
|
132
138
|
return {
|
|
133
139
|
setToggleHandle: setToggleHandle,
|
|
134
140
|
};
|
|
135
141
|
});
|
|
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" }))] })),
|
|
142
|
+
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: currentCommonSearchKey ? "更新常用搜索" : "保存为常用搜索" })) }))) : 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
143
|
};
|
|
138
144
|
var MemoForm = memo(forwardRef(Form));
|
|
139
145
|
MemoForm.displayName = "ZTXK_WEBUI_Form";
|
|
@@ -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 || []); });
|
|
@@ -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;
|
|
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
|
*/
|