@bit-sun/business-component 4.0.12-alpha.10 → 4.0.12-alpha.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "4.0.12-alpha.10",
3
+ "version": "4.0.12-alpha.12",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -1707,7 +1707,6 @@ export default () => {
1707
1707
  }
1708
1708
  const selectPropsMultiple = {
1709
1709
  mode: 'multiple',
1710
- maxTagCount: 1,
1711
1710
  }
1712
1711
 
1713
1712
  const [ tabKey, setTabKey ] = useState('single')
@@ -5,6 +5,11 @@
5
5
  &_show {
6
6
  display: flex;
7
7
 
8
+ .ant-select-dropdown {
9
+ top: 24px !important;
10
+ width: calc(150%) !important;
11
+ }
12
+
8
13
  // 下拉框清除图标位置调整
9
14
  .ant-select-clear {
10
15
  right: 33px;
@@ -16,6 +21,13 @@
16
21
  }
17
22
  }
18
23
 
24
+ &_show.search_select_show_list {
25
+ .ant-select-dropdown {
26
+ top: 24px !important;
27
+ width: calc(141%) !important;
28
+ }
29
+ }
30
+
19
31
  &_expand_button {
20
32
  position: relative;
21
33
  right: -11px;
@@ -8,7 +8,7 @@ import { stringify } from 'querystring';
8
8
  import _, { escapeRegExp, isNil, values } from "lodash"
9
9
  import './index.less';
10
10
  import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
11
- import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth } from './utils';
11
+ import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource } from './utils';
12
12
  import { judgeIsRequestError } from '@/utils/requestUtils';
13
13
  import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
14
14
 
@@ -69,8 +69,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
69
69
  listHeight: 160,
70
70
  optionLabelProp: "label",
71
71
  autoClearSearchValue: false,
72
- placement: 'bottomLeft'
72
+ placement: 'bottomRight'
73
73
  }
74
+
75
+ const pathname = window.location.href;
76
+ var pattern = /(action|create|edit|view)/
77
+ const isFormPage = pathname.match(pattern)?.length > 0;
78
+
74
79
  const initPagination = { showQuickJumper: true, showSizeChanger: false, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
75
80
  const tableInitPagination = { ...initPagination, total: 0, current: 1 }
76
81
  const disabled = noOperate || selectProps?.disabled || props?.disabled;
@@ -398,8 +403,15 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
398
403
  })
399
404
  : [];
400
405
  }
406
+ // 补充搜索项--选中的数据添加到数据源中去
407
+ const currentSRKs = getCurrentSRKs(selectMode,labelInValue,value)
408
+ if(currentSRKs?.length && currentSRKs?.some(s=> !source?.find(r=> r.value==s))) {
409
+ const selectedOption = items.filter(option => currentSRKs?.includes(option.value))||[];
410
+ source = (source||[]).concat(selectedOption)
411
+ }
401
412
  // 数据源 不可以有重复key
402
413
  source = Array.isArray(source) ? _.uniqBy(source, 'value') : [];
414
+
403
415
  if(callback) {
404
416
  callback(source)
405
417
  } else {
@@ -913,10 +925,16 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
913
925
  setSelectOpen(visible);
914
926
  // 关闭下拉框 如果首次本身就不展示数据的 没有选中数据-需要清空查询数据源; 首次展示的默认展示
915
927
  if (!visible && !value?.length) {
916
- resetSelectDataSource()
928
+ setTimeout(() => {
929
+ // 延时 是为了避免 执行时候出现下拉框弹两次的问题-可以看到数据源从展示到显示空数据框的问题
930
+ resetSelectDataSource()
931
+ }, 200)
917
932
  }
918
933
  }
