@bit-sun/business-component 2.3.21 → 2.3.22

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 (270) 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/docs/index.md +21 -21
  9. package/lib/assets/drag.svg +17 -17
  10. package/lib/assets/exportFail.svg +37 -37
  11. package/lib/assets/exportProcessing.svg +28 -28
  12. package/lib/assets/exportSuccess.svg +34 -34
  13. package/lib/assets/label_icon_bottom.svg +25 -25
  14. package/lib/assets/upExport.svg +22 -22
  15. package/package.json +78 -78
  16. package/src/assets/32.svg +27 -27
  17. package/src/assets/addIcon.svg +17 -17
  18. package/src/assets/allfunc.svg +27 -27
  19. package/src/assets/arrowRight.svg +24 -24
  20. package/src/assets/btn-delete.svg +29 -29
  21. package/src/assets/btn-edit.svg +19 -19
  22. package/src/assets/btn-more.svg +17 -17
  23. package/src/assets/btn-submit.svg +19 -19
  24. package/src/assets/caidan.svg +11 -11
  25. package/src/assets/close.svg +26 -26
  26. package/src/assets/drag.svg +17 -17
  27. package/src/assets/exportFail.svg +37 -37
  28. package/src/assets/exportProcessing.svg +28 -28
  29. package/src/assets/exportSuccess.svg +34 -34
  30. package/src/assets/fixed-left-active.svg +11 -11
  31. package/src/assets/fixed-left.svg +15 -15
  32. package/src/assets/fixed-right-active.svg +11 -11
  33. package/src/assets/fixed-right.svg +15 -15
  34. package/src/assets/guanbi.svg +15 -15
  35. package/src/assets/icon-quanping.svg +15 -15
  36. package/src/assets/icon-shezhi.svg +17 -17
  37. package/src/assets/label_icon_bottom.svg +25 -25
  38. package/src/assets/list-no-img.svg +21 -21
  39. package/src/assets/morentouxiang-32.svg +23 -23
  40. package/src/assets/scanning.svg +24 -24
  41. package/src/assets/upExport.svg +22 -22
  42. package/src/common/ENUM.ts +41 -41
  43. package/src/components/Business/AddSelectBusiness/index.md +162 -162
  44. package/src/components/Business/AddSelectBusiness/index.tsx +1060 -895
  45. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  46. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  47. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  48. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  49. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  50. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  51. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  57. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  58. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  59. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  60. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  61. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  62. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  63. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  64. package/src/components/Business/BsLayouts/index.less +79 -79
  65. package/src/components/Business/BsLayouts/index.tsx +1484 -1484
  66. package/src/components/Business/BsLayouts/service.ts +10 -10
  67. package/src/components/Business/BsLayouts/utils.tsx +203 -203
  68. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +564 -564
  69. package/src/components/Business/BsSulaQueryTable/index.less +221 -221
  70. package/src/components/Business/BsSulaQueryTable/index.tsx +535 -535
  71. package/src/components/Business/BsSulaQueryTable/setting.tsx +852 -852
  72. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  73. package/src/components/Business/BsSulaQueryTable/utils.tsx +690 -690
  74. package/src/components/Business/CommodityEntry/index.md +70 -70
  75. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  76. package/src/components/Business/CommonAlert/index.tsx +23 -23
  77. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  78. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  79. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  80. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  81. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  82. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  83. package/src/components/Business/HomePageWrapper/index.less +33 -33
  84. package/src/components/Business/HomePageWrapper/index.md +45 -45
  85. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  86. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  87. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +205 -205
  88. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  89. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  90. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  91. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  92. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  93. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  94. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  95. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  96. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  97. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  98. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  99. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  100. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  101. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  102. package/src/components/Business/JsonQueryTable/index.less +16 -16
  103. package/src/components/Business/JsonQueryTable/index.md +328 -328
  104. package/src/components/Business/JsonQueryTable/index.tsx +535 -535
  105. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  106. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  107. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  108. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  109. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  110. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  111. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  112. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  113. package/src/components/Business/JsonQueryTable/static.ts +390 -390
  114. package/src/components/Business/SearchSelect/BusinessUtils.ts +1762 -1762
  115. package/src/components/Business/SearchSelect/common.ts +75 -75
  116. package/src/components/Business/SearchSelect/index.md +1329 -1329
  117. package/src/components/Business/SearchSelect/index.tsx +55 -55
  118. package/src/components/Business/SearchSelect/utils.ts +100 -100
  119. package/src/components/Business/StateFlow/index.less +130 -130
  120. package/src/components/Business/StateFlow/index.md +60 -60
  121. package/src/components/Business/StateFlow/index.tsx +29 -29
  122. package/src/components/Business/TreeSearchSelect/index.md +156 -156
  123. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  124. package/src/components/Business/TreeSearchSelect/utils.ts +75 -75
  125. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  126. package/src/components/Business/columnSettingTable/index.less +247 -247
  127. package/src/components/Business/columnSettingTable/index.md +357 -357
  128. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  129. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  130. package/src/components/Business/columnSettingTable/utils.tsx +71 -71
  131. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -87
  132. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  133. package/src/components/Business/moreTreeTable/index.less +99 -99
  134. package/src/components/Business/moreTreeTable/index.md +448 -448
  135. package/src/components/Business/moreTreeTable/index.tsx +387 -387
  136. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  137. package/src/components/Functional/AddSelect/helps.ts +79 -14
  138. package/src/components/Functional/AddSelect/index.less +367 -367
  139. package/src/components/Functional/AddSelect/index.md +155 -155
  140. package/src/components/Functional/AddSelect/index.tsx +1170 -1282
  141. package/src/components/Functional/BillEntry/index.less +371 -371
  142. package/src/components/Functional/BillEntry/index.md +39 -39
  143. package/src/components/Functional/BillEntry/index.tsx +772 -772
  144. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  145. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  146. package/src/components/Functional/BsAntdSula/index.ts +2 -2
  147. package/src/components/Functional/DataImport/index.less +63 -63
  148. package/src/components/Functional/DataImport/index.md +44 -44
  149. package/src/components/Functional/DataImport/index.tsx +695 -695
  150. package/src/components/Functional/DataValidation/index.less +63 -63
  151. package/src/components/Functional/DataValidation/index.md +39 -39
  152. package/src/components/Functional/DataValidation/index.tsx +687 -687
  153. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -5
  154. package/src/components/Functional/EllipsisTooltip/index.js +36 -36
  155. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  156. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  157. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  158. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  159. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  160. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  161. package/src/components/Functional/SearchSelect/index.less +115 -115
  162. package/src/components/Functional/SearchSelect/index.md +141 -141
  163. package/src/components/Functional/SearchSelect/index.tsx +879 -879
  164. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  165. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  166. package/src/components/Functional/TreeSearchSelect/index.tsx +199 -199
  167. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  168. package/src/components/Solution/RuleComponent/index.d.ts +29 -29
  169. package/src/components/Solution/RuleComponent/index.js +2032 -2032
  170. package/src/components/Solution/RuleComponent/index.less +230 -230
  171. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  172. package/src/components/Solution/RuleComponent/ruleFiled.js +2107 -2107
  173. package/src/components/Solution/RuleComponent/services.ts +13 -13
  174. package/src/components/Solution/RuleComponent/util.js +139 -139
  175. package/src/index.ts +38 -38
  176. package/src/plugin/TableColumnSetting/index.less +247 -247
  177. package/src/plugin/TableColumnSetting/index.md +50 -50
  178. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  179. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  180. package/src/styles/bsDefault.less +1912 -1912
  181. package/src/utils/CheckOneUser/index.md +39 -39
  182. package/src/utils/CheckOneUser/index.ts +51 -51
  183. package/src/utils/LocalstorageUtils.ts +95 -95
  184. package/src/utils/TableUtils.tsx +18 -18
  185. package/src/utils/checkUtils.ts +39 -39
  186. package/src/utils/enumConfig.ts +11 -11
  187. package/src/utils/getFormMode.js +12 -12
  188. package/src/utils/index.ts +4 -4
  189. package/src/utils/requestUtils.ts +34 -34
  190. package/src/utils/serialize.js +7 -7
  191. package/src/utils/utils.ts +212 -212
  192. package/tsconfig.json +29 -29
  193. package/typings.d.ts +4 -4
  194. package/dist/common/ENUM.d.ts +0 -40
  195. package/dist/components/Business/AddSelectBusiness/index.d.ts +0 -3
  196. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +0 -4
  197. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +0 -4
  198. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +0 -4
  199. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +0 -17
  200. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +0 -30
  201. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +0 -3
  202. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +0 -2
  203. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +0 -4
  204. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +0 -4
  205. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +0 -2
  206. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +0 -8
  207. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +0 -8
  208. package/dist/components/Business/BsLayouts/index.d.ts +0 -18
  209. package/dist/components/Business/BsLayouts/service.d.ts +0 -1
  210. package/dist/components/Business/BsLayouts/utils.d.ts +0 -10
  211. package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +0 -60
  212. package/dist/components/Business/BsSulaQueryTable/index.d.ts +0 -2
  213. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +0 -60
  214. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +0 -98
  215. package/dist/components/Business/CommodityEntry/index.d.ts +0 -2
  216. package/dist/components/Business/CommonAlert/index.d.ts +0 -3
  217. package/dist/components/Business/CommonGuideWrapper/index.d.ts +0 -6
  218. package/dist/components/Business/DetailPageWrapper/index.d.ts +0 -9
  219. package/dist/components/Business/DetailPageWrapper/utils.d.ts +0 -8
  220. package/dist/components/Business/HomePageWrapper/index.d.ts +0 -3
  221. package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +0 -2
  222. package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +0 -2
  223. package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +0 -6
  224. package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +0 -2
  225. package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +0 -2
  226. package/dist/components/Business/JsonQueryTable/function.d.ts +0 -37
  227. package/dist/components/Business/JsonQueryTable/index.d.ts +0 -4
  228. package/dist/components/Business/JsonQueryTable/static.d.ts +0 -41
  229. package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +0 -5
  230. package/dist/components/Business/SearchSelect/common.d.ts +0 -25
  231. package/dist/components/Business/SearchSelect/index.d.ts +0 -3
  232. package/dist/components/Business/SearchSelect/utils.d.ts +0 -5
  233. package/dist/components/Business/StateFlow/index.d.ts +0 -3
  234. package/dist/components/Business/TreeSearchSelect/index.d.ts +0 -3
  235. package/dist/components/Business/TreeSearchSelect/utils.d.ts +0 -4
  236. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +0 -54
  237. package/dist/components/Business/columnSettingTable/index.d.ts +0 -16
  238. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +0 -17
  239. package/dist/components/Business/columnSettingTable/utils.d.ts +0 -8
  240. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +0 -3
  241. package/dist/components/Business/moreTreeTable/hooks/useSticky.d.ts +0 -8
  242. package/dist/components/Business/moreTreeTable/index.d.ts +0 -4
  243. package/dist/components/Business/moreTreeTable/utils.d.ts +0 -9
  244. package/dist/components/Functional/AddSelect/helps.d.ts +0 -1
  245. package/dist/components/Functional/AddSelect/index.d.ts +0 -3
  246. package/dist/components/Functional/BillEntry/index.d.ts +0 -4
  247. package/dist/components/Functional/BsAntdSula/BsCascader/index.d.ts +0 -18
  248. package/dist/components/Functional/BsAntdSula/index.d.ts +0 -1
  249. package/dist/components/Functional/DataImport/index.d.ts +0 -144
  250. package/dist/components/Functional/DataValidation/index.d.ts +0 -144
  251. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +0 -12
  252. package/dist/components/Functional/QueryMutipleInput/index.d.ts +0 -5
  253. package/dist/components/Functional/SearchSelect/index.d.ts +0 -4
  254. package/dist/components/Functional/SearchSelect/utils.d.ts +0 -1
  255. package/dist/components/Functional/TreeSearchSelect/index.d.ts +0 -2
  256. package/dist/components/Solution/RuleComponent/Formula.d.ts +0 -8
  257. package/dist/components/Solution/RuleComponent/services.d.ts +0 -1
  258. package/dist/index.d.ts +0 -28
  259. package/dist/index.esm.js +0 -30692
  260. package/dist/index.js +0 -30739
  261. package/dist/plugin/TableColumnSetting/index.d.ts +0 -64
  262. package/dist/plugin/TableColumnSetting/utils.d.ts +0 -1
  263. package/dist/utils/CheckOneUser/index.d.ts +0 -2
  264. package/dist/utils/LocalstorageUtils.d.ts +0 -17
  265. package/dist/utils/TableUtils.d.ts +0 -11
  266. package/dist/utils/checkUtils.d.ts +0 -3
  267. package/dist/utils/enumConfig.d.ts +0 -12
  268. package/dist/utils/index.d.ts +0 -4
  269. package/dist/utils/requestUtils.d.ts +0 -1
  270. package/dist/utils/utils.d.ts +0 -23
