@bit-sun/business-component 2.0.2 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Business/AddSelectBusiness/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +543 -85
- package/dist/index.js +543 -84
- package/package.json +1 -1
- package/src/components/Business/AddSelectBusiness/index.md +41 -0
- package/src/components/Business/AddSelectBusiness/index.tsx +299 -0
- package/src/components/Business/CommodityEntry/index.tsx +5 -2
- package/src/components/Business/SearchSelect/BusinessUtils.ts +1 -0
- package/src/components/Functional/AddSelect/index.less +10 -1
- package/src/components/Functional/AddSelect/index.md +3 -1
- package/src/components/Functional/AddSelect/index.tsx +117 -16
- package/src/components/Functional/DataImport/index.tsx +0 -1
- package/src/components/Functional/DataValidation/index.tsx +8 -1
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 业务组件
|
|
7
|
+
order: 1
|
|
8
|
+
title: 业务档录入器
|
|
9
|
+
order: 1
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# BusinessSearchSelect
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 商品选择录入器
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import React, { useState } from 'react';
|
|
19
|
+
import { Tabs } from 'antd';
|
|
20
|
+
import { AddSkuSelect } from '../../../index.ts';
|
|
21
|
+
|
|
22
|
+
export default () => {
|
|
23
|
+
const config = {
|
|
24
|
+
buttonText: 'context',
|
|
25
|
+
beforeShowModal: () => {
|
|
26
|
+
return Promise.resolve(true);
|
|
27
|
+
// return Promise.reject('校验有误');
|
|
28
|
+
},
|
|
29
|
+
onSaveCallback: (rows) => {
|
|
30
|
+
console.log('save call', rows);
|
|
31
|
+
return Promise.resolve(true);
|
|
32
|
+
// return Promise.reject('FAILE')
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<AddSkuSelect {...config} />
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
```
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Description:
|
|
3
|
+
* @Author: rodchen
|
|
4
|
+
* @Date: 2022-05-07 15:17:28
|
|
5
|
+
* @LastEditTime: 2022-05-08 21:01:21
|
|
6
|
+
* @LastEditors: rodchen
|
|
7
|
+
*/
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
import { Tooltip, Select } from 'antd';
|
|
10
|
+
import { AddSelect } from '../../../index';
|
|
11
|
+
|
|
12
|
+
export const AddSkuSelect = (parProps: any) => {
|
|
13
|
+
const selectProps = {
|
|
14
|
+
mode: 'multiple',
|
|
15
|
+
}
|
|
16
|
+
const [value, setValue] = useState(selectProps?.mode ? [] : null);
|
|
17
|
+
const props = {
|
|
18
|
+
buttonText: parProps.buttonText || '新增',
|
|
19
|
+
value,
|
|
20
|
+
// labelInValue: true, // 非必填 默认为false
|
|
21
|
+
requestConfig: {
|
|
22
|
+
url: `/items/sku/pager/v2`,
|
|
23
|
+
filter: 'qp-name-like', // 过滤参数 支持'qp-name-like'和['qp-name-like', 'qp-code-like']两种结构
|
|
24
|
+
otherParams: {
|
|
25
|
+
'qp-combination-eq': false,
|
|
26
|
+
}, // 默认参数
|
|
27
|
+
mappingTextField: 'name',
|
|
28
|
+
mappingValueField: 'skuCode',
|
|
29
|
+
},
|
|
30
|
+
selectProps,
|
|
31
|
+
onChange: (value: any) => {
|
|
32
|
+
console.log(value)
|
|
33
|
+
setValue(value)
|
|
34
|
+
},
|
|
35
|
+
beforeShowModal: parProps?.beforeShowModal,
|
|
36
|
+
onSaveCallback: parProps.onSaveCallback
|
|
37
|
+
// onSaveCallback: (rows) => {
|
|
38
|
+
// console.log('save call', rows);
|
|
39
|
+
// // return Promise.resolve(true);
|
|
40
|
+
// // return Promise.reject('FAILE')
|
|
41
|
+
// }
|
|
42
|
+
};
|
|
43
|
+
const modalTableProps = {
|
|
44
|
+
modalTableTitle: '选择商品',
|
|
45
|
+
tableSearchForm: [
|
|
46
|
+
{
|
|
47
|
+
name: 'qp-skuCode-like', label: 'SKU编码'
|
|
48
|
+
},
|
|
49
|
+
{ name: 'qp-skuName-like', label: 'SKU名称' },
|
|
50
|
+
{ name: 'qp-brandId-in', type: 'select', label: '品牌', field: {
|
|
51
|
+
type: 'select',
|
|
52
|
+
props: {
|
|
53
|
+
mode: 'multiple',
|
|
54
|
+
notFoundContent: '暂无数据',
|
|
55
|
+
allowClear: true,
|
|
56
|
+
showSearch: true,
|
|
57
|
+
showArrow: true,
|
|
58
|
+
maxTagCount: 1,
|
|
59
|
+
optionFilterProp: 'children',
|
|
60
|
+
filterOption: (input: string, option: { props: { children: string } }) =>
|
|
61
|
+
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
62
|
+
},
|
|
63
|
+
} },
|
|
64
|
+
{ name: 'qp-categoryId-in', type: 'treeSelect', label: '类目', field: {
|
|
65
|
+
type: 'treeSelect',
|
|
66
|
+
props: {
|
|
67
|
+
treeData: [],
|
|
68
|
+
treeCheckable: true,
|
|
69
|
+
showSearch: true,
|
|
70
|
+
allowClear: true,
|
|
71
|
+
showArrow: true,
|
|
72
|
+
treeNodeFilterProp: 'title',
|
|
73
|
+
treeDefaultExpandAll: true,
|
|
74
|
+
maxTagCount: 1,
|
|
75
|
+
placeholder: '请选择',
|
|
76
|
+
style: {
|
|
77
|
+
width: '100%',
|
|
78
|
+
},
|
|
79
|
+
dropdownStyle: { maxHeight: 400, maxWidth: 100, overflow: 'auto' }
|
|
80
|
+
},
|
|
81
|
+
} }
|
|
82
|
+
],
|
|
83
|
+
tableColumns: [
|
|
84
|
+
{
|
|
85
|
+
title: 'SKU编码',
|
|
86
|
+
width: 150,
|
|
87
|
+
dataIndex: 'skuCode',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
title: 'SKU名称',
|
|
91
|
+
width: 200,
|
|
92
|
+
ellipsis: {
|
|
93
|
+
showTitle: false,
|
|
94
|
+
},
|
|
95
|
+
render: (text: any) => (
|
|
96
|
+
<Tooltip placement="topLeft" title={text}>
|
|
97
|
+
{text}
|
|
98
|
+
</Tooltip>
|
|
99
|
+
),
|
|
100
|
+
dataIndex: 'name',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
title: '国际条码',
|
|
104
|
+
width: 100,
|
|
105
|
+
ellipsis: {
|
|
106
|
+
showTitle: false,
|
|
107
|
+
},
|
|
108
|
+
dataIndex: 'barCode',
|
|
109
|
+
render: (text: any) => (
|
|
110
|
+
<Tooltip placement="topLeft" title={text}>
|
|
111
|
+
{text}
|
|
112
|
+
</Tooltip>
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
title: '所属SPU名称',
|
|
117
|
+
width: 100,
|
|
118
|
+
ellipsis: {
|
|
119
|
+
showTitle: false,
|
|
120
|
+
},
|
|
121
|
+
dataIndex: 'itemName',
|
|
122
|
+
render: (text: any) => (
|
|
123
|
+
<Tooltip placement="topLeft" title={text}>
|
|
124
|
+
{text}
|
|
125
|
+
</Tooltip>
|
|
126
|
+
),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
title: '所属SPU编码',
|
|
130
|
+
width: 100,
|
|
131
|
+
ellipsis: {
|
|
132
|
+
showTitle: false,
|
|
133
|
+
},
|
|
134
|
+
dataIndex: 'itemCode',
|
|
135
|
+
render: (text: any) => (
|
|
136
|
+
<Tooltip placement="topLeft" title={text}>
|
|
137
|
+
{text}
|
|
138
|
+
</Tooltip>
|
|
139
|
+
),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
title: '外部编码',
|
|
143
|
+
width: 100,
|
|
144
|
+
ellipsis: {
|
|
145
|
+
showTitle: false,
|
|
146
|
+
},
|
|
147
|
+
render: (text: any) => (
|
|
148
|
+
<Tooltip placement="topLeft" title={text}>
|
|
149
|
+
{text}
|
|
150
|
+
</Tooltip>
|
|
151
|
+
),
|
|
152
|
+
dataIndex: 'externalCode',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
title: '规格',
|
|
156
|
+
width: 100,
|
|
157
|
+
ellipsis: {
|
|
158
|
+
showTitle: false,
|
|
159
|
+
},
|
|
160
|
+
render: (text: any) => (
|
|
161
|
+
<Tooltip placement="topLeft" title={text}>
|
|
162
|
+
{text}
|
|
163
|
+
</Tooltip>
|
|
164
|
+
),
|
|
165
|
+
dataIndex: 'propertyNameAndValue',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
title: '类目',
|
|
169
|
+
width: 100,
|
|
170
|
+
ellipsis: {
|
|
171
|
+
showTitle: false,
|
|
172
|
+
},
|
|
173
|
+
render: (text: any) => (
|
|
174
|
+
<Tooltip placement="topLeft" title={text}>
|
|
175
|
+
{text}
|
|
176
|
+
</Tooltip>
|
|
177
|
+
),
|
|
178
|
+
dataIndex: 'categoryName',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
title: '品类',
|
|
182
|
+
width: 100,
|
|
183
|
+
ellipsis: {
|
|
184
|
+
showTitle: false,
|
|
185
|
+
},
|
|
186
|
+
render: (text: any) => (
|
|
187
|
+
<Tooltip placement="topLeft" title={text}>
|
|
188
|
+
{text}
|
|
189
|
+
</Tooltip>
|
|
190
|
+
),
|
|
191
|
+
dataIndex: 'className',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: '品牌',
|
|
195
|
+
width: 100,
|
|
196
|
+
ellipsis: {
|
|
197
|
+
showTitle: false,
|
|
198
|
+
},
|
|
199
|
+
render: (text: any) => (
|
|
200
|
+
<Tooltip placement="topLeft" title={text}>
|
|
201
|
+
{text}
|
|
202
|
+
</Tooltip>
|
|
203
|
+
),
|
|
204
|
+
dataIndex: 'brandName',
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
selectColumn: [
|
|
208
|
+
{
|
|
209
|
+
title: 'SKU编码',
|
|
210
|
+
width: 150,
|
|
211
|
+
dataIndex: 'skuCode',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
title: 'SKU名称',
|
|
215
|
+
width: 200,
|
|
216
|
+
ellipsis: {
|
|
217
|
+
showTitle: false,
|
|
218
|
+
},
|
|
219
|
+
render: (text: any) => (
|
|
220
|
+
<Tooltip placement="topLeft" title={text}>
|
|
221
|
+
{text}
|
|
222
|
+
</Tooltip>
|
|
223
|
+
),
|
|
224
|
+
dataIndex: 'name',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
title: '数量',
|
|
228
|
+
width: 100,
|
|
229
|
+
isInputItem: true,
|
|
230
|
+
dataIndex: 'count',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
title: '单位',
|
|
234
|
+
dataIndex: 'selectUnitCode',
|
|
235
|
+
width: 80,
|
|
236
|
+
ellipsis: {
|
|
237
|
+
showTitle: false,
|
|
238
|
+
},
|
|
239
|
+
render: (text: any, record: any) => {
|
|
240
|
+
let baseUnitCode = '';
|
|
241
|
+
if (record?.packingUnitList) {
|
|
242
|
+
let base = record.packingUnitList.filter((item: any) => item.unitCode)
|
|
243
|
+
if (base.length) {
|
|
244
|
+
baseUnitCode = base[0].unitCode
|
|
245
|
+
record.selectUnitCode = base[0].unitCode
|
|
246
|
+
record.selectedScale = base[0]?.baseUnitScale || 1
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (baseUnitCode) {
|
|
251
|
+
return <>
|
|
252
|
+
<Select defaultValue={baseUnitCode} onChange={(value) => {record.selectUnitCode = value;record.selectedScale = record?.packingUnitList?.find((item: any) => item.unitCode === value)?.baseUnitScale || 1}} style={{width: '60px'}}>
|
|
253
|
+
{record.packingUnitList && record.packingUnitList.map((item: any) => {
|
|
254
|
+
return <Select.Option value={item.unitCode}>{item.name}</Select.Option>
|
|
255
|
+
})}
|
|
256
|
+
</Select>
|
|
257
|
+
</>
|
|
258
|
+
}
|
|
259
|
+
return <></>
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
title: '所属SPU编码',
|
|
264
|
+
width: 150,
|
|
265
|
+
ellipsis: {
|
|
266
|
+
showTitle: false,
|
|
267
|
+
},
|
|
268
|
+
dataIndex: 'itemCode',
|
|
269
|
+
render: (text: any) => (
|
|
270
|
+
<Tooltip placement="topLeft" title={text}>
|
|
271
|
+
{text}
|
|
272
|
+
</Tooltip>
|
|
273
|
+
),
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
title: '规格',
|
|
277
|
+
width: 200,
|
|
278
|
+
ellipsis: {
|
|
279
|
+
showTitle: false,
|
|
280
|
+
},
|
|
281
|
+
render: (text: any) => (
|
|
282
|
+
<Tooltip placement="topLeft" title={text}>
|
|
283
|
+
{text}
|
|
284
|
+
</Tooltip>
|
|
285
|
+
),
|
|
286
|
+
dataIndex: 'propertyNameAndValue',
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return (
|
|
292
|
+
<div>
|
|
293
|
+
<AddSelect
|
|
294
|
+
{...props}
|
|
295
|
+
modalTableProps={modalTableProps}
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
};
|
|
@@ -9,10 +9,12 @@ const CommodityEntry = (props: any) => {
|
|
|
9
9
|
const {
|
|
10
10
|
buttonName=' + 录入商品',
|
|
11
11
|
modalTitle = '录入商品',
|
|
12
|
+
buttonProps = {},
|
|
12
13
|
callbackHideModal,
|
|
13
14
|
callbackHandleOk,
|
|
14
15
|
columns=["skuCode", "quantity", "price"],
|
|
15
|
-
validDataUrl="/items/
|
|
16
|
+
validDataUrl="/items/sku/import/check",
|
|
17
|
+
isBrandAuth = true // 默认做品牌过滤
|
|
16
18
|
} = props;
|
|
17
19
|
|
|
18
20
|
const [modalProps, setModalProps]: any = useState({
|
|
@@ -58,13 +60,14 @@ const CommodityEntry = (props: any) => {
|
|
|
58
60
|
|
|
59
61
|
return (
|
|
60
62
|
<div>
|
|
61
|
-
<Button onClick={handleShowModal}>{buttonName}</Button>
|
|
63
|
+
<Button onClick={handleShowModal} {...buttonProps}>{buttonName}</Button>
|
|
62
64
|
{modalProps.visible && (
|
|
63
65
|
<Modal {...modalProps} onOk={handleOk} onCancel={handleCancel} destroyOnClose={true} zIndex={15}>
|
|
64
66
|
<DataValidation
|
|
65
67
|
onRef={(ref) => { dataValidationRef = ref }}
|
|
66
68
|
columns={columns}
|
|
67
69
|
validDataUrl={validDataUrl}
|
|
70
|
+
isBrandAuth={isBrandAuth}
|
|
68
71
|
/>
|
|
69
72
|
</Modal>
|
|
70
73
|
) || ''}
|
|
@@ -242,6 +242,7 @@ export function commonFun (type?: string, prefixUrl: any, requestConfigProp?: an
|
|
|
242
242
|
mappingValueField: 'skuCode',
|
|
243
243
|
mappingTextShowTextField: ['name', 'propertyNameAndValue'],
|
|
244
244
|
otherParams: {
|
|
245
|
+
'qp-combination-eq': false,
|
|
245
246
|
'qp-approveStatus-eq': 1,
|
|
246
247
|
// 'qp-type-eq': 10, // 查唯一国际条码【有些项目不需要必须要有国际条码,故注释,需要的项目自己定义otherParams补充上这个条件】
|
|
247
248
|
sorter: 'desc-id'
|
|
@@ -73,6 +73,15 @@
|
|
|
73
73
|
.ant-checkbox-wrapper {
|
|
74
74
|
justify-content: center;
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
.ant-form-item-label {
|
|
78
|
+
padding: 0PX;
|
|
79
|
+
line-height: 23px !important;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ant-form-item-label > label {
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
}
|
|
76
85
|
|
|
77
86
|
.ant-table-thead {
|
|
78
87
|
th {
|
|
@@ -171,7 +180,7 @@
|
|
|
171
180
|
margin-bottom: 10px;
|
|
172
181
|
}
|
|
173
182
|
&_formItems {
|
|
174
|
-
padding: 10px;
|
|
183
|
+
padding: 7px 10px;
|
|
175
184
|
}
|
|
176
185
|
}
|
|
177
186
|
.select_list_searchButton {
|
|
@@ -28,7 +28,9 @@ export default () => {
|
|
|
28
28
|
requestConfig: {
|
|
29
29
|
url: `/items/sku/pager/v2`,
|
|
30
30
|
filter: 'qp-name-like', // 过滤参数 支持'qp-name-like'和['qp-name-like', 'qp-code-like']两种结构
|
|
31
|
-
otherParams: {
|
|
31
|
+
otherParams: {
|
|
32
|
+
'qp-combination-eq': false,
|
|
33
|
+
}, // 默认参数
|
|
32
34
|
mappingTextField: 'name',
|
|
33
35
|
mappingValueField: 'skuCode',
|
|
34
36
|
},
|
|
@@ -9,6 +9,54 @@ import _ from "loadsh"
|
|
|
9
9
|
import './index.less';
|
|
10
10
|
import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
|
|
11
11
|
|
|
12
|
+
const loadSelectSource = (url: string, params?: any) => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
axios
|
|
15
|
+
.get(`${url}?${stringify(params)}`)
|
|
16
|
+
.then((result: any) => {
|
|
17
|
+
result = result.data;
|
|
18
|
+
if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
|
|
19
|
+
message.error(result.msg);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
resolve(result);
|
|
23
|
+
})
|
|
24
|
+
.catch((err) => {
|
|
25
|
+
reject(err);
|
|
26
|
+
});
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const formatSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['code', 'name']) => {
|
|
31
|
+
const data = reData && reData[position]?.data;
|
|
32
|
+
const list = Array.isArray(data) ? data :(data?.items || data?.list || data?.children || []);
|
|
33
|
+
const formatData = list?.length ? list.map((v: any) => ({ text: v[resKeyValue[1]], value: v[resKeyValue[0]] })) : [];
|
|
34
|
+
changeSearchForm[changePosition] = {...changeSearchForm[changePosition], initialSource: formatData}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 格式化树选择器数据源
|
|
38
|
+
const mapSearchTree = (treeDataItem: any, resKeyValue: any) => {
|
|
39
|
+
const haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
|
|
40
|
+
return {
|
|
41
|
+
title: treeDataItem[resKeyValue[1]],
|
|
42
|
+
value: treeDataItem[resKeyValue[0]],
|
|
43
|
+
parentId: treeDataItem.parent,
|
|
44
|
+
data: { ...treeDataItem },
|
|
45
|
+
isLeaf: !haveChildren,
|
|
46
|
+
disabled: haveChildren,
|
|
47
|
+
children: haveChildren ? treeDataItem.children.map((i: any) => mapSearchTree(i, resKeyValue)) : [],
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const formatTreeDataSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['id', 'name']) => {
|
|
51
|
+
const data = reData && reData[position]?.data;
|
|
52
|
+
const formatData = (data &&
|
|
53
|
+
Array.isArray(data) &&
|
|
54
|
+
data.length &&
|
|
55
|
+
data.map((ites: any) => mapSearchTree(ites, resKeyValue))) ||
|
|
56
|
+
[]
|
|
57
|
+
changeSearchForm[changePosition].field.props.treeData = formatData;
|
|
58
|
+
}
|
|
59
|
+
|
|
12
60
|
const { Option } = Select;
|
|
13
61
|
|
|
14
62
|
const AddSelect = (props: any) => {
|
|
@@ -23,7 +71,9 @@ const AddSelect = (props: any) => {
|
|
|
23
71
|
sourceName,
|
|
24
72
|
needModalTable = true,
|
|
25
73
|
getPopupContainer = undefined,
|
|
26
|
-
onSaveCallback
|
|
74
|
+
onSaveCallback,
|
|
75
|
+
buttonText = '添加',
|
|
76
|
+
beforeShowModal
|
|
27
77
|
} = props;
|
|
28
78
|
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField = 'name', mappingTextShowKeyField, mappingValueField = 'code', mappingTextShowTextField } = requestConfig || {};
|
|
29
79
|
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
@@ -74,6 +124,7 @@ const AddSelect = (props: any) => {
|
|
|
74
124
|
);
|
|
75
125
|
|
|
76
126
|
const [form] = Form.useForm();
|
|
127
|
+
const [tableSearchForm, setTableSearchForm] = useState(modalTableProps?.tableSearchForm)
|
|
77
128
|
const [caretLeftFlag, setCaretLeftFlag] = useState(true);
|
|
78
129
|
const [tableData, setTableData] = useState([]);
|
|
79
130
|
const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize })
|
|
@@ -239,6 +290,7 @@ const AddSelect = (props: any) => {
|
|
|
239
290
|
textShowText,
|
|
240
291
|
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
241
292
|
value: item[mappingValueField],
|
|
293
|
+
baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
|
|
242
294
|
};
|
|
243
295
|
})
|
|
244
296
|
: Array.isArray(res) &&
|
|
@@ -260,6 +312,7 @@ const AddSelect = (props: any) => {
|
|
|
260
312
|
textShowText,
|
|
261
313
|
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
262
314
|
value: item[mappingValueField],
|
|
315
|
+
baseUnitCode: item?.packingUnitList?.find((item: any) => item.baseUnit === true)?.unitCode
|
|
263
316
|
};
|
|
264
317
|
})
|
|
265
318
|
: [];
|
|
@@ -303,7 +356,20 @@ const AddSelect = (props: any) => {
|
|
|
303
356
|
}
|
|
304
357
|
|
|
305
358
|
useEffect(() => {
|
|
306
|
-
|
|
359
|
+
Promise.all([
|
|
360
|
+
loadSelectSource(`/items/brand/queryBrandList`, {
|
|
361
|
+
pageSize: 5000,
|
|
362
|
+
currentPage: 1,
|
|
363
|
+
'ctl-withAuth': true
|
|
364
|
+
}),
|
|
365
|
+
loadSelectSource(`/items/category/queryCategoryTree`, {
|
|
366
|
+
pageSize: 5000,
|
|
367
|
+
currentPage: 1,
|
|
368
|
+
}),
|
|
369
|
+
]).then((x: any)=>{
|
|
370
|
+
formatSource(x,0, 2, tableSearchForm,['id','name'])
|
|
371
|
+
formatTreeDataSource(x,1, 3, tableSearchForm)
|
|
372
|
+
})
|
|
307
373
|
}, [])
|
|
308
374
|
|
|
309
375
|
useEffect(() => {
|
|
@@ -317,7 +383,7 @@ const AddSelect = (props: any) => {
|
|
|
317
383
|
}, [sourceName])
|
|
318
384
|
|
|
319
385
|
const showModal = () => {
|
|
320
|
-
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
386
|
+
// getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
|
|
321
387
|
setIsModalVisible(true);
|
|
322
388
|
// 回显
|
|
323
389
|
if (value) {
|
|
@@ -335,8 +401,24 @@ const AddSelect = (props: any) => {
|
|
|
335
401
|
setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
|
|
336
402
|
}
|
|
337
403
|
}
|
|
404
|
+
|
|
405
|
+
setTimeout(() => {
|
|
406
|
+
document.getElementById("first-query")?.focus()
|
|
407
|
+
}, 50)
|
|
338
408
|
};
|
|
339
409
|
|
|
410
|
+
const handleShowModal = () => {
|
|
411
|
+
if(beforeShowModal) {
|
|
412
|
+
beforeShowModal(popvalue).then(res => {
|
|
413
|
+
showModal()
|
|
414
|
+
}).catch(Error => {
|
|
415
|
+
message.warning(Error)
|
|
416
|
+
})
|
|
417
|
+
} else {
|
|
418
|
+
showModal()
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
340
422
|
const handleSelectOver = (selectedValue: any) => {
|
|
341
423
|
if (selectedValue?.length) {
|
|
342
424
|
formaData(selectedValue);
|
|
@@ -358,6 +440,7 @@ const AddSelect = (props: any) => {
|
|
|
358
440
|
if(true) {
|
|
359
441
|
message.success('保存成功')
|
|
360
442
|
deleteSelectRows();
|
|
443
|
+
document.getElementById('first-query')?.focus()
|
|
361
444
|
!isContinue && handleCancel();
|
|
362
445
|
} else {
|
|
363
446
|
message.error(res)
|
|
@@ -384,9 +467,10 @@ const AddSelect = (props: any) => {
|
|
|
384
467
|
form.resetFields();
|
|
385
468
|
setTableFormParams({});
|
|
386
469
|
setIsModalVisible(false);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
470
|
+
setTableData([])
|
|
471
|
+
// if (selectMode) {
|
|
472
|
+
// run();
|
|
473
|
+
// }
|
|
390
474
|
};
|
|
391
475
|
|
|
392
476
|
const onSearchChange = (e) => {
|
|
@@ -435,6 +519,13 @@ const AddSelect = (props: any) => {
|
|
|
435
519
|
};
|
|
436
520
|
|
|
437
521
|
const onChangeSelectedKeys = (selectKeys, selectRows) => {
|
|
522
|
+
if(selectKeys.length - selectedRowKeys.length > 0) {
|
|
523
|
+
if (selectKeys.length - selectedRowKeys.length === 1) {
|
|
524
|
+
selectRows[selectRows.length -1]['needFocus'] = true;
|
|
525
|
+
} else {
|
|
526
|
+
selectRows[selectedRowKeys.length]['needFocus'] = true;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
438
529
|
setPopValue(selectRows);
|
|
439
530
|
setSelectedRowKeys(selectKeys)
|
|
440
531
|
// setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
|
|
@@ -520,7 +611,11 @@ const AddSelect = (props: any) => {
|
|
|
520
611
|
// 默认type是input
|
|
521
612
|
return (
|
|
522
613
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
523
|
-
<Input id={index === 0 ? "
|
|
614
|
+
<Input id={index === 0 ? "first-query" : 'index'} style={{ width: '100%' }} onKeyDown={(e) => {
|
|
615
|
+
if (e.keyCode === 13) {
|
|
616
|
+
onSearchTable()
|
|
617
|
+
}
|
|
618
|
+
}} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} />
|
|
524
619
|
</Form.Item>
|
|
525
620
|
)
|
|
526
621
|
})
|
|
@@ -563,19 +658,25 @@ const AddSelect = (props: any) => {
|
|
|
563
658
|
let inputIndex = 0;
|
|
564
659
|
let selectColumns = [... modalTableProps.selectColumn.map(item => {
|
|
565
660
|
const inputLength = modalTableProps.selectColumn.filter(item => item.isInputItem).length
|
|
566
|
-
const currentIndex = inputIndex
|
|
661
|
+
const currentIndex = inputIndex
|
|
662
|
+
|
|
567
663
|
if (item.isInputItem) {
|
|
568
664
|
inputIndex++;
|
|
569
665
|
return {
|
|
570
666
|
...item,
|
|
571
667
|
render: (text, record, index) => {
|
|
668
|
+
// let
|
|
669
|
+
if(record.needFocus === true && currentIndex === 0) {
|
|
670
|
+
|
|
671
|
+
}
|
|
572
672
|
return (
|
|
573
673
|
<InputNumber
|
|
574
674
|
defaultValue={text || 0}
|
|
575
675
|
min={0}
|
|
676
|
+
autoFocus={record.needFocus}
|
|
576
677
|
keyboard={false}
|
|
577
678
|
onChange={(value) => {
|
|
578
|
-
record[
|
|
679
|
+
record[item.dataIndex] = value
|
|
579
680
|
}}
|
|
580
681
|
// onFocus={(e)=> {
|
|
581
682
|
// let dom1 = e.currentTarget;
|
|
@@ -585,7 +686,7 @@ const AddSelect = (props: any) => {
|
|
|
585
686
|
onKeyDown={(e) => {
|
|
586
687
|
if(e.keyCode === 13 && e.ctrlKey) {
|
|
587
688
|
handleOk(true)
|
|
588
|
-
document.getElementById("
|
|
689
|
+
document.getElementById("first-query")?.focus()
|
|
589
690
|
}
|
|
590
691
|
if(e.keyCode === 8 && e.ctrlKey) {
|
|
591
692
|
message.success('删除当前行')
|
|
@@ -659,13 +760,13 @@ const AddSelect = (props: any) => {
|
|
|
659
760
|
return item
|
|
660
761
|
}), {
|
|
661
762
|
title: '操作',
|
|
662
|
-
width:
|
|
763
|
+
width: 50,
|
|
663
764
|
fixed: 'right',
|
|
664
765
|
render: (text, record, index) => {
|
|
665
766
|
return (
|
|
666
|
-
<
|
|
767
|
+
<span style={{cursor: 'pointer', color: '#005CFF' }} onClick={() => {
|
|
667
768
|
deleteRecord(record)
|
|
668
|
-
}} type={"
|
|
769
|
+
}} type={"text"}>删除</span>
|
|
669
770
|
)
|
|
670
771
|
}
|
|
671
772
|
},]
|
|
@@ -673,8 +774,8 @@ const AddSelect = (props: any) => {
|
|
|
673
774
|
return (
|
|
674
775
|
<div className={'add_select'}>
|
|
675
776
|
<div className="add_select_show" id={`add_select_div_${uniqueValue}`}>
|
|
676
|
-
<Button onClick={
|
|
677
|
-
|
|
777
|
+
<Button onClick={handleShowModal} type="primary">
|
|
778
|
+
{buttonText}
|
|
678
779
|
</Button>
|
|
679
780
|
</div>
|
|
680
781
|
{needModalTable && isModalVisible && (
|
|
@@ -720,7 +821,7 @@ const AddSelect = (props: any) => {
|
|
|
720
821
|
<div className={'select_list_columns'}>
|
|
721
822
|
<div className={'select_list_columns_formItems'}>
|
|
722
823
|
<Form form={form} layout='vertical' key='modalForm'>
|
|
723
|
-
{formItem(
|
|
824
|
+
{formItem(tableSearchForm)}
|
|
724
825
|
</Form>
|
|
725
826
|
</div>
|
|
726
827
|
</div>
|