@bit-sun/business-component 2.2.4 → 2.2.6

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 (179) 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/BsSulaQueryTable/SearchItemSetting.d.ts +59 -0
  9. package/dist/index.esm.js +547 -28
  10. package/dist/index.js +547 -28
  11. package/dist/utils/enumConfig.d.ts +1 -0
  12. package/docs/index.md +21 -21
  13. package/lib/assets/drag.svg +17 -17
  14. package/lib/assets/exportFail.svg +37 -37
  15. package/lib/assets/exportProcessing.svg +28 -28
  16. package/lib/assets/exportSuccess.svg +34 -34
  17. package/lib/assets/label_icon_bottom.svg +25 -25
  18. package/lib/assets/upExport.svg +22 -22
  19. package/package.json +77 -77
  20. package/src/assets/32.svg +27 -27
  21. package/src/assets/addIcon.svg +17 -17
  22. package/src/assets/allfunc.svg +27 -27
  23. package/src/assets/arrowRight.svg +24 -24
  24. package/src/assets/btn-delete.svg +29 -29
  25. package/src/assets/btn-edit.svg +19 -19
  26. package/src/assets/btn-more.svg +17 -17
  27. package/src/assets/btn-submit.svg +19 -19
  28. package/src/assets/caidan.svg +11 -11
  29. package/src/assets/close.svg +26 -26
  30. package/src/assets/drag.svg +17 -17
  31. package/src/assets/exportFail.svg +37 -37
  32. package/src/assets/exportProcessing.svg +28 -28
  33. package/src/assets/exportSuccess.svg +34 -34
  34. package/src/assets/fixed-left-active.svg +11 -11
  35. package/src/assets/fixed-left.svg +15 -15
  36. package/src/assets/fixed-right-active.svg +11 -11
  37. package/src/assets/fixed-right.svg +15 -15
  38. package/src/assets/guanbi.svg +15 -15
  39. package/src/assets/icon-quanping.svg +15 -15
  40. package/src/assets/icon-shezhi.svg +17 -17
  41. package/src/assets/label_icon_bottom.svg +25 -25
  42. package/src/assets/list-no-img.svg +21 -21
  43. package/src/assets/morentouxiang-32.svg +23 -23
  44. package/src/assets/scanning.svg +24 -24
  45. package/src/assets/upExport.svg +22 -22
  46. package/src/components/Business/AddSelectBusiness/index.md +63 -63
  47. package/src/components/Business/AddSelectBusiness/index.tsx +344 -344
  48. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  49. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  50. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  51. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  60. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  61. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  62. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  63. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  64. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -156
  65. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  66. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  67. package/src/components/Business/BsLayouts/index.less +79 -79
  68. package/src/components/Business/BsLayouts/index.tsx +1479 -1479
  69. package/src/components/Business/BsLayouts/service.ts +10 -10
  70. package/src/components/Business/BsLayouts/utils.tsx +230 -230
  71. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -0
  72. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  73. package/src/components/Business/BsSulaQueryTable/index.tsx +529 -480
  74. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  75. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  76. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  77. package/src/components/Business/CommodityEntry/index.md +70 -70
  78. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  79. package/src/components/Business/CommonAlert/index.tsx +23 -23
  80. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  81. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  82. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  83. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  84. package/src/components/Business/DetailPageWrapper/index.tsx +335 -335
  85. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  86. package/src/components/Business/HomePageWrapper/index.less +33 -33
  87. package/src/components/Business/HomePageWrapper/index.md +45 -45
  88. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  89. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  90. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  91. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  92. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  93. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  94. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  95. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  96. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  97. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  98. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  99. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  100. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  101. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  102. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  103. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  104. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  105. package/src/components/Business/JsonQueryTable/index.less +16 -16
  106. package/src/components/Business/JsonQueryTable/index.md +328 -328
  107. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  108. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  109. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  110. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  111. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  112. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  113. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  114. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  115. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  116. package/src/components/Business/JsonQueryTable/static.ts +356 -356
  117. package/src/components/Business/SearchSelect/BusinessUtils.ts +1586 -1586
  118. package/src/components/Business/SearchSelect/common.ts +53 -53
  119. package/src/components/Business/SearchSelect/index.md +1254 -1254
  120. package/src/components/Business/SearchSelect/index.tsx +51 -51
  121. package/src/components/Business/SearchSelect/utils.ts +100 -100
  122. package/src/components/Business/StateFlow/index.less +130 -130
  123. package/src/components/Business/StateFlow/index.md +60 -60
  124. package/src/components/Business/StateFlow/index.tsx +29 -29
  125. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  126. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  127. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  128. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  129. package/src/components/Business/columnSettingTable/index.less +247 -247
  130. package/src/components/Business/columnSettingTable/index.md +357 -357
  131. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  132. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  133. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  134. package/src/components/Business/moreTreeTable/index.less +99 -99
  135. package/src/components/Business/moreTreeTable/index.md +508 -508
  136. package/src/components/Business/moreTreeTable/index.tsx +315 -315
  137. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  138. package/src/components/Functional/AddSelect/index.less +367 -367
  139. package/src/components/Functional/AddSelect/index.md +155 -155
  140. package/src/components/Functional/AddSelect/index.tsx +1072 -1072
  141. package/src/components/Functional/BillEntry/index.less +371 -371
  142. package/src/components/Functional/BillEntry/index.md +39 -39
  143. package/src/components/Functional/BillEntry/index.tsx +766 -766
  144. package/src/components/Functional/DataImport/index.less +63 -63
  145. package/src/components/Functional/DataImport/index.md +44 -44
  146. package/src/components/Functional/DataImport/index.tsx +695 -695
  147. package/src/components/Functional/DataValidation/index.less +63 -63
  148. package/src/components/Functional/DataValidation/index.md +39 -39
  149. package/src/components/Functional/DataValidation/index.tsx +687 -687
  150. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  151. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  152. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  153. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  154. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  155. package/src/components/Functional/SearchSelect/index.less +115 -115
  156. package/src/components/Functional/SearchSelect/index.md +141 -141
  157. package/src/components/Functional/SearchSelect/index.tsx +813 -813
  158. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  159. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  160. package/src/components/Functional/TreeSearchSelect/index.tsx +160 -160
  161. package/src/index.ts +34 -34
  162. package/src/plugin/TableColumnSetting/index.less +247 -247
  163. package/src/plugin/TableColumnSetting/index.md +50 -50
  164. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  165. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  166. package/src/styles/bsDefault.less +1906 -1906
  167. package/src/utils/CheckOneUser/index.md +39 -39
  168. package/src/utils/CheckOneUser/index.ts +51 -51
  169. package/src/utils/LocalstorageUtils.ts +33 -33
  170. package/src/utils/TableUtils.tsx +18 -18
  171. package/src/utils/checkUtils.ts +39 -39
  172. package/src/utils/enumConfig.ts +11 -10
  173. package/src/utils/getFormMode.js +12 -12
  174. package/src/utils/index.ts +2 -2
  175. package/src/utils/requestUtils.ts +33 -33
  176. package/src/utils/serialize.js +7 -7
  177. package/src/utils/utils.ts +183 -183
  178. package/tsconfig.json +29 -29
  179. package/typings.d.ts +4 -4
