@bit-sun/business-component 2.4.26 → 2.4.28

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