zy-react-library 1.1.0 → 1.1.2
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/README.md +5 -1
- package/components/Cascader/Area/index.js +11 -11
- package/components/Cascader/Basic/index.js +23 -30
- package/components/Cascader/Dictionary/index.js +42 -42
- package/components/Cascader/Industry/index.js +12 -11
- package/components/Editor/index.js +43 -63
- package/components/FormBuilder/FormBuilder.js +97 -87
- package/components/FormBuilder/FormItemsRenderer.js +579 -581
- package/components/FormBuilder/index.js +5 -3
- package/components/HeaderBack/index.js +39 -32
- package/components/HiddenInfo/gwj/index.js +507 -439
- package/components/Icon/AddIcon/index.js +6 -6
- package/components/Icon/BackIcon/index.js +6 -6
- package/components/Icon/DeleteIcon/index.js +6 -6
- package/components/Icon/DownloadIcon/index.js +6 -6
- package/components/Icon/EditIcon/index.js +6 -6
- package/components/Icon/ExportIcon/index.js +6 -6
- package/components/Icon/ImportIcon/index.js +6 -6
- package/components/Icon/LocationIcon/index.js +6 -6
- package/components/Icon/PrintIcon/index.js +6 -6
- package/components/Icon/ResetIcon/index.js +6 -6
- package/components/Icon/SearchIcon/index.js +6 -6
- package/components/Icon/VideoIcon/index.js +6 -6
- package/components/Icon/ViewIcon/index.js +6 -6
- package/components/ImportFile/index.js +94 -91
- package/components/LeftTree/Area/index.js +15 -15
- package/components/LeftTree/Basic/index.js +54 -65
- package/components/LeftTree/Department/Gwj/index.js +29 -32
- package/components/LeftTree/Dictionary/index.js +42 -42
- package/components/Map/MapSelector.js +280 -254
- package/components/Map/index.js +90 -77
- package/components/Page/index.d.ts +2 -0
- package/components/Page/index.js +44 -34
- package/components/Pdf/index.js +92 -90
- package/components/PreviewImg/index.js +26 -32
- package/components/PreviewPdf/index.js +78 -86
- package/components/Search/index.js +147 -141
- package/components/Select/Basic/index.js +70 -76
- package/components/Select/Dictionary/index.js +42 -42
- package/components/Select/Personnel/Gwj/index.js +45 -49
- package/components/SelectCreate/index.js +33 -40
- package/components/SelectTree/Area/index.js +11 -17
- package/components/SelectTree/Basic/index.js +105 -102
- package/components/SelectTree/Department/Gwj/index.js +40 -46
- package/components/SelectTree/Dictionary/index.js +42 -42
- package/components/SelectTree/HiddenLevel/Gwj/index.js +33 -35
- package/components/SelectTree/HiddenPart/Gwj/index.js +16 -19
- package/components/SelectTree/Industry/index.js +12 -18
- package/components/Signature/index.js +68 -62
- package/components/Table/index.js +77 -73
- package/components/Table/index.less +7 -1
- package/components/TooltipPreviewImg/index.js +28 -27
- package/components/Upload/index.js +229 -275
- package/components/Video/AliPlayer.js +182 -160
- package/components/Video/index.js +71 -90
- package/css/common.less +4 -0
- package/enum/dictionary/index.js +5 -3
- package/enum/formItemRender/index.js +37 -35
- package/enum/hidden/gwj/index.js +65 -26
- package/enum/uploadFile/gwj/index.js +166 -84
- package/hooks/useDeleteFile/index.js +24 -30
- package/hooks/useDictionary/index.js +28 -30
- package/hooks/useDownloadBlob/index.js +78 -77
- package/hooks/useDownloadFile/index.js +76 -79
- package/hooks/useGetFile/index.js +32 -32
- package/hooks/useGetUrlQuery/index.js +1 -2
- package/hooks/useGetUserInfo/index.js +19 -26
- package/hooks/useIdle/index.js +9 -11
- package/hooks/useImportFile/index.js +30 -28
- package/hooks/useIsExistenceDuplicateSelection/index.js +25 -18
- package/hooks/useTable/index.js +49 -38
- package/hooks/useUploadFile/index.js +142 -147
- package/hooks/useUrlQueryCriteria/index.js +20 -13
- package/package.json +14 -1
- package/regular/index.js +34 -39
- package/utils/index.js +515 -511
|
@@ -1,86 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState } from
|
|
3
|
-
import Pdf from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
return null;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
PreviewPdf.displayName = "PreviewPdf";
|
|
85
|
-
|
|
86
|
-
export default PreviewPdf;
|
|
1
|
+
import { Space, Button } from 'antd';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Pdf from '../Pdf/index.js';
|
|
4
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const PreviewPdf = props => {
|
|
7
|
+
const {
|
|
8
|
+
files = [],
|
|
9
|
+
nameKey = "",
|
|
10
|
+
urlKey = "",
|
|
11
|
+
name = "",
|
|
12
|
+
url = ""
|
|
13
|
+
} = props;
|
|
14
|
+
const [visible, setVisible] = useState(false);
|
|
15
|
+
const [currentSrc, setCurrentSrc] = useState("");
|
|
16
|
+
const [currentName, setCurrentName] = useState("");
|
|
17
|
+
const previewPdf = (src, name) => {
|
|
18
|
+
setVisible(true);
|
|
19
|
+
setCurrentSrc(src);
|
|
20
|
+
setCurrentName(name);
|
|
21
|
+
};
|
|
22
|
+
const onCancel = () => {
|
|
23
|
+
setVisible(false);
|
|
24
|
+
setCurrentSrc("");
|
|
25
|
+
setCurrentName("");
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 单个文件预览模式
|
|
29
|
+
if (files.length === 0 && name && url) {
|
|
30
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
31
|
+
children: [/*#__PURE__*/jsxs(Space, {
|
|
32
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
33
|
+
children: name
|
|
34
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
35
|
+
type: "primary",
|
|
36
|
+
size: "small",
|
|
37
|
+
onClick: () => previewPdf(url, name),
|
|
38
|
+
children: "\u9884\u89C8"
|
|
39
|
+
})]
|
|
40
|
+
}), /*#__PURE__*/jsx(Pdf, {
|
|
41
|
+
visible: visible,
|
|
42
|
+
file: currentSrc,
|
|
43
|
+
name: currentName,
|
|
44
|
+
onCancel: onCancel
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 多文件预览模式
|
|
50
|
+
if (files.length > 0 && !name && !url) {
|
|
51
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
52
|
+
children: [files.map(item => /*#__PURE__*/jsx("div", {
|
|
53
|
+
style: {
|
|
54
|
+
marginTop: 5
|
|
55
|
+
},
|
|
56
|
+
children: /*#__PURE__*/jsxs(Space, {
|
|
57
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
58
|
+
children: item.name || item.fileName || item[nameKey]
|
|
59
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
60
|
+
type: "primary",
|
|
61
|
+
size: "small",
|
|
62
|
+
onClick: () => previewPdf(item.filePath || item[urlKey], item.name || item.fileName || item[nameKey]),
|
|
63
|
+
children: "\u9884\u89C8"
|
|
64
|
+
})]
|
|
65
|
+
})
|
|
66
|
+
}, item.filePath || item[urlKey])), /*#__PURE__*/jsx(Pdf, {
|
|
67
|
+
visible: visible,
|
|
68
|
+
file: currentSrc,
|
|
69
|
+
name: currentName,
|
|
70
|
+
onCancel: onCancel
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
76
|
+
PreviewPdf.displayName = "PreviewPdf";
|
|
77
|
+
|
|
78
|
+
export { PreviewPdf as default };
|
|
@@ -1,141 +1,147 @@
|
|
|
1
|
-
import { DownOutlined, UpOutlined } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import FormItemsRenderer from
|
|
5
|
-
import ResetIcon from
|
|
6
|
-
import SearchIcon from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
options = [],
|
|
15
|
-
values = {},
|
|
16
|
-
onFinish,
|
|
17
|
-
onSubmit,
|
|
18
|
-
onReset,
|
|
19
|
-
searchText = "搜索",
|
|
20
|
-
resetText = "重置",
|
|
21
|
-
showSearchButton = true,
|
|
22
|
-
showResetButton = true,
|
|
23
|
-
extraButtons,
|
|
24
|
-
form,
|
|
25
|
-
...restProps
|
|
26
|
-
} = props;
|
|
27
|
-
|
|
28
|
-
const [
|
|
29
|
-
const [
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
|
2
|
+
import { Form, Row, Col, Button } from 'antd';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import FormItemsRenderer from '../FormBuilder/FormItemsRenderer.js';
|
|
5
|
+
import ResetIcon from '../Icon/ResetIcon/index.js';
|
|
6
|
+
import SearchIcon from '../Icon/SearchIcon/index.js';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
const Search = props => {
|
|
10
|
+
const {
|
|
11
|
+
labelCol = {
|
|
12
|
+
span: 6
|
|
13
|
+
},
|
|
14
|
+
options = [],
|
|
15
|
+
values = {},
|
|
16
|
+
onFinish,
|
|
17
|
+
onSubmit,
|
|
18
|
+
onReset,
|
|
19
|
+
searchText = "搜索",
|
|
20
|
+
resetText = "重置",
|
|
21
|
+
showSearchButton = true,
|
|
22
|
+
showResetButton = true,
|
|
23
|
+
extraButtons,
|
|
24
|
+
form,
|
|
25
|
+
...restProps
|
|
26
|
+
} = props;
|
|
27
|
+
const [collapse, setCollapse] = useState(true);
|
|
28
|
+
const [span, setSpan] = useState(6);
|
|
29
|
+
const [showCollapseButton, setShowCollapseButton] = useState(false);
|
|
30
|
+
const classNameRef = useRef(`search-${Date.now()}`);
|
|
31
|
+
|
|
32
|
+
// 计算是否需要显示展开/收起按钮
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!options || options.length === 0) return;
|
|
35
|
+
const calculateLayout = () => {
|
|
36
|
+
const colEl = document.querySelectorAll(`.${classNameRef.current}>.${window.process.env.app.antd["ant-prefix"]}-col`);
|
|
37
|
+
const colElLength = colEl.length;
|
|
38
|
+
const excludeLast = colElLength - (extraButtons ? 2 : 1);
|
|
39
|
+
const spanMap = {
|
|
40
|
+
0: 24,
|
|
41
|
+
1: 18,
|
|
42
|
+
2: 12,
|
|
43
|
+
3: 6
|
|
44
|
+
};
|
|
45
|
+
setSpan(spanMap[excludeLast % 4] || 6);
|
|
46
|
+
setShowCollapseButton(excludeLast > 3);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// 延迟执行以确保 DOM 已渲染
|
|
50
|
+
setTimeout(calculateLayout, 0);
|
|
51
|
+
}, [options, extraButtons]);
|
|
52
|
+
|
|
53
|
+
// 处理表单提交
|
|
54
|
+
const handleSubmit = () => {
|
|
55
|
+
const values = form.getFieldsValue();
|
|
56
|
+
onFinish?.(values, "submit");
|
|
57
|
+
onSubmit?.(values);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// 处理重置
|
|
61
|
+
const handleReset = () => {
|
|
62
|
+
// form.resetFields();
|
|
63
|
+
// const values = form.getFieldsValue();
|
|
64
|
+
// onFinish?.(values, "reset");
|
|
65
|
+
// onReset?.(values);
|
|
66
|
+
|
|
67
|
+
const currentValues = form.getFieldsValue();
|
|
68
|
+
const resetValues = {};
|
|
69
|
+
Object.keys(currentValues).forEach(key => {
|
|
70
|
+
resetValues[key] = values.hasOwnProperty(key) ? values[key] : undefined;
|
|
71
|
+
});
|
|
72
|
+
form.setFieldsValue(resetValues);
|
|
73
|
+
onFinish?.(values, "reset");
|
|
74
|
+
onReset?.(values);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// 切换展开/收起
|
|
78
|
+
const toggleCollapse = () => {
|
|
79
|
+
setCollapse(!collapse);
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/jsx("div", {
|
|
82
|
+
className: "search-layout card-layout",
|
|
83
|
+
children: /*#__PURE__*/jsx(Form, {
|
|
84
|
+
form: form,
|
|
85
|
+
labelCol: labelCol,
|
|
86
|
+
initialValues: values,
|
|
87
|
+
...restProps,
|
|
88
|
+
children: /*#__PURE__*/jsxs(Row, {
|
|
89
|
+
className: classNameRef.current,
|
|
90
|
+
children: [/*#__PURE__*/jsx(FormItemsRenderer, {
|
|
91
|
+
options: options,
|
|
92
|
+
labelCol: labelCol,
|
|
93
|
+
span: 6,
|
|
94
|
+
collapse: collapse,
|
|
95
|
+
useAutoGenerateRequired: false,
|
|
96
|
+
initialValues: values
|
|
97
|
+
}), /*#__PURE__*/jsx(Col, {
|
|
98
|
+
span: showCollapseButton ? collapse ? 6 : span : span,
|
|
99
|
+
children: /*#__PURE__*/jsxs(Form.Item, {
|
|
100
|
+
label: " ",
|
|
101
|
+
labelCol: {
|
|
102
|
+
span: 2
|
|
103
|
+
},
|
|
104
|
+
colon: false,
|
|
105
|
+
style: {
|
|
106
|
+
textAlign: "right"
|
|
107
|
+
},
|
|
108
|
+
children: [showSearchButton && /*#__PURE__*/jsx(Button, {
|
|
109
|
+
type: "primary",
|
|
110
|
+
icon: /*#__PURE__*/jsx(SearchIcon, {}),
|
|
111
|
+
onClick: handleSubmit,
|
|
112
|
+
children: searchText
|
|
113
|
+
}), showResetButton && /*#__PURE__*/jsx(Button, {
|
|
114
|
+
style: {
|
|
115
|
+
marginLeft: 8
|
|
116
|
+
},
|
|
117
|
+
icon: /*#__PURE__*/jsx(ResetIcon, {}),
|
|
118
|
+
onClick: handleReset,
|
|
119
|
+
children: resetText
|
|
120
|
+
}), showCollapseButton && /*#__PURE__*/jsx(Button, {
|
|
121
|
+
type: "link",
|
|
122
|
+
icon: collapse ? /*#__PURE__*/jsx(DownOutlined, {}) : /*#__PURE__*/jsx(UpOutlined, {}),
|
|
123
|
+
onClick: toggleCollapse,
|
|
124
|
+
style: {
|
|
125
|
+
marginLeft: 8
|
|
126
|
+
},
|
|
127
|
+
children: collapse ? "展开" : "收起"
|
|
128
|
+
})]
|
|
129
|
+
})
|
|
130
|
+
}), extraButtons && /*#__PURE__*/jsx(Col, {
|
|
131
|
+
span: 24,
|
|
132
|
+
children: /*#__PURE__*/jsx(Form.Item, {
|
|
133
|
+
label: " ",
|
|
134
|
+
colon: false,
|
|
135
|
+
labelCol: {
|
|
136
|
+
span: 0
|
|
137
|
+
},
|
|
138
|
+
children: extraButtons
|
|
139
|
+
})
|
|
140
|
+
})]
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
Search.displayName = "Search";
|
|
146
|
+
|
|
147
|
+
export { Search as default };
|
|
@@ -1,76 +1,70 @@
|
|
|
1
|
-
import { Select } from
|
|
2
|
-
import { useEffect } from
|
|
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
|
-
|
|
33
|
-
onGetLabel?.(
|
|
34
|
-
onGetOption?.(
|
|
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
|
-
BasicSelect.displayName = "BasicSelect";
|
|
75
|
-
|
|
76
|
-
export default BasicSelect;
|
|
1
|
+
import { Select } from 'antd';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function BasicSelect(props) {
|
|
6
|
+
const {
|
|
7
|
+
onGetData,
|
|
8
|
+
onChange,
|
|
9
|
+
onGetLabel,
|
|
10
|
+
onGetOption,
|
|
11
|
+
placeholder = "",
|
|
12
|
+
data = [],
|
|
13
|
+
nameKey = "name",
|
|
14
|
+
idKey = "id",
|
|
15
|
+
labelRender,
|
|
16
|
+
...restProps
|
|
17
|
+
} = props;
|
|
18
|
+
const handleChange = (event, option) => {
|
|
19
|
+
if (Array.isArray(event)) {
|
|
20
|
+
if (event.length > 0) {
|
|
21
|
+
const findItems = [];
|
|
22
|
+
const names = [];
|
|
23
|
+
event.forEach(item => {
|
|
24
|
+
const findItem = data.find(dataItem => dataItem[idKey] === item);
|
|
25
|
+
if (findItem) {
|
|
26
|
+
findItems.push(findItem);
|
|
27
|
+
names.push(findItem[nameKey]);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
onGetLabel?.(names);
|
|
31
|
+
onGetOption?.(findItems);
|
|
32
|
+
} else {
|
|
33
|
+
onGetLabel?.([]);
|
|
34
|
+
onGetOption?.([]);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
if (event) {
|
|
38
|
+
const findItem = data.find(item => item[idKey] === event);
|
|
39
|
+
onGetLabel?.(findItem[nameKey]);
|
|
40
|
+
onGetOption?.(findItem);
|
|
41
|
+
} else {
|
|
42
|
+
onGetLabel?.("");
|
|
43
|
+
onGetOption?.({});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
onChange?.(event, option);
|
|
47
|
+
};
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
onGetData?.(data);
|
|
50
|
+
}, [data]);
|
|
51
|
+
return /*#__PURE__*/jsx(Select, {
|
|
52
|
+
placeholder: `请选择${placeholder}`,
|
|
53
|
+
showSearch: true,
|
|
54
|
+
allowClear: true,
|
|
55
|
+
optionFilterProp: "children",
|
|
56
|
+
onChange: handleChange,
|
|
57
|
+
...restProps,
|
|
58
|
+
children: data.map(item => {
|
|
59
|
+
const value = item[idKey];
|
|
60
|
+
const label = labelRender ? labelRender(item) : item[nameKey];
|
|
61
|
+
return /*#__PURE__*/jsx(Select.Option, {
|
|
62
|
+
value: value,
|
|
63
|
+
children: label
|
|
64
|
+
}, value);
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
BasicSelect.displayName = "BasicSelect";
|
|
69
|
+
|
|
70
|
+
export { BasicSelect as default };
|