919
934
  const renderTable = (dataSource) => {
935
+ const currentSRKs = getCurrentSRKs(selectMode,labelInValue,value)
936
+ const renderSource = getRenderSource(currentSRKs,items)
937
+
920
938
  return (
921
939
  <div className={`search_select_dropdown_table ${!selectMode?'search_select_dropdown_table1':''}`}>
922
940
  <Table
@@ -926,7 +944,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
926
944
  rowSelection: {
927
945
  type: 'checkbox',
928
946
  columnWidth: '24px',
929
- selectedRowKeys: labelInValue ? value?.map(s=> (s?.value||s)) : value,
947
+ selectedRowKeys: currentSRKs,
930
948
  preserveSelectedRowKeys: true, // 避免搜索之后 没有了选中前的数据 保证sks的正确性
931
949
  onChange: (sks, srs) => {
932
950
  const oldSelect = value?.map(s => ({ value: s?.value||s }))||[];
@@ -950,7 +968,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
950
968
  rowSelection: {
951
969
  type: 'radio',
952
970
  columnWidth: 0,
953
- selectedRowKeys: labelInValue ? value?.value&&[value?.value]||[] : value&&[value]||[],
971
+ selectedRowKeys: currentSRKs,
954
972
  },
955
973
  onRow: (record, rowKey) => ({
956
974
  onClick: event => {
@@ -960,7 +978,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
960
978
  })
961
979
  })}
962
980
  columns={selectProps?.renderTableColumns||[]}
963
- dataSource={items}
981
+ dataSource={renderSource}
964
982
  size="middle"
965
983
  pagination={false}
966
984
  rowKey={mappingValueField}
@@ -1049,7 +1067,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
1049
1067
  {getShowStr()}
1050
1068
  </div>) :
1051
1069
  <div
1052
- className="search_select_show"
1070
+ className={`${isFormPage ? '' : 'search_select_show_list'} search_select_show`}
1053
1071
  id={`search_select_div_${uniqueValue}`}
1054
1072
  >
1055
1073
  <Select
@@ -1059,7 +1077,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
1059
1077
  onClear={onClear}
1060
1078
  onDeselect={onDeselect}
1061
1079
  disabled={sDisabled}
1062
- dropdownStyle={{ borderRadius: '2px', padding: '10px 2px' }}
1080
+ dropdownStyle={{ borderRadius: '2px', padding: '10px 2px'}}
1063
1081
  open={selectOpen}
1064
1082
  onDropdownVisibleChange={onDropdownVisibleChange}
1065
1083
  dropdownRender={(menu) => items?.length ? renderTable(items) : menu}
@@ -1081,7 +1099,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
1081
1099
  suffixIcon: <div className={`search_select_expand_button ${(sDisabled)?'search_select_expand_button_disabled':''}`} onClick={showModal}><SearchOutlined /></div>
1082
1100
  } : {})}
1083
1101
  {...currentSelectProps}
1084
- getPopupContainer={(triggerNode) => (getPopupContainer && getPopupContainer(triggerNode)) || triggerNode.parentElement}
1102
+ getPopupContainer={(triggerNode) => triggerNode.parentElement || getPopupContainer && getPopupContainer(triggerNode)}
1085
1103
  >
1086
1104
  {items.map(item => (
1087
1105
  <Option key={item.value} label={item.text}>
@@ -4,6 +4,7 @@ export const handleSourceName = (sName: any) => {
4
4
  return sName
5
5
  }
6
6
 
7
+ // ------------------------------------------处理样式相关--开始----------------------------------------
7
8
  export const getFormRowInfo = (list: any) => {
8
9
  const totalRows = Math.ceil(list.length / columnsPerRow); // 计算总行数
9
10
  const lastRowColumns = (list.length+1) % columnsPerRow; // 计算最后一行的实际列数
@@ -35,4 +36,36 @@ export const getTableHeigth = (list: any) => {
35
36
  const totalRows = Math.ceil((list?.length+1) / 4);
36
37
  if(totalRows == 1) return 358; // modal弹窗760 调整为700 适应小屏
37
38
  return 411 - totalRows*10
38
- }
39
+ }
40
+
41
+ // ------------------------------------------处理样式相关--结束----------------------------------------
42
+
43
+
44
+ // ------------------------------------------处理数据相关--开始----------------------------------------
45
+ export const getCurrentSRKs = (selectMode: any,labelInValue:boolean,value: any) => {
46
+ return selectMode ? (labelInValue ? value?.map((s: any)=> (s?.value||s)) : value) : (labelInValue ? value?.value&&[value?.value]||[] : value&&[value]||[])
47
+ }
48
+
49
+ export const getRenderSource = (currentSRKs: any, items: any) => {
50
+ // 创建映射对象 用于记录原始选中顺序
51
+ const orderMap = new Map<number, number>();
52
+ currentSRKs.forEach((value: any, index: number) => {
53
+ orderMap.set(value, index);
54
+ });
55
+
56
+ // 被选中数据集合,获取之后排序
57
+ const selectedOption = items?.filter((option: any) => currentSRKs?.includes(option.value))||[];
58
+ const selectedOptionSort = selectedOption?.sort((a: any, b: any) => {
59
+ return (orderMap.get(a.value) ?? Infinity) - (orderMap.get(b.value) ?? Infinity);
60
+ })||[];
61
+
62
+ // 未选中数据集合
63
+ const otherOptions = items?.filter((option: any) => !currentSRKs?.includes(option.value))||[];
64
+
65
+ return [
66
+ ...selectedOptionSort,
67
+ ...otherOptions
68
+ ]
69
+ }
70
+
71
+ // ------------------------------------------处理数据相关--结束----------------------------------------