@@ -1,695 +1,695 @@
1
- /*
2
- * @Description:
3
- * @Author: rodchen
4
- * @Date: 2021-12-01 10:52:08
5
- * @LastEditTime: 2021-12-29 17:11:56
6
- * @LastEditors: rodchen
7
- */
8
- // @ts-nocheck
9
- import React from 'react';
10
- import {
11
- Button,
12
- Card,
13
- Radio,
14
- Checkbox,
15
- Space,
16
- Dropdown,
17
- Menu,
18
- Tooltip,
19
- message,
20
- } from 'antd';
21
- import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
22
- import {
23
- ExclamationCircleOutlined,
24
- DownOutlined,
25
- ProfileTwoTone,
26
- UnorderedListOutlined,
27
- } from '@ant-design/icons';
28
- import axios from 'axios';
29
- import './index.less';
30
- import _ from "lodash"
31
-
32
- // const luckysheet = window.luckysheet;
33
-
34
- let itemsTemp = [];
35
- let luckysheet;
36
-
37
- // const mapping = [
38
- // { "key": "skuCode", "name": "SKU编码", "rule": "skuCode" },
39
- // { "key": "quantity", "name": "数量", "rule": "quantity" },
40
- // { "key": "price", "name": "单价", "rule": "price" }
41
- // ]
42
-
43
- const mapping = new Map([
44
- ['skuCode', 'SKU编码'],
45
- ['quantity', '数量'],
46
- ['price', '单价'],
47
- ['regionCode', '库区'],
48
- ['checkQuantity', '实盘数量'],
49
- ['shareRatio', '共享比例'],
50
- ['lotNumberCode', '批号'],
51
- ['warehouseCode', '仓库编码'],
52
- ['regionCode', '库区'],
53
- ['locationCode', '货位'],
54
- ['rowNumber', '货位排数'],
55
- ['layerNumber', '货位层数'],
56
- ['gridNumber', '货位格号'],
57
- ['oldUniqueCode', '原始唯一码'],
58
- ['newUniqueCode', '新唯一码'],
59
- ['relationRecordCode', '单据编码'],
60
- ['remark', '备注'],
61
- ['externalCode', 'JDE商品编码'],
62
- ['realWarehouseCode', '仓库编码'],
63
- ['syncRate', '按百分比'],
64
- ['assignQuantity', '按指定数量'],
65
- ['retainQuantity', ' 按保留数量'],
66
- ['priority', ' 优先级'],
67
- ]);
68
-
69
- // for dnd
70
- // fake data generator
71
- const getItems = (count) =>
72
- Array.from({ length: count }, (v, k) => k).map((k) => ({
73
- id: `item-${k}`,
74
- content: `item ${k}`,
75
- }));
76
-
77
- // a little function to help us with reordering the result
78
- const reorder = (list, startIndex, endIndex) => {
79
- const result = Array.from(list);
80
- const [removed] = result.splice(startIndex, 1);
81
- result.splice(endIndex, 0, removed);
82
-
83
- return result;
84
- };
85
-
86
- const grid = 8;
87
-
88
- const getItemStyle = (isDragging, draggableStyle) => ({
89
- // some basic styles to make the items look a bit nicer
90
- userSelect: 'none',
91
- padding: `4px`,
92
- margin: `4px`,
93
- // change background colour if dragging
94
-
95
- // styles we need to apply on draggables
96
- ...draggableStyle,
97
- });
98
-
99
- const getListStyle = (isDraggingOver) => ({
100
- background: isDraggingOver ? '#fff' : '#fff',
101
- display: 'flex',
102
- padding: grid,
103
- overflow: 'auto',
104
- });
105
-
106
- const filterLetters = (i) => {
107
- if (i >= 0 && i <= 25) {
108
- return String.fromCharCode(65 + i);
109
- } else {
110
- return undefined;
111
- }
112
- };
113
-
114
- class DataImport extends React.Component {
115
- constructor(props) {
116
- super(props);
117
- this.props.onRef(this);
118
-
119
- if (props.customerColumnsMapping) {
120
- itemsTemp = props.customerColumnsMapping.map((item, index) => {
121
- return {
122
- id: `item-0${index}`,
123
- content: item.title,
124
- code: item.name,
125
- "ct": { //单元格值格式
126
- "fa": "General", //格式名称为自动格式
127
- "t": "s" //格式类型为数字类型
128
- }
129
- };
130
- })
131
- } else {
132
- itemsTemp = props.columns.map((item, index) => {
133
- if (!mapping.get(item))
134
- throw Error(
135
- `${item} is not in DataImport component, please fix this error`,
136
- );
137
- return {
138
- id: `item-0${index}`,
139
- content: mapping.get(item),
140
- code: item,
141
- "ct": { //单元格值格式
142
- "fa": "General", //格式名称为自动格式
143
- "t": "s" //格式类型为数字类型
144
- }
145
- };
146
- });
147
- }
148
- luckysheet = window.luckysheet || window.top.luckysheet;
149
- this.state = {
150
- showErrorData: false,
151
- data: [],
152
- items: [...itemsTemp],
153
- resultData: [],
154
- errorListCheck: false,
155
- };
156
- }
157
-
158
- onDragEnd(result) {
159
- // dropped outside the list
160
- if (!result.destination) {
161
- return;
162
- }
163
-
164
- const items = reorder(
165
- this.state.items,
166
- result.source.index,
167
- result.destination.index,
168
- );
169
-
170
- this.setState({
171
- items,
172
- });
173
-
174
- itemsTemp = items;
175
-
176
- luckysheet.refresh();
177
- }
178
-
179
- getCount = () => {
180
- const { resultData } = this.state;
181
- return {
182
- total: resultData.length,
183
- error: resultData.filter((item) => !item.flag).length,
184
- };
185
- };
186
-
187
- setConfig = (data) => {
188
- const { items } = this.state;
189
- const { notValid } = this.props;
190
- return {
191
- container: 'luckysheet',
192
- showtoolbar: false,
193
- hook: {
194
- columnTitleCellRenderBefore: function (columnAbc, postion, ctx) {
195
- if (columnAbc.name) {
196
- let charCode = columnAbc.name.charCodeAt();
197
- if (charCode - 65 <= items.length) {
198
- columnAbc.name = itemsTemp[charCode - 65]
199
- ? itemsTemp[charCode - 65].content
200
- : (!notValid ? '校验结果' : '');
201
- } else {
202
- columnAbc.name = '';
203
- }
204
- }
205
- },
206
- cellRenderBefore: function (cell, postion, sheetFile, ctx) {
207
- if (cell) {
208
- cell.fs = 10;
209
-
210
-
211
- if (typeof cell.v === 'string') {
212
- cell.m = cell.v = cell.m.trim();
213
- }
214
- if (cell && cell.m && cell.m.indexOf('E+') !== -1) {
215
- cell.v = cell.v.toString()
216
- cell.m = cell.v
217
- }
218
- if (typeof cell.v === 'number') {
219
- cell.v = cell.m
220
- }
221
- }
222
- // console.log(postion);
223
- },
224
- cellAllRenderBefore: function (data, sheetFile, ctx) {
225
- sheetFile.config.borderInfo = [];
226
- // console.info(data,sheetFile,ctx)
227
- },
228
- },
229
- // showtoolbarConfig: {
230
- // undoRedo: true, //撤销重做,注意撤消重做是两个按钮,由这一个配置决定显示还是隐藏
231
- // paintFormat: false, //格式刷
232
- // currencyFormat: false, //货币格式
233
- // percentageFormat: false, //百分比格式
234
- // numberDecrease: false, // '减少小数位数'
235
- // numberIncrease: false, // '增加小数位数
236
- // moreFormats: false, // '更多格式'
237
- // font: true, // '字体'
238
- // fontSize: true, // '字号大小'
239
-
240
- // },
241
- data: [
242
- {
243
- name: 'Cell', //工作表名称
244
- color: '', //工作表颜色
245
- index: 0, //工作表索引
246
- status: 1, //激活状态
247
- order: 0, //工作表的下标
248
- hide: 0, //是否隐藏
249
- row: 36, //行数
250
- column: 18, //列数
251
- defaultRowHeight: 20, //自定义行高
252
- defaultColWidth: 120, //自定义列宽
253
- config: {},
254
- // celldata:
255
- // data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
256
- // "r": b,
257
- // "c": d,
258
- // "v": { "ct": { "fa": "@", "t": "s" }, }
259
- // }))))
260
- // ,
261
- celldata:
262
- data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
263
- "r": b,
264
- "c": d,
265
- "v": { "ct": { "fa": "@", "t": "s" }, }
266
- }))))
267
- ,
268
- scrollLeft: 0, //左右滚动条位置
269
- // "scrollTop": 315, //上下滚动条位置
270
- luckysheet_select_save: [], //选中的区域
271
- calcChain: [], //公式链
272
- isPivotTable: false, //是否数据透视表
273
- pivotTable: {}, //数据透视表设置
274
- filter_select: {}, //筛选范围
275
- filter: null, //筛选配置
276
- luckysheet_alternateformat_save: [], //交替颜色
277
- luckysheet_alternateformat_save_modelCustom: [], //自定义交替颜色
278
- luckysheet_conditionformat_save: {}, //条件格式
279
- frozen: {}, //冻结行列配置
280
- chart: [], //图表配置
281
- zoomRatio: 1, // 缩放比例
282
- image: [], //图片
283
- showGridLines: 1, //是否显示网格线
284
- dataVerification: {}, //数据验证配置
285
- luckysheet_alternateformat_save: [
286
- {
287
- cellrange: {
288
- //单元格范围
289
- row: [0, 1000],
290
- column: [0, 18],
291
- },
292
- format: {
293
- head: {
294
- //页眉颜色
295
- fc: '#6aa84f',
296
- bc: '#ffffff',
297
- },
298
- one: {
299
- //第一种颜色
300
- bc: '#ffffff',
301
- },
302
- two: {
303
- //第二种颜色
304
- bc: '#f2f4f5',
305
- },
306
- foot: {
307
- //页脚颜色
308
- fc: '#000',
309
- bc: '#a5efcc',
310
- },
311
- },
312
- hasRowHeader: false, //含有页眉
313
- hasRowFooter: false, //含有页脚
314
- },
315
- ], //交替颜色
316
- luckysheet_alternateformat_save_modelCustom: [
317
- {
318
- head: {
319
- //页眉颜色
320
- fc: '#6aa84f',
321
- bc: '#ffffff',
322
- },
323
- one: {
324
- //第一种颜色
325
- fc: '#000',
326
- bc: '#ffffff',
327
- },
328
- two: {
329
- //第二种颜色
330
- fc: '#000',
331
- bc: '#e5fbee',
332
- },
333
- foot: {
334
- //页脚颜色
335
- fc: '#000',
336
- bc: '#a5efcc',
337
- },
338
- },
339
- ], //自定义交替颜色
340
- },
341
- ],
342
- cellRightClickConfig: {
343
- copy: false, // 复制
344
- copyAs: false, // 复制为
345
- paste: false, // 粘贴
346
- insertRow: false, // 插入行
347
- insertColumn: false, // 插入列
348
- // deleteRow: false, // 删除选中行
349
- // deleteColumn: false, // 删除选中列
350
- deleteCell: false, // 删除单元格
351
- hideRow: false, // 隐藏选中行和显示选中行
352
- hideColumn: false, // 隐藏选中列和显示选中列
353
- rowHeight: false, // 行高
354
- columnWidth: false, // 列宽
355
- clear: false, // 清除内容
356
- matrix: false, // 矩阵操作选区
357
- sort: false, // 排序选区
358
- filter: false, // 筛选选区
359
- chart: false, // 图表生成
360
- image: false, // 插入图片
361
- link: false, // 插入链接
362
- data: false, // 数据验证
363
- cellFormat: false, // 设置单元格格式
364
- },
365
- showsheetbar: false,
366
- optionstate: false,
367
- showstatisticBarConfig: {
368
- count: false, // 计数栏
369
- view: false, // 打印视图
370
- zoom: false, // 缩放
371
- },
372
- column: 10, //列数
373
- columnHeaderHeight: 30,
374
- lang: 'zh',
375
- defaultFontSize: '10',
376
- frozen: {
377
- type: 'rangeBoth',
378
- range: { row_focus: 1, column_focus: 1 },
379
- },
380
- };
381
- };
382
-
383
- componentDidMount() {
384
- luckysheet.create(this.setConfig([]));
385
- }
386
-
387
- componentWillUnmount() {
388
- // luckysheet.create(this.setConfig([]));
389
- luckysheet.destroy();
390
- }
391
-
392
- getValidateData = () => {
393
- const { resultData } = this.state;
394
-
395
- return {
396
- successData: resultData
397
- .filter((item) => item.flag)
398
- .map(({ flag, checkResults, ...item }) => item),
399
- failData: resultData
400
- .filter((item) => !item.flag)
401
- .map(({ flag, checkResults, ...item }) => item),
402
- };
403
- };
404
-
405
- getData = () => {
406
- console.time();
407
- let sheetData = luckysheet.getSheetData();
408
- let data = JSON.parse(JSON.stringify(sheetData))
409
- .filter((item) => {
410
- return item[0]
411
- })
412
- .map((item) => {
413
- let obj = {};
414
-
415
- item.slice(0, itemsTemp.length).map((innerItem, index) => {
416
- obj[this.state.items[index].code] = innerItem && (innerItem.v === innerItem.m ? innerItem.m : innerItem.v);
417
- });
418
-
419
- return obj;
420
- });
421
-
422
- return data.filter(item => item[this.props.customerColumnsMapping[0].name]);
423
- };
424
-
425
- resetData = () => {
426
- const { validDataUrl, updateData, columns } = this.props;
427
- const resultData = this.getData().filter(d => {
428
- return _.compact(Object.values(d)).length
429
- })
430
-
431
- axios
432
- .post(validDataUrl, {
433
- columns: columns,
434
- data: resultData,
435
- })
436
- .then((result) => {
437
- result = result.data;
438
- if (result.status !== '0') {
439
- message.error(result.msg);
440
- return;
441
- }
442
- const { items } = this.state;
443
- let validIndex = items.length;
444
- let res = result.data;
445
-
446
- let sheetData = luckysheet.getSheetData();
447
-
448
- sheetData.map((item, index) => {
449
- if (!res[index]) return item;
450
-
451
- const changeVMIndex = this.props.columns.findIndex(i => i === 'skuCode');
452
- if(this.props.columns.find(i => i === 'skuCode') && item[changeVMIndex].v !== res[index].skuCode) {
453
- item[changeVMIndex].v = res[index].skuCode;
454
- item[changeVMIndex].m = res[index].skuCode;
455
- }
456
-
457
- if (res[index].flag) {
458
- item[validIndex] = {
459
- ...item[validIndex],
460
- v: '通过',
461
- m: '通过',
462
- fc: 'green', //字体颜色为 "#990000"
463
- };
464
- } else {
465
- item[validIndex] = {
466
- ...item[validIndex],
467
- v: res[index].checkResults,
468
- m: res[index].checkResults,
469
- fc: 'red', //字体颜色为 "#990000"
470
- };
471
- }
472
-
473
- item[validIndex].ct = { fa: 'General', t: 'g' };
474
- });
475
- // sheetData.map((item, index) => {
476
- // luckysheet.setCellValue(index + 1, 4, 345)
477
- // })
478
-
479
- luckysheet.create(
480
- this.setConfig(luckysheet.transToCellData(sheetData)),
481
- );
482
- this.setState({
483
- data: luckysheet.transToCellData(sheetData),
484
- errorListCheck: false,
485
- resultData: res,
486
- });
487
-
488
- console.log(setExportData);
489
- setExportData([123123]);
490
- })
491
- .catch((err) => { });
492
- };
493
-
494
- filterData = (type: string) => {
495
- const { showErrorData, data, resultData } = this.state;
496
- let sheetData = luckysheet.transToData(data).filter((item, index) => {
497
- if (type === 'all') {
498
- return false;
499
- }
500
- if (type === 'error') {
501
- return item[itemsTemp.length] && item[itemsTemp.length].v === '通过';
502
- }
503
- });
504
-
505
- luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
506
- this.setState({
507
- data: luckysheet.transToCellData(sheetData),
508
- errorListCheck: false,
509
- resultData: type === 'all' ? [] : resultData.filter((item) => item.flag),
510
- });
511
- };
512
-
513
- toggleData = () => {
514
- const { showErrorData, data } = this.state;
515
-
516
- if (showErrorData) {
517
- luckysheet.create(this.setConfig(data));
518
- } else {
519
- let sheetData = luckysheet.getSheetData();
520
- sheetData = sheetData.filter((item, index) => {
521
- return !item[itemsTemp.length] || item[itemsTemp.length].v !== '通过';
522
- });
523
-
524
- luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
525
- }
526
-
527
- this.setState({
528
- showErrorData: !showErrorData,
529
- });
530
- };
531
-
532
- onChange = (e) => {
533
- this.setState({
534
- radioValue: e.target.value,
535
- });
536
- this.toggleData();
537
- };
538
-
539
- errorChange = (e: any) => {
540
- this.toggleData();
541
- this.setState({
542
- errorListCheck: e.target.checked,
543
- });
544
- };
545
-
546
- menuList = (
547
- <Menu>
548
- <Menu.Item key="1" className="sheet_table-menu_item_text">
549
- <a onClick={() => this.filterData('all')}>清空全部数据</a>
550
- </Menu.Item>
551
- <Menu.Divider />
552
- {!this.props.notValid && <Menu.Item key="2" className="sheet_table-menu_item_text">
553
- <a onClick={() => this.filterData('error')}>仅清空错误数据</a>
554
- </Menu.Item>}
555
- </Menu>
556
- );
557
-
558
- leftMenu = (
559
- <Menu>
560
- <Menu.Item key="3" className="sheet_table-menu_item_text">
561
- <span className="sheet_table_text">请拖动字段来对应列</span>
562
- </Menu.Item>
563
- <Menu.Divider />
564
- <div>
565
- <DragDropContext onDragEnd={(e) => this.onDragEnd(e)}>
566
- <Droppable droppableId="droppable" direction="vertical">
567
- {(provided, snapshot) => (
568
- <div
569
- ref={provided.innerRef}
570
- style={{
571
- ...getListStyle(snapshot.isDraggingOver),
572
- flexDirection: 'column',
573
- }}
574
- {...provided.droppableProps}
575
- >
576
- {this.state.items.map((item, index) => (
577
- <Draggable key={item.id} draggableId={item.id} index={index}>
578
- {(provided, snapshot) => (
579
- <div
580
- ref={provided.innerRef}
581
- {...provided.draggableProps}
582
- {...provided.dragHandleProps}
583
- style={getItemStyle(
584
- snapshot.isDragging,
585
- provided.draggableProps.style,
586
- )}
587
- >
588
- <Space>
589
- <span>{filterLetters(index)} 列 </span>
590
- <Space className="sheet_table_dnd_text">
591
- <UnorderedListOutlined />
592
- {item.content}
593
- </Space>
594
- </Space>
595
- </div>
596
- )}
597
- </Draggable>
598
- ))}
599
- {provided.placeholder}
600
- </div>
601
- )}
602
- </Droppable>
603
- </DragDropContext>
604
- </div>
605
- </Menu>
606
- );
607
-
608
- render() {
609
- const { errorListCheck } = this.state;
610
- const { title, notValid, customerColumnsMapping } = this.props;
611
-
612
- let totalSummary = this.getCount();
613
-
614
- const luckyCss = {
615
- margin: '0px',
616
- padding: '0px',
617
- position: 'absolute',
618
- width: '100%',
619
- height: '100%',
620
- left: '0px',
621
- top: '0px',
622
- };
623
- return (
624
- <>
625
- <div className="sheet_table_top">
626
- <Space>
627
- <span>排序列</span>
628
- <Dropdown
629
- trigger={['click']}
630
- overlay={this.leftMenu}
631
- placement="bottomLeft"
632
- >
633
- <a>
634
- <ProfileTwoTone />
635
- </a>
636
- </Dropdown>
637
- <Tooltip
638
- title={
639
- <>
640
- <span>使用指南:</span>
641
- <br></br>
642
- <span>
643
- 1、拖动数据项,以适配源数据的顺序,如您Excel中数据排序依次为编码、价格和数量,则您也可以将数据项的顺序调整为一致
644
- </span>
645
- <br></br>
646
- <span>2、复制文件数据(多列一起),在文本框内进行粘贴</span>
647
- <br></br>
648
- <span>
649
- 3、点击识别按钮进行数据校验,如全部正确,则点击录入按钮可录入数据,如存在错误数据,则需修改后再进行录入
650
- </span>
651
- </>
652
- }
653
- >
654
- <ExclamationCircleOutlined />
655
- </Tooltip>
656
- </Space>
657
- <Space>
658
- <Dropdown
659
- trigger={['click']}
660
- overlay={this.menuList}
661
- placement="bottomRight"
662
- >
663
- <Button>
664
- 清空
665
- <DownOutlined />
666
- </Button>
667
- </Dropdown>
668
-
669
- {!notValid && <Button type="primary" onClick={this.resetData}>
670
- 识别
671
- </Button>}
672
- </Space>
673
- </div>
674
-
675
- <div style={{ position: 'relative', height: '400px' }}>
676
- <div id="luckysheet" style={luckyCss}></div>
677
- </div>
678
- {!this.props.notValid && <div className="sheet_table_footer">
679
- <span className="sheet_table_footer_l">
680
- 共 {totalSummary.total} 条数据{!notValid && `, 其中错误 ${totalSummary.error} 项`}
681
- </span>
682
- {!notValid && <Space className="sheet_table_footer_r">
683
- <Checkbox
684
- checked={errorListCheck}
685
- onClick={this.errorChange}
686
- ></Checkbox>
687
- 仅展示错误数据
688
- </Space>}
689
- </div>}
690
- </>
691
- );
692
- }
693
- }
694
-
695
- export default DataImport;
1
+ /*
2
+ * @Description:
3
+ * @Author: rodchen
4
+ * @Date: 2021-12-01 10:52:08
5
+ * @LastEditTime: 2021-12-29 17:11:56
6
+ * @LastEditors: rodchen
7
+ */
8
+ // @ts-nocheck
9
+ import React from 'react';
10
+ import {
11
+ Button,
12
+ Card,
13
+ Radio,
14
+ Checkbox,
15
+ Space,
16
+ Dropdown,
17
+ Menu,
18
+ Tooltip,
19
+ message,
20
+ } from 'antd';
21
+ import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
22
+ import {
23
+ ExclamationCircleOutlined,
24
+ DownOutlined,
25
+ ProfileTwoTone,
26
+ UnorderedListOutlined,
27
+ } from '@ant-design/icons';
28
+ import axios from 'axios';
29
+ import './index.less';
30
+ import _ from "lodash"
31
+
32
+ // const luckysheet = window.luckysheet;
33
+
34
+ let itemsTemp = [];
35
+ let luckysheet;
36
+
37
+ // const mapping = [
38
+ // { "key": "skuCode", "name": "SKU编码", "rule": "skuCode" },
39
+ // { "key": "quantity", "name": "数量", "rule": "quantity" },
40
+ // { "key": "price", "name": "单价", "rule": "price" }
41
+ // ]
42
+
43
+ const mapping = new Map([
44
+ ['skuCode', 'SKU编码'],
45
+ ['quantity', '数量'],
46
+ ['price', '单价'],
47
+ ['regionCode', '库区'],
48
+ ['checkQuantity', '实盘数量'],
49
+ ['shareRatio', '共享比例'],
50
+ ['lotNumberCode', '批号'],
51
+ ['warehouseCode', '仓库编码'],
52
+ ['regionCode', '库区'],
53
+ ['locationCode', '货位'],
54
+ ['rowNumber', '货位排数'],
55
+ ['layerNumber', '货位层数'],
56
+ ['gridNumber', '货位格号'],
57
+ ['oldUniqueCode', '原始唯一码'],
58
+ ['newUniqueCode', '新唯一码'],
59
+ ['relationRecordCode', '单据编码'],
60
+ ['remark', '备注'],
61
+ ['externalCode', 'JDE商品编码'],
62
+ ['realWarehouseCode', '仓库编码'],
63
+ ['syncRate', '按百分比'],
64
+ ['assignQuantity', '按指定数量'],
65
+ ['retainQuantity', ' 按保留数量'],
66
+ ['priority', ' 优先级'],
67
+ ]);
68
+
69
+ // for dnd
70
+ // fake data generator
71
+ const getItems = (count) =>
72
+ Array.from({ length: count }, (v, k) => k).map((k) => ({
73
+ id: `item-${k}`,
74
+ content: `item ${k}`,
75
+ }));
76
+
77
+ // a little function to help us with reordering the result
78
+ const reorder = (list, startIndex, endIndex) => {
79
+ const result = Array.from(list);
80
+ const [removed] = result.splice(startIndex, 1);
81
+ result.splice(endIndex, 0, removed);
82
+
83
+ return result;
84
+ };
85
+
86
+ const grid = 8;
87
+
88
+ const getItemStyle = (isDragging, draggableStyle) => ({
89
+ // some basic styles to make the items look a bit nicer
90
+ userSelect: 'none',
91
+ padding: `4px`,
92
+ margin: `4px`,
93
+ // change background colour if dragging
94
+
95
+ // styles we need to apply on draggables
96
+ ...draggableStyle,
97
+ });
98
+
99
+ const getListStyle = (isDraggingOver) => ({
100
+ background: isDraggingOver ? '#fff' : '#fff',
101
+ display: 'flex',
102
+ padding: grid,
103
+ overflow: 'auto',
104
+ });
105
+
106
+ const filterLetters = (i) => {
107
+ if (i >= 0 && i <= 25) {
108
+ return String.fromCharCode(65 + i);
109
+ } else {
110
+ return undefined;
111
+ }
112
+ };
113
+
114
+ class DataImport extends React.Component {
115
+ constructor(props) {
116
+ super(props);
117
+ this.props.onRef(this);
118
+
119
+ if (props.customerColumnsMapping) {
120
+ itemsTemp = props.customerColumnsMapping.map((item, index) => {
121
+ return {
122
+ id: `item-0${index}`,
123
+ content: item.title,
124
+ code: item.name,
125
+ "ct": { //单元格值格式
126
+ "fa": "General", //格式名称为自动格式
127
+ "t": "s" //格式类型为数字类型
128
+ }
129
+ };
130
+ })
131
+ } else {
132
+ itemsTemp = props.columns.map((item, index) => {
133
+ if (!mapping.get(item))
134
+ throw Error(
135
+ `${item} is not in DataImport component, please fix this error`,
136
+ );
137
+ return {
138
+ id: `item-0${index}`,
139
+ content: mapping.get(item),
140
+ code: item,
141
+ "ct": { //单元格值格式
142
+ "fa": "General", //格式名称为自动格式
143
+ "t": "s" //格式类型为数字类型
144
+ }
145
+ };
146
+ });
147
+ }
148
+ luckysheet = window.luckysheet || window.top.luckysheet;
149
+ this.state = {
150
+ showErrorData: false,
151
+ data: [],
152
+ items: [...itemsTemp],
153
+ resultData: [],
154
+ errorListCheck: false,
155
+ };
156
+ }
157
+
158
+ onDragEnd(result) {
159
+ // dropped outside the list
160
+ if (!result.destination) {
161
+ return;
162
+ }
163
+
164
+ const items = reorder(
165
+ this.state.items,
166
+ result.source.index,
167
+ result.destination.index,
168
+ );
169
+
170
+ this.setState({
171
+ items,
172
+ });
173
+
174
+ itemsTemp = items;
175
+
176
+ luckysheet.refresh();
177
+ }
178
+
179
+ getCount = () => {
180
+ const { resultData } = this.state;
181
+ return {
182
+ total: resultData.length,
183
+ error: resultData.filter((item) => !item.flag).length,
184
+ };
185
+ };
186
+
187
+ setConfig = (data) => {
188
+ const { items } = this.state;
189
+ const { notValid } = this.props;
190
+ return {
191
+ container: 'luckysheet',
192
+ showtoolbar: false,
193
+ hook: {
194
+ columnTitleCellRenderBefore: function (columnAbc, postion, ctx) {
195
+ if (columnAbc.name) {
196
+ let charCode = columnAbc.name.charCodeAt();
197
+ if (charCode - 65 <= items.length) {
198
+ columnAbc.name = itemsTemp[charCode - 65]
199
+ ? itemsTemp[charCode - 65].content
200
+ : (!notValid ? '校验结果' : '');
201
+ } else {
202
+ columnAbc.name = '';
203
+ }
204
+ }
205
+ },
206
+ cellRenderBefore: function (cell, postion, sheetFile, ctx) {
207
+ if (cell) {
208
+ cell.fs = 10;
209
+
210
+
211
+ if (typeof cell.v === 'string') {
212
+ cell.m = cell.v = cell.m.trim();
213
+ }
214
+ if (cell && cell.m && cell.m.indexOf('E+') !== -1) {
215
+ cell.v = cell.v.toString()
216
+ cell.m = cell.v
217
+ }
218
+ if (typeof cell.v === 'number') {
219
+ cell.v = cell.m
220
+ }
221
+ }
222
+ // console.log(postion);
223
+ },
224
+ cellAllRenderBefore: function (data, sheetFile, ctx) {
225
+ sheetFile.config.borderInfo = [];
226
+ // console.info(data,sheetFile,ctx)
227
+ },
228
+ },
229
+ // showtoolbarConfig: {
230
+ // undoRedo: true, //撤销重做,注意撤消重做是两个按钮,由这一个配置决定显示还是隐藏
231
+ // paintFormat: false, //格式刷
232
+ // currencyFormat: false, //货币格式
233
+ // percentageFormat: false, //百分比格式
234
+ // numberDecrease: false, // '减少小数位数'
235
+ // numberIncrease: false, // '增加小数位数
236
+ // moreFormats: false, // '更多格式'
237
+ // font: true, // '字体'
238
+ // fontSize: true, // '字号大小'
239
+
240
+ // },
241
+ data: [
242
+ {
243
+ name: 'Cell', //工作表名称
244
+ color: '', //工作表颜色
245
+ index: 0, //工作表索引
246
+ status: 1, //激活状态
247
+ order: 0, //工作表的下标
248
+ hide: 0, //是否隐藏
249
+ row: 36, //行数
250
+ column: 18, //列数
251
+ defaultRowHeight: 20, //自定义行高
252
+ defaultColWidth: 120, //自定义列宽
253
+ config: {},
254
+ // celldata:
255
+ // data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
256
+ // "r": b,
257
+ // "c": d,
258
+ // "v": { "ct": { "fa": "@", "t": "s" }, }
259
+ // }))))
260
+ // ,
261
+ celldata:
262
+ data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
263
+ "r": b,
264
+ "c": d,
265
+ "v": { "ct": { "fa": "@", "t": "s" }, }
266
+ }))))
267
+ ,
268
+ scrollLeft: 0, //左右滚动条位置
269
+ // "scrollTop": 315, //上下滚动条位置
270
+ luckysheet_select_save: [], //选中的区域
271
+ calcChain: [], //公式链
272
+ isPivotTable: false, //是否数据透视表
273
+ pivotTable: {}, //数据透视表设置
274
+ filter_select: {}, //筛选范围
275
+ filter: null, //筛选配置
276
+ luckysheet_alternateformat_save: [], //交替颜色
277
+ luckysheet_alternateformat_save_modelCustom: [], //自定义交替颜色
278
+ luckysheet_conditionformat_save: {}, //条件格式
279
+ frozen: {}, //冻结行列配置
280
+ chart: [], //图表配置
281
+ zoomRatio: 1, // 缩放比例
282
+ image: [], //图片
283
+ showGridLines: 1, //是否显示网格线
284
+ dataVerification: {}, //数据验证配置
285
+ luckysheet_alternateformat_save: [
286
+ {
287
+ cellrange: {
288
+ //单元格范围
289
+ row: [0, 1000],
290
+ column: [0, 18],
291
+ },
292
+ format: {
293
+ head: {
294
+ //页眉颜色
295
+ fc: '#6aa84f',
296
+ bc: '#ffffff',
297
+ },
298
+ one: {
299
+ //第一种颜色
300
+ bc: '#ffffff',
301
+ },
302
+ two: {
303
+ //第二种颜色
304
+ bc: '#f2f4f5',
305
+ },
306
+ foot: {
307
+ //页脚颜色
308
+ fc: '#000',
309
+ bc: '#a5efcc',
310
+ },
311
+ },
312
+ hasRowHeader: false, //含有页眉
313
+ hasRowFooter: false, //含有页脚
314
+ },
315
+ ], //交替颜色
316
+ luckysheet_alternateformat_save_modelCustom: [
317
+ {
318
+ head: {
319
+ //页眉颜色
320
+ fc: '#6aa84f',
321
+ bc: '#ffffff',
322
+ },
323
+ one: {
324
+ //第一种颜色
325
+ fc: '#000',
326
+ bc: '#ffffff',
327
+ },
328
+ two: {
329
+ //第二种颜色
330
+ fc: '#000',
331
+ bc: '#e5fbee',
332
+ },
333
+ foot: {
334
+ //页脚颜色
335
+ fc: '#000',
336
+ bc: '#a5efcc',
337
+ },
338
+ },
339
+ ], //自定义交替颜色
340
+ },
341
+ ],
342
+ cellRightClickConfig: {
343
+ copy: false, // 复制
344
+ copyAs: false, // 复制为
345
+ paste: false, // 粘贴
346
+ insertRow: false, // 插入行
347
+ insertColumn: false, // 插入列
348
+ // deleteRow: false, // 删除选中行
349
+ // deleteColumn: false, // 删除选中列
350
+ deleteCell: false, // 删除单元格
351
+ hideRow: false, // 隐藏选中行和显示选中行
352
+ hideColumn: false, // 隐藏选中列和显示选中列
353
+ rowHeight: false, // 行高
354
+ columnWidth: false, // 列宽
355
+ clear: false, // 清除内容
356
+ matrix: false, // 矩阵操作选区
357
+ sort: false, // 排序选区
358
+ filter: false, // 筛选选区
359
+ chart: false, // 图表生成
360
+ image: false, // 插入图片
361
+ link: false, // 插入链接
362
+ data: false, // 数据验证
363
+ cellFormat: false, // 设置单元格格式
364
+ },
365
+ showsheetbar: false,
366
+ optionstate: false,
367
+ showstatisticBarConfig: {
368
+ count: false, // 计数栏
369
+ view: false, // 打印视图
370
+ zoom: false, // 缩放
371
+ },
372
+ column: 10, //列数
373
+ columnHeaderHeight: 30,
374
+ lang: 'zh',
375
+ defaultFontSize: '10',
376
+ frozen: {
377
+ type: 'rangeBoth',
378
+ range: { row_focus: 1, column_focus: 1 },
379
+ },
380
+ };
381
+ };
382
+
383
+ componentDidMount() {
384
+ luckysheet.create(this.setConfig([]));
385
+ }
386
+
387
+ componentWillUnmount() {
388
+ // luckysheet.create(this.setConfig([]));
389
+ luckysheet.destroy();
390
+ }
391
+
392
+ getValidateData = () => {
393
+ const { resultData } = this.state;
394
+
395
+ return {
396
+ successData: resultData
397
+ .filter((item) => item.flag)
398
+ .map(({ flag, checkResults, ...item }) => item),
399
+ failData: resultData
400
+ .filter((item) => !item.flag)
401
+ .map(({ flag, checkResults, ...item }) => item),
402
+ };
403
+ };
404
+
405
+ getData = () => {
406
+ console.time();
407
+ let sheetData = luckysheet.getSheetData();
408
+ let data = JSON.parse(JSON.stringify(sheetData))
409
+ .filter((item) => {
410
+ return item[0]
411
+ })
412
+ .map((item) => {
413
+ let obj = {};
414
+
415
+ item.slice(0, itemsTemp.length).map((innerItem, index) => {
416
+ obj[this.state.items[index].code] = innerItem && (innerItem.v === innerItem.m ? innerItem.m : innerItem.v);
417
+ });
418
+
419
+ return obj;
420
+ });
421
+
422
+ return data.filter(item => item[this.props.customerColumnsMapping[0].name]);
423
+ };
424
+
425
+ resetData = () => {
426
+ const { validDataUrl, updateData, columns } = this.props;
427
+ const resultData = this.getData().filter(d => {
428
+ return _.compact(Object.values(d)).length
429
+ })
430
+
431
+ axios
432
+ .post(validDataUrl, {
433
+ columns: columns,
434
+ data: resultData,
435
+ })
436
+ .then((result) => {
437
+ result = result.data;
438
+ if (result.status !== '0') {
439
+ message.error(result.msg);
440
+ return;
441
+ }
442
+ const { items } = this.state;
443
+ let validIndex = items.length;
444
+ let res = result.data;
445
+
446
+ let sheetData = luckysheet.getSheetData();
447
+
448
+ sheetData.map((item, index) => {
449
+ if (!res[index]) return item;
450
+
451
+ const changeVMIndex = this.props.columns.findIndex(i => i === 'skuCode');
452
+ if(this.props.columns.find(i => i === 'skuCode') && item[changeVMIndex].v !== res[index].skuCode) {
453
+ item[changeVMIndex].v = res[index].skuCode;
454
+ item[changeVMIndex].m = res[index].skuCode;
455
+ }
456
+
457
+ if (res[index].flag) {
458
+ item[validIndex] = {
459
+ ...item[validIndex],
460
+ v: '通过',
461
+ m: '通过',
462
+ fc: 'green', //字体颜色为 "#990000"
463
+ };
464
+ } else {
465
+ item[validIndex] = {
466
+ ...item[validIndex],
467
+ v: res[index].checkResults,
468
+ m: res[index].checkResults,
469
+ fc: 'red', //字体颜色为 "#990000"
470
+ };
471
+ }
472
+
473
+ item[validIndex].ct = { fa: 'General', t: 'g' };
474
+ });
475
+ // sheetData.map((item, index) => {
476
+ // luckysheet.setCellValue(index + 1, 4, 345)
477
+ // })
478
+
479
+ luckysheet.create(
480
+ this.setConfig(luckysheet.transToCellData(sheetData)),
481
+ );
482
+ this.setState({
483
+ data: luckysheet.transToCellData(sheetData),
484
+ errorListCheck: false,
485
+ resultData: res,
486
+ });
487
+
488
+ console.log(setExportData);
489
+ setExportData([123123]);
490
+ })
491
+ .catch((err) => { });
492
+ };
493
+
494
+ filterData = (type: string) => {
495
+ const { showErrorData, data, resultData } = this.state;
496
+ let sheetData = luckysheet.transToData(data).filter((item, index) => {
497
+ if (type === 'all') {
498
+ return false;
499
+ }
500
+ if (type === 'error') {
501
+ return item[itemsTemp.length] && item[itemsTemp.length].v === '通过';
502
+ }
503
+ });
504
+
505
+ luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
506
+ this.setState({
507
+ data: luckysheet.transToCellData(sheetData),
508
+ errorListCheck: false,
509
+ resultData: type === 'all' ? [] : resultData.filter((item) => item.flag),
510
+ });
511
+ };
512
+
513
+ toggleData = () => {
514
+ const { showErrorData, data } = this.state;
515
+
516
+ if (showErrorData) {
517
+ luckysheet.create(this.setConfig(data));
518
+ } else {
519
+ let sheetData = luckysheet.getSheetData();
520
+ sheetData = sheetData.filter((item, index) => {
521
+ return !item[itemsTemp.length] || item[itemsTemp.length].v !== '通过';
522
+ });
523
+
524
+ luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
525
+ }
526
+
527
+ this.setState({
528
+ showErrorData: !showErrorData,
529
+ });
530
+ };
531
+
532
+ onChange = (e) => {
533
+ this.setState({
534
+ radioValue: e.target.value,
535
+ });
536
+ this.toggleData();
537
+ };
538
+
539
+ errorChange = (e: any) => {
540
+ this.toggleData();
541
+ this.setState({
542
+ errorListCheck: e.target.checked,
543
+ });
544
+ };
545
+
546
+ menuList = (
547
+ <Menu>
548
+ <Menu.Item key="1" className="sheet_table-menu_item_text">
549
+ <a onClick={() => this.filterData('all')}>清空全部数据</a>
550
+ </Menu.Item>
551
+ <Menu.Divider />
552
+ {!this.props.notValid && <Menu.Item key="2" className="sheet_table-menu_item_text">
553
+ <a onClick={() => this.filterData('error')}>仅清空错误数据</a>
554
+ </Menu.Item>}
555
+ </Menu>
556
+ );
557
+
558
+ leftMenu = (
559
+ <Menu>
560
+ <Menu.Item key="3" className="sheet_table-menu_item_text">
561
+ <span className="sheet_table_text">请拖动字段来对应列</span>
562
+ </Menu.Item>
563
+ <Menu.Divider />
564
+ <div>
565
+ <DragDropContext onDragEnd={(e) => this.onDragEnd(e)}>
566
+ <Droppable droppableId="droppable" direction="vertical">
567
+ {(provided, snapshot) => (
568
+ <div
569
+ ref={provided.innerRef}
570
+ style={{
571
+ ...getListStyle(snapshot.isDraggingOver),
572
+ flexDirection: 'column',
573
+ }}
574
+ {...provided.droppableProps}
575
+ >
576
+ {this.state.items.map((item, index) => (
577
+ <Draggable key={item.id} draggableId={item.id} index={index}>
578
+ {(provided, snapshot) => (
579
+ <div
580
+ ref={provided.innerRef}
581
+ {...provided.draggableProps}
582
+ {...provided.dragHandleProps}
583
+ style={getItemStyle(
584
+ snapshot.isDragging,
585
+ provided.draggableProps.style,
586
+ )}
587
+ >
588
+ <Space>
589
+ <span>{filterLetters(index)} 列 </span>
590
+ <Space className="sheet_table_dnd_text">
591
+ <UnorderedListOutlined />
592
+ {item.content}
593
+ </Space>
594
+ </Space>
595
+ </div>
596
+ )}
597
+ </Draggable>
598
+ ))}
599
+ {provided.placeholder}
600
+ </div>
601
+ )}
602
+ </Droppable>
603
+ </DragDropContext>
604
+ </div>
605
+ </Menu>
606
+ );
607
+
608
+ render() {
609
+ const { errorListCheck } = this.state;
610
+ const { title, notValid, customerColumnsMapping } = this.props;
611
+
612
+ let totalSummary = this.getCount();
613
+
614
+ const luckyCss = {
615
+ margin: '0px',
616
+ padding: '0px',
617
+ position: 'absolute',
618
+ width: '100%',
619
+ height: '100%',
620
+ left: '0px',
621
+ top: '0px',
622
+ };
623
+ return (
624
+ <>
625
+ <div className="sheet_table_top">
626
+ <Space>
627
+ <span>排序列</span>
628
+ <Dropdown
629
+ trigger={['click']}
630
+ overlay={this.leftMenu}
631
+ placement="bottomLeft"
632
+ >
633
+ <a>
634
+ <ProfileTwoTone />
635
+ </a>
636
+ </Dropdown>
637
+ <Tooltip
638
+ title={
639
+ <>
640
+ <span>使用指南:</span>
641
+ <br></br>
642
+ <span>
643
+ 1、拖动数据项,以适配源数据的顺序,如您Excel中数据排序依次为编码、价格和数量,则您也可以将数据项的顺序调整为一致
644
+ </span>
645
+ <br></br>
646
+ <span>2、复制文件数据(多列一起),在文本框内进行粘贴</span>
647
+ <br></br>
648
+ <span>
649
+ 3、点击识别按钮进行数据校验,如全部正确,则点击录入按钮可录入数据,如存在错误数据,则需修改后再进行录入
650
+ </span>
651
+ </>
652
+ }
653
+ >
654
+ <ExclamationCircleOutlined />
655
+ </Tooltip>
656
+ </Space>
657
+ <Space>
658
+ <Dropdown
659
+ trigger={['click']}
660
+ overlay={this.menuList}
661
+ placement="bottomRight"
662
+ >
663
+ <Button>
664
+ 清空
665
+ <DownOutlined />
666
+ </Button>
667
+ </Dropdown>
668
+
669
+ {!notValid && <Button type="primary" onClick={this.resetData}>
670
+ 识别
671
+ </Button>}
672
+ </Space>
673
+ </div>
674
+
675
+ <div style={{ position: 'relative', height: '400px' }}>
676
+ <div id="luckysheet" style={luckyCss}></div>
677
+ </div>
678
+ {!this.props.notValid && <div className="sheet_table_footer">
679
+ <span className="sheet_table_footer_l">
680
+ 共 {totalSummary.total} 条数据{!notValid && `, 其中错误 ${totalSummary.error} 项`}
681
+ </span>
682
+ {!notValid && <Space className="sheet_table_footer_r">
683
+ <Checkbox
684
+ checked={errorListCheck}
685
+ onClick={this.errorChange}
686
+ ></Checkbox>
687
+ 仅展示错误数据
688
+ </Space>}
689
+ </div>}
690
+ </>
691
+ );
692
+ }
693
+ }
694
+
695
+ export default DataImport;