@bit-sun/business-component 4.0.12-alpha.26 → 4.0.12-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Functional/SearchSelect/utils.d.ts +7 -1
- package/dist/index.esm.js +595 -686
- package/dist/index.js +595 -686
- package/package.json +1 -1
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +1 -1
- package/src/components/Functional/SearchSelect/index.tsx +19 -137
- package/src/components/Functional/SearchSelect/utils.ts +58 -7
- package/src/components/Solution/RuleComponent/ruleFiled.js +85 -85
package/package.json
CHANGED
|
@@ -328,7 +328,7 @@ export function commonFun (type?: string, prefixUrl: any, parentProps?:any) {
|
|
|
328
328
|
tableSearchForm = [
|
|
329
329
|
{ name: 'qp-skuCode-in', label: 'SKU编码',type:'multipleQueryInput' },
|
|
330
330
|
{ name: 'qp-skuName-like', label: 'SKU名称' },
|
|
331
|
-
{ name: 'qp-itemCode-like', label: '
|
|
331
|
+
{ name: 'qp-itemCode-like', label: 'SPU编码' },
|
|
332
332
|
{ name: 'qp-eancode-in', label: '商品条码', field: {
|
|
333
333
|
type: 'multipleQueryInput',
|
|
334
334
|
props: {
|
|
@@ -4,11 +4,10 @@ import { useDebounceFn } from 'ahooks';
|
|
|
4
4
|
import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag, Row, Col, Space, Tabs } from 'antd';
|
|
5
5
|
import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
|
|
6
6
|
import request from '@/utils/request';
|
|
7
|
-
import { stringify } from 'querystring';
|
|
8
7
|
import _, { escapeRegExp, isNil, values } from "lodash"
|
|
9
8
|
import './index.less';
|
|
10
9
|
import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
|
|
11
|
-
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource } from './utils';
|
|
10
|
+
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource, convertUrlQueryParams, convertBodyParams, formatSelectedValue } from './utils';
|
|
12
11
|
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
13
12
|
import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
|
|
14
13
|
import PropertySelector from '@/components/Business/PropertyModal';
|
|
@@ -35,6 +34,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
35
34
|
} = props;
|
|
36
35
|
const {
|
|
37
36
|
url,
|
|
37
|
+
method = 'get',
|
|
38
38
|
otherParams,// 默认参数
|
|
39
39
|
isMap,
|
|
40
40
|
fixedparameter,
|
|
@@ -78,7 +78,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
78
78
|
var pattern = /(action|create|edit|view)/
|
|
79
79
|
const isFormPage = pathname.match(pattern)?.length > 0;
|
|
80
80
|
|
|
81
|
-
const initPagination = { showQuickJumper: true, showSizeChanger:
|
|
81
|
+
const initPagination = { showQuickJumper: true, showSizeChanger: true, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
|
|
82
82
|
const tableInitPagination = { ...initPagination, total: 0, current: 1 }
|
|
83
83
|
const disabled = noOperate || selectProps?.disabled || props?.disabled;
|
|
84
84
|
const isHaveDependency = fixedparameter && fieldValToParam && ctx;
|
|
@@ -182,7 +182,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
182
182
|
}))
|
|
183
183
|
|
|
184
184
|
// 获取数据源 (type: 1下拉框 2/3弹框 不传值默认为下拉框)
|
|
185
|
-
const getData = (params = {}, type = 1,callback?: any
|
|
185
|
+
const getData = (params = {}, type = 1,callback?: any) => {
|
|
186
186
|
if (!requestConfig) return;
|
|
187
187
|
|
|
188
188
|
setFetching(true)
|
|
@@ -330,114 +330,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
330
330
|
queryParams[selectParamsKey] = searchValue;
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
setFetching(false)
|
|
340
|
-
result = result.data;
|
|
341
|
-
if (judgeIsRequestError(result)) {
|
|
342
|
-
message.error(result.msg);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const res = result.data;
|
|
346
|
-
let source = [];
|
|
347
|
-
if (isMap) {
|
|
348
|
-
source = Object.keys(res).map((d, i) => {
|
|
349
|
-
return {
|
|
350
|
-
text: Object.values(res)[i],
|
|
351
|
-
value: d,
|
|
352
|
-
};
|
|
353
|
-
});
|
|
354
|
-
} else {
|
|
355
|
-
const keys = res.list ? 'list' : 'items';
|
|
356
|
-
source = res
|
|
357
|
-
? res[keys]
|
|
358
|
-
? res[keys].map((item: any, index: number) => {
|
|
359
|
-
let textShowText = item[mappingTextField]
|
|
360
|
-
if (mappingTextShowTextField) {
|
|
361
|
-
textShowText = []
|
|
362
|
-
if (Array.isArray(mappingTextShowTextField)) {
|
|
363
|
-
mappingTextShowTextField.forEach((r: any) => {
|
|
364
|
-
textShowText.push(item[r])
|
|
365
|
-
})
|
|
366
|
-
} else {
|
|
367
|
-
textShowText = item[mappingTextShowTextField]
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (!item?.children?.length) { delete item?.children };
|
|
371
|
-
return {
|
|
372
|
-
...item,
|
|
373
|
-
text: specialBracket
|
|
374
|
-
? `【${item[mappingValueField]}】${item[mappingTextField]}`
|
|
375
|
-
: item[mappingTextField],
|
|
376
|
-
textShowText,
|
|
377
|
-
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
378
|
-
value: item[mappingValueField],
|
|
379
|
-
keyIndex: type != 1 ? ((queryParams?.currentPage - 1) * queryParams?.pageSize + index + 1) : (index + 1),
|
|
380
|
-
};
|
|
381
|
-
})
|
|
382
|
-
: Array.isArray(res) &&
|
|
383
|
-
res?.map((item: Record<string, any>, index: number) => {
|
|
384
|
-
let textShowText = item[mappingTextField]
|
|
385
|
-
if (mappingTextShowTextField) {
|
|
386
|
-
textShowText = []
|
|
387
|
-
if (Array.isArray(mappingTextShowTextField)) {
|
|
388
|
-
mappingTextShowTextField.forEach((r: any) => {
|
|
389
|
-
textShowText.push(item[r])
|
|
390
|
-
})
|
|
391
|
-
} else {
|
|
392
|
-
textShowText = item[mappingTextShowTextField]
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
if (!item?.children?.length) { delete item?.children };
|
|
396
|
-
return {
|
|
397
|
-
...item,
|
|
398
|
-
text: specialBracket
|
|
399
|
-
? `【${item[mappingValueField]}】${item[mappingTextField]}`
|
|
400
|
-
: item[mappingTextField],
|
|
401
|
-
textShowText,
|
|
402
|
-
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
403
|
-
value: item[mappingValueField],
|
|
404
|
-
keyIndex: type != 1 ? ((queryParams?.currentPage - 1) * queryParams?.pageSize + index + 1) : (index + 1),
|
|
405
|
-
};
|
|
406
|
-
})
|
|
407
|
-
: [];
|
|
408
|
-
}
|
|
409
|
-
// 补充搜索项--选中的数据添加到数据源中去
|
|
410
|
-
const currentSRKs = getCurrentSRKs(selectMode, labelInValue, value)
|
|
411
|
-
if (type === 1 && currentSRKs?.length && currentSRKs?.some(s => !source?.find(r => r.value == s))) {
|
|
412
|
-
const selectedOption = items.filter(option => currentSRKs?.includes(option.value)) || [];
|
|
413
|
-
source = (source || []).concat(selectedOption)
|
|
414
|
-
}
|
|
415
|
-
// 数据源 不可以有重复key
|
|
416
|
-
source = Array.isArray(source) ? _.uniqBy(source, 'value') : [];
|
|
417
|
-
|
|
418
|
-
if (callback) {
|
|
419
|
-
callback(source)
|
|
420
|
-
} else {
|
|
421
|
-
if (type === 1) {
|
|
422
|
-
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
423
|
-
setSelectDataSource(source, (Number(res?.total || res?.totalCount || source.length)))
|
|
424
|
-
} else {
|
|
425
|
-
setTableData(source)
|
|
426
|
-
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)) })
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
})
|
|
430
|
-
.catch((err) => { setFetching(false) });
|
|
431
|
-
return;
|
|
333
|
+
let getRequest;
|
|
334
|
+
const methodName = method?.toLocaleLowerCase();
|
|
335
|
+
if(['post','patch','put'].includes(methodName)) {
|
|
336
|
+
getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams))
|
|
337
|
+
} else {
|
|
338
|
+
getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
|
|
432
339
|
}
|
|
433
340
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
`${url}?${stringify(queryParams)}`, {
|
|
438
|
-
headers: { ...extralHeaders }
|
|
439
|
-
})
|
|
440
|
-
.then((result: any) => {
|
|
341
|
+
if (!url || !getRequest) return;
|
|
342
|
+
|
|
343
|
+
getRequest.then((result: any) => {
|
|
441
344
|
setFetching(false)
|
|
442
345
|
result = result.data;
|
|
443
346
|
if (judgeIsRequestError(result)) {
|
|
@@ -736,17 +639,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
736
639
|
|
|
737
640
|
const onSearchTable = () => {
|
|
738
641
|
const params = form.getFieldsValue();
|
|
739
|
-
|
|
740
|
-
// const isHaveParams = params && Object.keys(params).filter(item => params[item]).length > 0;
|
|
741
642
|
setModalSearched(true);
|
|
742
|
-
|
|
743
|
-
let unique_params = null;
|
|
744
|
-
if (params['UNIQUE_SPEC']) {
|
|
745
|
-
unique_params = params['UNIQUE_SPEC']?.propertyList || [];
|
|
746
|
-
}
|
|
747
|
-
|
|
748
643
|
setTableFormParams(params);
|
|
749
|
-
getData({ ...params, pageSize: tableInitPageSize }, 2, null
|
|
644
|
+
getData({ ...params, pageSize: tableInitPageSize }, 2, null);
|
|
750
645
|
}
|
|
751
646
|
|
|
752
647
|
const onResetTable = () => {
|
|
@@ -956,14 +851,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
956
851
|
return collapsed ? formItem(list?.slice(0,viCount)) : formItem(list)
|
|
957
852
|
}
|
|
958
853
|
|
|
959
|
-
// const queryFieldsDom = <SearchItemTable
|
|
960
|
-
// ref={searchTableRef}
|
|
961
|
-
// setShowSearchFields={setShowSearchFields||[]}
|
|
962
|
-
// showSearchFields={showSearchFields||[]}
|
|
963
|
-
// datasource={modalTableProps?.tableSearchForm || []}
|
|
964
|
-
// bsTableCode={bsTableCode}
|
|
965
|
-
// />
|
|
966
|
-
|
|
967
854
|
const renderShowTable = (tableList, type) => {
|
|
968
855
|
const tableBoxHeighth = getTableHeigth(modalTableProps?.tableSearchForm);
|
|
969
856
|
const oSY = `calc(100vh - ${tableBoxHeighth}px - 82px)`; // 分页 24+16*2+10 「高 + margin * 2 + paddingBottom 10 」
|
|
@@ -976,7 +863,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
976
863
|
columns={tableShowColumns}
|
|
977
864
|
dataSource={tableList}
|
|
978
865
|
{...type=='noPage'?{
|
|
979
|
-
pagination: initPagination,
|
|
866
|
+
pagination: { ...initPagination,showSizeChanger: false },
|
|
980
867
|
locale: {
|
|
981
868
|
emptyText: '暂无已选结果',
|
|
982
869
|
}
|
|
@@ -1031,7 +918,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1031
918
|
}
|
|
1032
919
|
|
|
1033
920
|
const onDeselect = (...arg) => {
|
|
1034
|
-
const oldSelect =
|
|
921
|
+
const oldSelect = formatSelectedValue(value);
|
|
1035
922
|
const deRecord = arg[1];
|
|
1036
923
|
const srs = oldSelect.filter((s: any) => s.value != deRecord?.value)
|
|
1037
924
|
onSelectClick(srs, items,false)
|
|
@@ -1070,7 +957,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1070
957
|
selectedRowKeys: currentSRKs,
|
|
1071
958
|
preserveSelectedRowKeys: true, // 避免搜索之后 没有了选中前的数据 保证sks的正确性
|
|
1072
959
|
onChange: (sks, srs) => {
|
|
1073
|
-
const oldSelect =
|
|
960
|
+
const oldSelect = formatSelectedValue(value);
|
|
1074
961
|
let tmpSelectedRows = oldSelect.concat(srs).filter(item => item != undefined);
|
|
1075
962
|
let realSrs = sks.map(key => tmpSelectedRows.filter(item => item.value == key)[0]).filter(item => item != undefined)
|
|
1076
963
|
onSelectClick(realSrs, dataSource,false)
|
|
@@ -1081,11 +968,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1081
968
|
event.stopPropagation();
|
|
1082
969
|
event.nativeEvent.stopImmediatePropagation();
|
|
1083
970
|
|
|
1084
|
-
const oldSelect = value
|
|
1085
|
-
value: s?.value||s,
|
|
1086
|
-
key: s?.key||s,
|
|
1087
|
-
label: s?.label|| '',
|
|
1088
|
-
}))||[];
|
|
971
|
+
const oldSelect = formatSelectedValue(value);
|
|
1089
972
|
const newSelect = [JSON.parse(JSON.stringify(record))];
|
|
1090
973
|
const srs = getRealStr(oldSelect,newSelect,record);
|
|
1091
974
|
onSelectClick(srs,dataSource,false)
|
|
@@ -1244,7 +1127,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1244
1127
|
suffixIcon: <div className={`search_select_expand_button ${(sDisabled)?'search_select_expand_button_disabled':''}`} onClick={showModal}><SearchOutlined /></div>
|
|
1245
1128
|
} : {})}
|
|
1246
1129
|
{...currentSelectProps}
|
|
1247
|
-
getPopupContainer={(triggerNode) => (highestPopContainer && highestPopContainer()) || triggerNode.parentElement
|
|
1130
|
+
getPopupContainer={(triggerNode) => (highestPopContainer && highestPopContainer(triggerNode)) || triggerNode.parentElement}
|
|
1248
1131
|
>
|
|
1249
1132
|
{items.map(item => (
|
|
1250
1133
|
<Option key={item.value} label={item.text}>
|
|
@@ -1302,7 +1185,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1302
1185
|
<Button key="reset" onClick={onResetTable}>
|
|
1303
1186
|
重置 ctrl+U
|
|
1304
1187
|
</Button>
|
|
1305
|
-
{/* <div>{queryFieldsDom}</div> */}
|
|
1306
1188
|
<div style={{position: 'absolute',top: 0,right: 0}}>
|
|
1307
1189
|
{hasMoreQueryFields(modalTableProps) && modalTableProps?.isHorizontally
|
|
1308
1190
|
? <img onClick={() => {toggleCollapsed()}} style={{
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { stringify } from 'querystring';
|
|
2
|
+
import { omit } from "lodash"
|
|
3
|
+
|
|
1
4
|
export const columnsPerRow = 4; // 每行的列数
|
|
2
5
|
export const ColSpan = 6; // 查询条件 每行col = 24 /columnsPerRow
|
|
3
6
|
export const handleSourceName = (sName: any) => {
|
|
@@ -27,11 +30,6 @@ export const hasMoreQueryFields = (modalTableProps: any) => {
|
|
|
27
30
|
const visibleFieldsCount = getVisibleFieldsCount(modalTableProps);
|
|
28
31
|
return visibleFieldsCount < tableSearchForm?.length;
|
|
29
32
|
}
|
|
30
|
-
|
|
31
|
-
export const getRealStr = (oldSelect: any,newSelect: any, record: any) => {
|
|
32
|
-
return oldSelect?.length ? oldSelect.some((o: any) => o.value == record?.value) ? oldSelect.filter((s: any) => s.value != record?.value) : [...oldSelect,...newSelect] : newSelect;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
33
|
export const getTableHeigth = (list: any) => {
|
|
36
34
|
const totalRows = Math.ceil((list?.length+1) / 4);
|
|
37
35
|
if(totalRows == 1) return 358; // modal弹窗760 调整为700 适应小屏
|
|
@@ -42,10 +40,19 @@ export const getTableHeigth = (list: any) => {
|
|
|
42
40
|
|
|
43
41
|
|
|
44
42
|
// ------------------------------------------处理数据相关--开始----------------------------------------
|
|
43
|
+
export const formatSelectedValue = (value: any) => {
|
|
44
|
+
return value?.map((s: any) => ({
|
|
45
|
+
value: s?.value||s,
|
|
46
|
+
key: s?.key||s?.value||s,
|
|
47
|
+
label: s?.label|| '',
|
|
48
|
+
}))||[];
|
|
49
|
+
}
|
|
50
|
+
export const getRealStr = (oldSelect: any,newSelect: any, record: any) => {
|
|
51
|
+
return oldSelect?.length ? oldSelect.some((o: any) => o.value == record?.value) ? oldSelect.filter((s: any) => s.value != record?.value) : [...oldSelect,...newSelect] : newSelect;
|
|
52
|
+
}
|
|
45
53
|
export const getCurrentSRKs = (selectMode: any,labelInValue:boolean,value: any) => {
|
|
46
54
|
return selectMode ? (labelInValue ? value?.map((s: any)=> (s?.value||s)) : value) : (labelInValue ? value?.value&&[value?.value]||[] : value&&[value]||[])
|
|
47
55
|
}
|
|
48
|
-
|
|
49
56
|
export const getRenderSource = (currentSRKs: any, items: any) => {
|
|
50
57
|
// 判空处理
|
|
51
58
|
if(!currentSRKs?.length) return items||[];
|
|
@@ -71,4 +78,48 @@ export const getRenderSource = (currentSRKs: any, items: any) => {
|
|
|
71
78
|
]
|
|
72
79
|
}
|
|
73
80
|
|
|
74
|
-
// ------------------------------------------处理数据相关--结束----------------------------------------
|
|
81
|
+
// ------------------------------------------处理数据相关--结束----------------------------------------
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// ------------------------------------------查询相关--开始----------------------------------------
|
|
86
|
+
|
|
87
|
+
//处理单据编号查询 如果是查询单条数据 就是模糊查询 两条以上就是精准查询
|
|
88
|
+
export const convertOrderNo = (params: any) => {
|
|
89
|
+
//需要处理得编号字段名
|
|
90
|
+
const arr = [
|
|
91
|
+
'qp-skuCode-in',
|
|
92
|
+
'qp-eancode-in',
|
|
93
|
+
];
|
|
94
|
+
for (let i = 0; i < arr.length; i++) {
|
|
95
|
+
if (params[arr[i]]) {
|
|
96
|
+
if (!params[arr[i]].includes(',')) {
|
|
97
|
+
params[arr[i].replace(/(.*)in/, '$1like')] = params[arr[i]];
|
|
98
|
+
delete params[arr[i]];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return params;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const convertQueryParams = (params: any) => {
|
|
106
|
+
const result = convertOrderNo(params)
|
|
107
|
+
return omit(result,['UNIQUE_SPEC']); // 处理sku选择器属性参数
|
|
108
|
+
}
|
|
109
|
+
export const convertUrlQueryParams = (params: any) => {
|
|
110
|
+
// 非query请求:默认参数拼接URL,设置属性noUrlQueryParams可不拼接
|
|
111
|
+
return params?.noUrlQueryParams ? '' : `?${stringify(convertQueryParams(params))}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const convertBodyParams = (params: any) => {
|
|
115
|
+
// 处理sku选择器属性参数
|
|
116
|
+
let unique_params = null;
|
|
117
|
+
if (params['UNIQUE_SPEC']) {
|
|
118
|
+
unique_params = params['UNIQUE_SPEC']?.propertyList || [];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// body参数来源:sku选择器固定参数 > 调用所传bodyParams > 默认参数-无
|
|
122
|
+
return unique_params || params?.bodyParams || null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ------------------------------------------查询相关--结束----------------------------------------
|