@bit-sun/business-component 2.0.4 → 2.0.7
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/BillEntry/index.d.ts +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +776 -375
- package/dist/index.js +774 -372
- package/dist/utils/CheckOneUser/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Business/AddSelectBusiness/index.tsx +3 -1
- package/src/components/Business/SearchSelect/BusinessUtils.ts +1 -0
- package/src/components/Functional/AddSelect/index.less +69 -1
- package/src/components/Functional/AddSelect/index.md +3 -1
- package/src/components/Functional/BillEntry/index.less +371 -0
- package/src/components/Functional/BillEntry/index.md +37 -0
- package/src/components/Functional/BillEntry/index.tsx +556 -0
- package/src/components/Functional/DataValidation/index.tsx +1 -0
- package/src/index.ts +2 -1
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Button, message, Input, InputNumber, Tooltip, Table, Popover, Select } from 'antd';
|
|
3
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import { SearchOutlined, CopyOutlined, CloseCircleOutlined } from '@ant-design/icons';
|
|
5
|
+
import { stringify } from 'querystring';
|
|
6
|
+
import './index.less';
|
|
7
|
+
import axios from 'axios';
|
|
8
|
+
|
|
9
|
+
const InputElement = ({
|
|
10
|
+
record, text, currentIndex, inputLength, index, setData, data, item, callSelectItem
|
|
11
|
+
}: {
|
|
12
|
+
record: any, text: string, currentIndex: any, inputLength: any, index: any, setData: any, data: any, item: any, callSelectItem: any
|
|
13
|
+
}) => {
|
|
14
|
+
const [hoverVisibled, updateHoverVisibled] = useState(false);
|
|
15
|
+
const [searchData, updateSearchData] = useState([]);
|
|
16
|
+
const tableRef = useRef(null);
|
|
17
|
+
const [value, setValue] = useState(text)
|
|
18
|
+
const inputRef = useRef(false);
|
|
19
|
+
|
|
20
|
+
const onSerchdata = (name: any) => {
|
|
21
|
+
axios
|
|
22
|
+
.get(`/items/sku/pager/v2?${stringify({ 'skuCodeAndSkuName': name, 'pageSize': 100 })}`)
|
|
23
|
+
.then(({ data, status }: any) => {
|
|
24
|
+
if (status === 200) {
|
|
25
|
+
if (data.status === '0') {
|
|
26
|
+
updateSearchData(data.data.items.map((item: any, index: any) => ({
|
|
27
|
+
...item,
|
|
28
|
+
index
|
|
29
|
+
})))
|
|
30
|
+
} else {
|
|
31
|
+
updateSearchData([])
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const onCallback = (itemData: any) => {
|
|
38
|
+
updateHoverVisibled(false)
|
|
39
|
+
if (itemData) {
|
|
40
|
+
callSelectItem({ ...itemData, needFocus: true })
|
|
41
|
+
setValue(itemData[item.dataIndex])
|
|
42
|
+
} else {
|
|
43
|
+
callSelectItem(null)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const SearchDataTable = (hoverVisibled: any) => {
|
|
48
|
+
const [selectIndex, setSelectIndex] = useState(0);
|
|
49
|
+
const inputRef = useRef(null);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (searchData.length && hoverVisibled) {
|
|
53
|
+
let dom = tableRef?.current?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[0]
|
|
54
|
+
if (dom) {
|
|
55
|
+
dom.style.background = '#005CFF30'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, [hoverVisibled, tableRef?.current])
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const inter = setInterval(() => {
|
|
62
|
+
if (inputRef.current) {
|
|
63
|
+
inputRef.current.focus()
|
|
64
|
+
}
|
|
65
|
+
}, 500)
|
|
66
|
+
|
|
67
|
+
return () => {
|
|
68
|
+
clearInterval(inter);
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
if (!hoverVisibled) return <></>
|
|
73
|
+
|
|
74
|
+
return <div className={'add_select_wrapper_select'} style={{ width: '800px', height: '400px', overflow: 'auto', position: 'relative' }}>
|
|
75
|
+
<Input placeholder='请输入skucode或者sku名称' ref={inputRef} style={{ position: 'absolute', zIndex: '-100', height: '22px' }} onKeyDown={(e) => {
|
|
76
|
+
let currentIndex = selectIndex
|
|
77
|
+
if (e.keyCode === 27) {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
setSelectIndex(0);
|
|
81
|
+
onCallback(null)
|
|
82
|
+
}
|
|
83
|
+
if (e.keyCode === 13) { // enter
|
|
84
|
+
onCallback(searchData[currentIndex])
|
|
85
|
+
setSelectIndex(0);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (e.keyCode === 40) { // 向下
|
|
89
|
+
let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex + 1]
|
|
90
|
+
if (dom) {
|
|
91
|
+
tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex].style.background = ''
|
|
92
|
+
setSelectIndex(currentIndex + 1)
|
|
93
|
+
dom.style.background = '#005CFF30'
|
|
94
|
+
dom.scrollIntoViewIfNeeded(false)
|
|
95
|
+
}
|
|
96
|
+
} else if (e.keyCode === 38) {
|
|
97
|
+
let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex - 1]
|
|
98
|
+
if (dom) {
|
|
99
|
+
tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex].style.background = ''
|
|
100
|
+
setSelectIndex(currentIndex - 1)
|
|
101
|
+
dom.style.background = '#005CFF30'
|
|
102
|
+
dom.scrollIntoViewIfNeeded(false)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}} />
|
|
106
|
+
<Table
|
|
107
|
+
ref={tableRef}
|
|
108
|
+
pagination={false}
|
|
109
|
+
// components={
|
|
110
|
+
// {
|
|
111
|
+
// body: {
|
|
112
|
+
// cell: ({index, record, ...props}) => {
|
|
113
|
+
// debugger
|
|
114
|
+
// return <td {...props} style={selectIndex === record?.index ? {background: '#005CFF30'} : {} } />
|
|
115
|
+
// }
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// }
|
|
119
|
+
onRow={(record, index) => {
|
|
120
|
+
return {
|
|
121
|
+
onClick: ((record, index, event) => {
|
|
122
|
+
let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[index]
|
|
123
|
+
if (dom) {
|
|
124
|
+
[...(tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr'))].map(item => {
|
|
125
|
+
item.style.background = ''
|
|
126
|
+
})
|
|
127
|
+
dom.style.background = '#005CFF30'
|
|
128
|
+
dom.scrollIntoViewIfNeeded(false)
|
|
129
|
+
}
|
|
130
|
+
setSelectIndex(index)
|
|
131
|
+
}).bind(this, record, index), // 点击行
|
|
132
|
+
}
|
|
133
|
+
}}
|
|
134
|
+
rowClassName={'row-class'}
|
|
135
|
+
columns={[{
|
|
136
|
+
title: 'SKU编码',
|
|
137
|
+
width: 150,
|
|
138
|
+
dataIndex: 'skuCode',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
title: 'SKU名称',
|
|
142
|
+
width: 200,
|
|
143
|
+
ellipsis: {
|
|
144
|
+
showTitle: false,
|
|
145
|
+
},
|
|
146
|
+
render: (text: any) => (
|
|
147
|
+
<Tooltip placement="topLeft" title={text}>
|
|
148
|
+
{text}
|
|
149
|
+
</Tooltip>
|
|
150
|
+
),
|
|
151
|
+
dataIndex: 'name',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: '国际条码',
|
|
155
|
+
width: 100,
|
|
156
|
+
ellipsis: {
|
|
157
|
+
showTitle: false,
|
|
158
|
+
},
|
|
159
|
+
dataIndex: 'barCode',
|
|
160
|
+
render: (text: any) => (
|
|
161
|
+
<Tooltip placement="topLeft" title={text}>
|
|
162
|
+
{text}
|
|
163
|
+
</Tooltip>
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
title: '所属SPU名称',
|
|
168
|
+
width: 100,
|
|
169
|
+
ellipsis: {
|
|
170
|
+
showTitle: false,
|
|
171
|
+
},
|
|
172
|
+
dataIndex: 'itemName',
|
|
173
|
+
render: (text: any) => (
|
|
174
|
+
<Tooltip placement="topLeft" title={text}>
|
|
175
|
+
{text}
|
|
176
|
+
</Tooltip>
|
|
177
|
+
),
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
title: '所属SPU编码',
|
|
181
|
+
width: 100,
|
|
182
|
+
ellipsis: {
|
|
183
|
+
showTitle: false,
|
|
184
|
+
},
|
|
185
|
+
dataIndex: 'itemCode',
|
|
186
|
+
render: (text: any) => (
|
|
187
|
+
<Tooltip placement="topLeft" title={text}>
|
|
188
|
+
{text}
|
|
189
|
+
</Tooltip>
|
|
190
|
+
),
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
title: '外部编码',
|
|
194
|
+
width: 100,
|
|
195
|
+
ellipsis: {
|
|
196
|
+
showTitle: false,
|
|
197
|
+
},
|
|
198
|
+
render: (text: any) => (
|
|
199
|
+
<Tooltip placement="topLeft" title={text}>
|
|
200
|
+
{text}
|
|
201
|
+
</Tooltip>
|
|
202
|
+
),
|
|
203
|
+
dataIndex: 'externalCode',
|
|
204
|
+
}]} dataSource={searchData} />
|
|
205
|
+
</div>
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<Popover placement="bottomLeft" destroyTooltipOnHide={{ keepParent: false }} title="" trigger="" content={SearchDataTable(hoverVisibled)} visible={hoverVisibled} onVisibleChange={(disabled) => { updateHoverVisibled(disabled) }}>
|
|
211
|
+
{item.isPrimaryInput ?
|
|
212
|
+
<Input
|
|
213
|
+
value={value}
|
|
214
|
+
ref={inputRef}
|
|
215
|
+
placeholder='skucode / sku名称'
|
|
216
|
+
keyboard={false}
|
|
217
|
+
autoFocus={record.autoFocus}
|
|
218
|
+
onChange={(value) => {
|
|
219
|
+
record[item.dataIndex] = value.currentTarget.value
|
|
220
|
+
setValue(value.currentTarget.value)
|
|
221
|
+
// setData(data);
|
|
222
|
+
}}
|
|
223
|
+
// onFocus={(e)=> {
|
|
224
|
+
// let dom1 = e.currentTarget;
|
|
225
|
+
// dom1.setSelectionRange(100, 0);
|
|
226
|
+
// dom1.select(text);
|
|
227
|
+
// }}
|
|
228
|
+
onKeyDown={(e) => {
|
|
229
|
+
// if (e.keyCode === 13 && e.ctrlKey) {
|
|
230
|
+
// handleOk(true)
|
|
231
|
+
// document.getElementById("first-query")?.focus()
|
|
232
|
+
// }
|
|
233
|
+
if (e.keyCode === 8 && e.ctrlKey && index) {
|
|
234
|
+
message.success('删除当前行')
|
|
235
|
+
e.stopPropagation();
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
let dom = e.nativeEvent.path[3].children[index - 1]?.getElementsByTagName('input')[currentIndex]
|
|
238
|
+
if (dom) {
|
|
239
|
+
dom.select();
|
|
240
|
+
dom.focus();
|
|
241
|
+
dom.scrollIntoView(false)
|
|
242
|
+
}
|
|
243
|
+
dom = null
|
|
244
|
+
setData(data.filter((item, innerIndex) => innerIndex !== index))
|
|
245
|
+
}
|
|
246
|
+
if (e.keyCode === 13) { // enter
|
|
247
|
+
if (item.isPrimaryInput) {
|
|
248
|
+
if (e.currentTarget.value.length < 2) {
|
|
249
|
+
message.warning('至少输入两个字符');
|
|
250
|
+
} else {
|
|
251
|
+
updateHoverVisibled(true)
|
|
252
|
+
onSerchdata(e.currentTarget.value)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (e.keyCode === 37 && e.shiftKey) { // 左滑动
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
let dom = e.nativeEvent.path[3].children[index]?.getElementsByTagName('input')[currentIndex - 1]
|
|
260
|
+
if (dom) {
|
|
261
|
+
dom.select();
|
|
262
|
+
dom.focus();
|
|
263
|
+
dom.scrollIntoView(false)
|
|
264
|
+
}
|
|
265
|
+
dom = null
|
|
266
|
+
}
|
|
267
|
+
if (e.keyCode === 39 && e.shiftKey) { // 右滑
|
|
268
|
+
e.stopPropagation();
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
let dom = e.nativeEvent.path[3].children[index]?.getElementsByTagName('input')[currentIndex + 1]
|
|
271
|
+
if (dom) {
|
|
272
|
+
dom.select();
|
|
273
|
+
dom.focus();
|
|
274
|
+
dom.scrollIntoView(false)
|
|
275
|
+
}
|
|
276
|
+
dom = null
|
|
277
|
+
}
|
|
278
|
+
if (e.keyCode === 40) { // 向下
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
e.preventDefault();
|
|
281
|
+
let dom = e.nativeEvent.path[3].children[index + 1]?.getElementsByTagName('input')[currentIndex]
|
|
282
|
+
if (dom) {
|
|
283
|
+
dom.select();
|
|
284
|
+
dom.focus();
|
|
285
|
+
dom.scrollIntoView(false)
|
|
286
|
+
}
|
|
287
|
+
dom = null
|
|
288
|
+
} else if (e.keyCode === 38) {
|
|
289
|
+
e.stopPropagation();
|
|
290
|
+
e.preventDefault();
|
|
291
|
+
let dom1 = e.nativeEvent.path[3].children[index - 1]?.getElementsByTagName('input')[currentIndex]
|
|
292
|
+
if (dom1) {
|
|
293
|
+
// dom1.value=""
|
|
294
|
+
// dom1.setSelectionRange(100, 0);
|
|
295
|
+
dom1.select();
|
|
296
|
+
dom1.focus();
|
|
297
|
+
dom1.scrollIntoViewIfNeeded(false)
|
|
298
|
+
// dom1.value=record['count']
|
|
299
|
+
}
|
|
300
|
+
dom1 = null
|
|
301
|
+
} else if (e.keyCode === 9 && currentIndex === inputLength - 1 && index === data.length - 1) {
|
|
302
|
+
setData([...data, {}])
|
|
303
|
+
}
|
|
304
|
+
}}
|
|
305
|
+
/>
|
|
306
|
+
:
|
|
307
|
+
<InputNumber
|
|
308
|
+
// onBlur={() => {updateHoverVisibled(false)}}
|
|
309
|
+
defaultValue={text || 0}
|
|
310
|
+
min={0}
|
|
311
|
+
keyboard={false}
|
|
312
|
+
onChange={(value) => {
|
|
313
|
+
record[item.dataIndex] = value
|
|
314
|
+
}}
|
|
315
|
+
onKeyDown={(e) => {
|
|
316
|
+
// if (e.keyCode === 13 && e.ctrlKey) {
|
|
317
|
+
// handleOk(true)
|
|
318
|
+
// document.getElementById("first-query")?.focus()
|
|
319
|
+
// }
|
|
320
|
+
if (e.keyCode === 8 && e.ctrlKey && index) {
|
|
321
|
+
message.success('删除当前行')
|
|
322
|
+
e.stopPropagation();
|
|
323
|
+
e.preventDefault();
|
|
324
|
+
let dom = e.nativeEvent.path[5].children[index - 1]?.getElementsByTagName('input')[currentIndex]
|
|
325
|
+
if (dom) {
|
|
326
|
+
dom.select();
|
|
327
|
+
dom.focus();
|
|
328
|
+
dom.scrollIntoView(false)
|
|
329
|
+
}
|
|
330
|
+
dom = null
|
|
331
|
+
setData(data.filter((item, innerIndex) => innerIndex !== index))
|
|
332
|
+
}
|
|
333
|
+
if (e.keyCode === 37 && e.shiftKey) { // 左滑动
|
|
334
|
+
e.stopPropagation();
|
|
335
|
+
e.preventDefault();
|
|
336
|
+
let dom = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex - 1]
|
|
337
|
+
if (dom) {
|
|
338
|
+
dom.select();
|
|
339
|
+
dom.focus();
|
|
340
|
+
dom.scrollIntoView(false)
|
|
341
|
+
}
|
|
342
|
+
dom = null
|
|
343
|
+
}
|
|
344
|
+
if (e.keyCode === 39 && e.shiftKey) { // 右滑
|
|
345
|
+
e.stopPropagation();
|
|
346
|
+
e.preventDefault();
|
|
347
|
+
let dom = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex + 1]
|
|
348
|
+
if (dom) {
|
|
349
|
+
dom.select();
|
|
350
|
+
dom.focus();
|
|
351
|
+
dom.scrollIntoView(false)
|
|
352
|
+
}
|
|
353
|
+
dom = null
|
|
354
|
+
}
|
|
355
|
+
if (e.keyCode === 40) { // 向下
|
|
356
|
+
e.stopPropagation();
|
|
357
|
+
e.preventDefault();
|
|
358
|
+
let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex]
|
|
359
|
+
if (dom) {
|
|
360
|
+
dom.select();
|
|
361
|
+
dom.focus();
|
|
362
|
+
dom.scrollIntoView(false)
|
|
363
|
+
}
|
|
364
|
+
dom = null
|
|
365
|
+
} else if (e.keyCode === 38) {
|
|
366
|
+
e.stopPropagation();
|
|
367
|
+
e.preventDefault();
|
|
368
|
+
let dom1 = e.nativeEvent.path[5].children[index - 1]?.getElementsByTagName('input')[currentIndex]
|
|
369
|
+
if (dom1) {
|
|
370
|
+
// dom1.value=""
|
|
371
|
+
// dom1.setSelectionRange(100, 0);
|
|
372
|
+
dom1.select();
|
|
373
|
+
dom1.focus();
|
|
374
|
+
dom1.scrollIntoViewIfNeeded(false)
|
|
375
|
+
// dom1.value=record['count']
|
|
376
|
+
}
|
|
377
|
+
dom1 = null
|
|
378
|
+
} else if (e.keyCode === 9 && currentIndex === inputLength - 1 && index === data.length - 1) {
|
|
379
|
+
e.stopPropagation();
|
|
380
|
+
e.preventDefault();
|
|
381
|
+
} else if (e.keyCode === 13 && currentIndex === inputLength - 1 && index === data.length - 1 && record['skuCode']) {
|
|
382
|
+
setData([...data, { autoFocus: true }])
|
|
383
|
+
}
|
|
384
|
+
}}
|
|
385
|
+
/>
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
</Popover>
|
|
389
|
+
)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const BillEntry: React.FC = ({ onSaveCallback }) => {
|
|
393
|
+
const columns = [
|
|
394
|
+
{
|
|
395
|
+
title: 'SKU编码',
|
|
396
|
+
width: 150,
|
|
397
|
+
dataIndex: 'skuCode',
|
|
398
|
+
isInputItem: true,
|
|
399
|
+
isPrimaryInput: true
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
title: 'SKU名称',
|
|
403
|
+
width: 200,
|
|
404
|
+
ellipsis: {
|
|
405
|
+
showTitle: false,
|
|
406
|
+
},
|
|
407
|
+
render: (text: any) => (
|
|
408
|
+
<Tooltip placement="topLeft" title={text}>
|
|
409
|
+
{text}
|
|
410
|
+
</Tooltip>
|
|
411
|
+
),
|
|
412
|
+
dataIndex: 'name',
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
title: '单位',
|
|
416
|
+
dataIndex: 'selectUnitCode',
|
|
417
|
+
width: 100,
|
|
418
|
+
isSelectItem: true,
|
|
419
|
+
render: (text: any, record: any) => {
|
|
420
|
+
let baseUnitCode = '';
|
|
421
|
+
if (record?.packingUnitList) {
|
|
422
|
+
let base = record.packingUnitList.filter((item: any) => item.unitCode)
|
|
423
|
+
if (base.length) {
|
|
424
|
+
baseUnitCode = base[0].unitCode
|
|
425
|
+
record.selectUnitCode = base[0].unitCode
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
record.packingUnitList = record.packingUnitList || []
|
|
430
|
+
|
|
431
|
+
return <>
|
|
432
|
+
<Select value={record.selectUnitCode} onChange={(value) => { record.selectUnitCode = value }} style={{ width: '60px', height: '22px', lineHight: '22px' }}>
|
|
433
|
+
{record.packingUnitList && record.packingUnitList.map((item: any) => {
|
|
434
|
+
return <Select.Option value={item.unitCode}>{item.name}</Select.Option>
|
|
435
|
+
})}
|
|
436
|
+
</Select>
|
|
437
|
+
</>
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
title: '数量',
|
|
442
|
+
width: 100,
|
|
443
|
+
isInputItem: true,
|
|
444
|
+
dataIndex: 'count',
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
title: '所属SPU编码',
|
|
448
|
+
width: 100,
|
|
449
|
+
ellipsis: {
|
|
450
|
+
showTitle: false,
|
|
451
|
+
},
|
|
452
|
+
dataIndex: 'itemCode',
|
|
453
|
+
render: (text: any) => (
|
|
454
|
+
<Tooltip placement="topLeft" title={text}>
|
|
455
|
+
{text}
|
|
456
|
+
</Tooltip>
|
|
457
|
+
),
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
title: '规格',
|
|
461
|
+
width: 200,
|
|
462
|
+
ellipsis: {
|
|
463
|
+
showTitle: false,
|
|
464
|
+
},
|
|
465
|
+
render: (text: any) => (
|
|
466
|
+
<Tooltip placement="topLeft" title={text}>
|
|
467
|
+
{text}
|
|
468
|
+
</Tooltip>
|
|
469
|
+
),
|
|
470
|
+
dataIndex: 'propertyNameAndValue',
|
|
471
|
+
}
|
|
472
|
+
]
|
|
473
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
474
|
+
const [data, setData] = useState([{ hovered: false }]);
|
|
475
|
+
const tableRef = useRef(null)
|
|
476
|
+
|
|
477
|
+
const callSelectItem = (index, item) => {
|
|
478
|
+
if (item) {
|
|
479
|
+
let newData = [].concat(data)
|
|
480
|
+
newData[index] = { ...data[index], ...item }
|
|
481
|
+
setData(newData)
|
|
482
|
+
}
|
|
483
|
+
let dom = tableRef?.current?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[index + 1]
|
|
484
|
+
if (dom) {
|
|
485
|
+
setTimeout(() => {
|
|
486
|
+
dom.getElementsByTagName('input')[item ? 1 : 0]?.select()
|
|
487
|
+
dom.getElementsByTagName('input')[item ? 1 : 0]?.focus()
|
|
488
|
+
}, 200)
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const deleteRecord = (record) => {
|
|
493
|
+
setData(data.filter(item => item.skuCode !== record.skuCode))
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
let inputIndex = 0;
|
|
497
|
+
let selectColumns = [...columns.map(item => {
|
|
498
|
+
const inputLength = columns.filter(item => item.isInputItem || item.isSelectItem).length
|
|
499
|
+
const currentIndex = inputIndex
|
|
500
|
+
if (item.isInputItem) {
|
|
501
|
+
inputIndex++;
|
|
502
|
+
return {
|
|
503
|
+
...item,
|
|
504
|
+
render: (text, record, index) => {
|
|
505
|
+
return (
|
|
506
|
+
<InputElement setData={setData} callSelectItem={callSelectItem.bind(this, index)} item={item} isPrimaryInput={item.isPrimaryInput} record={record} text={text} data={data} index={index} inputLength={inputLength} currentIndex={currentIndex} />
|
|
507
|
+
);
|
|
508
|
+
},
|
|
509
|
+
}
|
|
510
|
+
} else if (item.isSelectItem) {
|
|
511
|
+
inputIndex++;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return item
|
|
515
|
+
}), {
|
|
516
|
+
title: '操作',
|
|
517
|
+
width: 50,
|
|
518
|
+
fixed: 'right',
|
|
519
|
+
render: (text, record, index) => {
|
|
520
|
+
if (index !== 0) {
|
|
521
|
+
return (
|
|
522
|
+
<span style={{ cursor: 'pointer', color: '#005CFF' }} onClick={() => {
|
|
523
|
+
deleteRecord(record)
|
|
524
|
+
}}>删除</span>
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}]
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
return (
|
|
532
|
+
<div className='add_select'>
|
|
533
|
+
<div className='add_select_quick_header'>
|
|
534
|
+
<div className='add_select_quick_header_title'><div>快速录入</div><Button type="primary" onClick={() => { onSaveCallback(data) }}>提交</Button></div>
|
|
535
|
+
<span><span>*</span> 快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Delete】-删除当前行;</span>
|
|
536
|
+
</div>
|
|
537
|
+
<div className={'add_select_wrapper_select add_select_wrapper_select_quick'}>
|
|
538
|
+
<Table
|
|
539
|
+
size='small'
|
|
540
|
+
scroll={{ y: 240 }}
|
|
541
|
+
ref={tableRef}
|
|
542
|
+
dataSource={data}
|
|
543
|
+
columns={selectColumns}
|
|
544
|
+
pagination={false}
|
|
545
|
+
rowClassName={'row-class'}
|
|
546
|
+
rowClassName={(record: object | null | undefined, index: number) =>
|
|
547
|
+
index % 2 === 0 ? 'table_base row-class' : 'table_odd row-class'
|
|
548
|
+
}
|
|
549
|
+
/>
|
|
550
|
+
</div>
|
|
551
|
+
|
|
552
|
+
</div>
|
|
553
|
+
);
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
export default BillEntry;
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import axios from 'axios';
|
|
10
|
-
|
|
10
|
+
import 'antd/dist/antd.css';
|
|
11
11
|
|
|
12
12
|
const resposne = JSON.parse(localStorage.getItem('userInfo') || '{}');
|
|
13
13
|
|
|
@@ -23,6 +23,7 @@ export { default as DataImport } from './components/Functional/DataImport';
|
|
|
23
23
|
export { default as QueryMutipleInput } from './components/Functional/QueryMutipleInput';
|
|
24
24
|
export { default as SearchSelect } from './components/Functional/SearchSelect';
|
|
25
25
|
export { default as AddSelect } from './components/Functional/AddSelect';
|
|
26
|
+
export { default as BillEntry } from './components/Functional/BillEntry';
|
|
26
27
|
export { default as BusinessSearchSelect } from './components/Business/SearchSelect';
|
|
27
28
|
export * from './components/Business/AddSelectBusiness';
|
|
28
29
|
export { default as CommodityEntry } from './components/Business/CommodityEntry';
|