@bit-sun/business-component 1.1.35 → 1.1.38
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/.editorconfig +16 -16
- package/.fatherrc.ts +4 -4
- package/.gitlab-ci.yml +174 -174
- package/.prettierignore +7 -7
- package/.prettierrc +11 -11
- package/.umirc.ts +28 -28
- package/README.md +27 -27
- package/dist/index.esm.js +2264 -3713
- package/dist/index.js +2264 -3713
- package/dist/utils/CheckOneUser/index.d.ts +1 -1
- package/docs/index.md +21 -21
- package/package.json +50 -50
- package/src/components/Business/CommodityEntry/index.md +69 -69
- package/src/components/Business/CommodityEntry/index.tsx +75 -75
- package/src/components/Business/SearchSelect/BusinessUtils.ts +1149 -1059
- package/src/components/Business/SearchSelect/common.ts +34 -34
- package/src/components/Business/SearchSelect/index.md +1061 -1061
- package/src/components/Business/SearchSelect/index.tsx +43 -43
- package/src/components/Business/SearchSelect/utils.ts +74 -74
- package/src/components/Functional/DataValidation/index.less +63 -63
- package/src/components/Functional/DataValidation/index.md +38 -38
- package/src/components/Functional/DataValidation/index.tsx +668 -668
- package/src/components/Functional/QueryMutipleInput/index.less +37 -37
- package/src/components/Functional/QueryMutipleInput/index.md +33 -33
- package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
- package/src/components/Functional/SearchSelect/index.less +115 -115
- package/src/components/Functional/SearchSelect/index.md +141 -141
- package/src/components/Functional/SearchSelect/index.tsx +714 -714
- package/src/index.ts +21 -21
- package/src/utils/CheckOneUser/index.md +39 -39
- package/src/utils/CheckOneUser/index.ts +51 -51
- package/tsconfig.json +29 -29
- package/typings.d.ts +2 -2
|
@@ -1,714 +1,714 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import { useDebounceFn } from 'ahooks';
|
|
4
|
-
import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
|
|
5
|
-
import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
|
|
6
|
-
import axios from 'axios';
|
|
7
|
-
import { stringify } from 'querystring';
|
|
8
|
-
import _ from "loadsh"
|
|
9
|
-
import './index.less';
|
|
10
|
-
import { BusinessSearchSelect } from '@/index';
|
|
11
|
-
|
|
12
|
-
const { Option } = Select;
|
|
13
|
-
|
|
14
|
-
const SearchSelect = (props: any) => {
|
|
15
|
-
const {
|
|
16
|
-
value, // 必传
|
|
17
|
-
onChange,
|
|
18
|
-
selectProps={},
|
|
19
|
-
modalTableProps={},
|
|
20
|
-
labelInValue=false,
|
|
21
|
-
requestConfig,
|
|
22
|
-
ctx,
|
|
23
|
-
sourceName,
|
|
24
|
-
needModalTable=true,
|
|
25
|
-
getPopupContainer=undefined
|
|
26
|
-
} = props;
|
|
27
|
-
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingTextShowKeyField,mappingValueField='code', mappingTextShowTextField } = requestConfig || {};
|
|
28
|
-
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
29
|
-
|
|
30
|
-
const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
|
|
31
|
-
const initVal = value || (selectMode ? [] : null);
|
|
32
|
-
const pageSize = 100 // 下拉框默认分页 条数
|
|
33
|
-
const tableInitPageSize = 10 // 弹框默认分页 条数
|
|
34
|
-
const currentPage = 1
|
|
35
|
-
const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
|
|
36
|
-
const currentSelectProps = {
|
|
37
|
-
...selectProps,
|
|
38
|
-
// 以下属性不可更改----设计配置项
|
|
39
|
-
showSearch: false,
|
|
40
|
-
filterOption: false,
|
|
41
|
-
allowClear: true,
|
|
42
|
-
listHeight: 160,
|
|
43
|
-
optionLabelProp: "label",
|
|
44
|
-
autoClearSearchValue: false
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const [items, setItems] = useState([]);
|
|
48
|
-
const [scrollPage, setScrollPage] = useState(1);
|
|
49
|
-
const [itemsTotal, setItemsTotal] = useState(0);
|
|
50
|
-
const [fetching, setFetching] = useState(false);
|
|
51
|
-
const [searchValue, setSearchValue] = useState('');
|
|
52
|
-
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
53
|
-
const [popvalue, setPopValue] = useState(initVal);
|
|
54
|
-
const [uniqueValue, setUniqueValue] = useState(sourceName)
|
|
55
|
-
const { run } = useDebounceFn(
|
|
56
|
-
(v?: any) => {
|
|
57
|
-
// 优化搜索参数 支持传多个
|
|
58
|
-
let searchParams = {};
|
|
59
|
-
if(typeof selectParamsKey === 'string') {
|
|
60
|
-
searchParams = { [selectParamsKey]: v ? initVal : searchValue }
|
|
61
|
-
}
|
|
62
|
-
if(Array.isArray(selectParamsKey)) {
|
|
63
|
-
selectParamsKey.forEach((i: any) => {
|
|
64
|
-
searchParams = { ...searchParams, [i]: searchValue }
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
// 防抖函数 待定
|
|
68
|
-
getData(searchParams)
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
wait: 1000,
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const [form] = Form.useForm();
|
|
76
|
-
const [caretLeftFlag, setCaretLeftFlag] = useState(true);
|
|
77
|
-
const [tableData, setTableData] = useState([]);
|
|
78
|
-
const [tablePagination, setTablePagination] = useState({ showQuickJumper: true, total: 0, current: 1, pageSize: tableInitPageSize })
|
|
79
|
-
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
80
|
-
const [doubleArr, setDoubleArr] = useState([]); // 存放双数组的数组
|
|
81
|
-
const [checkedAll, setCheckedAll] = useState(false)
|
|
82
|
-
const [indeterminate, setIndeterminate] = useState(false)
|
|
83
|
-
const [tableFormParams, setTableFormParams] = useState({});
|
|
84
|
-
const [tooltipVisible, setTooltipVisible] = useState(false);
|
|
85
|
-
|
|
86
|
-
// 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
|
|
87
|
-
const getData = (params={}, type=1) => {
|
|
88
|
-
if (!requestConfig) return;
|
|
89
|
-
|
|
90
|
-
setFetching(true)
|
|
91
|
-
|
|
92
|
-
// 处理dependence参数
|
|
93
|
-
const fixedParam = {};
|
|
94
|
-
if (fixedparameter && fieldValToParam && ctx) {
|
|
95
|
-
fixedparameter.forEach((item: any, index: any) => {
|
|
96
|
-
const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
|
|
97
|
-
if (fixedParamVal) {
|
|
98
|
-
fixedParam[item] = fixedParamVal;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// 数组对象处理,对带有特殊标记的name进行处理
|
|
104
|
-
for (const key in params) {
|
|
105
|
-
if (Object.prototype.hasOwnProperty.call(params, key)) {
|
|
106
|
-
const element = params[key];
|
|
107
|
-
if (element && key.indexOf('*number*') >= 0) {
|
|
108
|
-
const dataParams = key.split('*number*');
|
|
109
|
-
dataParams.forEach((value, index) => {
|
|
110
|
-
params[value] = element[index];
|
|
111
|
-
});
|
|
112
|
-
delete params[key];
|
|
113
|
-
} else if (element && key.indexOf('*address*') >= 0) {
|
|
114
|
-
const dataParams = key.split('*address*');
|
|
115
|
-
dataParams.forEach((value, index) => {
|
|
116
|
-
params[value] = element.PCDCode[index];
|
|
117
|
-
});
|
|
118
|
-
delete params[key];
|
|
119
|
-
} else if (element && key.indexOf('*costType*') >= 0) {
|
|
120
|
-
const dataParams = key.split('*costType*');
|
|
121
|
-
// eslint-disable-next-line prefer-destructuring
|
|
122
|
-
params[dataParams[0]] = element[1];
|
|
123
|
-
delete params[key];
|
|
124
|
-
} else if (element && key.indexOf('*fullDate*') >= 0) {
|
|
125
|
-
const dataParams = key.split('*fullDate*');
|
|
126
|
-
dataParams.forEach((value, index) => {
|
|
127
|
-
if (index === 0) {
|
|
128
|
-
params[value] = moment(element[index])
|
|
129
|
-
.millisecond(0)
|
|
130
|
-
.second(0)
|
|
131
|
-
.minute(0)
|
|
132
|
-
.hour(0)
|
|
133
|
-
.format('YYYY-MM-DD HH:mm:ss');
|
|
134
|
-
} else {
|
|
135
|
-
params[value] = moment(element[index])
|
|
136
|
-
.millisecond(59)
|
|
137
|
-
.second(59)
|
|
138
|
-
.minute(59)
|
|
139
|
-
.hour(23)
|
|
140
|
-
.format('YYYY-MM-DD HH:mm:ss');
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
delete params[key];
|
|
144
|
-
} else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
|
|
145
|
-
const dataParams = key.split('*checkBox*');
|
|
146
|
-
if(element){
|
|
147
|
-
params[dataParams[0]] = 0
|
|
148
|
-
}
|
|
149
|
-
delete params[key];
|
|
150
|
-
}else if (element && key.indexOf('*cascader*') >= 0) {
|
|
151
|
-
const dataParams = key.split('*cascader*');
|
|
152
|
-
params[dataParams[0]] = element[element.length -1]
|
|
153
|
-
delete params[key];
|
|
154
|
-
} else if (element && key.indexOf('*date*') >= 0) {
|
|
155
|
-
const dataParams = key.split('*date*')
|
|
156
|
-
dataParams.forEach((value, index) => {
|
|
157
|
-
if (index === 0) {
|
|
158
|
-
params[value] = moment(element[index])
|
|
159
|
-
.format('YYYY-MM-DD');
|
|
160
|
-
} else {
|
|
161
|
-
params[value] = moment(element[index])
|
|
162
|
-
.format('YYYY-MM-DD');
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
delete params[key];
|
|
166
|
-
}
|
|
167
|
-
else if (element && key.indexOf('*') >= 0) {
|
|
168
|
-
const dataParams = key.split('*');
|
|
169
|
-
dataParams.forEach((value, index) => {
|
|
170
|
-
params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
|
|
171
|
-
});
|
|
172
|
-
delete params[key];
|
|
173
|
-
} else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
|
|
174
|
-
const dataParams = key.split('_selectNumberRange')[0]
|
|
175
|
-
if (params[key][0] === 'range') {
|
|
176
|
-
if (params[key][1][0]) {
|
|
177
|
-
params[`qp-${dataParams}-ge`] = params[key][1][0]
|
|
178
|
-
}
|
|
179
|
-
if (params[key][1][1]) {
|
|
180
|
-
params[`qp-${dataParams}-le`] = params[key][1][1]
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
|
|
184
|
-
}
|
|
185
|
-
delete params[key]
|
|
186
|
-
}else if (Array.isArray(element)) {
|
|
187
|
-
params[key] = element.join(',');
|
|
188
|
-
} else if(element == null || element === undefined || String(element).trim() === '') {
|
|
189
|
-
delete params[key]
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const queryParams = {
|
|
195
|
-
pageSize,
|
|
196
|
-
currentPage,
|
|
197
|
-
...otherParams, // 默认参数
|
|
198
|
-
...fixedParam,
|
|
199
|
-
...params,
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
axios
|
|
203
|
-
.get(`${url}?${stringify(queryParams)}`)
|
|
204
|
-
.then((result: any) => {
|
|
205
|
-
setFetching(false)
|
|
206
|
-
result = result.data;
|
|
207
|
-
if (result.status !== '0') {
|
|
208
|
-
message.error(result.msg);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const res = result.data;
|
|
212
|
-
let source = [];
|
|
213
|
-
if (isMap) {
|
|
214
|
-
source = Object.keys(res).map((d, i) => {
|
|
215
|
-
return {
|
|
216
|
-
text: Object.values(res)[i],
|
|
217
|
-
value: d,
|
|
218
|
-
};
|
|
219
|
-
});
|
|
220
|
-
} else {
|
|
221
|
-
const keys = res.list ? 'list' : 'items';
|
|
222
|
-
source = res
|
|
223
|
-
? res[keys]
|
|
224
|
-
? res[keys].map((item: any) => {
|
|
225
|
-
let textShowText = item[mappingTextField]
|
|
226
|
-
if(mappingTextShowTextField) {
|
|
227
|
-
textShowText = []
|
|
228
|
-
if(Array.isArray(mappingTextShowTextField)) {
|
|
229
|
-
mappingTextShowTextField.forEach((r: any) => {
|
|
230
|
-
textShowText.push(item[r])
|
|
231
|
-
})
|
|
232
|
-
} else {
|
|
233
|
-
textShowText = item[mappingTextShowTextField]
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return {
|
|
237
|
-
...item,
|
|
238
|
-
text: item[mappingTextField],
|
|
239
|
-
textShowText,
|
|
240
|
-
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
241
|
-
value: item[mappingValueField],
|
|
242
|
-
};
|
|
243
|
-
})
|
|
244
|
-
: Array.isArray(res) &&
|
|
245
|
-
res?.map((item: Record<string, any>) => {
|
|
246
|
-
let textShowText = item[mappingTextField]
|
|
247
|
-
if(mappingTextShowTextField) {
|
|
248
|
-
textShowText = []
|
|
249
|
-
if(Array.isArray(mappingTextShowTextField)) {
|
|
250
|
-
mappingTextShowTextField.forEach((r: any) => {
|
|
251
|
-
textShowText.push(item[r])
|
|
252
|
-
})
|
|
253
|
-
} else {
|
|
254
|
-
textShowText = item[mappingTextShowTextField]
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
...item,
|
|
259
|
-
text: item[mappingTextField],
|
|
260
|
-
textShowText,
|
|
261
|
-
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
262
|
-
value: item[mappingValueField],
|
|
263
|
-
};
|
|
264
|
-
})
|
|
265
|
-
: [];
|
|
266
|
-
}
|
|
267
|
-
source = Array.isArray(source) ? source : []
|
|
268
|
-
if(type === 1) {
|
|
269
|
-
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
270
|
-
setItems(source)
|
|
271
|
-
setItemsTotal(Number(res?.total))
|
|
272
|
-
} else {
|
|
273
|
-
setTableData(source)
|
|
274
|
-
setTablePagination({...tablePagination, total: Number(res?.total), pageSize: Number(res?.size), current: Number(res?.page)})
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
.catch((err) => { setFetching(false) });
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const SelectScroll = e => {
|
|
281
|
-
e.persist();
|
|
282
|
-
const { target } = e;
|
|
283
|
-
const totalPage = Math.ceil(itemsTotal / pageSize)
|
|
284
|
-
// 判断是否滑动到底部
|
|
285
|
-
const isTouchGround = target.scrollTop + target.offsetHeight === target.scrollHeight // >=scrollHeight
|
|
286
|
-
// 判断数据是否还没有加载到了最后一页
|
|
287
|
-
const canPageAdd = scrollPage < totalPage
|
|
288
|
-
if (isTouchGround && canPageAdd) {
|
|
289
|
-
const nextScrollPage = scrollPage + 1;
|
|
290
|
-
setScrollPage(nextScrollPage);
|
|
291
|
-
getData({currentPage: nextScrollPage}); // 调用api方法
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
//判断是否滑动到顶部
|
|
295
|
-
const isTouchTop = target.scrollTop ===0 // <=0
|
|
296
|
-
// 判断数据是否到第一页
|
|
297
|
-
const canPageJian = scrollPage > 1
|
|
298
|
-
if (isTouchTop && canPageJian) {
|
|
299
|
-
const preScrollPage = scrollPage - 1;
|
|
300
|
-
setScrollPage(preScrollPage);
|
|
301
|
-
getData({currentPage: preScrollPage}); // 调用api方法
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
useEffect(() => {
|
|
306
|
-
run('init')
|
|
307
|
-
}, [])
|
|
308
|
-
|
|
309
|
-
useEffect(() => {
|
|
310
|
-
if(value) {
|
|
311
|
-
setPopValue(value);
|
|
312
|
-
onChange(value);
|
|
313
|
-
}
|
|
314
|
-
}, [value]);
|
|
315
|
-
|
|
316
|
-
useEffect(() => {
|
|
317
|
-
makeUniqueValue();
|
|
318
|
-
}, [sourceName])
|
|
319
|
-
|
|
320
|
-
const showModal = () => {
|
|
321
|
-
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
322
|
-
setIsModalVisible(true);
|
|
323
|
-
// 回显
|
|
324
|
-
if(value) {
|
|
325
|
-
if(selectMode) {
|
|
326
|
-
setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
|
|
327
|
-
setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
|
|
328
|
-
setIndeterminate(!!value.length && value.length < itemsTotal);
|
|
329
|
-
setCheckedAll(itemsTotal && value.length === itemsTotal);
|
|
330
|
-
// 需清空数据
|
|
331
|
-
if(!value.length) {
|
|
332
|
-
setDoubleArr([])
|
|
333
|
-
}
|
|
334
|
-
} else {
|
|
335
|
-
setSelectedRowKeys(labelInValue ? [value.key] : [value])
|
|
336
|
-
setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const handleSelectOver = (selectedValue: any) => {
|
|
342
|
-
if(selectedValue?.length) {
|
|
343
|
-
formaData(selectedValue);
|
|
344
|
-
// 解决选择最后1页的sku,返回后,不显示名称问题
|
|
345
|
-
const source = _.uniqBy(items.concat(selectedValue), 'value')
|
|
346
|
-
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
347
|
-
setItems(source)
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const handleOk = () => {
|
|
352
|
-
handleSelectOver(popvalue)
|
|
353
|
-
handleCancel();
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const formaData = (value) => {
|
|
357
|
-
if(labelInValue) {
|
|
358
|
-
const formatResult = value.map((i: any) => ({ key: i.code, label: i.name, value: i.code }))
|
|
359
|
-
onChange(selectMode ? formatResult : formatResult[0])
|
|
360
|
-
} else {
|
|
361
|
-
const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
|
|
362
|
-
onChange(formatResult)
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
const handleCancel = () => {
|
|
367
|
-
form.resetFields();
|
|
368
|
-
setTableFormParams({});
|
|
369
|
-
setIsModalVisible(false);
|
|
370
|
-
if(selectMode) {
|
|
371
|
-
run();
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
const onSearchChange = (e) => {
|
|
376
|
-
setSearchValue(e.target.value);
|
|
377
|
-
run();
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
const onSearchBlur = () => {
|
|
381
|
-
setSearchValue('')
|
|
382
|
-
run();
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
const onSearchTable = () => {
|
|
386
|
-
const params = form.getFieldsValue();
|
|
387
|
-
setTableFormParams(params);
|
|
388
|
-
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
389
|
-
if(selectMode){
|
|
390
|
-
getData(params)
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const onResetTable = () => {
|
|
395
|
-
form.resetFields();
|
|
396
|
-
setTableFormParams({});
|
|
397
|
-
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
const handleTableChange = (pagination) => {
|
|
401
|
-
getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
const onChangeCheckAll = (e) => {
|
|
405
|
-
if(e.target.checked) {
|
|
406
|
-
// 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
|
|
407
|
-
// 如果超过100条 就默认查出所有数据
|
|
408
|
-
const currentItemsData = JSON.parse(JSON.stringify(items))
|
|
409
|
-
const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize)
|
|
410
|
-
for(let i=0; i <= totalPage-1; i++){
|
|
411
|
-
doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize*i,tablePagination?.pageSize*(i+1))
|
|
412
|
-
}
|
|
413
|
-
setDoubleArr(doubleArr)
|
|
414
|
-
setSelectedRowKeys(currentItemsData.map(i => i.value))
|
|
415
|
-
setPopValue(currentItemsData);
|
|
416
|
-
if(items.length < itemsTotal) {
|
|
417
|
-
// TODO 请求接口获取所有数据
|
|
418
|
-
}
|
|
419
|
-
} else {
|
|
420
|
-
setSelectedRowKeys([])
|
|
421
|
-
setPopValue([]);
|
|
422
|
-
setDoubleArr([])
|
|
423
|
-
}
|
|
424
|
-
setIndeterminate(false);
|
|
425
|
-
setCheckedAll(e.target.checked);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
const LightHeightOption = (props) => {
|
|
429
|
-
const {
|
|
430
|
-
filterTxt, text,
|
|
431
|
-
} = props
|
|
432
|
-
const heightLightTxt = (txt, heightTxt) => {
|
|
433
|
-
if (heightTxt === '') {
|
|
434
|
-
return txt
|
|
435
|
-
}
|
|
436
|
-
// 前面filterOption 不区分大小写,这里用i
|
|
437
|
-
const regexp = new RegExp(heightTxt, 'gi')
|
|
438
|
-
return txt.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
|
|
439
|
-
}
|
|
440
|
-
return (
|
|
441
|
-
<Tooltip title={text}>
|
|
442
|
-
<div ref={(nodeElement) => {
|
|
443
|
-
if (nodeElement) {
|
|
444
|
-
nodeElement.innerHTML = heightLightTxt(text, filterTxt)
|
|
445
|
-
}
|
|
446
|
-
}}
|
|
447
|
-
/>
|
|
448
|
-
</Tooltip>
|
|
449
|
-
)
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// 扁平化二维数组的方法
|
|
453
|
-
const mapRows = params => {
|
|
454
|
-
var res = [];
|
|
455
|
-
for (var i = 0; i < params.length; i++) {
|
|
456
|
-
if (Array.isArray(params[i])) {
|
|
457
|
-
// 去重
|
|
458
|
-
res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
|
|
459
|
-
} else {
|
|
460
|
-
res.push(params[i]);
|
|
461
|
-
// 去重
|
|
462
|
-
res = _.uniqBy(res, 'value')
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return res.filter(Boolean); //去掉undefined的情况
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
const onChangeSelectedKeys=(selectKeys,selectRows) => {
|
|
469
|
-
const nowPage = tablePagination?.current;
|
|
470
|
-
|
|
471
|
-
let filterRows = []; // 存放拼接后的一维数组的变量
|
|
472
|
-
let sksResult = [];
|
|
473
|
-
|
|
474
|
-
if(selectMode) {
|
|
475
|
-
// 处理多选分页累计选中
|
|
476
|
-
// 勾选生成二维数组
|
|
477
|
-
doubleArr[nowPage ? nowPage - 1 : 0] = selectRows
|
|
478
|
-
// console.log(doubleArr)
|
|
479
|
-
setDoubleArr(doubleArr)
|
|
480
|
-
// 这块扁平化成为一位数组
|
|
481
|
-
filterRows = mapRows(doubleArr);
|
|
482
|
-
// console.log(filterRows)
|
|
483
|
-
|
|
484
|
-
sksResult = filterRows.map((i) => i.value)
|
|
485
|
-
} else {
|
|
486
|
-
// 处理单选
|
|
487
|
-
filterRows = selectRows;
|
|
488
|
-
sksResult = selectRows.map((i) => i.value)
|
|
489
|
-
// 单选直接选中 不需要确定
|
|
490
|
-
handleSelectOver(filterRows)
|
|
491
|
-
handleCancel();
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
setSelectedRowKeys(sksResult)
|
|
495
|
-
setPopValue(filterRows);
|
|
496
|
-
setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
|
|
497
|
-
setCheckedAll(filterRows.length === tablePagination?.total);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// 生成唯一值
|
|
501
|
-
const makeUniqueValue = () => {
|
|
502
|
-
const generateUnitKey = (((1+Math.random())*0x10000)|0).toString(16);
|
|
503
|
-
setUniqueValue(generateUnitKey);
|
|
504
|
-
return generateUnitKey;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
const rowSelection = {
|
|
508
|
-
type: selectMode ? 'checkbox' : 'radio',
|
|
509
|
-
selectedRowKeys,
|
|
510
|
-
onChange: (sks, srs) => {
|
|
511
|
-
onChangeSelectedKeys(sks, srs)
|
|
512
|
-
},
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
const onDoubleClickSelect = (e, record) => {
|
|
516
|
-
if(!selectMode) {
|
|
517
|
-
const srs = [JSON.parse(JSON.stringify(record))]
|
|
518
|
-
const sks = srs.map((i:any) => i.value)
|
|
519
|
-
onChangeSelectedKeys(sks, srs)
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
const themeColor = { color: '#1890ff' }
|
|
524
|
-
|
|
525
|
-
const formItem = (list) => {
|
|
526
|
-
if(isModalVisible && list?.length) {
|
|
527
|
-
return list.map((i: any) => {
|
|
528
|
-
if(i?.type === 'select' || i?.field?.type === 'select') {
|
|
529
|
-
return (
|
|
530
|
-
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
531
|
-
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}>
|
|
532
|
-
{i?.initialSource?.length && i?.initialSource.map((m: any) => (
|
|
533
|
-
<Option value={m.value} key={m.value}>{m.text}</Option>
|
|
534
|
-
))}
|
|
535
|
-
</Select>
|
|
536
|
-
</Form.Item>
|
|
537
|
-
)
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if(i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
|
|
541
|
-
return (
|
|
542
|
-
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
543
|
-
<TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}></TreeSelect>
|
|
544
|
-
</Form.Item>
|
|
545
|
-
)
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
if(i?.type === 'businessSearchSelect') {
|
|
549
|
-
return (
|
|
550
|
-
<div>
|
|
551
|
-
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
552
|
-
<BusinessSearchSelect {...i.field.props} />
|
|
553
|
-
</Form.Item>
|
|
554
|
-
</div>
|
|
555
|
-
)
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// 默认type是input
|
|
559
|
-
return (
|
|
560
|
-
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
561
|
-
<Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
|
|
562
|
-
</Form.Item>
|
|
563
|
-
)
|
|
564
|
-
})
|
|
565
|
-
} else {
|
|
566
|
-
return null
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
const maxTagPlaceholder = (selectedValues) => {
|
|
571
|
-
const onClose = (e: any,item: any) => {
|
|
572
|
-
e.preventDefault();
|
|
573
|
-
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)
|
|
574
|
-
onChange(newValue);
|
|
575
|
-
}
|
|
576
|
-
return (
|
|
577
|
-
<Tooltip title={selectedValues.map((i: any) => (
|
|
578
|
-
<Tag
|
|
579
|
-
closable={true}
|
|
580
|
-
onClose={(e) => onClose(e,i)}
|
|
581
|
-
style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
|
|
582
|
-
>
|
|
583
|
-
{i.label}
|
|
584
|
-
</Tag>
|
|
585
|
-
))}>
|
|
586
|
-
{`+ ${selectedValues?.length}`}
|
|
587
|
-
</Tooltip>
|
|
588
|
-
)
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
return (
|
|
592
|
-
<div className={'search_select'}>
|
|
593
|
-
<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
|
|
594
|
-
<Select
|
|
595
|
-
virtual
|
|
596
|
-
labelInValue={labelInValue}
|
|
597
|
-
value={value}
|
|
598
|
-
onChange={onChange}
|
|
599
|
-
dropdownRender={menu => (
|
|
600
|
-
<>
|
|
601
|
-
<Input
|
|
602
|
-
value={searchValue}
|
|
603
|
-
style={{ width: '98%', marginLeft: '1%' }}
|
|
604
|
-
placeholder="请输入"
|
|
605
|
-
onChange={e=> onSearchChange(e)}
|
|
606
|
-
onBlur={onSearchBlur}
|
|
607
|
-
onKeyDown={(e) => {
|
|
608
|
-
// 阻止多选的冒泡
|
|
609
|
-
e.stopPropagation()
|
|
610
|
-
}}
|
|
611
|
-
/>
|
|
612
|
-
<Divider style={{ margin: '8px 0' }} />
|
|
613
|
-
{menu}
|
|
614
|
-
</>
|
|
615
|
-
)}
|
|
616
|
-
notFoundContent={
|
|
617
|
-
fetching ? <Spin size="small" /> :
|
|
618
|
-
<div style={{ textAlign: 'center'}}>
|
|
619
|
-
<div style={{ marginBottom: 16 }}>
|
|
620
|
-
<CopyOutlined style={{ fontSize: '50px' }} />
|
|
621
|
-
</div>
|
|
622
|
-
<div>无匹配结果,请更换其他内容再试</div>
|
|
623
|
-
</div>
|
|
624
|
-
}
|
|
625
|
-
onPopupScroll={SelectScroll}
|
|
626
|
-
style={{ width: needModalTable?'calc(100% - 30px)':'calc(100%)' }}
|
|
627
|
-
placeholder="请选择"
|
|
628
|
-
maxTagPlaceholder={maxTagPlaceholder}
|
|
629
|
-
{...currentSelectProps}
|
|
630
|
-
getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
|
|
631
|
-
>
|
|
632
|
-
{items.map(item => (
|
|
633
|
-
<Option key={item.value} label={item.text}>
|
|
634
|
-
{LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
|
|
635
|
-
</Option>
|
|
636
|
-
))}
|
|
637
|
-
</Select>
|
|
638
|
-
{needModalTable && (
|
|
639
|
-
<Button style={{width: '30px', padding: '2px', height: 'auto'}} onClick={showModal} type="primary">
|
|
640
|
-
<SearchOutlined />
|
|
641
|
-
</Button>
|
|
642
|
-
)}
|
|
643
|
-
</div>
|
|
644
|
-
{needModalTable && isModalVisible && (
|
|
645
|
-
<Modal
|
|
646
|
-
width='80%'
|
|
647
|
-
title={modalTableProps?.modalTableTitle}
|
|
648
|
-
visible={isModalVisible}
|
|
649
|
-
onOk={handleOk}
|
|
650
|
-
onCancel={handleCancel}
|
|
651
|
-
footer={selectMode?[
|
|
652
|
-
<Button key="back" onClick={handleCancel}>
|
|
653
|
-
取消
|
|
654
|
-
</Button>,
|
|
655
|
-
<Button
|
|
656
|
-
key="submit"
|
|
657
|
-
type="primary"
|
|
658
|
-
onClick={handleOk}
|
|
659
|
-
disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
|
|
660
|
-
>
|
|
661
|
-
确定
|
|
662
|
-
</Button>,
|
|
663
|
-
]:null}
|
|
664
|
-
>
|
|
665
|
-
<div className={'search_select_wrapper'}>
|
|
666
|
-
<div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
|
|
667
|
-
<CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1' } />
|
|
668
|
-
</div>
|
|
669
|
-
<div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
|
|
670
|
-
<div className={'select_list_columns'}>
|
|
671
|
-
<div className={'select_list_columns_tips'}>搜索</div>
|
|
672
|
-
<div className={'select_list_columns_formItems'}>
|
|
673
|
-
<Form form={form} layout='vertical' key='modalForm'>
|
|
674
|
-
{formItem(modalTableProps?.tableSearchForm)}
|
|
675
|
-
</Form>
|
|
676
|
-
</div>
|
|
677
|
-
</div>
|
|
678
|
-
<div className={'select_list_searchButton'}>
|
|
679
|
-
<Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
|
|
680
|
-
<Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
|
|
681
|
-
</div>
|
|
682
|
-
</div>
|
|
683
|
-
<div className={caretLeftFlag ? 'search_select_wrapper_right': 'search_select_wrapper_right1'}>
|
|
684
|
-
<div>
|
|
685
|
-
<div className={'select_list_selectTips'}>
|
|
686
|
-
<div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
|
|
687
|
-
<div style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}>{selectMode ? '勾选后点击确定按钮完成选择' : '双击数据行或点击单选图标完成选择'}</div>
|
|
688
|
-
</div>
|
|
689
|
-
<Table
|
|
690
|
-
size='small'
|
|
691
|
-
rowSelection={rowSelection}
|
|
692
|
-
columns={modalTableProps?.tableColumns}
|
|
693
|
-
dataSource={tableData}
|
|
694
|
-
pagination={tablePagination}
|
|
695
|
-
onChange={handleTableChange}
|
|
696
|
-
rowKey={mappingValueField}
|
|
697
|
-
scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
|
|
698
|
-
onRow={record => {
|
|
699
|
-
return {
|
|
700
|
-
onDoubleClick: event => onDoubleClickSelect(event, record),
|
|
701
|
-
};
|
|
702
|
-
}}
|
|
703
|
-
/>
|
|
704
|
-
{selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} /> 全选所有页面</div> : ''}
|
|
705
|
-
</div>
|
|
706
|
-
</div>
|
|
707
|
-
</div>
|
|
708
|
-
</Modal>
|
|
709
|
-
)}
|
|
710
|
-
</div>
|
|
711
|
-
);
|
|
712
|
-
};
|
|
713
|
-
|
|
714
|
-
export default SearchSelect;
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { useDebounceFn } from 'ahooks';
|
|
4
|
+
import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
|
|
5
|
+
import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
import { stringify } from 'querystring';
|
|
8
|
+
import _ from "loadsh"
|
|
9
|
+
import './index.less';
|
|
10
|
+
import { BusinessSearchSelect } from '@/index';
|
|
11
|
+
|
|
12
|
+
const { Option } = Select;
|
|
13
|
+
|
|
14
|
+
const SearchSelect = (props: any) => {
|
|
15
|
+
const {
|
|
16
|
+
value, // 必传
|
|
17
|
+
onChange,
|
|
18
|
+
selectProps={},
|
|
19
|
+
modalTableProps={},
|
|
20
|
+
labelInValue=false,
|
|
21
|
+
requestConfig,
|
|
22
|
+
ctx,
|
|
23
|
+
sourceName,
|
|
24
|
+
needModalTable=true,
|
|
25
|
+
getPopupContainer=undefined
|
|
26
|
+
} = props;
|
|
27
|
+
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingTextShowKeyField,mappingValueField='code', mappingTextShowTextField } = requestConfig || {};
|
|
28
|
+
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
29
|
+
|
|
30
|
+
const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
|
|
31
|
+
const initVal = value || (selectMode ? [] : null);
|
|
32
|
+
const pageSize = 100 // 下拉框默认分页 条数
|
|
33
|
+
const tableInitPageSize = 10 // 弹框默认分页 条数
|
|
34
|
+
const currentPage = 1
|
|
35
|
+
const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
|
|
36
|
+
const currentSelectProps = {
|
|
37
|
+
...selectProps,
|
|
38
|
+
// 以下属性不可更改----设计配置项
|
|
39
|
+
showSearch: false,
|
|
40
|
+
filterOption: false,
|
|
41
|
+
allowClear: true,
|
|
42
|
+
listHeight: 160,
|
|
43
|
+
optionLabelProp: "label",
|
|
44
|
+
autoClearSearchValue: false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const [items, setItems] = useState([]);
|
|
48
|
+
const [scrollPage, setScrollPage] = useState(1);
|
|
49
|
+
const [itemsTotal, setItemsTotal] = useState(0);
|
|
50
|
+
const [fetching, setFetching] = useState(false);
|
|
51
|
+
const [searchValue, setSearchValue] = useState('');
|
|
52
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
53
|
+
const [popvalue, setPopValue] = useState(initVal);
|
|
54
|
+
const [uniqueValue, setUniqueValue] = useState(sourceName)
|
|
55
|
+
const { run } = useDebounceFn(
|
|
56
|
+
(v?: any) => {
|
|
57
|
+
// 优化搜索参数 支持传多个
|
|
58
|
+
let searchParams = {};
|
|
59
|
+
if(typeof selectParamsKey === 'string') {
|
|
60
|
+
searchParams = { [selectParamsKey]: v ? initVal : searchValue }
|
|
61
|
+
}
|
|
62
|
+
if(Array.isArray(selectParamsKey)) {
|
|
63
|
+
selectParamsKey.forEach((i: any) => {
|
|
64
|
+
searchParams = { ...searchParams, [i]: searchValue }
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
// 防抖函数 待定
|
|
68
|
+
getData(searchParams)
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
wait: 1000,
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const [form] = Form.useForm();
|
|
76
|
+
const [caretLeftFlag, setCaretLeftFlag] = useState(true);
|
|
77
|
+
const [tableData, setTableData] = useState([]);
|
|
78
|
+
const [tablePagination, setTablePagination] = useState({ showQuickJumper: true, total: 0, current: 1, pageSize: tableInitPageSize })
|
|
79
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
80
|
+
const [doubleArr, setDoubleArr] = useState([]); // 存放双数组的数组
|
|
81
|
+
const [checkedAll, setCheckedAll] = useState(false)
|
|
82
|
+
const [indeterminate, setIndeterminate] = useState(false)
|
|
83
|
+
const [tableFormParams, setTableFormParams] = useState({});
|
|
84
|
+
const [tooltipVisible, setTooltipVisible] = useState(false);
|
|
85
|
+
|
|
86
|
+
// 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
|
|
87
|
+
const getData = (params={}, type=1) => {
|
|
88
|
+
if (!requestConfig) return;
|
|
89
|
+
|
|
90
|
+
setFetching(true)
|
|
91
|
+
|
|
92
|
+
// 处理dependence参数
|
|
93
|
+
const fixedParam = {};
|
|
94
|
+
if (fixedparameter && fieldValToParam && ctx) {
|
|
95
|
+
fixedparameter.forEach((item: any, index: any) => {
|
|
96
|
+
const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
|
|
97
|
+
if (fixedParamVal) {
|
|
98
|
+
fixedParam[item] = fixedParamVal;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 数组对象处理,对带有特殊标记的name进行处理
|
|
104
|
+
for (const key in params) {
|
|
105
|
+
if (Object.prototype.hasOwnProperty.call(params, key)) {
|
|
106
|
+
const element = params[key];
|
|
107
|
+
if (element && key.indexOf('*number*') >= 0) {
|
|
108
|
+
const dataParams = key.split('*number*');
|
|
109
|
+
dataParams.forEach((value, index) => {
|
|
110
|
+
params[value] = element[index];
|
|
111
|
+
});
|
|
112
|
+
delete params[key];
|
|
113
|
+
} else if (element && key.indexOf('*address*') >= 0) {
|
|
114
|
+
const dataParams = key.split('*address*');
|
|
115
|
+
dataParams.forEach((value, index) => {
|
|
116
|
+
params[value] = element.PCDCode[index];
|
|
117
|
+
});
|
|
118
|
+
delete params[key];
|
|
119
|
+
} else if (element && key.indexOf('*costType*') >= 0) {
|
|
120
|
+
const dataParams = key.split('*costType*');
|
|
121
|
+
// eslint-disable-next-line prefer-destructuring
|
|
122
|
+
params[dataParams[0]] = element[1];
|
|
123
|
+
delete params[key];
|
|
124
|
+
} else if (element && key.indexOf('*fullDate*') >= 0) {
|
|
125
|
+
const dataParams = key.split('*fullDate*');
|
|
126
|
+
dataParams.forEach((value, index) => {
|
|
127
|
+
if (index === 0) {
|
|
128
|
+
params[value] = moment(element[index])
|
|
129
|
+
.millisecond(0)
|
|
130
|
+
.second(0)
|
|
131
|
+
.minute(0)
|
|
132
|
+
.hour(0)
|
|
133
|
+
.format('YYYY-MM-DD HH:mm:ss');
|
|
134
|
+
} else {
|
|
135
|
+
params[value] = moment(element[index])
|
|
136
|
+
.millisecond(59)
|
|
137
|
+
.second(59)
|
|
138
|
+
.minute(59)
|
|
139
|
+
.hour(23)
|
|
140
|
+
.format('YYYY-MM-DD HH:mm:ss');
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
delete params[key];
|
|
144
|
+
} else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
|
|
145
|
+
const dataParams = key.split('*checkBox*');
|
|
146
|
+
if(element){
|
|
147
|
+
params[dataParams[0]] = 0
|
|
148
|
+
}
|
|
149
|
+
delete params[key];
|
|
150
|
+
}else if (element && key.indexOf('*cascader*') >= 0) {
|
|
151
|
+
const dataParams = key.split('*cascader*');
|
|
152
|
+
params[dataParams[0]] = element[element.length -1]
|
|
153
|
+
delete params[key];
|
|
154
|
+
} else if (element && key.indexOf('*date*') >= 0) {
|
|
155
|
+
const dataParams = key.split('*date*')
|
|
156
|
+
dataParams.forEach((value, index) => {
|
|
157
|
+
if (index === 0) {
|
|
158
|
+
params[value] = moment(element[index])
|
|
159
|
+
.format('YYYY-MM-DD');
|
|
160
|
+
} else {
|
|
161
|
+
params[value] = moment(element[index])
|
|
162
|
+
.format('YYYY-MM-DD');
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
delete params[key];
|
|
166
|
+
}
|
|
167
|
+
else if (element && key.indexOf('*') >= 0) {
|
|
168
|
+
const dataParams = key.split('*');
|
|
169
|
+
dataParams.forEach((value, index) => {
|
|
170
|
+
params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
|
|
171
|
+
});
|
|
172
|
+
delete params[key];
|
|
173
|
+
} else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
|
|
174
|
+
const dataParams = key.split('_selectNumberRange')[0]
|
|
175
|
+
if (params[key][0] === 'range') {
|
|
176
|
+
if (params[key][1][0]) {
|
|
177
|
+
params[`qp-${dataParams}-ge`] = params[key][1][0]
|
|
178
|
+
}
|
|
179
|
+
if (params[key][1][1]) {
|
|
180
|
+
params[`qp-${dataParams}-le`] = params[key][1][1]
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
|
|
184
|
+
}
|
|
185
|
+
delete params[key]
|
|
186
|
+
}else if (Array.isArray(element)) {
|
|
187
|
+
params[key] = element.join(',');
|
|
188
|
+
} else if(element == null || element === undefined || String(element).trim() === '') {
|
|
189
|
+
delete params[key]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const queryParams = {
|
|
195
|
+
pageSize,
|
|
196
|
+
currentPage,
|
|
197
|
+
...otherParams, // 默认参数
|
|
198
|
+
...fixedParam,
|
|
199
|
+
...params,
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
axios
|
|
203
|
+
.get(`${url}?${stringify(queryParams)}`)
|
|
204
|
+
.then((result: any) => {
|
|
205
|
+
setFetching(false)
|
|
206
|
+
result = result.data;
|
|
207
|
+
if (result.status !== '0') {
|
|
208
|
+
message.error(result.msg);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const res = result.data;
|
|
212
|
+
let source = [];
|
|
213
|
+
if (isMap) {
|
|
214
|
+
source = Object.keys(res).map((d, i) => {
|
|
215
|
+
return {
|
|
216
|
+
text: Object.values(res)[i],
|
|
217
|
+
value: d,
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
const keys = res.list ? 'list' : 'items';
|
|
222
|
+
source = res
|
|
223
|
+
? res[keys]
|
|
224
|
+
? res[keys].map((item: any) => {
|
|
225
|
+
let textShowText = item[mappingTextField]
|
|
226
|
+
if(mappingTextShowTextField) {
|
|
227
|
+
textShowText = []
|
|
228
|
+
if(Array.isArray(mappingTextShowTextField)) {
|
|
229
|
+
mappingTextShowTextField.forEach((r: any) => {
|
|
230
|
+
textShowText.push(item[r])
|
|
231
|
+
})
|
|
232
|
+
} else {
|
|
233
|
+
textShowText = item[mappingTextShowTextField]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
...item,
|
|
238
|
+
text: item[mappingTextField],
|
|
239
|
+
textShowText,
|
|
240
|
+
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
241
|
+
value: item[mappingValueField],
|
|
242
|
+
};
|
|
243
|
+
})
|
|
244
|
+
: Array.isArray(res) &&
|
|
245
|
+
res?.map((item: Record<string, any>) => {
|
|
246
|
+
let textShowText = item[mappingTextField]
|
|
247
|
+
if(mappingTextShowTextField) {
|
|
248
|
+
textShowText = []
|
|
249
|
+
if(Array.isArray(mappingTextShowTextField)) {
|
|
250
|
+
mappingTextShowTextField.forEach((r: any) => {
|
|
251
|
+
textShowText.push(item[r])
|
|
252
|
+
})
|
|
253
|
+
} else {
|
|
254
|
+
textShowText = item[mappingTextShowTextField]
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
...item,
|
|
259
|
+
text: item[mappingTextField],
|
|
260
|
+
textShowText,
|
|
261
|
+
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
262
|
+
value: item[mappingValueField],
|
|
263
|
+
};
|
|
264
|
+
})
|
|
265
|
+
: [];
|
|
266
|
+
}
|
|
267
|
+
source = Array.isArray(source) ? source : []
|
|
268
|
+
if(type === 1) {
|
|
269
|
+
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
270
|
+
setItems(source)
|
|
271
|
+
setItemsTotal(Number(res?.total))
|
|
272
|
+
} else {
|
|
273
|
+
setTableData(source)
|
|
274
|
+
setTablePagination({...tablePagination, total: Number(res?.total), pageSize: Number(res?.size), current: Number(res?.page)})
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
.catch((err) => { setFetching(false) });
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const SelectScroll = e => {
|
|
281
|
+
e.persist();
|
|
282
|
+
const { target } = e;
|
|
283
|
+
const totalPage = Math.ceil(itemsTotal / pageSize)
|
|
284
|
+
// 判断是否滑动到底部
|
|
285
|
+
const isTouchGround = target.scrollTop + target.offsetHeight === target.scrollHeight // >=scrollHeight
|
|
286
|
+
// 判断数据是否还没有加载到了最后一页
|
|
287
|
+
const canPageAdd = scrollPage < totalPage
|
|
288
|
+
if (isTouchGround && canPageAdd) {
|
|
289
|
+
const nextScrollPage = scrollPage + 1;
|
|
290
|
+
setScrollPage(nextScrollPage);
|
|
291
|
+
getData({currentPage: nextScrollPage}); // 调用api方法
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
//判断是否滑动到顶部
|
|
295
|
+
const isTouchTop = target.scrollTop ===0 // <=0
|
|
296
|
+
// 判断数据是否到第一页
|
|
297
|
+
const canPageJian = scrollPage > 1
|
|
298
|
+
if (isTouchTop && canPageJian) {
|
|
299
|
+
const preScrollPage = scrollPage - 1;
|
|
300
|
+
setScrollPage(preScrollPage);
|
|
301
|
+
getData({currentPage: preScrollPage}); // 调用api方法
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
run('init')
|
|
307
|
+
}, [])
|
|
308
|
+
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
if(value) {
|
|
311
|
+
setPopValue(value);
|
|
312
|
+
onChange(value);
|
|
313
|
+
}
|
|
314
|
+
}, [value]);
|
|
315
|
+
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
makeUniqueValue();
|
|
318
|
+
}, [sourceName])
|
|
319
|
+
|
|
320
|
+
const showModal = () => {
|
|
321
|
+
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
322
|
+
setIsModalVisible(true);
|
|
323
|
+
// 回显
|
|
324
|
+
if(value) {
|
|
325
|
+
if(selectMode) {
|
|
326
|
+
setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
|
|
327
|
+
setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
|
|
328
|
+
setIndeterminate(!!value.length && value.length < itemsTotal);
|
|
329
|
+
setCheckedAll(itemsTotal && value.length === itemsTotal);
|
|
330
|
+
// 需清空数据
|
|
331
|
+
if(!value.length) {
|
|
332
|
+
setDoubleArr([])
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
setSelectedRowKeys(labelInValue ? [value.key] : [value])
|
|
336
|
+
setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const handleSelectOver = (selectedValue: any) => {
|
|
342
|
+
if(selectedValue?.length) {
|
|
343
|
+
formaData(selectedValue);
|
|
344
|
+
// 解决选择最后1页的sku,返回后,不显示名称问题
|
|
345
|
+
const source = _.uniqBy(items.concat(selectedValue), 'value')
|
|
346
|
+
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
347
|
+
setItems(source)
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const handleOk = () => {
|
|
352
|
+
handleSelectOver(popvalue)
|
|
353
|
+
handleCancel();
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const formaData = (value) => {
|
|
357
|
+
if(labelInValue) {
|
|
358
|
+
const formatResult = value.map((i: any) => ({ key: i.code, label: i.name, value: i.code }))
|
|
359
|
+
onChange(selectMode ? formatResult : formatResult[0])
|
|
360
|
+
} else {
|
|
361
|
+
const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
|
|
362
|
+
onChange(formatResult)
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const handleCancel = () => {
|
|
367
|
+
form.resetFields();
|
|
368
|
+
setTableFormParams({});
|
|
369
|
+
setIsModalVisible(false);
|
|
370
|
+
if(selectMode) {
|
|
371
|
+
run();
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
const onSearchChange = (e) => {
|
|
376
|
+
setSearchValue(e.target.value);
|
|
377
|
+
run();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const onSearchBlur = () => {
|
|
381
|
+
setSearchValue('')
|
|
382
|
+
run();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const onSearchTable = () => {
|
|
386
|
+
const params = form.getFieldsValue();
|
|
387
|
+
setTableFormParams(params);
|
|
388
|
+
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
389
|
+
if(selectMode){
|
|
390
|
+
getData(params)
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const onResetTable = () => {
|
|
395
|
+
form.resetFields();
|
|
396
|
+
setTableFormParams({});
|
|
397
|
+
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const handleTableChange = (pagination) => {
|
|
401
|
+
getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const onChangeCheckAll = (e) => {
|
|
405
|
+
if(e.target.checked) {
|
|
406
|
+
// 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
|
|
407
|
+
// 如果超过100条 就默认查出所有数据
|
|
408
|
+
const currentItemsData = JSON.parse(JSON.stringify(items))
|
|
409
|
+
const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize)
|
|
410
|
+
for(let i=0; i <= totalPage-1; i++){
|
|
411
|
+
doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize*i,tablePagination?.pageSize*(i+1))
|
|
412
|
+
}
|
|
413
|
+
setDoubleArr(doubleArr)
|
|
414
|
+
setSelectedRowKeys(currentItemsData.map(i => i.value))
|
|
415
|
+
setPopValue(currentItemsData);
|
|
416
|
+
if(items.length < itemsTotal) {
|
|
417
|
+
// TODO 请求接口获取所有数据
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
setSelectedRowKeys([])
|
|
421
|
+
setPopValue([]);
|
|
422
|
+
setDoubleArr([])
|
|
423
|
+
}
|
|
424
|
+
setIndeterminate(false);
|
|
425
|
+
setCheckedAll(e.target.checked);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const LightHeightOption = (props) => {
|
|
429
|
+
const {
|
|
430
|
+
filterTxt, text,
|
|
431
|
+
} = props
|
|
432
|
+
const heightLightTxt = (txt, heightTxt) => {
|
|
433
|
+
if (heightTxt === '') {
|
|
434
|
+
return txt
|
|
435
|
+
}
|
|
436
|
+
// 前面filterOption 不区分大小写,这里用i
|
|
437
|
+
const regexp = new RegExp(heightTxt, 'gi')
|
|
438
|
+
return txt.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
|
|
439
|
+
}
|
|
440
|
+
return (
|
|
441
|
+
<Tooltip title={text}>
|
|
442
|
+
<div ref={(nodeElement) => {
|
|
443
|
+
if (nodeElement) {
|
|
444
|
+
nodeElement.innerHTML = heightLightTxt(text, filterTxt)
|
|
445
|
+
}
|
|
446
|
+
}}
|
|
447
|
+
/>
|
|
448
|
+
</Tooltip>
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// 扁平化二维数组的方法
|
|
453
|
+
const mapRows = params => {
|
|
454
|
+
var res = [];
|
|
455
|
+
for (var i = 0; i < params.length; i++) {
|
|
456
|
+
if (Array.isArray(params[i])) {
|
|
457
|
+
// 去重
|
|
458
|
+
res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
|
|
459
|
+
} else {
|
|
460
|
+
res.push(params[i]);
|
|
461
|
+
// 去重
|
|
462
|
+
res = _.uniqBy(res, 'value')
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return res.filter(Boolean); //去掉undefined的情况
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
const onChangeSelectedKeys=(selectKeys,selectRows) => {
|
|
469
|
+
const nowPage = tablePagination?.current;
|
|
470
|
+
|
|
471
|
+
let filterRows = []; // 存放拼接后的一维数组的变量
|
|
472
|
+
let sksResult = [];
|
|
473
|
+
|
|
474
|
+
if(selectMode) {
|
|
475
|
+
// 处理多选分页累计选中
|
|
476
|
+
// 勾选生成二维数组
|
|
477
|
+
doubleArr[nowPage ? nowPage - 1 : 0] = selectRows
|
|
478
|
+
// console.log(doubleArr)
|
|
479
|
+
setDoubleArr(doubleArr)
|
|
480
|
+
// 这块扁平化成为一位数组
|
|
481
|
+
filterRows = mapRows(doubleArr);
|
|
482
|
+
// console.log(filterRows)
|
|
483
|
+
|
|
484
|
+
sksResult = filterRows.map((i) => i.value)
|
|
485
|
+
} else {
|
|
486
|
+
// 处理单选
|
|
487
|
+
filterRows = selectRows;
|
|
488
|
+
sksResult = selectRows.map((i) => i.value)
|
|
489
|
+
// 单选直接选中 不需要确定
|
|
490
|
+
handleSelectOver(filterRows)
|
|
491
|
+
handleCancel();
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
setSelectedRowKeys(sksResult)
|
|
495
|
+
setPopValue(filterRows);
|
|
496
|
+
setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
|
|
497
|
+
setCheckedAll(filterRows.length === tablePagination?.total);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// 生成唯一值
|
|
501
|
+
const makeUniqueValue = () => {
|
|
502
|
+
const generateUnitKey = (((1+Math.random())*0x10000)|0).toString(16);
|
|
503
|
+
setUniqueValue(generateUnitKey);
|
|
504
|
+
return generateUnitKey;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const rowSelection = {
|
|
508
|
+
type: selectMode ? 'checkbox' : 'radio',
|
|
509
|
+
selectedRowKeys,
|
|
510
|
+
onChange: (sks, srs) => {
|
|
511
|
+
onChangeSelectedKeys(sks, srs)
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
const onDoubleClickSelect = (e, record) => {
|
|
516
|
+
if(!selectMode) {
|
|
517
|
+
const srs = [JSON.parse(JSON.stringify(record))]
|
|
518
|
+
const sks = srs.map((i:any) => i.value)
|
|
519
|
+
onChangeSelectedKeys(sks, srs)
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const themeColor = { color: '#1890ff' }
|
|
524
|
+
|
|
525
|
+
const formItem = (list) => {
|
|
526
|
+
if(isModalVisible && list?.length) {
|
|
527
|
+
return list.map((i: any) => {
|
|
528
|
+
if(i?.type === 'select' || i?.field?.type === 'select') {
|
|
529
|
+
return (
|
|
530
|
+
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
531
|
+
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}>
|
|
532
|
+
{i?.initialSource?.length && i?.initialSource.map((m: any) => (
|
|
533
|
+
<Option value={m.value} key={m.value}>{m.text}</Option>
|
|
534
|
+
))}
|
|
535
|
+
</Select>
|
|
536
|
+
</Form.Item>
|
|
537
|
+
)
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if(i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
|
|
541
|
+
return (
|
|
542
|
+
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
543
|
+
<TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props}></TreeSelect>
|
|
544
|
+
</Form.Item>
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if(i?.type === 'businessSearchSelect') {
|
|
549
|
+
return (
|
|
550
|
+
<div>
|
|
551
|
+
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
552
|
+
<BusinessSearchSelect {...i.field.props} />
|
|
553
|
+
</Form.Item>
|
|
554
|
+
</div>
|
|
555
|
+
)
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// 默认type是input
|
|
559
|
+
return (
|
|
560
|
+
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
561
|
+
<Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
|
|
562
|
+
</Form.Item>
|
|
563
|
+
)
|
|
564
|
+
})
|
|
565
|
+
} else {
|
|
566
|
+
return null
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const maxTagPlaceholder = (selectedValues) => {
|
|
571
|
+
const onClose = (e: any,item: any) => {
|
|
572
|
+
e.preventDefault();
|
|
573
|
+
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)
|
|
574
|
+
onChange(newValue);
|
|
575
|
+
}
|
|
576
|
+
return (
|
|
577
|
+
<Tooltip title={selectedValues.map((i: any) => (
|
|
578
|
+
<Tag
|
|
579
|
+
closable={true}
|
|
580
|
+
onClose={(e) => onClose(e,i)}
|
|
581
|
+
style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
|
|
582
|
+
>
|
|
583
|
+
{i.label}
|
|
584
|
+
</Tag>
|
|
585
|
+
))}>
|
|
586
|
+
{`+ ${selectedValues?.length}`}
|
|
587
|
+
</Tooltip>
|
|
588
|
+
)
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return (
|
|
592
|
+
<div className={'search_select'}>
|
|
593
|
+
<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
|
|
594
|
+
<Select
|
|
595
|
+
virtual
|
|
596
|
+
labelInValue={labelInValue}
|
|
597
|
+
value={value}
|
|
598
|
+
onChange={onChange}
|
|
599
|
+
dropdownRender={menu => (
|
|
600
|
+
<>
|
|
601
|
+
<Input
|
|
602
|
+
value={searchValue}
|
|
603
|
+
style={{ width: '98%', marginLeft: '1%' }}
|
|
604
|
+
placeholder="请输入"
|
|
605
|
+
onChange={e=> onSearchChange(e)}
|
|
606
|
+
onBlur={onSearchBlur}
|
|
607
|
+
onKeyDown={(e) => {
|
|
608
|
+
// 阻止多选的冒泡
|
|
609
|
+
e.stopPropagation()
|
|
610
|
+
}}
|
|
611
|
+
/>
|
|
612
|
+
<Divider style={{ margin: '8px 0' }} />
|
|
613
|
+
{menu}
|
|
614
|
+
</>
|
|
615
|
+
)}
|
|
616
|
+
notFoundContent={
|
|
617
|
+
fetching ? <Spin size="small" /> :
|
|
618
|
+
<div style={{ textAlign: 'center'}}>
|
|
619
|
+
<div style={{ marginBottom: 16 }}>
|
|
620
|
+
<CopyOutlined style={{ fontSize: '50px' }} />
|
|
621
|
+
</div>
|
|
622
|
+
<div>无匹配结果,请更换其他内容再试</div>
|
|
623
|
+
</div>
|
|
624
|
+
}
|
|
625
|
+
onPopupScroll={SelectScroll}
|
|
626
|
+
style={{ width: needModalTable?'calc(100% - 30px)':'calc(100%)' }}
|
|
627
|
+
placeholder="请选择"
|
|
628
|
+
maxTagPlaceholder={maxTagPlaceholder}
|
|
629
|
+
{...currentSelectProps}
|
|
630
|
+
getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
|
|
631
|
+
>
|
|
632
|
+
{items.map(item => (
|
|
633
|
+
<Option key={item.value} label={item.text}>
|
|
634
|
+
{LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
|
|
635
|
+
</Option>
|
|
636
|
+
))}
|
|
637
|
+
</Select>
|
|
638
|
+
{needModalTable && (
|
|
639
|
+
<Button style={{width: '30px', padding: '2px', height: 'auto'}} onClick={showModal} type="primary">
|
|
640
|
+
<SearchOutlined />
|
|
641
|
+
</Button>
|
|
642
|
+
)}
|
|
643
|
+
</div>
|
|
644
|
+
{needModalTable && isModalVisible && (
|
|
645
|
+
<Modal
|
|
646
|
+
width='80%'
|
|
647
|
+
title={modalTableProps?.modalTableTitle}
|
|
648
|
+
visible={isModalVisible}
|
|
649
|
+
onOk={handleOk}
|
|
650
|
+
onCancel={handleCancel}
|
|
651
|
+
footer={selectMode?[
|
|
652
|
+
<Button key="back" onClick={handleCancel}>
|
|
653
|
+
取消
|
|
654
|
+
</Button>,
|
|
655
|
+
<Button
|
|
656
|
+
key="submit"
|
|
657
|
+
type="primary"
|
|
658
|
+
onClick={handleOk}
|
|
659
|
+
disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
|
|
660
|
+
>
|
|
661
|
+
确定
|
|
662
|
+
</Button>,
|
|
663
|
+
]:null}
|
|
664
|
+
>
|
|
665
|
+
<div className={'search_select_wrapper'}>
|
|
666
|
+
<div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
|
|
667
|
+
<CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1' } />
|
|
668
|
+
</div>
|
|
669
|
+
<div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
|
|
670
|
+
<div className={'select_list_columns'}>
|
|
671
|
+
<div className={'select_list_columns_tips'}>搜索</div>
|
|
672
|
+
<div className={'select_list_columns_formItems'}>
|
|
673
|
+
<Form form={form} layout='vertical' key='modalForm'>
|
|
674
|
+
{formItem(modalTableProps?.tableSearchForm)}
|
|
675
|
+
</Form>
|
|
676
|
+
</div>
|
|
677
|
+
</div>
|
|
678
|
+
<div className={'select_list_searchButton'}>
|
|
679
|
+
<Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
|
|
680
|
+
<Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
|
|
681
|
+
</div>
|
|
682
|
+
</div>
|
|
683
|
+
<div className={caretLeftFlag ? 'search_select_wrapper_right': 'search_select_wrapper_right1'}>
|
|
684
|
+
<div>
|
|
685
|
+
<div className={'select_list_selectTips'}>
|
|
686
|
+
<div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
|
|
687
|
+
<div style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}>{selectMode ? '勾选后点击确定按钮完成选择' : '双击数据行或点击单选图标完成选择'}</div>
|
|
688
|
+
</div>
|
|
689
|
+
<Table
|
|
690
|
+
size='small'
|
|
691
|
+
rowSelection={rowSelection}
|
|
692
|
+
columns={modalTableProps?.tableColumns}
|
|
693
|
+
dataSource={tableData}
|
|
694
|
+
pagination={tablePagination}
|
|
695
|
+
onChange={handleTableChange}
|
|
696
|
+
rowKey={mappingValueField}
|
|
697
|
+
scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
|
|
698
|
+
onRow={record => {
|
|
699
|
+
return {
|
|
700
|
+
onDoubleClick: event => onDoubleClickSelect(event, record),
|
|
701
|
+
};
|
|
702
|
+
}}
|
|
703
|
+
/>
|
|
704
|
+
{selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} /> 全选所有页面</div> : ''}
|
|
705
|
+
</div>
|
|
706
|
+
</div>
|
|
707
|
+
</div>
|
|
708
|
+
</Modal>
|
|
709
|
+
)}
|
|
710
|
+
</div>
|
|
711
|
+
);
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
export default SearchSelect;
|