@bit-sun/business-component 1.2.3 → 1.2.4-alpha.1

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