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

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 (167) hide show
  1. package/.fatherrc.ts +0 -1
  2. package/.umirc.ts +16 -31
  3. package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +1 -1
  4. package/dist/components/Business/SearchSelect/common.d.ts +1 -5
  5. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  6. package/dist/components/Business/SearchSelect/utils.d.ts +1 -2
  7. package/dist/components/Functional/SearchSelect/index.d.ts +1 -2
  8. package/dist/index.d.ts +0 -15
  9. package/dist/index.esm.js +4456 -19407
  10. package/dist/index.js +4443 -19411
  11. package/package.json +5 -26
  12. package/src/components/Business/CommodityEntry/index.md +3 -4
  13. package/src/components/Business/CommodityEntry/index.tsx +2 -7
  14. package/src/components/Business/SearchSelect/BusinessUtils.ts +14 -107
  15. package/src/components/Business/SearchSelect/common.ts +1 -20
  16. package/src/components/Business/SearchSelect/index.md +30 -60
  17. package/src/components/Business/SearchSelect/index.tsx +12 -21
  18. package/src/components/Business/SearchSelect/utils.ts +4 -30
  19. package/src/components/Functional/DataImport/index.tsx +2 -1
  20. package/src/components/Functional/DataValidation/index.tsx +1 -1
  21. package/src/components/Functional/SearchSelect/index.tsx +121 -218
  22. package/src/index.ts +6 -15
  23. package/typings.d.ts +0 -3
  24. package/dist/components/Business/AddSelectBusiness/index.d.ts +0 -1
  25. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +0 -4
  26. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +0 -4
  27. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +0 -4
  28. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +0 -17
  29. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +0 -30
  30. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +0 -3
  31. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +0 -2
  32. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +0 -4
  33. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +0 -4
  34. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +0 -2
  35. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +0 -8
  36. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +0 -8
  37. package/dist/components/Business/BsLayouts/index.d.ts +0 -18
  38. package/dist/components/Business/BsLayouts/service.d.ts +0 -1
  39. package/dist/components/Business/BsLayouts/utils.d.ts +0 -13
  40. package/dist/components/Business/BsSulaQueryTable/index.d.ts +0 -2
  41. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +0 -58
  42. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +0 -98
  43. package/dist/components/Business/CommonAlert/index.d.ts +0 -3
  44. package/dist/components/Business/CommonGuideWrapper/index.d.ts +0 -6
  45. package/dist/components/Business/DetailPageWrapper/index.d.ts +0 -9
  46. package/dist/components/Business/DetailPageWrapper/utils.d.ts +0 -8
  47. package/dist/components/Business/HomePageWrapper/index.d.ts +0 -3
  48. package/dist/components/Business/StateFlow/index.d.ts +0 -3
  49. package/dist/components/Business/TreeSearchSelect/index.d.ts +0 -3
  50. package/dist/components/Business/TreeSearchSelect/utils.d.ts +0 -2
  51. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +0 -54
  52. package/dist/components/Business/columnSettingTable/index.d.ts +0 -16
  53. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +0 -17
  54. package/dist/components/Business/columnSettingTable/utils.d.ts +0 -8
  55. package/dist/components/Functional/AddSelect/index.d.ts +0 -3
  56. package/dist/components/Functional/BillEntry/index.d.ts +0 -4
  57. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +0 -12
  58. package/dist/components/Functional/TreeSearchSelect/index.d.ts +0 -2
  59. package/dist/utils/enumConfig.d.ts +0 -10
  60. package/dist/utils/requestUtils.d.ts +0 -1
  61. package/dist/utils/utils.d.ts +0 -3
  62. package/lib/assets/arrow_top.png +0 -0
  63. package/lib/assets/drag.svg +0 -17
  64. package/lib/assets/exportFail.svg +0 -38
  65. package/lib/assets/exportProcessing.svg +0 -29
  66. package/lib/assets/exportSuccess.svg +0 -35
  67. package/lib/assets/exportlogo.png +0 -0
  68. package/lib/assets/label_icon_bottom.svg +0 -26
  69. package/lib/assets/upExport.svg +0 -23
  70. package/src/assets/32.svg +0 -28
  71. package/src/assets/addIcon.svg +0 -18
  72. package/src/assets/allfunc.svg +0 -28
  73. package/src/assets/arrowRight.svg +0 -25
  74. package/src/assets/arrow_top.png +0 -0
  75. package/src/assets/btn-delete.svg +0 -30
  76. package/src/assets/btn-edit.svg +0 -20
  77. package/src/assets/btn-more.svg +0 -18
  78. package/src/assets/btn-submit.svg +0 -20
  79. package/src/assets/caidan.svg +0 -12
  80. package/src/assets/close.svg +0 -26
  81. package/src/assets/closeicon.png +0 -0
  82. package/src/assets/drag.svg +0 -17
  83. package/src/assets/exportFail.svg +0 -38
  84. package/src/assets/exportProcessing.svg +0 -29
  85. package/src/assets/exportSuccess.svg +0 -35
  86. package/src/assets/exportlogo.png +0 -0
  87. package/src/assets/fixed-left-active.svg +0 -12
  88. package/src/assets/fixed-left.svg +0 -16
  89. package/src/assets/fixed-right-active.svg +0 -12
  90. package/src/assets/fixed-right.svg +0 -16
  91. package/src/assets/guanbi.svg +0 -16
  92. package/src/assets/icon-quanping.svg +0 -16
  93. package/src/assets/icon-shezhi.svg +0 -18
  94. package/src/assets/label_icon_bottom.svg +0 -26
  95. package/src/assets/list-no-img.svg +0 -22
  96. package/src/assets/morentouxiang-32.svg +0 -24
  97. package/src/assets/right.png +0 -0
  98. package/src/assets/scanning.svg +0 -25
  99. package/src/assets/upExport.svg +0 -23
  100. package/src/assets/xinglan-icon-out.png +0 -0
  101. package/src/components/Business/AddSelectBusiness/index.md +0 -41
  102. package/src/components/Business/AddSelectBusiness/index.tsx +0 -290
  103. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +0 -112
  104. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +0 -153
  105. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +0 -70
  106. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +0 -90
  107. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +0 -38
  108. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +0 -243
  109. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +0 -385
  110. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +0 -286
  111. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +0 -75
  112. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +0 -171
  113. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +0 -65
  114. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +0 -154
  115. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +0 -73
  116. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +0 -158
  117. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +0 -85
  118. package/src/components/Business/BsLayouts/Components/RightContent/home.less +0 -218
  119. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +0 -156
  120. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +0 -161
  121. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +0 -76
  122. package/src/components/Business/BsLayouts/index.less +0 -80
  123. package/src/components/Business/BsLayouts/index.tsx +0 -1465
  124. package/src/components/Business/BsLayouts/service.ts +0 -11
  125. package/src/components/Business/BsLayouts/utils.tsx +0 -211
  126. package/src/components/Business/BsSulaQueryTable/index.less +0 -220
  127. package/src/components/Business/BsSulaQueryTable/index.tsx +0 -505
  128. package/src/components/Business/BsSulaQueryTable/setting.tsx +0 -799
  129. package/src/components/Business/BsSulaQueryTable/utils.less +0 -65
  130. package/src/components/Business/BsSulaQueryTable/utils.tsx +0 -688
  131. package/src/components/Business/CommonAlert/index.less +0 -0
  132. package/src/components/Business/CommonAlert/index.tsx +0 -23
  133. package/src/components/Business/CommonGuideWrapper/index.less +0 -112
  134. package/src/components/Business/CommonGuideWrapper/index.md +0 -39
  135. package/src/components/Business/CommonGuideWrapper/index.tsx +0 -84
  136. package/src/components/Business/DetailPageWrapper/index.less +0 -80
  137. package/src/components/Business/DetailPageWrapper/index.tsx +0 -335
  138. package/src/components/Business/DetailPageWrapper/utils.tsx +0 -101
  139. package/src/components/Business/HomePageWrapper/index.less +0 -33
  140. package/src/components/Business/HomePageWrapper/index.md +0 -45
  141. package/src/components/Business/HomePageWrapper/index.tsx +0 -162
  142. package/src/components/Business/StateFlow/index.less +0 -131
  143. package/src/components/Business/StateFlow/index.md +0 -60
  144. package/src/components/Business/StateFlow/index.tsx +0 -30
  145. package/src/components/Business/TreeSearchSelect/index.md +0 -126
  146. package/src/components/Business/TreeSearchSelect/index.tsx +0 -34
  147. package/src/components/Business/TreeSearchSelect/utils.ts +0 -60
  148. package/src/components/Business/columnSettingTable/columnSetting.tsx +0 -764
  149. package/src/components/Business/columnSettingTable/index.less +0 -247
  150. package/src/components/Business/columnSettingTable/index.md +0 -358
  151. package/src/components/Business/columnSettingTable/index.tsx +0 -233
  152. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +0 -241
  153. package/src/components/Business/columnSettingTable/utils.tsx +0 -69
  154. package/src/components/Functional/AddSelect/index.less +0 -367
  155. package/src/components/Functional/AddSelect/index.md +0 -122
  156. package/src/components/Functional/AddSelect/index.tsx +0 -962
  157. package/src/components/Functional/BillEntry/index.less +0 -371
  158. package/src/components/Functional/BillEntry/index.md +0 -39
  159. package/src/components/Functional/BillEntry/index.tsx +0 -613
  160. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +0 -37
  161. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +0 -59
  162. package/src/components/Functional/TreeSearchSelect/index.md +0 -47
  163. package/src/components/Functional/TreeSearchSelect/index.tsx +0 -149
  164. package/src/styles/bsDefault.less +0 -1907
  165. package/src/utils/enumConfig.ts +0 -10
  166. package/src/utils/requestUtils.ts +0 -33
  167. package/src/utils/utils.ts +0 -52
@@ -1,764 +0,0 @@
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;