@bit-sun/business-component 2.2.9 → 2.2.10
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/Business/AddSelectBusiness/index.d.ts +1 -0
- package/dist/index.esm.js +551 -27
- package/dist/index.js +551 -26
- package/package.json +1 -1
- package/src/components/Business/AddSelectBusiness/index.md +33 -3
- package/src/components/Business/AddSelectBusiness/index.tsx +260 -3
- package/src/components/Business/CommodityEntry/index.md +1 -1
- package/src/components/Business/SearchSelect/BusinessUtils.ts +137 -0
- package/src/components/Business/SearchSelect/index.md +56 -0
- package/src/components/Business/SearchSelect/utils.ts +1 -1
- package/src/components/Functional/AddSelect/index.tsx +117 -24
- package/src/utils/requestUtils.ts +2 -0
|
@@ -12,7 +12,7 @@ import { Resizable } from 'react-resizable';
|
|
|
12
12
|
import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
|
|
13
13
|
import TableColumnSetting from '@/plugin/TableColumnSetting';
|
|
14
14
|
import { setInitialShowColumn } from '@/plugin/TableColumnSetting/utils';
|
|
15
|
-
import { handleAntdColumnsSpecialParams } from '@/utils/utils';
|
|
15
|
+
import { handleAntdColumnsSpecialParams, uuid } from '@/utils/utils';
|
|
16
16
|
import { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
|
|
17
17
|
|
|
18
18
|
const loadSelectSource = (url: string, params?: any) => {
|
|
@@ -100,10 +100,13 @@ const AddSelect = (props: any) => {
|
|
|
100
100
|
buttonProps = {},
|
|
101
101
|
beforeShowModal,
|
|
102
102
|
tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
|
|
103
|
+
businessType = 'sku',
|
|
104
|
+
isAllowRepeatedSelect = false
|
|
103
105
|
} = props;
|
|
104
106
|
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField = 'name', mappingTextShowKeyField, mappingValueField = 'code', mappingTextShowTextField } = requestConfig || {};
|
|
105
107
|
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
106
108
|
const realButtonProps = {type: "primary", ...buttonProps};
|
|
109
|
+
const selectRowKey = isAllowRepeatedSelect ? 'uuid' : mappingValueField
|
|
107
110
|
|
|
108
111
|
const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
|
|
109
112
|
const initVal = value || (selectMode ? [] : null);
|
|
@@ -188,7 +191,9 @@ const AddSelect = (props: any) => {
|
|
|
188
191
|
if(record.needFocus === true && currentIndex === 0) {
|
|
189
192
|
|
|
190
193
|
}
|
|
191
|
-
let precisionObj={
|
|
194
|
+
let precisionObj=businessType == 'skc'?{
|
|
195
|
+
precision: 0
|
|
196
|
+
}:{};
|
|
192
197
|
const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
|
|
193
198
|
const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
|
|
194
199
|
if(isCountUnitAccuracyCheck) {
|
|
@@ -305,6 +310,52 @@ const AddSelect = (props: any) => {
|
|
|
305
310
|
}
|
|
306
311
|
}
|
|
307
312
|
|
|
313
|
+
const selectLength = modalTableProps.selectColumn.filter(item => item.isSelectItem).length
|
|
314
|
+
const currentSelectIndex = selectIndex
|
|
315
|
+
if(item.isSelectItem) {
|
|
316
|
+
selectIndex++;
|
|
317
|
+
return {
|
|
318
|
+
...item,
|
|
319
|
+
render: (text, record, index) => {
|
|
320
|
+
if (item.dataSource?.length) {
|
|
321
|
+
return (
|
|
322
|
+
<Select
|
|
323
|
+
value={text || null}
|
|
324
|
+
onChange={(value) => {
|
|
325
|
+
if(businessType == 'skc' && popvalue.some((i: any) => i.code == record.code && i[item.dataIndex] == value)) {
|
|
326
|
+
message.warning('相同skc配码不可设置相同哦')
|
|
327
|
+
record[item.dataIndex] = null;
|
|
328
|
+
const newPopValue = popvalue.map((i: any, innerIndex: number) => {
|
|
329
|
+
if(innerIndex == index) {
|
|
330
|
+
i[item.dataIndex] = record[item.dataIndex]
|
|
331
|
+
}
|
|
332
|
+
return i
|
|
333
|
+
})
|
|
334
|
+
setPopValue(newPopValue)
|
|
335
|
+
return false
|
|
336
|
+
}
|
|
337
|
+
record[item.dataIndex] = value
|
|
338
|
+
const newPopValue = popvalue.map((i: any, innerIndex: number) => {
|
|
339
|
+
if(innerIndex == index) {
|
|
340
|
+
i[item.dataIndex] = record[item.dataIndex]
|
|
341
|
+
}
|
|
342
|
+
return i
|
|
343
|
+
})
|
|
344
|
+
setPopValue(newPopValue)
|
|
345
|
+
}}
|
|
346
|
+
style={{width: '160px'}}
|
|
347
|
+
>
|
|
348
|
+
{item.dataSource.map((item: any) => {
|
|
349
|
+
return <Select.Option value={item.code}>{item.name}</Select.Option>
|
|
350
|
+
})}
|
|
351
|
+
</Select>
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
return <></>
|
|
355
|
+
},
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
308
359
|
return item
|
|
309
360
|
}), {
|
|
310
361
|
title: '操作',
|
|
@@ -543,21 +594,50 @@ const AddSelect = (props: any) => {
|
|
|
543
594
|
}
|
|
544
595
|
|
|
545
596
|
useEffect(() => {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
597
|
+
if(businessType == 'sku') {
|
|
598
|
+
Promise.all([
|
|
599
|
+
loadSelectSource(`/items/brand/queryBrandList`, {
|
|
600
|
+
pageSize: 5000,
|
|
601
|
+
currentPage: 1,
|
|
602
|
+
'ctl-withAuth': true
|
|
603
|
+
}),
|
|
604
|
+
loadSelectSource(`/items/category/queryCategoryTree`, {
|
|
605
|
+
pageSize: 5000,
|
|
606
|
+
currentPage: 1,
|
|
607
|
+
}),
|
|
608
|
+
]).then((x: any)=>{
|
|
609
|
+
formatSource(x,0, 2, tableSearchForm,['id','name'])
|
|
610
|
+
formatTreeDataSource(x,1, 3, tableSearchForm)
|
|
611
|
+
})
|
|
612
|
+
}
|
|
613
|
+
if(businessType == 'skc') {
|
|
614
|
+
Promise.all([
|
|
615
|
+
loadSelectSource(`/items/item/propertyValue`, {
|
|
616
|
+
pageSize: 5000,
|
|
617
|
+
currentPage: 1,
|
|
618
|
+
'qp-propertyId-eq': '1467042217951883265'
|
|
619
|
+
}),
|
|
620
|
+
loadSelectSource(`/items/category/queryCategoryTree`, {
|
|
621
|
+
pageSize: 5000,
|
|
622
|
+
currentPage: 1,
|
|
623
|
+
}),
|
|
624
|
+
loadSelectSource(`/items/class/withProperty`, {
|
|
625
|
+
pageSize: 5000,
|
|
626
|
+
currentPage: 1,
|
|
627
|
+
}),
|
|
628
|
+
loadSelectSource(`/items/brand/queryBrandList`, {
|
|
629
|
+
pageSize: 5000,
|
|
630
|
+
currentPage: 1,
|
|
631
|
+
'ctl-withAuth': true
|
|
632
|
+
}),
|
|
633
|
+
]).then((x: any)=>{
|
|
634
|
+
formatSource(x,0, 3, tableSearchForm,['value','value'])
|
|
635
|
+
formatTreeDataSource(x,1, 4, tableSearchForm)
|
|
636
|
+
formatSource(x,2, 5, tableSearchForm,['id','name'])
|
|
637
|
+
formatSource(x,3, 6, tableSearchForm,['id','name'])
|
|
638
|
+
})
|
|
639
|
+
}
|
|
640
|
+
}, [businessType])
|
|
561
641
|
|
|
562
642
|
useEffect(() => {
|
|
563
643
|
if (value) {
|
|
@@ -719,8 +799,14 @@ const AddSelect = (props: any) => {
|
|
|
719
799
|
selectRows[selectedRowKeys.length]['needFocus'] = true;
|
|
720
800
|
}
|
|
721
801
|
}
|
|
722
|
-
|
|
723
|
-
|
|
802
|
+
if(isAllowRepeatedSelect) {
|
|
803
|
+
const list = popvalue.concat(selectRows).map((i: any) => ({...i, uuid: i.uuid || uuid()}))
|
|
804
|
+
setPopValue(list);
|
|
805
|
+
setSelectedRowKeys([])
|
|
806
|
+
} else {
|
|
807
|
+
setPopValue(selectRows);
|
|
808
|
+
setSelectedRowKeys(selectKeys)
|
|
809
|
+
}
|
|
724
810
|
// setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
|
|
725
811
|
// setCheckedAll(filterRows.length === tablePagination?.total);
|
|
726
812
|
}
|
|
@@ -844,11 +930,17 @@ const AddSelect = (props: any) => {
|
|
|
844
930
|
}
|
|
845
931
|
|
|
846
932
|
const deleteRecord = (record) => {
|
|
847
|
-
|
|
848
|
-
|
|
933
|
+
if(isAllowRepeatedSelect) {
|
|
934
|
+
setPopValue(popvalue.filter(item => item.uuid !== record.uuid))
|
|
935
|
+
setSelectedRowKeys([])
|
|
936
|
+
} else {
|
|
937
|
+
setPopValue(popvalue.filter(item => item.skuCode !== record.skuCode))
|
|
938
|
+
setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record.skuCode)])
|
|
939
|
+
}
|
|
849
940
|
}
|
|
850
941
|
|
|
851
942
|
let inputIndex = 0;
|
|
943
|
+
let selectIndex = 0;
|
|
852
944
|
|
|
853
945
|
useEffect(() => {
|
|
854
946
|
setInitialShowColumn(codeSelected,selectColumns,(res) => {
|
|
@@ -915,6 +1007,7 @@ const AddSelect = (props: any) => {
|
|
|
915
1007
|
})
|
|
916
1008
|
handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
|
|
917
1009
|
|
|
1010
|
+
const selectLength = isAllowRepeatedSelect ? (popvalue?.length || 0) : (selectedRowKeys?.length || 0)
|
|
918
1011
|
return (
|
|
919
1012
|
<div className={'add_select'}>
|
|
920
1013
|
<div className="add_select_show" id={`add_select_div_${uniqueValue}`}>
|
|
@@ -978,7 +1071,7 @@ const AddSelect = (props: any) => {
|
|
|
978
1071
|
<div className={caretLeftFlag ? 'add_select_wrapper_right' : 'add_select_wrapper_right1'}>
|
|
979
1072
|
<div>
|
|
980
1073
|
<div className={'select_list_selectTips'}>
|
|
981
|
-
<div style={{ marginLeft: 8 }}>搜索结果共 <span style={themeColor}>{tablePagination?.total || 0}</span> 项{selectMode ? <span>, 本次已选 <span style={themeColor}>{
|
|
1074
|
+
<div style={{ marginLeft: 8 }}>搜索结果共 <span style={themeColor}>{tablePagination?.total || 0}</span> 项{selectMode ? <span>, 本次已选 <span style={themeColor}>{selectLength}</span> 项</span> : ''}</div>
|
|
982
1075
|
<div>
|
|
983
1076
|
<span style={{ marginRight: 8 }}>
|
|
984
1077
|
<TableColumnSetting
|
|
@@ -1027,7 +1120,7 @@ const AddSelect = (props: any) => {
|
|
|
1027
1120
|
</div>
|
|
1028
1121
|
<div className={'add_select_wrapper_select'}>
|
|
1029
1122
|
<div className={'select_list_selectTips'}>
|
|
1030
|
-
<div style={{ marginLeft: 8 }}><span>本次已选 <span style={themeColor}>{
|
|
1123
|
+
<div style={{ marginLeft: 8 }}><span>本次已选 <span style={themeColor}>{selectLength}</span> 项</span></div>
|
|
1031
1124
|
<div style={{ display: 'flex' }}>
|
|
1032
1125
|
<span style={{ marginRight: 8 }}>
|
|
1033
1126
|
<TableColumnSetting
|
|
@@ -1047,7 +1140,7 @@ const AddSelect = (props: any) => {
|
|
|
1047
1140
|
dataSource={popvalue}
|
|
1048
1141
|
pagination={false}
|
|
1049
1142
|
// onChange={handleTableChange}
|
|
1050
|
-
rowKey={
|
|
1143
|
+
rowKey={selectRowKey}
|
|
1051
1144
|
rowClassName={'row-class'}
|
|
1052
1145
|
scroll={{ y: 500 }}
|
|
1053
1146
|
onRow={record => {
|
|
@@ -20,6 +20,8 @@ export function handleRequestAuthHeader(config?: any) {
|
|
|
20
20
|
// 处理请求头
|
|
21
21
|
const handleRequestHeader = (config: any) => {
|
|
22
22
|
config.headers['sso-sessionid'] = resposne?.sessionId || ''
|
|
23
|
+
config.headers['x-account-id'] = resposne?.accountPersonDetail?.accountId || -1
|
|
24
|
+
config.headers['x-employee-id'] = resposne?.employeeResVo?.id || 2
|
|
23
25
|
config.headers['x-tenant-id'] = getCurrentTenantId() || 1
|
|
24
26
|
if (localStorage.getItem('x-user-auth-context')) {
|
|
25
27
|
config.headers['x-user-auth-context'] = localStorage.getItem('x-user-auth-context');
|