@bit-sun/business-component 1.2.4-alpha.1 → 1.2.4
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/.fatherrc.ts +0 -1
- package/.umirc.ts +16 -31
- package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +1 -1
- package/dist/components/Business/SearchSelect/common.d.ts +1 -5
- package/dist/components/Business/SearchSelect/index.d.ts +1 -1
- package/dist/components/Business/SearchSelect/utils.d.ts +1 -2
- package/dist/components/Functional/SearchSelect/index.d.ts +1 -2
- package/dist/index.d.ts +0 -15
- package/dist/index.esm.js +4456 -19407
- package/dist/index.js +4443 -19411
- package/package.json +5 -26
- package/src/components/Business/CommodityEntry/index.md +3 -4
- package/src/components/Business/CommodityEntry/index.tsx +2 -7
- package/src/components/Business/SearchSelect/BusinessUtils.ts +14 -107
- package/src/components/Business/SearchSelect/common.ts +1 -20
- package/src/components/Business/SearchSelect/index.md +30 -60
- package/src/components/Business/SearchSelect/index.tsx +12 -21
- package/src/components/Business/SearchSelect/utils.ts +4 -30
- package/src/components/Functional/DataImport/index.tsx +2 -1
- package/src/components/Functional/DataValidation/index.tsx +1 -1
- package/src/components/Functional/SearchSelect/index.tsx +121 -218
- package/src/index.ts +6 -15
- package/typings.d.ts +0 -3
- package/dist/components/Business/AddSelectBusiness/index.d.ts +0 -1
- package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +0 -4
- package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +0 -4
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +0 -4
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +0 -17
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +0 -30
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +0 -3
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +0 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +0 -4
- package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +0 -4
- package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +0 -2
- package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +0 -8
- package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +0 -8
- package/dist/components/Business/BsLayouts/index.d.ts +0 -18
- package/dist/components/Business/BsLayouts/service.d.ts +0 -1
- package/dist/components/Business/BsLayouts/utils.d.ts +0 -13
- package/dist/components/Business/BsSulaQueryTable/index.d.ts +0 -2
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +0 -58
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +0 -98
- package/dist/components/Business/CommonAlert/index.d.ts +0 -3
- package/dist/components/Business/CommonGuideWrapper/index.d.ts +0 -6
- package/dist/components/Business/DetailPageWrapper/index.d.ts +0 -9
- package/dist/components/Business/DetailPageWrapper/utils.d.ts +0 -8
- package/dist/components/Business/HomePageWrapper/index.d.ts +0 -3
- package/dist/components/Business/StateFlow/index.d.ts +0 -3
- package/dist/components/Business/TreeSearchSelect/index.d.ts +0 -3
- package/dist/components/Business/TreeSearchSelect/utils.d.ts +0 -2
- package/dist/components/Business/columnSettingTable/columnSetting.d.ts +0 -54
- package/dist/components/Business/columnSettingTable/index.d.ts +0 -16
- package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +0 -17
- package/dist/components/Business/columnSettingTable/utils.d.ts +0 -8
- package/dist/components/Functional/AddSelect/index.d.ts +0 -3
- package/dist/components/Functional/BillEntry/index.d.ts +0 -4
- package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +0 -12
- package/dist/components/Functional/TreeSearchSelect/index.d.ts +0 -2
- package/dist/utils/enumConfig.d.ts +0 -10
- package/dist/utils/requestUtils.d.ts +0 -1
- package/dist/utils/utils.d.ts +0 -3
- package/lib/assets/arrow_top.png +0 -0
- package/lib/assets/drag.svg +0 -17
- package/lib/assets/exportFail.svg +0 -38
- package/lib/assets/exportProcessing.svg +0 -29
- package/lib/assets/exportSuccess.svg +0 -35
- package/lib/assets/exportlogo.png +0 -0
- package/lib/assets/label_icon_bottom.svg +0 -26
- package/lib/assets/upExport.svg +0 -23
- package/src/assets/32.svg +0 -28
- package/src/assets/addIcon.svg +0 -18
- package/src/assets/allfunc.svg +0 -28
- package/src/assets/arrowRight.svg +0 -25
- package/src/assets/arrow_top.png +0 -0
- package/src/assets/btn-delete.svg +0 -30
- package/src/assets/btn-edit.svg +0 -20
- package/src/assets/btn-more.svg +0 -18
- package/src/assets/btn-submit.svg +0 -20
- package/src/assets/caidan.svg +0 -12
- package/src/assets/close.svg +0 -26
- package/src/assets/closeicon.png +0 -0
- package/src/assets/drag.svg +0 -17
- package/src/assets/exportFail.svg +0 -38
- package/src/assets/exportProcessing.svg +0 -29
- package/src/assets/exportSuccess.svg +0 -35
- package/src/assets/exportlogo.png +0 -0
- package/src/assets/fixed-left-active.svg +0 -12
- package/src/assets/fixed-left.svg +0 -16
- package/src/assets/fixed-right-active.svg +0 -12
- package/src/assets/fixed-right.svg +0 -16
- package/src/assets/guanbi.svg +0 -16
- package/src/assets/icon-quanping.svg +0 -16
- package/src/assets/icon-shezhi.svg +0 -18
- package/src/assets/label_icon_bottom.svg +0 -26
- package/src/assets/list-no-img.svg +0 -22
- package/src/assets/morentouxiang-32.svg +0 -24
- package/src/assets/right.png +0 -0
- package/src/assets/scanning.svg +0 -25
- package/src/assets/upExport.svg +0 -23
- package/src/assets/xinglan-icon-out.png +0 -0
- package/src/components/Business/AddSelectBusiness/index.md +0 -41
- package/src/components/Business/AddSelectBusiness/index.tsx +0 -290
- package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +0 -112
- package/src/components/Business/BsLayouts/Components/AllFunc/index.less +0 -153
- package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +0 -70
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +0 -90
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +0 -38
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +0 -243
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +0 -385
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +0 -286
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +0 -75
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +0 -171
- package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +0 -65
- package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +0 -154
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +0 -73
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +0 -158
- package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +0 -85
- package/src/components/Business/BsLayouts/Components/RightContent/home.less +0 -218
- package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +0 -156
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +0 -161
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +0 -76
- package/src/components/Business/BsLayouts/index.less +0 -80
- package/src/components/Business/BsLayouts/index.tsx +0 -1465
- package/src/components/Business/BsLayouts/service.ts +0 -11
- package/src/components/Business/BsLayouts/utils.tsx +0 -211
- package/src/components/Business/BsSulaQueryTable/index.less +0 -220
- package/src/components/Business/BsSulaQueryTable/index.tsx +0 -505
- package/src/components/Business/BsSulaQueryTable/setting.tsx +0 -799
- package/src/components/Business/BsSulaQueryTable/utils.less +0 -65
- package/src/components/Business/BsSulaQueryTable/utils.tsx +0 -688
- package/src/components/Business/CommonAlert/index.less +0 -0
- package/src/components/Business/CommonAlert/index.tsx +0 -23
- package/src/components/Business/CommonGuideWrapper/index.less +0 -112
- package/src/components/Business/CommonGuideWrapper/index.md +0 -39
- package/src/components/Business/CommonGuideWrapper/index.tsx +0 -84
- package/src/components/Business/DetailPageWrapper/index.less +0 -80
- package/src/components/Business/DetailPageWrapper/index.tsx +0 -335
- package/src/components/Business/DetailPageWrapper/utils.tsx +0 -101
- package/src/components/Business/HomePageWrapper/index.less +0 -33
- package/src/components/Business/HomePageWrapper/index.md +0 -45
- package/src/components/Business/HomePageWrapper/index.tsx +0 -162
- package/src/components/Business/StateFlow/index.less +0 -131
- package/src/components/Business/StateFlow/index.md +0 -60
- package/src/components/Business/StateFlow/index.tsx +0 -30
- package/src/components/Business/TreeSearchSelect/index.md +0 -126
- package/src/components/Business/TreeSearchSelect/index.tsx +0 -34
- package/src/components/Business/TreeSearchSelect/utils.ts +0 -60
- package/src/components/Business/columnSettingTable/columnSetting.tsx +0 -764
- package/src/components/Business/columnSettingTable/index.less +0 -247
- package/src/components/Business/columnSettingTable/index.md +0 -358
- package/src/components/Business/columnSettingTable/index.tsx +0 -233
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +0 -241
- package/src/components/Business/columnSettingTable/utils.tsx +0 -69
- package/src/components/Functional/AddSelect/index.less +0 -367
- package/src/components/Functional/AddSelect/index.md +0 -122
- package/src/components/Functional/AddSelect/index.tsx +0 -962
- package/src/components/Functional/BillEntry/index.less +0 -371
- package/src/components/Functional/BillEntry/index.md +0 -39
- package/src/components/Functional/BillEntry/index.tsx +0 -613
- package/src/components/Functional/ExportFunctions/ExportIcon/index.md +0 -37
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +0 -59
- package/src/components/Functional/TreeSearchSelect/index.md +0 -47
- package/src/components/Functional/TreeSearchSelect/index.tsx +0 -149
- package/src/styles/bsDefault.less +0 -1907
- package/src/utils/enumConfig.ts +0 -10
- package/src/utils/requestUtils.ts +0 -33
- package/src/utils/utils.ts +0 -52
|
@@ -1,43 +1,30 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import React, { useState, useEffect
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import { useDebounceFn } from 'ahooks';
|
|
4
4
|
import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
|
|
5
5
|
import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import { stringify } from 'querystring';
|
|
8
|
-
import _ from "
|
|
8
|
+
import _ from "loadsh"
|
|
9
9
|
import './index.less';
|
|
10
|
-
import { BusinessSearchSelect
|
|
10
|
+
import { BusinessSearchSelect } from '@/index';
|
|
11
11
|
|
|
12
12
|
const { Option } = Select;
|
|
13
13
|
|
|
14
|
-
const SearchSelect =
|
|
14
|
+
const SearchSelect = (props: any) => {
|
|
15
15
|
const {
|
|
16
16
|
value, // 必传
|
|
17
17
|
onChange,
|
|
18
|
-
selectProps
|
|
19
|
-
modalTableProps
|
|
20
|
-
labelInValue
|
|
18
|
+
selectProps={},
|
|
19
|
+
modalTableProps={},
|
|
20
|
+
labelInValue=false,
|
|
21
21
|
requestConfig,
|
|
22
22
|
ctx,
|
|
23
23
|
sourceName,
|
|
24
|
-
needModalTable
|
|
25
|
-
getPopupContainer
|
|
26
|
-
fieldComponent,
|
|
24
|
+
needModalTable=true,
|
|
25
|
+
getPopupContainer=undefined
|
|
27
26
|
} = props;
|
|
28
|
-
const {
|
|
29
|
-
url,
|
|
30
|
-
otherParams,// 默认参数
|
|
31
|
-
isMap,
|
|
32
|
-
fixedparameter,
|
|
33
|
-
fieldValToParam,
|
|
34
|
-
mappingTextField = 'name',
|
|
35
|
-
mappingTextShowKeyField,
|
|
36
|
-
mappingValueField = 'code',
|
|
37
|
-
mappingTextShowTextField,
|
|
38
|
-
init = true,// 是否初始请求
|
|
39
|
-
extralHeaders = {},// 额外请求头参数
|
|
40
|
-
} = requestConfig || {};
|
|
27
|
+
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingTextShowKeyField,mappingValueField='code', mappingTextShowTextField } = requestConfig || {};
|
|
41
28
|
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
42
29
|
|
|
43
30
|
const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
|
|
@@ -46,7 +33,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
46
33
|
const tableInitPageSize = 10 // 弹框默认分页 条数
|
|
47
34
|
const currentPage = 1
|
|
48
35
|
const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
|
|
49
|
-
const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
|
|
50
36
|
const currentSelectProps = {
|
|
51
37
|
...selectProps,
|
|
52
38
|
// 以下属性不可更改----设计配置项
|
|
@@ -70,16 +56,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
70
56
|
(v?: any) => {
|
|
71
57
|
// 优化搜索参数 支持传多个
|
|
72
58
|
let searchParams = {};
|
|
73
|
-
if
|
|
74
|
-
|
|
75
|
-
if (labelInValue) {
|
|
76
|
-
selectParamsInitValue = Array.isArray(initVal) ? initVal.map((i: any) => i.value || i.key).join(',') : initVal
|
|
77
|
-
} else {
|
|
78
|
-
selectParamsInitValue = Array.isArray(initVal) ? initVal.join(',') : initVal
|
|
79
|
-
}
|
|
80
|
-
searchParams = v ? { [selectParamsInitKey]: selectParamsInitValue } : { [selectParamsKey]: searchValue }
|
|
59
|
+
if(typeof selectParamsKey === 'string') {
|
|
60
|
+
searchParams = { [selectParamsKey]: v ? initVal : searchValue }
|
|
81
61
|
}
|
|
82
|
-
if
|
|
62
|
+
if(Array.isArray(selectParamsKey)) {
|
|
83
63
|
selectParamsKey.forEach((i: any) => {
|
|
84
64
|
searchParams = { ...searchParams, [i]: searchValue }
|
|
85
65
|
})
|
|
@@ -103,28 +83,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
103
83
|
const [tableFormParams, setTableFormParams] = useState({});
|
|
104
84
|
const [tooltipVisible, setTooltipVisible] = useState(false);
|
|
105
85
|
|
|
106
|
-
useImperativeHandle(ref, () => ({
|
|
107
|
-
refreshDataSource: (reset: boolean = false) => {
|
|
108
|
-
if (reset) {
|
|
109
|
-
if (init) {
|
|
110
|
-
run('init');
|
|
111
|
-
} else {
|
|
112
|
-
setItems([]);
|
|
113
|
-
setItemsTotal(0);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
run();
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
clearDataSource: () => {
|
|
120
|
-
setItems([]);
|
|
121
|
-
setItemsTotal(0);
|
|
122
|
-
},
|
|
123
|
-
getTableFormRef: () => form,
|
|
124
|
-
}))
|
|
125
|
-
|
|
126
86
|
// 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
|
|
127
|
-
const getData = (params
|
|
87
|
+
const getData = (params={}, type=1) => {
|
|
128
88
|
if (!requestConfig) return;
|
|
129
89
|
|
|
130
90
|
setFetching(true)
|
|
@@ -184,13 +144,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
184
144
|
delete params[key];
|
|
185
145
|
} else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
|
|
186
146
|
const dataParams = key.split('*checkBox*');
|
|
187
|
-
if
|
|
147
|
+
if(element){
|
|
188
148
|
params[dataParams[0]] = 0
|
|
189
149
|
}
|
|
190
150
|
delete params[key];
|
|
191
|
-
}
|
|
151
|
+
}else if (element && key.indexOf('*cascader*') >= 0) {
|
|
192
152
|
const dataParams = key.split('*cascader*');
|
|
193
|
-
params[dataParams[0]] = element[element.length -
|
|
153
|
+
params[dataParams[0]] = element[element.length -1]
|
|
194
154
|
delete params[key];
|
|
195
155
|
} else if (element && key.indexOf('*date*') >= 0) {
|
|
196
156
|
const dataParams = key.split('*date*')
|
|
@@ -224,9 +184,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
224
184
|
params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
|
|
225
185
|
}
|
|
226
186
|
delete params[key]
|
|
227
|
-
}
|
|
187
|
+
}else if (Array.isArray(element)) {
|
|
228
188
|
params[key] = element.join(',');
|
|
229
|
-
} else if
|
|
189
|
+
} else if(element == null || element === undefined || String(element).trim() === '') {
|
|
230
190
|
delete params[key]
|
|
231
191
|
}
|
|
232
192
|
}
|
|
@@ -241,15 +201,11 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
241
201
|
}
|
|
242
202
|
|
|
243
203
|
axios
|
|
244
|
-
.get(
|
|
245
|
-
`${url}?${stringify(queryParams)}`,
|
|
246
|
-
{
|
|
247
|
-
headers: { ...extralHeaders }
|
|
248
|
-
})
|
|
204
|
+
.get(`${url}?${stringify(queryParams)}`)
|
|
249
205
|
.then((result: any) => {
|
|
250
206
|
setFetching(false)
|
|
251
207
|
result = result.data;
|
|
252
|
-
if (
|
|
208
|
+
if (result.status !== '0') {
|
|
253
209
|
message.error(result.msg);
|
|
254
210
|
return;
|
|
255
211
|
}
|
|
@@ -268,9 +224,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
268
224
|
? res[keys]
|
|
269
225
|
? res[keys].map((item: any) => {
|
|
270
226
|
let textShowText = item[mappingTextField]
|
|
271
|
-
if
|
|
227
|
+
if(mappingTextShowTextField) {
|
|
272
228
|
textShowText = []
|
|
273
|
-
if
|
|
229
|
+
if(Array.isArray(mappingTextShowTextField)) {
|
|
274
230
|
mappingTextShowTextField.forEach((r: any) => {
|
|
275
231
|
textShowText.push(item[r])
|
|
276
232
|
})
|
|
@@ -289,9 +245,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
289
245
|
: Array.isArray(res) &&
|
|
290
246
|
res?.map((item: Record<string, any>) => {
|
|
291
247
|
let textShowText = item[mappingTextField]
|
|
292
|
-
if
|
|
248
|
+
if(mappingTextShowTextField) {
|
|
293
249
|
textShowText = []
|
|
294
|
-
if
|
|
250
|
+
if(Array.isArray(mappingTextShowTextField)) {
|
|
295
251
|
mappingTextShowTextField.forEach((r: any) => {
|
|
296
252
|
textShowText.push(item[r])
|
|
297
253
|
})
|
|
@@ -310,13 +266,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
310
266
|
: [];
|
|
311
267
|
}
|
|
312
268
|
source = Array.isArray(source) ? source : []
|
|
313
|
-
if
|
|
269
|
+
if(type === 1) {
|
|
314
270
|
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
315
271
|
setItems(source)
|
|
316
272
|
setItemsTotal(Number(res?.total || res?.totalCount || source.length))
|
|
317
273
|
} else {
|
|
318
274
|
setTableData(source)
|
|
319
|
-
setTablePagination({
|
|
275
|
+
setTablePagination({...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage))})
|
|
320
276
|
}
|
|
321
277
|
})
|
|
322
278
|
.catch((err) => { setFetching(false) });
|
|
@@ -333,29 +289,28 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
333
289
|
if (isTouchGround && canPageAdd) {
|
|
334
290
|
const nextScrollPage = scrollPage + 1;
|
|
335
291
|
setScrollPage(nextScrollPage);
|
|
336
|
-
getData({
|
|
292
|
+
getData({currentPage: nextScrollPage}); // 调用api方法
|
|
337
293
|
}
|
|
338
294
|
|
|
339
295
|
//判断是否滑动到顶部
|
|
340
|
-
const isTouchTop = target.scrollTop ===
|
|
296
|
+
const isTouchTop = target.scrollTop ===0 // <=0
|
|
341
297
|
// 判断数据是否到第一页
|
|
342
298
|
const canPageJian = scrollPage > 1
|
|
343
299
|
if (isTouchTop && canPageJian) {
|
|
344
300
|
const preScrollPage = scrollPage - 1;
|
|
345
301
|
setScrollPage(preScrollPage);
|
|
346
|
-
getData({
|
|
302
|
+
getData({currentPage: preScrollPage}); // 调用api方法
|
|
347
303
|
}
|
|
348
304
|
}
|
|
349
305
|
|
|
350
306
|
useEffect(() => {
|
|
351
|
-
|
|
352
|
-
run('init')
|
|
353
|
-
}
|
|
307
|
+
run('init')
|
|
354
308
|
}, [])
|
|
355
309
|
|
|
356
310
|
useEffect(() => {
|
|
357
|
-
if
|
|
311
|
+
if(value) {
|
|
358
312
|
setPopValue(value);
|
|
313
|
+
onChange(value);
|
|
359
314
|
}
|
|
360
315
|
}, [value]);
|
|
361
316
|
|
|
@@ -367,14 +322,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
367
322
|
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
368
323
|
setIsModalVisible(true);
|
|
369
324
|
// 回显
|
|
370
|
-
if
|
|
371
|
-
if
|
|
325
|
+
if(value) {
|
|
326
|
+
if(selectMode) {
|
|
372
327
|
setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
|
|
373
328
|
setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
|
|
374
329
|
setIndeterminate(!!value.length && value.length < itemsTotal);
|
|
375
330
|
setCheckedAll(itemsTotal && value.length === itemsTotal);
|
|
376
331
|
// 需清空数据
|
|
377
|
-
if
|
|
332
|
+
if(!value.length) {
|
|
378
333
|
setDoubleArr([])
|
|
379
334
|
}
|
|
380
335
|
} else {
|
|
@@ -385,7 +340,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
385
340
|
};
|
|
386
341
|
|
|
387
342
|
const handleSelectOver = (selectedValue: any) => {
|
|
388
|
-
if
|
|
343
|
+
if(selectedValue?.length) {
|
|
389
344
|
formaData(selectedValue);
|
|
390
345
|
// 解决选择最后1页的sku,返回后,不显示名称问题
|
|
391
346
|
const source = _.uniqBy(items.concat(selectedValue), 'value')
|
|
@@ -400,8 +355,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
400
355
|
};
|
|
401
356
|
|
|
402
357
|
const formaData = (value) => {
|
|
403
|
-
if
|
|
404
|
-
const formatResult = value.map((i: any) => ({ key: i
|
|
358
|
+
if(labelInValue) {
|
|
359
|
+
const formatResult = value.map((i: any) => ({ key: i.code, label: i.name, value: i.code }))
|
|
405
360
|
onChange(selectMode ? formatResult : formatResult[0])
|
|
406
361
|
} else {
|
|
407
362
|
const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
|
|
@@ -413,45 +368,26 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
413
368
|
form.resetFields();
|
|
414
369
|
setTableFormParams({});
|
|
415
370
|
setIsModalVisible(false);
|
|
416
|
-
if
|
|
371
|
+
if(selectMode) {
|
|
417
372
|
run();
|
|
418
373
|
}
|
|
419
374
|
};
|
|
420
375
|
|
|
421
|
-
const refreshItems = () => {
|
|
422
|
-
// 查看是否存在关联值 如果有关联值 就查询 没有就不能查询
|
|
423
|
-
if (fieldValToParam && ctx) {
|
|
424
|
-
let formValueList = [];
|
|
425
|
-
fieldValToParam.forEach((item: any, index: any) => {
|
|
426
|
-
const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
|
|
427
|
-
formValueList.push(fixedParamVal);
|
|
428
|
-
});
|
|
429
|
-
if (formValueList.filter((item: any) => item).length > 0) {
|
|
430
|
-
run();
|
|
431
|
-
} else {
|
|
432
|
-
setItems([]);
|
|
433
|
-
setItemsTotal(0);
|
|
434
|
-
}
|
|
435
|
-
} else {
|
|
436
|
-
run();
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
376
|
const onSearchChange = (e) => {
|
|
441
377
|
setSearchValue(e.target.value);
|
|
442
|
-
|
|
378
|
+
run();
|
|
443
379
|
}
|
|
444
380
|
|
|
445
381
|
const onSearchBlur = () => {
|
|
446
|
-
setSearchValue('')
|
|
447
|
-
|
|
382
|
+
setSearchValue('')
|
|
383
|
+
run();
|
|
448
384
|
}
|
|
449
385
|
|
|
450
386
|
const onSearchTable = () => {
|
|
451
387
|
const params = form.getFieldsValue();
|
|
452
388
|
setTableFormParams(params);
|
|
453
389
|
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
454
|
-
if
|
|
390
|
+
if(selectMode){
|
|
455
391
|
getData(params)
|
|
456
392
|
}
|
|
457
393
|
}
|
|
@@ -467,18 +403,18 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
467
403
|
}
|
|
468
404
|
|
|
469
405
|
const onChangeCheckAll = (e) => {
|
|
470
|
-
if
|
|
406
|
+
if(e.target.checked) {
|
|
471
407
|
// 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
|
|
472
408
|
// 如果超过100条 就默认查出所有数据
|
|
473
409
|
const currentItemsData = JSON.parse(JSON.stringify(items))
|
|
474
410
|
const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize)
|
|
475
|
-
for
|
|
476
|
-
doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize
|
|
411
|
+
for(let i=0; i <= totalPage-1; i++){
|
|
412
|
+
doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize*i,tablePagination?.pageSize*(i+1))
|
|
477
413
|
}
|
|
478
414
|
setDoubleArr(doubleArr)
|
|
479
415
|
setSelectedRowKeys(currentItemsData.map(i => i.value))
|
|
480
416
|
setPopValue(currentItemsData);
|
|
481
|
-
if
|
|
417
|
+
if(items.length < itemsTotal) {
|
|
482
418
|
// TODO 请求接口获取所有数据
|
|
483
419
|
}
|
|
484
420
|
} else {
|
|
@@ -530,13 +466,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
530
466
|
return res.filter(Boolean); //去掉undefined的情况
|
|
531
467
|
};
|
|
532
468
|
|
|
533
|
-
const onChangeSelectedKeys
|
|
469
|
+
const onChangeSelectedKeys=(selectKeys,selectRows) => {
|
|
534
470
|
const nowPage = tablePagination?.current;
|
|
535
471
|
|
|
536
472
|
let filterRows = []; // 存放拼接后的一维数组的变量
|
|
537
473
|
let sksResult = [];
|
|
538
474
|
|
|
539
|
-
if
|
|
475
|
+
if(selectMode) {
|
|
540
476
|
// 处理多选分页累计选中
|
|
541
477
|
// 勾选生成二维数组
|
|
542
478
|
doubleArr[nowPage ? nowPage - 1 : 0] = selectRows
|
|
@@ -564,7 +500,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
564
500
|
|
|
565
501
|
// 生成唯一值
|
|
566
502
|
const makeUniqueValue = () => {
|
|
567
|
-
const generateUnitKey = (((1
|
|
503
|
+
const generateUnitKey = (((1+Math.random())*0x10000)|0).toString(16);
|
|
568
504
|
setUniqueValue(generateUnitKey);
|
|
569
505
|
return generateUnitKey;
|
|
570
506
|
}
|
|
@@ -575,17 +511,12 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
575
511
|
onChange: (sks, srs) => {
|
|
576
512
|
onChangeSelectedKeys(sks, srs)
|
|
577
513
|
},
|
|
578
|
-
getCheckboxProps: () => {
|
|
579
|
-
return ({
|
|
580
|
-
disabled: selectProps?.disabled || props?.disabled || !items.length,
|
|
581
|
-
})
|
|
582
|
-
},
|
|
583
514
|
};
|
|
584
515
|
|
|
585
516
|
const onDoubleClickSelect = (e, record) => {
|
|
586
|
-
if
|
|
517
|
+
if(!selectMode) {
|
|
587
518
|
const srs = [JSON.parse(JSON.stringify(record))]
|
|
588
|
-
const sks = srs.map((i:
|
|
519
|
+
const sks = srs.map((i:any) => i.value)
|
|
589
520
|
onChangeSelectedKeys(sks, srs)
|
|
590
521
|
}
|
|
591
522
|
}
|
|
@@ -593,20 +524,12 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
593
524
|
const themeColor = { color: '#1890ff' }
|
|
594
525
|
|
|
595
526
|
const formItem = (list) => {
|
|
596
|
-
if
|
|
597
|
-
const setDisabled = (name: any) => {
|
|
598
|
-
const { fixedparamsDisabled = false, fixedparameter = [] }: any = requestConfig;
|
|
599
|
-
if (fixedparamsDisabled && fixedparameter.find((item: any) => item === name)) {
|
|
600
|
-
return true
|
|
601
|
-
} else {
|
|
602
|
-
return false
|
|
603
|
-
}
|
|
604
|
-
};
|
|
527
|
+
if(isModalVisible && list?.length) {
|
|
605
528
|
return list.map((i: any) => {
|
|
606
|
-
if
|
|
529
|
+
if(i?.type === 'select' || i?.field?.type === 'select') {
|
|
607
530
|
return (
|
|
608
531
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
609
|
-
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}
|
|
532
|
+
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}>
|
|
610
533
|
{i?.initialSource?.length && i?.initialSource.map((m: any) => (
|
|
611
534
|
<Option value={m.value} key={m.value}>{m.text}</Option>
|
|
612
535
|
))}
|
|
@@ -615,42 +538,28 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
615
538
|
)
|
|
616
539
|
}
|
|
617
540
|
|
|
618
|
-
if
|
|
541
|
+
if(i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
|
|
619
542
|
return (
|
|
620
543
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
621
|
-
<TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}
|
|
544
|
+
<TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}></TreeSelect>
|
|
622
545
|
</Form.Item>
|
|
623
546
|
)
|
|
624
547
|
}
|
|
625
548
|
|
|
626
|
-
if
|
|
549
|
+
if(i?.type === 'businessSearchSelect') {
|
|
627
550
|
return (
|
|
628
551
|
<div>
|
|
629
552
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
630
|
-
<BusinessSearchSelect {...i.field.props}
|
|
553
|
+
<BusinessSearchSelect {...i.field.props} />
|
|
631
554
|
</Form.Item>
|
|
632
555
|
</div>
|
|
633
556
|
)
|
|
634
557
|
}
|
|
635
558
|
|
|
636
|
-
if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
|
|
637
|
-
return (
|
|
638
|
-
<div>
|
|
639
|
-
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
640
|
-
<QueryMutipleInput onValueChange={(value) => {
|
|
641
|
-
form.setFieldsValue({
|
|
642
|
-
[i.name]: value
|
|
643
|
-
})
|
|
644
|
-
}} />
|
|
645
|
-
</Form.Item>
|
|
646
|
-
</div>
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
|
|
650
559
|
// 默认type是input
|
|
651
560
|
return (
|
|
652
561
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
653
|
-
<Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props}
|
|
562
|
+
<Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
|
|
654
563
|
</Form.Item>
|
|
655
564
|
)
|
|
656
565
|
})
|
|
@@ -660,16 +569,16 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
660
569
|
}
|
|
661
570
|
|
|
662
571
|
const maxTagPlaceholder = (selectedValues) => {
|
|
663
|
-
const onClose = (e: any,
|
|
572
|
+
const onClose = (e: any,item: any) => {
|
|
664
573
|
e.preventDefault();
|
|
665
|
-
const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value)
|
|
574
|
+
const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value): JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
|
|
666
575
|
onChange(newValue);
|
|
667
576
|
}
|
|
668
577
|
return (
|
|
669
578
|
<Tooltip title={selectedValues.map((i: any) => (
|
|
670
579
|
<Tag
|
|
671
580
|
closable={true}
|
|
672
|
-
onClose={(e) => onClose(e,
|
|
581
|
+
onClose={(e) => onClose(e,i)}
|
|
673
582
|
style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
|
|
674
583
|
>
|
|
675
584
|
{i.label}
|
|
@@ -682,63 +591,57 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
682
591
|
|
|
683
592
|
return (
|
|
684
593
|
<div className={'search_select'}>
|
|
685
|
-
{
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
e.stopPropagation()
|
|
708
|
-
}}
|
|
709
|
-
/>
|
|
710
|
-
<Divider style={{ margin: '8px 0' }} />
|
|
711
|
-
{menu}
|
|
712
|
-
</>
|
|
713
|
-
)}
|
|
714
|
-
notFoundContent={
|
|
715
|
-
fetching ? <Spin size="small" /> :
|
|
716
|
-
<div style={{ textAlign: 'center' }}>
|
|
717
|
-
<div style={{ marginBottom: 16 }}>
|
|
718
|
-
<CopyOutlined style={{ fontSize: '50px' }} />
|
|
719
|
-
</div>
|
|
720
|
-
<div>无匹配结果,请更换其他内容再试</div>
|
|
721
|
-
</div>
|
|
722
|
-
}
|
|
723
|
-
onPopupScroll={SelectScroll}
|
|
724
|
-
style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
|
|
725
|
-
placeholder="请选择"
|
|
726
|
-
maxTagPlaceholder={maxTagPlaceholder}
|
|
727
|
-
{...currentSelectProps}
|
|
728
|
-
getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
|
|
729
|
-
>
|
|
730
|
-
{items.map(item => (
|
|
731
|
-
<Option key={item.value} label={item.text}>
|
|
732
|
-
{LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
|
|
733
|
-
</Option>
|
|
734
|
-
))}
|
|
735
|
-
</Select>
|
|
736
|
-
{needModalTable && (
|
|
737
|
-
<Button style={{ width: '30px', padding: '2px', height: 'auto' }} onClick={showModal} type="primary">
|
|
738
|
-
<SearchOutlined />
|
|
739
|
-
</Button>
|
|
594
|
+
<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
|
|
595
|
+
<Select
|
|
596
|
+
virtual
|
|
597
|
+
labelInValue={labelInValue}
|
|
598
|
+
value={value}
|
|
599
|
+
onChange={onChange}
|
|
600
|
+
dropdownRender={menu => (
|
|
601
|
+
<>
|
|
602
|
+
<Input
|
|
603
|
+
value={searchValue}
|
|
604
|
+
style={{ width: '98%', marginLeft: '1%' }}
|
|
605
|
+
placeholder="请输入"
|
|
606
|
+
onChange={e=> onSearchChange(e)}
|
|
607
|
+
onBlur={onSearchBlur}
|
|
608
|
+
onKeyDown={(e) => {
|
|
609
|
+
// 阻止多选的冒泡
|
|
610
|
+
e.stopPropagation()
|
|
611
|
+
}}
|
|
612
|
+
/>
|
|
613
|
+
<Divider style={{ margin: '8px 0' }} />
|
|
614
|
+
{menu}
|
|
615
|
+
</>
|
|
740
616
|
)}
|
|
741
|
-
|
|
617
|
+
notFoundContent={
|
|
618
|
+
fetching ? <Spin size="small" /> :
|
|
619
|
+
<div style={{ textAlign: 'center'}}>
|
|
620
|
+
<div style={{ marginBottom: 16 }}>
|
|
621
|
+
<CopyOutlined style={{ fontSize: '50px' }} />
|
|
622
|
+
</div>
|
|
623
|
+
<div>无匹配结果,请更换其他内容再试</div>
|
|
624
|
+
</div>
|
|
625
|
+
}
|
|
626
|
+
onPopupScroll={SelectScroll}
|
|
627
|
+
style={{ width: needModalTable?'calc(100% - 30px)':'calc(100%)' }}
|
|
628
|
+
placeholder="请选择"
|
|
629
|
+
maxTagPlaceholder={maxTagPlaceholder}
|
|
630
|
+
{...currentSelectProps}
|
|
631
|
+
getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
|
|
632
|
+
>
|
|
633
|
+
{items.map(item => (
|
|
634
|
+
<Option key={item.value} label={item.text}>
|
|
635
|
+
{LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
|
|
636
|
+
</Option>
|
|
637
|
+
))}
|
|
638
|
+
</Select>
|
|
639
|
+
{needModalTable && (
|
|
640
|
+
<Button style={{width: '30px', padding: '2px', height: 'auto'}} onClick={showModal} type="primary">
|
|
641
|
+
<SearchOutlined />
|
|
642
|
+
</Button>
|
|
643
|
+
)}
|
|
644
|
+
</div>
|
|
742
645
|
{needModalTable && isModalVisible && (
|
|
743
646
|
<Modal
|
|
744
647
|
width='80%'
|
|
@@ -746,7 +649,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
746
649
|
visible={isModalVisible}
|
|
747
650
|
onOk={handleOk}
|
|
748
651
|
onCancel={handleCancel}
|
|
749
|
-
footer={selectMode
|
|
652
|
+
footer={selectMode?[
|
|
750
653
|
<Button key="back" onClick={handleCancel}>
|
|
751
654
|
取消
|
|
752
655
|
</Button>,
|
|
@@ -758,11 +661,11 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
758
661
|
>
|
|
759
662
|
确定
|
|
760
663
|
</Button>,
|
|
761
|
-
]
|
|
664
|
+
]:null}
|
|
762
665
|
>
|
|
763
666
|
<div className={'search_select_wrapper'}>
|
|
764
667
|
<div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
|
|
765
|
-
<CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1'} />
|
|
668
|
+
<CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1' } />
|
|
766
669
|
</div>
|
|
767
670
|
<div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
|
|
768
671
|
<div className={'select_list_columns'}>
|
|
@@ -774,11 +677,11 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
774
677
|
</div>
|
|
775
678
|
</div>
|
|
776
679
|
<div className={'select_list_searchButton'}>
|
|
777
|
-
<Button key='reset' className={'select_list_button_space'}
|
|
680
|
+
<Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
|
|
778
681
|
<Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
|
|
779
682
|
</div>
|
|
780
683
|
</div>
|
|
781
|
-
<div className={caretLeftFlag ? 'search_select_wrapper_right'
|
|
684
|
+
<div className={caretLeftFlag ? 'search_select_wrapper_right': 'search_select_wrapper_right1'}>
|
|
782
685
|
<div>
|
|
783
686
|
<div className={'select_list_selectTips'}>
|
|
784
687
|
<div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
|
|
@@ -799,7 +702,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
799
702
|
};
|
|
800
703
|
}}
|
|
801
704
|
/>
|
|
802
|
-
{selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll}
|
|
705
|
+
{selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} /> 全选所有页面</div> : ''}
|
|
803
706
|
</div>
|
|
804
707
|
</div>
|
|
805
708
|
</div>
|
|
@@ -807,6 +710,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
807
710
|
)}
|
|
808
711
|
</div>
|
|
809
712
|
);
|
|
810
|
-
}
|
|
713
|
+
};
|
|
811
714
|
|
|
812
715
|
export default SearchSelect;
|