@bit-sun/business-component 4.0.12-alpha.28 → 4.0.12-alpha.29

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.
@@ -6,8 +6,8 @@ import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/ico
6
6
  import request from '@/utils/request';
7
7
  import _, { escapeRegExp, isNil, values } from "lodash"
8
8
  import './index.less';
9
- import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
10
- import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource, convertUrlQueryParams, convertBodyParams, formatSelectedValue } from './utils';
9
+ import { BusinessSearchSelect, QueryMutipleInput, QueryMutipleSearchSelect } from '@/index';
10
+ import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource, handleParams, convertUrlQueryParams, convertBodyParams, formatSelectedValue, convertResData, makeUniqueValue, handleSelectOptionsShowValue, LightHeightOption, maxTagPlaceholder } from './utils';
11
11
  import { judgeIsRequestError } from '@/utils/requestUtils';
12
12
  import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
13
13
  import PropertySelector from '@/components/Business/PropertyModal';
@@ -219,105 +219,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
219
219
  }
220
220
 
221
221
  // 数组对象处理,对带有特殊标记的name进行处理
222
- for (const key in params) {
223
- if (Object.prototype.hasOwnProperty.call(params, key)) {
224
- const element = params[key];
225
- if (element && key.indexOf('*number*') >= 0) {
226
- const dataParams = key.split('*number*');
227
- dataParams.forEach((value, index) => {
228
- params[value] = element[index];
229
- });
230
- delete params[key];
231
- } else if (element && key.indexOf('*address*') >= 0) {
232
- const dataParams = key.split('*address*');
233
- dataParams.forEach((value, index) => {
234
- params[value] = element.PCDCode[index];
235
- });
236
- delete params[key];
237
- } else if (element && key.indexOf('*costType*') >= 0) {
238
- const dataParams = key.split('*costType*');
239
- // eslint-disable-next-line prefer-destructuring
240
- params[dataParams[0]] = element[1];
241
- delete params[key];
242
- } else if (element && key.indexOf('*fullDate*') >= 0) {
243
- const dataParams = key.split('*fullDate*');
244
- dataParams.forEach((value, index) => {
245
- if (index === 0) {
246
- params[value] = moment(element[index])
247
- .millisecond(0)
248
- .second(0)
249
- .minute(0)
250
- .hour(0)
251
- .format('YYYY-MM-DD HH:mm:ss');
252
- } else {
253
- params[value] = moment(element[index])
254
- .millisecond(59)
255
- .second(59)
256
- .minute(59)
257
- .hour(23)
258
- .format('YYYY-MM-DD HH:mm:ss');
259
- }
260
- });
261
- delete params[key];
262
- } else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
263
- const dataParams = key.split('*checkBox*');
264
- if (element) {
265
- params[dataParams[0]] = 0
266
- }
267
- delete params[key];
268
- } else if (element && key.indexOf('*cascader*') >= 0) {
269
- const dataParams = key.split('*cascader*');
270
- params[dataParams[0]] = element[element.length - 1]
271
- delete params[key];
272
- } else if (element && key.indexOf('*date*') >= 0) {
273
- const dataParams = key.split('*date*')
274
- dataParams.forEach((value, index) => {
275
- if (index === 0) {
276
- params[value] = moment(element[index])
277
- .format('YYYY-MM-DD');
278
- } else {
279
- params[value] = moment(element[index])
280
- .format('YYYY-MM-DD');
281
- }
282
- });
283
- delete params[key];
284
- } else if (element && key.indexOf('*multiInput') >= 0) {
285
- let name = '',
286
- value = element['value'];
287
- if (value.indexOf(',') >= 0) {
288
- name = `qp-${element['name']}-in`;
289
- } else {
290
- name = `qp-${element['name']}-like`;
291
- }
292
- params[name] = value;
293
- delete params[key];
294
- }
295
- else if (element && key.indexOf('*') >= 0) {
296
- const dataParams = key.split('*');
297
- dataParams.forEach((value, index) => {
298
- params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
299
- });
300
- delete params[key];
301
- } else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
302
- const dataParams = key.split('_selectNumberRange')[0]
303
- if (params[key][0] === 'range') {
304
- if (params[key][1][0]) {
305
- params[`qp-${dataParams}-ge`] = params[key][1][0]
306
- }
307
- if (params[key][1][1]) {
308
- params[`qp-${dataParams}-le`] = params[key][1][1]
309
- }
310
- } else {
311
- params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
312
- }
313
- delete params[key]
314
- } else if (Array.isArray(element)) {
315
- params[key] = element.join(',');
316
- } else if (element == null || element === undefined || String(element).trim() === '') {
317
- delete params[key]
318
- }
319
- }
320
- }
222
+ handleParams(params)
321
223
 
