@hw-component/form 1.4.9 → 1.5.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.
- package/.eslintcache +1 -1
- package/es/Input/InputNumberGroup.d.ts +2 -2
- package/es/Input/InputNumberGroup.js +4 -4
- package/es/Upload/hooks/customRequest.js +11 -6
- package/lib/Input/InputNumberGroup.d.ts +2 -2
- package/lib/Input/InputNumberGroup.js +4 -4
- package/lib/Upload/hooks/customRequest.js +11 -6
- package/package.json +1 -1
- package/src/components/Form/HFormConnect.tsx +6 -7
- package/src/components/Form/config.ts +2 -3
- package/src/components/Form/hooks/useHForm.ts +10 -7
- package/src/components/Input/InputNumberGroup.tsx +141 -129
- package/src/components/Input/index.less +5 -5
- package/src/components/Select/components/AllSelect.tsx +13 -13
- package/src/components/Select/components/CheckBoxOption.tsx +3 -3
- package/src/components/Select/defaultConfig.tsx +4 -2
- package/src/components/Select/hooks/changeHooks.tsx +2 -2
- package/src/components/Switch/index.tsx +1 -1
- package/src/components/Upload/hooks/customRequest.ts +7 -3
- package/src/components/Upload/index.tsx +1 -1
- package/src/pages/Form/index.tsx +49 -42
- package/src/pages/ModalForm/index.tsx +11 -10
- package/src/pages/Select/index.tsx +1 -1
- package/src/pages/Upload/index.tsx +13 -1
|
@@ -18,7 +18,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
18
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
19
|
var subReq = /*#__PURE__*/function () {
|
|
20
20
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
21
|
-
var request, file, _yield$request, url;
|
|
21
|
+
var request, file, _yield$request, url, thumbUrl;
|
|
22
22
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
23
23
|
while (1) switch (_context.prev = _context.next) {
|
|
24
24
|
case 0:
|
|
@@ -38,23 +38,25 @@ var subReq = /*#__PURE__*/function () {
|
|
|
38
38
|
case 6:
|
|
39
39
|
_yield$request = _context.sent;
|
|
40
40
|
url = _yield$request.url;
|
|
41
|
+
thumbUrl = _yield$request.thumbUrl;
|
|
41
42
|
return _context.abrupt("return", {
|
|
42
43
|
url: url,
|
|
44
|
+
thumbUrl: thumbUrl,
|
|
43
45
|
status: "done"
|
|
44
46
|
});
|
|
45
|
-
case
|
|
46
|
-
_context.prev =
|
|
47
|
+
case 12:
|
|
48
|
+
_context.prev = 12;
|
|
47
49
|
_context.t0 = _context["catch"](3);
|
|
48
50
|
antd.message.error(_context.t0.message);
|
|
49
51
|
return _context.abrupt("return", {
|
|
50
52
|
url: "",
|
|
51
53
|
status: "error"
|
|
52
54
|
});
|
|
53
|
-
case
|
|
55
|
+
case 16:
|
|
54
56
|
case "end":
|
|
55
57
|
return _context.stop();
|
|
56
58
|
}
|
|
57
|
-
}, _callee, null, [[3,
|
|
59
|
+
}, _callee, null, [[3, 12]]);
|
|
58
60
|
}));
|
|
59
61
|
return function subReq(_x) {
|
|
60
62
|
return _ref2.apply(this, arguments);
|
|
@@ -63,19 +65,22 @@ var subReq = /*#__PURE__*/function () {
|
|
|
63
65
|
var fileListProvider = function fileListProvider(changeFile, files) {
|
|
64
66
|
var status = changeFile.status,
|
|
65
67
|
url = changeFile.url,
|
|
66
|
-
uid = changeFile.uid
|
|
68
|
+
uid = changeFile.uid,
|
|
69
|
+
thumbUrl = changeFile.thumbUrl;
|
|
67
70
|
if (status === "error") {
|
|
68
71
|
return files === null || files === void 0 ? void 0 : files.filter(function (item) {
|
|
69
72
|
return item.uid !== uid;
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
return files === null || files === void 0 ? void 0 : files.map(function (item) {
|
|
76
|
+
var fileDefaultThumbUrl = item.thumbUrl || thumbUrl;
|
|
73
77
|
var resultUrl = url || item.thumbUrl;
|
|
74
78
|
if (item.uid === uid) {
|
|
75
79
|
item.status = status;
|
|
76
80
|
item.response = {
|
|
77
81
|
url: resultUrl
|
|
78
82
|
};
|
|
83
|
+
item.thumbUrl = fileDefaultThumbUrl;
|
|
79
84
|
return item;
|
|
80
85
|
}
|
|
81
86
|
return item;
|
package/package.json
CHANGED
|
@@ -43,26 +43,25 @@ export default (
|
|
|
43
43
|
props: HFormItemProps,
|
|
44
44
|
ref
|
|
45
45
|
) => {
|
|
46
|
-
|
|
47
46
|
const { form, valueType = "float" } = useFormContext();
|
|
48
47
|
|
|
49
48
|
useEffect(() => {
|
|
50
|
-
const {name}=props;
|
|
51
|
-
if (!name){
|
|
49
|
+
const { name } = props;
|
|
50
|
+
if (!name) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
53
|
form?.addFormat(name, formatMaker(props, format[valueType]));
|
|
55
54
|
}, [valueType, props]);
|
|
56
55
|
const addFormat = (aFormat: Record<string, addFormatItemModal>) => {
|
|
57
|
-
const {name}=props;
|
|
58
|
-
if (!name){
|
|
56
|
+
const { name } = props;
|
|
57
|
+
if (!name) {
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
60
|
form?.addFormat(name, formatMaker(props, aFormat[valueType]));
|
|
62
61
|
};
|
|
63
62
|
const addDispatchListener = (key: string, fn: argsFn) => {
|
|
64
|
-
const { name
|
|
65
|
-
if (!name){
|
|
63
|
+
const { name, dispatch } = props;
|
|
64
|
+
if (!name) {
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
form?.addDispatchListener({ key, name, dispatch }, fn);
|
|
@@ -19,7 +19,7 @@ import Cascader from "../Cascader";
|
|
|
19
19
|
import VerificationCodeInput from "../Input/VerificationCodeInput";
|
|
20
20
|
import TrimInput from "../Input/TrimInput";
|
|
21
21
|
import TrimTextArea from "../TextArea/TrimTextArea";
|
|
22
|
-
import HInputNumberGroup from
|
|
22
|
+
import HInputNumberGroup from "../Input/InputNumberGroup";
|
|
23
23
|
export const placeholderConfig = {
|
|
24
24
|
inputType: [
|
|
25
25
|
"input",
|
|
@@ -29,7 +29,7 @@ export const placeholderConfig = {
|
|
|
29
29
|
"verificationCodeInput",
|
|
30
30
|
"trimInput",
|
|
31
31
|
"urlUpload",
|
|
32
|
-
"textArea"
|
|
32
|
+
"textArea",
|
|
33
33
|
],
|
|
34
34
|
selectType: ["select", "datePicker", "timePicker", "colorInput"],
|
|
35
35
|
};
|
|
@@ -56,7 +56,6 @@ const componentConfig = {
|
|
|
56
56
|
trimInput: TrimInput,
|
|
57
57
|
trimTextArea: TrimTextArea,
|
|
58
58
|
inputNumberGroup: HInputNumberGroup,
|
|
59
|
-
|
|
60
59
|
};
|
|
61
60
|
|
|
62
61
|
export default componentConfig;
|
|
@@ -157,13 +157,16 @@ export default () => {
|
|
|
157
157
|
form.setFieldsValue(newValue);
|
|
158
158
|
},
|
|
159
159
|
validateFields(nameList) {
|
|
160
|
-
return new Promise((resolve,reject) => {
|
|
161
|
-
form
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
form
|
|
162
|
+
.validateFields(nameList)
|
|
163
|
+
.then((value) => {
|
|
164
|
+
const result = this.formatValues(value, "outputValue");
|
|
165
|
+
return resolve(result);
|
|
166
|
+
})
|
|
167
|
+
.catch((e) => {
|
|
168
|
+
reject(e);
|
|
169
|
+
});
|
|
167
170
|
});
|
|
168
171
|
},
|
|
169
172
|
resetFieldsInitValue: () => {
|
|
@@ -1,137 +1,149 @@
|
|
|
1
|
-
import { InputNumber, Input } from
|
|
2
|
-
import { SwapRightOutlined } from
|
|
3
|
-
import React, { useMemo, useState } from
|
|
4
|
-
import type { InputNumberProps } from
|
|
1
|
+
import { InputNumber, Input } from "antd";
|
|
2
|
+
import { SwapRightOutlined } from "@ant-design/icons";
|
|
3
|
+
import React, { useMemo, useState } from "react";
|
|
4
|
+
import type { InputNumberProps } from "antd/lib/input-number";
|
|
5
5
|
import { useClassName } from "../hooks";
|
|
6
|
-
import {addFormatItemModal, HItemProps} from "@/components/Form/modal";
|
|
6
|
+
import type { addFormatItemModal, HItemProps } from "@/components/Form/modal";
|
|
7
7
|
import HFormConnect from "../Form/HFormConnect";
|
|
8
8
|
|
|
9
|
-
interface IProps<T=any> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
interface IProps<T = any> {
|
|
10
|
+
placeholder?: [string, string] | string;
|
|
11
|
+
addonAfter?: React.ReactNode;
|
|
12
|
+
valueMap?: {
|
|
13
|
+
min: string;
|
|
14
|
+
max: string;
|
|
15
|
+
};
|
|
16
|
+
inputNumberProps?: [InputNumberProps, InputNumberProps] | InputNumberProps;
|
|
17
|
+
value?: T;
|
|
18
|
+
onChange: (value: T) => void;
|
|
19
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
|
+
noHandlerWrap?: boolean;
|
|
21
21
|
}
|
|
22
22
|
const useArrayProps = (props: any) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
if (Array.isArray(props)) {
|
|
25
|
+
return props;
|
|
26
|
+
}
|
|
27
|
+
return [props, props];
|
|
28
|
+
}, [props]);
|
|
29
29
|
};
|
|
30
|
-
const InputNumberGroup=({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
30
|
+
const InputNumberGroup = ({
|
|
31
|
+
value = {},
|
|
32
|
+
valueMap = { min: "min", max: "max" },
|
|
33
|
+
onChange,
|
|
34
|
+
placeholder = ["请输入", "请输入"],
|
|
35
|
+
inputNumberProps = {},
|
|
36
|
+
addonAfter,
|
|
37
|
+
noHandlerWrap = true,
|
|
38
|
+
addFormat,
|
|
39
|
+
}: IProps) => {
|
|
40
|
+
const { min, max } = valueMap;
|
|
41
|
+
const { [min]: minVal, [max]: maxVal } = value;
|
|
42
|
+
const [fsPlaceholder, edPlaceholder] = useArrayProps(placeholder);
|
|
43
|
+
const [fsProps, edProps] = useArrayProps(inputNumberProps);
|
|
44
|
+
const [focus, setFocus] = useState(false);
|
|
45
|
+
const contentClassname = useClassName(["hw-input-group"]);
|
|
46
|
+
const bodyClassname = useClassName(["hw-input-group-body"]);
|
|
47
|
+
const activeClassname = useClassName(["hw-input-group-active"]);
|
|
48
|
+
const borderClassname = useClassName(["hw-input-group-border"]);
|
|
49
|
+
const oneClassname = useClassName(["hw-input-group-one"]);
|
|
50
|
+
const iconClassname = useClassName(["hw-input-group-icon"]);
|
|
51
|
+
const noHandlerWrapClassname = useClassName([
|
|
52
|
+
"hw-input-group-no-handler-wrap",
|
|
53
|
+
]);
|
|
54
|
+
addFormat?.({
|
|
55
|
+
float: {
|
|
56
|
+
inputValue: (item, initValue) => {
|
|
57
|
+
const { name: valueName = "" } = item;
|
|
58
|
+
const { min: minKey, max: maxKey } = valueMap;
|
|
59
|
+
const cuValue = initValue[valueName];
|
|
60
|
+
const minInitVal = initValue[minKey];
|
|
61
|
+
const maxInitVal = initValue[maxKey];
|
|
62
|
+
return {
|
|
63
|
+
[valueName]: {
|
|
64
|
+
[min]: minInitVal,
|
|
65
|
+
[max]: maxInitVal,
|
|
66
|
+
...cuValue,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
outputValue: (item, outputValue) => {
|
|
71
|
+
const { name: valueName = "" } = item;
|
|
72
|
+
const { [valueName]: itemVal = {} } = outputValue;
|
|
73
|
+
const { min: minKey, max: maxKey } = valueMap;
|
|
74
|
+
const {
|
|
75
|
+
[minKey]: minSubVal,
|
|
76
|
+
[maxKey]: maxSubVal,
|
|
77
|
+
...oItemVal
|
|
78
|
+
} = itemVal;
|
|
79
|
+
return {
|
|
80
|
+
[maxKey]: maxSubVal,
|
|
81
|
+
[minKey]: minSubVal,
|
|
82
|
+
[valueName]: oItemVal,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const change = (key: string, val: number | null) => {
|
|
88
|
+
const newVal = { ...value };
|
|
89
|
+
newVal[key] = val;
|
|
90
|
+
onChange?.(newVal);
|
|
91
|
+
};
|
|
92
|
+
return (
|
|
93
|
+
<Input.Group compact className={contentClassname}>
|
|
94
|
+
{addonAfter
|
|
95
|
+
? React.cloneElement(addonAfter as any, { value, onChange })
|
|
96
|
+
: addonAfter}
|
|
97
|
+
<div
|
|
98
|
+
className={`${bodyClassname} ${focus ? activeClassname : ""} ${
|
|
99
|
+
noHandlerWrap ? noHandlerWrapClassname : ""
|
|
100
|
+
}`}
|
|
101
|
+
>
|
|
102
|
+
<span className={borderClassname} />
|
|
103
|
+
<InputNumber<number>
|
|
104
|
+
bordered={false}
|
|
105
|
+
value={minVal}
|
|
106
|
+
max={maxVal}
|
|
107
|
+
min={0}
|
|
108
|
+
className={oneClassname}
|
|
109
|
+
onFocus={() => {
|
|
110
|
+
setFocus(true);
|
|
111
|
+
}}
|
|
112
|
+
onBlur={() => {
|
|
113
|
+
setFocus(false);
|
|
114
|
+
}}
|
|
115
|
+
onChange={(val) => {
|
|
116
|
+
change(min, val);
|
|
117
|
+
}}
|
|
118
|
+
placeholder={fsPlaceholder}
|
|
119
|
+
{...fsProps}
|
|
120
|
+
/>
|
|
121
|
+
<SwapRightOutlined className={iconClassname} />
|
|
122
|
+
<InputNumber<number>
|
|
123
|
+
bordered={false}
|
|
124
|
+
value={maxVal}
|
|
125
|
+
className={oneClassname}
|
|
126
|
+
placeholder={edPlaceholder}
|
|
127
|
+
min={minVal}
|
|
128
|
+
onFocus={() => {
|
|
129
|
+
setFocus(true);
|
|
130
|
+
}}
|
|
131
|
+
onBlur={() => {
|
|
132
|
+
setFocus(false);
|
|
133
|
+
}}
|
|
134
|
+
onChange={(val) => {
|
|
135
|
+
change(max, val);
|
|
136
|
+
}}
|
|
137
|
+
{...edProps}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
</Input.Group>
|
|
141
|
+
);
|
|
130
142
|
};
|
|
131
|
-
const Index=HFormConnect(InputNumberGroup)
|
|
143
|
+
const Index = HFormConnect(InputNumberGroup);
|
|
132
144
|
export default {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
145
|
+
Component: Index,
|
|
146
|
+
placeholder: ({ label }: HItemProps) => {
|
|
147
|
+
return [`请输入${label}最小值`, `请输入${label}最大值`];
|
|
148
|
+
},
|
|
149
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
width: 100%;
|
|
7
7
|
color: rgba(0, 0, 0, 0.25);
|
|
8
|
-
.@{all-input-group}-body{
|
|
8
|
+
.@{all-input-group}-body {
|
|
9
9
|
position: relative;
|
|
10
10
|
display: flex !important;
|
|
11
11
|
flex: 1;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
display: none;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
.@{all-input-group}-border{
|
|
29
|
+
.@{all-input-group}-border {
|
|
30
30
|
position: absolute;
|
|
31
31
|
left: -1px;
|
|
32
32
|
display: none;
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
height: 100%;
|
|
35
35
|
background-color: #40a9ff;
|
|
36
36
|
}
|
|
37
|
-
.@{all-input-group}-icon{
|
|
37
|
+
.@{all-input-group}-icon {
|
|
38
38
|
padding: 0 4px;
|
|
39
39
|
}
|
|
40
|
-
.@{all-input-group}-one{
|
|
40
|
+
.@{all-input-group}-one {
|
|
41
41
|
flex: 1;
|
|
42
42
|
}
|
|
43
|
-
.@{all-input-group}-active{
|
|
43
|
+
.@{all-input-group}-active {
|
|
44
44
|
border-color: #40a9ff;
|
|
45
45
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
46
46
|
}
|
|
@@ -2,7 +2,7 @@ import type { HSelectProps } from "@/components/Select/modal";
|
|
|
2
2
|
import { Checkbox, Space } from "antd";
|
|
3
3
|
import { itemOpProvider } from "../utils";
|
|
4
4
|
import { useClassName } from "../../hooks";
|
|
5
|
-
import React, {useMemo} from "react";
|
|
5
|
+
import React, { useMemo } from "react";
|
|
6
6
|
|
|
7
7
|
interface IProps extends HSelectProps {
|
|
8
8
|
checked?: boolean;
|
|
@@ -23,23 +23,23 @@ const Index: React.FC<IProps> = ({
|
|
|
23
23
|
fieldNames = {},
|
|
24
24
|
children,
|
|
25
25
|
}) => {
|
|
26
|
-
const notDisOption=useMemo(()=>{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},[options]);
|
|
26
|
+
const notDisOption = useMemo(() => {
|
|
27
|
+
return options?.filter((item) => {
|
|
28
|
+
return !item.disabled;
|
|
29
|
+
});
|
|
30
|
+
}, [options]);
|
|
31
31
|
const opLen = notDisOption?.length || 0;
|
|
32
32
|
const checked = (value as any[])?.length >= opLen;
|
|
33
33
|
const classNames = useRootClassName(checked);
|
|
34
34
|
const optionsClassName = useClassName(classNames);
|
|
35
35
|
const allCheckBox = useClassName("hw-all-check-box");
|
|
36
|
-
const allCheck=()=>{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const subItemOps=itemOpProvider(allCheckOption,fieldNames);
|
|
36
|
+
const allCheck = () => {
|
|
37
|
+
const allCheckOption = options?.filter((item) => {
|
|
38
|
+
return !item.disabled;
|
|
39
|
+
});
|
|
40
|
+
const subItemOps = itemOpProvider(allCheckOption, fieldNames);
|
|
41
41
|
onChange?.(allCheckOption, subItemOps);
|
|
42
|
-
}
|
|
42
|
+
};
|
|
43
43
|
const change = () => {
|
|
44
44
|
if (!checked) {
|
|
45
45
|
allCheck();
|
|
@@ -47,7 +47,7 @@ const Index: React.FC<IProps> = ({
|
|
|
47
47
|
}
|
|
48
48
|
onChange?.([], []);
|
|
49
49
|
};
|
|
50
|
-
if (!allSelect || mode !== "multiple" || serviceSearch||opLen===0) {
|
|
50
|
+
if (!allSelect || mode !== "multiple" || serviceSearch || opLen === 0) {
|
|
51
51
|
return <>{children}</>;
|
|
52
52
|
}
|
|
53
53
|
return (
|
|
@@ -3,12 +3,12 @@ import React from "react";
|
|
|
3
3
|
interface ICheckBoxOptionProps {
|
|
4
4
|
label?: React.ReactNode;
|
|
5
5
|
checked: boolean;
|
|
6
|
-
disabled?:boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export default ({ label, checked
|
|
8
|
+
export default ({ label, checked, disabled }: ICheckBoxOptionProps) => {
|
|
9
9
|
return (
|
|
10
10
|
<Space>
|
|
11
|
-
<Checkbox checked={checked} disabled={disabled}/>
|
|
11
|
+
<Checkbox checked={checked} disabled={disabled} />
|
|
12
12
|
{label}
|
|
13
13
|
</Space>
|
|
14
14
|
);
|
|
@@ -9,10 +9,12 @@ export const defaultModeConfig: HSelectProps["modeConfig"] = {
|
|
|
9
9
|
const checkVal = value?.map((itemVal) => {
|
|
10
10
|
return itemVal.value;
|
|
11
11
|
});
|
|
12
|
-
const {label,disabled,value:itemVal}=item;
|
|
12
|
+
const { label, disabled, value: itemVal } = item;
|
|
13
13
|
const newVal = checkVal || [];
|
|
14
14
|
const checked = newVal.indexOf(itemVal) !== -1;
|
|
15
|
-
return
|
|
15
|
+
return (
|
|
16
|
+
<CheckBoxOption disabled={disabled} label={label} checked={checked} />
|
|
17
|
+
);
|
|
16
18
|
},
|
|
17
19
|
},
|
|
18
20
|
};
|
|
@@ -142,11 +142,11 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
142
142
|
onChange(newChangeVal, subItemOps);
|
|
143
143
|
};
|
|
144
144
|
useEffect(() => {
|
|
145
|
-
if (mode === "tags"
|
|
145
|
+
if (mode === "tags") {
|
|
146
146
|
setVal(value);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
if (value===null||value===undefined){
|
|
149
|
+
if (value === null || value === undefined) {
|
|
150
150
|
setVal(undefined);
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
@@ -43,7 +43,7 @@ const Index: React.FC<HSwitchProps> = ({
|
|
|
43
43
|
float: {
|
|
44
44
|
inputValue: (item, initValue) => {
|
|
45
45
|
const { close } = valueSwitchMap;
|
|
46
|
-
const { name: valueName="" } = item;
|
|
46
|
+
const { name: valueName = "" } = item;
|
|
47
47
|
let val = initValue[valueName];
|
|
48
48
|
if (typeof val === "undefined" || val === null) {
|
|
49
49
|
val = close;
|
|
@@ -9,13 +9,14 @@ import { message } from "antd";
|
|
|
9
9
|
interface SubReqParamsModal {
|
|
10
10
|
request?: (
|
|
11
11
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
12
|
-
) => Promise<{ url: string }>;
|
|
12
|
+
) => Promise<{ url: string ,thumbUrl?:string}>;
|
|
13
13
|
file: RcFile;
|
|
14
14
|
}
|
|
15
15
|
interface ResultModal {
|
|
16
16
|
url: string;
|
|
17
17
|
status: UploadFileStatus;
|
|
18
18
|
uid?: string;
|
|
19
|
+
thumbUrl?:string;
|
|
19
20
|
}
|
|
20
21
|
const subReq = async ({
|
|
21
22
|
request,
|
|
@@ -28,9 +29,10 @@ const subReq = async ({
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
try {
|
|
31
|
-
const { url } = await request(file);
|
|
32
|
+
const { url ,thumbUrl} = await request(file);
|
|
32
33
|
return {
|
|
33
34
|
url,
|
|
35
|
+
thumbUrl,
|
|
34
36
|
status: "done",
|
|
35
37
|
};
|
|
36
38
|
} catch (err: any) {
|
|
@@ -42,17 +44,19 @@ const subReq = async ({
|
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
46
|
const fileListProvider = (changeFile: ResultModal, files?: UploadFile[]) => {
|
|
45
|
-
const { status, url, uid } = changeFile;
|
|
47
|
+
const { status, url, uid,thumbUrl } = changeFile;
|
|
46
48
|
if (status === "error") {
|
|
47
49
|
return files?.filter((item) => {
|
|
48
50
|
return item.uid !== uid;
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
return files?.map((item) => {
|
|
54
|
+
const fileDefaultThumbUrl=item.thumbUrl||thumbUrl;
|
|
52
55
|
const resultUrl = url || item.thumbUrl;
|
|
53
56
|
if (item.uid === uid) {
|
|
54
57
|
item.status = status;
|
|
55
58
|
item.response = { url: resultUrl };
|
|
59
|
+
item.thumbUrl=fileDefaultThumbUrl;
|
|
56
60
|
return item;
|
|
57
61
|
}
|
|
58
62
|
return item;
|