zy-react-library 1.0.54 → 1.0.55
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/components/Select/Basic/index.js +50 -32
- package/package.json +1 -1
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
import { Select } from "antd";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { Select } from "antd";
|
|
2
|
+
import { getLabelName } from "../../../utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 基础下拉组件(不建议直接使用此组件,二次继承使用)
|
|
6
|
+
*/
|
|
7
|
+
function BasicSelect(props) {
|
|
8
|
+
const {
|
|
9
|
+
onGetLabel,
|
|
10
|
+
placeholder = "",
|
|
11
|
+
data = [],
|
|
12
|
+
nameKey = "name",
|
|
13
|
+
idKey = "id",
|
|
14
|
+
...restProps
|
|
15
|
+
} = props;
|
|
16
|
+
|
|
17
|
+
// const handleSelect = (event) => {
|
|
18
|
+
// onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
|
|
19
|
+
// };
|
|
20
|
+
//
|
|
21
|
+
// const handleClear = () => {
|
|
22
|
+
// onGetLabel?.(undefined);
|
|
23
|
+
// };
|
|
24
|
+
|
|
25
|
+
const handleChange = (event) => {
|
|
26
|
+
if (event)
|
|
27
|
+
onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
|
|
28
|
+
else
|
|
29
|
+
onGetLabel?.(undefined);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
// <Select placeholder={`请选择${placeholder}`} showSearch allowClear onClear={handleClear} onSelect={handleSelect} {...restProps}>
|
|
34
|
+
<Select placeholder={`请选择${placeholder}`} showSearch allowClear onChange={handleChange} {...restProps}>
|
|
35
|
+
{data.map((item) => {
|
|
36
|
+
const value = item[idKey];
|
|
37
|
+
const label = item[nameKey];
|
|
38
|
+
return (
|
|
39
|
+
<Select.Option key={value} value={value}>
|
|
40
|
+
{label}
|
|
41
|
+
</Select.Option>
|
|
42
|
+
);
|
|
43
|
+
})}
|
|
44
|
+
</Select>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
BasicSelect.displayName = "BasicSelect";
|
|
49
|
+
|
|
50
|
+
export default BasicSelect;
|