@bit-sun/business-component 1.1.1 → 1.1.5
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/package.json +3 -2
- package/src/components/QueryMutipleInput/index.tsx +1 -1
- package/src/components/SearchSelect/business/BusinessSearchSelect.tsx +24 -0
- package/src/components/SearchSelect/business/BusinessUtils.ts +264 -0
- package/src/components/SearchSelect/business/index.md +55 -0
- package/src/components/SearchSelect/index.less +115 -0
- package/src/components/SearchSelect/index.md +138 -0
- package/src/components/SearchSelect/index.tsx +493 -0
- package/src/index.ts +3 -1
- package/dist/components/DataValidation/index.d.ts +0 -144
- package/dist/components/QueryMutipleInput/index.d.ts +0 -5
- package/dist/index.d.ts +0 -3
- package/dist/index.esm.js +0 -2386
- package/dist/index.js +0 -2399
- package/dist/utils/CheckOneUser/index.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bit-sun/business-component",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "dumi dev",
|
|
6
6
|
"docs:build": "dumi build",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"axios": "^0.24.0",
|
|
33
33
|
"classnames": "^2.3.1",
|
|
34
34
|
"loadsh": "^0.0.4",
|
|
35
|
+
"querystring": "^0.2.1",
|
|
35
36
|
"react": "^16.12.0",
|
|
36
37
|
"react-beautiful-dnd": "10.0.0"
|
|
37
38
|
},
|
|
@@ -46,4 +47,4 @@
|
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
48
49
|
}
|
|
49
|
-
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { commonFun } from './BusinessUtils';
|
|
3
|
+
import SearchSelect from '../index';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const BusinessSearchSelect = (props: any) => {
|
|
7
|
+
const businessType = props?.SelectBusinessType || 'supplier';
|
|
8
|
+
|
|
9
|
+
const { requestConfig, modalTableProps } = commonFun(businessType);
|
|
10
|
+
|
|
11
|
+
const currentProps = {
|
|
12
|
+
requestConfig,
|
|
13
|
+
...props,
|
|
14
|
+
modalTableProps
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div>
|
|
19
|
+
<SearchSelect {...currentProps} />
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default BusinessSearchSelect;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// 此文件用于 处理业务组件 所用到的公共方法
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import { message } from 'antd';
|
|
5
|
+
import { stringify } from 'querystring';
|
|
6
|
+
|
|
7
|
+
const getDicData = (dicCode: string) => {
|
|
8
|
+
let dicData = {};
|
|
9
|
+
let dictionaryData;
|
|
10
|
+
if (!dictionaryData) {
|
|
11
|
+
let storageDic = localStorage.getItem('dicData')
|
|
12
|
+
? JSON.parse(localStorage.getItem('dicData') || '{}')
|
|
13
|
+
: {};
|
|
14
|
+
dicData = storageDic[dicCode];
|
|
15
|
+
} else {
|
|
16
|
+
dicData = dictionaryData[dicCode];
|
|
17
|
+
}
|
|
18
|
+
if (!dicData || !dicData.length) {
|
|
19
|
+
// throw new Error(`当前没有${dicCode}字典值`);
|
|
20
|
+
}
|
|
21
|
+
return dicData
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const getDictionarySource = (dicCode: string, needConvertInterger = false) => {
|
|
25
|
+
let dicData = getDicData(dicCode);
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
if (needConvertInterger) {
|
|
29
|
+
dicData = dicData.map((item: { text: string; value: string }) => ({
|
|
30
|
+
...item,
|
|
31
|
+
value: parseFloat(item.value),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {}
|
|
35
|
+
return dicData;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getDictionaryTextByValue = (dicCode: string, value: string | number) => {
|
|
39
|
+
let dicData = getDicData(dicCode);
|
|
40
|
+
|
|
41
|
+
if (value === undefined) return '';
|
|
42
|
+
|
|
43
|
+
const dicItemArray = dicData?.filter(
|
|
44
|
+
(item: { value: string }) => item.value === value.toString(),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (!dicItemArray?.length) {
|
|
48
|
+
// throw new Error(`当前${dicCode}字典值合没有${value}的数据`)
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return dicItemArray[0].text;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const loadSelectSource = (url: string, params?: any) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
axios
|
|
58
|
+
.get(`${url}?${stringify(params)}`)
|
|
59
|
+
.then((result: any) => {
|
|
60
|
+
result = result.data;
|
|
61
|
+
if (result.status !== '0') {
|
|
62
|
+
message.error(result.msg);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
resolve(result);
|
|
66
|
+
})
|
|
67
|
+
.catch((err) => {
|
|
68
|
+
reject(err);
|
|
69
|
+
});
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export function commonFun (type?: string) {
|
|
74
|
+
// 默认type === 'supplier' 供应商选择器
|
|
75
|
+
let requestConfig = {
|
|
76
|
+
url: `/bop/api/supplier`,
|
|
77
|
+
filter: 'qp-codeAndName-like', // 过滤参数
|
|
78
|
+
otherParams: {}, // 默认参数
|
|
79
|
+
mappingTextField: 'name',
|
|
80
|
+
mappingValueField: 'code',
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* 处理 格式化下拉框数据源
|
|
85
|
+
* reData 必传 promise返回响应的数据 格式为[{},{},{},...] Promise.all第一个参数数组有多少个数组长度就是多少,其中每个对象为每次请求的结果数据
|
|
86
|
+
* 每个结果数据格式为{ status: '0', msg: 'success', data: { items: [], total: 1, size: 1, page: 1 }, traceId: 'baba..'}
|
|
87
|
+
* position 必传 为获取Promise.all请求结果的位置
|
|
88
|
+
* changePosition 必传 为搜索表单Form中需要更改数据源的Item项的位置
|
|
89
|
+
* changeSearchForm 必传 为搜索表单Form数据
|
|
90
|
+
* */
|
|
91
|
+
const formatSource = (reData: any, position: number, changePosition: number,changeSearchForm: any) => {
|
|
92
|
+
const data = reData && reData[position]?.data?.items || [];
|
|
93
|
+
const formatData = data?.length ? data.map((v: any) => ({ text: v.name, value: v.code })) : [];
|
|
94
|
+
changeSearchForm[changePosition] = {...changeSearchForm[changePosition], initialSource: formatData}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let tableSearchForm: any [] = [];
|
|
98
|
+
if(type === 'supplier') {
|
|
99
|
+
tableSearchForm = [
|
|
100
|
+
{ name: 'qp-name-like', label: '客户名称' }, // field: { type: 'input', props: { placeholder: '请输入'}}
|
|
101
|
+
{ name: 'qp-code-like', label: '客户编码' },
|
|
102
|
+
{ name: 'qp-conglomerateCode-in', type: 'select', label: '归属集团', field: {
|
|
103
|
+
type: 'select',
|
|
104
|
+
props: {
|
|
105
|
+
mode: 'multiple',
|
|
106
|
+
notFoundContent: '暂无数据',
|
|
107
|
+
allowClear: true,
|
|
108
|
+
showSearch: true,
|
|
109
|
+
showArrow: true,
|
|
110
|
+
maxTagCount: 1,
|
|
111
|
+
optionFilterProp: 'children',
|
|
112
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
113
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
// remoteSource: {
|
|
117
|
+
// init: true, // 初始请求数据源
|
|
118
|
+
// url: '/bop/api/company',
|
|
119
|
+
// params: {
|
|
120
|
+
// pageSize: 5000,
|
|
121
|
+
// currentPage: 1,
|
|
122
|
+
// 'qp-companyType-eq': '30',
|
|
123
|
+
// },
|
|
124
|
+
// converter({ data }: any) {
|
|
125
|
+
// if (data?.items == undefined || data?.items?.length == 0) {
|
|
126
|
+
// return [];
|
|
127
|
+
// }
|
|
128
|
+
// return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
|
|
129
|
+
// },
|
|
130
|
+
// },
|
|
131
|
+
// initialSource: [{ text: '英伦宝贝儿童用品有限公司', value: 'A0001' }]
|
|
132
|
+
},
|
|
133
|
+
{ name: 'qp-accountingCode-in', type: 'select', label: '归属核算主体', field: {
|
|
134
|
+
type: 'select',
|
|
135
|
+
props: {
|
|
136
|
+
mode: 'multiple',
|
|
137
|
+
notFoundContent: '暂无数据',
|
|
138
|
+
allowClear: true,
|
|
139
|
+
showSearch: true,
|
|
140
|
+
showArrow: true,
|
|
141
|
+
maxTagCount: 1,
|
|
142
|
+
optionFilterProp: 'children',
|
|
143
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
144
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
// remoteSource: {
|
|
148
|
+
// init: true, // 初始请求数据源
|
|
149
|
+
// url: `/bop/api/accountingSubject`,
|
|
150
|
+
// params: {
|
|
151
|
+
// pageSize: 5000,
|
|
152
|
+
// currentPage: 1,
|
|
153
|
+
// },
|
|
154
|
+
// converter({ data }: any ) {
|
|
155
|
+
// if (data?.items == undefined || data?.items?.length == 0) {
|
|
156
|
+
// return [];
|
|
157
|
+
// }
|
|
158
|
+
// return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
|
|
159
|
+
// },
|
|
160
|
+
// },
|
|
161
|
+
// initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
|
|
162
|
+
},
|
|
163
|
+
{ name: 'qp-companyCode-in', type: 'select', label: '归属法人公司', field: {
|
|
164
|
+
type: 'select',
|
|
165
|
+
props: {
|
|
166
|
+
mode: 'multiple',
|
|
167
|
+
notFoundContent: '暂无数据',
|
|
168
|
+
allowClear: true,
|
|
169
|
+
showSearch: true,
|
|
170
|
+
showArrow: true,
|
|
171
|
+
maxTagCount: 1,
|
|
172
|
+
optionFilterProp: 'children',
|
|
173
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
174
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
// remoteSource: {
|
|
178
|
+
// init: true, // 初始请求数据源
|
|
179
|
+
// url: '/bop/api/company',
|
|
180
|
+
// params: {
|
|
181
|
+
// pageSize: 5000,
|
|
182
|
+
// currentPage: 1,
|
|
183
|
+
// 'qp-companyType-eq': '20',
|
|
184
|
+
// },
|
|
185
|
+
// converter: ({ data }: any) => {
|
|
186
|
+
// return data.items
|
|
187
|
+
// ? data.items.map((item: any) => {
|
|
188
|
+
// return {
|
|
189
|
+
// text: item.name,
|
|
190
|
+
// value: item.code,
|
|
191
|
+
// };
|
|
192
|
+
// })
|
|
193
|
+
// : [];
|
|
194
|
+
// },
|
|
195
|
+
// },
|
|
196
|
+
// initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
|
|
197
|
+
},
|
|
198
|
+
{ name: 'qp-sharingType-eq', type: 'select', label: '共享类型', initialSource: getDictionarySource('UC000013') },
|
|
199
|
+
]
|
|
200
|
+
Promise.all([
|
|
201
|
+
loadSelectSource('/bop/api/company', {
|
|
202
|
+
pageSize: 5000,
|
|
203
|
+
currentPage: 1,
|
|
204
|
+
'qp-companyType-eq': '30',
|
|
205
|
+
}),
|
|
206
|
+
loadSelectSource('/bop/api/accountingSubject', {
|
|
207
|
+
pageSize: 5000,
|
|
208
|
+
currentPage: 1,
|
|
209
|
+
}),
|
|
210
|
+
loadSelectSource('/bop/api/company', {
|
|
211
|
+
pageSize: 5000,
|
|
212
|
+
currentPage: 1,
|
|
213
|
+
'qp-companyType-eq': '20',
|
|
214
|
+
})
|
|
215
|
+
]).then((x: any)=>{
|
|
216
|
+
formatSource(x,0, 2, tableSearchForm);
|
|
217
|
+
formatSource(x,1, 3, tableSearchForm);
|
|
218
|
+
formatSource(x,2, 4, tableSearchForm);
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
let modalTableProps = {
|
|
222
|
+
modalTableTitle: '选择供应商',
|
|
223
|
+
tableSearchForm,
|
|
224
|
+
tableColumns: [
|
|
225
|
+
{
|
|
226
|
+
title: '客户编码',
|
|
227
|
+
dataIndex: 'code',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
title: '客户名称',
|
|
231
|
+
dataIndex: 'name',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
title: '归属集团',
|
|
235
|
+
dataIndex: 'conglomerateName',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
title: '归属法人公司',
|
|
239
|
+
dataIndex: 'legalCompanyName',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
title: '归属核算主体',
|
|
243
|
+
dataIndex: 'accountingName',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
title: '共享类型',
|
|
247
|
+
dataIndex: 'sharingType',
|
|
248
|
+
render: (text: number) => getDictionaryTextByValue('UC000013', text),
|
|
249
|
+
},
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// 商品选择器
|
|
254
|
+
if(type === 'commodity') {
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// 仓库选择器
|
|
259
|
+
if(type === 'warehouse') {
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return { modalTableProps, requestConfig };
|
|
264
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 业务组件
|
|
7
|
+
order: 4
|
|
8
|
+
title: 供应商选择器
|
|
9
|
+
order: 0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## BusinessSearchSelect
|
|
13
|
+
|
|
14
|
+
Demo:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useState } from 'react';
|
|
18
|
+
import { BusinessSearchSelect } from '@bit-sun/business-component';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
// selectBusinessType 必传(不传默认为供应商选择器)
|
|
22
|
+
|
|
23
|
+
const selectProps = {
|
|
24
|
+
// mode: 'multiple',
|
|
25
|
+
// maxTagCount: 1,
|
|
26
|
+
// disabled: true
|
|
27
|
+
}
|
|
28
|
+
const [value, setValue] = useState(selectProps?.mode ? [] : null);
|
|
29
|
+
const props = {
|
|
30
|
+
value,
|
|
31
|
+
// labelInValue: true, // 非必填 默认为false
|
|
32
|
+
// requestConfig: {
|
|
33
|
+
// url: `http://test.i-baby.net/bop/api/supplier`,
|
|
34
|
+
// filter: 'qp-name-like', // 过滤参数
|
|
35
|
+
// otherParams: {}, // 默认参数
|
|
36
|
+
// mappingTextField: 'name',
|
|
37
|
+
// mappingValueField: 'code',
|
|
38
|
+
// }, // 非必传,业务字段已根据业务默认默认
|
|
39
|
+
selectProps, // 非必传
|
|
40
|
+
onChange: (value: any) => {
|
|
41
|
+
console.log(value)
|
|
42
|
+
setValue(value)
|
|
43
|
+
},
|
|
44
|
+
selectBusinessType: 'supplier',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div>
|
|
49
|
+
<BusinessSearchSelect {...props} />
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
.search_select {
|
|
2
|
+
&_show {
|
|
3
|
+
display: flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
&_expand_button {
|
|
7
|
+
position: relative;
|
|
8
|
+
width: 30px;
|
|
9
|
+
color: #ffffff;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
|
|
12
|
+
span {
|
|
13
|
+
position: absolute;
|
|
14
|
+
height: 20px;
|
|
15
|
+
line-height: 14px;
|
|
16
|
+
left: 50%;
|
|
17
|
+
top: 50%;
|
|
18
|
+
transform: translate(-50%, -50%);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&_wrapper {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
min-height: 60vh;
|
|
26
|
+
max-height: 60vh;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
|
|
30
|
+
&_click_flag {
|
|
31
|
+
position: absolute;
|
|
32
|
+
z-index: 10;
|
|
33
|
+
&_arrow {
|
|
34
|
+
transform: rotate(0deg);
|
|
35
|
+
transition: transform 0.5s;
|
|
36
|
+
}
|
|
37
|
+
&_arrow_1 {
|
|
38
|
+
transform: rotate(-180deg);
|
|
39
|
+
transition: transform 0.5s;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&_left {
|
|
44
|
+
width: 28%;
|
|
45
|
+
overflow-y: hidden;
|
|
46
|
+
//background-color: yellow;
|
|
47
|
+
transition: all 0.3s;
|
|
48
|
+
margin-left: 20px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&_left1 {
|
|
52
|
+
width: 0;
|
|
53
|
+
height: 0;
|
|
54
|
+
transition: all 0.3s;
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&_right {
|
|
59
|
+
width: 70%;
|
|
60
|
+
margin-left: 1%;
|
|
61
|
+
//background-color: pink;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&_right1 {
|
|
65
|
+
width: 100%;
|
|
66
|
+
margin-left: 20px;
|
|
67
|
+
//background-color: green;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&_right, _right1 {
|
|
71
|
+
overflow-x: auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.select_list_columns {
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: calc(60vh - 60px);
|
|
77
|
+
overflow-y: auto;
|
|
78
|
+
border: 1px solid #d8d8d8;
|
|
79
|
+
&_tips {
|
|
80
|
+
background: #eee;
|
|
81
|
+
padding: 6px 20px;
|
|
82
|
+
margin-bottom: 10px;
|
|
83
|
+
}
|
|
84
|
+
&_formItems {
|
|
85
|
+
padding: 0 20px;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
.select_list_searchButton {
|
|
89
|
+
display: flex;
|
|
90
|
+
margin: 10px 0px;
|
|
91
|
+
justify-content: flex-end;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.select_list_button_space {
|
|
95
|
+
margin-right: 10px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.select_list_selectTips {
|
|
99
|
+
display: flex;
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
height: 34px;
|
|
102
|
+
line-height: 32px;
|
|
103
|
+
background-color: #eee;
|
|
104
|
+
margin-bottom: 10px;
|
|
105
|
+
padding: 0 12px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.select_list_selectAll {
|
|
109
|
+
position: relative;
|
|
110
|
+
top: -40px;
|
|
111
|
+
left: 20px;
|
|
112
|
+
width: 160px;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 组件
|
|
7
|
+
order: 0
|
|
8
|
+
title: 档案选择器
|
|
9
|
+
order: 2
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## SearchSelect
|
|
13
|
+
|
|
14
|
+
Demo:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useState } from 'react';
|
|
18
|
+
import { SearchSelect } from '@bit-sun/business-component';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
const selectProps = {
|
|
22
|
+
// mode: 'multiple',
|
|
23
|
+
// maxTagCount: 1,
|
|
24
|
+
}
|
|
25
|
+
const [value, setValue] = useState(selectProps?.mode ? [] : null);
|
|
26
|
+
const props = {
|
|
27
|
+
value,
|
|
28
|
+
// labelInValue: true, // 非必填 默认为false
|
|
29
|
+
requestConfig: {
|
|
30
|
+
url: `http://test.i-baby.net/bop/api/supplier`,
|
|
31
|
+
filter: 'qp-name-like', // 过滤参数
|
|
32
|
+
otherParams: {}, // 默认参数
|
|
33
|
+
mappingTextField: 'name',
|
|
34
|
+
mappingValueField: 'code',
|
|
35
|
+
},
|
|
36
|
+
selectProps,
|
|
37
|
+
onChange: (value: any) => {
|
|
38
|
+
console.log(value)
|
|
39
|
+
setValue(value)
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const DictionaryUC000013 = [{ text: '共享', value: '10' }, { text: '私有', value: '20' }]
|
|
43
|
+
const modalTableProps = {
|
|
44
|
+
modalTableTitle: '选择供应商',
|
|
45
|
+
tableSearchForm:[
|
|
46
|
+
{ name: 'qp-name-like', label: '客户名称' }, // field: { type: 'input', props: { placeholder: '8888'}}
|
|
47
|
+
{ name: 'qp-code-like', label: '客户编码' },
|
|
48
|
+
{ name: 'qp-conglomerateCode-in', type: 'select', label: '归属集团', field: {
|
|
49
|
+
type: 'select',
|
|
50
|
+
props: {
|
|
51
|
+
mode: 'multiple',
|
|
52
|
+
notFoundContent: '暂无数据',
|
|
53
|
+
allowClear: true,
|
|
54
|
+
showSearch: true,
|
|
55
|
+
showArrow: true,
|
|
56
|
+
maxTagCount: 1,
|
|
57
|
+
optionFilterProp: 'children',
|
|
58
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
59
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
initialSource: [{ text: '英伦宝贝儿童用品有限公司', value: 'A0001' }]
|
|
63
|
+
},
|
|
64
|
+
{ name: 'qp-accountingCode-in', type: 'select', label: '归属核算主体', field: {
|
|
65
|
+
type: 'select',
|
|
66
|
+
props: {
|
|
67
|
+
mode: 'multiple',
|
|
68
|
+
notFoundContent: '暂无数据',
|
|
69
|
+
allowClear: true,
|
|
70
|
+
showSearch: true,
|
|
71
|
+
showArrow: true,
|
|
72
|
+
maxTagCount: 1,
|
|
73
|
+
optionFilterProp: 'children',
|
|
74
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
75
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
|
|
79
|
+
},
|
|
80
|
+
{ name: 'qp-companyCode-in', type: 'select', label: '归属法人公司', field: {
|
|
81
|
+
type: 'select',
|
|
82
|
+
props: {
|
|
83
|
+
mode: 'multiple',
|
|
84
|
+
notFoundContent: '暂无数据',
|
|
85
|
+
allowClear: true,
|
|
86
|
+
showSearch: true,
|
|
87
|
+
showArrow: true,
|
|
88
|
+
maxTagCount: 1,
|
|
89
|
+
optionFilterProp: 'children',
|
|
90
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
91
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
|
|
95
|
+
},
|
|
96
|
+
{ name: 'qp-sharingType-eq', type: 'select', label: '共享类型', initialSource: DictionaryUC000013 }, // 页面可以直接使用getDictionarySource('UC000013')
|
|
97
|
+
],
|
|
98
|
+
tableColumns: [
|
|
99
|
+
{
|
|
100
|
+
title: '客户编码',
|
|
101
|
+
dataIndex: 'code',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
title: '客户名称',
|
|
105
|
+
dataIndex: 'name',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
title: '归属集团',
|
|
109
|
+
dataIndex: 'conglomerateName',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
title: '归属法人公司',
|
|
113
|
+
dataIndex: 'legalCompanyName',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
title: '归属核算主体',
|
|
117
|
+
dataIndex: 'accountingName',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
title: '共享类型',
|
|
121
|
+
dataIndex: 'sharingType',
|
|
122
|
+
render: (text) => DictionaryUC000013?.find((i) => i.value === text)?.text, // getDictionaryTextByValue('UC000013', text)
|
|
123
|
+
},
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<div>
|
|
129
|
+
<SearchSelect
|
|
130
|
+
{...props}
|
|
131
|
+
modalTableProps={modalTableProps}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|