@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,687 +1,687 @@
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 DataValidation extends React.Component {
115
- constructor(props) {
116
- super(props);
117
- this.props.onRef(this);
118
-
119
- itemsTemp = props.columns.map((item, index) => {
120
- if (!mapping.get(item))
121
- throw Error(
122
- `${item} is not in DataValidation component, please fix this error`,
123
- );
124
- return {
125
- id: `item-0${index}`,
126
- content: mapping.get(item),
127
- code: item,
128
- "ct": { //单元格值格式
129
- "fa": "General", //格式名称为自动格式
130
- "t": "s" //格式类型为数字类型
131
- }
132
- };
133
- });
134
- luckysheet = window.luckysheet || window.top.luckysheet;
135
- this.state = {
136
- showErrorData: false,
137
- data: [],
138
- items: [...itemsTemp],
139
- resultData: [],
140
- errorListCheck: false,
141
- };
142
- }
143
-
144
- onDragEnd(result) {
145
- // dropped outside the list
146
- if (!result.destination) {
147
- return;
148
- }
149
-
150
- const items = reorder(
151
- this.state.items,
152
- result.source.index,
153
- result.destination.index,
154
- );
155
-
156
- this.setState({
157
- items,
158
- });
159
-
160
- itemsTemp = items;
161
-
162
- luckysheet.refresh();
163
- }
164
-
165
- getCount = () => {
166
- const { resultData } = this.state;
167
- return {
168
- total: resultData.length,
169
- error: resultData.filter((item) => !item.flag).length,
170
- };
171
- };
172
-
173
- setConfig = (data) => {
174
- const { items } = this.state;
175
- return {
176
- container: 'luckysheet',
177
- showtoolbar: false,
178
- hook: {
179
- columnTitleCellRenderBefore: function (columnAbc, postion, ctx) {
180
- if (columnAbc.name) {
181
- let charCode = columnAbc.name.charCodeAt();
182
- if (charCode - 65 <= items.length) {
183
- columnAbc.name = itemsTemp[charCode - 65]
184
- ? itemsTemp[charCode - 65].content
185
- : '校验结果';
186
- } else {
187
- columnAbc.name = '';
188
- }
189
- }
190
- },
191
- cellRenderBefore: function (cell, postion, sheetFile, ctx) {
192
- if (cell) {
193
- cell.fs = 10;
194
-
195
-
196
- if (typeof cell.v === 'string') {
197
- cell.m = cell.v = cell.m.trim();
198
- }
199
- if (cell && cell.m && cell.m.indexOf('E+') !== -1) {
200
- cell.v = cell.v.toString()
201
- cell.m = cell.v
202
- }
203
- if (typeof cell.v === 'number') {
204
- cell.v = cell.m
205
- }
206
- }
207
- // console.log(postion);
208
- },
209
- cellAllRenderBefore: function (data, sheetFile, ctx) {
210
- sheetFile.config.borderInfo = [];
211
- // console.info(data,sheetFile,ctx)
212
- },
213
- },
214
- // showtoolbarConfig: {
215
- // undoRedo: true, //撤销重做,注意撤消重做是两个按钮,由这一个配置决定显示还是隐藏
216
- // paintFormat: false, //格式刷
217
- // currencyFormat: false, //货币格式
218
- // percentageFormat: false, //百分比格式
219
- // numberDecrease: false, // '减少小数位数'
220
- // numberIncrease: false, // '增加小数位数
221
- // moreFormats: false, // '更多格式'
222
- // font: true, // '字体'
223
- // fontSize: true, // '字号大小'
224
-
225
- // },
226
- data: [
227
- {
228
- name: 'Cell', //工作表名称
229
- color: '', //工作表颜色
230
- index: 0, //工作表索引
231
- status: 1, //激活状态
232
- order: 0, //工作表的下标
233
- hide: 0, //是否隐藏
234
- row: 36, //行数
235
- column: 18, //列数
236
- defaultRowHeight: 20, //自定义行高
237
- defaultColWidth: 120, //自定义列宽
238
- config: {},
239
- // celldata:
240
- // data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
241
- // "r": b,
242
- // "c": d,
243
- // "v": { "ct": { "fa": "@", "t": "s" }, }
244
- // }))))
245
- // ,
246
- celldata:
247
- data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
248
- "r": b,
249
- "c": d,
250
- "v": { "ct": { "fa": "@", "t": "s" }, }
251
- }))))
252
- ,
253
- scrollLeft: 0, //左右滚动条位置
254
- // "scrollTop": 315, //上下滚动条位置
255
- luckysheet_select_save: [], //选中的区域
256
- calcChain: [], //公式链
257
- isPivotTable: false, //是否数据透视表
258
- pivotTable: {}, //数据透视表设置
259
- filter_select: {}, //筛选范围
260
- filter: null, //筛选配置
261
- luckysheet_alternateformat_save: [], //交替颜色
262
- luckysheet_alternateformat_save_modelCustom: [], //自定义交替颜色
263
- luckysheet_conditionformat_save: {}, //条件格式
264
- frozen: {}, //冻结行列配置
265
- chart: [], //图表配置
266
- zoomRatio: 1, // 缩放比例
267
- image: [], //图片
268
- showGridLines: 1, //是否显示网格线
269
- dataVerification: {}, //数据验证配置
270
- luckysheet_alternateformat_save: [
271
- {
272
- cellrange: {
273
- //单元格范围
274
- row: [0, 1000],
275
- column: [0, 18],
276
- },
277
- format: {
278
- head: {
279
- //页眉颜色
280
- fc: '#6aa84f',
281
- bc: '#ffffff',
282
- },
283
- one: {
284
- //第一种颜色
285
- bc: '#ffffff',
286
- },
287
- two: {
288
- //第二种颜色
289
- bc: '#f2f4f5',
290
- },
291
- foot: {
292
- //页脚颜色
293
- fc: '#000',
294
- bc: '#a5efcc',
295
- },
296
- },
297
- hasRowHeader: false, //含有页眉
298
- hasRowFooter: false, //含有页脚
299
- },
300
- ], //交替颜色
301
- luckysheet_alternateformat_save_modelCustom: [
302
- {
303
- head: {
304
- //页眉颜色
305
- fc: '#6aa84f',
306
- bc: '#ffffff',
307
- },
308
- one: {
309
- //第一种颜色
310
- fc: '#000',
311
- bc: '#ffffff',
312
- },
313
- two: {
314
- //第二种颜色
315
- fc: '#000',
316
- bc: '#e5fbee',
317
- },
318
- foot: {
319
- //页脚颜色
320
- fc: '#000',
321
- bc: '#a5efcc',
322
- },
323
- },
324
- ], //自定义交替颜色
325
- },
326
- ],
327
- cellRightClickConfig: {
328
- copy: false, // 复制
329
- copyAs: false, // 复制为
330
- paste: false, // 粘贴
331
- insertRow: false, // 插入行
332
- insertColumn: false, // 插入列
333
- // deleteRow: false, // 删除选中行
334
- // deleteColumn: false, // 删除选中列
335
- deleteCell: false, // 删除单元格
336
- hideRow: false, // 隐藏选中行和显示选中行
337
- hideColumn: false, // 隐藏选中列和显示选中列
338
- rowHeight: false, // 行高
339
- columnWidth: false, // 列宽
340
- clear: false, // 清除内容
341
- matrix: false, // 矩阵操作选区
342
- sort: false, // 排序选区
343
- filter: false, // 筛选选区
344
- chart: false, // 图表生成
345
- image: false, // 插入图片
346
- link: false, // 插入链接
347
- data: false, // 数据验证
348
- cellFormat: false, // 设置单元格格式
349
- },
350
- showsheetbar: false,
351
- optionstate: false,
352
- showstatisticBarConfig: {
353
- count: false, // 计数栏
354
- view: false, // 打印视图
355
- zoom: false, // 缩放
356
- },
357
- column: 10, //列数
358
- columnHeaderHeight: 30,
359
- lang: 'zh',
360
- defaultFontSize: '10',
361
- frozen: {
362
- type: 'rangeBoth',
363
- range: { row_focus: 1, column_focus: 1 },
364
- },
365
- };
366
- };
367
-
368
- componentDidMount() {
369
- luckysheet.create(this.setConfig([]));
370
- }
371
-
372
- componentWillUnmount() {
373
- // luckysheet.create(this.setConfig([]));
374
- luckysheet.destroy();
375
- }
376
-
377
- getValidateData = () => {
378
- const { resultData } = this.state;
379
-
380
- return {
381
- successData: resultData
382
- .filter((item) => item.flag)
383
- .map(({ flag, checkResults, ...item }) => item),
384
- failData: resultData
385
- .filter((item) => !item.flag)
386
- .map(({ flag, checkResults, ...item }) => item),
387
- };
388
- };
389
-
390
- getData = () => {
391
- console.time();
392
- let sheetData = luckysheet.getSheetData();
393
- let data = JSON.parse(JSON.stringify(sheetData))
394
- .filter((item) => item[0])
395
- .map((item) => {
396
- let obj = {};
397
-
398
- item.slice(0, itemsTemp.length).map((innerItem, index) => {
399
- obj[this.state.items[index].code] = innerItem && (innerItem.v === innerItem.m ? innerItem.m : innerItem.v);
400
- });
401
-
402
- return obj;
403
- });
404
-
405
- return data;
406
- };
407
-
408
- resetData = () => {
409
- const { validDataUrl, validDataParams, updateData, columns, isBrandAuth, isCheckStockNum = true } = this.props;
410
- const resultData = this.getData().filter(d => {
411
- return _.compact(Object.values(d)).length
412
- })
413
-
414
- // 处理业务参数
415
- let otherParams={}
416
- if(isBrandAuth){
417
- otherParams = { brandAuth: 'ctl-withAuth' }
418
- }
419
-
420
- axios
421
- .post(validDataUrl, {
422
- ...otherParams,
423
- ...validDataParams,
424
- columns: columns,
425
- data: resultData,
426
- checkStockNum: isCheckStockNum
427
- })
428
- .then((result) => {
429
- result = result.data;
430
- if (result.status !== '0') {
431
- message.error(result.msg);
432
- return;
433
- }
434
- const { items } = this.state;
435
- let validIndex = items.length;
436
- let res = result.data;
437
-
438
- let sheetData = luckysheet.getSheetData();
439
-
440
- sheetData.map((item, index) => {
441
- if (!res[index]) return item;
442
-
443
- const changeVMIndex = this.props.columns.findIndex(i => i === 'skuCode');
444
- if(this.props.columns.find(i => i === 'skuCode') && item[changeVMIndex].v !== res[index].skuCode) {
445
- item[changeVMIndex].v = res[index].skuCode;
446
- item[changeVMIndex].m = res[index].skuCode;
447
- }
448
-
449
- if (res[index].flag) {
450
- item[validIndex] = {
451
- ...item[validIndex],
452
- v: '通过',
453
- m: '通过',
454
- fc: 'green', //字体颜色为 "#990000"
455
- };
456
- } else {
457
- item[validIndex] = {
458
- ...item[validIndex],
459
- v: res[index].checkResults,
460
- m: res[index].checkResults,
461
- fc: 'red', //字体颜色为 "#990000"
462
- };
463
- }
464
-
465
- item[validIndex].ct = { fa: 'General', t: 'g' };
466
- });
467
- // sheetData.map((item, index) => {
468
- // luckysheet.setCellValue(index + 1, 4, 345)
469
- // })
470
-
471
- luckysheet.create(
472
- this.setConfig(luckysheet.transToCellData(sheetData)),
473
- );
474
- this.setState({
475
- data: luckysheet.transToCellData(sheetData),
476
- errorListCheck: false,
477
- resultData: res,
478
- });
479
-
480
- console.log(setExportData);
481
- setExportData([123123]);
482
- })
483
- .catch((err) => { });
484
- };
485
-
486
- filterData = (type: string) => {
487
- const { showErrorData, data, resultData } = this.state;
488
- let sheetData = luckysheet.transToData(data).filter((item, index) => {
489
- if (type === 'all') {
490
- return false;
491
- }
492
- if (type === 'error') {
493
- return item[itemsTemp.length] && item[itemsTemp.length].v === '通过';
494
- }
495
- });
496
-
497
- luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
498
- this.setState({
499
- data: luckysheet.transToCellData(sheetData),
500
- errorListCheck: false,
501
- resultData: type === 'all' ? [] : resultData.filter((item) => item.flag),
502
- });
503
- };
504
-
505
- toggleData = () => {
506
- const { showErrorData, data } = this.state;
507
-
508
- if (showErrorData) {
509
- luckysheet.create(this.setConfig(data));
510
- } else {
511
- let sheetData = luckysheet.getSheetData();
512
- sheetData = sheetData.filter((item, index) => {
513
- return !item[itemsTemp.length] || item[itemsTemp.length].v !== '通过';
514
- });
515
-
516
- luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
517
- }
518
-
519
- this.setState({
520
- showErrorData: !showErrorData,
521
- });
522
- };
523
-
524
- onChange = (e) => {
525
- this.setState({
526
- radioValue: e.target.value,
527
- });
528
- this.toggleData();
529
- };
530
-
531
- errorChange = (e: any) => {
532
- this.toggleData();
533
- this.setState({
534
- errorListCheck: e.target.checked,
535
- });
536
- };
537
-
538
- menuList = (
539
- <Menu>
540
- <Menu.Item key="1" className="sheet_table-menu_item_text">
541
- <a onClick={() => this.filterData('all')}>清空全部数据</a>
542
- </Menu.Item>
543
- <Menu.Divider />
544
- <Menu.Item key="2" className="sheet_table-menu_item_text">
545
- <a onClick={() => this.filterData('error')}>仅清空错误数据</a>
546
- </Menu.Item>
547
- </Menu>
548
- );
549
-
550
- leftMenu = (
551
- <Menu>
552
- <Menu.Item key="3" className="sheet_table-menu_item_text">
553
- <span className="sheet_table_text">请拖动字段来对应列</span>
554
- </Menu.Item>
555
- <Menu.Divider />
556
- <div>
557
- <DragDropContext onDragEnd={(e) => this.onDragEnd(e)}>
558
- <Droppable droppableId="droppable" direction="vertical">
559
- {(provided, snapshot) => (
560
- <div
561
- ref={provided.innerRef}
562
- style={{
563
- ...getListStyle(snapshot.isDraggingOver),
564
- flexDirection: 'column',
565
- }}
566
- {...provided.droppableProps}
567
- >
568
- {this.state.items.map((item, index) => (
569
- <Draggable key={item.id} draggableId={item.id} index={index}>
570
- {(provided, snapshot) => (
571
- <div
572
- ref={provided.innerRef}
573
- {...provided.draggableProps}
574
- {...provided.dragHandleProps}
575
- style={getItemStyle(
576
- snapshot.isDragging,
577
- provided.draggableProps.style,
578
- )}
579
- >
580
- <Space>
581
- <span>{filterLetters(index)} 列 </span>
582
- <Space className="sheet_table_dnd_text">
583
- <UnorderedListOutlined />
584
- {item.content}
585
- </Space>
586
- </Space>
587
- </div>
588
- )}
589
- </Draggable>
590
- ))}
591
- {provided.placeholder}
592
- </div>
593
- )}
594
- </Droppable>
595
- </DragDropContext>
596
- </div>
597
- </Menu>
598
- );
599
-
600
- render() {
601
- const { errorListCheck } = this.state;
602
- const { title } = this.props;
603
-
604
- let totalSummary = this.getCount();
605
-
606
- const luckyCss = {
607
- margin: '0px',
608
- padding: '0px',
609
- position: 'absolute',
610
- width: '100%',
611
- height: '100%',
612
- left: '0px',
613
- top: '0px',
614
- };
615
- return (
616
- <>
617
- <div className="sheet_table_top">
618
- <Space>
619
- <span>排序列</span>
620
- <Dropdown
621
- trigger={['click']}
622
- overlay={this.leftMenu}
623
- placement="bottomLeft"
624
- >
625
- <a>
626
- <ProfileTwoTone />
627
- </a>
628
- </Dropdown>
629
- <Tooltip
630
- title={
631
- <>
632
- <span>使用指南:</span>
633
- <br></br>
634
- <span>
635
- 1、拖动数据项,以适配源数据的顺序,如您Excel中数据排序依次为编码、价格和数量,则您也可以将数据项的顺序调整为一致
636
- </span>
637
- <br></br>
638
- <span>2、复制文件数据(多列一起),在文本框内进行粘贴</span>
639
- <br></br>
640
- <span>
641
- 3、点击识别按钮进行数据校验,如全部正确,则点击录入按钮可录入数据,如存在错误数据,则需修改后再进行录入
642
- </span>
643
- </>
644
- }
645
- >
646
- <ExclamationCircleOutlined />
647
- </Tooltip>
648
- </Space>
649
- <Space>
650
- <Dropdown
651
- trigger={['click']}
652
- overlay={this.menuList}
653
- placement="bottomRight"
654
- >
655
- <Button>
656
- 清空
657
- <DownOutlined />
658
- </Button>
659
- </Dropdown>
660
-
661
- <Button type="primary" onClick={this.resetData}>
662
- 识别
663
- </Button>
664
- </Space>
665
- </div>
666
-
667
- <div style={{ position: 'relative', height: '400px' }}>
668
- <div id="luckysheet" style={luckyCss}></div>
669
- </div>
670
- <div className="sheet_table_footer">
671
- <span className="sheet_table_footer_l">
672
- 共 {totalSummary.total} 条数据, 其中错误 {totalSummary.error} 项
673
- </span>
674
- <Space className="sheet_table_footer_r">
675
- <Checkbox
676
- checked={errorListCheck}
677
- onClick={this.errorChange}
678
- ></Checkbox>
679
- 仅展示错误数据
680
- </Space>
681
- </div>
682
- </>
683
- );
684
- }
685
- }
686
-
687
- export default DataValidation;
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 DataValidation extends React.Component {
115
+ constructor(props) {
116
+ super(props);
117
+ this.props.onRef(this);
118
+
119
+ itemsTemp = props.columns.map((item, index) => {
120
+ if (!mapping.get(item))
121
+ throw Error(
122
+ `${item} is not in DataValidation component, please fix this error`,
123
+ );
124
+ return {
125
+ id: `item-0${index}`,
126
+ content: mapping.get(item),
127
+ code: item,
128
+ "ct": { //单元格值格式
129
+ "fa": "General", //格式名称为自动格式
130
+ "t": "s" //格式类型为数字类型
131
+ }
132
+ };
133
+ });
134
+ luckysheet = window.luckysheet || window.top.luckysheet;
135
+ this.state = {
136
+ showErrorData: false,
137
+ data: [],
138
+ items: [...itemsTemp],
139
+ resultData: [],
140
+ errorListCheck: false,
141
+ };
142
+ }
143
+
144
+ onDragEnd(result) {
145
+ // dropped outside the list
146
+ if (!result.destination) {
147
+ return;
148
+ }
149
+
150
+ const items = reorder(
151
+ this.state.items,
152
+ result.source.index,
153
+ result.destination.index,
154
+ );
155
+
156
+ this.setState({
157
+ items,
158
+ });
159
+
160
+ itemsTemp = items;
161
+
162
+ luckysheet.refresh();
163
+ }
164
+
165
+ getCount = () => {
166
+ const { resultData } = this.state;
167
+ return {
168
+ total: resultData.length,
169
+ error: resultData.filter((item) => !item.flag).length,
170
+ };
171
+ };
172
+
173
+ setConfig = (data) => {
174
+ const { items } = this.state;
175
+ return {
176
+ container: 'luckysheet',
177
+ showtoolbar: false,
178
+ hook: {
179
+ columnTitleCellRenderBefore: function (columnAbc, postion, ctx) {
180
+ if (columnAbc.name) {
181
+ let charCode = columnAbc.name.charCodeAt();
182
+ if (charCode - 65 <= items.length) {
183
+ columnAbc.name = itemsTemp[charCode - 65]
184
+ ? itemsTemp[charCode - 65].content
185
+ : '校验结果';
186
+ } else {
187
+ columnAbc.name = '';
188
+ }
189
+ }
190
+ },
191
+ cellRenderBefore: function (cell, postion, sheetFile, ctx) {
192
+ if (cell) {
193
+ cell.fs = 10;
194
+
195
+
196
+ if (typeof cell.v === 'string') {
197
+ cell.m = cell.v = cell.m.trim();
198
+ }
199
+ if (cell && cell.m && cell.m.indexOf('E+') !== -1) {
200
+ cell.v = cell.v.toString()
201
+ cell.m = cell.v
202
+ }
203
+ if (typeof cell.v === 'number') {
204
+ cell.v = cell.m
205
+ }
206
+ }
207
+ // console.log(postion);
208
+ },
209
+ cellAllRenderBefore: function (data, sheetFile, ctx) {
210
+ sheetFile.config.borderInfo = [];
211
+ // console.info(data,sheetFile,ctx)
212
+ },
213
+ },
214
+ // showtoolbarConfig: {
215
+ // undoRedo: true, //撤销重做,注意撤消重做是两个按钮,由这一个配置决定显示还是隐藏
216
+ // paintFormat: false, //格式刷
217
+ // currencyFormat: false, //货币格式
218
+ // percentageFormat: false, //百分比格式
219
+ // numberDecrease: false, // '减少小数位数'
220
+ // numberIncrease: false, // '增加小数位数
221
+ // moreFormats: false, // '更多格式'
222
+ // font: true, // '字体'
223
+ // fontSize: true, // '字号大小'
224
+
225
+ // },
226
+ data: [
227
+ {
228
+ name: 'Cell', //工作表名称
229
+ color: '', //工作表颜色
230
+ index: 0, //工作表索引
231
+ status: 1, //激活状态
232
+ order: 0, //工作表的下标
233
+ hide: 0, //是否隐藏
234
+ row: 36, //行数
235
+ column: 18, //列数
236
+ defaultRowHeight: 20, //自定义行高
237
+ defaultColWidth: 120, //自定义列宽
238
+ config: {},
239
+ // celldata:
240
+ // data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
241
+ // "r": b,
242
+ // "c": d,
243
+ // "v": { "ct": { "fa": "@", "t": "s" }, }
244
+ // }))))
245
+ // ,
246
+ celldata:
247
+ data && data.length !== 0 ? data : _.flattenDeep(Array.from({ length: 100 }).map((a, b) => Array.from({ length: 100 }).map((c, d) => ({
248
+ "r": b,
249
+ "c": d,
250
+ "v": { "ct": { "fa": "@", "t": "s" }, }
251
+ }))))
252
+ ,
253
+ scrollLeft: 0, //左右滚动条位置
254
+ // "scrollTop": 315, //上下滚动条位置
255
+ luckysheet_select_save: [], //选中的区域
256
+ calcChain: [], //公式链
257
+ isPivotTable: false, //是否数据透视表
258
+ pivotTable: {}, //数据透视表设置
259
+ filter_select: {}, //筛选范围
260
+ filter: null, //筛选配置
261
+ luckysheet_alternateformat_save: [], //交替颜色
262
+ luckysheet_alternateformat_save_modelCustom: [], //自定义交替颜色
263
+ luckysheet_conditionformat_save: {}, //条件格式
264
+ frozen: {}, //冻结行列配置
265
+ chart: [], //图表配置
266
+ zoomRatio: 1, // 缩放比例
267
+ image: [], //图片
268
+ showGridLines: 1, //是否显示网格线
269
+ dataVerification: {}, //数据验证配置
270
+ luckysheet_alternateformat_save: [
271
+ {
272
+ cellrange: {
273
+ //单元格范围
274
+ row: [0, 1000],
275
+ column: [0, 18],
276
+ },
277
+ format: {
278
+ head: {
279
+ //页眉颜色
280
+ fc: '#6aa84f',
281
+ bc: '#ffffff',
282
+ },
283
+ one: {
284
+ //第一种颜色
285
+ bc: '#ffffff',
286
+ },
287
+ two: {
288
+ //第二种颜色
289
+ bc: '#f2f4f5',
290
+ },
291
+ foot: {
292
+ //页脚颜色
293
+ fc: '#000',
294
+ bc: '#a5efcc',
295
+ },
296
+ },
297
+ hasRowHeader: false, //含有页眉
298
+ hasRowFooter: false, //含有页脚
299
+ },
300
+ ], //交替颜色
301
+ luckysheet_alternateformat_save_modelCustom: [
302
+ {
303
+ head: {
304
+ //页眉颜色
305
+ fc: '#6aa84f',
306
+ bc: '#ffffff',
307
+ },
308
+ one: {
309
+ //第一种颜色
310
+ fc: '#000',
311
+ bc: '#ffffff',
312
+ },
313
+ two: {
314
+ //第二种颜色
315
+ fc: '#000',
316
+ bc: '#e5fbee',
317
+ },
318
+ foot: {
319
+ //页脚颜色
320
+ fc: '#000',
321
+ bc: '#a5efcc',
322
+ },
323
+ },
324
+ ], //自定义交替颜色
325
+ },
326
+ ],
327
+ cellRightClickConfig: {
328
+ copy: false, // 复制
329
+ copyAs: false, // 复制为
330
+ paste: false, // 粘贴
331
+ insertRow: false, // 插入行
332
+ insertColumn: false, // 插入列
333
+ // deleteRow: false, // 删除选中行
334
+ // deleteColumn: false, // 删除选中列
335
+ deleteCell: false, // 删除单元格
336
+ hideRow: false, // 隐藏选中行和显示选中行
337
+ hideColumn: false, // 隐藏选中列和显示选中列
338
+ rowHeight: false, // 行高
339
+ columnWidth: false, // 列宽
340
+ clear: false, // 清除内容
341
+ matrix: false, // 矩阵操作选区
342
+ sort: false, // 排序选区
343
+ filter: false, // 筛选选区
344
+ chart: false, // 图表生成
345
+ image: false, // 插入图片
346
+ link: false, // 插入链接
347
+ data: false, // 数据验证
348
+ cellFormat: false, // 设置单元格格式
349
+ },
350
+ showsheetbar: false,
351
+ optionstate: false,
352
+ showstatisticBarConfig: {
353
+ count: false, // 计数栏
354
+ view: false, // 打印视图
355
+ zoom: false, // 缩放
356
+ },
357
+ column: 10, //列数
358
+ columnHeaderHeight: 30,
359
+ lang: 'zh',
360
+ defaultFontSize: '10',
361
+ frozen: {
362
+ type: 'rangeBoth',
363
+ range: { row_focus: 1, column_focus: 1 },
364
+ },
365
+ };
366
+ };
367
+
368
+ componentDidMount() {
369
+ luckysheet.create(this.setConfig([]));
370
+ }
371
+
372
+ componentWillUnmount() {
373
+ // luckysheet.create(this.setConfig([]));
374
+ luckysheet.destroy();
375
+ }
376
+
377
+ getValidateData = () => {
378
+ const { resultData } = this.state;
379
+
380
+ return {
381
+ successData: resultData
382
+ .filter((item) => item.flag)
383
+ .map(({ flag, checkResults, ...item }) => item),
384
+ failData: resultData
385
+ .filter((item) => !item.flag)
386
+ .map(({ flag, checkResults, ...item }) => item),
387
+ };
388
+ };
389
+
390
+ getData = () => {
391
+ console.time();
392
+ let sheetData = luckysheet.getSheetData();
393
+ let data = JSON.parse(JSON.stringify(sheetData))
394
+ .filter((item) => item[0])
395
+ .map((item) => {
396
+ let obj = {};
397
+
398
+ item.slice(0, itemsTemp.length).map((innerItem, index) => {
399
+ obj[this.state.items[index].code] = innerItem && (innerItem.v === innerItem.m ? innerItem.m : innerItem.v);
400
+ });
401
+
402
+ return obj;
403
+ });
404
+
405
+ return data;
406
+ };
407
+
408
+ resetData = () => {
409
+ const { validDataUrl, validDataParams, updateData, columns, isBrandAuth, isCheckStockNum = true } = this.props;
410
+ const resultData = this.getData().filter(d => {
411
+ return _.compact(Object.values(d)).length
412
+ })
413
+
414
+ // 处理业务参数
415
+ let otherParams={}
416
+ if(isBrandAuth){
417
+ otherParams = { brandAuth: 'ctl-withAuth' }
418
+ }
419
+
420
+ axios
421
+ .post(validDataUrl, {
422
+ ...otherParams,
423
+ ...validDataParams,
424
+ columns: columns,
425
+ data: resultData,
426
+ checkStockNum: isCheckStockNum
427
+ })
428
+ .then((result) => {
429
+ result = result.data;
430
+ if (result.status !== '0') {
431
+ message.error(result.msg);
432
+ return;
433
+ }
434
+ const { items } = this.state;
435
+ let validIndex = items.length;
436
+ let res = result.data;
437
+
438
+ let sheetData = luckysheet.getSheetData();
439
+
440
+ sheetData.map((item, index) => {
441
+ if (!res[index]) return item;
442
+
443
+ const changeVMIndex = this.props.columns.findIndex(i => i === 'skuCode');
444
+ if(this.props.columns.find(i => i === 'skuCode') && item[changeVMIndex].v !== res[index].skuCode) {
445
+ item[changeVMIndex].v = res[index].skuCode;
446
+ item[changeVMIndex].m = res[index].skuCode;
447
+ }
448
+
449
+ if (res[index].flag) {
450
+ item[validIndex] = {
451
+ ...item[validIndex],
452
+ v: '通过',
453
+ m: '通过',
454
+ fc: 'green', //字体颜色为 "#990000"
455
+ };
456
+ } else {
457
+ item[validIndex] = {
458
+ ...item[validIndex],
459
+ v: res[index].checkResults,
460
+ m: res[index].checkResults,
461
+ fc: 'red', //字体颜色为 "#990000"
462
+ };
463
+ }
464
+
465
+ item[validIndex].ct = { fa: 'General', t: 'g' };
466
+ });
467
+ // sheetData.map((item, index) => {
468
+ // luckysheet.setCellValue(index + 1, 4, 345)
469
+ // })
470
+
471
+ luckysheet.create(
472
+ this.setConfig(luckysheet.transToCellData(sheetData)),
473
+ );
474
+ this.setState({
475
+ data: luckysheet.transToCellData(sheetData),
476
+ errorListCheck: false,
477
+ resultData: res,
478
+ });
479
+
480
+ console.log(setExportData);
481
+ setExportData([123123]);
482
+ })
483
+ .catch((err) => { });
484
+ };
485
+
486
+ filterData = (type: string) => {
487
+ const { showErrorData, data, resultData } = this.state;
488
+ let sheetData = luckysheet.transToData(data).filter((item, index) => {
489
+ if (type === 'all') {
490
+ return false;
491
+ }
492
+ if (type === 'error') {
493
+ return item[itemsTemp.length] && item[itemsTemp.length].v === '通过';
494
+ }
495
+ });
496
+
497
+ luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
498
+ this.setState({
499
+ data: luckysheet.transToCellData(sheetData),
500
+ errorListCheck: false,
501
+ resultData: type === 'all' ? [] : resultData.filter((item) => item.flag),
502
+ });
503
+ };
504
+
505
+ toggleData = () => {
506
+ const { showErrorData, data } = this.state;
507
+
508
+ if (showErrorData) {
509
+ luckysheet.create(this.setConfig(data));
510
+ } else {
511
+ let sheetData = luckysheet.getSheetData();
512
+ sheetData = sheetData.filter((item, index) => {
513
+ return !item[itemsTemp.length] || item[itemsTemp.length].v !== '通过';
514
+ });
515
+
516
+ luckysheet.create(this.setConfig(luckysheet.transToCellData(sheetData)));
517
+ }
518
+
519
+ this.setState({
520
+ showErrorData: !showErrorData,
521
+ });
522
+ };
523
+
524
+ onChange = (e) => {
525
+ this.setState({
526
+ radioValue: e.target.value,
527
+ });
528
+ this.toggleData();
529
+ };
530
+
531
+ errorChange = (e: any) => {
532
+ this.toggleData();
533
+ this.setState({
534
+ errorListCheck: e.target.checked,
535
+ });
536
+ };
537
+
538
+ menuList = (
539
+ <Menu>
540
+ <Menu.Item key="1" className="sheet_table-menu_item_text">
541
+ <a onClick={() => this.filterData('all')}>清空全部数据</a>
542
+ </Menu.Item>
543
+ <Menu.Divider />
544
+ <Menu.Item key="2" className="sheet_table-menu_item_text">
545
+ <a onClick={() => this.filterData('error')}>仅清空错误数据</a>
546
+ </Menu.Item>
547
+ </Menu>
548
+ );
549
+
550
+ leftMenu = (
551
+ <Menu>
552
+ <Menu.Item key="3" className="sheet_table-menu_item_text">
553
+ <span className="sheet_table_text">请拖动字段来对应列</span>
554
+ </Menu.Item>
555
+ <Menu.Divider />
556
+ <div>
557
+ <DragDropContext onDragEnd={(e) => this.onDragEnd(e)}>
558
+ <Droppable droppableId="droppable" direction="vertical">
559
+ {(provided, snapshot) => (
560
+ <div
561
+ ref={provided.innerRef}
562
+ style={{
563
+ ...getListStyle(snapshot.isDraggingOver),
564
+ flexDirection: 'column',
565
+ }}
566
+ {...provided.droppableProps}
567
+ >
568
+ {this.state.items.map((item, index) => (
569
+ <Draggable key={item.id} draggableId={item.id} index={index}>
570
+ {(provided, snapshot) => (
571
+ <div
572
+ ref={provided.innerRef}
573
+ {...provided.draggableProps}
574
+ {...provided.dragHandleProps}
575
+ style={getItemStyle(
576
+ snapshot.isDragging,
577
+ provided.draggableProps.style,
578
+ )}
579
+ >
580
+ <Space>
581
+ <span>{filterLetters(index)} 列 </span>
582
+ <Space className="sheet_table_dnd_text">
583
+ <UnorderedListOutlined />
584
+ {item.content}
585
+ </Space>
586
+ </Space>
587
+ </div>
588
+ )}
589
+ </Draggable>
590
+ ))}
591
+ {provided.placeholder}
592
+ </div>
593
+ )}
594
+ </Droppable>
595
+ </DragDropContext>
596
+ </div>
597
+ </Menu>
598
+ );
599
+
600
+ render() {
601
+ const { errorListCheck } = this.state;
602
+ const { title } = this.props;
603
+
604
+ let totalSummary = this.getCount();
605
+
606
+ const luckyCss = {
607
+ margin: '0px',
608
+ padding: '0px',
609
+ position: 'absolute',
610
+ width: '100%',
611
+ height: '100%',
612
+ left: '0px',
613
+ top: '0px',
614
+ };
615
+ return (
616
+ <>
617
+ <div className="sheet_table_top">
618
+ <Space>
619
+ <span>排序列</span>
620
+ <Dropdown
621
+ trigger={['click']}
622
+ overlay={this.leftMenu}
623
+ placement="bottomLeft"
624
+ >
625
+ <a>
626
+ <ProfileTwoTone />
627
+ </a>
628
+ </Dropdown>
629
+ <Tooltip
630
+ title={
631
+ <>
632
+ <span>使用指南:</span>
633
+ <br></br>
634
+ <span>
635
+ 1、拖动数据项,以适配源数据的顺序,如您Excel中数据排序依次为编码、价格和数量,则您也可以将数据项的顺序调整为一致
636
+ </span>
637
+ <br></br>
638
+ <span>2、复制文件数据(多列一起),在文本框内进行粘贴</span>
639
+ <br></br>
640
+ <span>
641
+ 3、点击识别按钮进行数据校验,如全部正确,则点击录入按钮可录入数据,如存在错误数据,则需修改后再进行录入
642
+ </span>
643
+ </>
644
+ }
645
+ >
646
+ <ExclamationCircleOutlined />
647
+ </Tooltip>
648
+ </Space>
649
+ <Space>
650
+ <Dropdown
651
+ trigger={['click']}
652
+ overlay={this.menuList}
653
+ placement="bottomRight"
654
+ >
655
+ <Button>
656
+ 清空
657
+ <DownOutlined />
658
+ </Button>
659
+ </Dropdown>
660
+
661
+ <Button type="primary" onClick={this.resetData}>
662
+ 识别
663
+ </Button>
664
+ </Space>
665
+ </div>
666
+
667
+ <div style={{ position: 'relative', height: '400px' }}>
668
+ <div id="luckysheet" style={luckyCss}></div>
669
+ </div>
670
+ <div className="sheet_table_footer">
671
+ <span className="sheet_table_footer_l">
672
+ 共 {totalSummary.total} 条数据, 其中错误 {totalSummary.error} 项
673
+ </span>
674
+ <Space className="sheet_table_footer_r">
675
+ <Checkbox
676
+ checked={errorListCheck}
677
+ onClick={this.errorChange}
678
+ ></Checkbox>
679
+ 仅展示错误数据
680
+ </Space>
681
+ </div>
682
+ </>
683
+ );
684
+ }
685
+ }
686
+
687
+ export default DataValidation;