@bit-sun/business-component 1.2.3 → 1.2.4-alpha.1

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 (169) hide show
  1. package/.fatherrc.ts +1 -0
  2. package/.umirc.ts +31 -16
  3. package/dist/components/Business/AddSelectBusiness/index.d.ts +1 -0
  4. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +4 -0
  5. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +4 -0
  6. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +4 -0
  7. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +17 -0
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +30 -0
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +3 -0
  10. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +2 -0
  11. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +4 -0
  12. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +4 -0
  13. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +2 -0
  14. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +8 -0
  15. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +8 -0
  16. package/dist/components/Business/BsLayouts/index.d.ts +18 -0
  17. package/dist/components/Business/BsLayouts/service.d.ts +1 -0
  18. package/dist/components/Business/BsLayouts/utils.d.ts +13 -0
  19. package/dist/components/Business/BsSulaQueryTable/index.d.ts +2 -0
  20. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +58 -0
  21. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +98 -0
  22. package/dist/components/Business/CommonAlert/index.d.ts +3 -0
  23. package/dist/components/Business/CommonGuideWrapper/index.d.ts +6 -0
  24. package/dist/components/Business/DetailPageWrapper/index.d.ts +9 -0
  25. package/dist/components/Business/DetailPageWrapper/utils.d.ts +8 -0
  26. package/dist/components/Business/HomePageWrapper/index.d.ts +3 -0
  27. package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +1 -1
  28. package/dist/components/Business/SearchSelect/common.d.ts +5 -1
  29. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  30. package/dist/components/Business/SearchSelect/utils.d.ts +2 -1
  31. package/dist/components/Business/StateFlow/index.d.ts +3 -0
  32. package/dist/components/Business/TreeSearchSelect/index.d.ts +3 -0
  33. package/dist/components/Business/TreeSearchSelect/utils.d.ts +2 -0
  34. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +54 -0
  35. package/dist/components/Business/columnSettingTable/index.d.ts +16 -0
  36. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +17 -0
  37. package/dist/components/Business/columnSettingTable/utils.d.ts +8 -0
  38. package/dist/components/Functional/AddSelect/index.d.ts +3 -0
  39. package/dist/components/Functional/BillEntry/index.d.ts +4 -0
  40. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +12 -0
  41. package/dist/components/Functional/SearchSelect/index.d.ts +2 -1
  42. package/dist/components/Functional/TreeSearchSelect/index.d.ts +2 -0
  43. package/dist/index.d.ts +15 -0
  44. package/dist/index.esm.js +19420 -4457
  45. package/dist/index.js +19451 -4471
  46. package/dist/utils/CheckOneUser/index.d.ts +1 -1
  47. package/dist/utils/enumConfig.d.ts +10 -0
  48. package/dist/utils/requestUtils.d.ts +1 -0
  49. package/dist/utils/utils.d.ts +3 -0
  50. package/lib/assets/arrow_top.png +0 -0
  51. package/lib/assets/drag.svg +17 -0
  52. package/lib/assets/exportFail.svg +38 -0
  53. package/lib/assets/exportProcessing.svg +29 -0
  54. package/lib/assets/exportSuccess.svg +35 -0
  55. package/lib/assets/exportlogo.png +0 -0
  56. package/lib/assets/label_icon_bottom.svg +26 -0
  57. package/lib/assets/upExport.svg +23 -0
  58. package/package.json +26 -5
  59. package/src/assets/32.svg +28 -0
  60. package/src/assets/addIcon.svg +18 -0
  61. package/src/assets/allfunc.svg +28 -0
  62. package/src/assets/arrowRight.svg +25 -0
  63. package/src/assets/arrow_top.png +0 -0
  64. package/src/assets/btn-delete.svg +30 -0
  65. package/src/assets/btn-edit.svg +20 -0
  66. package/src/assets/btn-more.svg +18 -0
  67. package/src/assets/btn-submit.svg +20 -0
  68. package/src/assets/caidan.svg +12 -0
  69. package/src/assets/close.svg +26 -0
  70. package/src/assets/closeicon.png +0 -0
  71. package/src/assets/drag.svg +17 -0
  72. package/src/assets/exportFail.svg +38 -0
  73. package/src/assets/exportProcessing.svg +29 -0
  74. package/src/assets/exportSuccess.svg +35 -0
  75. package/src/assets/exportlogo.png +0 -0
  76. package/src/assets/fixed-left-active.svg +12 -0
  77. package/src/assets/fixed-left.svg +16 -0
  78. package/src/assets/fixed-right-active.svg +12 -0
  79. package/src/assets/fixed-right.svg +16 -0
  80. package/src/assets/guanbi.svg +16 -0
  81. package/src/assets/icon-quanping.svg +16 -0
  82. package/src/assets/icon-shezhi.svg +18 -0
  83. package/src/assets/label_icon_bottom.svg +26 -0
  84. package/src/assets/list-no-img.svg +22 -0
  85. package/src/assets/morentouxiang-32.svg +24 -0
  86. package/src/assets/right.png +0 -0
  87. package/src/assets/scanning.svg +25 -0
  88. package/src/assets/upExport.svg +23 -0
  89. package/src/assets/xinglan-icon-out.png +0 -0
  90. package/src/components/Business/AddSelectBusiness/index.md +41 -0
  91. package/src/components/Business/AddSelectBusiness/index.tsx +290 -0
  92. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -0
  93. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -0
  94. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -0
  95. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -0
  96. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +38 -0
  97. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +243 -0
  98. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +385 -0
  99. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +286 -0
  100. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +75 -0
  101. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +171 -0
  102. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +65 -0
  103. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +154 -0
  104. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +73 -0
  105. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +158 -0
  106. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -0
  107. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -0
  108. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -0
  109. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +161 -0
  110. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +76 -0
  111. package/src/components/Business/BsLayouts/index.less +80 -0
  112. package/src/components/Business/BsLayouts/index.tsx +1465 -0
  113. package/src/components/Business/BsLayouts/service.ts +11 -0
  114. package/src/components/Business/BsLayouts/utils.tsx +211 -0
  115. package/src/components/Business/BsSulaQueryTable/index.less +220 -0
  116. package/src/components/Business/BsSulaQueryTable/index.tsx +505 -0
  117. package/src/components/Business/BsSulaQueryTable/setting.tsx +799 -0
  118. package/src/components/Business/BsSulaQueryTable/utils.less +65 -0
  119. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -0
  120. package/src/components/Business/CommodityEntry/index.md +4 -3
  121. package/src/components/Business/CommodityEntry/index.tsx +7 -2
  122. package/src/components/Business/CommonAlert/index.less +0 -0
  123. package/src/components/Business/CommonAlert/index.tsx +23 -0
  124. package/src/components/Business/CommonGuideWrapper/index.less +112 -0
  125. package/src/components/Business/CommonGuideWrapper/index.md +39 -0
  126. package/src/components/Business/CommonGuideWrapper/index.tsx +84 -0
  127. package/src/components/Business/DetailPageWrapper/index.less +80 -0
  128. package/src/components/Business/DetailPageWrapper/index.tsx +335 -0
  129. package/src/components/Business/DetailPageWrapper/utils.tsx +101 -0
  130. package/src/components/Business/HomePageWrapper/index.less +33 -0
  131. package/src/components/Business/HomePageWrapper/index.md +45 -0
  132. package/src/components/Business/HomePageWrapper/index.tsx +162 -0
  133. package/src/components/Business/SearchSelect/BusinessUtils.ts +107 -14
  134. package/src/components/Business/SearchSelect/common.ts +20 -1
  135. package/src/components/Business/SearchSelect/index.md +60 -30
  136. package/src/components/Business/SearchSelect/index.tsx +21 -12
  137. package/src/components/Business/SearchSelect/utils.ts +30 -4
  138. package/src/components/Business/StateFlow/index.less +131 -0
  139. package/src/components/Business/StateFlow/index.md +60 -0
  140. package/src/components/Business/StateFlow/index.tsx +30 -0
  141. package/src/components/Business/TreeSearchSelect/index.md +126 -0
  142. package/src/components/Business/TreeSearchSelect/index.tsx +34 -0
  143. package/src/components/Business/TreeSearchSelect/utils.ts +60 -0
  144. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -0
  145. package/src/components/Business/columnSettingTable/index.less +247 -0
  146. package/src/components/Business/columnSettingTable/index.md +358 -0
  147. package/src/components/Business/columnSettingTable/index.tsx +233 -0
  148. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +241 -0
  149. package/src/components/Business/columnSettingTable/utils.tsx +69 -0
  150. package/src/components/Functional/AddSelect/index.less +367 -0
  151. package/src/components/Functional/AddSelect/index.md +122 -0
  152. package/src/components/Functional/AddSelect/index.tsx +962 -0
  153. package/src/components/Functional/BillEntry/index.less +371 -0
  154. package/src/components/Functional/BillEntry/index.md +39 -0
  155. package/src/components/Functional/BillEntry/index.tsx +613 -0
  156. package/src/components/Functional/DataImport/index.tsx +7 -2
  157. package/src/components/Functional/DataValidation/index.md +1 -0
  158. package/src/components/Functional/DataValidation/index.tsx +17 -2
  159. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -0
  160. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -0
  161. package/src/components/Functional/SearchSelect/index.tsx +218 -121
  162. package/src/components/Functional/TreeSearchSelect/index.md +47 -0
  163. package/src/components/Functional/TreeSearchSelect/index.tsx +149 -0
  164. package/src/index.ts +15 -6
  165. package/src/styles/bsDefault.less +1907 -0
  166. package/src/utils/enumConfig.ts +10 -0
  167. package/src/utils/requestUtils.ts +33 -0
  168. package/src/utils/utils.ts +52 -0
  169. package/typings.d.ts +3 -0
