@bit-sun/business-component 4.2.0-alpha.3 → 4.2.0-alpha.31
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/.fatherrc.ts +1 -1
- package/.umirc.ts +13 -9
- package/dist/components/Business/AddSelectBusiness/index.d.ts +3 -4
- package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/ChooseStore/index.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +2 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +1 -2
- package/dist/components/Business/BsLayouts/index.d.ts +1 -1
- package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +5 -5
- package/dist/components/Business/BsSulaQueryTable/index.d.ts +1 -2
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +6 -6
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +14 -15
- package/dist/components/Business/CommodityEntry/index.d.ts +1 -2
- package/dist/components/Business/CommonAlert/index.d.ts +1 -2
- package/dist/components/Business/CommonGuideWrapper/index.d.ts +3 -3
- package/dist/components/Business/DetailPageWrapper/index.d.ts +12 -12
- package/dist/components/Business/HomePageWrapper/index.d.ts +1 -2
- package/dist/components/Business/ImportExport/ExportButton/ModalTitle.d.ts +11 -0
- package/dist/components/Business/ImportExport/ExportButton/TemplatePicker.d.ts +13 -0
- package/dist/components/Business/ImportExport/ExportButton/index.d.ts +15 -0
- package/dist/components/Business/ImportExport/ImportWizard/Preview.d.ts +11 -0
- package/dist/components/Business/ImportExport/ImportWizard/index.d.ts +15 -0
- package/dist/components/Business/ImportExport/TaskDrawer/index.d.ts +15 -0
- package/dist/components/Business/ImportExport/TaskProgress/index.d.ts +15 -0
- package/dist/components/Business/ImportExport/businessFunction.d.ts +15 -0
- package/dist/components/Business/ImportExport/index.d.ts +14 -0
- package/dist/components/Business/ImportExport/sceneCapability.d.ts +20 -0
- package/dist/components/Business/ImportExport/services/importExport.d.ts +22 -0
- package/dist/components/Business/ImportExport/services/routing.d.ts +8 -0
- package/dist/components/Business/ImportExport/types.d.ts +134 -0
- package/dist/components/Business/ItemPropertySelector/index.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +1 -2
- package/dist/components/Business/PropertyModal/index.d.ts +1 -2
- package/dist/components/Business/PropertyModal/propertyGroup.d.ts +1 -1
- package/dist/components/Business/SearchSelect/index.d.ts +1 -1
- package/dist/components/Business/StateFlow/index.d.ts +1 -2
- package/dist/components/Business/SystemLog/index.d.ts +78 -0
- package/dist/components/Business/TreeSearchSelect/index.d.ts +1 -1
- package/dist/components/Business/TrialCalculation/index.d.ts +15 -0
- package/dist/components/Business/columnSettingTable/columnSetting.d.ts +6 -6
- package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +1 -2
- package/dist/components/Business/columnSettingTable/index.d.ts +3 -3
- package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +3 -3
- package/dist/components/Business/columnSettingTable/utils.d.ts +1 -2
- package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
- package/dist/components/Common/ParagraphCopier/index.d.ts +1 -1
- package/dist/components/Common/Section/index.d.ts +1 -1
- package/dist/components/Functional/AddSelect/index.d.ts +1 -2
- package/dist/components/Functional/AuthButton/index.d.ts +1 -2
- package/dist/components/Functional/DataImport/index.d.ts +3 -3
- package/dist/components/Functional/DataValidation/index.d.ts +5 -5
- package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +1 -2
- package/dist/components/Functional/QueryMutipleInput/index.d.ts +1 -2
- package/dist/components/Functional/QueryMutipleSelect/index.d.ts +1 -2
- package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
- package/dist/components/Functional/SearchSelect/pagination.d.ts +22 -0
- package/dist/components/Functional/SearchSelect/utils.d.ts +2 -3
- package/dist/components/Functional/TreeSearchSelect/index.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +1 -1
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/Formula.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/InnerSelect.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/RenderCompItem.d.ts +1 -2
- package/dist/components/Solution/RuleSetter/RuleInstance.d.ts +1 -2
- package/dist/components/Solution/RuleSetter/baseRule.d.ts +1 -1
- package/dist/components/Solution/RuleSetter/index.d.ts +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.esm.js +5397 -1220
- package/dist/index.js +5417 -1213
- package/dist/plugin/TableColumnSetting/index.d.ts +5 -5
- package/dist/utils/TableUtils.d.ts +18 -19
- package/dist/utils/auth.d.ts +4 -0
- package/dist/utils/utils.d.ts +41 -0
- package/docs/error-record.md +52 -0
- package/docs/flow-control-readme.md +283 -0
- package/docs/task-records/2026-07-31-import-export-extraction.md +81 -0
- package/package.json +1 -1
- package/src/components/Business/AddSelectBusiness/index.tsx +3 -2
- package/src/components/Business/BsSulaQueryTable/index.md +57 -4
- package/src/components/Business/BsSulaQueryTable/index.tsx +174 -10
- package/src/components/Business/BsSulaQueryTable/setting.tsx +6 -0
- package/src/components/Business/DetailPageWrapper/index.tsx +81 -1
- package/src/components/Business/DetailPageWrapper/readme.md +89 -0
- package/src/components/Business/ImportExport/ExportButton/ModalTitle.tsx +27 -0
- package/src/components/Business/ImportExport/ExportButton/TemplatePicker.tsx +424 -0
- package/src/components/Business/ImportExport/ExportButton/index.module.less +382 -0
- package/src/components/Business/ImportExport/ExportButton/index.tsx +273 -0
- package/src/components/Business/ImportExport/ImportWizard/Preview.tsx +129 -0
- package/src/components/Business/ImportExport/ImportWizard/index.module.less +360 -0
- package/src/components/Business/ImportExport/ImportWizard/index.tsx +679 -0
- package/src/components/Business/ImportExport/TaskDrawer/index.tsx +285 -0
- package/src/components/Business/ImportExport/TaskProgress/index.tsx +267 -0
- package/src/components/Business/ImportExport/businessFunction.ts +29 -0
- package/src/components/Business/ImportExport/index.md +104 -0
- package/src/components/Business/ImportExport/index.tsx +208 -0
- package/src/components/Business/ImportExport/sceneCapability.ts +28 -0
- package/src/components/Business/ImportExport/services/importExport.ts +208 -0
- package/src/components/Business/ImportExport/services/routing.ts +21 -0
- package/src/components/Business/ImportExport/types.ts +180 -0
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +704 -48
- package/src/components/Business/SearchSelect/index.md +2 -2
- package/src/components/Business/SystemLog/index.md +37 -0
- package/src/components/Business/SystemLog/index.tsx +87 -0
- package/src/components/Business/TrialCalculation/PathDisplay.less +93 -0
- package/src/components/Business/TrialCalculation/PathDisplay_README.md +77 -0
- package/src/components/Business/TrialCalculation/index.tsx +322 -0
- package/src/components/Business/columnSettingTable/index.tsx +7 -6
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +23 -22
- package/src/components/Functional/AddSelect/index.tsx +95 -1
- package/src/components/Functional/DataValidation/index.tsx +31 -9
- package/src/components/Functional/QueryMutipleSelect/index.tsx +2 -2
- package/src/components/Functional/SearchSelect/index.md +109 -0
- package/src/components/Functional/SearchSelect/index.tsx +99 -17
- package/src/components/Functional/SearchSelect/pagination.ts +57 -0
- package/src/components/Functional/SearchSelect/utils.tsx +28 -18
- package/src/components/Functional/TreeSearchSelect/index.tsx +2 -1
- package/src/components/Solution/RuleComponent/README.md +187 -0
- package/src/components/Solution/RuleComponent/RenderCompItem.tsx +9 -1
- package/src/components/Solution/RuleComponent/RenderCompItem_README.md +189 -0
- package/src/components/Solution/RuleComponent/RuleField.md +63 -0
- package/src/components/Solution/RuleComponent/index.js +237 -8
- package/src/components/Solution/RuleComponent/ruleFiled.js +46 -6
- package/src/components/Solution/RuleSetter/README.md +97 -0
- package/src/index.ts +9 -0
- package/src/typings/umi.d.ts +9 -0
- package/src/utils/LocalstorageUtils.ts +1 -1
- package/src/utils/auth.ts +39 -2
- package/src/utils/utils.ts +41 -1
|
@@ -4,10 +4,17 @@ import { useDebounceFn } from 'ahooks';
|
|
|
4
4
|
import { Input, Button, Modal, Select, Divider, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag, Row, Col, Space, Tabs, Empty, DatePicker } from 'antd';
|
|
5
5
|
import { SearchOutlined, CopyOutlined, CaretLeftOutlined } from '@ant-design/icons';
|
|
6
6
|
import request from '@/utils/request';
|
|
7
|
-
import _, { escapeRegExp, isNil, values } from "lodash"
|
|
7
|
+
import _, { escapeRegExp, isNil, values, cloneDeep, isEmpty } from "lodash"
|
|
8
8
|
import './index.less';
|
|
9
9
|
import { BusinessSearchSelect, QueryMutipleInput, QueryMutipleSearchSelect } from '@/index';
|
|
10
|
-
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, getTableHeigth, getCurrentSRKs, getRenderSource, handleParams, convertUrlQueryParams, convertBodyParams, formatSelectedValue, convertResData, makeUniqueValue, handleSelectOptionsShowValue, LightHeightOption, maxTagPlaceholder, getShowStr, handleTableColumns } from './utils';
|
|
10
|
+
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, getTableHeigth, getCurrentSRKs, getRenderSource, handleParams, convertUrlQueryParams, convertBodyParams, formatSelectedValue, convertResData, makeUniqueValue, handleSelectOptionsShowValue, LightHeightOption, maxTagPlaceholder, getShowStr, handleTableColumns, convertQueryParams } from './utils';
|
|
11
|
+
import {
|
|
12
|
+
getSearchSelectModalPageSize,
|
|
13
|
+
normalizeSearchSelectModalPageSize,
|
|
14
|
+
SEARCH_SELECT_MODAL_DEFAULT_PAGE_SIZE,
|
|
15
|
+
SEARCH_SELECT_MODAL_PAGE_SIZE_OPTIONS,
|
|
16
|
+
setSearchSelectModalPageSize,
|
|
17
|
+
} from './pagination';
|
|
11
18
|
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
12
19
|
import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
|
|
13
20
|
import PropertySelector from '@/components/Business/PropertyModal';
|
|
@@ -32,6 +39,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
32
39
|
highestPopContainer = undefined,
|
|
33
40
|
fieldComponent,
|
|
34
41
|
onSaveCallback,
|
|
42
|
+
returnFormat = [],
|
|
35
43
|
selectBusinessType,
|
|
36
44
|
} = props;
|
|
37
45
|
const {
|
|
@@ -54,6 +62,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
54
62
|
viewShowValueStr, // 详情展示值,不传展示组件处理的默认值
|
|
55
63
|
searchStartLength, // 默认不校验长度去搜索,如果配置了,则按照配置项长度进行处理搜索
|
|
56
64
|
isQuery = false, // 是否是查询条件
|
|
65
|
+
requestType = 'get', // 自定义弹窗时候的查询方式 如果是post 并且需要所有参数都放在body里 需要设置此参数 && 兼容之前逻辑
|
|
57
66
|
} = rCTemp || {};
|
|
58
67
|
const requestConfig = {url,method,otherParams,isMap,fixedparameter,fieldValToParam,fixedparamsDisabled,mappingTextField,mappingTextShowKeyField,mappingValueField,mappingTextShowTextField,init,extralHeaders,specialBracket,noNeedSplit,noOperate,viewShowValueStr,searchStartLength,...rCTemp};
|
|
59
68
|
const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || ctx?.name || 'supplierCode')
|
|
@@ -61,11 +70,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
61
70
|
const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
|
|
62
71
|
const initVal = value || (selectMode ? [] : null);
|
|
63
72
|
const pageSize = 100 // 下拉框默认分页 条数
|
|
64
|
-
const tableInitPageSize =
|
|
73
|
+
const tableInitPageSize = SEARCH_SELECT_MODAL_DEFAULT_PAGE_SIZE // 弹框默认分页 条数
|
|
65
74
|
const currentPage = 1
|
|
66
75
|
const selectParamsKey = requestConfig?.filter || 'qp-codeAndName-like'
|
|
67
76
|
const selectParamsInitKey = requestConfig?.filterInit || selectParamsKey
|
|
68
77
|
const currentSelectProps = {
|
|
78
|
+
// 回显字段可自定义
|
|
79
|
+
optionLabelProp: "label",
|
|
69
80
|
...selectProps,
|
|
70
81
|
// 以下属性不可更改----设计配置项
|
|
71
82
|
showArrow: true,
|
|
@@ -73,7 +84,6 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
73
84
|
filterOption: false,
|
|
74
85
|
allowClear: true,
|
|
75
86
|
listHeight: 160,
|
|
76
|
-
optionLabelProp: "label",
|
|
77
87
|
autoClearSearchValue: false,
|
|
78
88
|
placement: 'bottomRight'
|
|
79
89
|
}
|
|
@@ -83,7 +93,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
83
93
|
const isFormPage = pathname.match(pattern)?.length > 0;
|
|
84
94
|
|
|
85
95
|
const initPagination = { showQuickJumper: true, showSizeChanger: true, showTotal: (total: any) => `共 ${total} 条`, pageSize: tableInitPageSize }
|
|
86
|
-
const tableInitPagination = { ...initPagination, total: 0, current: 1 }
|
|
96
|
+
const tableInitPagination = { ...initPagination, total: 0, current: 1, pageSizeOptions: SEARCH_SELECT_MODAL_PAGE_SIZE_OPTIONS }
|
|
87
97
|
const disabled = !!noOperate || selectProps?.disabled || props?.disabled;
|
|
88
98
|
const isHaveDependency = fixedparameter && fieldValToParam && ctx;
|
|
89
99
|
const isHaveDValue = () => {
|
|
@@ -239,7 +249,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
239
249
|
let getRequest;
|
|
240
250
|
const methodName = method?.toLocaleLowerCase?.();
|
|
241
251
|
if(['post','patch','put'].includes(methodName)) {
|
|
242
|
-
|
|
252
|
+
let bodyData = convertBodyParams(queryParams);
|
|
253
|
+
let urlStr = convertUrlQueryParams(queryParams);
|
|
254
|
+
|
|
255
|
+
// Fix: support sending params in body
|
|
256
|
+
if(requestConfig.isBodyRequest) {
|
|
257
|
+
if(!bodyData) {
|
|
258
|
+
bodyData = convertQueryParams(queryParams);
|
|
259
|
+
}
|
|
260
|
+
urlStr = '';
|
|
261
|
+
}
|
|
262
|
+
getRequest = request[methodName](`${url}${urlStr}`,bodyData, { headers: { ...extralHeaders }})
|
|
243
263
|
} else {
|
|
244
264
|
getRequest = request.get( `${url}${convertUrlQueryParams(queryParams)}`,{headers: { ...extralHeaders }})
|
|
245
265
|
}
|
|
@@ -360,19 +380,46 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
360
380
|
};
|
|
361
381
|
},[isModalVisible])
|
|
362
382
|
|
|
383
|
+
const safeJSONParse = (str: string) => {
|
|
384
|
+
try {
|
|
385
|
+
return JSON.parse(str);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
console.warn('JSON解析失败:', error);
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// 获取回显的value值 如果开启了搜索条件 则需要过滤掉搜索条件
|
|
393
|
+
const getShowValue = (value: any) => {
|
|
394
|
+
let newValue = cloneDeep(value);
|
|
395
|
+
if(selectProps.useSearchCondition && newValue) {
|
|
396
|
+
// 回显的时候 把搜索项的内容去掉
|
|
397
|
+
if(selectMode) {
|
|
398
|
+
newValue = newValue.filter((item: any) => {
|
|
399
|
+
const parsedItem = safeJSONParse(decodeURIComponent(item));
|
|
400
|
+
// 过滤掉JSON对象(搜索条件),保留非JSON数据(实际选择项)
|
|
401
|
+
return !parsedItem || !(parsedItem && typeof parsedItem === 'object' && !Array.isArray(parsedItem));
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return newValue;
|
|
406
|
+
}
|
|
363
407
|
const showModal = () => {
|
|
364
408
|
if(sDisabled) return;
|
|
365
|
-
|
|
409
|
+
|
|
410
|
+
const cachedPageSize = getSearchSelectModalPageSize();
|
|
366
411
|
setSelectOpen(false)
|
|
367
412
|
setSearchValue('');
|
|
368
413
|
setModalSearched(false);
|
|
414
|
+
setTablePagination({ ...tableInitPagination, pageSize: cachedPageSize, current: 1 });
|
|
369
415
|
|
|
370
416
|
setIsModalVisible(true);
|
|
371
417
|
// 回显
|
|
372
418
|
if (value) {
|
|
373
419
|
if (selectMode) {
|
|
374
|
-
|
|
375
|
-
|
|
420
|
+
const newValue = getShowValue(value);
|
|
421
|
+
setSelectedRowKeys(labelInValue ? newValue.map(i => i.key) : newValue)
|
|
422
|
+
setSelectedRows(labelInValue ? newValue.map(i => ({ [mappingValueField]: i.key, value: i.key, text: i.label })) : newValue.map(i => ({ [mappingValueField]: i, value: i })))
|
|
376
423
|
setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
|
|
377
424
|
setIndeterminate(!!value.length && value.length < itemsTotal);
|
|
378
425
|
setCheckedAll(itemsTotal && value.length === itemsTotal);
|
|
@@ -393,8 +440,25 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
393
440
|
setSelectDataSource(source,source?.length)
|
|
394
441
|
formaData(selectedValue, source);
|
|
395
442
|
} else {
|
|
396
|
-
|
|
397
|
-
|
|
443
|
+
var formatResult = selectMode ? [] : null;
|
|
444
|
+
// 支持使用查询条件 筛选
|
|
445
|
+
if (selectProps.useSearchCondition) {
|
|
446
|
+
var formValue = form.getFieldsValue();
|
|
447
|
+
// 一次性处理数据转换和过滤
|
|
448
|
+
var processedFormValue = Object.keys(formValue).reduce(function (acc, key) {
|
|
449
|
+
var value = formValue[key];
|
|
450
|
+
// 过滤空值(确保trim函数存在)
|
|
451
|
+
var trimmedValue = typeof value === 'string' ? value.trim() : value;
|
|
452
|
+
if (trimmedValue && trimmedValue !== '') {
|
|
453
|
+
acc[key] = trimmedValue;
|
|
454
|
+
}
|
|
455
|
+
return acc;
|
|
456
|
+
}, {});
|
|
457
|
+
const result = JSON.stringify(processedFormValue)
|
|
458
|
+
onChange(isEmpty(processedFormValue) ? formatResult : selectMode ? [result] : result, selectedValue);
|
|
459
|
+
} else {
|
|
460
|
+
onChange(formatResult, selectedValue);
|
|
461
|
+
}
|
|
398
462
|
}
|
|
399
463
|
}
|
|
400
464
|
const handleOk = () => {
|
|
@@ -424,14 +488,15 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
424
488
|
setConfirmLoading(false)
|
|
425
489
|
})
|
|
426
490
|
} else {
|
|
427
|
-
handleSelectOver(popvalue)
|
|
491
|
+
handleSelectOver(selectedRows.length ? popvalue : [])
|
|
428
492
|
handleCancel();
|
|
429
493
|
}
|
|
430
494
|
};
|
|
431
495
|
|
|
432
496
|
const formaData = (value: any, source: any) => {
|
|
433
497
|
if (labelInValue) {
|
|
434
|
-
const
|
|
498
|
+
const getFromat = (format, val) => format.map(({key,value})=> ({[key]:val[value]}))
|
|
499
|
+
const formatResult = value.map((i: any) => (Object.assign({ key: i[mappingValueField] || i.key, label: i[mappingTextField] || i.label, value: i[mappingValueField] || i.value }, ...getFromat(returnFormat, i))))
|
|
435
500
|
onChange(selectMode ? formatResult : formatResult[0], value,source)
|
|
436
501
|
} else {
|
|
437
502
|
const formatResult = selectMode ? value.map((i: any) => i.value) : _.get(value[0], 'value')
|
|
@@ -476,15 +541,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
476
541
|
|
|
477
542
|
const onSearchTable = () => {
|
|
478
543
|
const params = form.getFieldsValue();
|
|
544
|
+
const pageSize = normalizeSearchSelectModalPageSize(tablePagination?.pageSize);
|
|
479
545
|
setModalSearched(true);
|
|
480
546
|
setTableFormParams(params);
|
|
481
|
-
getData({ ...params, pageSize:
|
|
547
|
+
getData({ ...params, pageSize, currentPage: 1 }, 2, null);
|
|
482
548
|
}
|
|
483
549
|
|
|
484
550
|
const onResetTable = () => {
|
|
551
|
+
const pageSize = normalizeSearchSelectModalPageSize(tablePagination?.pageSize);
|
|
485
552
|
form.resetFields();
|
|
486
553
|
setTableFormParams({});
|
|
487
|
-
getData({ pageSize
|
|
554
|
+
getData({ pageSize, currentPage: 1 }, 2)
|
|
488
555
|
}
|
|
489
556
|
|
|
490
557
|
const toggleCollapsed = () => {
|
|
@@ -492,7 +559,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
492
559
|
};
|
|
493
560
|
|
|
494
561
|
const handleTableChange = (pagination) => {
|
|
495
|
-
|
|
562
|
+
const pageSize = normalizeSearchSelectModalPageSize(pagination.pageSize);
|
|
563
|
+
setSearchSelectModalPageSize(pageSize);
|
|
564
|
+
getData({ ...tableFormParams, pageSize, currentPage: pagination.current }, 2)
|
|
496
565
|
}
|
|
497
566
|
|
|
498
567
|
// 扁平化二维数组的方法
|
|
@@ -931,7 +1000,20 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
931
1000
|
footer={
|
|
932
1001
|
selectMode || modalTableProps?.modalRadioNeedFooter
|
|
933
1002
|
? [
|
|
934
|
-
|
|
1003
|
+
selectProps.useSearchCondition ? (
|
|
1004
|
+
<div
|
|
1005
|
+
key="instructions"
|
|
1006
|
+
style={{
|
|
1007
|
+
position: 'absolute',
|
|
1008
|
+
width: 'calc(100% - 500px)',
|
|
1009
|
+
textAlign: 'left'
|
|
1010
|
+
}}
|
|
1011
|
+
>
|
|
1012
|
+
<div>操作说明:结果集过多时,可无需选择具体数据,系统将直接按已设筛选条件查询</div>
|
|
1013
|
+
<Input style={{marginTop: '3px', height: '22px'}} value={value} />
|
|
1014
|
+
</div>
|
|
1015
|
+
) : <></>,
|
|
1016
|
+
<Button key="back" onClick={handleCancel} style={{margin: selectProps.useSearchCondition ? '10px 0' : 0}}>
|
|
935
1017
|
取消
|
|
936
1018
|
</Button>,
|
|
937
1019
|
<Button
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const SEARCH_SELECT_MODAL_DEFAULT_PAGE_SIZE = 100;
|
|
2
|
+
|
|
3
|
+
export const SEARCH_SELECT_MODAL_PAGE_SIZE_OPTIONS = [10, 20, 50, 100, 500, 1000];
|
|
4
|
+
|
|
5
|
+
export const SEARCH_SELECT_MODAL_PAGE_SIZE_CACHE_KEY = 'businessComponentSearchSelectPageSize';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 规范化选择器弹窗分页大小,缓存异常时统一回退到每页 100 条。
|
|
9
|
+
*
|
|
10
|
+
* @param pageSize 待校验的分页大小
|
|
11
|
+
* @returns 合法的分页大小
|
|
12
|
+
*/
|
|
13
|
+
export const normalizeSearchSelectModalPageSize = (pageSize: unknown): number => {
|
|
14
|
+
const normalizedPageSize = Number(pageSize);
|
|
15
|
+
return SEARCH_SELECT_MODAL_PAGE_SIZE_OPTIONS.includes(normalizedPageSize)
|
|
16
|
+
? normalizedPageSize
|
|
17
|
+
: SEARCH_SELECT_MODAL_DEFAULT_PAGE_SIZE;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 读取所有选择器弹窗共用的分页大小。
|
|
22
|
+
*
|
|
23
|
+
* @returns 缓存中的分页大小,无有效缓存时返回每页 100 条
|
|
24
|
+
*/
|
|
25
|
+
export const getSearchSelectModalPageSize = (): number => {
|
|
26
|
+
if (typeof window === 'undefined') {
|
|
27
|
+
return SEARCH_SELECT_MODAL_DEFAULT_PAGE_SIZE;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
return normalizeSearchSelectModalPageSize(
|
|
32
|
+
window.localStorage.getItem(SEARCH_SELECT_MODAL_PAGE_SIZE_CACHE_KEY),
|
|
33
|
+
);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return SEARCH_SELECT_MODAL_DEFAULT_PAGE_SIZE;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 保存所有选择器弹窗共用的分页大小。
|
|
41
|
+
*
|
|
42
|
+
* @param pageSize 用户选择的分页大小
|
|
43
|
+
*/
|
|
44
|
+
export const setSearchSelectModalPageSize = (pageSize: unknown): void => {
|
|
45
|
+
if (typeof window === 'undefined') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
window.localStorage.setItem(
|
|
51
|
+
SEARCH_SELECT_MODAL_PAGE_SIZE_CACHE_KEY,
|
|
52
|
+
String(normalizeSearchSelectModalPageSize(pageSize)),
|
|
53
|
+
);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
// 浏览器禁用本地缓存时保留当前分页行为,不阻断选择器使用。
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -42,7 +42,8 @@ export const hasMoreQueryFields = (modalTableProps: any) => {
|
|
|
42
42
|
}
|
|
43
43
|
export const getTableHeigth = (list: any) => {
|
|
44
44
|
const totalRows = Math.ceil((list?.length+1) / 4);
|
|
45
|
-
if(totalRows == 1) return 358; // modal弹窗760 调整为700 适应小屏
|
|
45
|
+
if(totalRows == 1) return 358; // modal弹窗760 调整为700 适应小屏
|
|
46
|
+
if(totalRows == 3) return 403; // modal弹窗760 调整为700 适应小屏
|
|
46
47
|
return 411 - totalRows*10
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -116,23 +117,25 @@ export const handleParams = (params: any) => {
|
|
|
116
117
|
delete params[key];
|
|
117
118
|
} else if (element && key.indexOf('*fullDate*') >= 0) {
|
|
118
119
|
const dataParams = key.split('*fullDate*');
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
if(params?.[key] && params?.[key]?.length) {
|
|
121
|
+
dataParams.forEach((value, index) => {
|
|
122
|
+
if (index === 0) {
|
|
123
|
+
params[value] = moment(element[index])
|
|
124
|
+
.millisecond(0)
|
|
125
|
+
.second(0)
|
|
126
|
+
.minute(0)
|
|
127
|
+
.hour(0)
|
|
128
|
+
.format('YYYY-MM-DD HH:mm:ss');
|
|
129
|
+
} else {
|
|
130
|
+
params[value] = moment(element[index])
|
|
131
|
+
.millisecond(59)
|
|
132
|
+
.second(59)
|
|
133
|
+
.minute(59)
|
|
134
|
+
.hour(23)
|
|
135
|
+
.format('YYYY-MM-DD HH:mm:ss');
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
136
139
|
delete params[key];
|
|
137
140
|
} else if (typeof element === 'boolean' && key.indexOf('*checkBox*') >= 0) {
|
|
138
141
|
const dataParams = key.split('*checkBox*');
|
|
@@ -233,6 +236,13 @@ export const convertBodyParams = (params: any) => {
|
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
// body参数来源:sku选择器固定参数 > 调用所传bodyParams > 默认参数-无
|
|
239
|
+
// post 方式参数 来源默认的bodyParams 以及原有搜索项的参数
|
|
240
|
+
if(params?.requestType && (params?.requestType?.toLocaleLowerCase() == 'post')) {
|
|
241
|
+
return omit({
|
|
242
|
+
...params?.bodyParams,
|
|
243
|
+
...params,
|
|
244
|
+
},['bodyParams', 'noUrlQueryParams', 'requestType']);
|
|
245
|
+
}
|
|
236
246
|
return unique_params || params?.bodyParams || null;
|
|
237
247
|
}
|
|
238
248
|
|
|
@@ -201,7 +201,8 @@ const TreeSearchSelect = (props: any) => {
|
|
|
201
201
|
showSearch={showSearch}
|
|
202
202
|
style={style}
|
|
203
203
|
value={value}
|
|
204
|
-
|
|
204
|
+
dropdownMatchSelectWidth={false}
|
|
205
|
+
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
|
205
206
|
treeData={treeData}
|
|
206
207
|
placeholder={placeholder}
|
|
207
208
|
allowClear={allowClear}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# RuleObjectComponent 规则组件
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
`RuleObjectComponent` 是一个功能强大的规则构建器组件,支持可视化的条件组合(并且/或者逻辑嵌套)、动态参数插入、执行动作配置以及返回值配置。它广泛应用于需要灵活定义业务规则的场景。
|
|
5
|
+
|
|
6
|
+
## 组件路径
|
|
7
|
+
`src/components/Solution/RuleComponent/index.js`
|
|
8
|
+
|
|
9
|
+
## Props 属性说明
|
|
10
|
+
|
|
11
|
+
| 属性名 | 类型 | 必填 | 说明 |
|
|
12
|
+
|Ref | --- | --- | --- |
|
|
13
|
+
| regularDataList | `Array` | 是 | 规则左侧“对象”选择树的数据源。 |
|
|
14
|
+
| operationList | `Array` | 是 | 规则中间“操作符”下拉列表的数据源。 |
|
|
15
|
+
| ruleClassData | `Array` | 是 | 规则组件的核心数据模型,用于回显和存储规则配置。 |
|
|
16
|
+
| callBack | `Function` | 是 | 数据变更时的回调函数,返回最新的 `ruleClassData`。 |
|
|
17
|
+
| systemVariableList | `Array` | 否 | “插入参数”功能的数据源,允许用户选择系统变量而非固定值。 |
|
|
18
|
+
| initialThresholdQuery | `Object` | 否 | 用于获取规则值域(右侧输入框/选择框)的初始查询参数。 |
|
|
19
|
+
| ruleGroupInfo | `Object` | 否 | 规则组信息,用于规则组实例场景。 |
|
|
20
|
+
| ruleTypeData | `Array` | 否 | “动作”配置的数据源。 |
|
|
21
|
+
| ruleReturnConfig | `Array` | 否 | “返回值”配置的数据源。 |
|
|
22
|
+
| disabled | `Boolean` | 否 | 是否禁用(只读模式)。 |
|
|
23
|
+
| canDelete | `Boolean` | 否 | 是否显示删除规则按钮。 |
|
|
24
|
+
| onlyOneRule | `Boolean` | 否 | 是否限制为单条规则(不显示新增规则按钮)。 |
|
|
25
|
+
| onlyCondition | `Boolean` | 否 | 是否仅展示条件部分(隐藏动作和返回值)。 |
|
|
26
|
+
| onlyAction | `Boolean` | 否 | 是否仅展示动作部分。 |
|
|
27
|
+
| needShowInsertSQL | `Boolean` | 否 | 是否显示“插入SQL”功能按钮。 |
|
|
28
|
+
| headerButtonComponentFun | `Function` | 否 | 自定义头部按钮渲染函数。 |
|
|
29
|
+
|
|
30
|
+
## 数据结构示例
|
|
31
|
+
|
|
32
|
+
### ruleClassData 结构
|
|
33
|
+
```json
|
|
34
|
+
[
|
|
35
|
+
{
|
|
36
|
+
"ruleName": "规则1",
|
|
37
|
+
"subExpression": [
|
|
38
|
+
{
|
|
39
|
+
"operationType": "logic", // logic 或 relation
|
|
40
|
+
"operationCode": "and", // logic时为 and/or
|
|
41
|
+
"subExpression": [ ... ] // 嵌套子条件
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"operationType": "relation",
|
|
45
|
+
"elementId": "...", // 左侧对象ID
|
|
46
|
+
"operationCode": "...", // 操作符
|
|
47
|
+
"params": ["..."], // 右侧值
|
|
48
|
+
// 新增参数条件控制
|
|
49
|
+
"isReqCondition": true,
|
|
50
|
+
"reqConditionData": {
|
|
51
|
+
"reqParamName": "param1",
|
|
52
|
+
"dataTypeCode": "21",
|
|
53
|
+
"operationCode": "eq",
|
|
54
|
+
"params": ["value"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"extraInfo": {
|
|
59
|
+
"execute": [], // 动作
|
|
60
|
+
"response": [] // 返回值
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 功能特性
|
|
67
|
+
1. **多层级逻辑嵌套**:支持无限层级的“并且/或者”逻辑组合。
|
|
68
|
+
2. **动态表单渲染**:根据选择的对象属性类型(`dataTypeCode`),自动渲染对应的输入组件(文本框、日期选择、业务选择器等)。
|
|
69
|
+
3. **参数插入**:支持将系统变量作为条件值。
|
|
70
|
+
4. **参数条件控制**:支持为特定条件配置请求参数名称、类型及校验规则。
|
|
71
|
+
5. **动作与返回值**:支持配置规则命中后的执行动作及返回值。
|
|
72
|
+
|
|
73
|
+
## 代码演示
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import React, { useState } from 'react';
|
|
77
|
+
import { RuleComponent } from '../../../index';
|
|
78
|
+
|
|
79
|
+
export default () => {
|
|
80
|
+
const [ruleClassData, setRuleClassData] = useState([]);
|
|
81
|
+
const [disabled, setDisabled] = useState(false);
|
|
82
|
+
|
|
83
|
+
// 模拟规则对象数据源
|
|
84
|
+
const regularDataList = [
|
|
85
|
+
{
|
|
86
|
+
id: 'user_info',
|
|
87
|
+
name: '用户信息',
|
|
88
|
+
code: 'user',
|
|
89
|
+
valueType: 'object',
|
|
90
|
+
propertyList: [
|
|
91
|
+
{ id: 'age', name: '年龄', code: 'age', valueType: '22', inputType: 11, choiceType: 10, },
|
|
92
|
+
{ id: 'name', name: '姓名', code: 'name', valueType: '21', inputType: 11, choiceType: 10, },
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'order_info',
|
|
97
|
+
name: '订单信息',
|
|
98
|
+
code: 'order',
|
|
99
|
+
valueType: 'object',
|
|
100
|
+
propertyList: [
|
|
101
|
+
{ id: 'amount', name: '金额', code: 'amount', valueType: '22', inputType: 11, choiceType: 10, },
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
// 模拟操作符数据源
|
|
107
|
+
const operationList = [
|
|
108
|
+
{
|
|
109
|
+
code: '21', // 字符串
|
|
110
|
+
operationList: [
|
|
111
|
+
{ code: 'eq', name: '等于' },
|
|
112
|
+
{ code: 'cn', name: '包含' },
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
code: '22', // 数值
|
|
117
|
+
operationList: [
|
|
118
|
+
{ code: 'eq', name: '等于' },
|
|
119
|
+
{ code: 'gt', name: '大于' },
|
|
120
|
+
{ code: 'lt', name: '小于' },
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
// 模拟系统变量
|
|
126
|
+
const systemVariableList = [
|
|
127
|
+
{ code: 'sys_uid', name: '当前用户ID' },
|
|
128
|
+
{ code: 'sys_time', name: '当前时间' },
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
const handleSave = () => {
|
|
132
|
+
console.log('保存规则数据:', JSON.stringify(ruleClassData, null, 2));
|
|
133
|
+
alert('规则数据已输出到控制台,请查看!');
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<div style={{ background: '#f0f2f5', padding: 20, width: '1200px' }}>
|
|
138
|
+
<div style={{ marginBottom: 16, textAlign: 'right' }}>
|
|
139
|
+
<button
|
|
140
|
+
onClick={() => setDisabled(!disabled)}
|
|
141
|
+
style={{
|
|
142
|
+
backgroundColor: '#faad14',
|
|
143
|
+
color: '#fff',
|
|
144
|
+
border: 'none',
|
|
145
|
+
padding: '6px 15px',
|
|
146
|
+
borderRadius: '2px',
|
|
147
|
+
cursor: 'pointer',
|
|
148
|
+
marginRight: '10px'
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{disabled ? '启用编辑' : '禁用编辑'}
|
|
152
|
+
</button>
|
|
153
|
+
<button
|
|
154
|
+
onClick={handleSave}
|
|
155
|
+
style={{
|
|
156
|
+
backgroundColor: '#1890ff',
|
|
157
|
+
color: '#fff',
|
|
158
|
+
border: 'none',
|
|
159
|
+
padding: '6px 15px',
|
|
160
|
+
borderRadius: '2px',
|
|
161
|
+
cursor: 'pointer'
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
保存规则
|
|
165
|
+
</button>
|
|
166
|
+
</div>
|
|
167
|
+
<RuleComponent
|
|
168
|
+
regularDataList={regularDataList}
|
|
169
|
+
operationList={operationList}
|
|
170
|
+
ruleClassData={ruleClassData}
|
|
171
|
+
needShowInsertSQL={true}
|
|
172
|
+
needShowReqCondition={true}
|
|
173
|
+
systemVariableList={systemVariableList}
|
|
174
|
+
disabled={disabled}
|
|
175
|
+
callBack={(newData) => {
|
|
176
|
+
console.log('Rule Changed:', newData);
|
|
177
|
+
setRuleClassData([...newData]);
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
<div style={{ marginTop: 20 }}>
|
|
181
|
+
<h4>当前规则数据:</h4>
|
|
182
|
+
<pre>{JSON.stringify(ruleClassData, null, 2)}</pre>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
```
|
|
@@ -589,7 +589,7 @@ export default function RenderCompItem(props:any){
|
|
|
589
589
|
null}
|
|
590
590
|
{/* 单选/多选 配送方式选择器 */}
|
|
591
591
|
{((ites?.inputType === 20 || ites?.inputType === 30) &&
|
|
592
|
-
ites?.choiceType === 310 && (
|
|
592
|
+
(ites?.choiceType === 310 || ites?.choiceType === 311)&& (
|
|
593
593
|
<BusinessSearchSelect
|
|
594
594
|
selectBusinessType="deliveryMode"
|
|
595
595
|
selectProps={{
|
|
@@ -606,6 +606,14 @@ export default function RenderCompItem(props:any){
|
|
|
606
606
|
labelInValue={true}
|
|
607
607
|
value={showValue(ites.code)}
|
|
608
608
|
requestConfig={{
|
|
609
|
+
...(ites?.choiceType === 311
|
|
610
|
+
? {
|
|
611
|
+
otherParams: {
|
|
612
|
+
// 配送方式只选择标准配送方式
|
|
613
|
+
'qp-recordChannnelCode-eq': 80,
|
|
614
|
+
},
|
|
615
|
+
}
|
|
616
|
+
: {}),
|
|
609
617
|
filterInit: 'qp-code-in',
|
|
610
618
|
}}
|
|
611
619
|
onChange={(value) => {
|