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