@@ -0,0 +1,799 @@
1
+ // @ts-nocheck
2
+ import React from 'react';
3
+ import {
4
+ Table,
5
+ message,
6
+ Checkbox,
7
+ Modal,
8
+ Input,
9
+ Button,
10
+ Tooltip,
11
+ } from 'antd';
12
+ import {
13
+ SortableContainer,
14
+ SortableElement,
15
+ SortableHandle,
16
+ } from 'react-sortable-hoc';
17
+ import axios from 'axios';
18
+ import { SearchOutlined } from '@ant-design/icons';
19
+ import { arrayMoveImmutable } from 'array-move';
20
+ import shezhi from '../../../assets/icon-shezhi.svg';
21
+ import close from '../../../assets/close.svg';
22
+ import drag from '../../../assets/drag.svg';
23
+ import fixedLeft from '../../../assets/fixed-left.svg';
24
+ import fixedLeftActive from '../../../assets/fixed-left-active.svg';
25
+ import fixedRight from '../../../assets/fixed-right.svg';
26
+ import fixedRightActive from '../../../assets/fixed-right-active.svg';
27
+ import './index.less';
28
+ import ENUM from '@/utils/enumConfig';
29
+
30
+ const DragHandle = SortableHandle(() => <img src={drag} />);
31
+
32
+ const SortableItem = SortableElement((props) => <tr {...props} />);
33
+ const SortableBody = SortableContainer((props) => <tbody {...props} />);
34
+
35
+ class SortableTable extends React.Component {
36
+ state = {
37
+ dataSource: [],
38
+ columns: [],
39
+ sortDataSource: [],
40
+ setVisible: false,
41
+ searchDataSource: false,
42
+ onSearchSort: false,
43
+ isDefaultValue: false,
44
+ defaultValue: [],
45
+ };
46
+
47
+ patchUserColumnConfig = (config) => {
48
+ let configvalue = config
49
+ ? config.map((item) => ({
50
+ key: item.key,
51
+ dataIndex: item.dataIndex,
52
+ width: item.width,
53
+ hidden: item.hidden,
54
+ fixed: item.fixed,
55
+ }))
56
+ : '';
57
+ axios({
58
+ url: '/user/appConfig/saveUserOrder',
59
+ method: 'POST',
60
+ data: {
61
+ code: window.location.hash,
62
+ detail: configvalue ? JSON.stringify(configvalue) : '',
63
+ },
64
+ }).then((res:any) => {
65
+ if (res?.data?.status === '0') {
66
+ this.patchConfigToLocalstorage(configvalue)
67
+ } else {
68
+ message.error('保存表头列自定义失败,请稍后尝试');
69
+ }
70
+ })
71
+ };
72
+
73
+ getConfigFromlocalstorage = () => {
74
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]';
75
+ let configArray = JSON.parse(config);
76
+ let configSetting = configArray.filter(
77
+ (item) => item.code === window.location.hash,
78
+ );
79
+
80
+ if (configSetting.length && configSetting[0].detail) {
81
+ return JSON.parse(configSetting[0].detail);
82
+ }
83
+ return [];
84
+ };
85
+
86
+ patchConfigToLocalstorage = (configvalue) => {
87
+ const { setShowColumns } = this.props;
88
+ const { sortDataSource } = this.state;
89
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]'
90
+ let configArray = JSON.parse(config)
91
+ let currentSetting = configArray.filter(item => item.code === window.location.hash)
92
+ if (currentSetting.length) {
93
+ currentSetting[0].detail = JSON.stringify(configvalue)
94
+ } else {
95
+ configArray.push({
96
+ "code": window.location.hash,
97
+ "detail": JSON.stringify(configvalue)
98
+ })
99
+ }
100
+
101
+ localStorage.setItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION, JSON.stringify(configArray));
102
+ this.setState({
103
+ visible: false,
104
+ });
105
+ setShowColumns([...sortDataSource]);
106
+ };
107
+
108
+ setInitValue = (isClick = false) => {
109
+ const { datasource, showColumn }: any =
110
+ this.props;
111
+ let config = this.getConfigFromlocalstorage();
112
+
113
+ this.setState({
114
+ isDefaultValue: true,
115
+ dataSource: datasource.map((item) => {
116
+ let innerItem = config.filter(
117
+ (inneritem) => {
118
+ let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex) ? JSON.stringify(inneritem.key || inneritem.dataIndex) : (inneritem.key || inneritem.dataIndex);
119
+ let itemKey = Array.isArray(item.key || item.dataIndex) ? JSON.stringify(item.key || item.dataIndex) : (item.key || item.dataIndex);
120
+ return innerKey && innerKey === itemKey;
121
+ }
122
+ );
123
+ return {
124
+ ...item,
125
+ key: item.key || item.dataIndex,
126
+ width: innerItem[0]?.width || item.width,
127
+ hidden: config.length && !innerItem.length,
128
+ };
129
+ }),
130
+ defaultValue: datasource.map((item) => {
131
+ let innerItem = config.filter(
132
+ (inneritem) => {
133
+ let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex) ? JSON.stringify(inneritem.key || inneritem.dataIndex) : (inneritem.key || inneritem.dataIndex);
134
+ let itemKey = Array.isArray(item.key || item.dataIndex) ? JSON.stringify(item.key || item.dataIndex) : (item.key || item.dataIndex);
135
+ return innerKey && innerKey === itemKey;
136
+ }
137
+ );
138
+ return {
139
+ ...item,
140
+ key: item.key || item.dataIndex,
141
+ width: innerItem[0]?.width || item.width,
142
+ hidden: config.length && !innerItem.length,
143
+ };
144
+ }),
145
+ sortDataSource: [...showColumn]
146
+ });
147
+ };
148
+
149
+ componentDidMount() {
150
+ const { datasource, showColumn }: any =
151
+ this.props;
152
+ let config = this.getConfigFromlocalstorage();
153
+
154
+ this.setState({
155
+ dataSource: datasource.map((item) => {
156
+ let innerItem = config.filter(
157
+ (inneritem) => {
158
+ let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex) ? JSON.stringify(inneritem.key || inneritem.dataIndex) : (inneritem.key || inneritem.dataIndex);
159
+ let itemKey = Array.isArray(item.key || item.dataIndex) ? JSON.stringify(item.key || item.dataIndex) : (item.key || item.dataIndex);
160
+ return innerKey && innerKey === itemKey;
161
+ }
162
+ );
163
+ return {
164
+ ...item,
165
+ key: item.key || item.dataIndex,
166
+ width: innerItem[0]?.width || item.width,
167
+ hidden: config.length && !innerItem.length,
168
+ };
169
+ }),
170
+ defaultValue: datasource.map((item) => {
171
+ let innerItem = config.filter(
172
+ (inneritem) => {
173
+ let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex) ? JSON.stringify(inneritem.key || inneritem.dataIndex) : (inneritem.key || inneritem.dataIndex);
174
+ let itemKey = Array.isArray(item.key || item.dataIndex) ? JSON.stringify(item.key || item.dataIndex) : (item.key || item.dataIndex);
175
+ return innerKey && innerKey === itemKey;
176
+ }
177
+ );
178
+ return {
179
+ ...item,
180
+ key: item.key || item.dataIndex,
181
+ width: innerItem[0]?.width || item.width,
182
+ hidden: config.length && !innerItem.length,
183
+ };
184
+ }),
185
+ sortDataSource: datasource
186
+ .filter((item) => !item.hidden)
187
+ .map((item) => ({
188
+ ...item,
189
+ key: item.key || item.dataIndex,
190
+ width:
191
+ showColumn.filter(
192
+ (inneritem) => {
193
+ let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex) ? JSON.stringify(inneritem.key || inneritem.dataIndex) : (inneritem.key || inneritem.dataIndex);
194
+ let itemKey = Array.isArray(item.key || item.dataIndex) ? JSON.stringify(item.key || item.dataIndex) : (item.key || item.dataIndex);
195
+ return innerKey && innerKey === itemKey;
196
+ }
197
+ )[0]?.width || item.width,
198
+ })),
199
+ });
200
+ }
201
+
202
+ columns = [
203
+ {
204
+ title: '列名称',
205
+ dataIndex: 'title',
206
+ className: 'drag-visible',
207
+ width: 100,
208
+ },
209
+ {
210
+ title: '列首',
211
+ dataIndex: 'fixedLeft',
212
+ render: (text, record) => {
213
+ return (
214
+ <span
215
+ onClick={() => {
216
+ const { sortDataSource } = this.state;
217
+ if (record?.fixed !== 'left') {
218
+ let newSortData = sortDataSource.map((item) => {
219
+ if (item.title === record.title) {
220
+ return {
221
+ ...item,
222
+ fixed: 'left',
223
+ };
224
+ }
225
+ return item;
226
+ });
227
+ this.setState({
228
+ sortDataSource: [
229
+ ...newSortData.filter((item) => item.fixed === 'left'),
230
+ ...newSortData.filter((item) => !item.fixed),
231
+ ...newSortData.filter((item) => item.fixed === 'right'),
232
+ ],
233
+ isDefaultValue: false,
234
+ dataSource: [
235
+ ...this.state.dataSource.map((item) => {
236
+ if (item.title === record.title) {
237
+ return {
238
+ ...item,
239
+ fixed: 'left',
240
+ };
241
+ }
242
+ return item;
243
+ }),
244
+ ],
245
+ });
246
+ } else {
247
+ let newSortData = sortDataSource.map((item) => {
248
+ if (item.title === record.title) {
249
+ return {
250
+ ...item,
251
+ fixed: null,
252
+ };
253
+ }
254
+ return item;
255
+ });
256
+ this.setState({
257
+ sortDataSource: [
258
+ ...newSortData.filter((item) => item.fixed === 'left'),
259
+ ...newSortData.filter((item) => !item.fixed),
260
+ ...newSortData.filter((item) => item.fixed === 'right'),
261
+ ],
262
+ isDefaultValue: false,
263
+ dataSource: [
264
+ ...this.state.dataSource.map((item) => {
265
+ if (item.title === record.title) {
266
+ return {
267
+ ...item,
268
+ fixed: null,
269
+ };
270
+ }
271
+ return item;
272
+ }),
273
+ ],
274
+ });
275
+ }
276
+ }}
277
+ >
278
+ <Tooltip
279
+ placement="top"
280
+ title={record?.fixed === 'left' ? '取消固定' : '固定列首'}
281
+ >
282
+ <img
283
+ src={record?.fixed === 'left' ? fixedLeftActive : fixedLeft}
284
+ />
285
+ </Tooltip>
286
+ </span>
287
+ );
288
+ },
289
+ },
290
+ {
291
+ title: '列尾',
292
+ dataIndex: 'fixedRight',
293
+ render: (text, record) => {
294
+ return (
295
+ <span
296
+ onClick={() => {
297
+ const { sortDataSource } = this.state;
298
+ if (record?.fixed !== 'right') {
299
+ let newSortData = sortDataSource.map((item) => {
300
+ if (item.title === record.title) {
301
+ return {
302
+ ...item,
303
+ fixed: 'right',
304
+ };
305
+ }
306
+ return item;
307
+ });
308
+ this.setState({
309
+ sortDataSource: [
310
+ ...newSortData.filter((item) => item.fixed === 'left'),
311
+ ...newSortData.filter((item) => !item.fixed),
312
+ ...newSortData.filter((item) => item.fixed === 'right'),
313
+ ],
314
+ isDefaultValue: false,
315
+ dataSource: [
316
+ ...this.state.dataSource.map((item) => {
317
+ if (item.title === record.title) {
318
+ return {
319
+ ...item,
320
+ fixed: 'right',
321
+ };
322
+ }
323
+ return item;
324
+ }),
325
+ ],
326
+ });
327
+ } else {
328
+ let newSortData = sortDataSource.map((item) => {
329
+ if (item.title === record.title) {
330
+ return {
331
+ ...item,
332
+ fixed: null,
333
+ };
334
+ }
335
+ return item;
336
+ });
337
+ this.setState({
338
+ sortDataSource: [
339
+ ...newSortData.filter((item) => item.fixed === 'left'),
340
+ ...newSortData.filter((item) => !item.fixed),
341
+ ...newSortData.filter((item) => item.fixed === 'right'),
342
+ ],
343
+ isDefaultValue: false,
344
+ dataSource: [
345
+ ...this.state.dataSource.map((item) => {
346
+ if (item.title === record.title) {
347
+ return {
348
+ ...item,
349
+ fixed: null,
350
+ };
351
+ }
352
+ return item;
353
+ }),
354
+ ],
355
+ });
356
+ }
357
+ }}
358
+ >
359
+ <Tooltip
360
+ placement="top"
361
+ title={record?.fixed === 'right' ? '取消固定' : '固定列尾'}
362
+ >
363
+ <img
364
+ src={record?.fixed === 'right' ? fixedRightActive : fixedRight}
365
+ />
366
+ </Tooltip>
367
+ </span>
368
+ );
369
+ },
370
+ },
371
+ {
372
+ title: '删除',
373
+ dataIndex: 'title1',
374
+ render: (text, record) => {
375
+ return (
376
+ <span
377
+ onClick={() => {
378
+ this.setState({
379
+ sortDataSource: this.state.sortDataSource.filter((item) => {
380
+ return item.title !== record.title;
381
+ }),
382
+ isDefaultValue: false,
383
+ dataSource: [
384
+ ...this.state.dataSource.map((item) => {
385
+ if (item.title === record.title) {
386
+ return {
387
+ ...item,
388
+ hidden: true,
389
+ };
390
+ }
391
+
392
+ return item;
393
+ }),
394
+ ],
395
+ });
396
+ }}
397
+ >
398
+ <img src={close} />
399
+ </span>
400
+ );
401
+ },
402
+ },
403
+ {
404
+ title: 'Sort',
405
+ dataIndex: 'sort',
406
+ className: 'drag-visible',
407
+ render: () => <DragHandle />,
408
+ },
409
+ ];
410
+
411
+ showModal = () => {
412
+ this.setState({
413
+ visible: true,
414
+ });
415
+ this.setInitValue();
416
+ };
417
+
418
+ handleOk = (e?: React.MouseEvent<HTMLElement>) => {
419
+ const { sortDataSource, isDefaultValue, defaultValue } = this.state;
420
+ if (!sortDataSource.length) {
421
+ message.warning('至少选择一列!');
422
+ return;
423
+ }
424
+ // if (isDefaultValue) {
425
+ // this.patchUserColumnConfig('');
426
+ // return;
427
+ // }
428
+ this.patchUserColumnConfig(sortDataSource);
429
+ };
430
+
431
+ handleCancel = (e: React.MouseEvent<HTMLElement>) => {
432
+ console.log(e);
433
+ this.setState({
434
+ visible: false,
435
+ });
436
+ };
437
+
438
+ handleTableHeadHidden = (title: string) => {
439
+ const { sortDataSource, dataSource } = this.state;
440
+ this.setState(
441
+ {
442
+ sortDataSource: sortDataSource.filter((item) => {
443
+ return item.title !== title;
444
+ }),
445
+ dataSource: [
446
+ ...dataSource.map((item) => {
447
+ if (item.title === title) {
448
+ return {
449
+ ...item,
450
+ hidden: true,
451
+ };
452
+ }
453
+
454
+ return item;
455
+ }),
456
+ ],
457
+ },
458
+ () => {
459
+ this.handleOk();
460
+ },
461
+ );
462
+ };
463
+
464
+ onSortEnd = ({ oldIndex, newIndex }) => {
465
+ const { sortDataSource } = this.state;
466
+ if (oldIndex !== newIndex) {
467
+ const newData = arrayMoveImmutable(
468
+ [].concat(sortDataSource),
469
+ oldIndex,
470
+ newIndex,
471
+ ).filter((el) => !!el);
472
+ this.setState({
473
+ sortDataSource: [
474
+ ...newData.filter((item) => item.fixed === 'left'),
475
+ ...newData.filter((item) => !item.fixed),
476
+ ...newData.filter((item) => item.fixed === 'right'),
477
+ ],
478
+ isDefaultValue: false,
479
+ });
480
+ }
481
+ };
482
+
483
+ DraggableContainer = (props) => (
484
+ <SortableBody
485
+ useDragHandle
486
+ disableAutoscroll
487
+ helperClass="row-dragging"
488
+ onSortEnd={this.onSortEnd}
489
+ {...props}
490
+ />
491
+ );
492
+
493
+ DraggableBodyRow = ({ className, style, ...restProps }) => {
494
+ const { sortDataSource } = this.state;
495
+ // function findIndex base on Table rowKey props and should always be a right array index
496
+ const index = sortDataSource.findIndex(
497
+ (x) => x.key === restProps['data-row-key'],
498
+ );
499
+ return <SortableItem index={index} {...restProps} />;
500
+ };
501
+
502
+ onChange = (e: CheckboxChangeEvent, title) => {
503
+ const { sortDataSource, dataSource } = this.state;
504
+ if (!e.target.checked) {
505
+ this.setState({
506
+ sortDataSource: sortDataSource.filter((item) => {
507
+ return item.title !== title;
508
+ }),
509
+ isDefaultValue: false,
510
+ dataSource: [
511
+ ...dataSource.map((item) => {
512
+ if (item.title === title) {
513
+ return {
514
+ ...item,
515
+ hidden: true,
516
+ };
517
+ }
518
+
519
+ return item;
520
+ }),
521
+ ],
522
+ });
523
+ } else {
524
+ let fixedLeft: any[] = [];
525
+ let fixedRight: any[] = [];
526
+ let noFixedSortSource: any = [];
527
+ let newSortData = [
528
+ ...sortDataSource,
529
+ ...dataSource
530
+ .filter((item) => item.title === title)
531
+ .map((source) => {
532
+ return {
533
+ ...source,
534
+ hidden: false,
535
+ };
536
+ }),
537
+ ];
538
+ newSortData.forEach((item) => {
539
+ if (item?.fixed === 'left') {
540
+ fixedLeft.push(item);
541
+ } else if (item?.fixed === 'right') {
542
+ fixedRight.push(item);
543
+ } else {
544
+ noFixedSortSource.push(item);
545
+ }
546
+ });
547
+ this.setState({
548
+ sortDataSource: [...fixedLeft, ...noFixedSortSource, ...fixedRight],
549
+ isDefaultValue: false,
550
+ dataSource: [
551
+ ...dataSource.map((item) => {
552
+ if (item.title === title) {
553
+ return {
554
+ ...item,
555
+ hidden: false,
556
+ };
557
+ }
558
+
559
+ return item;
560
+ }),
561
+ ],
562
+ });
563
+ }
564
+ };
565
+
566
+ handleReset = () => {
567
+ this.setInitValue(true);
568
+ };
569
+
570
+ onSearch = (e: any) => {
571
+ this.setState({
572
+ searchDataSource: e.target.value,
573
+ });
574
+ };
575
+
576
+ onSearchSort = (e: any) => {
577
+ this.setState({
578
+ onSearchSort: e.target.value,
579
+ });
580
+ };
581
+
582
+ render() {
583
+ const {
584
+ dataSource,
585
+ searchDataSource,
586
+ sortDataSource,
587
+ visible,
588
+ onSearchSort,
589
+ } = this.state;
590
+
591
+ let seatchDataSource = dataSource.filter(
592
+ (item) => item?.title?.indexOf(searchDataSource || '') > -1,
593
+ );
594
+
595
+ return (
596
+ <div className={'sort_table_wrapper'}>
597
+ {visible && (
598
+ <Modal
599
+ title="设置表头内容"
600
+ wrapClassName={'sort_table_wrapper'}
601
+ width={820}
602
+ visible={visible}
603
+ onOk={this.handleOk}
604
+ onCancel={this.handleCancel}
605
+ footer={[
606
+ <Button key="back" onClick={this.handleReset}>
607
+ 恢复默认
608
+ </Button>,
609
+ <Button key="submit" onClick={this.handleCancel}>
610
+ 取消
611
+ </Button>,
612
+ <Button key="submit" type="primary" onClick={this.handleOk}>
613
+ 确认
614
+ </Button>,
615
+ ]}
616
+ >
617
+ <div className={'sort_table'}>
618
+ <div className={'sort_table_column_wrapper'}>
619
+ <span className={'sort_table_column_count'}>
620
+ 可选字段 <span>(共{dataSource.length}个)</span>
621
+ </span>
622
+ <div className={'sort_table_column'}>
623
+ <Input
624
+ prefix={<SearchOutlined className="site-form-item-icon" />}
625
+ placeholder="搜索"
626
+ allowClear
627
+ onChange={this.onSearch}
628
+ style={{ width: 540 }}
629
+ />
630
+ <div>
631
+ {!searchDataSource && (
632
+ <Checkbox
633
+ checked={
634
+ !dataSource.some((item) => {
635
+ if (item.hidden) return true;
636
+
637
+ return false;
638
+ })
639
+ }
640
+ onClick={(e) => {
641
+ this.setState({
642
+ isDefaultValue: false,
643
+ dataSource: [
644
+ ...dataSource.map((item) => {
645
+ return {
646
+ ...item,
647
+ hidden: !e.target.checked,
648
+ };
649
+ }),
650
+ ],
651
+ sortDataSource: e.target.checked
652
+ ? [
653
+ ...dataSource
654
+ .filter((item) => item.fixed === 'left')
655
+ .map((item) => ({
656
+ ...item,
657
+ hidden: false,
658
+ })),
659
+ ...dataSource
660
+ .filter((item) => !item.fixed)
661
+ .map((item) => ({
662
+ ...item,
663
+ hidden: false,
664
+ })),
665
+ ...dataSource
666
+ .filter((item) => item.fixed === 'right')
667
+ .map((item) => ({
668
+ ...item,
669
+ hidden: false,
670
+ })),
671
+ ]
672
+ : [],
673
+ });
674
+ }}
675
+ >
676
+ 全选
677
+ </Checkbox>
678
+ )}
679
+ </div>
680
+ <div className={'sort_table_column_all'}>
681
+ {searchDataSource
682
+ ? seatchDataSource.map((item) => {
683
+ return (
684
+ <Checkbox
685
+ checked={!item.hidden}
686
+ onChange={(e) => {
687
+ this.onChange(e, item.title);
688
+ }}
689
+ >
690
+ {item.title}
691
+ </Checkbox>
692
+ );
693
+ })
694
+ : dataSource
695
+ .filter(
696
+ (item) =>
697
+ item?.title?.indexOf('人') === -1 &&
698
+ item?.title?.indexOf('日期') === -1,
699
+ )
700
+ .map((item) => {
701
+ return (
702
+ <Checkbox
703
+ checked={!item.hidden}
704
+ onChange={(e) => {
705
+ this.onChange(e, item.title);
706
+ }}
707
+ >
708
+ {item.title}
709
+ </Checkbox>
710
+ );
711
+ })}
712
+ {!!seatchDataSource.length && (
713
+ <span style={{ width: '144px' }}></span>
714
+ )}
715
+
716
+ {!seatchDataSource.length && (
717
+ <div className={'sort_table_column_all_empty'}>
718
+ 未查询到结果
719
+ </div>
720
+ )}
721
+ </div>
722
+ {!searchDataSource && (
723
+ <div>
724
+ <div className={'sort_table_column_special'}>
725
+ <span>人员时间字段</span>
726
+ </div>
727
+ <div className={'sort_table_column_all'}>
728
+ {[...dataSource]
729
+ .filter(
730
+ (item) =>
731
+ item?.title?.indexOf('人') > -1 ||
732
+ item?.title?.indexOf('日期') > -1,
733
+ )
734
+ .map((item) => {
735
+ return (
736
+ <Checkbox
737
+ checked={!item.hidden}
738
+ onChange={(e) => {
739
+ this.onChange(e, item.title);
740
+ }}
741
+ >
742
+ {item.title}
743
+ </Checkbox>
744
+ );
745
+ })}
746
+ <span style={{ width: '144px' }}></span>
747
+ </div>
748
+ </div>
749
+ )}
750
+ </div>
751
+ </div>
752
+ <div className={'sort_table_content_wrapper'}>
753
+ <span className={'sort_table_content_count'}>
754
+ 已选字段 <span>(共{sortDataSource.length}个)</span>
755
+ </span>
756
+ <div className={'sort_table_content'}>
757
+ <span style={{ paddingLeft: '10px' }}>
758
+ <Input
759
+ prefix={
760
+ <SearchOutlined className="site-form-item-icon" />
761
+ }
762
+ placeholder="搜索"
763
+ allowClear
764
+ onChange={this.onSearchSort}
765
+ style={{ width: 190 }}
766
+ />
767
+ </span>
768
+ <Table
769
+ pagination={false}
770
+ showHeader={false}
771
+ dataSource={
772
+ onSearchSort
773
+ ? sortDataSource.filter(
774
+ (item) => item?.title?.indexOf(onSearchSort) > -1,
775
+ )
776
+ : sortDataSource
777
+ }
778
+ columns={this.columns}
779
+ rowKey="key"
780
+ // rowSelection={rowSelection}
781
+ components={{
782
+ body: {
783
+ wrapper: this.DraggableContainer,
784
+ row: this.DraggableBodyRow,
785
+ },
786
+ }}
787
+ />
788
+ </div>
789
+ </div>
790
+ </div>
791
+ </Modal>
792
+ )}
793
+ <img width={32} onClick={this.showModal} src={shezhi} />
794
+ </div>
795
+ );
796
+ }
797
+ }
798
+
799
+ export default SortableTable;