@@ -1,813 +1,813 @@
1
- // @ts-nocheck
2
- import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
3
- import { useDebounceFn } from 'ahooks';
4
- import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
5
- import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
6
- import axios from 'axios';
7
- import { stringify } from 'querystring';
8
- import _ from "lodash"
9
- import './index.less';
10
- import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
- import { handleSourceName } from './utils';
12
-
13
- const { Option } = Select;
14
-
15
- const SearchSelect = forwardRef((props: any, ref: any) => {
16
- const {
17
- value, // 必传
18
- onChange,
19
- selectProps = {},
20
- modalTableProps = {},
21
- labelInValue = false,
22
- requestConfig,
23
- ctx,
24
- sourceName,
25
- needModalTable = true,
26
- getPopupContainer = undefined,
27
- fieldComponent,
28
- } = props;
29
- const {
30
- url,
31
- otherParams,// 默认参数
32
- isMap,
33
- fixedparameter,
34
- fieldValToParam,
35
- mappingTextField = 'name',
36
- mappingTextShowKeyField,
37
- mappingValueField = 'code',
38
- mappingTextShowTextField,
39
- init = true,// 是否初始请求
40
- extralHeaders = {},// 额外请求头参数
41
- } = requestConfig || {};
42
- const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || 'supplierCode')
43
-
44
- const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
45
- const initVal = value || (selectMode ? [] : null);
46
- const pageSize = 100 // 下拉框默认分页 条数
47
- const tableInitPageSize = 10 // 弹框默认分页 条数
48
- const currentPage = 1
49
- const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
50
- const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
51
- const currentSelectProps = {
52
- ...selectProps,
53
- // 以下属性不可更改----设计配置项
54
- showSearch: false,
55
- filterOption: false,
56
- allowClear: true,
57
- listHeight: 160,
58
- optionLabelProp: "label",
59
- autoClearSearchValue: false
60
- }
61
-
62
- const [items, setItems] = useState([]);
63
- const [scrollPage, setScrollPage] = useState(1);
64
- const [itemsTotal, setItemsTotal] = useState(0);
65
- const [fetching, setFetching] = useState(false);
66
- const [searchValue, setSearchValue] = useState('');
67
- const [isModalVisible, setIsModalVisible] = useState(false);
68
- const [popvalue, setPopValue] = useState(initVal);
69
- const [uniqueValue, setUniqueValue] = useState(resultSourceKey)
70
- const { run } = useDebounceFn(
71
- (v?: any) => {
72
- // 优化搜索参数 支持传多个
73
- let searchParams = {};
74
- if (typeof selectParamsKey === 'string') {
75
- let selectParamsInitValue = initVal
76
- if (labelInValue) {
77
- selectParamsInitValue = Array.isArray(initVal) ? initVal.map((i: any) => i.value || i.key).join(',') : initVal
78
- } else {
79
- selectParamsInitValue = Array.isArray(initVal) ? initVal.join(',') : initVal
80
- }
81
- searchParams = v ? { [selectParamsInitKey]: selectParamsInitValue } : { [selectParamsKey]: searchValue }
82
- }
83
- if (Array.isArray(selectParamsKey)) {
84
- selectParamsKey.forEach((i: any) => {
85
- searchParams = { ...searchParams, [i]: searchValue }
86
- })
87
- }
88
- // 防抖函数 待定
89
- getData(searchParams)
90
- },
91
- {
92
- wait: 1000,
93
- },
94
- );
95
-
96
- const [form] = Form.useForm();
97
- const [caretLeftFlag, setCaretLeftFlag] = useState(true);
98
- const [tableData, setTableData] = useState([]);
99
- const [tablePagination, setTablePagination] = useState({ showQuickJumper: true, total: 0, current: 1, pageSize: tableInitPageSize })
100
- const [selectedRowKeys, setSelectedRowKeys] = useState([]);
101
- const [doubleArr, setDoubleArr] = useState([]); // 存放双数组的数组
102
- const [checkedAll, setCheckedAll] = useState(false)
103
- const [indeterminate, setIndeterminate] = useState(false)
104
- const [tableFormParams, setTableFormParams] = useState({});
105
- const [tooltipVisible, setTooltipVisible] = useState(false);
106
-
107
- useImperativeHandle(ref, () => ({
108
- refreshDataSource: (reset: boolean = false) => {
109
- if (reset) {
110
- if (init) {
111
- run('init');
112
- } else {
113
- setItems([]);
114
- setItemsTotal(0);
115
- }
116
- } else {
117
- run();
118
- }
119
- },
120
- clearDataSource: () => {
121
- setItems([]);
122
- setItemsTotal(0);
123
- },
124
- getTableFormRef: () => form,
125
- }))
126
-
127
- // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
128
- const getData = (params = {}, type = 1) => {
129
- if (!requestConfig) return;
130
-
131
- setFetching(true)
132
-
133
- // 处理dependence参数
134
- const fixedParam = {};
135
- if (fixedparameter && fieldValToParam && ctx) {
136
- fixedparameter.forEach((item: any, index: any) => {
137
- const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
138
- if (fixedParamVal) {
139
- fixedParam[item] = fixedParamVal;
140
- form.setFieldsValue({ ...form?.getFieldsValue(), [item]: fixedParamVal })
141
- }
142
- });
143
- }
144
-
145
- // 数组对象处理,对带有特殊标记的name进行处理
146
- for (const key in params) {
147
- if (Object.prototype.hasOwnProperty.call(params, key)) {
148
- const element = params[key];
149
- if (element && key.indexOf('*number*') >= 0) {
150
- const dataParams = key.split('*number*');
151
- dataParams.forEach((value, index) => {
152
- params[value] = element[index];
153
- });
154
- delete params[key];
155
- } else if (element && key.indexOf('*address*') >= 0) {
156
- const dataParams = key.split('*address*');
157
- dataParams.forEach((value, index) => {
158
- params[value] = element.PCDCode[index];
159
- });
160
- delete params[key];
161
- } else if (element && key.indexOf('*costType*') >= 0) {
162
- const dataParams = key.split('*costType*');
163
- // eslint-disable-next-line prefer-destructuring
164
- params[dataParams[0]] = element[1];
165
- delete params[key];
166
- } else if (element && key.indexOf('*fullDate*') >= 0) {
167
- const dataParams = key.split('*fullDate*');
168
- dataParams.forEach((value, index) => {
169
- if (index === 0) {
170
- params[value] = moment(element[index])
171
- .millisecond(0)
172
- .second(0)
173
- .minute(0)
174
- .hour(0)
175
- .format('YYYY-MM-DD HH:mm:ss');
176
- } else {
177
- params[value] = moment(element[index])
178
- .millisecond(59)
179
- .second(59)
180
- .minute(59)
181
- .hour(23)
182
- .format('YYYY-MM-DD HH:mm:ss');
183
- }
184
- });
185
- delete params[key];
186
- } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
187
- const dataParams = key.split('*checkBox*');
188
- if (element) {
189
- params[dataParams[0]] = 0
190
- }
191
- delete params[key];
192
- } else if (element && key.indexOf('*cascader*') >= 0) {
193
- const dataParams = key.split('*cascader*');
194
- params[dataParams[0]] = element[element.length - 1]
195
- delete params[key];
196
- } else if (element && key.indexOf('*date*') >= 0) {
197
- const dataParams = key.split('*date*')
198
- dataParams.forEach((value, index) => {
199
- if (index === 0) {
200
- params[value] = moment(element[index])
201
- .format('YYYY-MM-DD');
202
- } else {
203
- params[value] = moment(element[index])
204
- .format('YYYY-MM-DD');
205
- }
206
- });
207
- delete params[key];
208
- }
209
- else if (element && key.indexOf('*') >= 0) {
210
- const dataParams = key.split('*');
211
- dataParams.forEach((value, index) => {
212
- params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
213
- });
214
- delete params[key];
215
- } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
216
- const dataParams = key.split('_selectNumberRange')[0]
217
- if (params[key][0] === 'range') {
218
- if (params[key][1][0]) {
219
- params[`qp-${dataParams}-ge`] = params[key][1][0]
220
- }
221
- if (params[key][1][1]) {
222
- params[`qp-${dataParams}-le`] = params[key][1][1]
223
- }
224
- } else {
225
- params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
226
- }
227
- delete params[key]
228
- } else if (Array.isArray(element)) {
229
- params[key] = element.join(',');
230
- } else if (element == null || element === undefined || String(element).trim() === '') {
231
- delete params[key]
232
- }
233
- }
234
- }
235
-
236
- const queryParams = {
237
- pageSize,
238
- currentPage,
239
- ...otherParams, // 默认参数
240
- ...fixedParam,
241
- ...params,
242
- }
243
-
244
- axios
245
- .get(
246
- `${url}?${stringify(queryParams)}`,
247
- {
248
- headers: { ...extralHeaders }
249
- })
250
- .then((result: any) => {
251
- setFetching(false)
252
- result = result.data;
253
- if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
254
- message.error(result.msg);
255
- return;
256
- }
257
- const res = result.data;
258
- let source = [];
259
- if (isMap) {
260
- source = Object.keys(res).map((d, i) => {
261
- return {
262
- text: Object.values(res)[i],
263
- value: d,
264
- };
265
- });
266
- } else {
267
- const keys = res.list ? 'list' : 'items';
268
- source = res
269
- ? res[keys]
270
- ? res[keys].map((item: any) => {
271
- let textShowText = item[mappingTextField]
272
- if (mappingTextShowTextField) {
273
- textShowText = []
274
- if (Array.isArray(mappingTextShowTextField)) {
275
- mappingTextShowTextField.forEach((r: any) => {
276
- textShowText.push(item[r])
277
- })
278
- } else {
279
- textShowText = item[mappingTextShowTextField]
280
- }
281
- }
282
- return {
283
- ...item,
284
- text: item[mappingTextField],
285
- textShowText,
286
- textShowKey: item[mappingTextShowKeyField || mappingValueField],
287
- value: item[mappingValueField],
288
- };
289
- })
290
- : Array.isArray(res) &&
291
- res?.map((item: Record<string, any>) => {
292
- let textShowText = item[mappingTextField]
293
- if (mappingTextShowTextField) {
294
- textShowText = []
295
- if (Array.isArray(mappingTextShowTextField)) {
296
- mappingTextShowTextField.forEach((r: any) => {
297
- textShowText.push(item[r])
298
- })
299
- } else {
300
- textShowText = item[mappingTextShowTextField]
301
- }
302
- }
303
- return {
304
- ...item,
305
- text: item[mappingTextField],
306
- textShowText,
307
- textShowKey: item[mappingTextShowKeyField || mappingValueField],
308
- value: item[mappingValueField],
309
- };
310
- })
311
- : [];
312
- }
313
- source = Array.isArray(source) ? source : []
314
- if (type === 1) {
315
- ctx?.form?.setFieldSource(resultSourceKey, source)
316
- setItems(source)
317
- setItemsTotal(Number(res?.total || res?.totalCount || source.length))
318
- } else {
319
- setTableData(source)
320
- setTablePagination({ ...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage)) })
321
- }
322
- })
323
- .catch((err) => { setFetching(false) });
324
- }
325
-
326
- const SelectScroll = e => {
327
- e.persist();
328
- const { target } = e;
329
- const totalPage = Math.ceil(itemsTotal / pageSize)
330
- // 判断是否滑动到底部
331
- const isTouchGround = target.scrollTop + target.offsetHeight === target.scrollHeight // >=scrollHeight
332
- // 判断数据是否还没有加载到了最后一页
333
- const canPageAdd = scrollPage < totalPage
334
- if (isTouchGround && canPageAdd) {
335
- const nextScrollPage = scrollPage + 1;
336
- setScrollPage(nextScrollPage);
337
- getData({ currentPage: nextScrollPage }); // 调用api方法
338
- }
339
-
340
- //判断是否滑动到顶部
341
- const isTouchTop = target.scrollTop === 0 // <=0
342
- // 判断数据是否到第一页
343
- const canPageJian = scrollPage > 1
344
- if (isTouchTop && canPageJian) {
345
- const preScrollPage = scrollPage - 1;
346
- setScrollPage(preScrollPage);
347
- getData({ currentPage: preScrollPage }); // 调用api方法
348
- }
349
- }
350
-
351
- useEffect(() => {
352
- if (init) {
353
- run('init')
354
- }
355
- }, [])
356
-
357
- useEffect(() => {
358
- if (value) {
359
- setPopValue(value);
360
- }
361
- }, [value]);
362
-
363
- useEffect(() => {
364
- makeUniqueValue();
365
- }, [resultSourceKey])
366
-
367
- const showModal = () => {
368
- getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
369
- setIsModalVisible(true);
370
- // 回显
371
- if (value) {
372
- if (selectMode) {
373
- setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
374
- setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
375
- setIndeterminate(!!value.length && value.length < itemsTotal);
376
- setCheckedAll(itemsTotal && value.length === itemsTotal);
377
- // 需清空数据
378
- if (!value.length) {
379
- setDoubleArr([])
380
- }
381
- } else {
382
- setSelectedRowKeys(labelInValue ? [value.key] : [value])
383
- setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
384
- }
385
- }
386
- };
387
-
388
- const handleSelectOver = (selectedValue: any) => {
389
- if (selectedValue?.length) {
390
- formaData(selectedValue);
391
- // 解决选择最后1页的sku,返回后,不显示名称问题
392
- const source = _.uniqBy(items.concat(selectedValue), 'value')
393
- ctx?.form?.setFieldSource(resultSourceKey, source)
394
- setItems(source)
395
- }
396
- }
397
-
398
- const handleOk = () => {
399
- handleSelectOver(popvalue)
400
- handleCancel();
401
- };
402
-
403
- const formaData = (value: any) => {
404
- if (labelInValue) {
405
- const formatResult = value.map((i: any) => ({ key: i[mappingValueField], label: i[mappingTextField], value: i[mappingValueField] }))
406
- onChange(selectMode ? formatResult : formatResult[0], value)
407
- } else {
408
- const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
409
- onChange(formatResult, value)
410
- }
411
- };
412
-
413
- const handleCancel = () => {
414
- form.resetFields();
415
- setTableFormParams({});
416
- setIsModalVisible(false);
417
- if (selectMode) {
418
- run();
419
- }
420
- };
421
-
422
- const refreshItems = () => {
423
- // 查看是否存在关联值 如果有关联值 就查询 没有就不能查询
424
- if (fieldValToParam && ctx) {
425
- let formValueList = [];
426
- fieldValToParam.forEach((item: any, index: any) => {
427
- const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
428
- formValueList.push(fixedParamVal);
429
- });
430
- if (formValueList.filter((item: any) => item).length > 0) {
431
- run();
432
- } else {
433
- setItems([]);
434
- setItemsTotal(0);
435
- }
436
- } else {
437
- run();
438
- }
439
- }
440
-
441
- const onSearchChange = (e) => {
442
- setSearchValue(e.target.value);
443
- refreshItems();
444
- }
445
-
446
- const onSearchBlur = () => {
447
- setSearchValue('');
448
- refreshItems();
449
- }
450
-
451
- const onSearchTable = () => {
452
- const params = form.getFieldsValue();
453
- setTableFormParams(params);
454
- getData({ ...params, pageSize: tableInitPageSize }, 2)
455
- if (selectMode) {
456
- getData(params)
457
- }
458
- }
459
-
460
- const onResetTable = () => {
461
- form.resetFields();
462
- setTableFormParams({});
463
- getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
464
- }
465
-
466
- const handleTableChange = (pagination) => {
467
- getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
468
- }
469
-
470
- const onChangeCheckAll = (e) => {
471
- if (e.target.checked) {
472
- // 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
473
- // 如果超过100条 就默认查出所有数据
474
- const currentItemsData = JSON.parse(JSON.stringify(items))
475
- const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize)
476
- for (let i = 0; i <= totalPage - 1; i++) {
477
- doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize * i, tablePagination?.pageSize * (i + 1))
478
- }
479
- setDoubleArr(doubleArr)
480
- setSelectedRowKeys(currentItemsData.map(i => i.value))
481
- setPopValue(currentItemsData);
482
- if (items.length < itemsTotal) {
483
- // TODO 请求接口获取所有数据
484
- }
485
- } else {
486
- setSelectedRowKeys([])
487
- setPopValue([]);
488
- setDoubleArr([])
489
- }
490
- setIndeterminate(false);
491
- setCheckedAll(e.target.checked);
492
- }
493
-
494
- const LightHeightOption = (props) => {
495
- const {
496
- filterTxt, text,
497
- } = props
498
- const heightLightTxt = (txt, heightTxt) => {
499
- if (heightTxt === '') {
500
- return txt
501
- }
502
- // 前面filterOption 不区分大小写,这里用i
503
- const regexp = new RegExp(heightTxt, 'gi')
504
- return txt.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
505
- }
506
- return (
507
- <Tooltip title={text}>
508
- <div ref={(nodeElement) => {
509
- if (nodeElement) {
510
- nodeElement.innerHTML = heightLightTxt(text, filterTxt)
511
- }
512
- }}
513
- />
514
- </Tooltip>
515
- )
516
- }
517
-
518
- // 扁平化二维数组的方法
519
- const mapRows = params => {
520
- var res = [];
521
- for (var i = 0; i < params.length; i++) {
522
- if (Array.isArray(params[i])) {
523
- // 去重
524
- res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
525
- } else {
526
- res.push(params[i]);
527
- // 去重
528
- res = _.uniqBy(res, 'value')
529
- }
530
- }
531
- return res.filter(Boolean); //去掉undefined的情况
532
- };
533
-
534
- const onChangeSelectedKeys = (selectKeys, selectRows) => {
535
- const nowPage = tablePagination?.current;
536
-
537
- let filterRows = []; // 存放拼接后的一维数组的变量
538
- let sksResult = [];
539
-
540
- if (selectMode) {
541
- // 处理多选分页累计选中
542
- // 勾选生成二维数组
543
- doubleArr[nowPage ? nowPage - 1 : 0] = selectRows
544
- // console.log(doubleArr)
545
- setDoubleArr(doubleArr)
546
- // 这块扁平化成为一位数组
547
- filterRows = mapRows(doubleArr);
548
- // console.log(filterRows)
549
-
550
- sksResult = filterRows.map((i) => i.value)
551
- } else {
552
- // 处理单选
553
- filterRows = selectRows;
554
- sksResult = selectRows.map((i) => i.value)
555
- // 单选直接选中 不需要确定
556
- handleSelectOver(filterRows)
557
- handleCancel();
558
- }
559
-
560
- setSelectedRowKeys(sksResult)
561
- setPopValue(filterRows);
562
- setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
563
- setCheckedAll(filterRows.length === tablePagination?.total);
564
- }
565
-
566
- // 生成唯一值
567
- const makeUniqueValue = () => {
568
- const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
569
- setUniqueValue(generateUnitKey);
570
- return generateUnitKey;
571
- }
572
-
573
- const rowSelection = {
574
- type: selectMode ? 'checkbox' : 'radio',
575
- selectedRowKeys,
576
- onChange: (sks, srs) => {
577
- onChangeSelectedKeys(sks, srs)
578
- },
579
- getCheckboxProps: () => {
580
- return ({
581
- disabled: selectProps?.disabled || props?.disabled || !items.length,
582
- })
583
- },
584
- };
585
-
586
- const onDoubleClickSelect = (e, record) => {
587
- if (!selectMode && !(selectProps?.disabled || props?.disabled || !items.length)) {
588
- const srs = [JSON.parse(JSON.stringify(record))]
589
- const sks = srs.map((i: any) => i.value)
590
- onChangeSelectedKeys(sks, srs)
591
- }
592
- }
593
-
594
- const themeColor = { color: '#1890ff' }
595
-
596
- const formItem = (list) => {
597
- if (isModalVisible && list?.length) {
598
- const setDisabled = (name: any) => {
599
- const { fixedparamsDisabled = false, fixedparameter = [] }: any = requestConfig;
600
- if (fixedparamsDisabled && fixedparameter.find((item: any) => item === name)) {
601
- return true
602
- } else {
603
- return false
604
- }
605
- };
606
- return list.map((i: any) => {
607
- if (i?.type === 'select' || i?.field?.type === 'select') {
608
- return (
609
- <Form.Item name={i.name} label={i.label} key={i.name}>
610
- <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
611
- {i?.initialSource?.length && i?.initialSource.map((m: any) => (
612
- <Option value={m.value} key={m.value}>{m.text}</Option>
613
- ))}
614
- </Select>
615
- </Form.Item>
616
- )
617
- }
618
-
619
- if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
620
- return (
621
- <Form.Item name={i.name} label={i.label} key={i.name}>
622
- <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
623
- </Form.Item>
624
- )
625
- }
626
-
627
- if (i?.type === 'businessSearchSelect' || i?.field?.type === 'businessSearchSelect') {
628
- return (
629
- <div>
630
- <Form.Item name={i.name} label={i.label} key={i.name}>
631
- <BusinessSearchSelect {...i.field.props} disabled={setDisabled(i.name)} />
632
- </Form.Item>
633
- </div>
634
- )
635
- }
636
-
637
- if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
638
- return (
639
- <div>
640
- <Form.Item name={i.name} label={i.label} key={i.name}>
641
- <QueryMutipleInput onValueChange={(value) => {
642
- form.setFieldsValue({
643
- [i.name]: value
644
- })
645
- }} />
646
- </Form.Item>
647
- </div>
648
- );
649
- }
650
-
651
- // 默认type是input
652
- return (
653
- <Form.Item name={i.name} label={i.label} key={i.name}>
654
- <Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
655
- </Form.Item>
656
- )
657
- })
658
- } else {
659
- return null
660
- }
661
- }
662
-
663
- const maxTagPlaceholder = (selectedValues) => {
664
- const onClose = (e: any, item: any) => {
665
- e.preventDefault();
666
- const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value) : JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
667
- onChange(newValue);
668
- }
669
- return (
670
- <Tooltip title={selectedValues.map((i: any) => (
671
- <Tag
672
- closable={true}
673
- onClose={(e) => onClose(e, i)}
674
- style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
675
- >
676
- {i.label}
677
- </Tag>
678
- ))}>
679
- {`+ ${selectedValues?.length}`}
680
- </Tooltip>
681
- )
682
- }
683
-
684
- return (
685
- <div className={'search_select'}>
686
- {fieldComponent ?
687
- (<div onClick={() => {
688
- fieldComponent.props?.onClick?.()
689
- showModal()
690
- }}>{fieldComponent}</div>) :
691
- (<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
692
- <Select
693
- virtual
694
- labelInValue={labelInValue}
695
- value={value}
696
- onChange={onChange}
697
- disabled={props.disabled}
698
- dropdownRender={menu => (
699
- <>
700
- <Input
701
- value={searchValue}
702
- style={{ width: '98%', marginLeft: '1%' }}
703
- placeholder="请输入"
704
- onChange={e => onSearchChange(e)}
705
- onBlur={onSearchBlur}
706
- onKeyDown={(e) => {
707
- // 阻止多选的冒泡
708
- e.stopPropagation()
709
- }}
710
- />
711
- <Divider style={{ margin: '8px 0' }} />
712
- {menu}
713
- </>
714
- )}
715
- notFoundContent={
716
- fetching ? <Spin size="small" /> :
717
- <div style={{ textAlign: 'center' }}>
718
- <div style={{ marginBottom: 16 }}>
719
- <CopyOutlined style={{ fontSize: '50px' }} />
720
- </div>
721
- <div>无匹配结果,请更换其他内容再试</div>
722
- </div>
723
- }
724
- onPopupScroll={SelectScroll}
725
- style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
726
- placeholder="请选择"
727
- maxTagPlaceholder={maxTagPlaceholder}
728
- {...currentSelectProps}
729
- getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
730
- >
731
- {items.map(item => (
732
- <Option key={item.value} label={item.text}>
733
- {LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
734
- </Option>
735
- ))}
736
- </Select>
737
- {needModalTable && (
738
- <Button style={{ width: '30px', padding: '2px', height: 'auto' }} onClick={showModal} type="primary">
739
- <SearchOutlined />
740
- </Button>
741
- )}
742
- </div>)}
743
- {needModalTable && isModalVisible && (
744
- <Modal
745
- width='80%'
746
- title={modalTableProps?.modalTableTitle}
747
- visible={isModalVisible}
748
- onOk={handleOk}
749
- onCancel={handleCancel}
750
- footer={selectMode ? [
751
- <Button key="back" onClick={handleCancel}>
752
- 取消
753
- </Button>,
754
- <Button
755
- key="submit"
756
- type="primary"
757
- onClick={handleOk}
758
- disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
759
- >
760
- 确定
761
- </Button>,
762
- ] : null}
763
- >
764
- <div className={'search_select_wrapper'}>
765
- <div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
766
- <CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1'} />
767
- </div>
768
- <div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
769
- <div className={'select_list_columns'}>
770
- <div className={'select_list_columns_tips'}>搜索</div>
771
- <div className={'select_list_columns_formItems'}>
772
- <Form form={form} layout='vertical' key='modalForm'>
773
- {formItem(modalTableProps?.tableSearchForm)}
774
- </Form>
775
- </div>
776
- </div>
777
- <div className={'select_list_searchButton'}>
778
- <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
779
- <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
780
- </div>
781
- </div>
782
- <div className={caretLeftFlag ? 'search_select_wrapper_right' : 'search_select_wrapper_right1'}>
783
- <div>
784
- <div className={'select_list_selectTips'}>
785
- <div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
786
- <div style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}>{selectMode ? '勾选后点击确定按钮完成选择' : '双击数据行或点击单选图标完成选择'}</div>
787
- </div>
788
- <Table
789
- size='small'
790
- rowSelection={rowSelection}
791
- columns={modalTableProps?.tableColumns}
792
- dataSource={tableData}
793
- pagination={tablePagination}
794
- onChange={handleTableChange}
795
- rowKey={mappingValueField}
796
- scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
797
- onRow={record => {
798
- return {
799
- onDoubleClick: event => onDoubleClickSelect(event, record),
800
- };
801
- }}
802
- />
803
- {selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} disabled={selectProps?.disabled || props?.disabled} /> 全选所有页面</div> : ''}
804
- </div>
805
- </div>
806
- </div>
807
- </Modal>
808
- )}
809
- </div>
810
- );
811
- });
812
-
813
- export default SearchSelect;
1
+ // @ts-nocheck
2
+ import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
3
+ import { useDebounceFn } from 'ahooks';
4
+ import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
5
+ import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
6
+ import axios from 'axios';
7
+ import { stringify } from 'querystring';
8
+ import _ from "lodash"
9
+ import './index.less';
10
+ import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
+ import { handleSourceName } from './utils';
12
+
13
+ const { Option } = Select;
14
+
15
+ const SearchSelect = forwardRef((props: any, ref: any) => {
16
+ const {
17
+ value, // 必传
18
+ onChange,
19
+ selectProps = {},
20
+ modalTableProps = {},
21
+ labelInValue = false,
22
+ requestConfig,
23
+ ctx,
24
+ sourceName,
25
+ needModalTable = true,
26
+ getPopupContainer = undefined,
27
+ fieldComponent,
28
+ } = props;
29
+ const {
30
+ url,
31
+ otherParams,// 默认参数
32
+ isMap,
33
+ fixedparameter,
34
+ fieldValToParam,
35
+ mappingTextField = 'name',
36
+ mappingTextShowKeyField,
37
+ mappingValueField = 'code',
38
+ mappingTextShowTextField,
39
+ init = true,// 是否初始请求
40
+ extralHeaders = {},// 额外请求头参数
41
+ } = requestConfig || {};
42
+ const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || 'supplierCode')
43
+
44
+ const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
45
+ const initVal = value || (selectMode ? [] : null);
46
+ const pageSize = 100 // 下拉框默认分页 条数
47
+ const tableInitPageSize = 10 // 弹框默认分页 条数
48
+ const currentPage = 1
49
+ const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
50
+ const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
51
+ const currentSelectProps = {
52
+ ...selectProps,
53
+ // 以下属性不可更改----设计配置项
54
+ showSearch: false,
55
+ filterOption: false,
56
+ allowClear: true,
57
+ listHeight: 160,
58
+ optionLabelProp: "label",
59
+ autoClearSearchValue: false
60
+ }
61
+
62
+ const [items, setItems] = useState([]);
63
+ const [scrollPage, setScrollPage] = useState(1);
64
+ const [itemsTotal, setItemsTotal] = useState(0);
65
+ const [fetching, setFetching] = useState(false);
66
+ const [searchValue, setSearchValue] = useState('');
67
+ const [isModalVisible, setIsModalVisible] = useState(false);
68
+ const [popvalue, setPopValue] = useState(initVal);
69
+ const [uniqueValue, setUniqueValue] = useState(resultSourceKey)
70
+ const { run } = useDebounceFn(
71
+ (v?: any) => {
72
+ // 优化搜索参数 支持传多个
73
+ let searchParams = {};
74
+ if (typeof selectParamsKey === 'string') {
75
+ let selectParamsInitValue = initVal
76
+ if (labelInValue) {
77
+ selectParamsInitValue = Array.isArray(initVal) ? initVal.map((i: any) => i.value || i.key).join(',') : initVal
78
+ } else {
79
+ selectParamsInitValue = Array.isArray(initVal) ? initVal.join(',') : initVal
80
+ }
81
+ searchParams = v ? { [selectParamsInitKey]: selectParamsInitValue } : { [selectParamsKey]: searchValue }
82
+ }
83
+ if (Array.isArray(selectParamsKey)) {
84
+ selectParamsKey.forEach((i: any) => {
85
+ searchParams = { ...searchParams, [i]: searchValue }
86
+ })
87
+ }
88
+ // 防抖函数 待定
89
+ getData(searchParams)
90
+ },
91
+ {
92
+ wait: 1000,
93
+ },
94
+ );
95
+
96
+ const [form] = Form.useForm();
97
+ const [caretLeftFlag, setCaretLeftFlag] = useState(true);
98
+ const [tableData, setTableData] = useState([]);
99
+ const [tablePagination, setTablePagination] = useState({ showQuickJumper: true, total: 0, current: 1, pageSize: tableInitPageSize })
100
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
101
+ const [doubleArr, setDoubleArr] = useState([]); // 存放双数组的数组
102
+ const [checkedAll, setCheckedAll] = useState(false)
103
+ const [indeterminate, setIndeterminate] = useState(false)
104
+ const [tableFormParams, setTableFormParams] = useState({});
105
+ const [tooltipVisible, setTooltipVisible] = useState(false);
106
+
107
+ useImperativeHandle(ref, () => ({
108
+ refreshDataSource: (reset: boolean = false) => {
109
+ if (reset) {
110
+ if (init) {
111
+ run('init');
112
+ } else {
113
+ setItems([]);
114
+ setItemsTotal(0);
115
+ }
116
+ } else {
117
+ run();
118
+ }
119
+ },
120
+ clearDataSource: () => {
121
+ setItems([]);
122
+ setItemsTotal(0);
123
+ },
124
+ getTableFormRef: () => form,
125
+ }))
126
+
127
+ // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
128
+ const getData = (params = {}, type = 1) => {
129
+ if (!requestConfig) return;
130
+
131
+ setFetching(true)
132
+
133
+ // 处理dependence参数
134
+ const fixedParam = {};
135
+ if (fixedparameter && fieldValToParam && ctx) {
136
+ fixedparameter.forEach((item: any, index: any) => {
137
+ const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
138
+ if (fixedParamVal) {
139
+ fixedParam[item] = fixedParamVal;
140
+ form.setFieldsValue({ ...form?.getFieldsValue(), [item]: fixedParamVal })
141
+ }
142
+ });
143
+ }
144
+
145
+ // 数组对象处理,对带有特殊标记的name进行处理
146
+ for (const key in params) {
147
+ if (Object.prototype.hasOwnProperty.call(params, key)) {
148
+ const element = params[key];
149
+ if (element && key.indexOf('*number*') >= 0) {
150
+ const dataParams = key.split('*number*');
151
+ dataParams.forEach((value, index) => {
152
+ params[value] = element[index];
153
+ });
154
+ delete params[key];
155
+ } else if (element && key.indexOf('*address*') >= 0) {
156
+ const dataParams = key.split('*address*');
157
+ dataParams.forEach((value, index) => {
158
+ params[value] = element.PCDCode[index];
159
+ });
160
+ delete params[key];
161
+ } else if (element && key.indexOf('*costType*') >= 0) {
162
+ const dataParams = key.split('*costType*');
163
+ // eslint-disable-next-line prefer-destructuring
164
+ params[dataParams[0]] = element[1];
165
+ delete params[key];
166
+ } else if (element && key.indexOf('*fullDate*') >= 0) {
167
+ const dataParams = key.split('*fullDate*');
168
+ dataParams.forEach((value, index) => {
169
+ if (index === 0) {
170
+ params[value] = moment(element[index])
171
+ .millisecond(0)
172
+ .second(0)
173
+ .minute(0)
174
+ .hour(0)
175
+ .format('YYYY-MM-DD HH:mm:ss');
176
+ } else {
177
+ params[value] = moment(element[index])
178
+ .millisecond(59)
179
+ .second(59)
180
+ .minute(59)
181
+ .hour(23)
182
+ .format('YYYY-MM-DD HH:mm:ss');
183
+ }
184
+ });
185
+ delete params[key];
186
+ } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
187
+ const dataParams = key.split('*checkBox*');
188
+ if (element) {
189
+ params[dataParams[0]] = 0
190
+ }
191
+ delete params[key];
192
+ } else if (element && key.indexOf('*cascader*') >= 0) {
193
+ const dataParams = key.split('*cascader*');
194
+ params[dataParams[0]] = element[element.length - 1]
195
+ delete params[key];
196
+ } else if (element && key.indexOf('*date*') >= 0) {
197
+ const dataParams = key.split('*date*')
198
+ dataParams.forEach((value, index) => {
199
+ if (index === 0) {
200
+ params[value] = moment(element[index])
201
+ .format('YYYY-MM-DD');
202
+ } else {
203
+ params[value] = moment(element[index])
204
+ .format('YYYY-MM-DD');
205
+ }
206
+ });
207
+ delete params[key];
208
+ }
209
+ else if (element && key.indexOf('*') >= 0) {
210
+ const dataParams = key.split('*');
211
+ dataParams.forEach((value, index) => {
212
+ params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
213
+ });
214
+ delete params[key];
215
+ } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
216
+ const dataParams = key.split('_selectNumberRange')[0]
217
+ if (params[key][0] === 'range') {
218
+ if (params[key][1][0]) {
219
+ params[`qp-${dataParams}-ge`] = params[key][1][0]
220
+ }
221
+ if (params[key][1][1]) {
222
+ params[`qp-${dataParams}-le`] = params[key][1][1]
223
+ }
224
+ } else {
225
+ params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
226
+ }
227
+ delete params[key]
228
+ } else if (Array.isArray(element)) {
229
+ params[key] = element.join(',');
230
+ } else if (element == null || element === undefined || String(element).trim() === '') {
231
+ delete params[key]
232
+ }
233
+ }
234
+ }
235
+
236
+ const queryParams = {
237
+ pageSize,
238
+ currentPage,
239
+ ...otherParams, // 默认参数
240
+ ...fixedParam,
241
+ ...params,
242
+ }
243
+
244
+ axios
245
+ .get(
246
+ `${url}?${stringify(queryParams)}`,
247
+ {
248
+ headers: { ...extralHeaders }
249
+ })
250
+ .then((result: any) => {
251
+ setFetching(false)
252
+ result = result.data;
253
+ if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
254
+ message.error(result.msg);
255
+ return;
256
+ }
257
+ const res = result.data;
258
+ let source = [];
259
+ if (isMap) {
260
+ source = Object.keys(res).map((d, i) => {
261
+ return {
262
+ text: Object.values(res)[i],
263
+ value: d,
264
+ };
265
+ });
266
+ } else {
267
+ const keys = res.list ? 'list' : 'items';
268
+ source = res
269
+ ? res[keys]
270
+ ? res[keys].map((item: any) => {
271
+ let textShowText = item[mappingTextField]
272
+ if (mappingTextShowTextField) {
273
+ textShowText = []
274
+ if (Array.isArray(mappingTextShowTextField)) {
275
+ mappingTextShowTextField.forEach((r: any) => {
276
+ textShowText.push(item[r])
277
+ })
278
+ } else {
279
+ textShowText = item[mappingTextShowTextField]
280
+ }
281
+ }
282
+ return {
283
+ ...item,
284
+ text: item[mappingTextField],
285
+ textShowText,
286
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
287
+ value: item[mappingValueField],
288
+ };
289
+ })
290
+ : Array.isArray(res) &&
291
+ res?.map((item: Record<string, any>) => {
292
+ let textShowText = item[mappingTextField]
293
+ if (mappingTextShowTextField) {
294
+ textShowText = []
295
+ if (Array.isArray(mappingTextShowTextField)) {
296
+ mappingTextShowTextField.forEach((r: any) => {
297
+ textShowText.push(item[r])
298
+ })
299
+ } else {
300
+ textShowText = item[mappingTextShowTextField]
301
+ }
302
+ }
303
+ return {
304
+ ...item,
305
+ text: item[mappingTextField],
306
+ textShowText,
307
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
308
+ value: item[mappingValueField],
309
+ };
310
+ })
311
+ : [];
312
+ }
313
+ source = Array.isArray(source) ? source : []
314
+ if (type === 1) {
315
+ ctx?.form?.setFieldSource(resultSourceKey, source)
316
+ setItems(source)
317
+ setItemsTotal(Number(res?.total || res?.totalCount || source.length))
318
+ } else {
319
+ setTableData(source)
320
+ setTablePagination({ ...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage)) })
321
+ }
322
+ })
323
+ .catch((err) => { setFetching(false) });
324
+ }
325
+
326
+ const SelectScroll = e => {
327
+ e.persist();
328
+ const { target } = e;
329
+ const totalPage = Math.ceil(itemsTotal / pageSize)
330
+ // 判断是否滑动到底部
331
+ const isTouchGround = target.scrollTop + target.offsetHeight === target.scrollHeight // >=scrollHeight
332
+ // 判断数据是否还没有加载到了最后一页
333
+ const canPageAdd = scrollPage < totalPage
334
+ if (isTouchGround && canPageAdd) {
335
+ const nextScrollPage = scrollPage + 1;
336
+ setScrollPage(nextScrollPage);
337
+ getData({ currentPage: nextScrollPage }); // 调用api方法
338
+ }
339
+
340
+ //判断是否滑动到顶部
341
+ const isTouchTop = target.scrollTop === 0 // <=0
342
+ // 判断数据是否到第一页
343
+ const canPageJian = scrollPage > 1
344
+ if (isTouchTop && canPageJian) {
345
+ const preScrollPage = scrollPage - 1;
346
+ setScrollPage(preScrollPage);
347
+ getData({ currentPage: preScrollPage }); // 调用api方法
348
+ }
349
+ }
350
+
351
+ useEffect(() => {
352
+ if (init) {
353
+ run('init')
354
+ }
355
+ }, [])
356
+
357
+ useEffect(() => {
358
+ if (value) {
359
+ setPopValue(value);
360
+ }
361
+ }, [value]);
362
+
363
+ useEffect(() => {
364
+ makeUniqueValue();
365
+ }, [resultSourceKey])
366
+
367
+ const showModal = () => {
368
+ getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
369
+ setIsModalVisible(true);
370
+ // 回显
371
+ if (value) {
372
+ if (selectMode) {
373
+ setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
374
+ setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
375
+ setIndeterminate(!!value.length && value.length < itemsTotal);
376
+ setCheckedAll(itemsTotal && value.length === itemsTotal);
377
+ // 需清空数据
378
+ if (!value.length) {
379
+ setDoubleArr([])
380
+ }
381
+ } else {
382
+ setSelectedRowKeys(labelInValue ? [value.key] : [value])
383
+ setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
384
+ }
385
+ }
386
+ };
387
+
388
+ const handleSelectOver = (selectedValue: any) => {
389
+ if (selectedValue?.length) {
390
+ formaData(selectedValue);
391
+ // 解决选择最后1页的sku,返回后,不显示名称问题
392
+ const source = _.uniqBy(items.concat(selectedValue), 'value')
393
+ ctx?.form?.setFieldSource(resultSourceKey, source)
394
+ setItems(source)
395
+ }
396
+ }
397
+
398
+ const handleOk = () => {
399
+ handleSelectOver(popvalue)
400
+ handleCancel();
401
+ };
402
+
403
+ const formaData = (value: any) => {
404
+ if (labelInValue) {
405
+ const formatResult = value.map((i: any) => ({ key: i[mappingValueField], label: i[mappingTextField], value: i[mappingValueField] }))
406
+ onChange(selectMode ? formatResult : formatResult[0], value)
407
+ } else {
408
+ const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
409
+ onChange(formatResult, value)
410
+ }
411
+ };
412
+
413
+ const handleCancel = () => {
414
+ form.resetFields();
415
+ setTableFormParams({});
416
+ setIsModalVisible(false);
417
+ if (selectMode) {
418
+ run();
419
+ }
420
+ };
421
+
422
+ const refreshItems = () => {
423
+ // 查看是否存在关联值 如果有关联值 就查询 没有就不能查询
424
+ if (fieldValToParam && ctx) {
425
+ let formValueList = [];
426
+ fieldValToParam.forEach((item: any, index: any) => {
427
+ const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
428
+ formValueList.push(fixedParamVal);
429
+ });
430
+ if (formValueList.filter((item: any) => item).length > 0) {
431
+ run();
432
+ } else {
433
+ setItems([]);
434
+ setItemsTotal(0);
435
+ }
436
+ } else {
437
+ run();
438
+ }
439
+ }
440
+
441
+ const onSearchChange = (e) => {
442
+ setSearchValue(e.target.value);
443
+ refreshItems();
444
+ }
445
+
446
+ const onSearchBlur = () => {
447
+ setSearchValue('');
448
+ refreshItems();
449
+ }
450
+
451
+ const onSearchTable = () => {
452
+ const params = form.getFieldsValue();
453
+ setTableFormParams(params);
454
+ getData({ ...params, pageSize: tableInitPageSize }, 2)
455
+ if (selectMode) {
456
+ getData(params)
457
+ }
458
+ }
459
+
460
+ const onResetTable = () => {
461
+ form.resetFields();
462
+ setTableFormParams({});
463
+ getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
464
+ }
465
+
466
+ const handleTableChange = (pagination) => {
467
+ getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
468
+ }
469
+
470
+ const onChangeCheckAll = (e) => {
471
+ if (e.target.checked) {
472
+ // 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
473
+ // 如果超过100条 就默认查出所有数据
474
+ const currentItemsData = JSON.parse(JSON.stringify(items))
475
+ const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize)
476
+ for (let i = 0; i <= totalPage - 1; i++) {
477
+ doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize * i, tablePagination?.pageSize * (i + 1))
478
+ }
479
+ setDoubleArr(doubleArr)
480
+ setSelectedRowKeys(currentItemsData.map(i => i.value))
481
+ setPopValue(currentItemsData);
482
+ if (items.length < itemsTotal) {
483
+ // TODO 请求接口获取所有数据
484
+ }
485
+ } else {
486
+ setSelectedRowKeys([])
487
+ setPopValue([]);
488
+ setDoubleArr([])
489
+ }
490
+ setIndeterminate(false);
491
+ setCheckedAll(e.target.checked);
492
+ }
493
+
494
+ const LightHeightOption = (props) => {
495
+ const {
496
+ filterTxt, text,
497
+ } = props
498
+ const heightLightTxt = (txt, heightTxt) => {
499
+ if (heightTxt === '') {
500
+ return txt
501
+ }
502
+ // 前面filterOption 不区分大小写,这里用i
503
+ const regexp = new RegExp(heightTxt, 'gi')
504
+ return txt.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
505
+ }
506
+ return (
507
+ <Tooltip title={text}>
508
+ <div ref={(nodeElement) => {
509
+ if (nodeElement) {
510
+ nodeElement.innerHTML = heightLightTxt(text, filterTxt)
511
+ }
512
+ }}
513
+ />
514
+ </Tooltip>
515
+ )
516
+ }
517
+
518
+ // 扁平化二维数组的方法
519
+ const mapRows = params => {
520
+ var res = [];
521
+ for (var i = 0; i < params.length; i++) {
522
+ if (Array.isArray(params[i])) {
523
+ // 去重
524
+ res = _.uniqBy(res.concat(mapRows(params[i])), 'value');
525
+ } else {
526
+ res.push(params[i]);
527
+ // 去重
528
+ res = _.uniqBy(res, 'value')
529
+ }
530
+ }
531
+ return res.filter(Boolean); //去掉undefined的情况
532
+ };
533
+
534
+ const onChangeSelectedKeys = (selectKeys, selectRows) => {
535
+ const nowPage = tablePagination?.current;
536
+
537
+ let filterRows = []; // 存放拼接后的一维数组的变量
538
+ let sksResult = [];
539
+
540
+ if (selectMode) {
541
+ // 处理多选分页累计选中
542
+ // 勾选生成二维数组
543
+ doubleArr[nowPage ? nowPage - 1 : 0] = selectRows
544
+ // console.log(doubleArr)
545
+ setDoubleArr(doubleArr)
546
+ // 这块扁平化成为一位数组
547
+ filterRows = mapRows(doubleArr);
548
+ // console.log(filterRows)
549
+
550
+ sksResult = filterRows.map((i) => i.value)
551
+ } else {
552
+ // 处理单选
553
+ filterRows = selectRows;
554
+ sksResult = selectRows.map((i) => i.value)
555
+ // 单选直接选中 不需要确定
556
+ handleSelectOver(filterRows)
557
+ handleCancel();
558
+ }
559
+
560
+ setSelectedRowKeys(sksResult)
561
+ setPopValue(filterRows);
562
+ setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
563
+ setCheckedAll(filterRows.length === tablePagination?.total);
564
+ }
565
+
566
+ // 生成唯一值
567
+ const makeUniqueValue = () => {
568
+ const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
569
+ setUniqueValue(generateUnitKey);
570
+ return generateUnitKey;
571
+ }
572
+
573
+ const rowSelection = {
574
+ type: selectMode ? 'checkbox' : 'radio',
575
+ selectedRowKeys,
576
+ onChange: (sks, srs) => {
577
+ onChangeSelectedKeys(sks, srs)
578
+ },
579
+ getCheckboxProps: () => {
580
+ return ({
581
+ disabled: selectProps?.disabled || props?.disabled || !items.length,
582
+ })
583
+ },
584
+ };
585
+
586
+ const onDoubleClickSelect = (e, record) => {
587
+ if (!selectMode && !(selectProps?.disabled || props?.disabled || !items.length)) {
588
+ const srs = [JSON.parse(JSON.stringify(record))]
589
+ const sks = srs.map((i: any) => i.value)
590
+ onChangeSelectedKeys(sks, srs)
591
+ }
592
+ }
593
+
594
+ const themeColor = { color: '#1890ff' }
595
+
596
+ const formItem = (list) => {
597
+ if (isModalVisible && list?.length) {
598
+ const setDisabled = (name: any) => {
599
+ const { fixedparamsDisabled = false, fixedparameter = [] }: any = requestConfig;
600
+ if (fixedparamsDisabled && fixedparameter.find((item: any) => item === name)) {
601
+ return true
602
+ } else {
603
+ return false
604
+ }
605
+ };
606
+ return list.map((i: any) => {
607
+ if (i?.type === 'select' || i?.field?.type === 'select') {
608
+ return (
609
+ <Form.Item name={i.name} label={i.label} key={i.name}>
610
+ <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
611
+ {i?.initialSource?.length && i?.initialSource.map((m: any) => (
612
+ <Option value={m.value} key={m.value}>{m.text}</Option>
613
+ ))}
614
+ </Select>
615
+ </Form.Item>
616
+ )
617
+ }
618
+
619
+ if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
620
+ return (
621
+ <Form.Item name={i.name} label={i.label} key={i.name}>
622
+ <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
623
+ </Form.Item>
624
+ )
625
+ }
626
+
627
+ if (i?.type === 'businessSearchSelect' || i?.field?.type === 'businessSearchSelect') {
628
+ return (
629
+ <div>
630
+ <Form.Item name={i.name} label={i.label} key={i.name}>
631
+ <BusinessSearchSelect {...i.field.props} disabled={setDisabled(i.name)} />
632
+ </Form.Item>
633
+ </div>
634
+ )
635
+ }
636
+
637
+ if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
638
+ return (
639
+ <div>
640
+ <Form.Item name={i.name} label={i.label} key={i.name}>
641
+ <QueryMutipleInput onValueChange={(value) => {
642
+ form.setFieldsValue({
643
+ [i.name]: value
644
+ })
645
+ }} />
646
+ </Form.Item>
647
+ </div>
648
+ );
649
+ }
650
+
651
+ // 默认type是input
652
+ return (
653
+ <Form.Item name={i.name} label={i.label} key={i.name}>
654
+ <Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
655
+ </Form.Item>
656
+ )
657
+ })
658
+ } else {
659
+ return null
660
+ }
661
+ }
662
+
663
+ const maxTagPlaceholder = (selectedValues) => {
664
+ const onClose = (e: any, item: any) => {
665
+ e.preventDefault();
666
+ const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value) : JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
667
+ onChange(newValue);
668
+ }
669
+ return (
670
+ <Tooltip title={selectedValues.map((i: any) => (
671
+ <Tag
672
+ closable={true}
673
+ onClose={(e) => onClose(e, i)}
674
+ style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
675
+ >
676
+ {i.label}
677
+ </Tag>
678
+ ))}>
679
+ {`+ ${selectedValues?.length}`}
680
+ </Tooltip>
681
+ )
682
+ }
683
+
684
+ return (
685
+ <div className={'search_select'}>
686
+ {fieldComponent ?
687
+ (<div onClick={() => {
688
+ fieldComponent.props?.onClick?.()
689
+ showModal()
690
+ }}>{fieldComponent}</div>) :
691
+ (<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
692
+ <Select
693
+ virtual
694
+ labelInValue={labelInValue}
695
+ value={value}
696
+ onChange={onChange}
697
+ disabled={props.disabled}
698
+ dropdownRender={menu => (
699
+ <>
700
+ <Input
701
+ value={searchValue}
702
+ style={{ width: '98%', marginLeft: '1%' }}
703
+ placeholder="请输入"
704
+ onChange={e => onSearchChange(e)}
705
+ onBlur={onSearchBlur}
706
+ onKeyDown={(e) => {
707
+ // 阻止多选的冒泡
708
+ e.stopPropagation()
709
+ }}
710
+ />
711
+ <Divider style={{ margin: '8px 0' }} />
712
+ {menu}
713
+ </>
714
+ )}
715
+ notFoundContent={
716
+ fetching ? <Spin size="small" /> :
717
+ <div style={{ textAlign: 'center' }}>
718
+ <div style={{ marginBottom: 16 }}>
719
+ <CopyOutlined style={{ fontSize: '50px' }} />
720
+ </div>
721
+ <div>无匹配结果,请更换其他内容再试</div>
722
+ </div>
723
+ }
724
+ onPopupScroll={SelectScroll}
725
+ style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
726
+ placeholder="请选择"
727
+ maxTagPlaceholder={maxTagPlaceholder}
728
+ {...currentSelectProps}
729
+ getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
730
+ >
731
+ {items.map(item => (
732
+ <Option key={item.value} label={item.text}>
733
+ {LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
734
+ </Option>
735
+ ))}
736
+ </Select>
737
+ {needModalTable && (
738
+ <Button style={{ width: '30px', padding: '2px', height: 'auto' }} onClick={showModal} type="primary">
739
+ <SearchOutlined />
740
+ </Button>
741
+ )}
742
+ </div>)}
743
+ {needModalTable && isModalVisible && (
744
+ <Modal
745
+ width='80%'
746
+ title={modalTableProps?.modalTableTitle}
747
+ visible={isModalVisible}
748
+ onOk={handleOk}
749
+ onCancel={handleCancel}
750
+ footer={selectMode ? [
751
+ <Button key="back" onClick={handleCancel}>
752
+ 取消
753
+ </Button>,
754
+ <Button
755
+ key="submit"
756
+ type="primary"
757
+ onClick={handleOk}
758
+ disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
759
+ >
760
+ 确定
761
+ </Button>,
762
+ ] : null}
763
+ >
764
+ <div className={'search_select_wrapper'}>
765
+ <div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
766
+ <CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1'} />
767
+ </div>
768
+ <div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
769
+ <div className={'select_list_columns'}>
770
+ <div className={'select_list_columns_tips'}>搜索</div>
771
+ <div className={'select_list_columns_formItems'}>
772
+ <Form form={form} layout='vertical' key='modalForm'>
773
+ {formItem(modalTableProps?.tableSearchForm)}
774
+ </Form>
775
+ </div>
776
+ </div>
777
+ <div className={'select_list_searchButton'}>
778
+ <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
779
+ <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
780
+ </div>
781
+ </div>
782
+ <div className={caretLeftFlag ? 'search_select_wrapper_right' : 'search_select_wrapper_right1'}>
783
+ <div>
784
+ <div className={'select_list_selectTips'}>
785
+ <div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
786
+ <div style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}>{selectMode ? '勾选后点击确定按钮完成选择' : '双击数据行或点击单选图标完成选择'}</div>
787
+ </div>
788
+ <Table
789
+ size='small'
790
+ rowSelection={rowSelection}
791
+ columns={modalTableProps?.tableColumns}
792
+ dataSource={tableData}
793
+ pagination={tablePagination}
794
+ onChange={handleTableChange}
795
+ rowKey={mappingValueField}
796
+ scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
797
+ onRow={record => {
798
+ return {
799
+ onDoubleClick: event => onDoubleClickSelect(event, record),
800
+ };
801
+ }}
802
+ />
803
+ {selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} disabled={selectProps?.disabled || props?.disabled} /> 全选所有页面</div> : ''}
804
+ </div>
805
+ </div>
806
+ </div>
807
+ </Modal>
808
+ )}
809
+ </div>
810
+ );
811
+ });
812
+
813
+ export default SearchSelect;