@bit-sun/business-component 2.4.31-alpha.9 → 2.4.32

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