@bit-sun/business-component 2.3.21 → 2.3.23

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.
Files changed (202) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  10. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  11. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
  12. package/dist/components/Functional/AddSelect/helps.d.ts +13 -0
  13. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  14. package/dist/index.esm.js +1338 -1258
  15. package/dist/index.js +1344 -1264
  16. package/dist/utils/utils.d.ts +1 -1
  17. package/docs/index.md +21 -21
  18. package/lib/assets/drag.svg +17 -17
  19. package/lib/assets/exportFail.svg +37 -37
  20. package/lib/assets/exportProcessing.svg +28 -28
  21. package/lib/assets/exportSuccess.svg +34 -34
  22. package/lib/assets/label_icon_bottom.svg +25 -25
  23. package/lib/assets/upExport.svg +22 -22
  24. package/package.json +78 -78
  25. package/src/assets/32.svg +27 -27
  26. package/src/assets/addIcon.svg +17 -17
  27. package/src/assets/allfunc.svg +27 -27
  28. package/src/assets/arrowRight.svg +24 -24
  29. package/src/assets/btn-delete.svg +29 -29
  30. package/src/assets/btn-edit.svg +19 -19
  31. package/src/assets/btn-more.svg +17 -17
  32. package/src/assets/btn-submit.svg +19 -19
  33. package/src/assets/caidan.svg +11 -11
  34. package/src/assets/close.svg +26 -26
  35. package/src/assets/drag.svg +17 -17
  36. package/src/assets/exportFail.svg +37 -37
  37. package/src/assets/exportProcessing.svg +28 -28
  38. package/src/assets/exportSuccess.svg +34 -34
  39. package/src/assets/fixed-left-active.svg +11 -11
  40. package/src/assets/fixed-left.svg +15 -15
  41. package/src/assets/fixed-right-active.svg +11 -11
  42. package/src/assets/fixed-right.svg +15 -15
  43. package/src/assets/guanbi.svg +15 -15
  44. package/src/assets/icon-quanping.svg +15 -15
  45. package/src/assets/icon-shezhi.svg +17 -17
  46. package/src/assets/label_icon_bottom.svg +25 -25
  47. package/src/assets/list-no-img.svg +21 -21
  48. package/src/assets/morentouxiang-32.svg +23 -23
  49. package/src/assets/scanning.svg +24 -24
  50. package/src/assets/upExport.svg +22 -22
  51. package/src/common/ENUM.ts +41 -41
  52. package/src/components/Business/AddSelectBusiness/index.md +162 -162
  53. package/src/components/Business/AddSelectBusiness/index.tsx +1060 -895
  54. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  55. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  56. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  64. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  65. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  66. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  67. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  68. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  69. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  70. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  71. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  72. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  73. package/src/components/Business/BsLayouts/index.less +79 -79
  74. package/src/components/Business/BsLayouts/index.tsx +1484 -1484
  75. package/src/components/Business/BsLayouts/service.ts +10 -10
  76. package/src/components/Business/BsLayouts/utils.tsx +203 -203
  77. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +564 -564
  78. package/src/components/Business/BsSulaQueryTable/index.less +221 -221
  79. package/src/components/Business/BsSulaQueryTable/index.tsx +535 -535
  80. package/src/components/Business/BsSulaQueryTable/setting.tsx +852 -852
  81. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  82. package/src/components/Business/BsSulaQueryTable/utils.tsx +690 -690
  83. package/src/components/Business/CommodityEntry/index.md +70 -70
  84. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  85. package/src/components/Business/CommonAlert/index.tsx +23 -23
  86. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  87. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  88. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  89. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  90. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  91. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  92. package/src/components/Business/HomePageWrapper/index.less +33 -33
  93. package/src/components/Business/HomePageWrapper/index.md +45 -45
  94. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  95. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  96. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +205 -205
  97. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  98. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  99. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  100. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  101. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  102. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  103. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  104. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  105. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  106. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  107. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  108. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  109. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  110. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  111. package/src/components/Business/JsonQueryTable/index.less +16 -16
  112. package/src/components/Business/JsonQueryTable/index.md +328 -328
  113. package/src/components/Business/JsonQueryTable/index.tsx +535 -535
  114. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  115. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  116. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  117. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  118. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  119. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  120. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  121. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  122. package/src/components/Business/JsonQueryTable/static.ts +390 -390
  123. package/src/components/Business/SearchSelect/BusinessUtils.ts +1762 -1762
  124. package/src/components/Business/SearchSelect/common.ts +75 -75
  125. package/src/components/Business/SearchSelect/index.md +1329 -1329
  126. package/src/components/Business/SearchSelect/index.tsx +55 -55
  127. package/src/components/Business/SearchSelect/utils.ts +100 -100
  128. package/src/components/Business/StateFlow/index.less +130 -130
  129. package/src/components/Business/StateFlow/index.md +60 -60
  130. package/src/components/Business/StateFlow/index.tsx +29 -29
  131. package/src/components/Business/TreeSearchSelect/index.md +156 -156
  132. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  133. package/src/components/Business/TreeSearchSelect/utils.ts +75 -75
  134. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  135. package/src/components/Business/columnSettingTable/index.less +247 -247
  136. package/src/components/Business/columnSettingTable/index.md +357 -357
  137. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  138. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  139. package/src/components/Business/columnSettingTable/utils.tsx +71 -71
  140. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -87
  141. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  142. package/src/components/Business/moreTreeTable/index.less +99 -99
  143. package/src/components/Business/moreTreeTable/index.md +448 -448
  144. package/src/components/Business/moreTreeTable/index.tsx +387 -387
  145. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  146. package/src/components/Functional/AddSelect/helps.ts +79 -14
  147. package/src/components/Functional/AddSelect/index.less +367 -367
  148. package/src/components/Functional/AddSelect/index.md +155 -155
  149. package/src/components/Functional/AddSelect/index.tsx +1170 -1282
  150. package/src/components/Functional/BillEntry/index.less +371 -371
  151. package/src/components/Functional/BillEntry/index.md +39 -39
  152. package/src/components/Functional/BillEntry/index.tsx +772 -772
  153. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  154. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  155. package/src/components/Functional/BsAntdSula/index.ts +2 -2
  156. package/src/components/Functional/DataImport/index.less +63 -63
  157. package/src/components/Functional/DataImport/index.md +44 -44
  158. package/src/components/Functional/DataImport/index.tsx +695 -695
  159. package/src/components/Functional/DataValidation/index.less +63 -63
  160. package/src/components/Functional/DataValidation/index.md +39 -39
  161. package/src/components/Functional/DataValidation/index.tsx +687 -687
  162. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -5
  163. package/src/components/Functional/EllipsisTooltip/index.js +36 -36
  164. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  165. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  166. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  167. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  168. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  169. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  170. package/src/components/Functional/SearchSelect/index.less +115 -115
  171. package/src/components/Functional/SearchSelect/index.md +141 -141
  172. package/src/components/Functional/SearchSelect/index.tsx +879 -879
  173. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  174. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  175. package/src/components/Functional/TreeSearchSelect/index.tsx +199 -199
  176. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  177. package/src/components/Solution/RuleComponent/index.d.ts +29 -29
  178. package/src/components/Solution/RuleComponent/index.js +2032 -2032
  179. package/src/components/Solution/RuleComponent/index.less +230 -230
  180. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  181. package/src/components/Solution/RuleComponent/ruleFiled.js +2107 -2107
  182. package/src/components/Solution/RuleComponent/services.ts +13 -13
  183. package/src/components/Solution/RuleComponent/util.js +139 -139
  184. package/src/index.ts +38 -38
  185. package/src/plugin/TableColumnSetting/index.less +247 -247
  186. package/src/plugin/TableColumnSetting/index.md +50 -50
  187. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  188. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  189. package/src/styles/bsDefault.less +1912 -1912
  190. package/src/utils/CheckOneUser/index.md +39 -39
  191. package/src/utils/CheckOneUser/index.ts +51 -51
  192. package/src/utils/LocalstorageUtils.ts +95 -95
  193. package/src/utils/TableUtils.tsx +18 -18
  194. package/src/utils/checkUtils.ts +39 -39
  195. package/src/utils/enumConfig.ts +11 -11
  196. package/src/utils/getFormMode.js +12 -12
  197. package/src/utils/index.ts +4 -4
  198. package/src/utils/requestUtils.ts +34 -34
  199. package/src/utils/serialize.js +7 -7
  200. package/src/utils/utils.ts +212 -212
  201. package/tsconfig.json +29 -29
  202. package/typings.d.ts +4 -4
