@bit-sun/business-component 2.2.21 → 2.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/index.esm.js +34 -31
  9. package/dist/index.js +34 -31
  10. package/docs/index.md +21 -21
  11. package/lib/assets/drag.svg +17 -17
  12. package/lib/assets/exportFail.svg +37 -37
  13. package/lib/assets/exportProcessing.svg +28 -28
  14. package/lib/assets/exportSuccess.svg +34 -34
  15. package/lib/assets/label_icon_bottom.svg +25 -25
  16. package/lib/assets/upExport.svg +22 -22
  17. package/package.json +77 -77
  18. package/src/assets/32.svg +27 -27
  19. package/src/assets/addIcon.svg +17 -17
  20. package/src/assets/allfunc.svg +27 -27
  21. package/src/assets/arrowRight.svg +24 -24
  22. package/src/assets/arrow_top.svg +17 -17
  23. package/src/assets/btn-delete.svg +29 -29
  24. package/src/assets/btn-edit.svg +19 -19
  25. package/src/assets/btn-more.svg +17 -17
  26. package/src/assets/btn-submit.svg +19 -19
  27. package/src/assets/caidan.svg +11 -11
  28. package/src/assets/close.svg +26 -26
  29. package/src/assets/drag.svg +17 -17
  30. package/src/assets/exportFail.svg +37 -37
  31. package/src/assets/exportProcessing.svg +28 -28
  32. package/src/assets/exportSuccess.svg +34 -34
  33. package/src/assets/fixed-left-active.svg +11 -11
  34. package/src/assets/fixed-left.svg +15 -15
  35. package/src/assets/fixed-right-active.svg +11 -11
  36. package/src/assets/fixed-right.svg +15 -15
  37. package/src/assets/guanbi.svg +15 -15
  38. package/src/assets/icon-quanping.svg +15 -15
  39. package/src/assets/icon-shezhi.svg +17 -17
  40. package/src/assets/label_icon_bottom.svg +25 -25
  41. package/src/assets/list-no-img.svg +21 -21
  42. package/src/assets/morentouxiang-32.svg +23 -23
  43. package/src/assets/scanning.svg +24 -24
  44. package/src/assets/upExport.svg +22 -22
  45. package/src/components/Business/AddSelectBusiness/index.md +129 -129
  46. package/src/components/Business/AddSelectBusiness/index.tsx +835 -835
  47. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  48. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  49. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  50. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  51. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  59. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  60. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  61. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  62. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  63. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  64. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  65. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  66. package/src/components/Business/BsLayouts/index.less +79 -79
  67. package/src/components/Business/BsLayouts/index.tsx +1480 -1479
  68. package/src/components/Business/BsLayouts/service.ts +10 -10
  69. package/src/components/Business/BsLayouts/utils.tsx +203 -203
  70. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -538
  71. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  72. package/src/components/Business/BsSulaQueryTable/index.tsx +527 -527
  73. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  74. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  75. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  76. package/src/components/Business/CommodityEntry/index.md +70 -70
  77. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  78. package/src/components/Business/CommonAlert/index.tsx +23 -23
  79. package/src/components/Business/CommonGuideWrapper/index.less +113 -113
  80. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  81. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  82. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  83. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  84. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  85. package/src/components/Business/HomePageWrapper/index.less +33 -33
  86. package/src/components/Business/HomePageWrapper/index.md +45 -45
  87. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  88. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  89. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  90. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  91. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  92. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  93. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  94. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  95. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  96. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  97. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  98. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  99. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  100. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  101. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  102. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  103. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  104. package/src/components/Business/JsonQueryTable/index.less +16 -16
  105. package/src/components/Business/JsonQueryTable/index.md +328 -328
  106. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  107. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  108. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  109. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  110. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  111. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  112. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  113. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  114. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  115. package/src/components/Business/JsonQueryTable/static.ts +390 -390
  116. package/src/components/Business/SearchSelect/BusinessUtils.ts +1730 -1730
  117. package/src/components/Business/SearchSelect/common.ts +53 -53
  118. package/src/components/Business/SearchSelect/index.md +1310 -1310
  119. package/src/components/Business/SearchSelect/index.tsx +51 -51
  120. package/src/components/Business/SearchSelect/utils.ts +100 -100
  121. package/src/components/Business/StateFlow/index.less +151 -151
  122. package/src/components/Business/StateFlow/index.md +60 -60
  123. package/src/components/Business/StateFlow/index.tsx +32 -32
  124. package/src/components/Business/TreeSearchSelect/index.md +154 -154
  125. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  126. package/src/components/Business/TreeSearchSelect/utils.ts +69 -69
  127. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  128. package/src/components/Business/columnSettingTable/index.less +247 -247
  129. package/src/components/Business/columnSettingTable/index.md +357 -357
  130. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  131. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  132. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  133. package/src/components/Business/moreTreeTable/index.less +99 -99
  134. package/src/components/Business/moreTreeTable/index.md +448 -448
  135. package/src/components/Business/moreTreeTable/index.tsx +361 -361
  136. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  137. package/src/components/Functional/AddSelect/index.less +367 -367
  138. package/src/components/Functional/AddSelect/index.md +155 -155
  139. package/src/components/Functional/AddSelect/index.tsx +1203 -1203
  140. package/src/components/Functional/BillEntry/index.less +371 -371
  141. package/src/components/Functional/BillEntry/index.md +39 -39
  142. package/src/components/Functional/BillEntry/index.tsx +766 -766
  143. package/src/components/Functional/DataImport/index.less +63 -63
  144. package/src/components/Functional/DataImport/index.md +44 -44
  145. package/src/components/Functional/DataImport/index.tsx +695 -695
  146. package/src/components/Functional/DataValidation/index.less +63 -63
  147. package/src/components/Functional/DataValidation/index.md +39 -39
  148. package/src/components/Functional/DataValidation/index.tsx +687 -687
  149. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  150. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  151. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  152. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  153. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  154. package/src/components/Functional/SearchSelect/index.less +115 -115
  155. package/src/components/Functional/SearchSelect/index.md +141 -141
  156. package/src/components/Functional/SearchSelect/index.tsx +846 -846
  157. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  158. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  159. package/src/components/Functional/TreeSearchSelect/index.tsx +162 -160
  160. package/src/index.ts +34 -34
  161. package/src/plugin/TableColumnSetting/index.less +247 -247
  162. package/src/plugin/TableColumnSetting/index.md +50 -50
  163. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  164. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  165. package/src/styles/bsDefault.less +1912 -1912
  166. package/src/utils/CheckOneUser/index.md +39 -39
  167. package/src/utils/CheckOneUser/index.ts +51 -51
  168. package/src/utils/LocalstorageUtils.ts +90 -90
  169. package/src/utils/TableUtils.tsx +18 -18
  170. package/src/utils/checkUtils.ts +39 -39
  171. package/src/utils/enumConfig.ts +11 -11
  172. package/src/utils/getFormMode.js +12 -12
  173. package/src/utils/index.ts +3 -3
  174. package/src/utils/requestUtils.ts +34 -34
  175. package/src/utils/serialize.js +7 -7
  176. package/src/utils/utils.ts +183 -183
  177. package/tsconfig.json +29 -29
  178. package/typings.d.ts +4 -4
