@bit-sun/business-component 4.0.12-alpha.9 → 4.0.13-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.
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +1 -1
- package/dist/components/Business/PropertyModal/index.d.ts +23 -0
- package/dist/components/Business/PropertyModal/mockData.d.ts +10 -0
- package/dist/components/Business/PropertyModal/propertyGroup.d.ts +4 -0
- package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +4 -0
- package/dist/components/Functional/QueryMutipleSelect/index.d.ts +5 -0
- package/dist/components/Functional/SearchSelect/utils.d.ts +16 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1510 -588
- package/dist/index.js +1507 -583
- package/package.json +3 -3
- package/src/components/Business/BsSulaQueryTable/utils.tsx +5 -4
- package/src/components/Business/PropertyModal/index.less +58 -0
- package/src/components/Business/PropertyModal/index.md +33 -0
- package/src/components/Business/PropertyModal/index.tsx +271 -0
- package/src/components/Business/PropertyModal/mockData.ts +160 -0
- package/src/components/Business/PropertyModal/propertyGroup.tsx +205 -0
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +50 -3
- package/src/components/Business/SearchSelect/index.md +3 -4
- package/src/components/Business/columnSettingTable/columnSetting.tsx +2 -1
- package/src/components/Business/columnSettingTable/components/TableSumComponent.tsx +25 -0
- package/src/components/Business/columnSettingTable/components/style.less +25 -0
- package/src/components/Business/columnSettingTable/index.tsx +3 -28
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +2 -27
- package/src/components/Functional/QueryMutipleSelect/index.less +117 -0
- package/src/components/Functional/QueryMutipleSelect/index.md +41 -0
- package/src/components/Functional/QueryMutipleSelect/index.tsx +245 -0
- package/src/components/Functional/SearchSelect/index.less +33 -1
- package/src/components/Functional/SearchSelect/index.tsx +76 -269
- package/src/components/Functional/SearchSelect/utils.tsx +401 -0
- package/src/components/Solution/RuleComponent/ruleFiled.js +93 -93
- package/src/index.ts +2 -0
- package/src/components/Functional/SearchSelect/utils.ts +0 -38
|
@@ -4,13 +4,13 @@ import { useDebounceFn } from 'ahooks';
|
|
|
4
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
|
-
import { stringify } from 'querystring';
|
|
8
7
|
import _, { escapeRegExp, isNil, values } from "lodash"
|
|
9
8
|
import './index.less';
|
|
10
|
-
import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
|
|
11
|
-
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth } 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';
|
|
12
11
|
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
13
12
|
import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
|
|
13
|
+
import PropertySelector from '@/components/Business/PropertyModal';
|
|
14
14
|
|
|
15
15
|
const { Option } = Select;
|
|
16
16
|
|
|
@@ -27,12 +27,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
27
27
|
sourceName,
|
|
28
28
|
needModalTable = true,
|
|
29
29
|
getPopupContainer = undefined,
|
|
30
|
+
highestPopContainer = undefined,
|
|
30
31
|
fieldComponent,
|
|
31
32
|
onSaveCallback,
|
|
32
33
|
selectBusinessType,
|
|
33
34
|
} = props;
|
|
34
35
|
const {
|
|
35
36
|
url,
|
|
37
|
+
method = 'get',
|
|
36
38
|
otherParams,// 默认参数
|
|
37
39
|
isMap,
|
|
38
40
|
fixedparameter,
|
|
@@ -69,9 +71,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
69
71
|
listHeight: 160,
|
|
70
72
|
optionLabelProp: "label",
|
|
71
73
|
autoClearSearchValue: false,
|
|
72
|
-
placement: '
|
|
74
|
+
placement: 'bottomRight'
|
|
73
75
|
}
|
|
74
|
-
|
|
76
|
+
|
|
77
|
+
const pathname = window.location.href;
|
|
78
|
+
var pattern = /(action|create|edit|view)/
|
|
79
|
+
const isFormPage = pathname.match(pattern)?.length > 0;
|
|
80
|
+
|
|
81
|
+
const initPagination = { showQuickJumper: true, showSizeChanger: true, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
|
|
75
82
|
const tableInitPagination = { ...initPagination, total: 0, current: 1 }
|
|
76
83
|
const disabled = noOperate || selectProps?.disabled || props?.disabled;
|
|
77
84
|
const isHaveDependency = fixedparameter && fieldValToParam && ctx;
|
|
@@ -87,6 +94,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
87
94
|
|
|
88
95
|
const [items, setItems] = useState([]);
|
|
89
96
|
const [selectOpen, setSelectOpen] = useState(false);
|
|
97
|
+
const [isMaxTagsOpen, setIsMaxTagsOpen] = useState(false);
|
|
90
98
|
const [scrollPage, setScrollPage] = useState(1);
|
|
91
99
|
const [itemsTotal, setItemsTotal] = useState(0);
|
|
92
100
|
const [fetching, setFetching] = useState(false);
|
|
@@ -211,105 +219,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
211
219
|
}
|
|
212
220
|
|
|
213
221
|
// 数组对象处理,对带有特殊标记的name进行处理
|
|
214
|
-
|
|
215
|
-
if (Object.prototype.hasOwnProperty.call(params, key)) {
|
|
216
|
-
const element = params[key];
|
|
217
|
-
if (element && key.indexOf('*number*') >= 0) {
|
|
218
|
-
const dataParams = key.split('*number*');
|
|
219
|
-
dataParams.forEach((value, index) => {
|
|
220
|
-
params[value] = element[index];
|
|
221
|
-
});
|
|
222
|
-
delete params[key];
|
|
223
|
-
} else if (element && key.indexOf('*address*') >= 0) {
|
|
224
|
-
const dataParams = key.split('*address*');
|
|
225
|
-
dataParams.forEach((value, index) => {
|
|
226
|
-
params[value] = element.PCDCode[index];
|
|
227
|
-
});
|
|
228
|
-
delete params[key];
|
|
229
|
-
} else if (element && key.indexOf('*costType*') >= 0) {
|
|
230
|
-
const dataParams = key.split('*costType*');
|
|
231
|
-
// eslint-disable-next-line prefer-destructuring
|
|
232
|
-
params[dataParams[0]] = element[1];
|
|
233
|
-
delete params[key];
|
|
234
|
-
} else if (element && key.indexOf('*fullDate*') >= 0) {
|
|
235
|
-
const dataParams = key.split('*fullDate*');
|
|
236
|
-
dataParams.forEach((value, index) => {
|
|
237
|
-
if (index === 0) {
|
|
238
|
-
params[value] = moment(element[index])
|
|
239
|
-
.millisecond(0)
|
|
240
|
-
.second(0)
|
|
241
|
-
.minute(0)
|
|
242
|
-
.hour(0)
|
|
243
|
-
.format('YYYY-MM-DD HH:mm:ss');
|
|
244
|
-
} else {
|
|
245
|
-
params[value] = moment(element[index])
|
|
246
|
-
.millisecond(59)
|
|
247
|
-
.second(59)
|
|
248
|
-
.minute(59)
|
|
249
|
-
.hour(23)
|
|
250
|
-
.format('YYYY-MM-DD HH:mm:ss');
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
delete params[key];
|
|
254
|
-
} else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
|
|
255
|
-
const dataParams = key.split('*checkBox*');
|
|
256
|
-
if (element) {
|
|
257
|
-
params[dataParams[0]] = 0
|
|
258
|
-
}
|
|
259
|
-
delete params[key];
|
|
260
|
-
} else if (element && key.indexOf('*cascader*') >= 0) {
|
|
261
|
-
const dataParams = key.split('*cascader*');
|
|
262
|
-
params[dataParams[0]] = element[element.length - 1]
|
|
263
|
-
delete params[key];
|
|
264
|
-
} else if (element && key.indexOf('*date*') >= 0) {
|
|
265
|
-
const dataParams = key.split('*date*')
|
|
266
|
-
dataParams.forEach((value, index) => {
|
|
267
|
-
if (index === 0) {
|
|
268
|
-
params[value] = moment(element[index])
|
|
269
|
-
.format('YYYY-MM-DD');
|
|
270
|
-
} else {
|
|
271
|
-
params[value] = moment(element[index])
|
|
272
|
-
.format('YYYY-MM-DD');
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
delete params[key];
|
|
276
|
-
} else if (element && key.indexOf('*multiInput') >= 0) {
|
|
277
|
-
let name = '',
|
|
278
|
-
value = element['value'];
|
|
279
|
-
if (value.indexOf(',') >= 0) {
|
|
280
|
-
name = `qp-${element['name']}-in`;
|
|
281
|
-
} else {
|
|
282
|
-
name = `qp-${element['name']}-like`;
|
|
283
|
-
}
|
|
284
|
-
params[name] = value;
|
|
285
|
-
delete params[key];
|
|
286
|
-
}
|
|
287
|
-
else if (element && key.indexOf('*') >= 0) {
|
|
288
|
-
const dataParams = key.split('*');
|
|
289
|
-
dataParams.forEach((value, index) => {
|
|
290
|
-
params[value] = element[index].format('YYYY-MM-DD HH:mm:ss');
|
|
291
|
-
});
|
|
292
|
-
delete params[key];
|
|
293
|
-
} else if (element && key.indexOf('_selectNumberRange') >= 0) { // key = xxxxx_selectNumberRange qp-xxxxx-gt
|
|
294
|
-
const dataParams = key.split('_selectNumberRange')[0]
|
|
295
|
-
if (params[key][0] === 'range') {
|
|
296
|
-
if (params[key][1][0]) {
|
|
297
|
-
params[`qp-${dataParams}-ge`] = params[key][1][0]
|
|
298
|
-
}
|
|
299
|
-
if (params[key][1][1]) {
|
|
300
|
-
params[`qp-${dataParams}-le`] = params[key][1][1]
|
|
301
|
-
}
|
|
302
|
-
} else {
|
|
303
|
-
params[`qp-${dataParams}-${params[key][0]}`] = params[key][1]
|
|
304
|
-
}
|
|
305
|
-
delete params[key]
|
|
306
|
-
} else if (Array.isArray(element)) {
|
|
307
|
-
params[key] = element.join(',');
|
|
308
|
-
} else if (element == null || element === undefined || String(element).trim() === '') {
|
|
309
|
-
delete params[key]
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
222
|
+
handleParams(params)
|
|
313
223
|
|
|
314
224
|
const queryParams = {
|
|
315
225
|
pageSize,
|
|
@@ -321,13 +231,18 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
321
231
|
if (isNil(queryParams[selectParamsKey])) {
|
|
322
232
|
queryParams[selectParamsKey] = searchValue;
|
|
323
233
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
.
|
|
234
|
+
|
|
235
|
+
let getRequest;
|
|
236
|
+
const methodName = method?.toLocaleLowerCase();
|
|
237
|
+
if(['post','patch','put'].includes(methodName)) {
|
|
238
|
+
getRequest = request[methodName](`${url}${convertUrlQueryParams(queryParams)}`,convertBodyParams(queryParams))
|
|
239
|
+
} else {
|
|
240
|
+
getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!url || !getRequest) return;
|
|
244
|
+
|
|
245
|
+
getRequest.then((result: any) => {
|
|
331
246
|
setFetching(false)
|
|
332
247
|
result = result.data;
|
|
333
248
|
if (judgeIsRequestError(result)) {
|
|
@@ -335,71 +250,8 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
335
250
|
return;
|
|
336
251
|
}
|
|
337
252
|
const res = result.data;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
source = Object.keys(res).map((d, i) => {
|
|
341
|
-
return {
|
|
342
|
-
text: Object.values(res)[i],
|
|
343
|
-
value: d,
|
|
344
|
-
};
|
|
345
|
-
});
|
|
346
|
-
} else {
|
|
347
|
-
const keys = res.list ? 'list' : 'items';
|
|
348
|
-
source = res
|
|
349
|
-
? res[keys]
|
|
350
|
-
? res[keys].map((item: any, index: number) => {
|
|
351
|
-
let textShowText = item[mappingTextField]
|
|
352
|
-
if (mappingTextShowTextField) {
|
|
353
|
-
textShowText = []
|
|
354
|
-
if (Array.isArray(mappingTextShowTextField)) {
|
|
355
|
-
mappingTextShowTextField.forEach((r: any) => {
|
|
356
|
-
textShowText.push(item[r])
|
|
357
|
-
})
|
|
358
|
-
} else {
|
|
359
|
-
textShowText = item[mappingTextShowTextField]
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if(!item?.children?.length) {delete item?.children};
|
|
363
|
-
return {
|
|
364
|
-
...item,
|
|
365
|
-
text: specialBracket
|
|
366
|
-
? `【${item[mappingValueField]}】${item[mappingTextField]}`
|
|
367
|
-
: item[mappingTextField],
|
|
368
|
-
textShowText,
|
|
369
|
-
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
370
|
-
value: item[mappingValueField],
|
|
371
|
-
keyIndex: index + 1,
|
|
372
|
-
};
|
|
373
|
-
})
|
|
374
|
-
: Array.isArray(res) &&
|
|
375
|
-
res?.map((item: Record<string, any>, index: number) => {
|
|
376
|
-
let textShowText = item[mappingTextField]
|
|
377
|
-
if (mappingTextShowTextField) {
|
|
378
|
-
textShowText = []
|
|
379
|
-
if (Array.isArray(mappingTextShowTextField)) {
|
|
380
|
-
mappingTextShowTextField.forEach((r: any) => {
|
|
381
|
-
textShowText.push(item[r])
|
|
382
|
-
})
|
|
383
|
-
} else {
|
|
384
|
-
textShowText = item[mappingTextShowTextField]
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
if(!item?.children?.length) {delete item?.children};
|
|
388
|
-
return {
|
|
389
|
-
...item,
|
|
390
|
-
text: specialBracket
|
|
391
|
-
? `【${item[mappingValueField]}】${item[mappingTextField]}`
|
|
392
|
-
: item[mappingTextField],
|
|
393
|
-
textShowText,
|
|
394
|
-
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
395
|
-
value: item[mappingValueField],
|
|
396
|
-
keyIndex: index + 1,
|
|
397
|
-
};
|
|
398
|
-
})
|
|
399
|
-
: [];
|
|
400
|
-
}
|
|
401
|
-
// 数据源 不可以有重复key
|
|
402
|
-
source = Array.isArray(source) ? _.uniqBy(source, 'value') : [];
|
|
253
|
+
const source: any = convertResData(requestConfig, res, { selectMode, labelInValue, value, type, items, queryParams });
|
|
254
|
+
|
|
403
255
|
if(callback) {
|
|
404
256
|
callback(source)
|
|
405
257
|
} else {
|
|
@@ -468,7 +320,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
468
320
|
}, [value]);
|
|
469
321
|
|
|
470
322
|
useEffect(() => {
|
|
471
|
-
makeUniqueValue();
|
|
323
|
+
setUniqueValue(makeUniqueValue());
|
|
472
324
|
}, [resultSourceKey])
|
|
473
325
|
|
|
474
326
|
useEffect(() => {
|
|
@@ -619,12 +471,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
619
471
|
|
|
620
472
|
const onSearchTable = () => {
|
|
621
473
|
const params = form.getFieldsValue();
|
|
622
|
-
|
|
623
|
-
// const isHaveParams = params && Object.keys(params).filter(item => params[item]).length > 0;
|
|
624
474
|
setModalSearched(true);
|
|
625
|
-
|
|
626
475
|
setTableFormParams(params);
|
|
627
|
-
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
476
|
+
getData({ ...params, pageSize: tableInitPageSize }, 2, null);
|
|
628
477
|
}
|
|
629
478
|
|
|
630
479
|
const onResetTable = () => {
|
|
@@ -640,30 +489,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
640
489
|
const handleTableChange = (pagination) => {
|
|
641
490
|
getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
|
|
642
491
|
}
|
|
643
|
-
const LightHeightOption = (props) => {
|
|
644
|
-
const {
|
|
645
|
-
filterTxt, text,
|
|
646
|
-
} = props
|
|
647
|
-
const heightLightTxt = (text, heightTxt) => {
|
|
648
|
-
if (heightTxt === '') {
|
|
649
|
-
return text
|
|
650
|
-
}
|
|
651
|
-
const searchString = escapeRegExp(heightTxt);
|
|
652
|
-
// 前面filterOption 不区分大小写,这里用i
|
|
653
|
-
const regexp = new RegExp(searchString, 'gi')
|
|
654
|
-
return text.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
|
|
655
|
-
}
|
|
656
|
-
return (
|
|
657
|
-
<Tooltip title={text}>
|
|
658
|
-
<div ref={(nodeElement) => {
|
|
659
|
-
if (nodeElement) {
|
|
660
|
-
nodeElement.innerHTML = heightLightTxt(text, filterTxt)
|
|
661
|
-
}
|
|
662
|
-
}}
|
|
663
|
-
/>
|
|
664
|
-
</Tooltip>
|
|
665
|
-
)
|
|
666
|
-
}
|
|
667
492
|
|
|
668
493
|
// 扁平化二维数组的方法
|
|
669
494
|
const mapRows = params => {
|
|
@@ -697,13 +522,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
697
522
|
setCheckedAll(selectRows.length === tablePagination?.total);
|
|
698
523
|
}
|
|
699
524
|
|
|
700
|
-
// 生成唯一值
|
|
701
|
-
const makeUniqueValue = () => {
|
|
702
|
-
const generateUnitKey = (((1 + Math.random()) * 0x10000) | 0).toString(16);
|
|
703
|
-
setUniqueValue(generateUnitKey);
|
|
704
|
-
return generateUnitKey;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
525
|
const rowSelection = {
|
|
708
526
|
type: selectMode ? 'checkbox' : 'radio',
|
|
709
527
|
selectedRowKeys,
|
|
@@ -804,6 +622,28 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
804
622
|
</Col>
|
|
805
623
|
);
|
|
806
624
|
}
|
|
625
|
+
if (i?.field?.type === 'proppertySelector') {
|
|
626
|
+
return (
|
|
627
|
+
<Col span={ColSpan} key={i.name}>
|
|
628
|
+
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
629
|
+
<PropertySelector
|
|
630
|
+
/>
|
|
631
|
+
</Form.Item>
|
|
632
|
+
</Col>
|
|
633
|
+
);
|
|
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
|
+
}
|
|
807
647
|
|
|
808
648
|
// 默认type是input
|
|
809
649
|
return (
|
|
@@ -824,14 +664,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
824
664
|
return collapsed ? formItem(list?.slice(0,viCount)) : formItem(list)
|
|
825
665
|
}
|
|
826
666
|
|
|
827
|
-
// const queryFieldsDom = <SearchItemTable
|
|
828
|
-
// ref={searchTableRef}
|
|
829
|
-
// setShowSearchFields={setShowSearchFields||[]}
|
|
830
|
-
// showSearchFields={showSearchFields||[]}
|
|
831
|
-
// datasource={modalTableProps?.tableSearchForm || []}
|
|
832
|
-
// bsTableCode={bsTableCode}
|
|
833
|
-
// />
|
|
834
|
-
|
|
835
667
|
const renderShowTable = (tableList, type) => {
|
|
836
668
|
const tableBoxHeighth = getTableHeigth(modalTableProps?.tableSearchForm);
|
|
837
669
|
const oSY = `calc(100vh - ${tableBoxHeighth}px - 82px)`; // 分页 24+16*2+10 「高 + margin * 2 + paddingBottom 10 」
|
|
@@ -844,7 +676,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
844
676
|
columns={tableShowColumns}
|
|
845
677
|
dataSource={tableList}
|
|
846
678
|
{...type=='noPage'?{
|
|
847
|
-
pagination: initPagination,
|
|
679
|
+
pagination: { ...initPagination,showSizeChanger: false },
|
|
848
680
|
locale: {
|
|
849
681
|
emptyText: '暂无已选结果',
|
|
850
682
|
}
|
|
@@ -880,10 +712,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
880
712
|
{ label: `已选(${selectedRowKeys?.length || 0})`, key: 'selected', children: renderShowTable(selectedRows?.map((s,index)=> ({...s,keyIndex:index+1}))||[],'noPage') },
|
|
881
713
|
];
|
|
882
714
|
|
|
883
|
-
const resetSelectDataSource = () => {
|
|
715
|
+
const resetSelectDataSource = (isClear=false) => {
|
|
884
716
|
setSearchValue('');
|
|
885
717
|
// 有关联值 不需要清空下拉框数据 也不需要重新去请求了
|
|
886
|
-
if(isHaveDependency) return;
|
|
718
|
+
if(!isClear && isHaveDependency) return; // 清空时需要放开:级联首次回之后,清空数据需要重新查询下拉框的值
|
|
887
719
|
clearSelectDataSource();
|
|
888
720
|
init && run('init')
|
|
889
721
|
}
|
|
@@ -895,11 +727,11 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
895
727
|
formaData([], items);
|
|
896
728
|
onChangeSelectedKeys([], [])
|
|
897
729
|
// 重置下拉框数据源
|
|
898
|
-
resetSelectDataSource();
|
|
730
|
+
resetSelectDataSource(true);
|
|
899
731
|
}
|
|
900
732
|
|
|
901
733
|
const onDeselect = (...arg) => {
|
|
902
|
-
const oldSelect =
|
|
734
|
+
const oldSelect = formatSelectedValue(value);
|
|
903
735
|
const deRecord = arg[1];
|
|
904
736
|
const srs = oldSelect.filter((s: any) => s.value != deRecord?.value)
|
|
905
737
|
onSelectClick(srs, items,false)
|
|
@@ -910,13 +742,22 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
910
742
|
}
|
|
911
743
|
|
|
912
744
|
const onDropdownVisibleChange = (visible) => {
|
|
745
|
+
// 阻止maxTagPlaceholder点击事件触发下拉框展示事件
|
|
746
|
+
if(isMaxTagsOpen && !selectOpen) return;
|
|
747
|
+
|
|
913
748
|
setSelectOpen(visible);
|
|
914
749
|
// 关闭下拉框 如果首次本身就不展示数据的 没有选中数据-需要清空查询数据源; 首次展示的默认展示
|
|
915
750
|
if (!visible && !value?.length) {
|
|
916
|
-
|
|
751
|
+
setTimeout(() => {
|
|
752
|
+
// 延时 是为了避免 执行时候出现下拉框弹两次的问题-可以看到数据源从展示到显示空数据框的问题
|
|
753
|
+
resetSelectDataSource()
|
|
754
|
+
}, 200)
|
|
917
755
|
}
|
|
918
756
|
}
|
|
919
757
|
const renderTable = (dataSource) => {
|
|
758
|
+
const currentSRKs = getCurrentSRKs(selectMode,labelInValue,value)
|
|
759
|
+
const renderSource = getRenderSource(currentSRKs,items)
|
|
760
|
+
|
|
920
761
|
return (
|
|
921
762
|
<div className={`search_select_dropdown_table ${!selectMode?'search_select_dropdown_table1':''}`}>
|
|
922
763
|
<Table
|
|
@@ -926,10 +767,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
926
767
|
rowSelection: {
|
|
927
768
|
type: 'checkbox',
|
|
928
769
|
columnWidth: '24px',
|
|
929
|
-
selectedRowKeys:
|
|
770
|
+
selectedRowKeys: currentSRKs,
|
|
930
771
|
preserveSelectedRowKeys: true, // 避免搜索之后 没有了选中前的数据 保证sks的正确性
|
|
931
772
|
onChange: (sks, srs) => {
|
|
932
|
-
const oldSelect =
|
|
773
|
+
const oldSelect = formatSelectedValue(value);
|
|
933
774
|
let tmpSelectedRows = oldSelect.concat(srs).filter(item => item != undefined);
|
|
934
775
|
let realSrs = sks.map(key => tmpSelectedRows.filter(item => item.value == key)[0]).filter(item => item != undefined)
|
|
935
776
|
onSelectClick(realSrs, dataSource,false)
|
|
@@ -940,7 +781,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
940
781
|
event.stopPropagation();
|
|
941
782
|
event.nativeEvent.stopImmediatePropagation();
|
|
942
783
|
|
|
943
|
-
const oldSelect =
|
|
784
|
+
const oldSelect = formatSelectedValue(value);
|
|
944
785
|
const newSelect = [JSON.parse(JSON.stringify(record))];
|
|
945
786
|
const srs = getRealStr(oldSelect,newSelect,record);
|
|
946
787
|
onSelectClick(srs,dataSource,false)
|
|
@@ -950,7 +791,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
950
791
|
rowSelection: {
|
|
951
792
|
type: 'radio',
|
|
952
793
|
columnWidth: 0,
|
|
953
|
-
selectedRowKeys:
|
|
794
|
+
selectedRowKeys: currentSRKs,
|
|
954
795
|
},
|
|
955
796
|
onRow: (record, rowKey) => ({
|
|
956
797
|
onClick: event => {
|
|
@@ -960,7 +801,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
960
801
|
})
|
|
961
802
|
})}
|
|
962
803
|
columns={selectProps?.renderTableColumns||[]}
|
|
963
|
-
dataSource={
|
|
804
|
+
dataSource={renderSource}
|
|
964
805
|
size="middle"
|
|
965
806
|
pagination={false}
|
|
966
807
|
rowKey={mappingValueField}
|
|
@@ -970,39 +811,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
970
811
|
);
|
|
971
812
|
}
|
|
972
813
|
|
|
973
|
-
const maxTagPlaceholder = (selectedValues) => {
|
|
974
|
-
const onClose = (e: any, item: any) => {
|
|
975
|
-
e.preventDefault();
|
|
976
|
-
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)
|
|
977
|
-
onChange(newValue);
|
|
978
|
-
}
|
|
979
|
-
return (
|
|
980
|
-
<Tooltip title={selectedValues.map((i: any) => (
|
|
981
|
-
<Tag
|
|
982
|
-
closable={true}
|
|
983
|
-
onClose={(e) => onClose(e, i)}
|
|
984
|
-
style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
|
|
985
|
-
>
|
|
986
|
-
{i.label}
|
|
987
|
-
</Tag>
|
|
988
|
-
))}>
|
|
989
|
-
{`+ ${selectedValues?.length}`}
|
|
990
|
-
</Tooltip>
|
|
991
|
-
)
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
const handleSelectOptionsShowValue = (specialBracket: boolean, noNeedSplit: boolean, item: object) => {
|
|
995
|
-
let showText = Array.isArray(item.textShowText) &&
|
|
996
|
-
item.textShowText.join(' ') || item.textShowText;
|
|
997
|
-
if (noNeedSplit) {
|
|
998
|
-
return item.text;
|
|
999
|
-
} else {
|
|
1000
|
-
return specialBracket
|
|
1001
|
-
? `【${item.textShowKey || ''}】${showText}`
|
|
1002
|
-
: `${item.textShowKey || ''} ${showText}`
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
|
|
1006
814
|
const getShowLabelTextStr = (kongValue): string => {
|
|
1007
815
|
if (selectMode) {
|
|
1008
816
|
return Array.isArray(value) && value?.map(item => item.label || item.text || '')?.join(',') || kongValue;
|
|
@@ -1049,7 +857,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1049
857
|
{getShowStr()}
|
|
1050
858
|
</div>) :
|
|
1051
859
|
<div
|
|
1052
|
-
className=
|
|
860
|
+
className={`${isFormPage ? '' : 'search_select_show_list'} search_select_show`}
|
|
1053
861
|
id={`search_select_div_${uniqueValue}`}
|
|
1054
862
|
>
|
|
1055
863
|
<Select
|
|
@@ -1059,7 +867,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1059
867
|
onClear={onClear}
|
|
1060
868
|
onDeselect={onDeselect}
|
|
1061
869
|
disabled={sDisabled}
|
|
1062
|
-
dropdownStyle={{ borderRadius: '2px', padding: '10px 2px'
|
|
870
|
+
dropdownStyle={{ borderRadius: '2px', padding: '10px 2px'}}
|
|
1063
871
|
open={selectOpen}
|
|
1064
872
|
onDropdownVisibleChange={onDropdownVisibleChange}
|
|
1065
873
|
dropdownRender={(menu) => items?.length ? renderTable(items) : menu}
|
|
@@ -1075,13 +883,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1075
883
|
onPopupScroll={SelectScroll}
|
|
1076
884
|
style={{ width: 'calc(100%)' }}
|
|
1077
885
|
placeholder="请选择"
|
|
1078
|
-
maxTagPlaceholder={maxTagPlaceholder}
|
|
886
|
+
maxTagPlaceholder={(v)=> maxTagPlaceholder(v,{ selectProps:{labelInValue}, onChange, value, setIsMaxTagsOpen })}
|
|
1079
887
|
onSearch={(v) => onSearchChange(v)}
|
|
1080
888
|
{...(needModalTable ? {
|
|
1081
889
|
suffixIcon: <div className={`search_select_expand_button ${(sDisabled)?'search_select_expand_button_disabled':''}`} onClick={showModal}><SearchOutlined /></div>
|
|
1082
890
|
} : {})}
|
|
1083
891
|
{...currentSelectProps}
|
|
1084
|
-
getPopupContainer={(triggerNode) => (
|
|
892
|
+
getPopupContainer={(triggerNode) => (highestPopContainer && highestPopContainer(triggerNode)) || triggerNode.parentElement}
|
|
1085
893
|
>
|
|
1086
894
|
{items.map(item => (
|
|
1087
895
|
<Option key={item.value} label={item.text}>
|
|
@@ -1139,7 +947,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
1139
947
|
<Button key="reset" onClick={onResetTable}>
|
|
1140
948
|
重置 ctrl+U
|
|
1141
949
|
</Button>
|
|
1142
|
-
{/* <div>{queryFieldsDom}</div> */}
|
|
1143
950
|
<div style={{position: 'absolute',top: 0,right: 0}}>
|
|
1144
951
|
{hasMoreQueryFields(modalTableProps) && modalTableProps?.isHorizontally
|
|
1145
952
|
? <img onClick={() => {toggleCollapsed()}} style={{
|