@bit-sun/business-component 4.0.11-alpha.2 → 4.0.11-alpha.21

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 (41) hide show
  1. package/.umirc.ts +10 -6
  2. package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +2 -4
  3. package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +2 -1
  4. package/dist/components/Functional/SearchSelect/utils.d.ts +11 -0
  5. package/dist/index.esm.js +1706 -930
  6. package/dist/index.js +1705 -929
  7. package/package.json +1 -1
  8. package/src/assets/copyImg.svg +16 -0
  9. package/src/assets/zhankaitiaojian-icon.svg +18 -0
  10. package/src/components/Business/BsLayouts/index.tsx +17 -0
  11. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +45 -17
  12. package/src/components/Business/BsSulaQueryTable/index.less +21 -38
  13. package/src/components/Business/BsSulaQueryTable/index.tsx +17 -15
  14. package/src/components/Business/BsSulaQueryTable/setting.tsx +5 -5
  15. package/src/components/Business/BsSulaQueryTable/utils.tsx +1 -1
  16. package/src/components/Business/DetailPageWrapper/index.less +10 -2
  17. package/src/components/Business/DetailPageWrapper/index.tsx +1 -1
  18. package/src/components/Business/HomePageWrapper/index.less +9 -0
  19. package/src/components/Business/HomePageWrapper/index.tsx +1 -1
  20. package/src/components/Business/SearchSelect/BusinessUtils.tsx +834 -179
  21. package/src/components/Business/SearchSelect/index.md +181 -0
  22. package/src/components/Business/SearchSelect/index.tsx +2 -1
  23. package/src/components/Business/SearchSelect/utils.ts +4 -1
  24. package/src/components/Business/StateFlow/index.less +140 -124
  25. package/src/components/Business/StateFlow/index.tsx +3 -3
  26. package/src/components/Business/columnSettingTable/columnSetting.tsx +6 -6
  27. package/src/components/Business/columnSettingTable/index.less +33 -71
  28. package/src/components/Business/columnSettingTable/index.tsx +3 -4
  29. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +3 -5
  30. package/src/components/Common/ParagraphCopier/index.tsx +2 -6
  31. package/src/components/Functional/QueryMutipleInput/index.less +13 -10
  32. package/src/components/Functional/QueryMutipleInput/index.tsx +2 -11
  33. package/src/components/Functional/SearchSelect/index.less +235 -73
  34. package/src/components/Functional/SearchSelect/index.tsx +351 -250
  35. package/src/components/Functional/SearchSelect/utils.ts +35 -0
  36. package/src/components/Solution/RuleComponent/index.js +4 -3
  37. package/src/components/Solution/RuleSetter/function.ts +2 -1
  38. package/src/plugin/TableColumnSetting/index.less +38 -70
  39. package/src/plugin/TableColumnSetting/index.tsx +5 -5
  40. package/src/styles/bsDefault.less +132 -136
  41. package/src/utils/TableUtils.tsx +1 -1
@@ -1,15 +1,16 @@
1
1
  // @ts-nocheck
2
2
  import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
3
3
  import { useDebounceFn } from 'ahooks';
4
- import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
4
+ import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag, Row, Col, Space, Tabs } from 'antd';
5
5
  import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
6
6
  import request from '@/utils/request';
7
7
  import { stringify } from 'querystring';
8
- import _, { escapeRegExp, isNil } from "lodash"
8
+ import _, { escapeRegExp, isNil, values } from "lodash"
9
9
  import './index.less';
10
10
  import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
- import { handleSourceName } from './utils';
11
+ import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth } from './utils';
12
12
  import { judgeIsRequestError } from '@/utils/requestUtils';
13
+ import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
13
14
 
14
15
  const { Option } = Select;
15
16
 
@@ -27,6 +28,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
27
28
  needModalTable = true,
28
29
  getPopupContainer = undefined,
29
30
  fieldComponent,
31
+ onSaveCallback,
30
32
  selectBusinessType,
31
33
  } = props;
32
34
  const {
@@ -40,33 +42,40 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
40
42
  mappingTextShowKeyField,
41
43
  mappingValueField = 'code',
42
44
  mappingTextShowTextField,
43
- init = true,// 是否初始请求
45
+ init = false,// 是否初始请求,默认初始不请求,查询需要限制录入4位数以上支持模糊查询
44
46
  extralHeaders = {},// 额外请求头参数
45
47
  specialBracket = false,// 是否使用特殊括弧显示选项 【value】text
46
48
  noNeedSplit = false,// label显示不需要任何特殊化
49
+ noOperate, // 级联禁用按钮设置字段
50
+ viewShowValueStr, // 详情展示值,不传展示组件处理的默认值
51
+ searchStartLength, // 默认不校验长度去搜索,如果配置了,则按照配置项长度进行处理搜索
47
52
  } = requestConfig || {};
48
53
  const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || ctx?.name || 'supplierCode')
49
54
 
50
55
  const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
51
56
  const initVal = value || (selectMode ? [] : null);
52
57
  const pageSize = 100 // 下拉框默认分页 条数
53
- const tableInitPageSize = 10 // 弹框默认分页 条数
58
+ const tableInitPageSize = 20 // 弹框默认分页 条数
54
59
  const currentPage = 1
