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