@bit-sun/business-component 2.0.30 → 2.0.32

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