@bit-sun/business-component 1.1.3 → 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 +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.md +22 -14
- package/src/components/SearchSelect/index.tsx +164 -93
- package/src/index.ts +1 -0
- package/dist/components/DataValidation/index.d.ts +0 -144
- package/dist/components/QueryMutipleInput/index.d.ts +0 -5
- package/dist/components/SearchSelect/index.d.ts +0 -9
- package/dist/index.d.ts +0 -4
- package/dist/index.esm.js +0 -3051
- package/dist/index.js +0 -3065
- package/dist/utils/CheckOneUser/index.d.ts +0 -2
package/package.json
CHANGED
|
@@ -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
|
|
@@ -14,20 +14,36 @@ order: 2
|
|
|
14
14
|
Demo:
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
-
import React, {
|
|
17
|
+
import React, { useState } from 'react';
|
|
18
18
|
import { SearchSelect } from '@bit-sun/business-component';
|
|
19
19
|
|
|
20
20
|
export default () => {
|
|
21
21
|
const selectProps = {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// mode: 'multiple',
|
|
23
|
+
// maxTagCount: 1,
|
|
24
24
|
}
|
|
25
|
-
|
|
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
|
+
};
|
|
26
42
|
const DictionaryUC000013 = [{ text: '共享', value: '10' }, { text: '私有', value: '20' }]
|
|
27
43
|
const modalTableProps = {
|
|
28
44
|
modalTableTitle: '选择供应商',
|
|
29
45
|
tableSearchForm:[
|
|
30
|
-
{ name: 'qp-name-like', label: '客户名称' }, // field: { type: 'input', props: { placeholder: '8888'}}
|
|
46
|
+
{ name: 'qp-name-like', label: '客户名称' }, // field: { type: 'input', props: { placeholder: '8888'}}
|
|
31
47
|
{ name: 'qp-code-like', label: '客户编码' },
|
|
32
48
|
{ name: 'qp-conglomerateCode-in', type: 'select', label: '归属集团', field: {
|
|
33
49
|
type: 'select',
|
|
@@ -108,19 +124,11 @@ export default () => {
|
|
|
108
124
|
]
|
|
109
125
|
}
|
|
110
126
|
|
|
111
|
-
const onValueChange = (value) => {
|
|
112
|
-
console.log(value)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
127
|
return (
|
|
116
128
|
<div>
|
|
117
129
|
<SearchSelect
|
|
118
|
-
|
|
119
|
-
// initValue={[{value: '20220105001', label: 'LH公司'}]} // 多选
|
|
120
|
-
selectProps={selectProps}
|
|
130
|
+
{...props}
|
|
121
131
|
modalTableProps={modalTableProps}
|
|
122
|
-
selectDataUrl='http://test.i-baby.net/bop/api/supplier'
|
|
123
|
-
onValueChange={onValueChange}
|
|
124
132
|
/>
|
|
125
133
|
</div>
|
|
126
134
|
);
|