322
224
  const queryParams = {
323
225
  pageSize,
@@ -348,77 +250,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
348
250
  return;
349
251
  }
350
252
  const res = result.data;
351
- let source = [];
352
- if (isMap) {
353
- source = Object.keys(res).map((d, i) => {
354
- return {
355
- text: Object.values(res)[i],
356
- value: d,
357
- };
358
- });
359
- } else {
360
- const keys = res.list ? 'list' : 'items';
361
- source = res
362
- ? res[keys]
363
- ? res[keys].map((item: any, index: number) => {
364
- let textShowText = item[mappingTextField]
365
- if (mappingTextShowTextField) {
366
- textShowText = []
367
- if (Array.isArray(mappingTextShowTextField)) {
368
- mappingTextShowTextField.forEach((r: any) => {
369
- textShowText.push(item[r])
370
- })
371
- } else {
372
- textShowText = item[mappingTextShowTextField]
373
- }
374
- }
375
- if(!item?.children?.length) {delete item?.children};
376
- return {
377
- ...item,
378
- text: specialBracket
379
- ? `【${item[mappingValueField]}】${item[mappingTextField]}`
380
- : item[mappingTextField],
381
- textShowText,
382
- textShowKey: item[mappingTextShowKeyField || mappingValueField],
383
- value: item[mappingValueField],
384
- keyIndex: type != 1 ? ((queryParams?.currentPage - 1) * queryParams?.pageSize + index + 1) : (index+1),
385
- };
386
- })
387
- : Array.isArray(res) &&
388
- res?.map((item: Record<string, any>, index: number) => {
389
- let textShowText = item[mappingTextField]
390
- if (mappingTextShowTextField) {
391
- textShowText = []
392
- if (Array.isArray(mappingTextShowTextField)) {
393
- mappingTextShowTextField.forEach((r: any) => {
394
- textShowText.push(item[r])
395
- })
396
- } else {
397
- textShowText = item[mappingTextShowTextField]
398
- }
399
- }
400
- if(!item?.children?.length) {delete item?.children};
401
- return {
402
- ...item,
403
- text: specialBracket
404
- ? `【${item[mappingValueField]}】${item[mappingTextField]}`
405
- : item[mappingTextField],
406
- textShowText,
407
- textShowKey: item[mappingTextShowKeyField || mappingValueField],
408
- value: item[mappingValueField],
409
- keyIndex: type != 1 ? ((queryParams?.currentPage - 1) * queryParams?.pageSize + index + 1) : (index+1),
410
- };
411
- })
412
- : [];
413
- }
414
- // 补充搜索项--选中的数据添加到数据源中去
415
- const currentSRKs = getCurrentSRKs(selectMode,labelInValue,value)
416
- if(type === 1 && currentSRKs?.length && currentSRKs?.some(s=> !source?.find(r=> r.value==s))) {
417
- const selectedOption = items.filter(option => currentSRKs?.includes(option.value))||[];
418
- source = (source||[]).concat(selectedOption)
419
- }
420
- // 数据源 不可以有重复key
421
- source = Array.isArray(source) ? _.uniqBy(source, 'value') : [];
253
+ const source: any = convertResData(requestConfig, res, { selectMode, labelInValue, value, type, items, queryParams });
422
254
 
423
255
  if(callback) {
424
256
  callback(source)
@@ -488,7 +320,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
488
320
  }, [value]);
489
321
 
490
322
  useEffect(() => {
491
- makeUniqueValue();
323
+ setUniqueValue(makeUniqueValue());
492
324
  }, [resultSourceKey])
493
325
 
