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