55
60
  const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
56
61
  const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
57
62
  const currentSelectProps = {
58
63
  ...selectProps,
59
64
  // 以下属性不可更改----设计配置项
60
- showSearch: false,
65
+ showArrow: true,
66
+ showSearch: true,
61
67
  filterOption: false,
62
68
  allowClear: true,
63
69
  listHeight: 160,
64
70
  optionLabelProp: "label",
65
71
  autoClearSearchValue: false
66
72
  }
67
- const tableInitPagination = { showQuickJumper: true, total: 0, current: 1, pageSize: tableInitPageSize }
73
+ const initPagination = { showQuickJumper: true, showSizeChanger: false, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
74
+ const tableInitPagination = { ...initPagination, total: 0, current: 1 }
75
+ const disabled = noOperate || selectProps?.disabled || props?.disabled
68
76
 
69
77
  const [items, setItems] = useState([]);
78
+ const [selectOpen, setSelectOpen] = useState(false);
70
79
  const [scrollPage, setScrollPage] = useState(1);
71
80
  const [itemsTotal, setItemsTotal] = useState(0);
72
81
  const [fetching, setFetching] = useState(false);
@@ -101,6 +110,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
101
110
  );
102
111
 
103
112
  const [form] = Form.useForm();
113
+ const [collapsed, setCollapsed] = useState(true);
104
114
  const [caretLeftFlag, setCaretLeftFlag] = useState(true);
105
115
  const [tableData, setTableData] = useState([]);
106
116
  const [tablePagination, setTablePagination] = useState(tableInitPagination)
@@ -110,6 +120,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
110
120
  const [indeterminate, setIndeterminate] = useState(false)
111
121
  const [tableFormParams, setTableFormParams] = useState({});
112
122
  const [tooltipVisible, setTooltipVisible] = useState(false);
123
+ const [tableShowColumns, setTabletShowColumns] = useState(modalTableProps?.tableColumns?.filter(s => typeof s.defaultSort == 'number')?.sort((a,b)=> a.defaultSort-b.defaultSort)||[]);
124
+ const [confirmLoading, setConfirmLoading] = useState(false);
125
+ const [modalSearched, setModalSearched]=useState(false);
126
+
127
+ const setSelectDataSource = (list,total: number) => {
128
+ setItems(list);
129
+ setItemsTotal(total);
130
+ }
131
+ const clearSelectDataSource = () => {
132
+ setSelectDataSource([],0)
133
+ }
113
134
 
114
135
  useImperativeHandle(ref, () => ({
115
136
  refreshDataSource: (reset: boolean = false) => {
@@ -117,26 +138,22 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
117
138
  if (init) {
118
139
  run('init');
119
140
  } else {
120
- setItems([]);
121
- setItemsTotal(0);
141
+ clearSelectDataSource();
122
142
  }
123
143
  } else {
124
144
  run();
125
145
  }
126
146
  },
127
- clearDataSource: () => {
128
- setItems([]);
129
- setItemsTotal(0);
130
- },
147
+ clearSelectDataSource:clearSelectDataSource,
131
148
  getTableFormRef: () => form,
132
149
  // 解决下拉框数据源的问题
133
150
  getSelectDataSource: () => items,
134
- setSelectDataSource: (list: any, listTotal: number) => {
135
- setItems(list);
136
- setItemsTotal(listTotal);
137
- },
151
+ setSelectDataSource,
138
152
  refreshSelectDataSource: () => {
139
153
  refreshItems()
154
+ },
155
+ handleModalVisible: (flag) => {
156
+ if (flag) { showModal(); } else { handleCancel(); }
140
157
  }
141
158
  }))
142
159
 
@@ -314,7 +331,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
314
331
  const keys = res.list ? 'list' : 'items';
315
332
  source = res
316
333
  ? res[keys]
317
- ? res[keys].map((item: any) => {
334
+ ? res[keys].map((item: any, index: number) => {
318
335
  let textShowText = item[mappingTextField]
319
336
  if (mappingTextShowTextField) {
320
337
  textShowText = []
@@ -326,6 +343,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
326
343
  textShowText = item[mappingTextShowTextField]
327
344
  }
328
345
  }
346
+ if(!item?.children?.length) {delete item?.children};
329
347
  return {
330
348
  ...item,
331
349
  text: specialBracket
@@ -334,10 +352,11 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
334
352
  textShowText,
335
353
  textShowKey: item[mappingTextShowKeyField || mappingValueField],
336
354
  value: item[mappingValueField],
355
+ keyIndex: index + 1,
337
356
  };
338
357
  })
339
358
  : Array.isArray(res) &&
340
- res?.map((item: Record<string, any>) => {
359
+ res?.map((item: Record<string, any>, index: number) => {
341
360
  let textShowText = item[mappingTextField]
342
361
  if (mappingTextShowTextField) {
343
362
  textShowText = []
@@ -349,6 +368,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
349
368
  textShowText = item[mappingTextShowTextField]
350
369
  }
351
370
  }
371
+ if(!item?.children?.length) {delete item?.children};
352
372
  return {
353
373
  ...item,
354
374
  text: specialBracket
@@ -357,6 +377,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
357
377
  textShowText,
358
378
  textShowKey: item[mappingTextShowKeyField || mappingValueField],
359
379
  value: item[mappingValueField],
380
+ keyIndex: index + 1,
360
381
  };
361
382
  })
362
383
  : [];
@@ -367,8 +388,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
367
388
  } else {
368
389
  if (type === 1) {
369
390
  ctx?.form?.setFieldSource(resultSourceKey, source)
370
- setItems(source)
371
- setItemsTotal(Number(res?.total || res?.totalCount || source.length))
391
+ setSelectDataSource(source,(Number(res?.total || res?.totalCount || source.length)))
372
392
  } else {
373
393
  setTableData(source)
374
394
  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)) })
