@bit-sun/business-component 2.2.47 → 2.2.49

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 (186) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  10. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  11. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
  12. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  13. package/dist/index.esm.js +666 -635
  14. package/dist/index.js +673 -642
  15. package/dist/utils/utils.d.ts +1 -1
  16. package/docs/index.md +21 -21
  17. package/lib/assets/drag.svg +17 -17
  18. package/lib/assets/exportFail.svg +37 -37
  19. package/lib/assets/exportProcessing.svg +28 -28
  20. package/lib/assets/exportSuccess.svg +34 -34
  21. package/lib/assets/label_icon_bottom.svg +25 -25
  22. package/lib/assets/upExport.svg +22 -22
  23. package/package.json +77 -77
  24. package/src/assets/32.svg +27 -27
  25. package/src/assets/addIcon.svg +17 -17
  26. package/src/assets/allfunc.svg +27 -27
  27. package/src/assets/arrowRight.svg +24 -24
  28. package/src/assets/btn-delete.svg +29 -29
  29. package/src/assets/btn-edit.svg +19 -19
  30. package/src/assets/btn-more.svg +17 -17
  31. package/src/assets/btn-submit.svg +19 -19
  32. package/src/assets/caidan.svg +11 -11
  33. package/src/assets/close.svg +26 -26
  34. package/src/assets/drag.svg +17 -17
  35. package/src/assets/exportFail.svg +37 -37
  36. package/src/assets/exportProcessing.svg +28 -28
  37. package/src/assets/exportSuccess.svg +34 -34
  38. package/src/assets/fixed-left-active.svg +11 -11
  39. package/src/assets/fixed-left.svg +15 -15
  40. package/src/assets/fixed-right-active.svg +11 -11
  41. package/src/assets/fixed-right.svg +15 -15
  42. package/src/assets/guanbi.svg +15 -15
  43. package/src/assets/icon-quanping.svg +15 -15
  44. package/src/assets/icon-shezhi.svg +17 -17
  45. package/src/assets/label_icon_bottom.svg +25 -25
  46. package/src/assets/list-no-img.svg +21 -21
  47. package/src/assets/morentouxiang-32.svg +23 -23
  48. package/src/assets/scanning.svg +24 -24
  49. package/src/assets/upExport.svg +22 -22
  50. package/src/components/Business/AddSelectBusiness/index.md +161 -161
  51. package/src/components/Business/AddSelectBusiness/index.tsx +861 -861
  52. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  53. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  54. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  64. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  65. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  66. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  67. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  68. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  69. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  70. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  71. package/src/components/Business/BsLayouts/index.less +79 -79
  72. package/src/components/Business/BsLayouts/index.tsx +1484 -1484
  73. package/src/components/Business/BsLayouts/service.ts +10 -10
  74. package/src/components/Business/BsLayouts/utils.tsx +203 -203
  75. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +564 -564
  76. package/src/components/Business/BsSulaQueryTable/index.less +221 -221
  77. package/src/components/Business/BsSulaQueryTable/index.tsx +527 -527
  78. package/src/components/Business/BsSulaQueryTable/setting.tsx +832 -832
  79. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  80. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  81. package/src/components/Business/CommodityEntry/index.md +70 -70
  82. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  83. package/src/components/Business/CommonAlert/index.tsx +23 -23
  84. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  85. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  86. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  87. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  88. package/src/components/Business/DetailPageWrapper/index.tsx +313 -313
  89. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  90. package/src/components/Business/HomePageWrapper/index.less +33 -33
  91. package/src/components/Business/HomePageWrapper/index.md +45 -45
  92. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  93. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  94. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  95. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  96. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  97. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  98. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  99. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  100. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  101. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  102. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  103. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  104. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  105. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  106. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  107. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  108. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  109. package/src/components/Business/JsonQueryTable/index.less +16 -16
  110. package/src/components/Business/JsonQueryTable/index.md +328 -328
  111. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  112. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  113. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  114. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  115. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  116. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  117. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  118. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  119. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  120. package/src/components/Business/JsonQueryTable/static.ts +390 -390
  121. package/src/components/Business/SearchSelect/BusinessUtils.ts +1732 -1732
  122. package/src/components/Business/SearchSelect/common.ts +53 -53
  123. package/src/components/Business/SearchSelect/index.md +1319 -1319
  124. package/src/components/Business/SearchSelect/index.tsx +51 -51
  125. package/src/components/Business/SearchSelect/utils.ts +100 -100
  126. package/src/components/Business/StateFlow/index.less +130 -130
  127. package/src/components/Business/StateFlow/index.md +60 -60
  128. package/src/components/Business/StateFlow/index.tsx +29 -29
  129. package/src/components/Business/TreeSearchSelect/index.md +154 -154
  130. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  131. package/src/components/Business/TreeSearchSelect/utils.ts +69 -69
  132. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  133. package/src/components/Business/columnSettingTable/index.less +247 -247
  134. package/src/components/Business/columnSettingTable/index.md +357 -357
  135. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  136. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  137. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  138. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +86 -86
  139. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  140. package/src/components/Business/moreTreeTable/index.less +99 -99
  141. package/src/components/Business/moreTreeTable/index.md +448 -448
  142. package/src/components/Business/moreTreeTable/index.tsx +380 -380
  143. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  144. package/src/components/Functional/AddSelect/helps.ts +14 -14
  145. package/src/components/Functional/AddSelect/index.less +367 -367
  146. package/src/components/Functional/AddSelect/index.md +155 -155
  147. package/src/components/Functional/AddSelect/index.tsx +1279 -1279
  148. package/src/components/Functional/BillEntry/index.less +371 -371
  149. package/src/components/Functional/BillEntry/index.md +39 -39
  150. package/src/components/Functional/BillEntry/index.tsx +772 -772
  151. package/src/components/Functional/DataImport/index.less +63 -63
  152. package/src/components/Functional/DataImport/index.md +44 -44
  153. package/src/components/Functional/DataImport/index.tsx +695 -695
  154. package/src/components/Functional/DataValidation/index.less +63 -63
  155. package/src/components/Functional/DataValidation/index.md +39 -39
  156. package/src/components/Functional/DataValidation/index.tsx +687 -687
  157. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  158. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  159. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  160. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  161. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  162. package/src/components/Functional/SearchSelect/index.less +115 -115
  163. package/src/components/Functional/SearchSelect/index.md +141 -141
  164. package/src/components/Functional/SearchSelect/index.tsx +849 -849
  165. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  166. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  167. package/src/components/Functional/TreeSearchSelect/index.tsx +162 -162
  168. package/src/index.ts +34 -34
  169. package/src/plugin/TableColumnSetting/index.less +247 -247
  170. package/src/plugin/TableColumnSetting/index.md +50 -50
  171. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  172. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  173. package/src/styles/bsDefault.less +1912 -1912
  174. package/src/utils/CheckOneUser/index.md +39 -39
  175. package/src/utils/CheckOneUser/index.ts +51 -51
  176. package/src/utils/LocalstorageUtils.ts +90 -90
  177. package/src/utils/TableUtils.tsx +18 -18
  178. package/src/utils/checkUtils.ts +39 -39
  179. package/src/utils/enumConfig.ts +11 -11
  180. package/src/utils/getFormMode.js +12 -12
  181. package/src/utils/index.ts +3 -3
  182. package/src/utils/requestUtils.ts +34 -34
  183. package/src/utils/serialize.js +7 -7
  184. package/src/utils/utils.ts +183 -183
  185. package/tsconfig.json +29 -29
  186. package/typings.d.ts +4 -4