@@ -1,772 +1,772 @@
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
- import { Resizable } from 'react-resizable';
9
- import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
10
- import { tableColumnsImage } from '@/components/Business/BsSulaQueryTable/utils';
11
- import { getSkuImg } from '@/utils/TableUtils';
12
- import TableColumnSetting from '@/plugin/TableColumnSetting';
13
- import { setInitialShowColumn } from '@/plugin/TableColumnSetting/utils';
14
- import { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
15
- import { handleAntdColumnsSpecialParams } from '@/utils/utils';
16
-
17
- const InputElement = ({
18
- record, text, currentIndex, inputLength, index, setData, data, item, callSelectItem
19
- }: {
20
- record: any, text: string, currentIndex: any, inputLength: any, index: any, setData: any, data: any, item: any, callSelectItem: any
21
- }) => {
22
- const [hoverVisibled, updateHoverVisibled] = useState(false);
23
- const [searchData, updateSearchData] = useState([]);
24
- const tableRef = useRef(null);
25
- const [value, setValue] = useState(text)
26
- const inputRef = useRef(false);
27
-
28
- const onSerchdata = (name: any) => {
29
- axios
30
- .get(`/items/sku/pager/v2?${stringify({ 'skuCodeAndSkuName': name, 'pageSize': 100, 'qp-combination-eq': false, 'qp-approveStatus-eq': 1, 'qp-status-eq': 1 })}`)
31
- .then(({ data, status }: any) => {
32
- if (status === 200) {
33
- if (data.status === '0') {
34
- const resultData = data.data.items.map((item: any, index: any) => ({
35
- ...item,
36
- index
37
- }));
38
- if (resultData.length === 1) {
39
- callSelectItem({ ...resultData[0], needFocus: true })
40
- setValue(resultData[0][item.dataIndex])
41
- } else {
42
- updateHoverVisibled(true)
43
- updateSearchData(resultData)
44
- }
45
- } else {
46
- updateSearchData([])
47
- }
48
- }
49
- })
50
- }
51
-
52
- const onCallback = (itemData: any) => {
53
- updateHoverVisibled(false)
54
- if (itemData) {
55
- callSelectItem({ ...itemData, needFocus: true })
56
- setValue(itemData[item.dataIndex])
57
- } else {
58
- callSelectItem(null)
59
- }
60
- }
61
-
62
- const SearchDataTable = (hoverVisibled: any) => {
63
- const [selectIndex, setSelectIndex] = useState(0);
64
- const inputRef = useRef(null);
65
-
66
- useEffect(() => {
67
- if (searchData.length && hoverVisibled) {
68
- let dom = tableRef?.current?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[0]
69
- if (dom) {
70
- dom.style.background = '#005CFF30'
71
- }
72
- }
73
- }, [hoverVisibled, tableRef?.current])
74
-
75
- useEffect(() => {
76
- const inter = setInterval(() => {
77
- if (inputRef.current) {
78
- inputRef.current.focus()
79
- }
80
- }, 500)
81
-
82
- return () => {
83
- clearInterval(inter);
84
- }
85
- })
86
-
87
- if (!hoverVisibled) return <></>
88
-
89
- return <div className={'add_select_wrapper_select'} style={{ width: '800px', height: '400px', overflow: 'auto', position: 'relative' }}>
90
- <Input placeholder='请输入skucode或者sku名称' ref={inputRef} style={{ position: 'absolute', zIndex: '-100', height: '22px' }} onKeyDown={(e) => {
91
- let currentIndex = selectIndex
92
- if (e.keyCode === 27) {
93
- e.stopPropagation();
94
- e.preventDefault();
95
- setSelectIndex(0);
96
- onCallback(null)
97
- }
98
- if (e.keyCode === 13) { // enter
99
- onCallback(searchData[currentIndex])
100
- setSelectIndex(0);
101
- }
102
-
103
- if (e.keyCode === 40) { // 向下
104
- let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex + 1]
105
- if (dom) {
106
- tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex].style.background = ''
107
- setSelectIndex(currentIndex + 1)
108
- dom.style.background = '#005CFF30'
109
- dom.scrollIntoViewIfNeeded(false)
110
- }
111
- } else if (e.keyCode === 38) {
112
- let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex - 1]
113
- if (dom) {
114
- tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex].style.background = ''
115
- setSelectIndex(currentIndex - 1)
116
- dom.style.background = '#005CFF30'
117
- dom.scrollIntoViewIfNeeded(false)
118
- }
119
- }
120
- }} />
121
- <Table
122
- ref={tableRef}
123
- pagination={false}
124
- // components={
125
- // {
126
- // body: {
127
- // cell: ({index, record, ...props}) => {
128
- // debugger
129
- // return <td {...props} style={selectIndex === record?.index ? {background: '#005CFF30'} : {} } />
130
- // }
131
- // }
132
- // }
133
- // }
134
- onRow={(record, index) => {
135
- return {
136
- onClick: ((record, index, event) => {
137
- let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[index]
138
- if (dom) {
139
- [...(tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr'))].map(item => {
140
- item.style.background = ''
141
- })
142
- dom.style.background = '#005CFF30'
143
- dom.scrollIntoViewIfNeeded(false)
144
- }
145
- setSelectIndex(index)
146
- }).bind(this, record, index), // 点击行
147
- }
148
- }}
149
- rowClassName={'row-class'}
150
- columns={[{
151
- title: 'SKU编码',
152
- width: 150,
153
- dataIndex: 'skuCode',
154
- },
155
- {
156
- title: 'SKU名称',
157
- width: 200,
158
- ellipsis: {
159
- showTitle: false,
160
- },
161
- render: (text: any) => (
162
- <Tooltip placement="topLeft" title={text}>
163
- {text}
164
- </Tooltip>
165
- ),
166
- dataIndex: 'name',
167
- },
168
- {
169
- title: '图片',
170
- dataIndex: 'itemUrl',
171
- width: 200,
172
- ellipsis: {
173
- showTitle: false,
174
- },
175
- render: (text: any,record: any) => (
176
- <Tooltip placement="topLeft" title={text}>
177
- {tableColumnsImage(getSkuImg(record),{ width: 28, height: 28 })}
178
- </Tooltip>
179
- ),
180
- },
181
- {
182
- title: '国际条码',
183
- width: 100,
184
- ellipsis: {
185
- showTitle: false,
186
- },
187
- dataIndex: 'barCode',
188
- render: (text: any) => (
189
- <Tooltip placement="topLeft" title={text}>
190
- {text}
191
- </Tooltip>
192
- ),
193
- },
194
- {
195
- title: '所属SPU名称',
196
- width: 100,
197
- ellipsis: {
198
- showTitle: false,
199
- },
200
- dataIndex: 'itemName',
201
- render: (text: any) => (
202
- <Tooltip placement="topLeft" title={text}>
203
- {text}
204
- </Tooltip>
205
- ),
206
- },
207
- {
208
- title: '所属SPU编码',
209
- width: 100,
210
- ellipsis: {
211
- showTitle: false,
212
- },
213
- dataIndex: 'itemCode',
214
- render: (text: any) => (
215
- <Tooltip placement="topLeft" title={text}>
216
- {text}
217
- </Tooltip>
218
- ),
219
- },
220
- {
221
- title: '外部编码',
222
- width: 100,
223
- ellipsis: {
224
- showTitle: false,
225
- },
226
- render: (text: any) => (
227
- <Tooltip placement="topLeft" title={text}>
228
- {text}
229
- </Tooltip>
230
- ),
231
- dataIndex: 'externalCode',
232
- }]} dataSource={searchData} />
233
- </div>
234
- }
235
-
236
- let precisionObj={};
237
- const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
238
- const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
239
- if(isCountUnitAccuracyCheck) {
240
- precisionObj = {
241
- onBlur: (e: any) => {
242
- const { target: { value } } = e;
243
- if(!checkQuantityAccuracy(value,Number(unitAccuracy))) {
244
- record[item.dataIndex] = precisionQuantity(value,Number(unitAccuracy))
245
- const newData = data.map((i: any, innerIndex: number) => {
246
- if(innerIndex == index) {
247
- i[item.dataIndex] = record[item.dataIndex]
248
- }
249
- return i
250
- })
251
- setData(newData)
252
- }
253
- }
254
- // precision: unitAccuracy
255
- }
256
- }
257
-
258
- return (
259
- <Popover placement="bottomLeft" destroyTooltipOnHide={{ keepParent: false }} title="" trigger="" content={SearchDataTable(hoverVisibled)} visible={hoverVisibled} onVisibleChange={(disabled) => { updateHoverVisibled(disabled) }}>
260
- {item.isPrimaryInput ?
261
- <Input
262
- value={value}
263
- ref={inputRef}
264
- placeholder='skucode / sku名称'
265
- keyboard={false}
266
- autoFocus={record.autoFocus}
267
- onChange={(value) => {
268
- record[item.dataIndex] = value.currentTarget.value
269
- setValue(value.currentTarget.value)
270
- // setData(data);
271
- }}
272
- // onFocus={(e)=> {
273
- // let dom1 = e.currentTarget;
274
- // dom1.setSelectionRange(100, 0);
275
- // dom1.select(text);
276
- // }}
277
- onKeyDown={(e) => {
278
- // if (e.keyCode === 13 && e.ctrlKey) {
279
- // handleOk(true)
280
- // document.getElementById("first-query")?.focus()
281
- // }
282
- if (e.keyCode === 8 && e.ctrlKey && index) {
283
- message.success('删除当前行')
284
- e.stopPropagation();
285
- e.preventDefault();
286
- let dom = e.nativeEvent.path[3].children[index]?.getElementsByTagName('input')[currentIndex]
287
- if (dom) {
288
- dom.select();
289
- dom.focus();
290
- dom.scrollIntoViewIfNeeded(false)
291
- }
292
- dom = null
293
- setData(data.filter((item, innerIndex) => innerIndex !== index))
294
- }
295
- if (e.keyCode === 13) { // enter
296
- if (item.isPrimaryInput) {
297
- if (e.currentTarget.value.length < 2) {
298
- message.warning('至少输入两个字符');
299
- } else {
300
- onSerchdata(e.currentTarget.value)
301
- }
302
- }
303
- }
304
- if (e.keyCode === 37 && e.shiftKey) { // 左滑动
305
- e.stopPropagation();
306
- e.preventDefault();
307
- let dom = e.nativeEvent.path[3].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
308
- if (dom) {
309
- dom.select();
310
- dom.focus();
311
- dom.scrollIntoViewIfNeeded(false)
312
- }
313
- dom = null
314
- }
315
- if (e.keyCode === 39 && e.shiftKey) { // 右滑
316
- e.stopPropagation();
317
- e.preventDefault();
318
- let dom = e.nativeEvent.path[3].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
319
- if (dom) {
320
- dom.select();
321
- dom.focus();
322
- dom.scrollIntoViewIfNeeded(false)
323
- }
324
- dom = null
325
- }
326
- if (e.keyCode === 40) { // 向下
327
- e.stopPropagation();
328
- e.preventDefault();
329
- let dom = e.nativeEvent.path[3].children[index + 2]?.getElementsByTagName('input')[currentIndex]
330
- if (dom) {
331
- dom.select();
332
- dom.focus();
333
- dom.scrollIntoViewIfNeeded(false)
334
- }
335
- dom = null
336
- } else if (e.keyCode === 38) {
337
- e.stopPropagation();
338
- e.preventDefault();
339
- let dom1 = e.nativeEvent.path[3].children[index]?.getElementsByTagName('input')[currentIndex]
340
- if (dom1) {
341
- // dom1.value=""
342
- // dom1.setSelectionRange(100, 0);
343
- dom1.select();
344
- dom1.focus();
345
- dom1.scrollIntoViewIfNeeded(false)
346
- // dom1.value=record['count']
347
- }
348
- dom1 = null
349
- } else if (e.keyCode === 9 && currentIndex === inputLength - 1 && index === data.length - 1) {
350
- setData([...data, {}])
351
- }
352
- }}
353
- />
354
- :
355
- <InputNumber
356
- // onBlur={() => {updateHoverVisibled(false)}}
357
- value={text || ''}
358
- min={0}
359
- keyboard={false}
360
- {...precisionObj}
361
- onChange={(value) => {
362
- record[item.dataIndex] = value
363
- const newData = data.map((i: any, innerIndex: number) => {
364
- if(innerIndex == index) {
365
- i[item.dataIndex] = record[item.dataIndex]
366
- }
367
- return i
368
- })
369
- setData(newData)
370
- }}
371
- onKeyDown={(e) => {
372
- // if (e.keyCode === 13 && e.ctrlKey) {
373
- // handleOk(true)
374
- // document.getElementById("first-query")?.focus()
375
- // }
376
- if (e.keyCode === 8 && e.ctrlKey && index) {
377
- message.success('删除当前行')
378
- e.stopPropagation();
379
- e.preventDefault();
380
- let dom = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
381
- if (dom) {
382
- dom.select();
383
- dom.focus();
384
- dom.scrollIntoViewIfNeeded(false)
385
- }
386
- dom = null
387
- setData(data.filter((item, innerIndex) => innerIndex !== index))
388
- }
389
- if (e.keyCode === 37 && e.shiftKey) { // 左滑动
390
- e.stopPropagation();
391
- e.preventDefault();
392
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
393
- if (dom) {
394
- dom.select();
395
- dom.focus();
396
- dom.scrollIntoViewIfNeeded(false)
397
- }
398
- dom = null
399
- }
400
- if (e.keyCode === 39 && e.shiftKey) { // 右滑
401
- e.stopPropagation();
402
- e.preventDefault();
403
- let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
404
- if (dom) {
405
- dom.select();
406
- dom.focus();
407
- dom.scrollIntoViewIfNeeded(false)
408
- }
409
- dom = null
410
- }
411
- if (e.keyCode === 40) { // 向下
412
- e.stopPropagation();
413
- e.preventDefault();
414
- let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
415
- if (dom) {
416
- dom.select();
417
- dom.focus();
418
- dom.scrollIntoViewIfNeeded(false)
419
- }
420
- dom = null
421
- } else if (e.keyCode === 38) {
422
- e.stopPropagation();
423
- e.preventDefault();
424
- let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
425
- if (dom1) {
426
- // dom1.value=""
427
- // dom1.setSelectionRange(100, 0);
428
- dom1.select();
429
- dom1.focus();
430
- dom1.scrollIntoViewIfNeeded(false)
431
- // dom1.value=record['count']
432
- }
433
- dom1 = null
434
- } else if (e.keyCode === 9 && currentIndex === inputLength - 1 && index === data.length - 1) {
435
- e.stopPropagation();
436
- e.preventDefault();
437
- } else if (e.keyCode === 13 && currentIndex === inputLength - 1 && index === data.length - 1 && record['skuCode']) {
438
- setData([...data, { autoFocus: true }])
439
- }
440
- }}
441
- />
442
- }
443
-
444
- </Popover>
445
- )
446
- }
447
-
448
- const ResizeableTitle = (props) => {
449
- const { onResize, width, ...restProps } = props;
450
-
451
- if (!width) {
452
- return <th {...restProps} />;
453
- }
454
- return (
455
- <Resizable
456
- width={width}
457
- height={0}
458
- onResize={onResize}
459
- draggableOpts={{ enableUserSelectHack: false }}
460
- >
461
- <th {...restProps} />
462
- </Resizable>
463
- );
464
- };
465
-
466
- const BillEntry: React.FC = ({ onSaveCallback, validDataUrl="/items/sku/import/check", isBrandAuth=true, isCheckStockNum=true, tableCode='skuBillEntry-tableSelectedItemPartCode' }) => {
467
- const columns = [
468
- {
469
- title: 'SKU编码',
470
- width: 150,
471
- dataIndex: 'skuCode',
472
- isInputItem: true,
473
- isPrimaryInput: true
474
- },
475
- {
476
- title: 'SKU名称',
477
- width: 200,
478
- ellipsis: {
479
- showTitle: false,
480
- },
481
- render: (text: any) => (
482
- <Tooltip placement="topLeft" title={text}>
483
- {text}
484
- </Tooltip>
485
- ),
486
- dataIndex: 'name',
487
- },
488
- {
489
- title: '图片',
490
- dataIndex: 'itemUrl',
491
- width: 200,
492
- ellipsis: {
493
- showTitle: false,
494
- },
495
- render: (text: any,record: any) => (
496
- <Tooltip placement="topLeft" title={text}>
497
- {tableColumnsImage(getSkuImg(record),{ width: 28, height: 28 })}
498
- </Tooltip>
499
- ),
500
- },
501
- {
502
- title: '单位',
503
- dataIndex: 'selectUnitCode',
504
- width: 100,
505
- render: (text: any, record: any) => {
506
- if (record?.packingUnitList?.length) {
507
- const basePackUnit = record?.packingUnitList[0]
508
- record.selectUnitCode = basePackUnit.unitCode
509
- return basePackUnit.name || basePackUnit.unitCode
510
- }
511
-
512
-
513
- return <></>
514
- },
515
- },
516
- {
517
- title: '数量',
518
- width: 100,
519
- isInputItem: true,
520
- dataIndex: 'count',
521
- },
522
- {
523
- title: '所属SPU编码',
524
- width: 100,
525
- ellipsis: {
526
- showTitle: false,
527
- },
528
- dataIndex: 'itemCode',
529
- render: (text: any) => (
530
- <Tooltip placement="topLeft" title={text}>
531
- {text}
532
- </Tooltip>
533
- ),
534
- },
535
- {
536
- title: '规格',
537
- width: 200,
538
- ellipsis: {
539
- showTitle: false,
540
- },
541
- render: (text: any) => (
542
- <Tooltip placement="topLeft" title={text}>
543
- {text}
544
- </Tooltip>
545
- ),
546
- dataIndex: 'propertyNameAndValue',
547
- }
548
- ]
549
- const [isModalVisible, setIsModalVisible] = useState(false);
550
- const [data, setData] = useState([{ hovered: false }]);
551
- const tableRef = useRef(null)
552
- const codeSelected = tableCode;
553
-
554
- const [loading, setLoading] = useState(false);
555
- const [selectColumns, setSelectColumns] = useState([]);
556
- const [showColumns, setShowColumns] = useState([]);
557
-
558
- useEffect(() => {
559
- setSelectColumns([...columns.map(item => {
560
- const inputLength = columns.filter(item => item.isInputItem || item.isSelectItem).length
561
- const currentIndex = inputIndex
562
- if (item.isInputItem) {
563
- inputIndex++;
564
- return {
565
- ...item,
566
- render: (text, record, index) => {
567
- return (
568
- <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} />
569
- );
570
- },
571
- }
572
- } else if (item.isSelectItem) {
573
- inputIndex++;
574
- }
575
-
576
- return item
577
- }), {
578
- title: '操作',
579
- width: 50,
580
- render: (text, record, index) => {
581
- if (index !== 0) {
582
- return (
583
- <span style={{ cursor: 'pointer', color: '#005CFF' }} onClick={() => {
584
- deleteRecord(record)
585
- }}>删除</span>
586
- )
587
- }
588
- }
589
- }])
590
- },[data])
591
-
592
- useEffect(() => {
593
- setInitialShowColumn(codeSelected,selectColumns,(res) => {
594
- console.log(res,'---res')
595
- setShowColumnsCallback(res)
596
- })
597
- },[selectColumns])
598
-
599
- const callSelectItem = (index, item) => {
600
- if (item) {
601
- let newData = [].concat(data)
602
- newData[index] = { ...data[index], ...item }
603
- setData(newData)
604
- }
605
- let dom = tableRef?.current?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[index + 1]
606
- if (dom) {
607
- setTimeout(() => {
608
- dom.getElementsByTagName('input')[item ? 1 : 0]?.select()
609
- dom.getElementsByTagName('input')[item ? 1 : 0]?.focus()
610
- }, 200)
611
- }
612
- }
613
-
614
- const deleteRecord = (record) => {
615
- setData(data.filter(item => item.skuCode !== record.skuCode))
616
- }
617
-
618
- let inputIndex = 0;
619
-
620
- const isSkuCanEntry = (resultData) => {
621
- // 处理业务参数
622
- let otherParams={}
623
- if(isBrandAuth){
624
- otherParams = { brandAuth: 'ctl-withAuth' }
625
- }
626
- return axios
627
- .post(validDataUrl, {
628
- ...otherParams,
629
- columns: ["skuCode", "quantity"],
630
- data: resultData.map((i:any) => ({ skuCode: i.skuCode, quality: i.count })),
631
- checkStockNum: isCheckStockNum,
632
- })
633
- .then((result) => {
634
- result = result.data;
635
- if (result.status !== '0') {
636
- message.error(result.msg);
637
- return { flag: false }
638
- } else {
639
- let res = result.data || [];
640
- const errorList = res.filter((i: any) => !i.flag);
641
- return { flag: !errorList?.length, errorList }
642
- }
643
- }).catch(() => {
644
- return { flag:false }
645
- })
646
- }
647
-
648
- const handleSubmit = async () => {
649
- // 加校验逻辑
650
- if (!data?.length) {
651
- message.warning('至少录入一条数据');
652
- return;
653
- }
654
- if (!data?.every((d: any) => d.skuCode && d.name)) {
655
- message.warning('请选择商品!');
656
- return;
657
- }
658
- if (!data?.every((d: any) => d.count)) {
659
- message.warning('请填写商品数量!');
660
- return;
661
- }
662
- const canEntryObject = await isSkuCanEntry(data)
663
- if(canEntryObject?.flag === false) {
664
- const messageInfo = canEntryObject?.errorList?.length && canEntryObject?.errorList.map((i: any) => <div>{i.skuCode}校验失败:{i.checkResults}</div>)
665
- messageInfo && message.warning({ content: messageInfo, duration: 6 });
666
- return;
667
- }
668
-
669
- setLoading(true)
670
- onSaveCallback(data).then(res => {
671
- if(true) {
672
- let initSuccessMessage = '保存成功'
673
- const rmsbi = res?.messageSuccessBackInfo || {};
674
- if(rmsbi && Object.keys(rmsbi)?.length){
675
- rmsbi?.needThrowSuccess ? message.success(rmsbi?.successMessage || initSuccessMessage) : null
676
- } else {
677
- message.success(initSuccessMessage)
678
- }
679
- }
680
- setLoading(false)
681
- }).catch(Error => {
682
- message.error(Error);
683
- setLoading(false)
684
- })
685
- }
686
-
687
- const setShowColumnsCallback = (newColumns: Array<any>) => {
688
- setShowColumns([...newColumns])
689
- }
690
-
691
- const handleResize = (arr,index: any, callback) => (_: any, { size }: any) => {
692
- let newColumns = arr.map((col: any) => ({ ...col }));
693
- const handleIndex = (arr: any, indexArr: any) => {
694
- let i = indexArr.shift();
695
- if (indexArr.length > 0) {
696
- handleIndex(arr[i].children, indexArr);
697
- } else {
698
- arr[i] = {
699
- ...arr[i],
700
- width: size.width,
701
- };
702
- handleAntdColumnsSpecialParams(arr[i]);
703
- }
704
- };
705
- handleIndex(newColumns, [...index]);
706
- callback(newColumns)
707
- };
708
-
709
- const handleColumns = (arr: any, indexArr: any[], callback: any) => {
710
- arr.forEach((item: any, index: any) => {
711
- let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
712
- if (noEmptyArray(item.children)) {
713
- handleColumns(item.children, indexArrInside);
714
- } else {
715
- item.width = item.width || getItemDefaultWidth(item);
716
- item.onHeaderCell = (column: any) => ({
717
- ...item,
718
- width:
719
- typeof column.width === 'number'
720
- ? column.width
721
- : parseInt(column.width.replace('px', '')),
722
- onResize: handleResize(arr,indexArrInside, callback),
723
- });
724
- }
725
- })
726
- };
727
- let showSelectedCol = showColumns.map((item: any) => {
728
- handleAntdColumnsSpecialParams(item);
729
- return ({ ...item })
730
- })
731
- handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
732
-
733
- return (
734
- <div className='add_select'>
735
- <div className='add_select_quick_header'>
736
- <div className='add_select_quick_header_title'><div>快速录入</div><Button type="primary" onClick={() => handleSubmit()} loading={loading}>提交</Button></div>
737
- <span><span>*</span> &nbsp;快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Delete】-删除当前行;</span>
738
- <span style={{ marginRight: 8, float: 'right' }}>
739
- <TableColumnSetting
740
- setShowColumns={setShowColumnsCallback}
741
- showColumns={showColumns}
742
- datasource={selectColumns || []}
743
- tableCode={codeSelected}
744
- settingImgAttribute={{ width: 24, style: { marginTop: 2 } }}
745
- />
746
- </span>
747
- </div>
748
- <div className={'add_select_wrapper_select add_select_wrapper_select_quick'}>
749
- <Table
750
- size='small'
751
- scroll={{ y: 240 }}
752
- ref={tableRef}
753
- dataSource={data}
754
- columns={showSelectedCol}
755
- pagination={false}
756
- rowClassName={'row-class'}
757
- rowClassName={(record: object | null | undefined, index: number) =>
758
- index % 2 === 0 ? 'table_base row-class' : 'table_odd row-class'
759
- }
760
- components={{
761
- header: {
762
- cell: ResizeableTitle,
763
- },
764
- }}
765
- />
766
- </div>
767
-
768
- </div>
769
- );
770
- };
771
-
772
- export default BillEntry;
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
+ import { Resizable } from 'react-resizable';
9
+ import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
10
+ import { tableColumnsImage } from '@/components/Business/BsSulaQueryTable/utils';
11
+ import { getSkuImg } from '@/utils/TableUtils';
12
+ import TableColumnSetting from '@/plugin/TableColumnSetting';
13
+ import { setInitialShowColumn } from '@/plugin/TableColumnSetting/utils';
14
+ import { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
15
+ import { handleAntdColumnsSpecialParams } from '@/utils/utils';
16
+
17
+ const InputElement = ({
18
+ record, text, currentIndex, inputLength, index, setData, data, item, callSelectItem
19
+ }: {
20
+ record: any, text: string, currentIndex: any, inputLength: any, index: any, setData: any, data: any, item: any, callSelectItem: any
21
+ }) => {
22
+ const [hoverVisibled, updateHoverVisibled] = useState(false);
23
+ const [searchData, updateSearchData] = useState([]);
24
+ const tableRef = useRef(null);
25
+ const [value, setValue] = useState(text)
26
+ const inputRef = useRef(false);
27
+
28
+ const onSerchdata = (name: any) => {
29
+ axios
30
+ .get(`/items/sku/pager/v2?${stringify({ 'skuCodeAndSkuName': name, 'pageSize': 100, 'qp-combination-eq': false, 'qp-approveStatus-eq': 1, 'qp-status-eq': 1 })}`)
31
+ .then(({ data, status }: any) => {
32
+ if (status === 200) {
33
+ if (data.status === '0') {
34
+ const resultData = data.data.items.map((item: any, index: any) => ({
35
+ ...item,
36
+ index
37
+ }));
38
+ if (resultData.length === 1) {
39
+ callSelectItem({ ...resultData[0], needFocus: true })
40
+ setValue(resultData[0][item.dataIndex])
41
+ } else {
42
+ updateHoverVisibled(true)
43
+ updateSearchData(resultData)
44
+ }
45
+ } else {
46
+ updateSearchData([])
47
+ }
48
+ }
49
+ })
50
+ }
51
+
52
+ const onCallback = (itemData: any) => {
53
+ updateHoverVisibled(false)
54
+ if (itemData) {
55
+ callSelectItem({ ...itemData, needFocus: true })
56
+ setValue(itemData[item.dataIndex])
57
+ } else {
58
+ callSelectItem(null)
59
+ }
60
+ }
61
+
62
+ const SearchDataTable = (hoverVisibled: any) => {
63
+ const [selectIndex, setSelectIndex] = useState(0);
64
+ const inputRef = useRef(null);
65
+
66
+ useEffect(() => {
67
+ if (searchData.length && hoverVisibled) {
68
+ let dom = tableRef?.current?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[0]
69
+ if (dom) {
70
+ dom.style.background = '#005CFF30'
71
+ }
72
+ }
73
+ }, [hoverVisibled, tableRef?.current])
74
+
75
+ useEffect(() => {
76
+ const inter = setInterval(() => {
77
+ if (inputRef.current) {
78
+ inputRef.current.focus()
79
+ }
80
+ }, 500)
81
+
82
+ return () => {
83
+ clearInterval(inter);
84
+ }
85
+ })
86
+
87
+ if (!hoverVisibled) return <></>
88
+
89
+ return <div className={'add_select_wrapper_select'} style={{ width: '800px', height: '400px', overflow: 'auto', position: 'relative' }}>
90
+ <Input placeholder='请输入skucode或者sku名称' ref={inputRef} style={{ position: 'absolute', zIndex: '-100', height: '22px' }} onKeyDown={(e) => {
91
+ let currentIndex = selectIndex
92
+ if (e.keyCode === 27) {
93
+ e.stopPropagation();
94
+ e.preventDefault();
95
+ setSelectIndex(0);
96
+ onCallback(null)
97
+ }
98
+ if (e.keyCode === 13) { // enter
99
+ onCallback(searchData[currentIndex])
100
+ setSelectIndex(0);
101
+ }
102
+
103
+ if (e.keyCode === 40) { // 向下
104
+ let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex + 1]
105
+ if (dom) {
106
+ tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex].style.background = ''
107
+ setSelectIndex(currentIndex + 1)
108
+ dom.style.background = '#005CFF30'
109
+ dom.scrollIntoViewIfNeeded(false)
110
+ }
111
+ } else if (e.keyCode === 38) {
112
+ let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex - 1]
113
+ if (dom) {
114
+ tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[currentIndex].style.background = ''
115
+ setSelectIndex(currentIndex - 1)
116
+ dom.style.background = '#005CFF30'
117
+ dom.scrollIntoViewIfNeeded(false)
118
+ }
119
+ }
120
+ }} />
121
+ <Table
122
+ ref={tableRef}
123
+ pagination={false}
124
+ // components={
125
+ // {
126
+ // body: {
127
+ // cell: ({index, record, ...props}) => {
128
+ // debugger
129
+ // return <td {...props} style={selectIndex === record?.index ? {background: '#005CFF30'} : {} } />
130
+ // }
131
+ // }
132
+ // }
133
+ // }
134
+ onRow={(record, index) => {
135
+ return {
136
+ onClick: ((record, index, event) => {
137
+ let dom = tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[index]
138
+ if (dom) {
139
+ [...(tableRef.current.getElementsByTagName('tbody')[0].getElementsByTagName('tr'))].map(item => {
140
+ item.style.background = ''
141
+ })
142
+ dom.style.background = '#005CFF30'
143
+ dom.scrollIntoViewIfNeeded(false)
144
+ }
145
+ setSelectIndex(index)
146
+ }).bind(this, record, index), // 点击行
147
+ }
148
+ }}
149
+ rowClassName={'row-class'}
150
+ columns={[{
151
+ title: 'SKU编码',
152
+ width: 150,
153
+ dataIndex: 'skuCode',
154
+ },
155
+ {
156
+ title: 'SKU名称',
157
+ width: 200,
158
+ ellipsis: {
159
+ showTitle: false,
160
+ },
161
+ render: (text: any) => (
162
+ <Tooltip placement="topLeft" title={text}>
163
+ {text}
164
+ </Tooltip>
165
+ ),
166
+ dataIndex: 'name',
167
+ },
168
+ {
169
+ title: '图片',
170
+ dataIndex: 'itemUrl',
171
+ width: 200,
172
+ ellipsis: {
173
+ showTitle: false,
174
+ },
175
+ render: (text: any,record: any) => (
176
+ <Tooltip placement="topLeft" title={text}>
177
+ {tableColumnsImage(getSkuImg(record),{ width: 28, height: 28 })}
178
+ </Tooltip>
179
+ ),
180
+ },
181
+ {
182
+ title: '国际条码',
183
+ width: 100,
184
+ ellipsis: {
185
+ showTitle: false,
186
+ },
187
+ dataIndex: 'barCode',
188
+ render: (text: any) => (
189
+ <Tooltip placement="topLeft" title={text}>
190
+ {text}
191
+ </Tooltip>
192
+ ),
193
+ },
194
+ {
195
+ title: '所属SPU名称',
196
+ width: 100,
197
+ ellipsis: {
198
+ showTitle: false,
199
+ },
200
+ dataIndex: 'itemName',
201
+ render: (text: any) => (
202
+ <Tooltip placement="topLeft" title={text}>
203
+ {text}
204
+ </Tooltip>
205
+ ),
206
+ },
207
+ {
208
+ title: '所属SPU编码',
209
+ width: 100,
210
+ ellipsis: {
211
+ showTitle: false,
212
+ },
213
+ dataIndex: 'itemCode',
214
+ render: (text: any) => (
215
+ <Tooltip placement="topLeft" title={text}>
216
+ {text}
217
+ </Tooltip>
218
+ ),
219
+ },
220
+ {
221
+ title: '外部编码',
222
+ width: 100,
223
+ ellipsis: {
224
+ showTitle: false,
225
+ },
226
+ render: (text: any) => (
227
+ <Tooltip placement="topLeft" title={text}>
228
+ {text}
229
+ </Tooltip>
230
+ ),
231
+ dataIndex: 'externalCode',
232
+ }]} dataSource={searchData} />
233
+ </div>
234
+ }
235
+
236
+ let precisionObj={};
237
+ const unitAccuracy = record.packingUnitList?.[0]?.unitAccuracy
238
+ const isCountUnitAccuracyCheck = item.dataIndex =='count' && unitAccuracy !== undefined
239
+ if(isCountUnitAccuracyCheck) {
240
+ precisionObj = {
241
+ onBlur: (e: any) => {
242
+ const { target: { value } } = e;
243
+ if(!checkQuantityAccuracy(value,Number(unitAccuracy))) {
244
+ record[item.dataIndex] = precisionQuantity(value,Number(unitAccuracy))
245
+ const newData = data.map((i: any, innerIndex: number) => {
246
+ if(innerIndex == index) {
247
+ i[item.dataIndex] = record[item.dataIndex]
248
+ }
249
+ return i
250
+ })
251
+ setData(newData)
252
+ }
253
+ }
254
+ // precision: unitAccuracy
255
+ }
256
+ }
257
+
258
+ return (
259
+ <Popover placement="bottomLeft" destroyTooltipOnHide={{ keepParent: false }} title="" trigger="" content={SearchDataTable(hoverVisibled)} visible={hoverVisibled} onVisibleChange={(disabled) => { updateHoverVisibled(disabled) }}>
260
+ {item.isPrimaryInput ?
261
+ <Input
262
+ value={value}
263
+ ref={inputRef}
264
+ placeholder='skucode / sku名称'
265
+ keyboard={false}
266
+ autoFocus={record.autoFocus}
267
+ onChange={(value) => {
268
+ record[item.dataIndex] = value.currentTarget.value
269
+ setValue(value.currentTarget.value)
270
+ // setData(data);
271
+ }}
272
+ // onFocus={(e)=> {
273
+ // let dom1 = e.currentTarget;
274
+ // dom1.setSelectionRange(100, 0);
275
+ // dom1.select(text);
276
+ // }}
277
+ onKeyDown={(e) => {
278
+ // if (e.keyCode === 13 && e.ctrlKey) {
279
+ // handleOk(true)
280
+ // document.getElementById("first-query")?.focus()
281
+ // }
282
+ if (e.keyCode === 8 && e.ctrlKey && index) {
283
+ message.success('删除当前行')
284
+ e.stopPropagation();
285
+ e.preventDefault();
286
+ let dom = e.nativeEvent.path[3].children[index]?.getElementsByTagName('input')[currentIndex]
287
+ if (dom) {
288
+ dom.select();
289
+ dom.focus();
290
+ dom.scrollIntoViewIfNeeded(false)
291
+ }
292
+ dom = null
293
+ setData(data.filter((item, innerIndex) => innerIndex !== index))
294
+ }
295
+ if (e.keyCode === 13) { // enter
296
+ if (item.isPrimaryInput) {
297
+ if (e.currentTarget.value.length < 2) {
298
+ message.warning('至少输入两个字符');
299
+ } else {
300
+ onSerchdata(e.currentTarget.value)
301
+ }
302
+ }
303
+ }
304
+ if (e.keyCode === 37 && e.shiftKey) { // 左滑动
305
+ e.stopPropagation();
306
+ e.preventDefault();
307
+ let dom = e.nativeEvent.path[3].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
308
+ if (dom) {
309
+ dom.select();
310
+ dom.focus();
311
+ dom.scrollIntoViewIfNeeded(false)
312
+ }
313
+ dom = null
314
+ }
315
+ if (e.keyCode === 39 && e.shiftKey) { // 右滑
316
+ e.stopPropagation();
317
+ e.preventDefault();
318
+ let dom = e.nativeEvent.path[3].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
319
+ if (dom) {
320
+ dom.select();
321
+ dom.focus();
322
+ dom.scrollIntoViewIfNeeded(false)
323
+ }
324
+ dom = null
325
+ }
326
+ if (e.keyCode === 40) { // 向下
327
+ e.stopPropagation();
328
+ e.preventDefault();
329
+ let dom = e.nativeEvent.path[3].children[index + 2]?.getElementsByTagName('input')[currentIndex]
330
+ if (dom) {
331
+ dom.select();
332
+ dom.focus();
333
+ dom.scrollIntoViewIfNeeded(false)
334
+ }
335
+ dom = null
336
+ } else if (e.keyCode === 38) {
337
+ e.stopPropagation();
338
+ e.preventDefault();
339
+ let dom1 = e.nativeEvent.path[3].children[index]?.getElementsByTagName('input')[currentIndex]
340
+ if (dom1) {
341
+ // dom1.value=""
342
+ // dom1.setSelectionRange(100, 0);
343
+ dom1.select();
344
+ dom1.focus();
345
+ dom1.scrollIntoViewIfNeeded(false)
346
+ // dom1.value=record['count']
347
+ }
348
+ dom1 = null
349
+ } else if (e.keyCode === 9 && currentIndex === inputLength - 1 && index === data.length - 1) {
350
+ setData([...data, {}])
351
+ }
352
+ }}
353
+ />
354
+ :
355
+ <InputNumber
356
+ // onBlur={() => {updateHoverVisibled(false)}}
357
+ value={text || ''}
358
+ min={0}
359
+ keyboard={false}
360
+ {...precisionObj}
361
+ onChange={(value) => {
362
+ record[item.dataIndex] = value
363
+ const newData = data.map((i: any, innerIndex: number) => {
364
+ if(innerIndex == index) {
365
+ i[item.dataIndex] = record[item.dataIndex]
366
+ }
367
+ return i
368
+ })
369
+ setData(newData)
370
+ }}
371
+ onKeyDown={(e) => {
372
+ // if (e.keyCode === 13 && e.ctrlKey) {
373
+ // handleOk(true)
374
+ // document.getElementById("first-query")?.focus()
375
+ // }
376
+ if (e.keyCode === 8 && e.ctrlKey && index) {
377
+ message.success('删除当前行')
378
+ e.stopPropagation();
379
+ e.preventDefault();
380
+ let dom = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
381
+ if (dom) {
382
+ dom.select();
383
+ dom.focus();
384
+ dom.scrollIntoViewIfNeeded(false)
385
+ }
386
+ dom = null
387
+ setData(data.filter((item, innerIndex) => innerIndex !== index))
388
+ }
389
+ if (e.keyCode === 37 && e.shiftKey) { // 左滑动
390
+ e.stopPropagation();
391
+ e.preventDefault();
392
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
393
+ if (dom) {
394
+ dom.select();
395
+ dom.focus();
396
+ dom.scrollIntoViewIfNeeded(false)
397
+ }
398
+ dom = null
399
+ }
400
+ if (e.keyCode === 39 && e.shiftKey) { // 右滑
401
+ e.stopPropagation();
402
+ e.preventDefault();
403
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
404
+ if (dom) {
405
+ dom.select();
406
+ dom.focus();
407
+ dom.scrollIntoViewIfNeeded(false)
408
+ }
409
+ dom = null
410
+ }
411
+ if (e.keyCode === 40) { // 向下
412
+ e.stopPropagation();
413
+ e.preventDefault();
414
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
415
+ if (dom) {
416
+ dom.select();
417
+ dom.focus();
418
+ dom.scrollIntoViewIfNeeded(false)
419
+ }
420
+ dom = null
421
+ } else if (e.keyCode === 38) {
422
+ e.stopPropagation();
423
+ e.preventDefault();
424
+ let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
425
+ if (dom1) {
426
+ // dom1.value=""
427
+ // dom1.setSelectionRange(100, 0);
428
+ dom1.select();
429
+ dom1.focus();
430
+ dom1.scrollIntoViewIfNeeded(false)
431
+ // dom1.value=record['count']
432
+ }
433
+ dom1 = null
434
+ } else if (e.keyCode === 9 && currentIndex === inputLength - 1 && index === data.length - 1) {
435
+ e.stopPropagation();
436
+ e.preventDefault();
437
+ } else if (e.keyCode === 13 && currentIndex === inputLength - 1 && index === data.length - 1 && record['skuCode']) {
438
+ setData([...data, { autoFocus: true }])
439
+ }
440
+ }}
441
+ />
442
+ }
443
+
444
+ </Popover>
445
+ )
446
+ }
447
+
448
+ const ResizeableTitle = (props) => {
449
+ const { onResize, width, ...restProps } = props;
450
+
451
+ if (!width) {
452
+ return <th {...restProps} />;
453
+ }
454
+ return (
455
+ <Resizable
456
+ width={width}
457
+ height={0}
458
+ onResize={onResize}
459
+ draggableOpts={{ enableUserSelectHack: false }}
460
+ >
461
+ <th {...restProps} />
462
+ </Resizable>
463
+ );
464
+ };
465
+
466
+ const BillEntry: React.FC = ({ onSaveCallback, validDataUrl="/items/sku/import/check", isBrandAuth=true, isCheckStockNum=true, tableCode='skuBillEntry-tableSelectedItemPartCode' }) => {
467
+ const columns = [
468
+ {
469
+ title: 'SKU编码',
470
+ width: 150,
471
+ dataIndex: 'skuCode',
472
+ isInputItem: true,
473
+ isPrimaryInput: true
474
+ },
475
+ {
476
+ title: 'SKU名称',
477
+ width: 200,
478
+ ellipsis: {
479
+ showTitle: false,
480
+ },
481
+ render: (text: any) => (
482
+ <Tooltip placement="topLeft" title={text}>
483
+ {text}
484
+ </Tooltip>
485
+ ),
486
+ dataIndex: 'name',
487
+ },
488
+ {
489
+ title: '图片',
490
+ dataIndex: 'itemUrl',
491
+ width: 200,
492
+ ellipsis: {
493
+ showTitle: false,
494
+ },
495
+ render: (text: any,record: any) => (
496
+ <Tooltip placement="topLeft" title={text}>
497
+ {tableColumnsImage(getSkuImg(record),{ width: 28, height: 28 })}
498
+ </Tooltip>
499
+ ),
500
+ },
501
+ {
502
+ title: '单位',
503
+ dataIndex: 'selectUnitCode',
504
+ width: 100,
505
+ render: (text: any, record: any) => {
506
+ if (record?.packingUnitList?.length) {
507
+ const basePackUnit = record?.packingUnitList[0]
508
+ record.selectUnitCode = basePackUnit.unitCode
509
+ return basePackUnit.name || basePackUnit.unitCode
510
+ }
511
+
512
+
513
+ return <></>
514
+ },
515
+ },
516
+ {
517
+ title: '数量',
518
+ width: 100,
519
+ isInputItem: true,
520
+ dataIndex: 'count',
521
+ },
522
+ {
523
+ title: '所属SPU编码',
524
+ width: 100,
525
+ ellipsis: {
526
+ showTitle: false,
527
+ },
528
+ dataIndex: 'itemCode',
529
+ render: (text: any) => (
530
+ <Tooltip placement="topLeft" title={text}>
531
+ {text}
532
+ </Tooltip>
533
+ ),
534
+ },
535
+ {
536
+ title: '规格',
537
+ width: 200,
538
+ ellipsis: {
539
+ showTitle: false,
540
+ },
541
+ render: (text: any) => (
542
+ <Tooltip placement="topLeft" title={text}>
543
+ {text}
544
+ </Tooltip>
545
+ ),
546
+ dataIndex: 'propertyNameAndValue',
547
+ }
548
+ ]
549
+ const [isModalVisible, setIsModalVisible] = useState(false);
550
+ const [data, setData] = useState([{ hovered: false }]);
551
+ const tableRef = useRef(null)
552
+ const codeSelected = tableCode;
553
+
554
+ const [loading, setLoading] = useState(false);
555
+ const [selectColumns, setSelectColumns] = useState([]);
556
+ const [showColumns, setShowColumns] = useState([]);
557
+
558
+ useEffect(() => {
559
+ setSelectColumns([...columns.map(item => {
560
+ const inputLength = columns.filter(item => item.isInputItem || item.isSelectItem).length
561
+ const currentIndex = inputIndex
562
+ if (item.isInputItem) {
563
+ inputIndex++;
564
+ return {
565
+ ...item,
566
+ render: (text, record, index) => {
567
+ return (
568
+ <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} />
569
+ );
570
+ },
571
+ }
572
+ } else if (item.isSelectItem) {
573
+ inputIndex++;
574
+ }
575
+
576
+ return item
577
+ }), {
578
+ title: '操作',
579
+ width: 50,
580
+ render: (text, record, index) => {
581
+ if (index !== 0) {
582
+ return (
583
+ <span style={{ cursor: 'pointer', color: '#005CFF' }} onClick={() => {
584
+ deleteRecord(record)
585
+ }}>删除</span>
586
+ )
587
+ }
588
+ }
589
+ }])
590
+ },[data])
591
+
592
+ useEffect(() => {
593
+ setInitialShowColumn(codeSelected,selectColumns,(res) => {
594
+ console.log(res,'---res')
595
+ setShowColumnsCallback(res)
596
+ })
597
+ },[selectColumns])
598
+
599
+ const callSelectItem = (index, item) => {
600
+ if (item) {
601
+ let newData = [].concat(data)
602
+ newData[index] = { ...data[index], ...item }
603
+ setData(newData)
604
+ }
605
+ let dom = tableRef?.current?.getElementsByTagName('tbody')[0].getElementsByTagName('tr')[index + 1]
606
+ if (dom) {
607
+ setTimeout(() => {
608
+ dom.getElementsByTagName('input')[item ? 1 : 0]?.select()
609
+ dom.getElementsByTagName('input')[item ? 1 : 0]?.focus()
610
+ }, 200)
611
+ }
612
+ }
613
+
614
+ const deleteRecord = (record) => {
615
+ setData(data.filter(item => item.skuCode !== record.skuCode))
616
+ }
617
+
618
+ let inputIndex = 0;
619
+
620
+ const isSkuCanEntry = (resultData) => {
621
+ // 处理业务参数
622
+ let otherParams={}
623
+ if(isBrandAuth){
624
+ otherParams = { brandAuth: 'ctl-withAuth' }
625
+ }
626
+ return axios
627
+ .post(validDataUrl, {
628
+ ...otherParams,
629
+ columns: ["skuCode", "quantity"],
630
+ data: resultData.map((i:any) => ({ skuCode: i.skuCode, quality: i.count })),
631
+ checkStockNum: isCheckStockNum,
632
+ })
633
+ .then((result) => {
634
+ result = result.data;
635
+ if (result.status !== '0') {
636
+ message.error(result.msg);
637
+ return { flag: false }
638
+ } else {
639
+ let res = result.data || [];
640
+ const errorList = res.filter((i: any) => !i.flag);
641
+ return { flag: !errorList?.length, errorList }
642
+ }
643
+ }).catch(() => {
644
+ return { flag:false }
645
+ })
646
+ }
647
+
648
+ const handleSubmit = async () => {
649
+ // 加校验逻辑
650
+ if (!data?.length) {
651
+ message.warning('至少录入一条数据');
652
+ return;
653
+ }
654
+ if (!data?.every((d: any) => d.skuCode && d.name)) {
655
+ message.warning('请选择商品!');
656
+ return;
657
+ }
658
+ if (!data?.every((d: any) => d.count)) {
659
+ message.warning('请填写商品数量!');
660
+ return;
661
+ }
662
+ const canEntryObject = await isSkuCanEntry(data)
663
+ if(canEntryObject?.flag === false) {
664
+ const messageInfo = canEntryObject?.errorList?.length && canEntryObject?.errorList.map((i: any) => <div>{i.skuCode}校验失败:{i.checkResults}</div>)
665
+ messageInfo && message.warning({ content: messageInfo, duration: 6 });
666
+ return;
667
+ }
668
+
669
+ setLoading(true)
670
+ onSaveCallback(data).then(res => {
671
+ if(true) {
672
+ let initSuccessMessage = '保存成功'
673
+ const rmsbi = res?.messageSuccessBackInfo || {};
674
+ if(rmsbi && Object.keys(rmsbi)?.length){
675
+ rmsbi?.needThrowSuccess ? message.success(rmsbi?.successMessage || initSuccessMessage) : null
676
+ } else {
677
+ message.success(initSuccessMessage)
678
+ }
679
+ }
680
+ setLoading(false)
681
+ }).catch(Error => {
682
+ message.error(Error);
683
+ setLoading(false)
684
+ })
685
+ }
686
+
687
+ const setShowColumnsCallback = (newColumns: Array<any>) => {
688
+ setShowColumns([...newColumns])
689
+ }
690
+
691
+ const handleResize = (arr,index: any, callback) => (_: any, { size }: any) => {
692
+ let newColumns = arr.map((col: any) => ({ ...col }));
693
+ const handleIndex = (arr: any, indexArr: any) => {
694
+ let i = indexArr.shift();
695
+ if (indexArr.length > 0) {
696
+ handleIndex(arr[i].children, indexArr);
697
+ } else {
698
+ arr[i] = {
699
+ ...arr[i],
700
+ width: size.width,
701
+ };
702
+ handleAntdColumnsSpecialParams(arr[i]);
703
+ }
704
+ };
705
+ handleIndex(newColumns, [...index]);
706
+ callback(newColumns)
707
+ };
708
+
709
+ const handleColumns = (arr: any, indexArr: any[], callback: any) => {
710
+ arr.forEach((item: any, index: any) => {
711
+ let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
712
+ if (noEmptyArray(item.children)) {
713
+ handleColumns(item.children, indexArrInside);
714
+ } else {
715
+ item.width = item.width || getItemDefaultWidth(item);
716
+ item.onHeaderCell = (column: any) => ({
717
+ ...item,
718
+ width:
719
+ typeof column.width === 'number'
720
+ ? column.width
721
+ : parseInt(column.width.replace('px', '')),
722
+ onResize: handleResize(arr,indexArrInside, callback),
723
+ });
724
+ }
725
+ })
726
+ };
727
+ let showSelectedCol = showColumns.map((item: any) => {
728
+ handleAntdColumnsSpecialParams(item);
729
+ return ({ ...item })
730
+ })
731
+ handleColumns(showSelectedCol, [],(res)=> setShowColumnsCallback(res));
732
+
733
+ return (
734
+ <div className='add_select'>
735
+ <div className='add_select_quick_header'>
736
+ <div className='add_select_quick_header_title'><div>快速录入</div><Button type="primary" onClick={() => handleSubmit()} loading={loading}>提交</Button></div>
737
+ <span><span>*</span> &nbsp;快捷键:【Tab】-跳格切换;【Shift+←、→】-当前行左、右移动;【 ↑、↓】-当前列上、下移动;【ctrl+Delete】-删除当前行;</span>
738
+ <span style={{ marginRight: 8, float: 'right' }}>
739
+ <TableColumnSetting
740
+ setShowColumns={setShowColumnsCallback}
741
+ showColumns={showColumns}
742
+ datasource={selectColumns || []}
743
+ tableCode={codeSelected}
744
+ settingImgAttribute={{ width: 24, style: { marginTop: 2 } }}
745
+ />
746
+ </span>
747
+ </div>
748
+ <div className={'add_select_wrapper_select add_select_wrapper_select_quick'}>
749
+ <Table
750
+ size='small'
751
+ scroll={{ y: 240 }}
752
+ ref={tableRef}
753
+ dataSource={data}
754
+ columns={showSelectedCol}
755
+ pagination={false}
756
+ rowClassName={'row-class'}
757
+ rowClassName={(record: object | null | undefined, index: number) =>
758
+ index % 2 === 0 ? 'table_base row-class' : 'table_odd row-class'
759
+ }
760
+ components={{
761
+ header: {
762
+ cell: ResizeableTitle,
763
+ },
764
+ }}
765
+ />
766
+ </div>
767
+
768
+ </div>
769
+ );
770
+ };
771
+
772
+ export default BillEntry;