@bit-sun/business-component 2.0.40 → 2.1.0

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