@@ -1,538 +1,538 @@
1
- // @ts-nocheck
2
- import React from 'react';
3
- import {
4
- Table,
5
- message,
6
- Checkbox,
7
- Modal,
8
- Input,
9
- Button,
10
- Tooltip,
11
- } from 'antd';
12
- import {
13
- SortableContainer,
14
- SortableElement,
15
- SortableHandle,
16
- } from 'react-sortable-hoc';
17
- import axios from 'axios';
18
- import { SearchOutlined } from '@ant-design/icons';
19
- import { arrayMoveImmutable } from 'array-move';
20
- import close from '../../../assets/close.svg';
21
- import drag from '../../../assets/drag.svg';
22
- import './index.less';
23
- import ENUM from '@/utils/enumConfig';
24
-
25
- const DragHandle = SortableHandle(() => <img src={drag} />);
26
- const SortableItem = SortableElement((props) => <tr {...props} />);
27
- const SortableBody = SortableContainer((props) => <tbody {...props} />);
28
-
29
-
30
- class SearchItemTable extends React.Component {
31
- state = {
32
- dataSource: [],
33
- columns: [],
34
- sortDataSource: [],
35
- setVisible: false,
36
- searchDataSource: false,
37
- onSearchSort: false,
38
- isDefaultValue: false,
39
- defaultValue: [],
40
- bsTableCode: '', //设置table 列的标识
41
- };
42
-
43
- patchUserSearchFieldsConfig = (config) => {
44
- let that = this;
45
- let configvalue = config
46
- ? config.map((item) => ({
47
- name: item.name,
48
- hidden: item.hidden,
49
- }))
50
- : '';
51
-
52
- axios({
53
- url: '/user/appConfig/saveQueryCriteria',
54
- method: 'POST',
55
- data: {
56
- code: that.state.bsTableCode,
57
- detail: configvalue ? JSON.stringify(configvalue) : '',
58
- },
59
- }).then((res:any) => {
60
- if (res?.data?.status === '0') {
61
- this.patchConfigToLocalstorage(configvalue)
62
- } else {
63
- message.error('保存搜索项自定义失败,请稍后尝试');
64
- }
65
- })
66
- };
67
-
68
- getConfigFromlocalstorage = () => {
69
- let config = localStorage.getItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION) || '[]';
70
- let configArray = JSON.parse(config);
71
- let configSetting = configArray.filter(
72
- (item) => item.code === this.state.bsTableCode,
73
- );
74
-
75
- if (configSetting.length && configSetting[0].detail) {
76
- return JSON.parse(configSetting[0].detail);
77
- }
78
- return [];
79
- };
80
-
81
- patchConfigToLocalstorage = (configvalue) => {
82
- const { setShowSearchFields } = this.props;
83
- const { sortDataSource, bsTableCode } = this.state;
84
- let config = localStorage.getItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION) || '[]'
85
- let configArray = JSON.parse(config)
86
- let currentSetting = configArray.filter(item => item.code === bsTableCode)
87
- if (currentSetting.length) {
88
- currentSetting[0].detail = JSON.stringify(configvalue)
89
- } else {
90
- configArray.push({
91
- "code": bsTableCode,
92
- "detail": JSON.stringify(configvalue)
93
- })
94
- }
95
-
96
- localStorage.setItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION, JSON.stringify(configArray));
97
- this.setState({
98
- visible: false,
99
- });
100
- setShowSearchFields([...sortDataSource]);
101
- };
102
-
103
- setInitValue = (isClick = false) => {
104
- const { datasource = [], showSearchFields =[] }: any =
105
- this.props;
106
- let config = this.getConfigFromlocalstorage();
107
- this.setState({
108
- isDefaultValue: true,
109
- dataSource: datasource.map((item) => {
110
- let innerItem = config.filter(
111
- (inneritem) => {
112
- let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
113
- let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
114
- return innerKey && innerKey === itemKey;
115
- }
116
- );
117
- return {
118
- ...item,
119
- hidden: config.length && !innerItem.length,
120
- };
121
- }),
122
- defaultValue: datasource.map((item) => {
123
- let innerItem = config.filter(
124
- (inneritem) => {
125
- let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
126
- let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
127
- return innerKey && innerKey === itemKey;
128
- }
129
- );
130
- return {
131
- ...item,
132
- hidden: config.length && !innerItem.length,
133
- };
134
- }),
135
- sortDataSource: [...showSearchFields]
136
- });
137
- };
138
-
139
- componentDidMount() {
140
- const {
141
- datasource,
142
- showSearchFields,
143
- bsTableCode
144
- }: any = this.props;
145
-
146
- let config = this.getConfigFromlocalstorage();
147
-
148
- this.setState({
149
- dataSource: datasource.map((item) => {
150
- let innerItem = config.filter(
151
- (inneritem) => {
152
- let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
153
- let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
154
- return innerKey && innerKey === itemKey;
155
- }
156
- );
157
- return {
158
- ...item,
159
- hidden: config.length && !innerItem.length,
160
- };
161
- }),
162
- defaultValue: datasource.map((item) => {
163
- let innerItem = config.filter(
164
- (inneritem) => {
165
- let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
166
- let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
167
- return innerKey && innerKey === itemKey;
168
- }
169
- );
170
- return {
171
- ...item,
172
- hidden: config.length && !innerItem.length,
173
- };
174
- }),
175
- sortDataSource: datasource
176
- .filter((item) => !item.hidden)
177
- .map((item) => ({
178
- ...item,
179
- })),
180
- bsTableCode
181
- });
182
- }
183
-
184
- columns = [
185
- {
186
- title: '搜索字段名称',
187
- dataIndex: 'label',
188
- className: 'drag-visible',
189
- width: 100,
190
- },
191
- {
192
- title: '删除',
193
- dataIndex: 'title1',
194
- render: (text, record) => {
195
- return (
196
- <span
197
- onClick={() => {
198
- this.setState({
199
- sortDataSource: this.state.sortDataSource.filter((item) => {
200
- return item.label !== record.label;
201
- }),
202
- isDefaultValue: false,
203
- dataSource: [
204
- ...this.state.dataSource.map((item) => {
205
- if (item.label === record.label) {
206
- return {
207
- ...item,
208
- hidden: true,
209
- };
210
- }
211
- return item;
212
- }),
213
- ],
214
- });
215
- }}
216
- >
217
- <img src={close} />
218
- </span>
219
- );
220
- },
221
- },
222
- {
223
- title: 'Sort',
224
- dataIndex: 'sort',
225
- className: 'drag-visible',
226
- render: () => <DragHandle />,
227
- },
228
- ];
229
-
230
- showModal = () => {
231
- this.setState({
232
- visible: true,
233
- });
234
- this.setInitValue();
235
- };
236
-
237
- handleOk = (e?: React.MouseEvent<HTMLElement>) => {
238
- const { sortDataSource, isDefaultValue, defaultValue } = this.state;
239
- if (!sortDataSource.length) {
240
- message.warning('至少选择一个搜索项!');
241
- return;
242
- }
243
- this.patchUserSearchFieldsConfig(sortDataSource);
244
- };
245
-
246
- handleCancel = (e: React.MouseEvent<HTMLElement>) => {
247
- console.log(e);
248
- this.setState({
249
- visible: false,
250
- });
251
- };
252
-
253
- handleTableHeadHidden = (title: string) => {
254
- const { sortDataSource, dataSource } = this.state;
255
- this.setState(
256
- {
257
- sortDataSource: sortDataSource.filter((item) => {
258
- return item.title !== title;
259
- }),
260
- dataSource: [
261
- ...dataSource.map((item) => {
262
- if (item.title === title) {
263
- return {
264
- ...item,
265
- hidden: true,
266
- };
267
- }
268
- return item;
269
- }),
270
- ],
271
- },
272
- () => {
273
- this.handleOk();
274
- },
275
- );
276
- };
277
-
278
- onSortEnd = ({ oldIndex, newIndex }) => {
279
- const { sortDataSource } = this.state;
280
- if (oldIndex !== newIndex) {
281
- const newData = arrayMoveImmutable(
282
- [].concat(sortDataSource),
283
- oldIndex,
284
- newIndex,
285
- ).filter((el) => !!el);
286
- this.setState({
287
- sortDataSource: [ ...newData],
288
- isDefaultValue: false,
289
- });
290
- }
291
- };
292
-
293
- DraggableContainer = (props) => (
294
- <SortableBody
295
- useDragHandle
296
- disableAutoscroll
297
- helperClass="row-dragging"
298
- onSortEnd={this.onSortEnd}
299
- {...props}
300
- />
301
- );
302
-
303
- DraggableBodyRow = ({ className, style, ...restProps }) => {
304
- const { sortDataSource } = this.state;
305
- const index = sortDataSource.findIndex(
306
- (x) => x.name === restProps['data-row-key'],
307
- );
308
- return <SortableItem index={index} {...restProps} />;
309
- };
310
-
311
- onChange = (e: CheckboxChangeEvent, label) => {
312
- const { sortDataSource, dataSource } = this.state;
313
- if (!e.target.checked) {
314
- this.setState({
315
- sortDataSource: sortDataSource.filter((item) => {
316
- return item.label !== label;
317
- }),
318
- isDefaultValue: false,
319
- dataSource: [
320
- ...dataSource.map((item) => {
321
- if (item.label === label) {
322
- return {
323
- ...item,
324
- hidden: true,
325
- };
326
- }
327
- return item;
328
- }),
329
- ],
330
- });
331
- } else {
332
- let newSortData = [
333
- ...sortDataSource,
334
- ...dataSource
335
- .filter((item) => item.label === label)
336
- .map((source) => {
337
- return {
338
- ...source,
339
- hidden: false,
340
- };
341
- }),
342
- ];
343
- this.setState({
344
- sortDataSource: [...newSortData],
345
- isDefaultValue: false,
346
- dataSource: [
347
- ...dataSource.map((item) => {
348
- if (item.label === label) {
349
- return {
350
- ...item,
351
- hidden: false,
352
- };
353
- }
354
- return item;
355
- }),
356
- ],
357
- });
358
- }
359
- };
360
-
361
- handleReset = () => {
362
- this.setInitValue(true);
363
- };
364
-
365
- onSearch = (e: any) => {
366
- this.setState({
367
- searchDataSource: e.target.value,
368
- });
369
- };
370
-
371
- onSearchSort = (e: any) => {
372
- this.setState({
373
- onSearchSort: e.target.value,
374
- });
375
- };
376
-
377
- render() {
378
- const {
379
- dataSource = [],
380
- searchDataSource,
381
- sortDataSource,
382
- visible,
383
- onSearchSort,
384
- } = this.state;
385
- let newSearchSource = dataSource.filter(
386
- (item) => item?.label?.indexOf(searchDataSource||'') > -1,
387
- );
388
- return (
389
- <div className={'sort_table_wrapper'}>
390
- {visible && (
391
- <Modal
392
- title="设置搜索项内容"
393
- wrapClassName={'sort_table_wrapper'}
394
- width={820}
395
- visible={visible}
396
- onOk={this.handleOk}
397
- onCancel={this.handleCancel}
398
- footer={[
399
- <Button key="back" onClick={this.handleReset}>
400
- 恢复默认
401
- </Button>,
402
- <Button key="submit" onClick={this.handleCancel}>
403
- 取消
404
- </Button>,
405
- <Button key="submit" type="primary" onClick={this.handleOk}>
406
- 确认
407
- </Button>,
408
- ]}
409
- >
410
- <div className={'sort_table'}>
411
- <div className={'sort_table_column_wrapper'}>
412
- <span className={'sort_table_column_count'}>
413
- 可选字段 <span>(共{dataSource.length}个)</span>
414
- </span>
415
- <div className={'sort_table_column'}>
416
- <Input
417
- prefix={<SearchOutlined className="site-form-item-icon" />}
418
- placeholder="搜索"
419
- allowClear
420
- onChange={this.onSearch}
421
- style={{ width: 540 }}
422
- />
423
- <div>
424
- {!searchDataSource && (
425
- <Checkbox
426
- checked={
427
- !dataSource.some((item) => {
428
- if (item.hidden) return true;
429
-
430
- return false;
431
- })
432
- }
433
- onClick={(e) => {
434
- this.setState({
435
- isDefaultValue: false,
436
- dataSource: [
437
- ...dataSource.map((item) => {
438
- return {
439
- ...item,
440
- hidden: !e.target.checked,
441
- };
442
- }),
443
- ],
444
- sortDataSource: e.target.checked
445
- ? [...dataSource.map((item) => ({...item,hidden: false}))]
446
- : [],
447
- });
448
- }}
449
- >
450
- 全选
451
- </Checkbox>
452
- )}
453
- </div>
454
- <div className={'sort_table_column_all'}>
455
- {searchDataSource
456
- ? newSearchSource.map((item) => {
457
- return (
458
- <Checkbox
459
- checked={!item.hidden}
460
- onChange={(e) => {
461
- this.onChange(e, item.label);
462
- }}
463
- >
464
- {item.label}
465
- </Checkbox>
466
- );
467
- })
468
- : dataSource.map((item) => {
469
- return (
470
- <Checkbox
471
- checked={!item.hidden}
472
- onChange={(e) => {
473
- this.onChange(e, item.label);
474
- }}
475
- >
476
- {item.label}
477
- </Checkbox>
478
- );
479
- })}
480
- {!!newSearchSource.length && (
481
- <span style={{ width: '144px' }}></span>
482
- )}
483
-
484
- {!newSearchSource.length && (
485
- <div className={'sort_table_column_all_empty'}>
486
- 未查询到结果
487
- </div>
488
- )}
489
- </div>
490
- </div>
491
- </div>
492
- <div className={'sort_table_content_wrapper'}>
493
- <span className={'sort_table_content_count'}>
494
- 已选字段 <span>(共{sortDataSource.length}个)</span>
495
- </span>
496
- <div className={'sort_table_content'}>
497
- <span style={{ paddingLeft: '10px' }}>
498
- <Input
499
- prefix={
500
- <SearchOutlined className="site-form-item-icon" />
501
- }
502
- placeholder="搜索"
503
- allowClear
504
- onChange={this.onSearchSort}
505
- style={{ width: 190 }}
506
- />
507
- </span>
508
- <Table
509
- pagination={false}
510
- showHeader={false}
511
- dataSource={
512
- onSearchSort
513
- ? sortDataSource.filter(
514
- (item) => item?.label?.indexOf(onSearchSort) > -1,
515
- )
516
- : sortDataSource
517
- }
518
- columns={this.columns}
519
- rowKey="name"
520
- components={{
521
- body: {
522
- wrapper: this.DraggableContainer,
523
- row: this.DraggableBodyRow,
524
- },
525
- }}
526
- />
527
- </div>
528
- </div>
529
- </div>
530
- </Modal>
531
- )}
532
- <div onClick={this.showModal} style={{fontSize:14}}>搜索项设置</div>
533
- </div>
534
- );
535
- }
536
- }
537
-
538
- export default SearchItemTable;
1
+ // @ts-nocheck
2
+ import React from 'react';
3
+ import {
4
+ Table,
5
+ message,
6
+ Checkbox,
7
+ Modal,
8
+ Input,
9
+ Button,
10
+ Tooltip,
11
+ } from 'antd';
12
+ import {
13
+ SortableContainer,
14
+ SortableElement,
15
+ SortableHandle,
16
+ } from 'react-sortable-hoc';
17
+ import axios from 'axios';
18
+ import { SearchOutlined } from '@ant-design/icons';
19
+ import { arrayMoveImmutable } from 'array-move';
20
+ import close from '../../../assets/close.svg';
21
+ import drag from '../../../assets/drag.svg';
22
+ import './index.less';
23
+ import ENUM from '@/utils/enumConfig';
24
+
25
+ const DragHandle = SortableHandle(() => <img src={drag} />);
26
+ const SortableItem = SortableElement((props) => <tr {...props} />);
27
+ const SortableBody = SortableContainer((props) => <tbody {...props} />);
28
+
29
+
30
+ class SearchItemTable extends React.Component {
31
+ state = {
32
+ dataSource: [],
33
+ columns: [],
34
+ sortDataSource: [],
35
+ setVisible: false,
36
+ searchDataSource: false,
37
+ onSearchSort: false,
38
+ isDefaultValue: false,
39
+ defaultValue: [],
40
+ bsTableCode: '', //设置table 列的标识
41
+ };
42
+
43
+ patchUserSearchFieldsConfig = (config) => {
44
+ let that = this;
45
+ let configvalue = config
46
+ ? config.map((item) => ({
47
+ name: item.name,
48
+ hidden: item.hidden,
49
+ }))
50
+ : '';
51
+
52
+ axios({
53
+ url: '/user/appConfig/saveQueryCriteria',
54
+ method: 'POST',
55
+ data: {
56
+ code: that.state.bsTableCode,
57
+ detail: configvalue ? JSON.stringify(configvalue) : '',
58
+ },
59
+ }).then((res:any) => {
60
+ if (res?.data?.status === '0') {
61
+ this.patchConfigToLocalstorage(configvalue)
62
+ } else {
63
+ message.error('保存搜索项自定义失败,请稍后尝试');
64
+ }
65
+ })
66
+ };
67
+
68
+ getConfigFromlocalstorage = () => {
69
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION) || '[]';
70
+ let configArray = JSON.parse(config);
71
+ let configSetting = configArray.filter(
72
+ (item) => item.code === this.state.bsTableCode,
73
+ );
74
+
75
+ if (configSetting.length && configSetting[0].detail) {
76
+ return JSON.parse(configSetting[0].detail);
77
+ }
78
+ return [];
79
+ };
80
+
81
+ patchConfigToLocalstorage = (configvalue) => {
82
+ const { setShowSearchFields } = this.props;
83
+ const { sortDataSource, bsTableCode } = this.state;
84
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION) || '[]'
85
+ let configArray = JSON.parse(config)
86
+ let currentSetting = configArray.filter(item => item.code === bsTableCode)
87
+ if (currentSetting.length) {
88
+ currentSetting[0].detail = JSON.stringify(configvalue)
89
+ } else {
90
+ configArray.push({
91
+ "code": bsTableCode,
92
+ "detail": JSON.stringify(configvalue)
93
+ })
94
+ }
95
+
96
+ localStorage.setItem(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION, JSON.stringify(configArray));
97
+ this.setState({
98
+ visible: false,
99
+ });
100
+ setShowSearchFields([...sortDataSource]);
101
+ };
102
+
103
+ setInitValue = (isClick = false) => {
104
+ const { datasource = [], showSearchFields =[] }: any =
105
+ this.props;
106
+ let config = this.getConfigFromlocalstorage();
107
+ this.setState({
108
+ isDefaultValue: true,
109
+ dataSource: datasource.map((item) => {
110
+ let innerItem = config.filter(
111
+ (inneritem) => {
112
+ let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
113
+ let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
114
+ return innerKey && innerKey === itemKey;
115
+ }
116
+ );
117
+ return {
118
+ ...item,
119
+ hidden: config.length && !innerItem.length,
120
+ };
121
+ }),
122
+ defaultValue: datasource.map((item) => {
123
+ let innerItem = config.filter(
124
+ (inneritem) => {
125
+ let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
126
+ let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
127
+ return innerKey && innerKey === itemKey;
128
+ }
129
+ );
130
+ return {
131
+ ...item,
132
+ hidden: config.length && !innerItem.length,
133
+ };
134
+ }),
135
+ sortDataSource: [...showSearchFields]
136
+ });
137
+ };
138
+
139
+ componentDidMount() {
140
+ const {
141
+ datasource,
142
+ showSearchFields,
143
+ bsTableCode
144
+ }: any = this.props;
145
+
146
+ let config = this.getConfigFromlocalstorage();
147
+
148
+ this.setState({
149
+ dataSource: datasource.map((item) => {
150
+ let innerItem = config.filter(
151
+ (inneritem) => {
152
+ let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
153
+ let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
154
+ return innerKey && innerKey === itemKey;
155
+ }
156
+ );
157
+ return {
158
+ ...item,
159
+ hidden: config.length && !innerItem.length,
160
+ };
161
+ }),
162
+ defaultValue: datasource.map((item) => {
163
+ let innerItem = config.filter(
164
+ (inneritem) => {
165
+ let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : (inneritem.name);
166
+ let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : (item.name);
167
+ return innerKey && innerKey === itemKey;
168
+ }
169
+ );
170
+ return {
171
+ ...item,
172
+ hidden: config.length && !innerItem.length,
173
+ };
174
+ }),
175
+ sortDataSource: datasource
176
+ .filter((item) => !item.hidden)
177
+ .map((item) => ({
178
+ ...item,
179
+ })),
180
+ bsTableCode
181
+ });
182
+ }
183
+
184
+ columns = [
185
+ {
186
+ title: '搜索字段名称',
187
+ dataIndex: 'label',
188
+ className: 'drag-visible',
189
+ width: 100,
190
+ },
191
+ {
192
+ title: '删除',
193
+ dataIndex: 'title1',
194
+ render: (text, record) => {
195
+ return (
196
+ <span
197
+ onClick={() => {
198
+ this.setState({
199
+ sortDataSource: this.state.sortDataSource.filter((item) => {
200
+ return item.label !== record.label;
201
+ }),
202
+ isDefaultValue: false,
203
+ dataSource: [
204
+ ...this.state.dataSource.map((item) => {
205
+ if (item.label === record.label) {
206
+ return {
207
+ ...item,
208
+ hidden: true,
209
+ };
210
+ }
211
+ return item;
212
+ }),
213
+ ],
214
+ });
215
+ }}
216
+ >
217
+ <img src={close} />
218
+ </span>
219
+ );
220
+ },
221
+ },
222
+ {
223
+ title: 'Sort',
224
+ dataIndex: 'sort',
225
+ className: 'drag-visible',
226
+ render: () => <DragHandle />,
227
+ },
228
+ ];
229
+
230
+ showModal = () => {
231
+ this.setState({
232
+ visible: true,
233
+ });
234
+ this.setInitValue();
235
+ };
236
+
237
+ handleOk = (e?: React.MouseEvent<HTMLElement>) => {
238
+ const { sortDataSource, isDefaultValue, defaultValue } = this.state;
239
+ if (!sortDataSource.length) {
240
+ message.warning('至少选择一个搜索项!');
241
+ return;
242
+ }
243
+ this.patchUserSearchFieldsConfig(sortDataSource);
244
+ };
245
+
246
+ handleCancel = (e: React.MouseEvent<HTMLElement>) => {
247
+ console.log(e);
248
+ this.setState({
249
+ visible: false,
250
+ });
251
+ };
252
+
253
+ handleTableHeadHidden = (title: string) => {
254
+ const { sortDataSource, dataSource } = this.state;
255
+ this.setState(
256
+ {
257
+ sortDataSource: sortDataSource.filter((item) => {
258
+ return item.title !== title;
259
+ }),
260
+ dataSource: [
261
+ ...dataSource.map((item) => {
262
+ if (item.title === title) {
263
+ return {
264
+ ...item,
265
+ hidden: true,
266
+ };
267
+ }
268
+ return item;
269
+ }),
270
+ ],
271
+ },
272
+ () => {
273
+ this.handleOk();
274
+ },
275
+ );
276
+ };
277
+
278
+ onSortEnd = ({ oldIndex, newIndex }) => {
279
+ const { sortDataSource } = this.state;
280
+ if (oldIndex !== newIndex) {
281
+ const newData = arrayMoveImmutable(
282
+ [].concat(sortDataSource),
283
+ oldIndex,
284
+ newIndex,
285
+ ).filter((el) => !!el);
286
+ this.setState({
287
+ sortDataSource: [ ...newData],
288
+ isDefaultValue: false,
289
+ });
290
+ }
291
+ };
292
+
293
+ DraggableContainer = (props) => (
294
+ <SortableBody
295
+ useDragHandle
296
+ disableAutoscroll
297
+ helperClass="row-dragging"
298
+ onSortEnd={this.onSortEnd}
299
+ {...props}
300
+ />
301
+ );
302
+
303
+ DraggableBodyRow = ({ className, style, ...restProps }) => {
304
+ const { sortDataSource } = this.state;
305
+ const index = sortDataSource.findIndex(
306
+ (x) => x.name === restProps['data-row-key'],
307
+ );
308
+ return <SortableItem index={index} {...restProps} />;
309
+ };
310
+
311
+ onChange = (e: CheckboxChangeEvent, label) => {
312
+ const { sortDataSource, dataSource } = this.state;
313
+ if (!e.target.checked) {
314
+ this.setState({
315
+ sortDataSource: sortDataSource.filter((item) => {
316
+ return item.label !== label;
317
+ }),
318
+ isDefaultValue: false,
319
+ dataSource: [
320
+ ...dataSource.map((item) => {
321
+ if (item.label === label) {
322
+ return {
323
+ ...item,
324
+ hidden: true,
325
+ };
326
+ }
327
+ return item;
328
+ }),
329
+ ],
330
+ });
331
+ } else {
332
+ let newSortData = [
333
+ ...sortDataSource,
334
+ ...dataSource
335
+ .filter((item) => item.label === label)
336
+ .map((source) => {
337
+ return {
338
+ ...source,
339
+ hidden: false,
340
+ };
341
+ }),
342
+ ];
343
+ this.setState({
344
+ sortDataSource: [...newSortData],
345
+ isDefaultValue: false,
346
+ dataSource: [
347
+ ...dataSource.map((item) => {
348
+ if (item.label === label) {
349
+ return {
350
+ ...item,
351
+ hidden: false,
352
+ };
353
+ }
354
+ return item;
355
+ }),
356
+ ],
357
+ });
358
+ }
359
+ };
360
+
361
+ handleReset = () => {
362
+ this.setInitValue(true);
363
+ };
364
+
365
+ onSearch = (e: any) => {
366
+ this.setState({
367
+ searchDataSource: e.target.value,
368
+ });
369
+ };
370
+
371
+ onSearchSort = (e: any) => {
372
+ this.setState({
373
+ onSearchSort: e.target.value,
374
+ });
375
+ };
376
+
377
+ render() {
378
+ const {
379
+ dataSource = [],
380
+ searchDataSource,
381
+ sortDataSource,
382
+ visible,
383
+ onSearchSort,
384
+ } = this.state;
385
+ let newSearchSource = dataSource.filter(
386
+ (item) => item?.label?.indexOf(searchDataSource||'') > -1,
387
+ );
388
+ return (
389
+ <div className={'sort_table_wrapper'}>
390
+ {visible && (
391
+ <Modal
392
+ title="设置搜索项内容"
393
+ wrapClassName={'sort_table_wrapper'}
394
+ width={820}
395
+ visible={visible}
396
+ onOk={this.handleOk}
397
+ onCancel={this.handleCancel}
398
+ footer={[
399
+ <Button key="back" onClick={this.handleReset}>
400
+ 恢复默认
401
+ </Button>,
402
+ <Button key="submit" onClick={this.handleCancel}>
403
+ 取消
404
+ </Button>,
405
+ <Button key="submit" type="primary" onClick={this.handleOk}>
406
+ 确认
407
+ </Button>,
408
+ ]}
409
+ >
410
+ <div className={'sort_table'}>
411
+ <div className={'sort_table_column_wrapper'}>
412
+ <span className={'sort_table_column_count'}>
413
+ 可选字段 <span>(共{dataSource.length}个)</span>
414
+ </span>
415
+ <div className={'sort_table_column'}>
416
+ <Input
417
+ prefix={<SearchOutlined className="site-form-item-icon" />}
418
+ placeholder="搜索"
419
+ allowClear
420
+ onChange={this.onSearch}
421
+ style={{ width: 540 }}
422
+ />
423
+ <div>
424
+ {!searchDataSource && (
425
+ <Checkbox
426
+ checked={
427
+ !dataSource.some((item) => {
428
+ if (item.hidden) return true;
429
+
430
+ return false;
431
+ })
432
+ }
433
+ onClick={(e) => {
434
+ this.setState({
435
+ isDefaultValue: false,
436
+ dataSource: [
437
+ ...dataSource.map((item) => {
438
+ return {
439
+ ...item,
440
+ hidden: !e.target.checked,
441
+ };
442
+ }),
443
+ ],
444
+ sortDataSource: e.target.checked
445
+ ? [...dataSource.map((item) => ({...item,hidden: false}))]
446
+ : [],
447
+ });
448
+ }}
449
+ >
450
+ 全选
451
+ </Checkbox>
452
+ )}
453
+ </div>
454
+ <div className={'sort_table_column_all'}>
455
+ {searchDataSource
456
+ ? newSearchSource.map((item) => {
457
+ return (
458
+ <Checkbox
459
+ checked={!item.hidden}
460
+ onChange={(e) => {
461
+ this.onChange(e, item.label);
462
+ }}
463
+ >
464
+ {item.label}
465
+ </Checkbox>
466
+ );
467
+ })
468
+ : dataSource.map((item) => {
469
+ return (
470
+ <Checkbox
471
+ checked={!item.hidden}
472
+ onChange={(e) => {
473
+ this.onChange(e, item.label);
474
+ }}
475
+ >
476
+ {item.label}
477
+ </Checkbox>
478
+ );
479
+ })}
480
+ {!!newSearchSource.length && (
481
+ <span style={{ width: '144px' }}></span>
482
+ )}
483
+
484
+ {!newSearchSource.length && (
485
+ <div className={'sort_table_column_all_empty'}>
486
+ 未查询到结果
487
+ </div>
488
+ )}
489
+ </div>
490
+ </div>
491
+ </div>
492
+ <div className={'sort_table_content_wrapper'}>
493
+ <span className={'sort_table_content_count'}>
494
+ 已选字段 <span>(共{sortDataSource.length}个)</span>
495
+ </span>
496
+ <div className={'sort_table_content'}>
497
+ <span style={{ paddingLeft: '10px' }}>
498
+ <Input
499
+ prefix={
500
+ <SearchOutlined className="site-form-item-icon" />
501
+ }
502
+ placeholder="搜索"
503
+ allowClear
504
+ onChange={this.onSearchSort}
505
+ style={{ width: 190 }}
506
+ />
507
+ </span>
508
+ <Table
509
+ pagination={false}
510
+ showHeader={false}
511
+ dataSource={
512
+ onSearchSort
513
+ ? sortDataSource.filter(
514
+ (item) => item?.label?.indexOf(onSearchSort) > -1,
515
+ )
516
+ : sortDataSource
517
+ }
518
+ columns={this.columns}
519
+ rowKey="name"
520
+ components={{
521
+ body: {
522
+ wrapper: this.DraggableContainer,
523
+ row: this.DraggableBodyRow,
524
+ },
525
+ }}
526
+ />
527
+ </div>
528
+ </div>
529
+ </div>
530
+ </Modal>
531
+ )}
532
+ <div onClick={this.showModal} style={{fontSize:14}}>搜索项设置</div>
533
+ </div>
534
+ );
535
+ }
536
+ }
537
+
538
+ export default SearchItemTable;