@hw-component/form 1.10.35 → 1.10.36
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/es/Form/hooks/useHForm.js +3 -1
- package/es/Form/hooks/useReqControl.js +4 -5
- package/es/Form/index.js +0 -1
- package/es/Select/hooks/norHooks.js +1 -0
- package/lib/Form/hooks/useHForm.js +3 -1
- package/lib/Form/hooks/useReqControl.js +4 -5
- package/lib/Form/index.js +0 -1
- package/lib/Select/hooks/norHooks.js +1 -0
- package/package.json +1 -1
- package/src/components/Form/hooks/useHForm.ts +3 -1
- package/src/components/Form/hooks/useReqControl.ts +0 -1
- package/src/components/Form/index.tsx +0 -1
- package/src/components/Select/hooks/norHooks.ts +1 -0
- package/src/components/TDPicker/RangePicker.tsx +2 -1
- package/src/pages/Form/index.tsx +49 -36
|
@@ -193,7 +193,9 @@ var useHForm = (function () {
|
|
|
193
193
|
resetFieldsInitValue: function resetFieldsInitValue() {
|
|
194
194
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
195
195
|
var oldValue = form.getFieldsValue(true);
|
|
196
|
-
var
|
|
196
|
+
var outputOldValue = formatValuesFn(oldValue, "outputValue");
|
|
197
|
+
var changeVal = _objectSpread(_objectSpread({}, oldValue), outputOldValue);
|
|
198
|
+
var keys = Object.keys(changeVal);
|
|
197
199
|
var newVale = {};
|
|
198
200
|
keys.forEach(function (key) {
|
|
199
201
|
newVale[key] = undefined;
|
|
@@ -20,17 +20,16 @@ var useSubRequest = function useSubRequest(_ref) {
|
|
|
20
20
|
while (1) switch (_context.prev = _context.next) {
|
|
21
21
|
case 0:
|
|
22
22
|
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
|
|
23
|
-
console.log(subVal, "sss");
|
|
24
23
|
params = getSaveParams();
|
|
25
24
|
if (!request) {
|
|
26
|
-
_context.next =
|
|
25
|
+
_context.next = 5;
|
|
27
26
|
break;
|
|
28
27
|
}
|
|
29
|
-
_context.next =
|
|
28
|
+
_context.next = 5;
|
|
30
29
|
return request(subVal, params);
|
|
31
|
-
case
|
|
30
|
+
case 5:
|
|
32
31
|
onFinish === null || onFinish === void 0 || onFinish(subVal, params);
|
|
33
|
-
case
|
|
32
|
+
case 6:
|
|
34
33
|
case "end":
|
|
35
34
|
return _context.stop();
|
|
36
35
|
}
|
package/es/Form/index.js
CHANGED
|
@@ -72,6 +72,7 @@ var useOptionsRequest = function useOptionsRequest(_ref) {
|
|
|
72
72
|
}
|
|
73
73
|
return params;
|
|
74
74
|
};
|
|
75
|
+
console.log(dispatchManual, "dispatchManual");
|
|
75
76
|
var _useRequest = useRequest(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
76
77
|
var requestParams,
|
|
77
78
|
type,
|
|
@@ -196,7 +196,9 @@ var useHForm = (function () {
|
|
|
196
196
|
resetFieldsInitValue: function resetFieldsInitValue() {
|
|
197
197
|
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
198
198
|
var oldValue = form.getFieldsValue(true);
|
|
199
|
-
var
|
|
199
|
+
var outputOldValue = formatValuesFn(oldValue, "outputValue");
|
|
200
|
+
var changeVal = _objectSpread(_objectSpread({}, oldValue), outputOldValue);
|
|
201
|
+
var keys = Object.keys(changeVal);
|
|
200
202
|
var newVale = {};
|
|
201
203
|
keys.forEach(function (key) {
|
|
202
204
|
newVale[key] = undefined;
|
|
@@ -21,17 +21,16 @@ var useSubRequest = function useSubRequest(_ref) {
|
|
|
21
21
|
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
23
23
|
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
|
|
24
|
-
console.log(subVal, "sss");
|
|
25
24
|
params = getSaveParams();
|
|
26
25
|
if (!request) {
|
|
27
|
-
_context.next =
|
|
26
|
+
_context.next = 5;
|
|
28
27
|
break;
|
|
29
28
|
}
|
|
30
|
-
_context.next =
|
|
29
|
+
_context.next = 5;
|
|
31
30
|
return request(subVal, params);
|
|
32
|
-
case
|
|
31
|
+
case 5:
|
|
33
32
|
onFinish === null || onFinish === void 0 || onFinish(subVal, params);
|
|
34
|
-
case
|
|
33
|
+
case 6:
|
|
35
34
|
case "end":
|
|
36
35
|
return _context.stop();
|
|
37
36
|
}
|
package/lib/Form/index.js
CHANGED
|
@@ -73,6 +73,7 @@ var useOptionsRequest = function useOptionsRequest(_ref) {
|
|
|
73
73
|
}
|
|
74
74
|
return params;
|
|
75
75
|
};
|
|
76
|
+
console.log(dispatchManual, "dispatchManual");
|
|
76
77
|
var _useRequest = ahooks.useRequest(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
77
78
|
var requestParams,
|
|
78
79
|
type,
|
package/package.json
CHANGED
|
@@ -178,7 +178,9 @@ export default () => {
|
|
|
178
178
|
},
|
|
179
179
|
resetFieldsInitValue: (values = {}) => {
|
|
180
180
|
const oldValue = form.getFieldsValue(true);
|
|
181
|
-
const
|
|
181
|
+
const outputOldValue=formatValuesFn(oldValue,"outputValue");
|
|
182
|
+
const changeVal={...oldValue,...outputOldValue};
|
|
183
|
+
const keys = Object.keys(changeVal);
|
|
182
184
|
const newVale = {};
|
|
183
185
|
keys.forEach((key) => {
|
|
184
186
|
newVale[key] = undefined;
|
|
@@ -55,6 +55,7 @@ const HRangePicker: React.FC<HRangePickerProps> = ({
|
|
|
55
55
|
inputValue: (item, initValue) => {
|
|
56
56
|
const { name: valueName = "" } = item;
|
|
57
57
|
const resultObj = {};
|
|
58
|
+
|
|
58
59
|
Object.values(dateMapKeys).forEach((key) => {
|
|
59
60
|
if (initValue[key]) {
|
|
60
61
|
resultObj[key] = initValue[key];
|
|
@@ -62,7 +63,7 @@ const HRangePicker: React.FC<HRangePickerProps> = ({
|
|
|
62
63
|
});
|
|
63
64
|
const hasKeys = Object.keys(resultObj).length !== 0;
|
|
64
65
|
return {
|
|
65
|
-
[valueName as string]: hasKeys ? resultObj :
|
|
66
|
+
[valueName as string]: hasKeys ? resultObj :null,
|
|
66
67
|
};
|
|
67
68
|
},
|
|
68
69
|
outputValue: (item, outputValue) => {
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
HForm,
|
|
3
|
+
HFormConfigProvider,
|
|
4
|
+
useHForm,
|
|
5
|
+
HSelect,
|
|
6
|
+
HBasicForm, HRangePicker,
|
|
7
7
|
} from "../../components";
|
|
8
8
|
import {useEffect, useState} from "react";
|
|
9
9
|
import { Button, Form, Input, Space } from "antd";
|
|
@@ -33,39 +33,52 @@ const Test3 = ({ value = {}, onChange }) => {
|
|
|
33
33
|
</Space>
|
|
34
34
|
);
|
|
35
35
|
};
|
|
36
|
-
const TestItem = () => {
|
|
37
|
-
return (
|
|
38
|
-
<Form.Item name="name1">
|
|
39
|
-
<Test3 />
|
|
40
|
-
</Form.Item>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
36
|
const Test = (props) => {
|
|
44
|
-
useEffect(()=>{
|
|
45
|
-
console.log("ffff")
|
|
46
|
-
},[]);
|
|
47
37
|
return <div>ffff</div>;
|
|
48
38
|
};
|
|
49
39
|
const Basic = () => {
|
|
50
40
|
return (
|
|
51
41
|
<HBasicForm
|
|
52
42
|
configData={[
|
|
53
|
-
{
|
|
54
|
-
label: "你好",
|
|
55
|
-
type: "inputNumberGroup",
|
|
56
|
-
name: "jgTime",
|
|
57
|
-
},
|
|
58
43
|
{
|
|
59
44
|
label:"test",
|
|
60
45
|
name:"test",
|
|
61
46
|
render:()=>{
|
|
62
47
|
return <Test/>
|
|
63
48
|
}
|
|
64
|
-
}
|
|
49
|
+
},{
|
|
50
|
+
name:'deviceType',
|
|
51
|
+
label:"deviceType"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label:"select",
|
|
55
|
+
name:"select",
|
|
56
|
+
type:"select",
|
|
57
|
+
dispatch: {
|
|
58
|
+
fnKey: 'reload',
|
|
59
|
+
dependencies: ['deviceType'],
|
|
60
|
+
},
|
|
61
|
+
itemProps:{
|
|
62
|
+
request:()=>{
|
|
63
|
+
console.log("request")
|
|
64
|
+
return Promise.resolve([])
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
65
68
|
]}
|
|
66
69
|
/>
|
|
67
70
|
);
|
|
68
71
|
};
|
|
72
|
+
|
|
73
|
+
const TestItem = ({value,...props}) => {
|
|
74
|
+
return (
|
|
75
|
+
<div>
|
|
76
|
+
1
|
|
77
|
+
<HRangePicker value={value} {...props}/>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
69
82
|
export default () => {
|
|
70
83
|
const form = useHForm();
|
|
71
84
|
const [id, setId] = useState(1);
|
|
@@ -99,28 +112,28 @@ export default () => {
|
|
|
99
112
|
<div style={{ width: 1000 }}>
|
|
100
113
|
<HForm
|
|
101
114
|
configData={[
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
115
|
+
// {
|
|
116
|
+
// noStyle: true,
|
|
117
|
+
// nameKey: "sendSetting",
|
|
118
|
+
// render: () => {
|
|
119
|
+
// return <Basic />;
|
|
120
|
+
// },
|
|
121
|
+
// },
|
|
109
122
|
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
123
|
+
name:'time',
|
|
124
|
+
label:"time",
|
|
125
|
+
render:()=>{
|
|
126
|
+
return <TestItem/>
|
|
114
127
|
}
|
|
115
|
-
}
|
|
128
|
+
}
|
|
116
129
|
]}
|
|
117
130
|
dismissOnPressEnter={false}
|
|
118
131
|
labelWidth={88}
|
|
119
132
|
form={form}
|
|
120
133
|
initialValues={{
|
|
121
134
|
richEditor: "1312312",
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
select:"1",
|
|
136
|
+
deviceType:"1"
|
|
124
137
|
}}
|
|
125
138
|
labelAlign={"left"}
|
|
126
139
|
onValuesChange={(val) => {
|
|
@@ -164,7 +177,7 @@ export default () => {
|
|
|
164
177
|
</div>
|
|
165
178
|
<div
|
|
166
179
|
onClick={() => {
|
|
167
|
-
form.
|
|
180
|
+
form.resetFieldsInitValue();
|
|
168
181
|
}}
|
|
169
182
|
>
|
|
170
183
|
重置
|