@xfe-repo/web-components 1.8.0 → 1.8.1
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/dist/index.css +34 -1
- package/dist/index.d.mts +46 -12
- package/dist/index.d.ts +46 -12
- package/dist/index.js +524 -172
- package/dist/index.mjs +478 -134
- package/package.json +2 -2
- package/skills/xfe-web-components/GUIDE.md +3 -2
- package/skills/xfe-web-components/SKILL.md +3 -2
- package/skills/xfe-web-components/references/EffectLabelSelect.md +6 -5
- package/skills/xfe-web-components/references/EffectMerchantSelect.md +13 -28
- package/skills/xfe-web-components/references/EffectSearchSelect.md +262 -0
- package/skills/xfe-web-components/references/EffectStaffSelect.md +4 -4
- package/skills/xfe-web-components/references/commonFn.md +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-components",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"module": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"react-use": "^17.5.1",
|
|
65
65
|
"swr": "^2.2.5",
|
|
66
66
|
"@xfe-repo/web-micro": "1.7.0",
|
|
67
|
-
"@xfe-repo/web-router": "1.6.1",
|
|
68
67
|
"@xfe-repo/web-service": "1.6.0",
|
|
68
|
+
"@xfe-repo/web-router": "1.6.1",
|
|
69
69
|
"@xfe-repo/web-utils": "1.6.0"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
| EffectBrandTransfer | | ✅ TransferValueType | ✅ useBrandOptions | ✅ categoryId | | | ✅ | |
|
|
14
14
|
| EffectCategoryCascade | ✅ 多选/获取原始数据 | ✅ TreeValueType 等6个 | ✅ useCategoryTree | | | | ✅ | ✅ 级联起点 |
|
|
15
15
|
| EffectFileUpload | ✅ 自动上传/手动上传 | ✅ SimpleFileData, UploadResult | ✅ uploadUploadFile | | ✅ handleUpload等 | ✅ Group | ✅ | ✅ WithFilePanel |
|
|
16
|
-
| EffectLabelSelect | ✅ 自定义数据源 | ✅ SelectOptionItem, LabelDic | ✅ 可自定义 | | | | ✅ |
|
|
16
|
+
| EffectLabelSelect | ✅ 自定义数据源 | ✅ SelectOptionItem, LabelDic | ✅ 可自定义 | | | | ✅ | ✅ SearchSelect |
|
|
17
17
|
| EffectMerchantSelect | ✅ 搜索源切换 | ✅ MerchantOptions | ✅ useMerchantOptions | | | | ✅ | |
|
|
18
18
|
| EffectReservoirSelect | | | ✅ reservoirList | ✅ warehouseId | | | ✅ | ✅ WarehouseSelect |
|
|
19
|
+
| EffectSearchSelect | ✅ 自定义接口/搜索源 | ✅ EffectSearchSelectProps | ✅ useSWRImmutable | | | | ✅ | ✅ Label/Merchant |
|
|
19
20
|
| EffectScopeSelect | ✅ scopeLevel控制 | ✅ ScopeSelectValueType, ScopeLevelEnum | | | | ✅ 内含5个Effect | ✅ | |
|
|
20
21
|
| EffectSeriesSelect | | | ✅ useSeriesOptions | ✅ categoryId, brandId | | | ✅ | ✅ 级联链 |
|
|
21
22
|
| EffectSeriesSelectV2 | | | ✅ seriesList | ✅ categoryId, brandId | | | ✅ | ✅ 级联链 |
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
|
|
56
57
|
## 维护优先级
|
|
57
58
|
|
|
58
|
-
> 全部
|
|
59
|
+
> 全部 41 个组件文档已完成编写,并经过 platform + dashboard + erp 三项目业务用法审计。
|
|
59
60
|
> 以下优先级适用于后续组件新增或文档维护场景。
|
|
60
61
|
|
|
61
62
|
### 高优先级维护(业务使用频率最高、Agent 出错影响最大)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: xfe-web-components
|
|
3
3
|
description: >-
|
|
4
|
-
@xfe-repo/web-components 组件库的完整使用指南。包含
|
|
4
|
+
@xfe-repo/web-components 组件库的完整使用指南。包含 41 个 React 组件的 Props 类型定义、
|
|
5
5
|
代码示例、常见陷阱和组件间联动关系。当使用 EffectBrandSelect、EffectCategoryCascade、
|
|
6
6
|
WithModal、EffectFileUpload、EffectScopeSelect、CTable、SearchForm、OSSImage、
|
|
7
7
|
CInput、SearchList、Currency、Loading 等组件时自动激活。
|
|
@@ -36,9 +36,10 @@ description: >-
|
|
|
36
36
|
| EffectScopeSelect | `references/EffectScopeSelect.md` | 商品范围选择(复合组件) |
|
|
37
37
|
| EffectAddressCascade | `references/EffectAddressCascade.md` | 地址级联选择 |
|
|
38
38
|
| EffectBrandTransfer | `references/EffectBrandTransfer.md` | 品牌穿梭框 |
|
|
39
|
-
| EffectLabelSelect | `references/EffectLabelSelect.md` |
|
|
39
|
+
| EffectLabelSelect | `references/EffectLabelSelect.md` | 标签维度双选择器(已废弃) |
|
|
40
40
|
| EffectMerchantSelect | `references/EffectMerchantSelect.md` | 商户选择器 |
|
|
41
41
|
| EffectReservoirSelect | `references/EffectReservoirSelect.md` | 库区选择器 |
|
|
42
|
+
| EffectSearchSelect | `references/EffectSearchSelect.md` | 搜索源联想选择器 |
|
|
42
43
|
| EffectSeriesSelect | `references/EffectSeriesSelect.md` | 系列选择器 |
|
|
43
44
|
| EffectSeriesSelectV2 | `references/EffectSeriesSelectV2.md` | 系列多选器 V2 |
|
|
44
45
|
| EffectSkuRecognize | `references/EffectSkuRecognize.md` | SKU 图片识别 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# EffectLabelSelect
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 标签维度双选择器。左侧选择搜索维度,右侧根据选中维度远程搜索并选择具体值。该组件已在源码中标记为 `@deprecated`,新业务优先使用 `EffectSearchSelect`。
|
|
4
4
|
|
|
5
5
|
## 导入
|
|
6
6
|
|
|
@@ -216,7 +216,8 @@ export const getSecondValue = (str?: string) => string
|
|
|
216
216
|
|
|
217
217
|
## 相关组件
|
|
218
218
|
|
|
219
|
-
| 场景
|
|
220
|
-
|
|
|
221
|
-
|
|
|
222
|
-
|
|
|
219
|
+
| 场景 | 组件 | 说明 |
|
|
220
|
+
| ---------------- | ---------------------- | --------------------------------------- |
|
|
221
|
+
| 新版通用搜索联想 | `EffectSearchSelect` | 推荐使用,支持默认商户接口和自定义接口 |
|
|
222
|
+
| 商户选择旧组件 | `EffectMerchantSelect` | 固定商户搜索源的旧组件 |
|
|
223
|
+
| API 配置 | `ConfigProvider` | 提供 `apiService.merchantList` 接口实现 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# EffectMerchantSelect
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 商户下拉选择器,支持按商户号、平台名、商户名、手机号四种搜索源切换查询,选项标签根据当前搜索源自动展示对应字段,数据通过 `apiService.merchantList` 自动获取。
|
|
4
4
|
|
|
5
5
|
## 导入
|
|
6
6
|
|
|
@@ -39,7 +39,7 @@ function MyForm() {
|
|
|
39
39
|
|
|
40
40
|
```tsx
|
|
41
41
|
<EffectMerchantSelect
|
|
42
|
-
source="platformName" //
|
|
42
|
+
source="platformName" // 初始按平台名搜索
|
|
43
43
|
value={merchantNo}
|
|
44
44
|
onChange={(value, name) => {
|
|
45
45
|
setMerchantNo(value)
|
|
@@ -48,13 +48,6 @@ function MyForm() {
|
|
|
48
48
|
/>
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
### 自定义标签展示模式
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
// 选项标签展示为 "商户平台名 - 企业编号" 格式
|
|
55
|
-
<EffectMerchantSelect labelDisplayMode="platformName-enterpriseNo" value={merchantNo} onChange={(value) => setMerchantNo(value)} />
|
|
56
|
-
```
|
|
57
|
-
|
|
58
51
|
### onChange 同步商户名称
|
|
59
52
|
|
|
60
53
|
Form 管理 enterpriseNo,但 enterpriseName 需要 useState 单独保存:
|
|
@@ -75,37 +68,34 @@ const [merchantName, setMerchantName] = useState('')
|
|
|
75
68
|
|
|
76
69
|
```tsx
|
|
77
70
|
<Form.Item name="enterpriseNo" label="商户">
|
|
78
|
-
<EffectMerchantSelect source="phone"
|
|
71
|
+
<EffectMerchantSelect source="phone" />
|
|
79
72
|
</Form.Item>
|
|
80
73
|
```
|
|
81
74
|
|
|
82
|
-
>
|
|
75
|
+
> `source` 可选值:`"enterpriseNo"`(默认,按商户号)、`"platformName"`(按平台名)、`"name"`(按商户名)、`"phone"`(按手机号)。选项标签会根据当前搜索源自动展示对应字段。
|
|
83
76
|
|
|
84
77
|
## Props
|
|
85
78
|
|
|
86
79
|
```typescript
|
|
87
|
-
type
|
|
80
|
+
type DefaultMerchantSourceValue = 'enterpriseNo' | 'platformName' | 'name' | 'phone'
|
|
88
81
|
|
|
89
82
|
interface EffectMerchantSelectProps {
|
|
90
83
|
className?: string
|
|
91
84
|
onChange?: (value?: string, name?: string) => void
|
|
92
85
|
value?: string
|
|
93
86
|
/** 搜索字段来源 */
|
|
94
|
-
source?:
|
|
87
|
+
source?: DefaultMerchantSourceValue
|
|
95
88
|
disabled?: boolean
|
|
96
|
-
/** 选项标签展示模式 */
|
|
97
|
-
labelDisplayMode?: LabelDisplayMode
|
|
98
89
|
}
|
|
99
90
|
```
|
|
100
91
|
|
|
101
|
-
| 属性
|
|
102
|
-
|
|
|
103
|
-
| value
|
|
104
|
-
| onChange
|
|
105
|
-
| source
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
| className | `string` | 否 | - | 自定义样式类名 |
|
|
92
|
+
| 属性 | 类型 | 必填 | 默认值 | 说明 |
|
|
93
|
+
| --------- | ------------------------------------------------------- | ---- | ---------------- | ------------------------------------------- |
|
|
94
|
+
| value | `string` | 否 | - | 受控值(企业编号 enterpriseNo) |
|
|
95
|
+
| onChange | `(value?: string, name?: string) => void` | 否 | - | 值变化回调,第二个参数为商户的 platformName |
|
|
96
|
+
| source | `'enterpriseNo' \| 'platformName' \| 'name' \| 'phone'` | 否 | `'enterpriseNo'` | 初始搜索字段来源,同时决定选项标签展示内容 |
|
|
97
|
+
| disabled | `boolean` | 否 | - | 禁用状态 |
|
|
98
|
+
| className | `string` | 否 | - | 自定义样式类名 |
|
|
109
99
|
|
|
110
100
|
## 导出类型
|
|
111
101
|
|
|
@@ -117,13 +107,8 @@ export type MerchantOptions = {
|
|
|
117
107
|
originalName: string
|
|
118
108
|
data?: MerchantListBus
|
|
119
109
|
}[]
|
|
120
|
-
|
|
121
|
-
// 标签展示模式
|
|
122
|
-
export type LabelDisplayMode = 'platformName' | 'platformName-enterpriseNo'
|
|
123
110
|
```
|
|
124
111
|
|
|
125
|
-
> **注意**:`LabelDisplayMode` 定义在内部 `useMerchantOptions` 模块中,未从包入口直接导出。使用时直接传字面量 `'platformName'` 或 `'platformName-enterpriseNo'` 即可。
|
|
126
|
-
|
|
127
112
|
## API 数据源
|
|
128
113
|
|
|
129
114
|
- **内部 Hook**:`useMerchantOptions`(使用 SWR 缓存,`revalidateOnMount: false`)
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# EffectSearchSelect
|
|
2
|
+
|
|
3
|
+
> 带默认副作用接口的搜索联想选择器。左侧选择搜索源,右侧远程搜索并选择结果;默认用于商户搜索,内部调用 `apiService.merchantList`,也支持传入自定义接口、搜索源和数据转换函数。
|
|
4
|
+
|
|
5
|
+
## 导入
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { EffectSearchSelect } from '@xfe-repo/web-components'
|
|
9
|
+
import type { EffectSearchSelectProps } from '@xfe-repo/web-components'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 基本用法
|
|
13
|
+
|
|
14
|
+
### Form.Item 集成(最常用)
|
|
15
|
+
|
|
16
|
+
默认按商户信息搜索,value 为商户 `enterpriseNo`:
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<Form.Item name="enterpriseNo" label="商户" rules={[{ required: true, message: '请选择商户' }]}>
|
|
20
|
+
<EffectSearchSelect />
|
|
21
|
+
</Form.Item>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
默认左侧搜索源:
|
|
25
|
+
|
|
26
|
+
| 文案 | value | 说明 |
|
|
27
|
+
| ------ | -------------- | --------------------- |
|
|
28
|
+
| 商户号 | `enterpriseNo` | 按商户号/企业编号搜索 |
|
|
29
|
+
| 平台名 | `platformName` | 按商户平台名搜索 |
|
|
30
|
+
| 商户名 | `name` | 按商户名搜索 |
|
|
31
|
+
| 手机号 | `phone` | 按手机号搜索 |
|
|
32
|
+
|
|
33
|
+
### 独立受控模式
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
const [enterpriseNo, setEnterpriseNo] = useState<string>()
|
|
37
|
+
|
|
38
|
+
<EffectSearchSelect
|
|
39
|
+
value={enterpriseNo}
|
|
40
|
+
onChange={(value, option) => {
|
|
41
|
+
setEnterpriseNo(value)
|
|
42
|
+
console.log('选中项原始数据:', option?.raw)
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 进阶用法
|
|
48
|
+
|
|
49
|
+
### 自定义左侧搜索源
|
|
50
|
+
|
|
51
|
+
`sources` 只需要传 `{ label, value }[]`。默认情况下,`value` 会作为请求字段名:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<EffectSearchSelect
|
|
55
|
+
sources={[
|
|
56
|
+
{ label: '平台名', value: 'platformName' },
|
|
57
|
+
{ label: '商户名', value: 'name' },
|
|
58
|
+
]}
|
|
59
|
+
defaultSourceValue="platformName"
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 切换搜索源不触发表单校验
|
|
64
|
+
|
|
65
|
+
组件默认行为是:切换左侧搜索源时清空内部搜索态,但不触发右侧字段 `onChange`,避免 `Form.Item` 因 `validateTrigger="onChange"` 立即校验。
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<Form.Item name="enterpriseNo" label="商户" rules={[{ required: true, message: '请选择商户' }]}>
|
|
69
|
+
<EffectSearchSelect />
|
|
70
|
+
</Form.Item>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 自定义接口和数据转换
|
|
74
|
+
|
|
75
|
+
用于复用“左侧搜索源 + 右侧远程联想选择”的整体交互:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
type StaffParams = {
|
|
79
|
+
name?: string
|
|
80
|
+
phone?: string
|
|
81
|
+
page: number
|
|
82
|
+
pageSize: number
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type StaffResponse = {
|
|
86
|
+
list: { user_id: number; name: string; phone: string }[]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type StaffItem = StaffResponse['list'][number]
|
|
90
|
+
|
|
91
|
+
;<EffectSearchSelect<StaffParams, StaffResponse, StaffItem, number, 'name' | 'phone'>
|
|
92
|
+
sources={[
|
|
93
|
+
{ label: '员工名', value: 'name' },
|
|
94
|
+
{ label: '手机号', value: 'phone' },
|
|
95
|
+
]}
|
|
96
|
+
request={myStaffSearchApi}
|
|
97
|
+
transformOptions={(data) =>
|
|
98
|
+
data.list.map((item) => ({
|
|
99
|
+
label: item.name,
|
|
100
|
+
value: item.user_id,
|
|
101
|
+
raw: item,
|
|
102
|
+
}))
|
|
103
|
+
}
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 自定义请求参数构建
|
|
108
|
+
|
|
109
|
+
当左侧 `source.value` 不能直接作为接口字段名,或接口需要复杂参数时,使用 `buildParams`:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
<EffectSearchSelect<MyParams, MyResponse, MyItem, string, 'keyword'>
|
|
113
|
+
sources={[{ label: '关键字', value: 'keyword' }]}
|
|
114
|
+
request={mySearchApi}
|
|
115
|
+
buildParams={(keyword, source, baseParams) => ({
|
|
116
|
+
...baseParams,
|
|
117
|
+
page: 1,
|
|
118
|
+
pageSize: 20,
|
|
119
|
+
query: {
|
|
120
|
+
field: source.value,
|
|
121
|
+
keyword,
|
|
122
|
+
},
|
|
123
|
+
})}
|
|
124
|
+
transformOptions={(data) =>
|
|
125
|
+
data.list.map((item) => ({
|
|
126
|
+
label: item.name,
|
|
127
|
+
value: item.id,
|
|
128
|
+
raw: item,
|
|
129
|
+
}))
|
|
130
|
+
}
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Props
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
type SelectValue = string | number
|
|
138
|
+
|
|
139
|
+
type EffectSearchSource<SourceValue extends string = string> = {
|
|
140
|
+
label: string
|
|
141
|
+
value: SourceValue
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
type EffectSearchOption<Value extends SelectValue = string, Raw = unknown> = {
|
|
145
|
+
label: React.ReactNode
|
|
146
|
+
value: Value
|
|
147
|
+
disabled?: boolean
|
|
148
|
+
raw?: Raw
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type EffectSearchRequest<Params extends object, ResponseData> = (
|
|
152
|
+
params: Params,
|
|
153
|
+
config?: BFFRequestConfig,
|
|
154
|
+
) => Promise<BffDataType<ResponseData>>
|
|
155
|
+
|
|
156
|
+
interface EffectSearchSelectProps<
|
|
157
|
+
Params extends object = InMerchantListBusDto,
|
|
158
|
+
ResponseData = OutMerchantListBusDto,
|
|
159
|
+
Raw = MerchantListBus,
|
|
160
|
+
Value extends SelectValue = string,
|
|
161
|
+
SourceValue extends string = DefaultMerchantSearchSourceValue,
|
|
162
|
+
> extends Omit<SelectProps<Value>, 'mode' | 'options' | 'onChange' | 'onSearch'> {
|
|
163
|
+
sources?: readonly EffectSearchSource<SourceValue>[]
|
|
164
|
+
defaultSourceValue?: SourceValue
|
|
165
|
+
fetchParams?: Partial<Params>
|
|
166
|
+
pageSize?: number
|
|
167
|
+
buildParams?: (keyword: string, source: EffectSearchSource<SourceValue>, baseParams: Partial<Params>) => Params
|
|
168
|
+
onChange?: (value?: Value, option?: EffectSearchOption<Value, Raw>) => void
|
|
169
|
+
request?: EffectSearchRequest<Params, ResponseData>
|
|
170
|
+
transformOptions?: (
|
|
171
|
+
data: ResponseData,
|
|
172
|
+
context: { source: EffectSearchSource<SourceValue>; keyword: string },
|
|
173
|
+
) => EffectSearchOption<Value, Raw>[]
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
| 属性 | 类型 | 必填 | 默认值 | 说明 |
|
|
178
|
+
| ------------------ | ----------------------------------------- | ---- | ---------------------------- | ------------------------------------------ |
|
|
179
|
+
| value | `Value` | 否 | - | 受控值,默认商户场景为 `enterpriseNo` |
|
|
180
|
+
| onChange | `(value?, option?) => void` | 否 | - | 右侧选择值变化回调 |
|
|
181
|
+
| sources | `EffectSearchSource[]` | 否 | 默认商户搜索源 | 左侧搜索源配置,`value` 默认作为请求字段名 |
|
|
182
|
+
| defaultSourceValue | `SourceValue` | 否 | `enterpriseNo` | 默认搜索源 |
|
|
183
|
+
| fetchParams | `Partial<Params>` | 否 | `{}` | 额外请求参数 |
|
|
184
|
+
| pageSize | `number` | 否 | `20` | 默认请求分页大小 |
|
|
185
|
+
| buildParams | `(keyword, source, baseParams) => Params` | 否 | 内置按 `[source.value]` 构建 | 自定义请求参数构建 |
|
|
186
|
+
| request | `EffectSearchRequest` | 否 | `apiService.merchantList` | 自定义请求函数 |
|
|
187
|
+
| transformOptions | `(data, context) => EffectSearchOption[]` | 否 | 默认商户转换 | 将接口响应转换成右侧 Select options |
|
|
188
|
+
|
|
189
|
+
## 导出类型
|
|
190
|
+
|
|
191
|
+
当前包入口主要导出:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
export type EffectSearchSelectProps
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
源码中还定义了 `EffectSearchSource`、`EffectSearchOption`、`EffectSearchRequest`、`EffectSearchBuildParams` 等类型;如需对外使用,优先检查包入口是否已导出。
|
|
198
|
+
|
|
199
|
+
## API 数据源
|
|
200
|
+
|
|
201
|
+
- **内部 Hook**:`useEffectSearchOptions`
|
|
202
|
+
- **缓存方案**:`useSWRImmutable`
|
|
203
|
+
- **默认接口**:`apiService.merchantList`
|
|
204
|
+
- **默认请求参数**:`{ page: 1, pageSize: 20, ...fetchParams, [source.value]: keyword }`
|
|
205
|
+
- **可覆盖**:通过 `request` 传入自定义接口,或通过 `<ConfigProvider apiService={{ merchantList: customFn }}>` 替换默认商户接口
|
|
206
|
+
|
|
207
|
+
### 默认商户选项展示
|
|
208
|
+
|
|
209
|
+
默认商户场景下,右侧联想项会根据左侧搜索源展示对应字段:
|
|
210
|
+
|
|
211
|
+
| source.value | 右侧 label 来源 |
|
|
212
|
+
| -------------- | ---------------------------------------- |
|
|
213
|
+
| `enterpriseNo` | `item.enterpriseNo` |
|
|
214
|
+
| `platformName` | `item.platformName` |
|
|
215
|
+
| `name` | `item.name` |
|
|
216
|
+
| `phone` | 当前接口暂无手机号字段,回退展示组合信息 |
|
|
217
|
+
|
|
218
|
+
右侧选中值仍为 `item.enterpriseNo`。
|
|
219
|
+
|
|
220
|
+
## 常见陷阱
|
|
221
|
+
|
|
222
|
+
- ❌ 期望切换左侧搜索源时自动触发表单校验:
|
|
223
|
+
```tsx
|
|
224
|
+
// 默认不会触发字段 onChange,避免 Form.Item 立刻出现必填校验
|
|
225
|
+
<EffectSearchSelect />
|
|
226
|
+
```
|
|
227
|
+
- ✅ 切换左侧搜索源只是内部交互,会清空右侧搜索态并等待用户重新输入。
|
|
228
|
+
|
|
229
|
+
- ❌ 自定义接口时只传 `request`,没有传 `transformOptions`:
|
|
230
|
+
```tsx
|
|
231
|
+
<EffectSearchSelect request={myApi} />
|
|
232
|
+
```
|
|
233
|
+
- ✅ 自定义接口应同时传入 `transformOptions`,确保返回 `{ label, value, raw }`:
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
<EffectSearchSelect
|
|
237
|
+
request={myApi}
|
|
238
|
+
transformOptions={(data) => data.list.map((item) => ({ label: item.name, value: item.id, raw: item }))}
|
|
239
|
+
/>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
- ❌ 认为 `sources.value` 是提交值:
|
|
243
|
+
```tsx
|
|
244
|
+
// sources.value 是搜索字段名,不是 Form.Item 的提交值
|
|
245
|
+
sources={[{ label: '商户名', value: 'name' }]}
|
|
246
|
+
```
|
|
247
|
+
- ✅ Form.Item 的提交值来自右侧选项的 `option.value`,默认商户场景为 `enterpriseNo`。
|
|
248
|
+
|
|
249
|
+
- ❌ 未输入关键字时期待接口立即请求:
|
|
250
|
+
```tsx
|
|
251
|
+
// 空输入不请求
|
|
252
|
+
```
|
|
253
|
+
- ✅ 输入关键字后才触发远程搜索。
|
|
254
|
+
|
|
255
|
+
## 相关组件
|
|
256
|
+
|
|
257
|
+
| 场景 | 组件 | 说明 |
|
|
258
|
+
| -------------- | ---------------------- | ------------------------------------------------ |
|
|
259
|
+
| 旧版标签搜索 | `EffectLabelSelect` | 已废弃,保留兼容;新业务优先使用本组件 |
|
|
260
|
+
| 旧版商户选择 | `EffectMerchantSelect` | 固定商户搜索源的旧组件 |
|
|
261
|
+
| API 配置 | `ConfigProvider` | 提供 `apiService.merchantList` 或其他 Effect API |
|
|
262
|
+
| 搜索表单中使用 | `SearchForm` | 常与 Form.Item 搜索条件一起使用 |
|
|
@@ -144,7 +144,7 @@ type EffectStaffSelectProps = {
|
|
|
144
144
|
|
|
145
145
|
## 相关组件
|
|
146
146
|
|
|
147
|
-
| 场景 | 组件
|
|
148
|
-
| ---------- |
|
|
149
|
-
| 多维度搜索 | `
|
|
150
|
-
| API 配置 | `ConfigProvider`
|
|
147
|
+
| 场景 | 组件 | 说明 |
|
|
148
|
+
| ---------- | -------------------- | --------------------------------------- |
|
|
149
|
+
| 多维度搜索 | `EffectSearchSelect` | 支持切换搜索维度的通用选择器 |
|
|
150
|
+
| API 配置 | `ConfigProvider` | 提供 `apiService.businessList` 接口实现 |
|
|
@@ -175,7 +175,9 @@ export const commonDateRangePickerGetValueProps: (dateStrs: string[] | null) =>
|
|
|
175
175
|
|
|
176
176
|
### getSelectValue / getStrValue 系列
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
配合旧组件 `EffectLabelSelect` 的 `customLabelInValue` 模式使用的解析函数组。当 EffectLabelSelect 设置了 `customLabelInValue` 后,value 不再是简单的 ID,而是一个分号分隔的组合字符串。
|
|
179
|
+
|
|
180
|
+
> 新业务优先使用 `EffectSearchSelect`,只有兼容旧字段格式时才需要这些函数。
|
|
179
181
|
|
|
180
182
|
导入:
|
|
181
183
|
|