@bit-sun/business-component 2.3.22-beta1 → 2.3.22-beta11

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