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

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