@@ -1,849 +1,849 @@
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
- // 单选 默认直接选中 不需要确定 配置了modalRadioNeedFooter就需要确定
590
- if(!modalTableProps?.modalRadioNeedFooter) {
591
- handleSelectOver(filterRows)
592
- handleCancel();
593
- }
594
- }
595
-
596
- setSelectedRowKeys(sksResult)
597
- setPopValue(filterRows);
598
- setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
599
- setCheckedAll(filterRows.length === tablePagination?.total);
600
- }
601
-
602
- // 生成唯一值
603
- const makeUniqueValue = () => {
604
- const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
605
- setUniqueValue(generateUnitKey);
606
- return generateUnitKey;
607
- }
608
-
609
- const rowSelection = {
610
- type: selectMode ? 'checkbox' : 'radio',
611
- selectedRowKeys,
612
- onChange: (sks, srs) => {
613
- onChangeSelectedKeys(sks, srs)
614
- },
615
- getCheckboxProps: () => {
616
- return ({
617
- disabled: selectProps?.disabled || props?.disabled || (!items.length && !tableData.length),
618
- })
619
- },
620
- };
621
-
622
- const onDoubleClickSelect = (e, record) => {
623
- if (!selectMode && !(selectProps?.disabled || props?.disabled || (!items.length && !tableData.length))) {
624
- const srs = [JSON.parse(JSON.stringify(record))]
625
- const sks = srs.map((i: any) => i.value)
626
- onChangeSelectedKeys(sks, srs)
627
- }
628
- }
629
-
630
- const themeColor = { color: '#1890ff' }
631
-
632
- const formItem = (list) => {
633
- if (isModalVisible && list?.length) {
634
- const setDisabled = (name: any) => {
635
- if (fixedparamsDisabled && fixedparameter?.length && fixedparameter.find((item: any) => item === name)) {
636
- return true
637
- } else {
638
- return false
639
- }
640
- };
641
- return list.map((i: any) => {
642
- if (i?.type === 'select' || i?.field?.type === 'select') {
643
- return (
644
- <Form.Item name={i.name} label={i.label} key={i.name}>
645
- <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
646
- {i?.initialSource?.length && i?.initialSource.map((m: any) => (
647
- <Option value={m.value} key={m.value}>{m.text}</Option>
648
- ))}
649
- </Select>
650
- </Form.Item>
651
- )
652
- }
653
-
654
- if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
655
- return (
656
- <Form.Item name={i.name} label={i.label} key={i.name}>
657
- <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
658
- </Form.Item>
659
- )
660
- }
661
-
662
- if (i?.type === 'businessSearchSelect' || i?.field?.type === 'businessSearchSelect') {
663
- return (
664
- <div>
665
- <Form.Item name={i.name} label={i.label} key={i.name}>
666
- <BusinessSearchSelect {...i.field.props} disabled={setDisabled(i.name)} />
667
- </Form.Item>
668
- </div>
669
- )
670
- }
671
-
672
- if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
673
- return (
674
- <div>
675
- <Form.Item name={i.name} label={i.label} key={i.name}>
676
- <QueryMutipleInput onValueChange={(value) => {
677
- form.setFieldsValue({
678
- [i.name]: value
679
- })
680
- }} />
681
- </Form.Item>
682
- </div>
683
- );
684
- }
685
-
686
- // 默认type是input
687
- return (
688
- <Form.Item name={i.name} label={i.label} key={i.name}>
689
- <Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
690
- </Form.Item>
691
- )
692
- })
693
- } else {
694
- return null
695
- }
696
- }
697
-
698
- const maxTagPlaceholder = (selectedValues) => {
699
- const onClose = (e: any, item: any) => {
700
- e.preventDefault();
701
- 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)
702
- onChange(newValue);
703
- }
704
- return (
705
- <Tooltip title={selectedValues.map((i: any) => (
706
- <Tag
707
- closable={true}
708
- onClose={(e) => onClose(e, i)}
709
- style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
710
- >
711
- {i.label}
712
- </Tag>
713
- ))}>
714
- {`+ ${selectedValues?.length}`}
715
- </Tooltip>
716
- )
717
- }
718
-
719
- return (
720
- <div className={'search_select'}>
721
- {fieldComponent ?
722
- (<div onClick={() => {
723
- fieldComponent.props?.onClick?.()
724
- showModal()
725
- }}>{fieldComponent}</div>) :
726
- (<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
727
- <Select
728
- virtual
729
- labelInValue={labelInValue}
730
- value={value}
731
- onChange={onChange}
732
- disabled={props.disabled}
733
- dropdownRender={menu => (
734
- <>
735
- <Input
736
- value={searchValue}
737
- style={{ width: '98%', marginLeft: '1%' }}
738
- placeholder="请输入"
739
- onChange={e => onSearchChange(e)}
740
- onBlur={onSearchBlur}
741
- onKeyDown={(e) => {
742
- // 阻止多选的冒泡
743
- e.stopPropagation()
744
- }}
745
- />
746
- <Divider style={{ margin: '8px 0' }} />
747
- {menu}
748
- </>
749
- )}
750
- notFoundContent={
751
- fetching ? <Spin size="small" /> :
752
- <div style={{ textAlign: 'center' }}>
753
- <div style={{ marginBottom: 16 }}>
754
- <CopyOutlined style={{ fontSize: '50px' }} />
755
- </div>
756
- <div>无匹配结果,请更换其他内容再试</div>
757
- </div>
758
- }
759
- onPopupScroll={SelectScroll}
760
- style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
761
- placeholder="请选择"
762
- maxTagPlaceholder={maxTagPlaceholder}
763
- {...currentSelectProps}
764
- getPopupContainer={(triggerNode) => (getPopupContainer && getPopupContainer(triggerNode)) || triggerNode.parentElement}
765
- >
766
- {items.map(item => (
767
- <Option key={item.value} label={item.text}>
768
- {LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
769
- </Option>
770
- ))}
771
- </Select>
772
- {needModalTable && (
773
- <Button style={{ width: '30px', padding: '2px', height: 'auto' }} onClick={showModal} type="primary">
774
- <SearchOutlined />
775
- </Button>
776
- )}
777
- </div>)}
778
- {needModalTable && isModalVisible && (
779
- <Modal
780
- width='80%'
781
- title={modalTableProps?.modalTableTitle}
782
- visible={isModalVisible}
783
- onOk={handleOk}
784
- onCancel={handleCancel}
785
- footer={(selectMode || modalTableProps?.modalRadioNeedFooter) ? [
786
- <Button key="back" onClick={handleCancel}>
787
- 取消
788
- </Button>,
789
- <Button
790
- key="submit"
791
- type="primary"
792
- onClick={handleOk}
793
- disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
794
- >
795
- 确定
796
- </Button>,
797
- ] : null}
798
- {...(modalTableProps?.modalProps || {})}
799
- >
800
- <div className={'search_select_wrapper'}>
801
- <div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
802
- <CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1'} />
803
- </div>
804
- <div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
805
- <div className={'select_list_columns'}>
806
- <div className={'select_list_columns_tips'}>搜索</div>
807
- <div className={'select_list_columns_formItems'}>
808
- <Form form={form} layout='vertical' key='modalForm'>
809
- {formItem(modalTableProps?.tableSearchForm)}
810
- </Form>
811
- </div>
812
- </div>
813
- <div className={'select_list_searchButton'}>
814
- <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
815
- <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
816
- </div>
817
- </div>
818
- <div className={caretLeftFlag ? 'search_select_wrapper_right' : 'search_select_wrapper_right1'}>
819
- <div>
820
- <div className={'select_list_selectTips'}>
821
- <div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
822
- <div style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}>{selectMode ? '勾选后点击确定按钮完成选择' : '双击数据行或点击单选图标完成选择'}</div>
823
- </div>
824
- <Table
825
- size='small'
826
- rowSelection={rowSelection}
827
- columns={modalTableProps?.tableColumns}
828
- dataSource={tableData}
829
- pagination={tablePagination}
830
- onChange={handleTableChange}
831
- rowKey={mappingValueField}
832
- scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
833
- onRow={record => {
834
- return {
835
- onDoubleClick: event => onDoubleClickSelect(event, record),
836
- };
837
- }}
838
- />
839
- {selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} disabled={selectProps?.disabled || props?.disabled} /> 全选所有页面</div> : ''}
840
- </div>
841
- </div>
842
- </div>
843
- </Modal>
844
- )}
845
- </div>
846
- );
847
- });
848
-
849
- 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
+ // 单选 默认直接选中 不需要确定 配置了modalRadioNeedFooter就需要确定
590
+ if(!modalTableProps?.modalRadioNeedFooter) {
591
+ handleSelectOver(filterRows)
592
+ handleCancel();
593
+ }
594
+ }
595
+
596
+ setSelectedRowKeys(sksResult)
597
+ setPopValue(filterRows);
598
+ setIndeterminate(!!filterRows.length && filterRows.length < tablePagination?.total);
599
+ setCheckedAll(filterRows.length === tablePagination?.total);
600
+ }
601
+
602
+ // 生成唯一值
603
+ const makeUniqueValue = () => {
604
+ const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
605
+ setUniqueValue(generateUnitKey);
606
+ return generateUnitKey;
607
+ }
608
+
609
+ const rowSelection = {
610
+ type: selectMode ? 'checkbox' : 'radio',
611
+ selectedRowKeys,
612
+ onChange: (sks, srs) => {
613
+ onChangeSelectedKeys(sks, srs)
614
+ },
615
+ getCheckboxProps: () => {
616
+ return ({
617
+ disabled: selectProps?.disabled || props?.disabled || (!items.length && !tableData.length),
618
+ })
619
+ },
620
+ };
621
+
622
+ const onDoubleClickSelect = (e, record) => {
623
+ if (!selectMode && !(selectProps?.disabled || props?.disabled || (!items.length && !tableData.length))) {
624
+ const srs = [JSON.parse(JSON.stringify(record))]
625
+ const sks = srs.map((i: any) => i.value)
626
+ onChangeSelectedKeys(sks, srs)
627
+ }
628
+ }
629
+
630
+ const themeColor = { color: '#1890ff' }
631
+
632
+ const formItem = (list) => {
633
+ if (isModalVisible && list?.length) {
634
+ const setDisabled = (name: any) => {
635
+ if (fixedparamsDisabled && fixedparameter?.length && fixedparameter.find((item: any) => item === name)) {
636
+ return true
637
+ } else {
638
+ return false
639
+ }
640
+ };
641
+ return list.map((i: any) => {
642
+ if (i?.type === 'select' || i?.field?.type === 'select') {
643
+ return (
644
+ <Form.Item name={i.name} label={i.label} key={i.name}>
645
+ <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
646
+ {i?.initialSource?.length && i?.initialSource.map((m: any) => (
647
+ <Option value={m.value} key={m.value}>{m.text}</Option>
648
+ ))}
649
+ </Select>
650
+ </Form.Item>
651
+ )
652
+ }
653
+
654
+ if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
655
+ return (
656
+ <Form.Item name={i.name} label={i.label} key={i.name}>
657
+ <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
658
+ </Form.Item>
659
+ )
660
+ }
661
+
662
+ if (i?.type === 'businessSearchSelect' || i?.field?.type === 'businessSearchSelect') {
663
+ return (
664
+ <div>
665
+ <Form.Item name={i.name} label={i.label} key={i.name}>
666
+ <BusinessSearchSelect {...i.field.props} disabled={setDisabled(i.name)} />
667
+ </Form.Item>
668
+ </div>
669
+ )
670
+ }
671
+
672
+ if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
673
+ return (
674
+ <div>
675
+ <Form.Item name={i.name} label={i.label} key={i.name}>
676
+ <QueryMutipleInput onValueChange={(value) => {
677
+ form.setFieldsValue({
678
+ [i.name]: value
679
+ })
680
+ }} />
681
+ </Form.Item>
682
+ </div>
683
+ );
684
+ }
685
+
686
+ // 默认type是input
687
+ return (
688
+ <Form.Item name={i.name} label={i.label} key={i.name}>
689
+ <Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
690
+ </Form.Item>
691
+ )
692
+ })
693
+ } else {
694
+ return null
695
+ }
696
+ }
697
+
698
+ const maxTagPlaceholder = (selectedValues) => {
699
+ const onClose = (e: any, item: any) => {
700
+ e.preventDefault();
701
+ 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)
702
+ onChange(newValue);
703
+ }
704
+ return (
705
+ <Tooltip title={selectedValues.map((i: any) => (
706
+ <Tag
707
+ closable={true}
708
+ onClose={(e) => onClose(e, i)}
709
+ style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
710
+ >
711
+ {i.label}
712
+ </Tag>
713
+ ))}>
714
+ {`+ ${selectedValues?.length}`}
715
+ </Tooltip>
716
+ )
717
+ }
718
+
719
+ return (
720
+ <div className={'search_select'}>
721
+ {fieldComponent ?
722
+ (<div onClick={() => {
723
+ fieldComponent.props?.onClick?.()
724
+ showModal()
725
+ }}>{fieldComponent}</div>) :
726
+ (<div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
727
+ <Select
728
+ virtual
729
+ labelInValue={labelInValue}
730
+ value={value}
731
+ onChange={onChange}
732
+ disabled={props.disabled}
733
+ dropdownRender={menu => (
734
+ <>
735
+ <Input
736
+ value={searchValue}
737
+ style={{ width: '98%', marginLeft: '1%' }}
738
+ placeholder="请输入"
739
+ onChange={e => onSearchChange(e)}
740
+ onBlur={onSearchBlur}
741
+ onKeyDown={(e) => {
742
+ // 阻止多选的冒泡
743
+ e.stopPropagation()
744
+ }}
745
+ />
746
+ <Divider style={{ margin: '8px 0' }} />
747
+ {menu}
748
+ </>
749
+ )}
750
+ notFoundContent={
751
+ fetching ? <Spin size="small" /> :
752
+ <div style={{ textAlign: 'center' }}>
753
+ <div style={{ marginBottom: 16 }}>
754
+ <CopyOutlined style={{ fontSize: '50px' }} />
755
+ </div>
756
+ <div>无匹配结果,请更换其他内容再试</div>
757
+ </div>
758
+ }
759
+ onPopupScroll={SelectScroll}
760
+ style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
761
+ placeholder="请选择"
762
+ maxTagPlaceholder={maxTagPlaceholder}
763
+ {...currentSelectProps}
764
+ getPopupContainer={(triggerNode) => (getPopupContainer && getPopupContainer(triggerNode)) || triggerNode.parentElement}
765
+ >
766
+ {items.map(item => (
767
+ <Option key={item.value} label={item.text}>
768
+ {LightHeightOption({ text: `${item.textShowKey} ${Array.isArray(item.textShowText) && item.textShowText.join(' ') || item.textShowText}`, filterTxt: searchValue })}
769
+ </Option>
770
+ ))}
771
+ </Select>
772
+ {needModalTable && (
773
+ <Button style={{ width: '30px', padding: '2px', height: 'auto' }} onClick={showModal} type="primary">
774
+ <SearchOutlined />
775
+ </Button>
776
+ )}
777
+ </div>)}
778
+ {needModalTable && isModalVisible && (
779
+ <Modal
780
+ width='80%'
781
+ title={modalTableProps?.modalTableTitle}
782
+ visible={isModalVisible}
783
+ onOk={handleOk}
784
+ onCancel={handleCancel}
785
+ footer={(selectMode || modalTableProps?.modalRadioNeedFooter) ? [
786
+ <Button key="back" onClick={handleCancel}>
787
+ 取消
788
+ </Button>,
789
+ <Button
790
+ key="submit"
791
+ type="primary"
792
+ onClick={handleOk}
793
+ disabled={!tableData.length || (selectProps?.disabled || props?.disabled)}
794
+ >
795
+ 确定
796
+ </Button>,
797
+ ] : null}
798
+ {...(modalTableProps?.modalProps || {})}
799
+ >
800
+ <div className={'search_select_wrapper'}>
801
+ <div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>
802
+ <CaretLeftOutlined className={caretLeftFlag ? 'search_select_wrapper_click_flag_arrow' : 'search_select_wrapper_click_flag_arrow_1'} />
803
+ </div>
804
+ <div className={caretLeftFlag ? 'search_select_wrapper_left' : 'search_select_wrapper_left1'}>
805
+ <div className={'select_list_columns'}>
806
+ <div className={'select_list_columns_tips'}>搜索</div>
807
+ <div className={'select_list_columns_formItems'}>
808
+ <Form form={form} layout='vertical' key='modalForm'>
809
+ {formItem(modalTableProps?.tableSearchForm)}
810
+ </Form>
811
+ </div>
812
+ </div>
813
+ <div className={'select_list_searchButton'}>
814
+ <Button key='reset' className={'select_list_button_space'} onClick={onResetTable}>重置</Button>
815
+ <Button key='search' type="primary" onClick={onSearchTable}>查询</Button>
816
+ </div>
817
+ </div>
818
+ <div className={caretLeftFlag ? 'search_select_wrapper_right' : 'search_select_wrapper_right1'}>
819
+ <div>
820
+ <div className={'select_list_selectTips'}>
821
+ <div style={{ marginLeft: 8 }}>搜索结果共<span style={themeColor}>{tablePagination?.total || 0}</span>项{selectMode ? <span>, 本次已选<span style={themeColor}>{selectedRowKeys?.length || 0}</span>项</span> : ''}</div>
822
+ <div style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}>{selectMode ? '勾选后点击确定按钮完成选择' : '双击数据行或点击单选图标完成选择'}</div>
823
+ </div>
824
+ <Table
825
+ size='small'
826
+ rowSelection={rowSelection}
827
+ columns={modalTableProps?.tableColumns}
828
+ dataSource={tableData}
829
+ pagination={tablePagination}
830
+ onChange={handleTableChange}
831
+ rowKey={mappingValueField}
832
+ scroll={{ x: modalTableProps.overScrollX || 'max-content', y: modalTableProps.overScrollY || null }}
833
+ onRow={record => {
834
+ return {
835
+ onDoubleClick: event => onDoubleClickSelect(event, record),
836
+ };
837
+ }}
838
+ />
839
+ {selectMode ? <div className={'select_list_selectAll'}><Checkbox indeterminate={indeterminate} checked={checkedAll} onChange={onChangeCheckAll} disabled={selectProps?.disabled || props?.disabled} /> 全选所有页面</div> : ''}
840
+ </div>
841
+ </div>
842
+ </div>
843
+ </Modal>
844
+ )}
845
+ </div>
846
+ );
847
+ });
848
+
849
+ export default SearchSelect;