@bit-sun/business-component 3.0.0-alpha.21 → 3.0.0-alpha.23

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