@bit-sun/business-component 2.3.22-beta9 → 2.3.23-beta01

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