@bit-sun/business-component 2.2.35 → 2.2.36

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 (191) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -1
  9. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +1 -1
  10. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  11. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  12. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +2 -2
  13. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +2 -2
  14. package/dist/components/Business/BsLayouts/index.d.ts +2 -2
  15. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +2 -2
  16. package/dist/components/Business/JsonQueryTable/static.d.ts +1 -1
  17. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  18. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  19. package/dist/index.esm.js +657 -649
  20. package/dist/index.js +657 -649
  21. package/dist/utils/TableUtils.d.ts +2 -2
  22. package/dist/utils/utils.d.ts +1 -1
  23. package/docs/index.md +21 -21
  24. package/lib/assets/drag.svg +17 -17
  25. package/lib/assets/exportFail.svg +37 -37
  26. package/lib/assets/exportProcessing.svg +28 -28
  27. package/lib/assets/exportSuccess.svg +34 -34
  28. package/lib/assets/label_icon_bottom.svg +25 -25
  29. package/lib/assets/upExport.svg +22 -22
  30. package/package.json +1 -1
  31. package/src/assets/32.svg +27 -27
  32. package/src/assets/addIcon.svg +17 -17
  33. package/src/assets/allfunc.svg +27 -27
  34. package/src/assets/arrowRight.svg +24 -24
  35. package/src/assets/btn-delete.svg +29 -29
  36. package/src/assets/btn-edit.svg +19 -19
  37. package/src/assets/btn-more.svg +17 -17
  38. package/src/assets/btn-submit.svg +19 -19
  39. package/src/assets/caidan.svg +11 -11
  40. package/src/assets/close.svg +26 -26
  41. package/src/assets/drag.svg +17 -17
  42. package/src/assets/exportFail.svg +37 -37
  43. package/src/assets/exportProcessing.svg +28 -28
  44. package/src/assets/exportSuccess.svg +34 -34
  45. package/src/assets/fixed-left-active.svg +11 -11
  46. package/src/assets/fixed-left.svg +15 -15
  47. package/src/assets/fixed-right-active.svg +11 -11
  48. package/src/assets/fixed-right.svg +15 -15
  49. package/src/assets/guanbi.svg +15 -15
  50. package/src/assets/icon-quanping.svg +15 -15
  51. package/src/assets/icon-shezhi.svg +17 -17
  52. package/src/assets/label_icon_bottom.svg +25 -25
  53. package/src/assets/list-no-img.svg +21 -21
  54. package/src/assets/morentouxiang-32.svg +23 -23
  55. package/src/assets/scanning.svg +24 -24
  56. package/src/assets/upExport.svg +22 -22
  57. package/src/components/Business/AddSelectBusiness/index.md +161 -161
  58. package/src/components/Business/AddSelectBusiness/index.tsx +861 -861
  59. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  60. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  61. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  64. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  65. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  66. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  67. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  68. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  69. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  70. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  71. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  72. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  73. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  74. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  75. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  76. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  77. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  78. package/src/components/Business/BsLayouts/index.less +79 -79
  79. package/src/components/Business/BsLayouts/index.tsx +1484 -1484
  80. package/src/components/Business/BsLayouts/service.ts +10 -10
  81. package/src/components/Business/BsLayouts/utils.tsx +203 -203
  82. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -538
  83. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  84. package/src/components/Business/BsSulaQueryTable/index.tsx +527 -527
  85. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  86. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  87. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  88. package/src/components/Business/CommodityEntry/index.md +70 -70
  89. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  90. package/src/components/Business/CommonAlert/index.tsx +23 -23
  91. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  92. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  93. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  94. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  95. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  96. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  97. package/src/components/Business/HomePageWrapper/index.less +33 -33
  98. package/src/components/Business/HomePageWrapper/index.md +45 -45
  99. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  100. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  101. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  102. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  103. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  104. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  105. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  106. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  107. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  108. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  109. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  110. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  111. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  112. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  113. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  114. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  115. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  116. package/src/components/Business/JsonQueryTable/index.less +16 -16
  117. package/src/components/Business/JsonQueryTable/index.md +328 -328
  118. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  119. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  120. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  121. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  122. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  123. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  124. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  125. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  126. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  127. package/src/components/Business/JsonQueryTable/static.ts +390 -390
  128. package/src/components/Business/SearchSelect/BusinessUtils.ts +1731 -1730
  129. package/src/components/Business/SearchSelect/common.ts +53 -53
  130. package/src/components/Business/SearchSelect/index.md +1319 -1319
  131. package/src/components/Business/SearchSelect/index.tsx +51 -51
  132. package/src/components/Business/SearchSelect/utils.ts +100 -100
  133. package/src/components/Business/StateFlow/index.less +130 -130
  134. package/src/components/Business/StateFlow/index.md +60 -60
  135. package/src/components/Business/StateFlow/index.tsx +29 -29
  136. package/src/components/Business/TreeSearchSelect/index.md +154 -154
  137. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  138. package/src/components/Business/TreeSearchSelect/utils.ts +69 -69
  139. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  140. package/src/components/Business/columnSettingTable/index.less +247 -247
  141. package/src/components/Business/columnSettingTable/index.md +357 -357
  142. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  143. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  144. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  145. package/src/components/Business/moreTreeTable/index.less +99 -99
  146. package/src/components/Business/moreTreeTable/index.md +448 -448
  147. package/src/components/Business/moreTreeTable/index.tsx +23 -23
  148. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  149. package/src/components/Functional/AddSelect/helps.ts +14 -14
  150. package/src/components/Functional/AddSelect/index.less +367 -367
  151. package/src/components/Functional/AddSelect/index.md +155 -155
  152. package/src/components/Functional/AddSelect/index.tsx +1279 -1272
  153. package/src/components/Functional/BillEntry/index.less +371 -371
  154. package/src/components/Functional/BillEntry/index.md +39 -39
  155. package/src/components/Functional/BillEntry/index.tsx +772 -766
  156. package/src/components/Functional/DataImport/index.less +63 -63
  157. package/src/components/Functional/DataImport/index.md +44 -44
  158. package/src/components/Functional/DataImport/index.tsx +695 -695
  159. package/src/components/Functional/DataValidation/index.less +63 -63
  160. package/src/components/Functional/DataValidation/index.md +39 -39
  161. package/src/components/Functional/DataValidation/index.tsx +687 -687
  162. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  163. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  164. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  165. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  166. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  167. package/src/components/Functional/SearchSelect/index.less +115 -115
  168. package/src/components/Functional/SearchSelect/index.md +141 -141
  169. package/src/components/Functional/SearchSelect/index.tsx +849 -849
  170. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  171. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  172. package/src/components/Functional/TreeSearchSelect/index.tsx +162 -162
  173. package/src/index.ts +34 -34
  174. package/src/plugin/TableColumnSetting/index.less +247 -247
  175. package/src/plugin/TableColumnSetting/index.md +50 -50
  176. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  177. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  178. package/src/styles/bsDefault.less +1912 -1912
  179. package/src/utils/CheckOneUser/index.md +39 -39
  180. package/src/utils/CheckOneUser/index.ts +51 -51
  181. package/src/utils/LocalstorageUtils.ts +90 -90
  182. package/src/utils/TableUtils.tsx +18 -18
  183. package/src/utils/checkUtils.ts +39 -39
  184. package/src/utils/enumConfig.ts +11 -11
  185. package/src/utils/getFormMode.js +12 -12
  186. package/src/utils/index.ts +3 -3
  187. package/src/utils/requestUtils.ts +34 -34
  188. package/src/utils/serialize.js +7 -7
  189. package/src/utils/utils.ts +183 -183
  190. package/tsconfig.json +29 -29
  191. package/typings.d.ts +4 -4
@@ -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;