@bit-sun/business-component 4.0.11-alpha.9 → 4.0.12-alpha.2
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/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +2 -4
- package/dist/components/Functional/SearchSelect/utils.d.ts +4 -0
- package/dist/index.esm.js +637 -424
- package/dist/index.js +638 -425
- package/package.json +2 -2
- package/src/components/Business/BsLayouts/index.tsx +17 -0
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +45 -17
- package/src/components/Business/BsSulaQueryTable/index.less +21 -38
- package/src/components/Business/BsSulaQueryTable/setting.tsx +5 -5
- package/src/components/Business/DetailPageWrapper/index.less +10 -1
- package/src/components/Business/DetailPageWrapper/index.tsx +27 -2
- package/src/components/Business/HomePageWrapper/index.less +9 -0
- package/src/components/Business/HomePageWrapper/index.tsx +1 -1
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +66 -25
- package/src/components/Business/SearchSelect/index.md +6 -5
- package/src/components/Business/columnSettingTable/columnSetting.tsx +5 -5
- package/src/components/Business/columnSettingTable/index.less +33 -71
- package/src/components/Functional/QueryMutipleInput/index.tsx +2 -0
- package/src/components/Functional/SearchSelect/index.less +22 -5
- package/src/components/Functional/SearchSelect/index.tsx +146 -67
- package/src/components/Functional/SearchSelect/utils.ts +12 -1
- package/src/components/Functional/TreeSearchSelect/index.tsx +1 -1
- package/src/plugin/TableColumnSetting/index.less +38 -70
- package/src/plugin/TableColumnSetting/index.tsx +5 -5
- package/src/styles/bsDefault.less +130 -123
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
font-size: 14px;
|
|
22
22
|
font-weight: bolder;
|
|
23
|
+
background: #fafafa;
|
|
23
24
|
|
|
24
25
|
span {
|
|
25
26
|
position: absolute;
|
|
@@ -32,6 +33,11 @@
|
|
|
32
33
|
background-color: @primary-color;
|
|
33
34
|
color: #fff;
|
|
34
35
|
}
|
|
36
|
+
&_expand_button_disabled:hover {
|
|
37
|
+
background-color: transparent;
|
|
38
|
+
color: rgba(0, 0, 0, 0.25);
|
|
39
|
+
cursor: not-allowed;
|
|
40
|
+
}
|
|
35
41
|
|
|
36
42
|
&_dropdown_table {
|
|
37
43
|
// padding: 4px 10px 6px;
|
|
@@ -92,16 +98,27 @@
|
|
|
92
98
|
.ant-modal-body {
|
|
93
99
|
padding: 0px;
|
|
94
100
|
background: #F3F3F3;
|
|
95
|
-
height:
|
|
101
|
+
height: calc(100vh - 235px); // modal弹窗760 调整为700 适应小屏
|
|
96
102
|
overflow: hidden;
|
|
97
103
|
}
|
|
104
|
+
.ant-modal-footer {
|
|
105
|
+
.ant-btn.ant-btn-default {
|
|
106
|
+
color: @primary-color;
|
|
107
|
+
border-color: @primary-color;
|
|
108
|
+
}
|
|
109
|
+
.ant-btn-primary,.ant-btn-primary[disabled] {
|
|
110
|
+
background: @primary-color;
|
|
111
|
+
border-color: @primary-color;
|
|
112
|
+
}
|
|
113
|
+
.ant-btn-primary[disabled] {
|
|
114
|
+
opacity: .5;
|
|
115
|
+
color: #fff;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
98
118
|
}
|
|
99
119
|
|
|
100
120
|
&_wrapper {
|
|
101
121
|
position: relative;
|
|
102
|
-
min-height: 80vh;
|
|
103
|
-
max-height: 80vh;
|
|
104
|
-
overflow: hidden;
|
|
105
122
|
font-size: 14px;
|
|
106
123
|
|
|
107
124
|
&_topForm {
|
|
@@ -115,7 +132,7 @@
|
|
|
115
132
|
display: flex;
|
|
116
133
|
align-items: flex-start;
|
|
117
134
|
|
|
118
|
-
.ant-row .ant-form-item {
|
|
135
|
+
.ant-row .ant-form-item, .ant-row .ant-col .ant-space {
|
|
119
136
|
font-size: 12px !important;
|
|
120
137
|
margin-right: 0px !important;
|
|
121
138
|
margin-bottom: 8px !important;
|
|
@@ -8,12 +8,11 @@ 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 } from './utils';
|
|
11
|
+
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth } from './utils';
|
|
12
12
|
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
13
13
|
import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
|
|
14
14
|
|
|
15
15
|
const { Option } = Select;
|
|
16
|
-
const ColSpan = 6;
|
|
17
16
|
|
|
18
17
|
const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
19
18
|
const {
|
|
@@ -47,6 +46,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
47
46
|
extralHeaders = {},// 额外请求头参数
|
|
48
47
|
specialBracket = false,// 是否使用特殊括弧显示选项 【value】text
|
|
49
48
|
noNeedSplit = false,// label显示不需要任何特殊化
|
|
49
|
+
noOperate, // 级联禁用按钮设置字段
|
|
50
|
+
viewShowValueStr, // 详情展示值,不传展示组件处理的默认值
|
|
51
|
+
searchStartLength, // 默认不校验长度去搜索,如果配置了,则按照配置项长度进行处理搜索
|
|
50
52
|
} = requestConfig || {};
|
|
51
53
|
const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || ctx?.name || 'supplierCode')
|
|
52
54
|
|
|
@@ -66,10 +68,22 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
66
68
|
allowClear: true,
|
|
67
69
|
listHeight: 160,
|
|
68
70
|
optionLabelProp: "label",
|
|
69
|
-
autoClearSearchValue: false
|
|
71
|
+
autoClearSearchValue: false,
|
|
72
|
+
placement: 'bottomLeft'
|
|
70
73
|
}
|
|
71
|
-
const initPagination = { showQuickJumper: true, showSizeChanger:
|
|
72
|
-
const tableInitPagination = { ...initPagination, total: 0, current: 1
|
|
74
|
+
const initPagination = { showQuickJumper: true, showSizeChanger: false, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
|
|
75
|
+
const tableInitPagination = { ...initPagination, total: 0, current: 1 }
|
|
76
|
+
const disabled = noOperate || selectProps?.disabled || props?.disabled;
|
|
77
|
+
const isHaveDependency = fixedparameter && fieldValToParam && ctx;
|
|
78
|
+
const isHaveDValue = () => {
|
|
79
|
+
let formValueList = [];
|
|
80
|
+
fieldValToParam.forEach((item: any, index: any) => {
|
|
81
|
+
const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
|
|
82
|
+
formValueList.push(fixedParamVal);
|
|
83
|
+
});
|
|
84
|
+
return formValueList.filter((item: any) => item).length > 0
|
|
85
|
+
}
|
|
86
|
+
const sDisabled = disabled || (isHaveDependency && !!!isHaveDValue());
|
|
73
87
|
|
|
74
88
|
const [items, setItems] = useState([]);
|
|
75
89
|
const [selectOpen, setSelectOpen] = useState(false);
|
|
@@ -119,33 +133,43 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
119
133
|
const [tooltipVisible, setTooltipVisible] = useState(false);
|
|
120
134
|
const [tableShowColumns, setTabletShowColumns] = useState(modalTableProps?.tableColumns?.filter(s => typeof s.defaultSort == 'number')?.sort((a,b)=> a.defaultSort-b.defaultSort)||[]);
|
|
121
135
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
136
|
+
const [modalSearched, setModalSearched]=useState(false);
|
|
137
|
+
|
|
138
|
+
const setSelectDataSource = (list,total: number) => {
|
|
139
|
+
setItems(list);
|
|
140
|
+
setItemsTotal(total);
|
|
141
|
+
}
|
|
142
|
+
const clearSelectDataSource = () => {
|
|
143
|
+
setSelectDataSource([],0)
|
|
144
|
+
}
|
|
122
145
|
|
|
123
146
|
useImperativeHandle(ref, () => ({
|
|
124
147
|
refreshDataSource: (reset: boolean = false) => {
|
|
125
148
|
if (reset) {
|
|
126
149
|
if (init) {
|
|
150
|
+
// 有关联,依赖项清空,此form项数据源也应清空, 也不可点击搜索
|
|
151
|
+
if(isHaveDependency){
|
|
152
|
+
clearSelectDataSource();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
127
155
|
run('init');
|
|
128
156
|
} else {
|
|
129
|
-
|
|
130
|
-
setItemsTotal(0);
|
|
157
|
+
clearSelectDataSource();
|
|
131
158
|
}
|
|
132
159
|
} else {
|
|
133
160
|
run();
|
|
134
161
|
}
|
|
135
162
|
},
|
|
136
|
-
|
|
137
|
-
setItems([]);
|
|
138
|
-
setItemsTotal(0);
|
|
139
|
-
},
|
|
163
|
+
clearSelectDataSource:clearSelectDataSource,
|
|
140
164
|
getTableFormRef: () => form,
|
|
141
165
|
// 解决下拉框数据源的问题
|
|
142
166
|
getSelectDataSource: () => items,
|
|
143
|
-
setSelectDataSource
|
|
144
|
-
setItems(list);
|
|
145
|
-
setItemsTotal(listTotal);
|
|
146
|
-
},
|
|
167
|
+
setSelectDataSource,
|
|
147
168
|
refreshSelectDataSource: () => {
|
|
148
169
|
refreshItems()
|
|
170
|
+
},
|
|
171
|
+
handleModalVisible: (flag) => {
|
|
172
|
+
if (flag) { showModal(); } else { handleCancel(); }
|
|
149
173
|
}
|
|
150
174
|
}))
|
|
151
175
|
|
|
@@ -157,7 +181,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
157
181
|
|
|
158
182
|
// 处理dependence参数
|
|
159
183
|
const fixedParam = {};
|
|
160
|
-
if (
|
|
184
|
+
if (isHaveDependency) {
|
|
161
185
|
fixedparameter.forEach((item: any, index: any) => {
|
|
162
186
|
const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
|
|
163
187
|
if(fixedParamVal) {
|
|
@@ -374,14 +398,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
374
398
|
})
|
|
375
399
|
: [];
|
|
376
400
|
}
|
|
377
|
-
|
|
401
|
+
// 数据源 不可以有重复key
|
|
402
|
+
source = Array.isArray(source) ? _.uniqBy(source, 'value') : [];
|
|
378
403
|
if(callback) {
|
|
379
404
|
callback(source)
|
|
380
405
|
} else {
|
|
381
406
|
if (type === 1) {
|
|
382
407
|
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
383
|
-
|
|
384
|
-
setItemsTotal(Number(res?.total || res?.totalCount || source.length))
|
|
408
|
+
setSelectDataSource(source,(Number(res?.total || res?.totalCount || source.length)))
|
|
385
409
|
} else {
|
|
386
410
|
setTableData(source)
|
|
387
411
|
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)) })
|
|
@@ -431,6 +455,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
431
455
|
if (init) {
|
|
432
456
|
run('init')
|
|
433
457
|
}
|
|
458
|
+
// 编辑/详情页面回显
|
|
459
|
+
if(!init && !!value && ['edit','view'].includes(ctx?.mode)) {
|
|
460
|
+
run('init')
|
|
461
|
+
}
|
|
434
462
|
}, [])
|
|
435
463
|
|
|
436
464
|
useEffect(() => {
|
|
@@ -445,15 +473,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
445
473
|
|
|
446
474
|
useEffect(() => {
|
|
447
475
|
if (init) {
|
|
448
|
-
|
|
449
|
-
setItemsTotal(0);
|
|
476
|
+
clearSelectDataSource();
|
|
450
477
|
run('init')
|
|
451
478
|
}
|
|
452
479
|
},[selectBusinessType])
|
|
453
480
|
|
|
454
481
|
// 处理键盘事件
|
|
455
482
|
const handleKeyPress = (event) => {
|
|
456
|
-
console.log(event,'----event')
|
|
457
483
|
if ((event.metaKey || event.ctrlKey) && (event.key === 'U' || event.keyCode == 85)) {
|
|
458
484
|
// ctrl + U 键 重置
|
|
459
485
|
onResetTable()
|
|
@@ -478,8 +504,12 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
478
504
|
},[isModalVisible])
|
|
479
505
|
|
|
480
506
|
const showModal = () => {
|
|
481
|
-
|
|
482
|
-
|
|
507
|
+
if(sDisabled) return;
|
|
508
|
+
|
|
509
|
+
setSelectOpen(false)
|
|
510
|
+
setSearchValue('');
|
|
511
|
+
setModalSearched(false);
|
|
512
|
+
|
|
483
513
|
setIsModalVisible(true);
|
|
484
514
|
// 回显
|
|
485
515
|
if (value) {
|
|
@@ -503,7 +533,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
503
533
|
// 解决选择最后1页的sku,返回后,不显示名称问题
|
|
504
534
|
const source = _.uniqBy(items.concat(selectedValue), 'value')
|
|
505
535
|
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
506
|
-
|
|
536
|
+
setSelectDataSource(source,source?.length)
|
|
507
537
|
formaData(selectedValue, source);
|
|
508
538
|
} else {
|
|
509
539
|
const formatResult = selectMode ? [] : null
|
|
@@ -566,24 +596,15 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
566
596
|
const handleCancel = () => {
|
|
567
597
|
clearModalTable();
|
|
568
598
|
setIsModalVisible(false);
|
|
569
|
-
if (selectMode) {
|
|
570
|
-
run();
|
|
571
|
-
}
|
|
572
599
|
};
|
|
573
600
|
|
|
574
601
|
const refreshItems = () => {
|
|
575
602
|
// 查看是否存在关联值 如果有关联值 就查询 没有就不能查询
|
|
576
603
|
if (fieldValToParam && ctx && fixedparamsDisabled) {
|
|
577
|
-
|
|
578
|
-
fieldValToParam.forEach((item: any, index: any) => {
|
|
579
|
-
const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
|
|
580
|
-
formValueList.push(fixedParamVal);
|
|
581
|
-
});
|
|
582
|
-
if (formValueList.filter((item: any) => item).length > 0) {
|
|
604
|
+
if (!!isHaveDValue()) {
|
|
583
605
|
run();
|
|
584
606
|
} else {
|
|
585
|
-
|
|
586
|
-
setItemsTotal(0);
|
|
607
|
+
clearSelectDataSource();
|
|
587
608
|
}
|
|
588
609
|
} else {
|
|
589
610
|
run();
|
|
@@ -592,17 +613,18 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
592
613
|
|
|
593
614
|
const onSearchChange = (v) => {
|
|
594
615
|
setSearchValue(v);
|
|
595
|
-
if(v?.length <
|
|
616
|
+
if(!!searchStartLength && v?.length < searchStartLength) return;
|
|
596
617
|
refreshItems();
|
|
597
618
|
}
|
|
598
619
|
|
|
599
620
|
const onSearchTable = () => {
|
|
600
621
|
const params = form.getFieldsValue();
|
|
622
|
+
|
|
623
|
+
// const isHaveParams = params && Object.keys(params).filter(item => params[item]).length > 0;
|
|
624
|
+
setModalSearched(true);
|
|
625
|
+
|
|
601
626
|
setTableFormParams(params);
|
|
602
627
|
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
603
|
-
if (selectMode) {
|
|
604
|
-
getData(params)
|
|
605
|
-
}
|
|
606
628
|
}
|
|
607
629
|
|
|
608
630
|
const onResetTable = () => {
|
|
@@ -695,13 +717,23 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
695
717
|
},
|
|
696
718
|
getCheckboxProps: selectProps?.getCheckboxProps ? selectProps?.getCheckboxProps : () => {
|
|
697
719
|
return ({
|
|
698
|
-
disabled:
|
|
720
|
+
disabled: disabled || (!items.length && !tableData.length),
|
|
699
721
|
})
|
|
700
722
|
},
|
|
701
723
|
};
|
|
702
724
|
|
|
703
|
-
const
|
|
704
|
-
if (
|
|
725
|
+
const onRowClickSelect = (e, record,type) => {
|
|
726
|
+
if (selectMode && !(disabled || (!items.length && !tableData.length))) {
|
|
727
|
+
const oldSelect = selectedRows;
|
|
728
|
+
const newSelect = [JSON.parse(JSON.stringify(record))];
|
|
729
|
+
const srs = getRealStr(oldSelect,newSelect,record);
|
|
730
|
+
const sks = srs.map((i: any) => i.value)
|
|
731
|
+
|
|
732
|
+
onChangeSelectedKeys(sks, srs)
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
const onDoubleClickSelect = (e, record,type) => {
|
|
736
|
+
if (!selectMode && !(disabled || (!items.length && !tableData.length))) {
|
|
705
737
|
const srs = [JSON.parse(JSON.stringify(record))]
|
|
706
738
|
const sks = srs.map((i: any) => i.value)
|
|
707
739
|
onChangeSelectedKeys(sks, srs)
|
|
@@ -729,7 +761,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
729
761
|
return (
|
|
730
762
|
<Col span={ColSpan} key={i.name}>
|
|
731
763
|
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
732
|
-
<Select style={{ width: '100%' }} placeholder='请选择' {...i?.field?.props} disabled={setDisabled(i.name)}>
|
|
764
|
+
<Select style={{ width: '100%' }} placeholder='请选择' onDeselect ={v => onSearchTable()} {...i?.field?.props} disabled={setDisabled(i.name)}>
|
|
733
765
|
{i?.initialSource?.length && i?.initialSource.map((m: any) => (
|
|
734
766
|
<Option value={m.value} key={m.value}>{m.text}</Option>
|
|
735
767
|
))}
|
|
@@ -800,9 +832,11 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
800
832
|
// bsTableCode={bsTableCode}
|
|
801
833
|
// />
|
|
802
834
|
|
|
803
|
-
const renderShowTable = (tableList, type
|
|
835
|
+
const renderShowTable = (tableList, type) => {
|
|
836
|
+
const tableBoxHeighth = getTableHeigth(modalTableProps?.tableSearchForm);
|
|
837
|
+
const oSY = `calc(100vh - 391px - 82px)`; // 分页 24+16*2+10 「高 + margin * 2 + paddingBottom 10 」
|
|
804
838
|
return (
|
|
805
|
-
<div style={{ height:
|
|
839
|
+
<div style={{ height: `calc(100vh - 391px)` }}>
|
|
806
840
|
<Table
|
|
807
841
|
bordered
|
|
808
842
|
size="middle"
|
|
@@ -810,19 +844,26 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
810
844
|
columns={tableShowColumns}
|
|
811
845
|
dataSource={tableList}
|
|
812
846
|
{...type=='noPage'?{
|
|
813
|
-
pagination: initPagination
|
|
847
|
+
pagination: initPagination,
|
|
848
|
+
locale: {
|
|
849
|
+
emptyText: '暂无已选结果',
|
|
850
|
+
}
|
|
814
851
|
}:{
|
|
815
852
|
pagination: tablePagination,
|
|
816
853
|
onChange: handleTableChange,
|
|
817
|
-
loading: fetching
|
|
854
|
+
loading: fetching,
|
|
855
|
+
locale: {
|
|
856
|
+
emptyText: modalSearched? '无匹配结果,请更换其他内容再试' : '请输入搜索条件',
|
|
857
|
+
}
|
|
818
858
|
}}
|
|
819
859
|
rowKey={mappingValueField}
|
|
820
860
|
scroll={{
|
|
821
861
|
x: modalTableProps.overScrollX || 'max-content',
|
|
822
|
-
y: modalTableProps.overScrollY ||
|
|
862
|
+
y: modalTableProps.overScrollY || oSY,
|
|
823
863
|
}}
|
|
824
864
|
onRow={(record) => {
|
|
825
865
|
return {
|
|
866
|
+
onClick: event => onRowClickSelect(event, record), // 点击行
|
|
826
867
|
onDoubleClick: (event) =>
|
|
827
868
|
onDoubleClickSelect(event, record),
|
|
828
869
|
};
|
|
@@ -839,14 +880,36 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
839
880
|
{ label: `已选(${selectedRowKeys?.length || 0})`, key: 'selected', children: renderShowTable(selectedRows?.map((s,index)=> ({...s,keyIndex:index+1}))||[],'noPage') },
|
|
840
881
|
];
|
|
841
882
|
|
|
883
|
+
const resetSelectDataSource = () => {
|
|
884
|
+
setSearchValue('');
|
|
885
|
+
// 有关联值 不需要清空下拉框数据 也不需要重新去请求了
|
|
886
|
+
if(isHaveDependency) return;
|
|
887
|
+
clearSelectDataSource();
|
|
888
|
+
init && run('init')
|
|
889
|
+
}
|
|
890
|
+
|
|
842
891
|
const onClear = () => {
|
|
843
892
|
formaData([], items);
|
|
893
|
+
resetSelectDataSource();
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
const onDeselect = (...arg) => {
|
|
897
|
+
const oldSelect = value?.map(s => ({ value: s?.value||s }))||[];
|
|
898
|
+
const deRecord = arg[1];
|
|
899
|
+
const srs = oldSelect.filter((s: any) => s.value != deRecord?.value)
|
|
900
|
+
onSelectClick(srs, items,false)
|
|
901
|
+
}
|
|
902
|
+
const onSelectClick = (srs, ds,nr=true) => {
|
|
903
|
+
formaData(srs, ds);
|
|
904
|
+
nr && setSelectOpen(false);
|
|
844
905
|
}
|
|
845
906
|
|
|
846
907
|
const onDropdownVisibleChange = (visible) => {
|
|
847
908
|
setSelectOpen(visible);
|
|
848
|
-
//
|
|
849
|
-
|
|
909
|
+
// 关闭下拉框 如果首次本身就不展示数据的 没有选中数据-需要清空查询数据源; 首次展示的默认展示
|
|
910
|
+
if (!visible && !value?.length) {
|
|
911
|
+
resetSelectDataSource()
|
|
912
|
+
}
|
|
850
913
|
}
|
|
851
914
|
const renderTable = (dataSource) => {
|
|
852
915
|
return (
|
|
@@ -857,11 +920,27 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
857
920
|
{...(selectMode?{
|
|
858
921
|
rowSelection: {
|
|
859
922
|
type: 'checkbox',
|
|
860
|
-
|
|
923
|
+
columnWidth: '24px',
|
|
924
|
+
selectedRowKeys: labelInValue ? value?.map(s=> (s?.value||s)) : value,
|
|
925
|
+
preserveSelectedRowKeys: true, // 避免搜索之后 没有了选中前的数据 保证sks的正确性
|
|
861
926
|
onChange: (sks, srs) => {
|
|
862
|
-
|
|
927
|
+
const oldSelect = value?.map(s => ({ value: s?.value||s }))||[];
|
|
928
|
+
let tmpSelectedRows = oldSelect.concat(srs).filter(item => item != undefined);
|
|
929
|
+
let realSrs = sks.map(key => tmpSelectedRows.filter(item => item.value == key)[0]).filter(item => item != undefined)
|
|
930
|
+
onSelectClick(realSrs, dataSource,false)
|
|
863
931
|
}
|
|
864
|
-
}
|
|
932
|
+
},
|
|
933
|
+
onRow: (record, rowKey) => ({
|
|
934
|
+
onClick: event => {
|
|
935
|
+
event.stopPropagation();
|
|
936
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
937
|
+
|
|
938
|
+
const oldSelect = value?.map(s => ({ value: s?.value||s }))||[];
|
|
939
|
+
const newSelect = [JSON.parse(JSON.stringify(record))];
|
|
940
|
+
const srs = getRealStr(oldSelect,newSelect,record);
|
|
941
|
+
onSelectClick(srs,dataSource,false)
|
|
942
|
+
}, // 点击行
|
|
943
|
+
})
|
|
865
944
|
}:{
|
|
866
945
|
rowSelection: {
|
|
867
946
|
type: 'radio',
|
|
@@ -869,11 +948,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
869
948
|
selectedRowKeys: labelInValue ? value?.value&&[value?.value]||[] : value&&[value]||[],
|
|
870
949
|
},
|
|
871
950
|
onRow: (record, rowKey) => ({
|
|
872
|
-
|
|
951
|
+
onClick: event => {
|
|
873
952
|
const srs = [JSON.parse(JSON.stringify(record))]
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
},
|
|
953
|
+
onSelectClick(srs,dataSource)
|
|
954
|
+
}, // 点击行
|
|
877
955
|
})
|
|
878
956
|
})}
|
|
879
957
|
columns={selectProps?.renderTableColumns||[]}
|
|
@@ -936,6 +1014,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
936
1014
|
return (getSelectValueText(value) || kongValue) as string;
|
|
937
1015
|
}
|
|
938
1016
|
const getShowStr = () => {
|
|
1017
|
+
// 优先使用业务使用传入的展示
|
|
1018
|
+
if(viewShowValueStr) return viewShowValueStr;
|
|
1019
|
+
|
|
939
1020
|
const kongValue = '无'
|
|
940
1021
|
// 先判断labelInValue与否,labelInValue可以直接去value中获取字段名称,否则去下拉框数据里面去拿;
|
|
941
1022
|
// 再判断是单选还是多选,数据类型不同取值方式也不同
|
|
@@ -945,7 +1026,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
945
1026
|
return getShowValueStr(kongValue);
|
|
946
1027
|
}
|
|
947
1028
|
|
|
948
|
-
const isShouldShowStr = props.disabled && ctx
|
|
1029
|
+
const isShouldShowStr = (props.disabled && ctx) || ctx?.mode == 'view';
|
|
949
1030
|
return (
|
|
950
1031
|
<div className={'search_select'}>
|
|
951
1032
|
{fieldComponent ? (
|
|
@@ -971,7 +1052,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
971
1052
|
value={value}
|
|
972
1053
|
onChange={onchange}
|
|
973
1054
|
onClear={onClear}
|
|
974
|
-
|
|
1055
|
+
onDeselect={onDeselect}
|
|
1056
|
+
disabled={sDisabled}
|
|
975
1057
|
dropdownStyle={{ borderRadius: '2px', padding: '10px 2px' }}
|
|
976
1058
|
open={selectOpen}
|
|
977
1059
|
onDropdownVisibleChange={onDropdownVisibleChange}
|
|
@@ -981,7 +1063,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
981
1063
|
<Spin size="small" className='searchSelectSpin' />
|
|
982
1064
|
) : (
|
|
983
1065
|
<div style={{ textAlign: 'center' }}>
|
|
984
|
-
<div>{searchValue?'无匹配结果,请更换其他内容再试'
|
|
1066
|
+
<div>{(searchValue||init||isHaveDependency)?'无匹配结果,请更换其他内容再试':`请录入${searchStartLength?'4位数以上':''}字符进行模糊查询`}</div>
|
|
985
1067
|
</div>
|
|
986
1068
|
)
|
|
987
1069
|
}
|
|
@@ -991,7 +1073,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
991
1073
|
maxTagPlaceholder={maxTagPlaceholder}
|
|
992
1074
|
onSearch={(v) => onSearchChange(v)}
|
|
993
1075
|
{...(needModalTable ? {
|
|
994
|
-
suffixIcon: <div className=
|
|
1076
|
+
suffixIcon: <div className={`search_select_expand_button ${(sDisabled)?'search_select_expand_button_disabled':''}`} onClick={showModal}><SearchOutlined /></div>
|
|
995
1077
|
} : {})}
|
|
996
1078
|
{...currentSelectProps}
|
|
997
1079
|
getPopupContainer={(triggerNode) => (getPopupContainer && getPopupContainer(triggerNode)) || triggerNode.parentElement}
|
|
@@ -1009,6 +1091,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1009
1091
|
)}
|
|
1010
1092
|
{needModalTable && isModalVisible && (
|
|
1011
1093
|
<Modal
|
|
1094
|
+
maskClosable={false}
|
|
1012
1095
|
destroyOnClose
|
|
1013
1096
|
width="80%"
|
|
1014
1097
|
title={modalTableProps?.modalTableTitle}
|
|
@@ -1027,11 +1110,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1027
1110
|
type="primary"
|
|
1028
1111
|
loading={confirmLoading}
|
|
1029
1112
|
onClick={handleOk}
|
|
1030
|
-
disabled={
|
|
1031
|
-
!tableData.length ||
|
|
1032
|
-
selectProps?.disabled ||
|
|
1033
|
-
props?.disabled
|
|
1034
|
-
}
|
|
1113
|
+
disabled={sDisabled}
|
|
1035
1114
|
>
|
|
1036
1115
|
确定
|
|
1037
1116
|
</Button>,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
export const columnsPerRow = 4; // 每行的列数
|
|
2
|
+
export const ColSpan = 6; // 查询条件 每行col = 24 /columnsPerRow
|
|
1
3
|
export const handleSourceName = (sName: any) => {
|
|
2
4
|
return sName
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
export const getFormRowInfo = (list: any) => {
|
|
6
|
-
const columnsPerRow = 4; // 每行的列数
|
|
7
8
|
const totalRows = Math.ceil(list.length / columnsPerRow); // 计算总行数
|
|
8
9
|
const lastRowColumns = (list.length+1) % columnsPerRow; // 计算最后一行的实际列数
|
|
9
10
|
const emptySlots = lastRowColumns === 0 ? 0 : columnsPerRow - lastRowColumns; // 计算最后一行的空位数
|
|
@@ -24,4 +25,14 @@ export const hasMoreQueryFields = (modalTableProps: any) => {
|
|
|
24
25
|
const { tableSearchForm } = modalTableProps || {}
|
|
25
26
|
const visibleFieldsCount = getVisibleFieldsCount(modalTableProps);
|
|
26
27
|
return visibleFieldsCount < tableSearchForm?.length;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const getRealStr = (oldSelect: any,newSelect: any, record: any) => {
|
|
31
|
+
return oldSelect?.length ? oldSelect.some((o: any) => o.value == record?.value) ? oldSelect.filter((s: any) => s.value != record?.value) : [...oldSelect,...newSelect] : newSelect;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const getTableHeigth = (list: any) => {
|
|
35
|
+
const totalRows = Math.ceil((list?.length+1) / 4);
|
|
36
|
+
if(totalRows == 1) return 502; // modal弹窗760 调整为700 适应小屏
|
|
37
|
+
return 488 - totalRows*10
|
|
27
38
|
}
|