494
326
  useEffect(() => {
@@ -657,30 +489,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
657
489
  const handleTableChange = (pagination) => {
658
490
  getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
659
491
  }
660
- const LightHeightOption = (props) => {
661
- const {
662
- filterTxt, text,
663
- } = props
664
- const heightLightTxt = (text, heightTxt) => {
665
- if (heightTxt === '') {
666
- return text
667
- }
668
- const searchString = escapeRegExp(heightTxt);
669
- // 前面filterOption 不区分大小写,这里用i
670
- const regexp = new RegExp(searchString, 'gi')
671
- return text.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
672
- }
673
- return (
674
- <Tooltip title={text}>
675
- <div ref={(nodeElement) => {
676
- if (nodeElement) {
677
- nodeElement.innerHTML = heightLightTxt(text, filterTxt)
678
- }
679
- }}
680
- />
681
- </Tooltip>
682
- )
683
- }
684
492
 
685
493
  // 扁平化二维数组的方法
686
494
  const mapRows = params => {
@@ -714,13 +522,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
714
522
  setCheckedAll(selectRows.length === tablePagination?.total);
715
523
  }
716
524
 
717
- // 生成唯一值
718
- const makeUniqueValue = () => {
719
- const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
720
- setUniqueValue(generateUnitKey);
721
- return generateUnitKey;
722
- }
723
-
724
525
  const rowSelection = {
725
526
  type: selectMode ? 'checkbox' : 'radio',
726
527
  selectedRowKeys,
@@ -831,6 +632,18 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
831
632
  </Col>
832
633
  );
833
634
  }
635
+ if (i?.field?.type === 'multipleQuerySearchSelect') {
636
+ return (
637
+ <Col span={ColSpan} key={i.name}>
638
+ <Form.Item name={i.name} label={i.label} key={i.name}>
639
+ <QueryMutipleSearchSelect {...i.field.props} onValueChange={(value) => {
640
+ form.setFieldsValue({
641
+ [i.name]: value
642
+ })}} />
643
+ </Form.Item>
644
+ </Col>
645
+ );
646
+ }
834
647
 
835
648
  // 默认type是input
836
649
  return (
@@ -998,57 +811,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
998
811
  );
999
812
  }
1000
813
 
1001
- const maxTagPlaceholder = (selectedValues) => {
1002
- const onClose = (e: any, item: any) => {
1003
- e.preventDefault();
1004
- 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)
1005
- onChange(newValue);
1006
- }
1007
- return (
1008
- <Tooltip
1009
- overlayClassName='searchSelectMaxTagToolTip'
1010
- destroyTooltipOnHide
1011
- placement="topRight"
1012
- autoAdjustOverflow={false}
1013
- title={(
1014
- <div
1015
- style={{ margin: '6px 8px 0px' }}
1016
- onMouseEnter={() => {
1017
- setIsMaxTagsOpen(true)
1018
- }}
1019
- onMouseLeave={() => {
1020
- setIsMaxTagsOpen(false)
1021
- }}
1022
- >
1023
- {selectedValues.map((i: any) => (
1024
- <Tag
1025
- closable={true}
1026
- onClose={(e) => onClose(e, i)}
1027
- style={{ margin: '0px 3px 3px 0px', background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
1028
- >
1029
- {i.label}
1030
- </Tag>
1031
- ))}
1032
- </div>
1033
- )}
1034
- >
1035
- {`+ ${selectedValues?.length}`}
1036
- </Tooltip>
1037
- )
1038
- }
1039
-
1040
- const handleSelectOptionsShowValue = (specialBracket: boolean, noNeedSplit: boolean, item: object) => {
1041
- let showText = Array.isArray(item.textShowText) &&
1042
- item.textShowText.join(' ') || item.textShowText;
1043
- if (noNeedSplit) {
1044
- return item.text;
1045
- } else {
1046
- return specialBracket
1047
- ? `【${item.textShowKey || ''}】${showText}`
1048
- : `${item.textShowKey || ''} ${showText}`
1049
- }
1050
- };
1051
-
1052
814
  const getShowLabelTextStr = (kongValue): string => {
1053
815
  if (selectMode) {
1054
816
  return Array.isArray(value) && value?.map(item => item.label || item.text || '')?.join(',') || kongValue;
@@ -1121,7 +883,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
1121
883
  onPopupScroll={SelectScroll}
1122
884
  style={{ width: 'calc(100%)' }}
1123
885
  placeholder="请选择"
1124
- maxTagPlaceholder={maxTagPlaceholder}
886
+ maxTagPlaceholder={(v)=> maxTagPlaceholder(v,{ selectProps:{labelInValue}, onChange, value, setIsMaxTagsOpen })}
1125
887
  onSearch={(v) => onSearchChange(v)}
1126
888
  {...(needModalTable ? {
1127
889
  suffixIcon: <div className={`search_select_expand_button ${(sDisabled)?'search_select_expand_button_disabled':''}`} onClick={showModal}><SearchOutlined /></div>