@kne/super-select-plus 0.1.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/README.md +1156 -0
- package/dist/city-230db4c1.js +35095 -0
- package/dist/city-230db4c1.js.map +1 -0
- package/dist/city-5444842a.js +35092 -0
- package/dist/city-5444842a.js.map +1 -0
- package/dist/function-99219f66.js +15595 -0
- package/dist/function-99219f66.js.map +1 -0
- package/dist/function-9db71e91.js +15596 -0
- package/dist/function-9db71e91.js.map +1 -0
- package/dist/index.css +135 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1033 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +1020 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/industry-2e3bda15.js +757 -0
- package/dist/industry-2e3bda15.js.map +1 -0
- package/dist/industry-8d720d2a.js +756 -0
- package/dist/industry-8d720d2a.js.map +1 -0
- package/dist/locale/en-US.js +18 -0
- package/dist/locale/en-US.js.map +1 -0
- package/dist/locale/en-US.modern.js +18 -0
- package/dist/locale/en-US.modern.js.map +1 -0
- package/dist/locale/zh-CN.js +18 -0
- package/dist/locale/zh-CN.js.map +1 -0
- package/dist/locale/zh-CN.modern.js +18 -0
- package/dist/locale/zh-CN.modern.js.map +1 -0
- package/package.json +112 -0
package/README.md
ADDED
|
@@ -0,0 +1,1156 @@
|
|
|
1
|
+
# super-select-plus
|
|
2
|
+
|
|
3
|
+
### 描述
|
|
4
|
+
|
|
5
|
+
基于 super-select 的 React 业务选择器组件库,提供职能、行业、城市选择器与枚举显示组件,支持国际化与拼音搜索
|
|
6
|
+
|
|
7
|
+
### 安装
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm i --save @kne/super-select-plus
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 概述
|
|
14
|
+
|
|
15
|
+
`@kne/super-select-plus` 是一个基于 `@kne/super-select` 封装的 React
|
|
16
|
+
业务选择器组件库,提供职能、行业、城市等常见业务场景的选择器组件和枚举值显示组件。所有组件均支持国际化、拼音搜索、单选/多选等功能,枚举显示组件使用
|
|
17
|
+
`react-fetch` 统一管理数据加载和缓存。
|
|
18
|
+
|
|
19
|
+
### 主要特性
|
|
20
|
+
|
|
21
|
+
- **丰富的业务选择器**:提供职能选择器、行业选择器、城市选择器三大核心组件
|
|
22
|
+
- **枚举值显示组件**:提供地址、职能、行业等枚举值的统一显示组件
|
|
23
|
+
- **级联选择支持**:职能和行业选择器基于级联选择器实现,支持多级数据选择
|
|
24
|
+
- **智能搜索**:支持中英文搜索、拼音搜索、首字母搜索
|
|
25
|
+
- **国际化支持**:内置中英文切换,可根据语言环境自动切换显示内容
|
|
26
|
+
- **灵活的展示模式**:支持下拉菜单和弹窗两种展示模式
|
|
27
|
+
- **数量限制**:支持设置最大选择数量
|
|
28
|
+
- **单选/多选**:所有组件均支持单选和多选模式
|
|
29
|
+
- **数据缓存**:枚举显示组件内置多层缓存机制,提升性能
|
|
30
|
+
- **自定义渲染**:枚举显示组件支持自定义渲染函数,灵活展示
|
|
31
|
+
|
|
32
|
+
### 组件列表
|
|
33
|
+
|
|
34
|
+
| 组件名称 | 功能描述 |
|
|
35
|
+
|----------------|-------------------|
|
|
36
|
+
| SelectFunction | 职能选择器,支持多级职能数据选择 |
|
|
37
|
+
| SelectIndustry | 行业选择器,支持多级行业数据选择 |
|
|
38
|
+
| SelectAddress | 城市选择器,支持国内外城市搜索选择 |
|
|
39
|
+
| AddressEnum | 地址枚举显示,用于显示城市名称 |
|
|
40
|
+
| FunctionEnum | 职能枚举显示,用于显示职能名称 |
|
|
41
|
+
| IndustryEnum | 行业枚举显示,用于显示行业名称 |
|
|
42
|
+
| EnumDisplay | 通用枚举显示,支持自定义数据源 |
|
|
43
|
+
|
|
44
|
+
### 数据来源
|
|
45
|
+
|
|
46
|
+
组件内置了丰富的业务数据:
|
|
47
|
+
|
|
48
|
+
- **职能数据**:包含完整的职位职能分类,支持三级职能体系
|
|
49
|
+
- **行业数据**:覆盖主要行业分类,支持多级行业结构
|
|
50
|
+
- **城市数据**:包含国内外主要城市,支持按省份、国家分类
|
|
51
|
+
|
|
52
|
+
所有数据支持中英文双语,可通过组件的静态方法获取原始数据进行自定义处理。
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### 示例
|
|
56
|
+
|
|
57
|
+
#### 示例代码
|
|
58
|
+
|
|
59
|
+
- SelectFunction 职能选择器
|
|
60
|
+
- 基于级联选择器的职能选择组件,支持多级职能数据的选择,具备搜索、单选/多选等功能
|
|
61
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],antd(antd)
|
|
62
|
+
|
|
63
|
+
```jsx
|
|
64
|
+
const { SelectFunction } = _SuperSelectPlus;
|
|
65
|
+
const { Flex, Divider, Tag, Switch } = antd;
|
|
66
|
+
const { useState } = React;
|
|
67
|
+
|
|
68
|
+
// 基础多选示例
|
|
69
|
+
const BasicMultiExample = ({ isPopup }) => {
|
|
70
|
+
const [value, setValue] = useState([]);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Flex vertical gap={8}>
|
|
74
|
+
<span>多选职能:</span>
|
|
75
|
+
<SelectFunction
|
|
76
|
+
value={value}
|
|
77
|
+
onChange={setValue}
|
|
78
|
+
isPopup={isPopup}
|
|
79
|
+
placeholder="请选择职能"
|
|
80
|
+
style={{ width: 320 }}
|
|
81
|
+
/>
|
|
82
|
+
{value.length > 0 && (
|
|
83
|
+
<Flex wrap gap={4}>
|
|
84
|
+
{value.map((item) => (
|
|
85
|
+
<Tag key={item.id} color="blue">
|
|
86
|
+
{item.name}
|
|
87
|
+
</Tag>
|
|
88
|
+
))}
|
|
89
|
+
</Flex>
|
|
90
|
+
)}
|
|
91
|
+
</Flex>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// 单选示例
|
|
96
|
+
const SingleSelectExample = ({ isPopup }) => {
|
|
97
|
+
const [value, setValue] = useState(null);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Flex vertical gap={8}>
|
|
101
|
+
<span>单选职能:</span>
|
|
102
|
+
<SelectFunction
|
|
103
|
+
single
|
|
104
|
+
value={value}
|
|
105
|
+
onChange={setValue}
|
|
106
|
+
isPopup={isPopup}
|
|
107
|
+
placeholder="请选择职能"
|
|
108
|
+
style={{ width: 320 }}
|
|
109
|
+
/>
|
|
110
|
+
{value && <Tag color="green">已选:{value.name}</Tag>}
|
|
111
|
+
</Flex>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// 数量限制示例
|
|
116
|
+
const MaxLimitExample = ({ isPopup }) => {
|
|
117
|
+
const [value, setValue] = useState([]);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Flex vertical gap={8}>
|
|
121
|
+
<span>最多选择 3 个职能:</span>
|
|
122
|
+
<SelectFunction
|
|
123
|
+
value={value}
|
|
124
|
+
onChange={setValue}
|
|
125
|
+
isPopup={isPopup}
|
|
126
|
+
maxLength={3}
|
|
127
|
+
placeholder="请选择职能(最多3项)"
|
|
128
|
+
style={{ width: 320 }}
|
|
129
|
+
/>
|
|
130
|
+
<Tag color={value.length >= 3 ? 'red' : 'blue'}>
|
|
131
|
+
已选择 {value.length}/3 项
|
|
132
|
+
</Tag>
|
|
133
|
+
</Flex>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// 弹窗模式示例
|
|
138
|
+
const PopupModeExample = () => {
|
|
139
|
+
const [value, setValue] = useState([]);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Flex vertical gap={8}>
|
|
143
|
+
<span>弹窗模式:</span>
|
|
144
|
+
<SelectFunction
|
|
145
|
+
value={value}
|
|
146
|
+
onChange={setValue}
|
|
147
|
+
isPopup={false}
|
|
148
|
+
placeholder="点击打开弹窗选择"
|
|
149
|
+
style={{ width: 320 }}
|
|
150
|
+
/>
|
|
151
|
+
{value.length > 0 && (
|
|
152
|
+
<div>已选:{value.map((item) => item.name).join('、')}</div>
|
|
153
|
+
)}
|
|
154
|
+
</Flex>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const BaseExample = () => {
|
|
159
|
+
const [isPopup, setIsPopup] = useState(true);
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<Flex vertical gap={24}>
|
|
163
|
+
<Flex align="center" gap={12}>
|
|
164
|
+
<span>展示模式:</span>
|
|
165
|
+
<Switch
|
|
166
|
+
checked={isPopup}
|
|
167
|
+
onChange={setIsPopup}
|
|
168
|
+
checkedChildren="下拉"
|
|
169
|
+
unCheckedChildren="弹窗"
|
|
170
|
+
/>
|
|
171
|
+
<span style={{ color: '#666', fontSize: 12 }}>
|
|
172
|
+
{isPopup ? '点击输入框展开下拉菜单' : '点击输入框打开弹窗'}
|
|
173
|
+
</span>
|
|
174
|
+
</Flex>
|
|
175
|
+
<Divider />
|
|
176
|
+
<BasicMultiExample isPopup={isPopup} />
|
|
177
|
+
<Divider />
|
|
178
|
+
<SingleSelectExample isPopup={isPopup} />
|
|
179
|
+
<Divider />
|
|
180
|
+
<MaxLimitExample isPopup={isPopup} />
|
|
181
|
+
<Divider />
|
|
182
|
+
<PopupModeExample />
|
|
183
|
+
</Flex>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
render(<BaseExample />);
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- SelectIndustry 行业选择器
|
|
192
|
+
- 基于级联选择器的行业选择组件,支持多级行业数据的选择,具备搜索、单选/多选等功能
|
|
193
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],antd(antd)
|
|
194
|
+
|
|
195
|
+
```jsx
|
|
196
|
+
const { SelectIndustry } = _SuperSelectPlus;
|
|
197
|
+
const { Flex, Divider, Tag, Switch } = antd;
|
|
198
|
+
const { useState } = React;
|
|
199
|
+
|
|
200
|
+
// 基础多选示例
|
|
201
|
+
const BasicMultiExample = ({ isPopup }) => {
|
|
202
|
+
const [value, setValue] = useState([]);
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<Flex vertical gap={8}>
|
|
206
|
+
<span>多选行业:</span>
|
|
207
|
+
<SelectIndustry
|
|
208
|
+
value={value}
|
|
209
|
+
onChange={setValue}
|
|
210
|
+
isPopup={isPopup}
|
|
211
|
+
placeholder="请选择行业"
|
|
212
|
+
style={{ width: 320 }}
|
|
213
|
+
/>
|
|
214
|
+
{value.length > 0 && (
|
|
215
|
+
<Flex wrap gap={4}>
|
|
216
|
+
{value.map((item) => (
|
|
217
|
+
<Tag key={item.id} color="blue">
|
|
218
|
+
{item.name}
|
|
219
|
+
</Tag>
|
|
220
|
+
))}
|
|
221
|
+
</Flex>
|
|
222
|
+
)}
|
|
223
|
+
</Flex>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// 单选示例
|
|
228
|
+
const SingleSelectExample = ({ isPopup }) => {
|
|
229
|
+
const [value, setValue] = useState(null);
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<Flex vertical gap={8}>
|
|
233
|
+
<span>单选行业:</span>
|
|
234
|
+
<SelectIndustry
|
|
235
|
+
single
|
|
236
|
+
value={value}
|
|
237
|
+
onChange={setValue}
|
|
238
|
+
isPopup={isPopup}
|
|
239
|
+
placeholder="请选择行业"
|
|
240
|
+
style={{ width: 320 }}
|
|
241
|
+
/>
|
|
242
|
+
{value && <Tag color="green">已选:{value.name}</Tag>}
|
|
243
|
+
</Flex>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// 数量限制示例
|
|
248
|
+
const MaxLimitExample = ({ isPopup }) => {
|
|
249
|
+
const [value, setValue] = useState([]);
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<Flex vertical gap={8}>
|
|
253
|
+
<span>最多选择 3 个行业:</span>
|
|
254
|
+
<SelectIndustry
|
|
255
|
+
value={value}
|
|
256
|
+
onChange={setValue}
|
|
257
|
+
isPopup={isPopup}
|
|
258
|
+
maxLength={3}
|
|
259
|
+
placeholder="请选择行业(最多3项)"
|
|
260
|
+
style={{ width: 320 }}
|
|
261
|
+
/>
|
|
262
|
+
<Tag color={value.length >= 3 ? 'red' : 'blue'}>
|
|
263
|
+
已选择 {value.length}/3 项
|
|
264
|
+
</Tag>
|
|
265
|
+
</Flex>
|
|
266
|
+
);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const BaseExample = () => {
|
|
270
|
+
const [isPopup, setIsPopup] = useState(true);
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<Flex vertical gap={24}>
|
|
274
|
+
<Flex align="center" gap={12}>
|
|
275
|
+
<span>展示模式:</span>
|
|
276
|
+
<Switch
|
|
277
|
+
checked={isPopup}
|
|
278
|
+
onChange={setIsPopup}
|
|
279
|
+
checkedChildren="下拉"
|
|
280
|
+
unCheckedChildren="弹窗"
|
|
281
|
+
/>
|
|
282
|
+
<span style={{ color: '#666', fontSize: 12 }}>
|
|
283
|
+
{isPopup ? '点击输入框展开下拉菜单' : '点击输入框打开弹窗'}
|
|
284
|
+
</span>
|
|
285
|
+
</Flex>
|
|
286
|
+
<Divider />
|
|
287
|
+
<BasicMultiExample isPopup={isPopup} />
|
|
288
|
+
<Divider />
|
|
289
|
+
<SingleSelectExample isPopup={isPopup} />
|
|
290
|
+
<Divider />
|
|
291
|
+
<MaxLimitExample isPopup={isPopup} />
|
|
292
|
+
</Flex>
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
render(<BaseExample />);
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
- SelectAddress 城市选择器
|
|
301
|
+
- 城市地址选择组件,支持国内外城市搜索选择,具备拼音搜索、首字母搜索等功能
|
|
302
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],(@kne/current-lib_super-select-plus/dist/index.css),antd(antd)
|
|
303
|
+
|
|
304
|
+
```jsx
|
|
305
|
+
const { SelectAddress } = _SuperSelectPlus;
|
|
306
|
+
const { Flex, Divider, Tag, Switch } = antd;
|
|
307
|
+
const { useState } = React;
|
|
308
|
+
|
|
309
|
+
// 基础多选示例
|
|
310
|
+
const BasicMultiExample = ({ isPopup }) => {
|
|
311
|
+
const [value, setValue] = useState([]);
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<Flex vertical gap={8}>
|
|
315
|
+
<span>多选城市:</span>
|
|
316
|
+
<SelectAddress
|
|
317
|
+
value={value}
|
|
318
|
+
onChange={setValue}
|
|
319
|
+
isPopup={isPopup}
|
|
320
|
+
placeholder="请选择城市"
|
|
321
|
+
style={{ width: 320 }}
|
|
322
|
+
/>
|
|
323
|
+
{value.length > 0 && (
|
|
324
|
+
<Flex wrap gap={4}>
|
|
325
|
+
{value.map((item) => (
|
|
326
|
+
<Tag key={item.code} color="blue">
|
|
327
|
+
{item.name}
|
|
328
|
+
</Tag>
|
|
329
|
+
))}
|
|
330
|
+
</Flex>
|
|
331
|
+
)}
|
|
332
|
+
</Flex>
|
|
333
|
+
);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// 单选示例
|
|
337
|
+
const SingleSelectExample = ({ isPopup }) => {
|
|
338
|
+
const [value, setValue] = useState(null);
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<Flex vertical gap={8}>
|
|
342
|
+
<span>单选城市:</span>
|
|
343
|
+
<SelectAddress
|
|
344
|
+
single
|
|
345
|
+
value={value}
|
|
346
|
+
onChange={setValue}
|
|
347
|
+
isPopup={isPopup}
|
|
348
|
+
placeholder="请选择城市"
|
|
349
|
+
style={{ width: 320 }}
|
|
350
|
+
/>
|
|
351
|
+
{value && <Tag color="green">已选:{value.name}</Tag>}
|
|
352
|
+
</Flex>
|
|
353
|
+
);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// 数量限制示例
|
|
357
|
+
const MaxLimitExample = ({ isPopup }) => {
|
|
358
|
+
const [value, setValue] = useState([]);
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<Flex vertical gap={8}>
|
|
362
|
+
<span>最多选择 5 个城市:</span>
|
|
363
|
+
<SelectAddress
|
|
364
|
+
value={value}
|
|
365
|
+
onChange={setValue}
|
|
366
|
+
isPopup={isPopup}
|
|
367
|
+
maxLength={5}
|
|
368
|
+
placeholder="请选择城市(最多5项)"
|
|
369
|
+
style={{ width: 320 }}
|
|
370
|
+
/>
|
|
371
|
+
<Tag color={value.length >= 5 ? 'red' : 'blue'}>
|
|
372
|
+
已选择 {value.length}/5 项
|
|
373
|
+
</Tag>
|
|
374
|
+
</Flex>
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const BaseExample = () => {
|
|
379
|
+
const [isPopup, setIsPopup] = useState(true);
|
|
380
|
+
|
|
381
|
+
return (
|
|
382
|
+
<Flex vertical gap={24}>
|
|
383
|
+
<Flex align="center" gap={12}>
|
|
384
|
+
<span>展示模式:</span>
|
|
385
|
+
<Switch
|
|
386
|
+
checked={isPopup}
|
|
387
|
+
onChange={setIsPopup}
|
|
388
|
+
checkedChildren="下拉"
|
|
389
|
+
unCheckedChildren="弹窗"
|
|
390
|
+
/>
|
|
391
|
+
<span style={{ color: '#666', fontSize: 12 }}>
|
|
392
|
+
{isPopup ? '点击输入框展开下拉菜单' : '点击输入框打开弹窗'}
|
|
393
|
+
</span>
|
|
394
|
+
</Flex>
|
|
395
|
+
<Divider />
|
|
396
|
+
<BasicMultiExample isPopup={isPopup} />
|
|
397
|
+
<Divider />
|
|
398
|
+
<SingleSelectExample isPopup={isPopup} />
|
|
399
|
+
<Divider />
|
|
400
|
+
<MaxLimitExample isPopup={isPopup} />
|
|
401
|
+
</Flex>
|
|
402
|
+
);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
render(<BaseExample />);
|
|
406
|
+
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
- AddressEnum 地址枚举显示
|
|
410
|
+
- 用于显示城市名称的枚举组件,支持国际化、显示父级、自定义渲染等功能
|
|
411
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],antd(antd),remoteLoader(@kne/remote-loader)
|
|
412
|
+
|
|
413
|
+
```jsx
|
|
414
|
+
const { AddressEnum } = _SuperSelectPlus;
|
|
415
|
+
const { createWithRemoteLoader } = remoteLoader;
|
|
416
|
+
const { Flex } = antd;
|
|
417
|
+
|
|
418
|
+
const BaseExample = createWithRemoteLoader({
|
|
419
|
+
modules: ['components-core:Global@PureGlobal', 'components-core:InfoPage']
|
|
420
|
+
})(({ remoteModules }) => {
|
|
421
|
+
const [PureGlobal, InfoPage] = remoteModules;
|
|
422
|
+
|
|
423
|
+
return (
|
|
424
|
+
<PureGlobal preset={{
|
|
425
|
+
ajax: async api => {
|
|
426
|
+
return { data: { code: 0, data: await api.loader() } };
|
|
427
|
+
},
|
|
428
|
+
apis: {
|
|
429
|
+
cityData: {
|
|
430
|
+
loader: async () => {
|
|
431
|
+
const module = await import('@kne/super-select-plus/src/SelectAddress/city.json');
|
|
432
|
+
return module.default || module;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}}>
|
|
437
|
+
<InfoPage>
|
|
438
|
+
<InfoPage.Part title="基本用法">
|
|
439
|
+
<Flex vertical gap={12}>
|
|
440
|
+
<p>北京(编码:010):<AddressEnum name="010" /></p>
|
|
441
|
+
<p>上海(编码:020):<AddressEnum name="020" /></p>
|
|
442
|
+
<p>广州(编码:050020):<AddressEnum name="050020" /></p>
|
|
443
|
+
<p>深圳(编码:050090):<AddressEnum name="050090" /></p>
|
|
444
|
+
</Flex>
|
|
445
|
+
</InfoPage.Part>
|
|
446
|
+
|
|
447
|
+
<InfoPage.Part title="自定义渲染">
|
|
448
|
+
<Flex vertical gap={12}>
|
|
449
|
+
<p>带样式渲染:</p>
|
|
450
|
+
<AddressEnum name="010">
|
|
451
|
+
{({ city, parent }, { getLabelForLocal, locale }) => city && (
|
|
452
|
+
<span style={{ padding: '4px 8px', background: '#f0f0f0', borderRadius: '4px' }}>
|
|
453
|
+
{getLabelForLocal(city, locale)}
|
|
454
|
+
{parent && <span style={{ fontSize: '12px', color: '#666', marginLeft: '8px' }}>({getLabelForLocal(parent, locale)})</span>}
|
|
455
|
+
</span>
|
|
456
|
+
)}
|
|
457
|
+
</AddressEnum>
|
|
458
|
+
|
|
459
|
+
<p>带图标显示:</p>
|
|
460
|
+
<AddressEnum name="020">
|
|
461
|
+
{({ city }, { getLabelForLocal, locale }) => city && (
|
|
462
|
+
<span>📍 {getLabelForLocal(city, locale)}</span>
|
|
463
|
+
)}
|
|
464
|
+
</AddressEnum>
|
|
465
|
+
</Flex>
|
|
466
|
+
</InfoPage.Part>
|
|
467
|
+
|
|
468
|
+
<InfoPage.Part title="实际业务场景">
|
|
469
|
+
<div style={{ lineHeight: '32px' }}>
|
|
470
|
+
<div><strong>姓名:</strong>张三</div>
|
|
471
|
+
<div><strong>所在城市:</strong><AddressEnum name="010" /></div>
|
|
472
|
+
<div><strong>期望工作城市:</strong><AddressEnum name="020" /></div>
|
|
473
|
+
</div>
|
|
474
|
+
</InfoPage.Part>
|
|
475
|
+
|
|
476
|
+
<InfoPage.Part title="错误处理">
|
|
477
|
+
<p>不存在的城市编码 999999:<AddressEnum name="999999" /></p>
|
|
478
|
+
</InfoPage.Part>
|
|
479
|
+
</InfoPage>
|
|
480
|
+
</PureGlobal>
|
|
481
|
+
);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
render(<BaseExample />);
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
- FunctionEnum 职能枚举显示
|
|
489
|
+
- 用于显示职能名称的枚举组件,支持国际化、自定义渲染等功能
|
|
490
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],antd(antd),remoteLoader(@kne/remote-loader)
|
|
491
|
+
|
|
492
|
+
```jsx
|
|
493
|
+
const { FunctionEnum } = _SuperSelectPlus;
|
|
494
|
+
const { createWithRemoteLoader } = remoteLoader;
|
|
495
|
+
const { Flex } = antd;
|
|
496
|
+
|
|
497
|
+
const BaseExample = createWithRemoteLoader({
|
|
498
|
+
modules: ['components-core:Global@PureGlobal', 'components-core:InfoPage']
|
|
499
|
+
})(({ remoteModules }) => {
|
|
500
|
+
const [PureGlobal, InfoPage] = remoteModules;
|
|
501
|
+
|
|
502
|
+
return (
|
|
503
|
+
<PureGlobal preset={{
|
|
504
|
+
ajax: async api => {
|
|
505
|
+
return { data: { code: 0, data: await api.loader() } };
|
|
506
|
+
},
|
|
507
|
+
apis: {
|
|
508
|
+
functionData: {
|
|
509
|
+
loader: async () => {
|
|
510
|
+
const module = await import('@kne/super-select-plus/src/SelectFunction/function.json');
|
|
511
|
+
return module.default || module;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}}>
|
|
516
|
+
<InfoPage>
|
|
517
|
+
<InfoPage.Part title="基本用法">
|
|
518
|
+
<Flex vertical gap={12}>
|
|
519
|
+
<p>CEO(编码:001001001):<FunctionEnum name="001001001" /></p>
|
|
520
|
+
<p>副总裁(编码:001001002):<FunctionEnum name="001001002" /></p>
|
|
521
|
+
<p>COO(编码:001001003):<FunctionEnum name="001001003" /></p>
|
|
522
|
+
</Flex>
|
|
523
|
+
</InfoPage.Part>
|
|
524
|
+
|
|
525
|
+
<InfoPage.Part title="自定义渲染">
|
|
526
|
+
<Flex vertical gap={12}>
|
|
527
|
+
<p>带样式渲染:</p>
|
|
528
|
+
<FunctionEnum name="001001001">
|
|
529
|
+
{(item, { locale }) => item && (
|
|
530
|
+
<span style={{ padding: '4px 8px', background: '#e6f7ff', borderRadius: '4px' }}>
|
|
531
|
+
{item.label}
|
|
532
|
+
{item.enName && <span style={{ marginLeft: '8px', color: '#666' }}>({item.enName})</span>}
|
|
533
|
+
</span>
|
|
534
|
+
)}
|
|
535
|
+
</FunctionEnum>
|
|
536
|
+
|
|
537
|
+
<p>带层级显示:</p>
|
|
538
|
+
<FunctionEnum name="001001002">
|
|
539
|
+
{(item, { mapping }) => {
|
|
540
|
+
if (!item) return null;
|
|
541
|
+
const parent = item.parentId ? mapping.get(item.parentId) : null;
|
|
542
|
+
return (
|
|
543
|
+
<div>
|
|
544
|
+
{parent && <span style={{ fontSize: '12px', color: '#999' }}>{parent.label} > </span>}
|
|
545
|
+
<span style={{ color: '#1890ff' }}>{item.label}</span>
|
|
546
|
+
</div>
|
|
547
|
+
);
|
|
548
|
+
}}
|
|
549
|
+
</FunctionEnum>
|
|
550
|
+
</Flex>
|
|
551
|
+
</InfoPage.Part>
|
|
552
|
+
|
|
553
|
+
<InfoPage.Part title="实际业务场景">
|
|
554
|
+
<div style={{ lineHeight: '32px' }}>
|
|
555
|
+
<div><strong>姓名:</strong>李四</div>
|
|
556
|
+
<div><strong>当前职能:</strong><FunctionEnum name="001001001" /></div>
|
|
557
|
+
<div><strong>期望职能:</strong><FunctionEnum name="001001002" /></div>
|
|
558
|
+
</div>
|
|
559
|
+
</InfoPage.Part>
|
|
560
|
+
|
|
561
|
+
<InfoPage.Part title="国际化支持">
|
|
562
|
+
<FunctionEnum name="001001003">
|
|
563
|
+
{(item, { locale }) => item && (
|
|
564
|
+
<div>
|
|
565
|
+
<div>当前语言:{locale}</div>
|
|
566
|
+
<div>显示名称:{item.label}</div>
|
|
567
|
+
{item.chName && <div>中文名:{item.chName}</div>}
|
|
568
|
+
{item.enName && <div>英文名:{item.enName}</div>}
|
|
569
|
+
</div>
|
|
570
|
+
)}
|
|
571
|
+
</FunctionEnum>
|
|
572
|
+
</InfoPage.Part>
|
|
573
|
+
</InfoPage>
|
|
574
|
+
</PureGlobal>
|
|
575
|
+
);
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
render(<BaseExample />);
|
|
579
|
+
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
- IndustryEnum 行业枚举显示
|
|
583
|
+
- 用于显示行业名称的枚举组件,支持国际化、自定义渲染等功能
|
|
584
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],antd(antd),remoteLoader(@kne/remote-loader)
|
|
585
|
+
|
|
586
|
+
```jsx
|
|
587
|
+
const { IndustryEnum } = _SuperSelectPlus;
|
|
588
|
+
const { createWithRemoteLoader } = remoteLoader;
|
|
589
|
+
const { Flex } = antd;
|
|
590
|
+
|
|
591
|
+
const BaseExample = createWithRemoteLoader({
|
|
592
|
+
modules: ['components-core:Global@PureGlobal', 'components-core:InfoPage']
|
|
593
|
+
})(({ remoteModules }) => {
|
|
594
|
+
const [PureGlobal, InfoPage] = remoteModules;
|
|
595
|
+
|
|
596
|
+
return (
|
|
597
|
+
<PureGlobal preset={{
|
|
598
|
+
ajax: async api => {
|
|
599
|
+
return { data: { code: 0, data: await api.loader() } };
|
|
600
|
+
},
|
|
601
|
+
apis: {
|
|
602
|
+
industryData: {
|
|
603
|
+
loader: async () => {
|
|
604
|
+
const module = await import('@kne/super-select-plus/src/SelectIndustry/industry.json');
|
|
605
|
+
return module.default || module;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}}>
|
|
610
|
+
<InfoPage>
|
|
611
|
+
<InfoPage.Part title="基本用法">
|
|
612
|
+
<Flex vertical gap={12}>
|
|
613
|
+
<p>互联网/电子通信/软件(编码:001):<IndustryEnum name="001" /></p>
|
|
614
|
+
<p>房地产/建筑/物业(编码:003):<IndustryEnum name="003" /></p>
|
|
615
|
+
<p>金融(编码:004):<IndustryEnum name="004" /></p>
|
|
616
|
+
</Flex>
|
|
617
|
+
</InfoPage.Part>
|
|
618
|
+
|
|
619
|
+
<InfoPage.Part title="自定义渲染">
|
|
620
|
+
<Flex vertical gap={12}>
|
|
621
|
+
<p>带样式渲染:</p>
|
|
622
|
+
<IndustryEnum name="001">
|
|
623
|
+
{(item, { locale }) => item && (
|
|
624
|
+
<span style={{ padding: '4px 8px', background: '#f6ffed', borderRadius: '4px' }}>
|
|
625
|
+
{item.label}
|
|
626
|
+
{item.enName && <span style={{ marginLeft: '8px', color: '#666' }}>({item.enName})</span>}
|
|
627
|
+
</span>
|
|
628
|
+
)}
|
|
629
|
+
</IndustryEnum>
|
|
630
|
+
</Flex>
|
|
631
|
+
</InfoPage.Part>
|
|
632
|
+
|
|
633
|
+
<InfoPage.Part title="实际业务场景">
|
|
634
|
+
<div style={{ lineHeight: '32px' }}>
|
|
635
|
+
<div><strong>企业名称:</strong>某某科技有限公司</div>
|
|
636
|
+
<div><strong>所属行业:</strong><IndustryEnum name="001" /></div>
|
|
637
|
+
<div><strong>期望行业:</strong><IndustryEnum name="004" /></div>
|
|
638
|
+
</div>
|
|
639
|
+
</InfoPage.Part>
|
|
640
|
+
|
|
641
|
+
<InfoPage.Part title="行业标签展示">
|
|
642
|
+
<Flex gap={8}>
|
|
643
|
+
<IndustryEnum name="001">
|
|
644
|
+
{(item) => item && <span style={{ padding: '4px 8px', background: '#e6f7ff', borderRadius: '4px' }}>{item.label}</span>}
|
|
645
|
+
</IndustryEnum>
|
|
646
|
+
<IndustryEnum name="003">
|
|
647
|
+
{(item) => item && <span style={{ padding: '4px 8px', background: '#f6ffed', borderRadius: '4px' }}>{item.label}</span>}
|
|
648
|
+
</IndustryEnum>
|
|
649
|
+
<IndustryEnum name="004">
|
|
650
|
+
{(item) => item && <span style={{ padding: '4px 8px', background: '#fff7e6', borderRadius: '4px' }}>{item.label}</span>}
|
|
651
|
+
</IndustryEnum>
|
|
652
|
+
</Flex>
|
|
653
|
+
</InfoPage.Part>
|
|
654
|
+
</InfoPage>
|
|
655
|
+
</PureGlobal>
|
|
656
|
+
);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
render(<BaseExample />);
|
|
660
|
+
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
- EnumDisplay 通用枚举显示
|
|
664
|
+
- 通用枚举显示组件,支持自定义数据源、国际化、缓存等功能
|
|
665
|
+
- _SuperSelectPlus(@kne/current-lib_super-select-plus)[import * as _SuperSelectPlus from "@kne/super-select-plus"],antd(antd),remoteLoader(@kne/remote-loader)
|
|
666
|
+
|
|
667
|
+
```jsx
|
|
668
|
+
const { EnumDisplay } = _SuperSelectPlus;
|
|
669
|
+
const { createWithRemoteLoader } = remoteLoader;
|
|
670
|
+
const { Flex } = antd;
|
|
671
|
+
|
|
672
|
+
const BaseExample = createWithRemoteLoader({
|
|
673
|
+
modules: ['components-core:Global@PureGlobal', 'components-core:InfoPage']
|
|
674
|
+
})(({ remoteModules }) => {
|
|
675
|
+
const [PureGlobal, InfoPage] = remoteModules;
|
|
676
|
+
|
|
677
|
+
// 自定义枚举数据示例
|
|
678
|
+
const customEnumData = [
|
|
679
|
+
{ code: '1', name: '本科', enName: 'Bachelor' },
|
|
680
|
+
{ code: '2', name: '硕士', enName: 'Master' },
|
|
681
|
+
{ code: '3', name: '博士', enName: 'Doctor' }
|
|
682
|
+
];
|
|
683
|
+
|
|
684
|
+
// 学历枚举配置
|
|
685
|
+
const educationEnumApi = {
|
|
686
|
+
cache: 'EDUCATION_DATA',
|
|
687
|
+
isLocal: true,
|
|
688
|
+
loader: async () => customEnumData
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
return (
|
|
692
|
+
<PureGlobal preset={{
|
|
693
|
+
ajax: async api => {
|
|
694
|
+
return { data: { code: 0, data: await api.loader() } };
|
|
695
|
+
}
|
|
696
|
+
}}>
|
|
697
|
+
<InfoPage>
|
|
698
|
+
<InfoPage.Part title="基本用法">
|
|
699
|
+
<Flex vertical gap={12}>
|
|
700
|
+
<p>学历 - 本科(编码:1):<EnumDisplay name="1" type="education" {...educationEnumApi} /></p>
|
|
701
|
+
<p>学历 - 硕士(编码:2):<EnumDisplay name="2" type="education" {...educationEnumApi} /></p>
|
|
702
|
+
<p>学历 - 博士(编码:3):<EnumDisplay name="3" type="education" {...educationEnumApi} /></p>
|
|
703
|
+
</Flex>
|
|
704
|
+
</InfoPage.Part>
|
|
705
|
+
|
|
706
|
+
<InfoPage.Part title="自定义 getLabel 函数">
|
|
707
|
+
<EnumDisplay
|
|
708
|
+
name="1"
|
|
709
|
+
type="education"
|
|
710
|
+
{...educationEnumApi}
|
|
711
|
+
getLabel={(item, locale) => locale === 'en-US' ? (item.enName || item.name) : item.name}
|
|
712
|
+
>
|
|
713
|
+
{(item, { locale }) => item && (
|
|
714
|
+
<div>
|
|
715
|
+
<div>当前语言:{locale}</div>
|
|
716
|
+
<div>显示名称:{item.label}</div>
|
|
717
|
+
</div>
|
|
718
|
+
)}
|
|
719
|
+
</EnumDisplay>
|
|
720
|
+
</InfoPage.Part>
|
|
721
|
+
|
|
722
|
+
<InfoPage.Part title="自定义渲染">
|
|
723
|
+
<EnumDisplay name="2" type="education" {...educationEnumApi}>
|
|
724
|
+
{(item) => item && (
|
|
725
|
+
<span style={{ padding: '4px 8px', background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', borderRadius: '4px', color: '#fff' }}>
|
|
726
|
+
{item.name} {item.enName && `(${item.enName})`}
|
|
727
|
+
</span>
|
|
728
|
+
)}
|
|
729
|
+
</EnumDisplay>
|
|
730
|
+
</InfoPage.Part>
|
|
731
|
+
|
|
732
|
+
<InfoPage.Part title="实际业务场景">
|
|
733
|
+
<div style={{ lineHeight: '32px' }}>
|
|
734
|
+
<div><strong>姓名:</strong>赵六</div>
|
|
735
|
+
<div><strong>最高学历:</strong><EnumDisplay name="3" type="education" {...educationEnumApi} /></div>
|
|
736
|
+
<div><strong>第二学历:</strong><EnumDisplay name="2" type="education" {...educationEnumApi} /></div>
|
|
737
|
+
</div>
|
|
738
|
+
</InfoPage.Part>
|
|
739
|
+
|
|
740
|
+
<InfoPage.Part title="错误处理">
|
|
741
|
+
<EnumDisplay name="999" type="education" {...educationEnumApi}>
|
|
742
|
+
{(item) => <span>{item ? item.label : '未知学历'}</span>}
|
|
743
|
+
</EnumDisplay>
|
|
744
|
+
</InfoPage.Part>
|
|
745
|
+
</InfoPage>
|
|
746
|
+
</PureGlobal>
|
|
747
|
+
);
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
render(<BaseExample />);
|
|
751
|
+
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
### API
|
|
755
|
+
|
|
756
|
+
### SelectFunction 职能选择器
|
|
757
|
+
|
|
758
|
+
基于级联选择器的职能选择组件,支持多级职能数据的搜索和选择,适用于招聘、HR系统等业务场景。
|
|
759
|
+
|
|
760
|
+
#### 属性
|
|
761
|
+
|
|
762
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
763
|
+
|------|------|-------|------|
|
|
764
|
+
| value | array \| object | [] | 当前选中的值,单选时为对象,多选时为数组 |
|
|
765
|
+
| onChange | function | - | 选中值变化时的回调函数 |
|
|
766
|
+
| single | boolean | false | 是否单选模式 |
|
|
767
|
+
| placeholder | string | '请选择职能' | 输入框占位符 |
|
|
768
|
+
| isPopup | boolean | true | 是否下拉模式,false 为弹窗模式 |
|
|
769
|
+
| overlayWidth | string \| number | '320px' | 选择器宽度 |
|
|
770
|
+
| onSearch | function | - | 自定义搜索函数,参数为 (searchText, { mapping }) |
|
|
771
|
+
| maxLength | number | - | 多选时最多可选数量 |
|
|
772
|
+
| disabled | boolean | false | 是否禁用 |
|
|
773
|
+
| style | object | - | 自定义样式 |
|
|
774
|
+
| className | string | - | 自定义类名 |
|
|
775
|
+
|
|
776
|
+
#### 静态方法
|
|
777
|
+
|
|
778
|
+
| 方法 | 说明 |
|
|
779
|
+
|------|------|
|
|
780
|
+
| SelectFunction.defaultData() | 获取默认职能数据,返回 Promise |
|
|
781
|
+
| SelectFunction.defaultProps | 组件默认属性配置 |
|
|
782
|
+
|
|
783
|
+
#### 数据结构
|
|
784
|
+
|
|
785
|
+
组件内部使用扁平化的职能数据结构,通过 `code` 和 `parentCode` 建立层级关系:
|
|
786
|
+
|
|
787
|
+
```javascript
|
|
788
|
+
{
|
|
789
|
+
code: '001001001', // 职能编码
|
|
790
|
+
parentCode: '001001', // 父级编码
|
|
791
|
+
chName: '首席执行官CEO', // 中文名称
|
|
792
|
+
enName: 'CEO', // 英文名称
|
|
793
|
+
pinyin: 'shouzhixingguan', // 拼音
|
|
794
|
+
spelling: 'szxg' // 首字母缩写
|
|
795
|
+
}
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
---
|
|
799
|
+
|
|
800
|
+
### SelectIndustry 行业选择器
|
|
801
|
+
|
|
802
|
+
基于级联选择器的行业选择组件,支持多级行业数据的搜索和选择,适用于招聘、企业信息管理等业务场景。
|
|
803
|
+
|
|
804
|
+
#### 属性
|
|
805
|
+
|
|
806
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
807
|
+
|------|------|-------|------|
|
|
808
|
+
| value | array \| object | [] | 当前选中的值,单选时为对象,多选时为数组 |
|
|
809
|
+
| onChange | function | - | 选中值变化时的回调函数 |
|
|
810
|
+
| single | boolean | false | 是否单选模式 |
|
|
811
|
+
| placeholder | string | '请选择行业' | 输入框占位符 |
|
|
812
|
+
| isPopup | boolean | true | 是否下拉模式,false 为弹窗模式 |
|
|
813
|
+
| overlayWidth | string \| number | '320px' | 选择器宽度 |
|
|
814
|
+
| onSearch | function | - | 自定义搜索函数,参数为 (searchText, { mapping }) |
|
|
815
|
+
| maxLength | number | - | 多选时最多可选数量 |
|
|
816
|
+
| disabled | boolean | false | 是否禁用 |
|
|
817
|
+
| style | object | - | 自定义样式 |
|
|
818
|
+
| className | string | - | 自定义类名 |
|
|
819
|
+
|
|
820
|
+
#### 静态方法
|
|
821
|
+
|
|
822
|
+
| 方法 | 说明 |
|
|
823
|
+
|------|------|
|
|
824
|
+
| SelectIndustry.defaultData() | 获取默认行业数据,返回 Promise |
|
|
825
|
+
| SelectIndustry.defaultProps() | 组件默认属性配置 |
|
|
826
|
+
|
|
827
|
+
#### 数据结构
|
|
828
|
+
|
|
829
|
+
组件内部使用扁平化的行业数据结构,通过 `code` 和 `parentCode` 建立层级关系:
|
|
830
|
+
|
|
831
|
+
```javascript
|
|
832
|
+
{
|
|
833
|
+
code: '001', // 行业编码
|
|
834
|
+
parentCode: '', // 父级编码
|
|
835
|
+
chName: '互联网/电子通信/软件', // 中文名称
|
|
836
|
+
enName: 'Internet/Telecoms/Software', // 英文名称
|
|
837
|
+
pinyin: 'hulianwang', // 拼音
|
|
838
|
+
spelling: 'hlw' // 首字母缩写
|
|
839
|
+
}
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
### SelectAddress 城市选择器
|
|
845
|
+
|
|
846
|
+
城市地址选择组件,支持国内外城市的搜索和选择,具备拼音搜索、首字母搜索等功能,适用于地址填写、城市筛选等业务场景。
|
|
847
|
+
|
|
848
|
+
#### 属性
|
|
849
|
+
|
|
850
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
851
|
+
|------|------|-------|------|
|
|
852
|
+
| value | array \| object | [] | 当前选中的值,单选时为对象,多选时为数组 |
|
|
853
|
+
| onChange | function | - | 选中值变化时的回调函数 |
|
|
854
|
+
| single | boolean | false | 是否单选模式 |
|
|
855
|
+
| placeholder | string | '请选择城市' | 输入框占位符 |
|
|
856
|
+
| isPopup | boolean | true | 是否下拉模式,false 为弹窗模式 |
|
|
857
|
+
| overlayWidth | string \| number | '320px' | 选择器宽度 |
|
|
858
|
+
| searchPlaceholder | string | - | 搜索框占位符 |
|
|
859
|
+
| maxLength | number | - | 多选时最多可选数量 |
|
|
860
|
+
| disabled | boolean | false | 是否禁用 |
|
|
861
|
+
| style | object | - | 自定义样式 |
|
|
862
|
+
| className | string | - | 自定义类名 |
|
|
863
|
+
|
|
864
|
+
#### 静态方法
|
|
865
|
+
|
|
866
|
+
| 方法 | 说明 |
|
|
867
|
+
|------|------|
|
|
868
|
+
| SelectAddress.defaultData() | 获取默认城市数据,返回 Promise |
|
|
869
|
+
| SelectAddress.createAddressApi(cityData) | 根据城市数据创建地址 API 实例 |
|
|
870
|
+
| SelectAddress.defaultProps | 组件默认属性配置 |
|
|
871
|
+
|
|
872
|
+
#### Address API
|
|
873
|
+
|
|
874
|
+
`createAddressApi` 方法返回的对象包含以下方法:
|
|
875
|
+
|
|
876
|
+
| 方法 | 参数 | 返回值 | 说明 |
|
|
877
|
+
|------|------|--------|------|
|
|
878
|
+
| getCity(id) | string: 城市ID | object: { city, parent } | 根据ID获取城市信息 |
|
|
879
|
+
| searchCities(value) | string: 搜索关键词 | array: 城市列表 | 搜索城市,支持拼音和首字母 |
|
|
880
|
+
| getCityList() | - | array: 城市列表 | 获取所有城市列表 |
|
|
881
|
+
|
|
882
|
+
#### 数据结构
|
|
883
|
+
|
|
884
|
+
城市数据包含国内外主要城市:
|
|
885
|
+
|
|
886
|
+
```javascript
|
|
887
|
+
{
|
|
888
|
+
code: '010', // 城市编码
|
|
889
|
+
name: '北京', // 城市名称
|
|
890
|
+
enName: 'Beijing', // 英文名称
|
|
891
|
+
parentCode: '410', // 父级编码
|
|
892
|
+
pinyin: 'beijing', // 拼音
|
|
893
|
+
spelling: 'bj' // 首字母缩写
|
|
894
|
+
}
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
---
|
|
898
|
+
|
|
899
|
+
### AddressEnum 地址枚举显示组件
|
|
900
|
+
|
|
901
|
+
用于显示城市名称的枚举组件,使用 `react-fetch` 加载数据,支持缓存和国际化。
|
|
902
|
+
|
|
903
|
+
#### 属性
|
|
904
|
+
|
|
905
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
906
|
+
|------|------|-------|------|
|
|
907
|
+
| name | string | - | 城市编码,必需 |
|
|
908
|
+
| displayParent | boolean | false | 是否显示父级城市名称 |
|
|
909
|
+
| force | boolean | false | 是否强制刷新缓存 |
|
|
910
|
+
| children | function | - | 自定义渲染函数 |
|
|
911
|
+
| api | object | - | 自定义 API 配置 |
|
|
912
|
+
|
|
913
|
+
#### 自定义渲染函数
|
|
914
|
+
|
|
915
|
+
```javascript
|
|
916
|
+
children={({ city, parent }, { displayParent, locale, getLabelForLocal }) => {
|
|
917
|
+
// city: 城市数据对象
|
|
918
|
+
// parent: 父级城市数据对象
|
|
919
|
+
// displayParent: 是否显示父级
|
|
920
|
+
// locale: 当前语言环境
|
|
921
|
+
// getLabelForLocal: 获取本地化标签的函数
|
|
922
|
+
return <span>{getLabelForLocal(city, locale)}</span>;
|
|
923
|
+
}}
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
#### 静态方法
|
|
927
|
+
|
|
928
|
+
| 方法 | 说明 |
|
|
929
|
+
|------|------|
|
|
930
|
+
| AddressEnum.getLabelForLocal(item, locale) | 获取本地化标签 |
|
|
931
|
+
| AddressEnum.addressDefaultApi | 默认 API 配置 |
|
|
932
|
+
|
|
933
|
+
#### 使用示例
|
|
934
|
+
|
|
935
|
+
```jsx
|
|
936
|
+
// 基本用法
|
|
937
|
+
<AddressEnum name="010" />
|
|
938
|
+
|
|
939
|
+
// 显示父级
|
|
940
|
+
<AddressEnum name="010" displayParent />
|
|
941
|
+
|
|
942
|
+
// 自定义渲染
|
|
943
|
+
<AddressEnum name="010">
|
|
944
|
+
{({ city, parent }, { getLabelForLocal, locale }) => (
|
|
945
|
+
<div>
|
|
946
|
+
{parent && <span>{getLabelForLocal(parent, locale)} · </span>}
|
|
947
|
+
{getLabelForLocal(city, locale)}
|
|
948
|
+
</div>
|
|
949
|
+
)}
|
|
950
|
+
</AddressEnum>
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
---
|
|
954
|
+
|
|
955
|
+
### FunctionEnum 职能枚举显示组件
|
|
956
|
+
|
|
957
|
+
用于显示职能名称的枚举组件,使用 `react-fetch` 加载数据,支持缓存和国际化。
|
|
958
|
+
|
|
959
|
+
#### 属性
|
|
960
|
+
|
|
961
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
962
|
+
|------|------|-------|------|
|
|
963
|
+
| name | string | - | 职能编码,必需 |
|
|
964
|
+
| force | boolean | false | 是否强制刷新缓存 |
|
|
965
|
+
| children | function | - | 自定义渲染函数 |
|
|
966
|
+
| api | object | - | 自定义 API 配置 |
|
|
967
|
+
|
|
968
|
+
#### 自定义渲染函数
|
|
969
|
+
|
|
970
|
+
```javascript
|
|
971
|
+
children={(item, { locale, mapping }) => {
|
|
972
|
+
// item: 职能数据对象,包含 label, chName, enName 等
|
|
973
|
+
// locale: 当前语言环境
|
|
974
|
+
// mapping: 所有职能数据的 Map 对象
|
|
975
|
+
return <span>{item.label}</span>;
|
|
976
|
+
}}
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
#### 静态方法
|
|
980
|
+
|
|
981
|
+
| 方法 | 说明 |
|
|
982
|
+
|------|------|
|
|
983
|
+
| FunctionEnum.getLabelForLocal(item, locale) | 获取本地化标签 |
|
|
984
|
+
| FunctionEnum.defaultFunctionApi | 默认 API 配置 |
|
|
985
|
+
|
|
986
|
+
#### 使用示例
|
|
987
|
+
|
|
988
|
+
```jsx
|
|
989
|
+
// 基本用法
|
|
990
|
+
<FunctionEnum name="001001001" />
|
|
991
|
+
|
|
992
|
+
// 自定义渲染
|
|
993
|
+
<FunctionEnum name="001001001">
|
|
994
|
+
{(item, { locale }) => (
|
|
995
|
+
<div>
|
|
996
|
+
<span>{item.label}</span>
|
|
997
|
+
{item.enName && <span>({item.enName})</span>}
|
|
998
|
+
</div>
|
|
999
|
+
)}
|
|
1000
|
+
</FunctionEnum>
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
---
|
|
1004
|
+
|
|
1005
|
+
### IndustryEnum 行业枚举显示组件
|
|
1006
|
+
|
|
1007
|
+
用于显示行业名称的枚举组件,使用 `react-fetch` 加载数据,支持缓存和国际化。
|
|
1008
|
+
|
|
1009
|
+
#### 属性
|
|
1010
|
+
|
|
1011
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
1012
|
+
|------|------|-------|------|
|
|
1013
|
+
| name | string | - | 行业编码,必需 |
|
|
1014
|
+
| force | boolean | false | 是否强制刷新缓存 |
|
|
1015
|
+
| children | function | - | 自定义渲染函数 |
|
|
1016
|
+
| api | object | - | 自定义 API 配置 |
|
|
1017
|
+
|
|
1018
|
+
#### 自定义渲染函数
|
|
1019
|
+
|
|
1020
|
+
```javascript
|
|
1021
|
+
children={(item, { locale, mapping }) => {
|
|
1022
|
+
// item: 行业数据对象,包含 label, chName, enName 等
|
|
1023
|
+
// locale: 当前语言环境
|
|
1024
|
+
// mapping: 所有行业数据的 Map 对象
|
|
1025
|
+
return <span>{item.label}</span>;
|
|
1026
|
+
}}
|
|
1027
|
+
```
|
|
1028
|
+
|
|
1029
|
+
#### 静态方法
|
|
1030
|
+
|
|
1031
|
+
| 方法 | 说明 |
|
|
1032
|
+
|------|------|
|
|
1033
|
+
| IndustryEnum.getLabelForLocal(item, locale) | 获取本地化标签 |
|
|
1034
|
+
| IndustryEnum.defaultIndustryApi | 默认 API 配置 |
|
|
1035
|
+
|
|
1036
|
+
#### 使用示例
|
|
1037
|
+
|
|
1038
|
+
```jsx
|
|
1039
|
+
// 基本用法
|
|
1040
|
+
<IndustryEnum name="001" />
|
|
1041
|
+
|
|
1042
|
+
// 自定义渲染
|
|
1043
|
+
<IndustryEnum name="001">
|
|
1044
|
+
{(item, { locale }) => (
|
|
1045
|
+
<div>
|
|
1046
|
+
<span>{item.label}</span>
|
|
1047
|
+
{item.enName && <span>({item.enName})</span>}
|
|
1048
|
+
</div>
|
|
1049
|
+
)}
|
|
1050
|
+
</IndustryEnum>
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
---
|
|
1054
|
+
|
|
1055
|
+
### EnumDisplay 通用枚举显示组件
|
|
1056
|
+
|
|
1057
|
+
通用的枚举显示组件,支持自定义数据源、国际化、缓存等功能。
|
|
1058
|
+
|
|
1059
|
+
#### 属性
|
|
1060
|
+
|
|
1061
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
1062
|
+
|------|------|-------|------|
|
|
1063
|
+
| name | string | - | 枚举值编码,必需 |
|
|
1064
|
+
| type | string | - | 枚举类型标识 |
|
|
1065
|
+
| cache | string | 'ENUM_DATA' | 缓存键名 |
|
|
1066
|
+
| force | boolean | false | 是否强制刷新缓存 |
|
|
1067
|
+
| children | function | - | 自定义渲染函数 |
|
|
1068
|
+
| api | object | - | API 配置对象 |
|
|
1069
|
+
| getLabel | function | - | 自定义标签获取函数 |
|
|
1070
|
+
|
|
1071
|
+
#### API 配置
|
|
1072
|
+
|
|
1073
|
+
```javascript
|
|
1074
|
+
api={{
|
|
1075
|
+
cache: 'CUSTOM_DATA', // 缓存键名
|
|
1076
|
+
isLocal: true, // 是否本地数据
|
|
1077
|
+
ttl: 1000 * 60 * 60 * 24, // 缓存时间(毫秒)
|
|
1078
|
+
loader: async () => { // 数据加载函数
|
|
1079
|
+
return data;
|
|
1080
|
+
}
|
|
1081
|
+
}}
|
|
1082
|
+
|
|
1083
|
+
// 或远程 API
|
|
1084
|
+
api={{
|
|
1085
|
+
cache: 'REMOTE_DATA',
|
|
1086
|
+
url: '/api/enum', // API 地址
|
|
1087
|
+
method: 'GET', // 请求方法
|
|
1088
|
+
dataFormat: (data) => data // 数据格式化函数
|
|
1089
|
+
}}
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
#### 自定义渲染函数
|
|
1093
|
+
|
|
1094
|
+
```javascript
|
|
1095
|
+
children={(item, { locale, mapping }) => {
|
|
1096
|
+
// item: 枚举数据对象
|
|
1097
|
+
// locale: 当前语言环境
|
|
1098
|
+
// mapping: 所有枚举数据的 Map 对象
|
|
1099
|
+
return <span>{item.label}</span>;
|
|
1100
|
+
}}
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
#### 使用示例
|
|
1104
|
+
|
|
1105
|
+
```jsx
|
|
1106
|
+
// 基本用法
|
|
1107
|
+
<EnumDisplay
|
|
1108
|
+
name="1"
|
|
1109
|
+
type="education"
|
|
1110
|
+
api={{
|
|
1111
|
+
cache: 'EDUCATION_DATA',
|
|
1112
|
+
loader: async () => [
|
|
1113
|
+
{ code: '1', name: '本科', enName: 'Bachelor' },
|
|
1114
|
+
{ code: '2', name: '硕士', enName: 'Master' }
|
|
1115
|
+
]
|
|
1116
|
+
}}
|
|
1117
|
+
/>
|
|
1118
|
+
|
|
1119
|
+
// 自定义 getLabel
|
|
1120
|
+
<EnumDisplay
|
|
1121
|
+
name="1"
|
|
1122
|
+
type="education"
|
|
1123
|
+
api={api}
|
|
1124
|
+
getLabel={(item, locale) => {
|
|
1125
|
+
return locale === 'en-US' ? item.enName : item.name;
|
|
1126
|
+
}}
|
|
1127
|
+
/>
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
---
|
|
1131
|
+
|
|
1132
|
+
### 国际化支持
|
|
1133
|
+
|
|
1134
|
+
所有组件均支持国际化,通过 `@kne/react-intl` 实现:
|
|
1135
|
+
|
|
1136
|
+
#### 支持的语言
|
|
1137
|
+
|
|
1138
|
+
- 中文(zh-CN):默认语言
|
|
1139
|
+
- 英文(en-US):备用语言
|
|
1140
|
+
|
|
1141
|
+
#### 使用方式
|
|
1142
|
+
|
|
1143
|
+
组件会根据当前 locale 自动切换语言:
|
|
1144
|
+
|
|
1145
|
+
- 中文名称(chName)优先显示中文环境
|
|
1146
|
+
- 英文名称(enName)优先显示英文环境
|
|
1147
|
+
- 当对应语言不存在时,会使用备选语言
|
|
1148
|
+
|
|
1149
|
+
#### 搜索功能
|
|
1150
|
+
|
|
1151
|
+
所有组件的搜索功能均支持:
|
|
1152
|
+
|
|
1153
|
+
- 中文名称搜索(chName)
|
|
1154
|
+
- 英文名称搜索(enName)
|
|
1155
|
+
- 拼音搜索(pinyin)
|
|
1156
|
+
- 首字母搜索(spelling)
|