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

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 (167) hide show
  1. package/.fatherrc.ts +0 -1
  2. package/.umirc.ts +16 -31
  3. package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +1 -1
  4. package/dist/components/Business/SearchSelect/common.d.ts +1 -5
  5. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  6. package/dist/components/Business/SearchSelect/utils.d.ts +1 -2
  7. package/dist/components/Functional/SearchSelect/index.d.ts +1 -2
  8. package/dist/index.d.ts +0 -15
  9. package/dist/index.esm.js +4456 -19407
  10. package/dist/index.js +4443 -19411
  11. package/package.json +5 -26
  12. package/src/components/Business/CommodityEntry/index.md +3 -4
  13. package/src/components/Business/CommodityEntry/index.tsx +2 -7
  14. package/src/components/Business/SearchSelect/BusinessUtils.ts +14 -107
  15. package/src/components/Business/SearchSelect/common.ts +1 -20
  16. package/src/components/Business/SearchSelect/index.md +30 -60
  17. package/src/components/Business/SearchSelect/index.tsx +12 -21
  18. package/src/components/Business/SearchSelect/utils.ts +4 -30
  19. package/src/components/Functional/DataImport/index.tsx +2 -1
  20. package/src/components/Functional/DataValidation/index.tsx +1 -1
  21. package/src/components/Functional/SearchSelect/index.tsx +121 -218
  22. package/src/index.ts +6 -15
  23. package/typings.d.ts +0 -3
  24. package/dist/components/Business/AddSelectBusiness/index.d.ts +0 -1
  25. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +0 -4
  26. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +0 -4
  27. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +0 -4
  28. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +0 -17
  29. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +0 -30
  30. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +0 -3
  31. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +0 -2
  32. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +0 -4
  33. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +0 -4
  34. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +0 -2
  35. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +0 -8
  36. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +0 -8
  37. package/dist/components/Business/BsLayouts/index.d.ts +0 -18
  38. package/dist/components/Business/BsLayouts/service.d.ts +0 -1
  39. package/dist/components/Business/BsLayouts/utils.d.ts +0 -13
  40. package/dist/components/Business/BsSulaQueryTable/index.d.ts +0 -2
  41. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +0 -58
  42. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +0 -98
  43. package/dist/components/Business/CommonAlert/index.d.ts +0 -3
  44. package/dist/components/Business/CommonGuideWrapper/index.d.ts +0 -6
  45. package/dist/components/Business/DetailPageWrapper/index.d.ts +0 -9
  46. package/dist/components/Business/DetailPageWrapper/utils.d.ts +0 -8
  47. package/dist/components/Business/HomePageWrapper/index.d.ts +0 -3
  48. package/dist/components/Business/StateFlow/index.d.ts +0 -3
  49. package/dist/components/Business/TreeSearchSelect/index.d.ts +0 -3
  50. package/dist/components/Business/TreeSearchSelect/utils.d.ts +0 -2
  51. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +0 -54
  52. package/dist/components/Business/columnSettingTable/index.d.ts +0 -16
  53. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +0 -17
  54. package/dist/components/Business/columnSettingTable/utils.d.ts +0 -8
  55. package/dist/components/Functional/AddSelect/index.d.ts +0 -3
  56. package/dist/components/Functional/BillEntry/index.d.ts +0 -4
  57. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +0 -12
  58. package/dist/components/Functional/TreeSearchSelect/index.d.ts +0 -2
  59. package/dist/utils/enumConfig.d.ts +0 -10
  60. package/dist/utils/requestUtils.d.ts +0 -1
  61. package/dist/utils/utils.d.ts +0 -3
  62. package/lib/assets/arrow_top.png +0 -0
  63. package/lib/assets/drag.svg +0 -17
  64. package/lib/assets/exportFail.svg +0 -38
  65. package/lib/assets/exportProcessing.svg +0 -29
  66. package/lib/assets/exportSuccess.svg +0 -35
  67. package/lib/assets/exportlogo.png +0 -0
  68. package/lib/assets/label_icon_bottom.svg +0 -26
  69. package/lib/assets/upExport.svg +0 -23
  70. package/src/assets/32.svg +0 -28
  71. package/src/assets/addIcon.svg +0 -18
  72. package/src/assets/allfunc.svg +0 -28
  73. package/src/assets/arrowRight.svg +0 -25
  74. package/src/assets/arrow_top.png +0 -0
  75. package/src/assets/btn-delete.svg +0 -30
  76. package/src/assets/btn-edit.svg +0 -20
  77. package/src/assets/btn-more.svg +0 -18
  78. package/src/assets/btn-submit.svg +0 -20
  79. package/src/assets/caidan.svg +0 -12
  80. package/src/assets/close.svg +0 -26
  81. package/src/assets/closeicon.png +0 -0
  82. package/src/assets/drag.svg +0 -17
  83. package/src/assets/exportFail.svg +0 -38
  84. package/src/assets/exportProcessing.svg +0 -29
  85. package/src/assets/exportSuccess.svg +0 -35
  86. package/src/assets/exportlogo.png +0 -0
  87. package/src/assets/fixed-left-active.svg +0 -12
  88. package/src/assets/fixed-left.svg +0 -16
  89. package/src/assets/fixed-right-active.svg +0 -12
  90. package/src/assets/fixed-right.svg +0 -16
  91. package/src/assets/guanbi.svg +0 -16
  92. package/src/assets/icon-quanping.svg +0 -16
  93. package/src/assets/icon-shezhi.svg +0 -18
  94. package/src/assets/label_icon_bottom.svg +0 -26
  95. package/src/assets/list-no-img.svg +0 -22
  96. package/src/assets/morentouxiang-32.svg +0 -24
  97. package/src/assets/right.png +0 -0
  98. package/src/assets/scanning.svg +0 -25
  99. package/src/assets/upExport.svg +0 -23
  100. package/src/assets/xinglan-icon-out.png +0 -0
  101. package/src/components/Business/AddSelectBusiness/index.md +0 -41
  102. package/src/components/Business/AddSelectBusiness/index.tsx +0 -290
  103. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +0 -112
  104. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +0 -153
  105. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +0 -70
  106. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +0 -90
  107. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +0 -38
  108. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +0 -243
  109. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +0 -385
  110. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +0 -286
  111. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +0 -75
  112. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +0 -171
  113. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +0 -65
  114. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +0 -154
  115. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +0 -73
  116. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +0 -158
  117. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +0 -85
  118. package/src/components/Business/BsLayouts/Components/RightContent/home.less +0 -218
  119. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +0 -156
  120. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +0 -161
  121. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +0 -76
  122. package/src/components/Business/BsLayouts/index.less +0 -80
  123. package/src/components/Business/BsLayouts/index.tsx +0 -1465
  124. package/src/components/Business/BsLayouts/service.ts +0 -11
  125. package/src/components/Business/BsLayouts/utils.tsx +0 -211
  126. package/src/components/Business/BsSulaQueryTable/index.less +0 -220
  127. package/src/components/Business/BsSulaQueryTable/index.tsx +0 -505
  128. package/src/components/Business/BsSulaQueryTable/setting.tsx +0 -799
  129. package/src/components/Business/BsSulaQueryTable/utils.less +0 -65
  130. package/src/components/Business/BsSulaQueryTable/utils.tsx +0 -688
  131. package/src/components/Business/CommonAlert/index.less +0 -0
  132. package/src/components/Business/CommonAlert/index.tsx +0 -23
  133. package/src/components/Business/CommonGuideWrapper/index.less +0 -112
  134. package/src/components/Business/CommonGuideWrapper/index.md +0 -39
  135. package/src/components/Business/CommonGuideWrapper/index.tsx +0 -84
  136. package/src/components/Business/DetailPageWrapper/index.less +0 -80
  137. package/src/components/Business/DetailPageWrapper/index.tsx +0 -335
  138. package/src/components/Business/DetailPageWrapper/utils.tsx +0 -101
  139. package/src/components/Business/HomePageWrapper/index.less +0 -33
  140. package/src/components/Business/HomePageWrapper/index.md +0 -45
  141. package/src/components/Business/HomePageWrapper/index.tsx +0 -162
  142. package/src/components/Business/StateFlow/index.less +0 -131
  143. package/src/components/Business/StateFlow/index.md +0 -60
  144. package/src/components/Business/StateFlow/index.tsx +0 -30
  145. package/src/components/Business/TreeSearchSelect/index.md +0 -126
  146. package/src/components/Business/TreeSearchSelect/index.tsx +0 -34
  147. package/src/components/Business/TreeSearchSelect/utils.ts +0 -60
  148. package/src/components/Business/columnSettingTable/columnSetting.tsx +0 -764
  149. package/src/components/Business/columnSettingTable/index.less +0 -247
  150. package/src/components/Business/columnSettingTable/index.md +0 -358
  151. package/src/components/Business/columnSettingTable/index.tsx +0 -233
  152. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +0 -241
  153. package/src/components/Business/columnSettingTable/utils.tsx +0 -69
  154. package/src/components/Functional/AddSelect/index.less +0 -367
  155. package/src/components/Functional/AddSelect/index.md +0 -122
  156. package/src/components/Functional/AddSelect/index.tsx +0 -962
  157. package/src/components/Functional/BillEntry/index.less +0 -371
  158. package/src/components/Functional/BillEntry/index.md +0 -39
  159. package/src/components/Functional/BillEntry/index.tsx +0 -613
  160. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +0 -37
  161. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +0 -59
  162. package/src/components/Functional/TreeSearchSelect/index.md +0 -47
  163. package/src/components/Functional/TreeSearchSelect/index.tsx +0 -149
  164. package/src/styles/bsDefault.less +0 -1907
  165. package/src/utils/enumConfig.ts +0 -10
  166. package/src/utils/requestUtils.ts +0 -33
  167. package/src/utils/utils.ts +0 -52
@@ -1,799 +0,0 @@
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;