@bit-sun/business-component 2.2.4 → 2.2.6

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