@@ -418,6 +438,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
418
438
  if (init) {
419
439
  run('init')
420
440
  }
441
+ // 编辑/详情页面回显
442
+ if(!init && !!value && ['edit','view'].includes(ctx?.mode)) {
443
+ run('init')
444
+ }
421
445
  }, [])
422
446
 
423
447
  useEffect(() => {
@@ -432,14 +456,41 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
432
456
 
433
457
  useEffect(() => {
434
458
  if (init) {
435
- setItems([]);
436
- setItemsTotal(0);
459
+ clearSelectDataSource();
437
460
  run('init')
438
461
  }
439
462
  },[selectBusinessType])
440
463
 
464
+ // 处理键盘事件
465
+ const handleKeyPress = (event) => {
466
+ if ((event.metaKey || event.ctrlKey) && (event.key === 'U' || event.keyCode == 85)) {
467
+ // ctrl + U 键 重置
468
+ onResetTable()
469
+ } else if (event.key === 'Enter' || event.keyCode == 13) {
470
+ // Enter 键 查询
471
+ onSearchTable()
472
+ }
473
+ };
474
+ useEffect(() => {
475
+ const removeListener = () => {
476
+ // 组件卸载时移除事件监听
477
+ document.removeEventListener('keydown', handleKeyPress);
478
+ }
479
+ if(isModalVisible) {
480
+ document.addEventListener('keydown', handleKeyPress);
481
+ } else {
482
+ removeListener()
483
+ }
484
+ return () => {
485
+ removeListener()
486
+ };
487
+ },[isModalVisible])
488
+
441
489
  const showModal = () => {
442
- getData({ pageSize: tableInitPageSize, currentPage: 1 }, 3)
490
+ setSelectOpen(false)
491
+ setSearchValue('');
492
+ setModalSearched(false);
493
+
443
494
  setIsModalVisible(true);
444
495
  // 回显
445
496
  if (value) {
@@ -463,17 +514,43 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
463
514
  // 解决选择最后1页的sku,返回后,不显示名称问题
464
515
  const source = _.uniqBy(items.concat(selectedValue), 'value')
465
516
  ctx?.form?.setFieldSource(resultSourceKey, source)
466
- setItems(source)
517
+ setSelectDataSource(source,source?.length)
467
518
  formaData(selectedValue, source);
468
519
  } else {
469
520
  const formatResult = selectMode ? [] : null
470
521
  onChange(formatResult, selectedValue)
471
522
  }
472
523
  }
473
-
474
524
  const handleOk = () => {
475
- handleSelectOver(popvalue)
476
- handleCancel();
525
+ // 按钮保存可传入
526
+ if(onSaveCallback) {
527
+ setConfirmLoading(true)
528
+ onSaveCallback(popvalue).then(res => {
529
+ if(true) {
530
+ // 成功信息可以在调用处处理 即resolve({messageSuccessBackInfo: { needThrowSuccess: false } })、resolve({messageSuccessBackInfo: { needThrowSuccess: true, successMessage: '已保存' } })
531
+ let initSuccessMessage = '保存成功'
532
+ const rmsbi = res?.messageSuccessBackInfo || {};
533
+ if(rmsbi && Object.keys(rmsbi)?.length){
534
+ rmsbi?.needThrowSuccess ? message.success(rmsbi?.successMessage || initSuccessMessage) : null
535
+ } else {
536
+ message.success(initSuccessMessage)
537
+ }
538
+ handleCancel();
539
+ } else {
540
+ }
541
+ setConfirmLoading(false)
542
+ }).catch(Error => {
543
+ if(typeof Error === 'object') {
544
+ !Error.needThrowError ? null : message.error(Error.message)
545
+ } else {
546
+ message.error(Error);
547
+ }
548
+ setConfirmLoading(false)
549
+ })
550
+ } else {
551
+ handleSelectOver(popvalue)
552
+ handleCancel();
553
+ }
477
554
  };
478
555
 
479
556
  const formaData = (value: any, source: any) => {
@@ -500,9 +577,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
500
577
  const handleCancel = () => {
501
578
  clearModalTable();
502
579
  setIsModalVisible(false);
503
- if (selectMode) {
504
- run();
505
- }
506
580
  };
507
581
 
508
582
  const refreshItems = () => {
@@ -516,31 +590,27 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
516
590
  if (formValueList.filter((item: any) => item).length > 0) {
517
591
  run();
518
592
  } else {
519
- setItems([]);
520
- setItemsTotal(0);
593
+ clearSelectDataSource();
521
594
  }
522
595
  } else {
523
596
  run();
524
597
  }
525
598
  }
526
599
 
527
- const onSearchChange = (e) => {
528
- setSearchValue(e.target.value);
529
- refreshItems();
530
- }
531
-
532
- const onSearchBlur = () => {
533
- setSearchValue('');
600
+ const onSearchChange = (v) => {
601
+ setSearchValue(v);
602
+ if(!!searchStartLength && v?.length < searchStartLength) return;
534
603
  refreshItems();
535
604
  }
536
605
 
537
606
  const onSearchTable = () => {
538
607
  const params = form.getFieldsValue();
608
+
609
+ // const isHaveParams = params && Object.keys(params).filter(item => params[item]).length > 0;
610
+ setModalSearched(true);
611
+
539
612
  setTableFormParams(params);
540
613
  getData({ ...params, pageSize: tableInitPageSize }, 2)
541
- if (selectMode) {
542
- getData(params)
543
- }
544
614
  }
545
615
 
546
616
  const onResetTable = () => {
@@ -549,49 +619,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
549
619
  getData({ pageSize: tableInitPageSize, currentPage: 1 }, 2)
550
620
  }
551
621
 
622
+ const toggleCollapsed = () => {
623
+ setCollapsed(!collapsed);
624
+ };
625
+
552
626
  const handleTableChange = (pagination) => {
553
627
  getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
554
628
  }
555
-
556
- const onCheckAllData = (pSize) => {
557
- getData({ ...tableFormParams, pageSize: pSize, currentPage: 1 }, 2,(source) => {
558
- const currentItemsData = JSON.parse(JSON.stringify(source))
559
- setSelectedRowKeys(currentItemsData.map(i => i.value))
560
- setPopValue(currentItemsData);
561
- setSelectedRows(currentItemsData)
562
- })
563
- }
564
-
565
- const onChangeCheckAll = (e) => {
566
- // 允许用户自定义 全选操作逻辑
567
- if(modalTableProps?.onCheckAll) {
568
- modalTableProps?.onCheckAll(e,{items,itemsTotal,tablePagination,onCheckAllData,setSelectedRowKeys,setPopValue,setSelectedRows,setIndeterminate,setCheckedAll})
569
- return;
570
- }
571
-
572
- if (e.target.checked) {
573
- // 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
574
- // 如果超过100条 就默认查出所有数据
575
- if ((items.length < itemsTotal) || (items.length === itemsTotal && itemsTotal == 0)) {
576
- const totalCount = tablePagination?.total || itemsTotal // 兼容有查询条件的情况 首次加载是没有所有数据的,默认给加载后端返回的总条数
577
- const totalPage = Math.ceil(totalCount / tablePagination?.pageSize);
578
- const allPageSize = totalPage * tablePagination?.pageSize;
579
- onCheckAllData(allPageSize)
580
- } else {
581
- const currentItemsData = JSON.parse(JSON.stringify(items))
582
- setSelectedRowKeys(currentItemsData.map(i => i.value))
583
- setPopValue(currentItemsData);
584
- setSelectedRows(currentItemsData)
585
- }
586
- } else {
587
- setSelectedRowKeys([])
588
- setPopValue([]);
589
- setSelectedRows([])
590
- }
591
- setIndeterminate(false);
592
- setCheckedAll(e.target.checked);
593
- }
594
-
595
629
  const LightHeightOption = (props) => {
596
630
  const {
597
631
  filterTxt, text,
@@ -634,7 +668,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
634
668
  };
635
669
 
636
670
  const onChangeSelectedKeys = (selectKeys, selectRows) => {
637
- let sksResult = selectRows.map((i) => i.value);
671
+ let sksResult = selectRows?.map((i) => i.value)||[];
638
672
 
639
673
  // 单选 默认直接选中 不需要确定 配置了modalRadioNeedFooter就需要确定
640
674
  if(!selectMode && !modalTableProps?.modalRadioNeedFooter) {
@@ -669,13 +703,23 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
669
703
  },
670
704
  getCheckboxProps: selectProps?.getCheckboxProps ? selectProps?.getCheckboxProps : () => {
671
705
  return ({
672
- disabled: selectProps?.disabled || props?.disabled || (!items.length && !tableData.length),
706
+ disabled: disabled || (!items.length && !tableData.length),
673
707
  })
674
708
  },
675
709
  };
676
710
 
677
- const onDoubleClickSelect = (e, record) => {
678
- if (!selectMode && !(selectProps?.disabled || props?.disabled || (!items.length && !tableData.length))) {
711
+ const onRowClickSelect = (e, record,type) => {
712
+ if (selectMode && !(disabled || (!items.length && !tableData.length))) {
713
+ const oldSelect = selectedRows;
714
+ const newSelect = [JSON.parse(JSON.stringify(record))];
715
+ const srs = getRealStr(oldSelect,newSelect,record);
716
+ const sks = srs.map((i: any) => i.value)
717
+
718
+ onChangeSelectedKeys(sks, srs)
719
+ }
720
+ }
721
+ const onDoubleClickSelect = (e, record,type) => {
722
+ if (!selectMode && !(disabled || (!items.length && !tableData.length))) {
679
723
  const srs = [JSON.parse(JSON.stringify(record))]
680
724
  const sks = srs.map((i: any) => i.value)
681
725
  onChangeSelectedKeys(sks, srs)
@@ -693,40 +737,49 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
693
737
  return false
694
738
  }
695
739
  };
696
- return list.map((i: any) => {
740
+
741
+ const { emptyArray } = getFormRowInfo(list);
742
+ const addKong = emptyArray?.map((i: any) =>({ type: 'kong'}))||[];
743
+ return list?.concat(addKong)?.map((i: any, index: number) => {
744
+ if(i?.type === 'kong') return <Col span={ColSpan} key={i}></Col>;
745
+
697
746
  if (i?.type === 'select' || i?.field?.type === 'select') {
698
747
  return (
699
- <Form.Item name={i.name} label={i.label} key={i.name}>
700
- <Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
701
- {i?.initialSource?.length && i?.initialSource.map((m: any) => (
702
- <Option value={m.value} key={m.value}>{m.text}</Option>
703
- ))}
704
- </Select>
705
- </Form.Item>
748
+ <Col span={ColSpan} key={i.name}>
749
+ <Form.Item name={i.name} label={i.label} key={i.name}>
750
+ <Select style={{ width: '100%' }} placeholder='请选择' onDeselect ={v => onSearchTable()} {...i?.field?.props} disabled={setDisabled(i.name)}>
751
+ {i?.initialSource?.length && i?.initialSource.map((m: any) => (
752
+ <Option value={m.value} key={m.value}>{m.text}</Option>
753
+ ))}
754
+ </Select>
755
+ </Form.Item>
756
+ </Col>
706
757
  )
707
758
  }
708
759
 
709
760
  if (i?.type === 'treeSelect' || i?.field?.type === 'treeSelect') {
710
761
  return (
711
- <Form.Item name={i.name} label={i.label} key={i.name}>
712
- <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
713
- </Form.Item>
762
+ <Col span={ColSpan} key={i.name}>
763
+ <Form.Item name={i.name} label={i.label} key={i.name}>
764
+ <TreeSelect style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}></TreeSelect>
765
+ </Form.Item>
766
+ </Col>
714
767
  )
715
768
  }
716
769
 
717
770
  if (i?.type === 'businessSearchSelect' || i?.field?.type === 'businessSearchSelect') {
718
771
  return (
719
- <div>
772
+ <Col span={ColSpan} key={i.name}>
720
773
  <Form.Item name={i.name} label={i.label} key={i.name}>
721
774
  <BusinessSearchSelect {...i.field.props} disabled={setDisabled(i.name)} />
722
775
  </Form.Item>
723
- </div>
776
+ </Col>
724
777
  )
725
778
  }
726
779
 
727
780
  if (i?.type === 'multipleQueryInput' || i?.field?.type === 'multipleQueryInput') {
728
781
  return (
729
- <div>
782
+ <Col span={ColSpan} key={i.name}>
730
783
  <Form.Item name={i.name} label={i.label} key={i.name}>
731
784
  <QueryMutipleInput onValueChange={(value) => {
732
785
  form.setFieldsValue({
@@ -734,15 +787,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
734
787
  })
735
788
  }} />
736
789
  </Form.Item>
737
- </div>
790
+ </Col>
738
791
  );
739
792
  }
740
793
 
741
794
  // 默认type是input
742
795
  return (
743
- <Form.Item name={i.name} label={i.label} key={i.name}>
744
- <Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
745
- </Form.Item>
796
+ <Col span={ColSpan} key={i.name}>
797
+ <Form.Item name={i.name} label={i.label} key={i.name}>
798
+ <Input style={{ width: '100%' }} placeholder='请输入' allowClear maxLength={100} {...i?.field?.props} disabled={setDisabled(i.name)} />
799
+ </Form.Item>
800
+ </Col>
746
801
  )
747
802
  })
748
803
  } else {
@@ -750,6 +805,142 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
750
805
  }
751
806
  }
752
807
 
808
+ const renderFormItem = (list) => {
809
+ const viCount = modalTableProps?.visibleFieldsCount || defaultVisibleFieldsCount;
810
+ return collapsed ? formItem(list?.slice(0,viCount)) : formItem(list)
811
+ }
812
+
813
+ // const queryFieldsDom = <SearchItemTable
814
+ // ref={searchTableRef}
815
+ // setShowSearchFields={setShowSearchFields||[]}
816
+ // showSearchFields={showSearchFields||[]}
817
+ // datasource={modalTableProps?.tableSearchForm || []}
818
+ // bsTableCode={bsTableCode}
819
+ // />
820
+
821
+ const renderShowTable = (tableList, type) => {
822
+ const tableBoxHeighth = getTableHeigth(modalTableProps?.tableSearchForm);
823
+ return (
824
+ <div style={{ height: `${tableBoxHeighth}px` }}>
825
+ <Table
826
+ bordered
827
+ size="middle"
828
+ rowSelection={rowSelection}
829
+ columns={tableShowColumns}
830
+ dataSource={tableList}
831
+ {...type=='noPage'?{
832
+ pagination: initPagination,
833
+ locale: {
834
+ emptyText: '暂无已选结果',
835
+ }
836
+ }:{
837
+ pagination: tablePagination,
838
+ onChange: handleTableChange,
839
+ loading: fetching,
840
+ locale: {
841
+ emptyText: modalSearched? '无匹配结果,请更换其他内容再试' : '请输入搜索条件',
842
+ }
843
+ }}
844
+ rowKey={mappingValueField}
845
+ scroll={{
846
+ x: modalTableProps.overScrollX || 'max-content',
847
+ y: modalTableProps.overScrollY || 440,
848
+ }}
849
+ onRow={(record) => {
850
+ return {
851
+ onClick: event => onRowClickSelect(event, record), // 点击行
852
+ onDoubleClick: (event) =>
853
+ onDoubleClickSelect(event, record),
854
+ };
855
+ }}
856
+ />
857
+ </div>
858
+ )
859
+ }
860
+
861
+ const tabsItems1 = [
862
+ { label: `全部(${tablePagination?.total || 0})`, key: 'all', children: renderShowTable(tableData) }, // 务必填写 key
863
+ ];
864
+ const tabsItems2 = [
865
+ { label: `已选(${selectedRowKeys?.length || 0})`, key: 'selected', children: renderShowTable(selectedRows?.map((s,index)=> ({...s,keyIndex:index+1}))||[],'noPage') },
866
+ ];
867
+
868
+ const resetSelectDataSource = () => {
869
+ setSearchValue('');
870
+ clearSelectDataSource();
871
+ init && run('init')
872
+ }
873
+
874
+ const onClear = () => {
875
+ formaData([], items);
876
+ resetSelectDataSource();
877
+ }
878
+ const onSelectClick = (srs, ds,nr=true) => {
879
+ formaData(srs, ds);
880
+ nr && setSelectOpen(false);
881
+ }
882
+
883
+ const onDropdownVisibleChange = (visible) => {
884
+ setSelectOpen(visible);
885
+ // 关闭下拉框 如果首次本身就不展示数据的 没有选中数据-需要清空查询数据源; 首次展示的默认展示
886
+ if (!visible && !value?.length) {
887
+ resetSelectDataSource()
888
+ }
889
+ }
890
+ const renderTable = (dataSource) => {
891
+ return (
892
+ <div className={`search_select_dropdown_table ${!selectMode?'search_select_dropdown_table1':''}`}>
893
+ <Table
894
+ virtual
895
+ bordered
896
+ {...(selectMode?{
897
+ rowSelection: {
898
+ type: 'checkbox',
899
+ columnWidth: '24px',
900
+ selectedRowKeys: labelInValue ? value?.map(s=> (s?.value||s)) : value,
901
+ onChange: (sks, srs) => {
902
+ const oldSelect = value?.map(s => ({ value: s?.value||s }))||[];
903
+ let tmpSelectedRows = oldSelect.concat(srs).filter(item => item != undefined);
904
+ let realSrs = sks.map(key => tmpSelectedRows.filter(item => item[mappingValueField] == key)[0]).filter(item => item != undefined)
905
+ onSelectClick(realSrs, dataSource,false)
906
+ }
907
+ },
908
+ onRow: (record, rowKey) => ({
909
+ onClick: event => {
910
+ event.stopPropagation();
911
+ event.nativeEvent.stopImmediatePropagation();
912
+
913
+ const oldSelect = value?.map(s => ({ value: s?.value||s }))||[];
914
+ const newSelect = [JSON.parse(JSON.stringify(record))];
915
+ console.log('行选择:','oldSelect',oldSelect,'newSelect',newSelect,'record',record)
916
+ const srs = getRealStr(oldSelect,newSelect,record);
917
+ onSelectClick(srs,dataSource,false)
918
+ }, // 点击行
919
+ })
920
+ }:{
921
+ rowSelection: {
922
+ type: 'radio',
923
+ columnWidth: 0,
924
+ selectedRowKeys: labelInValue ? value?.value&&[value?.value]||[] : value&&[value]||[],
925
+ },
926
+ onRow: (record, rowKey) => ({
927
+ onClick: event => {
928
+ const srs = [JSON.parse(JSON.stringify(record))]
929
+ onSelectClick(srs,dataSource)
930
+ }, // 点击行
931
+ })
932
+ })}
933
+ columns={selectProps?.renderTableColumns||[]}
934
+ dataSource={items}
935
+ size="middle"
936
+ pagination={false}
937
+ rowKey={mappingValueField}
938
+ scroll={{ x: 'max-content', y: 288 }}
939
+ />
940
+ </div>
941
+ );
942
+ }
943
+
753
944
  const maxTagPlaceholder = (selectedValues) => {
754
945
  const onClose = (e: any, item: any) => {
755
946
  e.preventDefault();
@@ -799,6 +990,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
799
990
  return (getSelectValueText(value) || kongValue) as string;
800
991
  }
801
992
  const getShowStr = () => {
993
+ // 优先使用业务使用传入的展示
994
+ if(viewShowValueStr) return viewShowValueStr;
995
+
802
996
  const kongValue = '无'
803
997
  // 先判断labelInValue与否,labelInValue可以直接去value中获取字段名称,否则去下拉框数据里面去拿;
804
998
  // 再判断是单选还是多选,数据类型不同取值方式也不同
@@ -808,7 +1002,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
808
1002
  return getShowValueStr(kongValue);
809
1003
  }
810
1004
 
811
- const isShouldShowStr = props.disabled && ctx
1005
+ const isShouldShowStr = (props.disabled && ctx) || ctx?.mode == 'view'
812
1006
  return (
813
1007
  <div className={'search_select'}>
814
1008
  {fieldComponent ? (
@@ -830,44 +1024,32 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
830
1024
  id={`search_select_div_${uniqueValue}`}
831
1025
  >
832
1026
  <Select
833
- virtual
834
1027
  labelInValue={labelInValue}
835
1028
  value={value}
836
- onChange={onChange}
837
- disabled={props.disabled}
838
- dropdownRender={(menu) => (
839
- <>
840
- <Input
841
- value={searchValue}
842
- style={{ width: '98%', marginLeft: '1%' }}
843
- placeholder="请输入"
844
- onChange={(e) => onSearchChange(e)}
845
- onBlur={onSearchBlur}
846
- onKeyDown={(e) => {
847
- // 阻止多选的冒泡
848
- e.stopPropagation();
849
- }}
850
- />
851
- <Divider style={{ margin: '8px 0' }} />
852
- {menu}
853
- </>
854
- )}
1029
+ onChange={onchange}
1030
+ onClear={onClear}
1031
+ disabled={disabled}
1032
+ dropdownStyle={{ borderRadius: '2px', padding: '10px 2px' }}
1033
+ open={selectOpen}
1034
+ onDropdownVisibleChange={onDropdownVisibleChange}
1035
+ dropdownRender={(menu) => items?.length ? renderTable(items) : menu}
855
1036
  notFoundContent={
856
1037
  fetching ? (
857
1038
  <Spin size="small" className='searchSelectSpin' />
858
1039
  ) : (
859
1040
  <div style={{ textAlign: 'center' }}>
860
- <div style={{ marginBottom: 16 }}>
861
- <CopyOutlined style={{ fontSize: '50px' }} />
862
- </div>
863
- <div>无匹配结果,请更换其他内容再试</div>
1041
+ <div>{searchValue?'无匹配结果,请更换其他内容再试':`请录入${searchStartLength?'4位数以上':''}字符进行模糊查询`}</div>
864
1042
  </div>
865
1043
  )
866
1044
  }
867
1045
  onPopupScroll={SelectScroll}
868
- style={{ width: needModalTable ? 'calc(100% - 30px)' : 'calc(100%)' }}
1046
+ style={{ width: 'calc(100%)' }}
869
1047
  placeholder="请选择"
870
1048
  maxTagPlaceholder={maxTagPlaceholder}
1049
+ onSearch={(v) => onSearchChange(v)}
1050
+ {...(needModalTable ? {
1051
+ suffixIcon: <div className={`search_select_expand_button ${(disabled)?'search_select_expand_button_disabled':''}`} onClick={showModal}><SearchOutlined /></div>
1052
+ } : {})}
871
1053
  {...currentSelectProps}
872
1054
  getPopupContainer={(triggerNode) => (getPopupContainer && getPopupContainer(triggerNode)) || triggerNode.parentElement}
873
1055
  >
@@ -880,22 +1062,16 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
880
1062
  </Option>
881
1063
  ))}
882
1064
  </Select>
883
- {needModalTable && (
884
- <Button
885
- style={{ width: '30px', padding: '2px'}}
886
- onClick={showModal}
887
- type="primary"
888
- >
889
- <SearchOutlined />
890
- </Button>
891
- )}
892
1065
  </div>
893
1066
  )}
894
1067
  {needModalTable && isModalVisible && (
895
1068
  <Modal
1069
+ maskClosable={false}
1070
+ destroyOnClose
896
1071
  width="80%"
897
1072
  title={modalTableProps?.modalTableTitle}
898
1073
  visible={isModalVisible}
1074
+ confirmLoading={confirmLoading}
899
1075
  onOk={handleOk}
900
1076
  onCancel={handleCancel}
901
1077
  footer={
@@ -907,129 +1083,54 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
907
1083
  <Button
908
1084
  key="submit"
909
1085
  type="primary"
1086
+ loading={confirmLoading}
910
1087
  onClick={handleOk}
911
- disabled={
912
- !tableData.length ||
913
- selectProps?.disabled ||
914
- props?.disabled
915
- }
1088
+ disabled={disabled}
916
1089
  >
917
1090
  确定
918
1091
  </Button>,
919
1092
  ]
920
1093
  : null
921
1094
  }
1095
+ wrapClassName={'search_select_modal_wrapper'}
922
1096
  {...(modalTableProps?.modalProps || {})}
923
1097
  >
924
1098
  <div className={'search_select_wrapper'}>
925
- <div
926
- className={'search_select_wrapper_click_flag'}
927
- onClick={() => setCaretLeftFlag(!caretLeftFlag)}
928
- >
929
- <CaretLeftOutlined
930
- className={
931
- caretLeftFlag
932
- ? 'search_select_wrapper_click_flag_arrow'
933
- : 'search_select_wrapper_click_flag_arrow_1'
934
- }
935
- />
936
- </div>
937
- <div
938
- className={
939
- caretLeftFlag
940
- ? 'search_select_wrapper_left'
941
- : 'search_select_wrapper_left1'
942
- }
943
- >
1099
+ <div className={'search_select_wrapper_topForm'}>
944
1100
  <div className={'select_list_columns'}>
945
- <div className={'select_list_columns_tips'}>搜索</div>
946
- <div className={'select_list_columns_formItems'}>
947
- <Form form={form} layout="vertical" key="modalForm">
948
- {formItem(modalTableProps?.tableSearchForm)}
949
- </Form>
950
- </div>
951
- </div>
952
- <div className={'select_list_searchButton'}>
953
- <Button
954
- key="reset"
955
- className={'select_list_button_space'}
956
- onClick={onResetTable}
957
- >
958
- 重置
959
- </Button>
960
- <Button key="search" type="primary" onClick={onSearchTable}>
961
- 查询
962
- </Button>
1101
+ <Form form={form} layout={'horizontal'} colon={false} key="modalForm">
1102
+ <Row>
1103
+ {renderFormItem(modalTableProps?.tableSearchForm)}
1104
+ <Col span={6}>
1105
+ <Space>
1106
+ <Button key="search" type="primary" onClick={onSearchTable}>
1107
+ 查询 Enter
1108
+ </Button>
1109
+ <Button key="reset" onClick={onResetTable}>
1110
+ 重置 ctrl+U
1111
+ </Button>
1112
+ {/* <div>{queryFieldsDom}</div> */}
1113
+ <div style={{position: 'absolute',top: 0,right: 0}}>
1114
+ {hasMoreQueryFields(modalTableProps) && modalTableProps?.isHorizontally
1115
+ ? <img onClick={() => {toggleCollapsed()}} style={{
1116
+ cursor: 'pointer',
1117
+ fontSize: '10px',
1118
+ transition: '0.3s all',
1119
+ transform: `rotate(${collapsed ? 0 : 0.5}turn)`,
1120
+ }} src={zhankaitiaojian} />
1121
+ : <></>
1122
+ }
1123
+ </div>
1124
+ </Space>
1125
+ </Col>
1126
+ </Row>
1127
+ </Form>
963
1128
  </div>
964
1129
  </div>
965
- <div
966
- className={
967
- caretLeftFlag
968
- ? 'search_select_wrapper_right'
969
- : 'search_select_wrapper_right1'
970
- }
971
- >
972
- <div>
973
- <div className={'select_list_selectTips'}>
974
- <div style={{ marginLeft: 8 }}>
975
- 搜索结果共
976
- <span style={themeColor}>
977
- {tablePagination?.total || 0}
978
- </span>
979
-
980
- {selectMode ? (
981
- <span>
982
- , 本次已选
983
- <span style={themeColor}>
984
- {selectedRowKeys?.length || 0}
985
- </span>
986
-
987
- </span>
988
- ) : (
989
- ''
990
- )}
991
- </div>
992
- <div
993
- style={{ color: 'rgba(127, 127, 127, 0.6470588235294118)' }}
994
- >
995
- {selectMode
996
- ? '勾选后点击确定按钮完成选择'
997
- : '双击数据行或点击单选图标完成选择'}
998
- </div>
999
- </div>
1000
- <Table
1001
- size="small"
1002
- rowSelection={rowSelection}
1003
- columns={modalTableProps?.tableColumns}
1004
- dataSource={tableData}
1005
- pagination={tablePagination}
1006
- onChange={handleTableChange}
1007
- rowKey={mappingValueField}
1008
- scroll={{
1009
- x: modalTableProps.overScrollX || 'max-content',
1010
- y: modalTableProps.overScrollY || null,
1011
- }}
1012
- onRow={(record) => {
1013
- return {
1014
- onDoubleClick: (event) =>
1015
- onDoubleClickSelect(event, record),
1016
- };
1017
- }}
1018
- />
1019
- {(selectMode && !modalTableProps?.isHiddenCheckAll) ? (
1020
- <div className={'select_list_selectAll'}>
1021
- <Checkbox
1022
- indeterminate={indeterminate}
1023
- checked={checkedAll}
1024
- onChange={onChangeCheckAll}
1025
- disabled={selectProps?.disabled || props?.disabled}
1026
- />{' '}
1027
- 全选所有页面
1028
- </div>
1029
- ) : (
1030
- ''
1031
- )}
1032
- </div>
1130
+
1131
+ <div className={'search_select_wrapper_bottomTable'}>
1132
+ <div className={selectMode ?'search_select_wrapper_bottomTable_wrapLeft2':'search_select_wrapper_bottomTable_wrapLeft1'}><Tabs items={tabsItems1} /></div>
1133
+ {selectMode ? <div className={'search_select_wrapper_bottomTable_wrapRight'}><Tabs items={tabsItems2} tabBarExtraContent={<span onClick={()=> onChangeSelectedKeys([], [])}>清空已选</span>} /></div> : null}
1033
1134
  </div>
1034
1135
  </div>
1035
1136
  </Modal>