@hw-component/form 1.10.22 → 1.10.24
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/.eslintcache +1 -1
- package/es/Form/hooks/index.d.ts +0 -5
- package/es/Form/hooks/index.js +5 -118
- package/es/Form/hooks/useReqControl.d.ts +12 -0
- package/es/Form/hooks/useReqControl.js +171 -0
- package/es/Form/index.d.ts +1 -1
- package/es/Form/index.js +8 -16
- package/es/Form/modal.d.ts +3 -0
- package/lib/Form/hooks/index.d.ts +0 -5
- package/lib/Form/hooks/index.js +4 -118
- package/lib/Form/hooks/useReqControl.d.ts +12 -0
- package/lib/Form/hooks/useReqControl.js +172 -0
- package/lib/Form/index.d.ts +1 -1
- package/lib/Form/index.js +7 -15
- package/lib/Form/modal.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/Form/hooks/index.ts +0 -70
- package/src/components/Form/hooks/useReqControl.ts +129 -0
- package/src/components/Form/index.tsx +6 -13
- package/src/components/Form/modal.ts +3 -0
- package/src/components/Select/hooks/norHooks.ts +6 -6
- package/src/pages/Select/index.tsx +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
4
|
+
var _typeof = require('@babel/runtime-corejs3/helpers/typeof');
|
|
5
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
6
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var ahooks = require('ahooks');
|
|
9
|
+
|
|
10
|
+
var _excluded = ["request"];
|
|
11
|
+
var useSubRequest = function useSubRequest(_ref) {
|
|
12
|
+
var form = _ref.form,
|
|
13
|
+
preserve = _ref.preserve,
|
|
14
|
+
request = _ref.request,
|
|
15
|
+
onFinish = _ref.onFinish,
|
|
16
|
+
getSaveParams = _ref.getSaveParams;
|
|
17
|
+
return ahooks.useRequest(/*#__PURE__*/function () {
|
|
18
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
19
|
+
var subVal, params;
|
|
20
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
|
|
24
|
+
params = getSaveParams();
|
|
25
|
+
if (!request) {
|
|
26
|
+
_context.next = 5;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
_context.next = 5;
|
|
30
|
+
return request(subVal, params);
|
|
31
|
+
case 5:
|
|
32
|
+
onFinish === null || onFinish === void 0 || onFinish(subVal, params);
|
|
33
|
+
case 6:
|
|
34
|
+
case "end":
|
|
35
|
+
return _context.stop();
|
|
36
|
+
}
|
|
37
|
+
}, _callee);
|
|
38
|
+
}));
|
|
39
|
+
return function (_x) {
|
|
40
|
+
return _ref2.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
}(), {
|
|
43
|
+
manual: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var useInfoRequest = function useInfoRequest(_ref3) {
|
|
47
|
+
var infoRequest = _ref3.infoRequest,
|
|
48
|
+
form = _ref3.form,
|
|
49
|
+
initialValues = _ref3.initialValues,
|
|
50
|
+
getSaveParams = _ref3.getSaveParams,
|
|
51
|
+
setSaveParams = _ref3.setSaveParams;
|
|
52
|
+
var _useMemo = React.useMemo(function () {
|
|
53
|
+
if (_typeof(infoRequest) === "object") {
|
|
54
|
+
var infoReq = infoRequest.request,
|
|
55
|
+
op = _objectWithoutProperties(infoRequest, _excluded);
|
|
56
|
+
return {
|
|
57
|
+
infoReq: infoReq,
|
|
58
|
+
options: op
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
infoReq: infoRequest,
|
|
63
|
+
options: {}
|
|
64
|
+
};
|
|
65
|
+
}, [infoRequest]),
|
|
66
|
+
initReq = _useMemo.infoReq,
|
|
67
|
+
options = _useMemo.options;
|
|
68
|
+
return ahooks.useRequest(/*#__PURE__*/function () {
|
|
69
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(reqParams) {
|
|
70
|
+
var relParams, result;
|
|
71
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
relParams = typeof reqParams === "undefined" ? getSaveParams() : reqParams;
|
|
75
|
+
setSaveParams(relParams);
|
|
76
|
+
if (!initReq) {
|
|
77
|
+
_context2.next = 8;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
_context2.next = 5;
|
|
81
|
+
return initReq(relParams);
|
|
82
|
+
case 5:
|
|
83
|
+
result = _context2.sent;
|
|
84
|
+
form === null || form === void 0 || form.setFieldsValue(result);
|
|
85
|
+
return _context2.abrupt("return", result || {});
|
|
86
|
+
case 8:
|
|
87
|
+
if (!(typeof initialValues === "undefined")) {
|
|
88
|
+
_context2.next = 10;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return _context2.abrupt("return", {});
|
|
92
|
+
case 10:
|
|
93
|
+
form === null || form === void 0 || form.setFieldsValue(initialValues);
|
|
94
|
+
return _context2.abrupt("return", initialValues);
|
|
95
|
+
case 12:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context2.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee2);
|
|
100
|
+
}));
|
|
101
|
+
return function (_x2) {
|
|
102
|
+
return _ref4.apply(this, arguments);
|
|
103
|
+
};
|
|
104
|
+
}(), options);
|
|
105
|
+
};
|
|
106
|
+
var useInfoReq = function useInfoReq(_ref5) {
|
|
107
|
+
var initialValues = _ref5.initialValues,
|
|
108
|
+
infoRequest = _ref5.infoRequest,
|
|
109
|
+
form = _ref5.form,
|
|
110
|
+
_ref5$params = _ref5.params,
|
|
111
|
+
params = _ref5$params === void 0 ? {} : _ref5$params,
|
|
112
|
+
request = _ref5.request,
|
|
113
|
+
onFinish = _ref5.onFinish,
|
|
114
|
+
preserve = _ref5.preserve,
|
|
115
|
+
loading = _ref5.loading,
|
|
116
|
+
error = _ref5.error,
|
|
117
|
+
reload = _ref5.reload;
|
|
118
|
+
var reqData = React.useMemo(function () {
|
|
119
|
+
var saveParams = params || {};
|
|
120
|
+
return {
|
|
121
|
+
params: saveParams
|
|
122
|
+
};
|
|
123
|
+
}, [params]);
|
|
124
|
+
var getSaveParams = function getSaveParams() {
|
|
125
|
+
return reqData.params;
|
|
126
|
+
};
|
|
127
|
+
var setSaveParams = function setSaveParams(newParams) {
|
|
128
|
+
reqData.params = newParams;
|
|
129
|
+
};
|
|
130
|
+
var subControl = useSubRequest({
|
|
131
|
+
form: form,
|
|
132
|
+
preserve: preserve,
|
|
133
|
+
request: request,
|
|
134
|
+
onFinish: onFinish,
|
|
135
|
+
getSaveParams: getSaveParams
|
|
136
|
+
});
|
|
137
|
+
var infoControl = useInfoRequest({
|
|
138
|
+
infoRequest: infoRequest,
|
|
139
|
+
form: form,
|
|
140
|
+
initialValues: initialValues,
|
|
141
|
+
getSaveParams: getSaveParams,
|
|
142
|
+
setSaveParams: setSaveParams
|
|
143
|
+
});
|
|
144
|
+
var run = infoControl.run,
|
|
145
|
+
mutate = infoControl.mutate;
|
|
146
|
+
React.useEffect(function () {
|
|
147
|
+
if (form) {
|
|
148
|
+
form.reload = function (reloadParams) {
|
|
149
|
+
mutate(undefined);
|
|
150
|
+
return run(reloadParams);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}, []);
|
|
154
|
+
var resultInfoControl = function resultInfoControl() {
|
|
155
|
+
if (!infoRequest) {
|
|
156
|
+
return {
|
|
157
|
+
loading: loading,
|
|
158
|
+
error: error,
|
|
159
|
+
data: initialValues,
|
|
160
|
+
run: reload
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return infoControl;
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
subControl: subControl,
|
|
167
|
+
infoControl: resultInfoControl()
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
exports.useInfoReq = useInfoReq;
|
|
172
|
+
// powered by h
|
package/lib/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form,
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, valueType, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, preserve, rowWrapper, requiredMode, style, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/lib/Form/index.js
CHANGED
|
@@ -13,22 +13,17 @@ var index$1 = require('../PageHandler/index.js');
|
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var InitSet = require('./InitSet.js');
|
|
15
15
|
var Basic = require('./Basic.js');
|
|
16
|
+
var useReqControl = require('./hooks/useReqControl.js');
|
|
16
17
|
|
|
17
|
-
var _excluded = ["configData", "labelWidth", "form", "
|
|
18
|
+
var _excluded = ["configData", "labelWidth", "form", "valueType", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter", "preserve", "rowWrapper", "requiredMode", "style"];
|
|
18
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
21
|
var HForm = (function (_ref) {
|
|
21
22
|
var configData = _ref.configData,
|
|
22
23
|
labelWidth = _ref.labelWidth,
|
|
23
24
|
form = _ref.form,
|
|
24
|
-
request = _ref.request,
|
|
25
|
-
onFinish = _ref.onFinish,
|
|
26
|
-
infoRequest = _ref.infoRequest,
|
|
27
25
|
_ref$valueType = _ref.valueType,
|
|
28
26
|
valueType = _ref$valueType === void 0 ? "float" : _ref$valueType,
|
|
29
|
-
initialValues = _ref.initialValues,
|
|
30
|
-
_ref$params = _ref.params,
|
|
31
|
-
params = _ref$params === void 0 ? {} : _ref$params,
|
|
32
27
|
onValuesChange = _ref.onValuesChange,
|
|
33
28
|
itemSpan = _ref.itemSpan,
|
|
34
29
|
_ref$hideLabel = _ref.hideLabel,
|
|
@@ -52,16 +47,11 @@ var HForm = (function (_ref) {
|
|
|
52
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
48
|
dispatchSourceData = _useState2[0],
|
|
54
49
|
setDispatchSourceData = _useState2[1];
|
|
55
|
-
var _useInfoReq =
|
|
56
|
-
initialValues: initialValues,
|
|
57
|
-
request: request,
|
|
58
|
-
onFinish: onFinish,
|
|
50
|
+
var _useInfoReq = useReqControl.useInfoReq(_objectSpread({
|
|
59
51
|
valueType: valueType,
|
|
60
52
|
form: hForm,
|
|
61
|
-
infoRequest: infoRequest,
|
|
62
|
-
params: params,
|
|
63
53
|
preserve: preserve
|
|
64
|
-
}),
|
|
54
|
+
}, props)),
|
|
65
55
|
subControl = _useInfoReq.subControl,
|
|
66
56
|
infoControl = _useInfoReq.infoControl;
|
|
67
57
|
var valuesChange = index.useValuesChange({
|
|
@@ -89,7 +79,9 @@ var HForm = (function (_ref) {
|
|
|
89
79
|
loading: infoLoading,
|
|
90
80
|
error: infoErr,
|
|
91
81
|
data: infoData,
|
|
92
|
-
reload:
|
|
82
|
+
reload: function reload() {
|
|
83
|
+
infoRun === null || infoRun === void 0 || infoRun();
|
|
84
|
+
},
|
|
93
85
|
children: jsxRuntime.jsx(index$2.FormContext.Provider, {
|
|
94
86
|
value: {
|
|
95
87
|
loading: submitLoading || loading,
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -80,6 +80,9 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "
|
|
|
80
80
|
rowWrapper?: boolean;
|
|
81
81
|
flexBox?: boolean;
|
|
82
82
|
requiredMode?: boolean;
|
|
83
|
+
loading?: boolean;
|
|
84
|
+
error?: Error;
|
|
85
|
+
reload?: VoidFunction;
|
|
83
86
|
}
|
|
84
87
|
export interface HFormItemProps extends HItemProps {
|
|
85
88
|
required?: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { useRequest } from "ahooks";
|
|
2
1
|
import type { HFormProps, HFormInstance } from "../modal";
|
|
3
2
|
import useHForm from "./useHForm";
|
|
4
|
-
import { useEffect, useMemo } from "react";
|
|
5
3
|
import FormConfig from "../config";
|
|
6
4
|
import { useFormConfigContext } from "../Context/FormConfigProvider";
|
|
7
5
|
import type { DispatchModal } from "../modal";
|
|
@@ -16,74 +14,6 @@ export const useCurrentForm = (form?: HFormInstance) => {
|
|
|
16
14
|
const selfForm = useHForm();
|
|
17
15
|
return form || selfForm;
|
|
18
16
|
};
|
|
19
|
-
type ParamsModal = Omit<HFormProps, "configData">;
|
|
20
|
-
|
|
21
|
-
export const useInfoReq = ({
|
|
22
|
-
initialValues,
|
|
23
|
-
infoRequest,
|
|
24
|
-
form,
|
|
25
|
-
params,
|
|
26
|
-
request,
|
|
27
|
-
onFinish,
|
|
28
|
-
preserve,
|
|
29
|
-
}: ParamsModal) => {
|
|
30
|
-
const reqData = useMemo(() => {
|
|
31
|
-
const saveParams = params || {};
|
|
32
|
-
return {
|
|
33
|
-
params: saveParams,
|
|
34
|
-
};
|
|
35
|
-
}, [params]);
|
|
36
|
-
const { infoReq: initReq, options } = useMemo(() => {
|
|
37
|
-
if (typeof infoRequest === "object") {
|
|
38
|
-
const { request: infoReq, ...op } = infoRequest;
|
|
39
|
-
return {
|
|
40
|
-
infoReq,
|
|
41
|
-
options: op,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
infoReq: infoRequest,
|
|
46
|
-
options: {},
|
|
47
|
-
};
|
|
48
|
-
}, [infoRequest]);
|
|
49
|
-
|
|
50
|
-
const subControl = useRequest(
|
|
51
|
-
async (value) => {
|
|
52
|
-
const subVal = form?.outputValues(value, preserve);
|
|
53
|
-
if (request) {
|
|
54
|
-
await request(subVal, reqData.params);
|
|
55
|
-
}
|
|
56
|
-
onFinish?.(subVal, reqData.params);
|
|
57
|
-
},
|
|
58
|
-
{ manual: true }
|
|
59
|
-
);
|
|
60
|
-
const infoControl = useRequest(async (reqParams = reqData.params) => {
|
|
61
|
-
reqData.params = reqParams;
|
|
62
|
-
if (initReq) {
|
|
63
|
-
const result = await initReq(reqParams);
|
|
64
|
-
form?.setFieldsValue(result);
|
|
65
|
-
return result || {};
|
|
66
|
-
}
|
|
67
|
-
if (typeof initialValues === "undefined") {
|
|
68
|
-
return {};
|
|
69
|
-
}
|
|
70
|
-
form?.setFieldsValue(initialValues);
|
|
71
|
-
return initialValues;
|
|
72
|
-
}, options);
|
|
73
|
-
const { run, mutate } = infoControl;
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (form) {
|
|
76
|
-
form.reload = (reloadParams) => {
|
|
77
|
-
mutate(undefined);
|
|
78
|
-
return run(reloadParams);
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}, []);
|
|
82
|
-
return {
|
|
83
|
-
subControl,
|
|
84
|
-
infoControl,
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
17
|
|
|
88
18
|
export const useDefaultComponents = () => {
|
|
89
19
|
const defaultComponent = useFormConfigContext("defaultComponent");
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
import { useRequest } from "ahooks";
|
|
3
|
+
import { HFormProps } from "@/components/Form/modal";
|
|
4
|
+
|
|
5
|
+
type ParamsModal = Omit<HFormProps, "configData">;
|
|
6
|
+
interface SunParamsModal extends Omit<HFormProps, "configData"> {
|
|
7
|
+
getSaveParams: () => Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
interface InfoParamsModal extends SunParamsModal {
|
|
10
|
+
setSaveParams: (params: Record<string, any>) => void;
|
|
11
|
+
}
|
|
12
|
+
const useSubRequest = ({
|
|
13
|
+
form,
|
|
14
|
+
preserve,
|
|
15
|
+
request,
|
|
16
|
+
onFinish,
|
|
17
|
+
getSaveParams,
|
|
18
|
+
}: SunParamsModal) => {
|
|
19
|
+
return useRequest(
|
|
20
|
+
async (value) => {
|
|
21
|
+
const subVal = form?.outputValues(value, preserve);
|
|
22
|
+
const params = getSaveParams();
|
|
23
|
+
if (request) {
|
|
24
|
+
await request(subVal, params);
|
|
25
|
+
}
|
|
26
|
+
onFinish?.(subVal, params);
|
|
27
|
+
},
|
|
28
|
+
{ manual: true }
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
const useInfoRequest = ({
|
|
32
|
+
infoRequest,
|
|
33
|
+
form,
|
|
34
|
+
initialValues,
|
|
35
|
+
getSaveParams,
|
|
36
|
+
setSaveParams,
|
|
37
|
+
}: InfoParamsModal) => {
|
|
38
|
+
const { infoReq: initReq, options } = useMemo(() => {
|
|
39
|
+
if (typeof infoRequest === "object") {
|
|
40
|
+
const { request: infoReq, ...op } = infoRequest;
|
|
41
|
+
return {
|
|
42
|
+
infoReq,
|
|
43
|
+
options: op,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
infoReq: infoRequest,
|
|
48
|
+
options: {},
|
|
49
|
+
};
|
|
50
|
+
}, [infoRequest]);
|
|
51
|
+
return useRequest(async (reqParams?: Record<string, any>) => {
|
|
52
|
+
const relParams =
|
|
53
|
+
typeof reqParams === "undefined" ? getSaveParams() : reqParams;
|
|
54
|
+
setSaveParams(relParams);
|
|
55
|
+
if (initReq) {
|
|
56
|
+
const result = await initReq(relParams);
|
|
57
|
+
form?.setFieldsValue(result);
|
|
58
|
+
return result || {};
|
|
59
|
+
}
|
|
60
|
+
if (typeof initialValues === "undefined") {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
form?.setFieldsValue(initialValues);
|
|
64
|
+
return initialValues;
|
|
65
|
+
}, options);
|
|
66
|
+
};
|
|
67
|
+
export const useInfoReq = ({
|
|
68
|
+
initialValues,
|
|
69
|
+
infoRequest,
|
|
70
|
+
form,
|
|
71
|
+
params = {},
|
|
72
|
+
request,
|
|
73
|
+
onFinish,
|
|
74
|
+
preserve,
|
|
75
|
+
loading,
|
|
76
|
+
error,
|
|
77
|
+
reload
|
|
78
|
+
}: ParamsModal) => {
|
|
79
|
+
const reqData = useMemo(() => {
|
|
80
|
+
const saveParams = params || {};
|
|
81
|
+
return {
|
|
82
|
+
params: saveParams,
|
|
83
|
+
};
|
|
84
|
+
}, [params]);
|
|
85
|
+
const getSaveParams = () => {
|
|
86
|
+
return reqData.params;
|
|
87
|
+
};
|
|
88
|
+
const setSaveParams = (newParams) => {
|
|
89
|
+
reqData.params = newParams;
|
|
90
|
+
};
|
|
91
|
+
const subControl = useSubRequest({
|
|
92
|
+
form,
|
|
93
|
+
preserve,
|
|
94
|
+
request,
|
|
95
|
+
onFinish,
|
|
96
|
+
getSaveParams,
|
|
97
|
+
});
|
|
98
|
+
const infoControl = useInfoRequest({
|
|
99
|
+
infoRequest,
|
|
100
|
+
form,
|
|
101
|
+
initialValues,
|
|
102
|
+
getSaveParams,
|
|
103
|
+
setSaveParams,
|
|
104
|
+
});
|
|
105
|
+
const { run, mutate } = infoControl;
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (form) {
|
|
108
|
+
form.reload = (reloadParams) => {
|
|
109
|
+
mutate(undefined);
|
|
110
|
+
return run(reloadParams);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}, []);
|
|
114
|
+
const resultInfoControl=()=>{
|
|
115
|
+
if (!infoRequest){
|
|
116
|
+
return {
|
|
117
|
+
loading,
|
|
118
|
+
error,
|
|
119
|
+
data:initialValues,
|
|
120
|
+
run:reload
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return infoControl;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
subControl,
|
|
127
|
+
infoControl:resultInfoControl()
|
|
128
|
+
};
|
|
129
|
+
};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { Form } from "antd";
|
|
2
2
|
import type { HFormProps } from "./modal";
|
|
3
|
-
import { useCurrentForm,
|
|
3
|
+
import { useCurrentForm, useValuesChange } from "./hooks";
|
|
4
4
|
import { FormContext } from "./Context";
|
|
5
5
|
import PageHandler from "../PageHandler";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
7
|
import InitSet from "./InitSet";
|
|
8
8
|
import Basic from "./Basic";
|
|
9
|
-
|
|
9
|
+
import { useInfoReq } from "./hooks/useReqControl";
|
|
10
10
|
export default ({
|
|
11
11
|
configData,
|
|
12
12
|
labelWidth,
|
|
13
13
|
form,
|
|
14
|
-
request,
|
|
15
|
-
onFinish,
|
|
16
|
-
infoRequest,
|
|
17
14
|
valueType = "float",
|
|
18
|
-
initialValues,
|
|
19
|
-
params = {},
|
|
20
15
|
onValuesChange,
|
|
21
16
|
itemSpan,
|
|
22
17
|
hideLabel: formHideLabel = false,
|
|
@@ -36,14 +31,10 @@ export default ({
|
|
|
36
31
|
const hForm = useCurrentForm(form);
|
|
37
32
|
const [dispatchSourceData, setDispatchSourceData] = useState({});
|
|
38
33
|
const { subControl, infoControl } = useInfoReq({
|
|
39
|
-
initialValues,
|
|
40
|
-
request,
|
|
41
|
-
onFinish,
|
|
42
34
|
valueType,
|
|
43
35
|
form: hForm,
|
|
44
|
-
infoRequest,
|
|
45
|
-
params,
|
|
46
36
|
preserve,
|
|
37
|
+
...props,
|
|
47
38
|
});
|
|
48
39
|
const valuesChange = useValuesChange({
|
|
49
40
|
onValuesChange,
|
|
@@ -77,7 +68,9 @@ export default ({
|
|
|
77
68
|
loading={infoLoading}
|
|
78
69
|
error={infoErr}
|
|
79
70
|
data={infoData}
|
|
80
|
-
reload={
|
|
71
|
+
reload={() => {
|
|
72
|
+
infoRun?.();
|
|
73
|
+
}}
|
|
81
74
|
>
|
|
82
75
|
<FormContext.Provider
|
|
83
76
|
value={{
|
|
@@ -128,6 +128,9 @@ export interface HFormProps<T = any, R = any>
|
|
|
128
128
|
rowWrapper?: boolean;
|
|
129
129
|
flexBox?: boolean;
|
|
130
130
|
requiredMode?: boolean;
|
|
131
|
+
loading?: boolean;
|
|
132
|
+
error?: Error;
|
|
133
|
+
reload?: VoidFunction;
|
|
131
134
|
}
|
|
132
135
|
export interface HFormItemProps extends HItemProps {
|
|
133
136
|
required?: boolean;
|
|
@@ -160,12 +160,12 @@ export const useSelectReq = ({
|
|
|
160
160
|
run({}, "page");
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
|
-
const mathShowSearch=useMemo(()=>{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},[showSearch,serviceSearch])
|
|
163
|
+
const mathShowSearch = useMemo(() => {
|
|
164
|
+
if (typeof showSearch == "undefined") {
|
|
165
|
+
return serviceSearch;
|
|
166
|
+
}
|
|
167
|
+
return showSearch;
|
|
168
|
+
}, [showSearch, serviceSearch]);
|
|
169
169
|
return {
|
|
170
170
|
run,
|
|
171
171
|
loading,
|