@bit-sun/business-component 2.2.49 → 2.3.0-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/common/ENUM.d.ts +40 -0
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +2 -2
- package/dist/components/Business/SearchSelect/common.d.ts +9 -1
- package/dist/components/Business/TreeSearchSelect/utils.d.ts +3 -1
- package/dist/components/Functional/AddSelect/helps.d.ts +13 -0
- package/dist/components/Functional/BsAntdSula/BsCascader/index.d.ts +18 -0
- package/dist/components/Functional/BsAntdSula/index.d.ts +1 -0
- package/dist/components/Solution/RuleComponent/Formula.d.ts +8 -0
- package/dist/components/Solution/RuleComponent/services.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +10842 -11311
- package/dist/index.js +10803 -11268
- package/dist/utils/LocalstorageUtils.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/utils.d.ts +7 -0
- package/package.json +2 -1
- package/src/common/ENUM.ts +41 -0
- package/src/components/Business/AddSelectBusiness/index.md +1 -0
- package/src/components/Business/AddSelectBusiness/index.tsx +375 -176
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +1 -1
- package/src/components/Business/BsSulaQueryTable/index.tsx +20 -12
- package/src/components/Business/BsSulaQueryTable/setting.tsx +36 -16
- package/src/components/Business/BsSulaQueryTable/utils.tsx +31 -29
- package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +4 -0
- package/src/components/Business/JsonQueryTable/index.tsx +248 -33
- package/src/components/Business/JsonQueryTable/static.ts +5 -5
- package/src/components/Business/SearchSelect/BusinessUtils.ts +37 -7
- package/src/components/Business/SearchSelect/common.ts +23 -1
- package/src/components/Business/SearchSelect/index.md +12 -2
- package/src/components/Business/SearchSelect/index.tsx +5 -2
- package/src/components/Business/TreeSearchSelect/index.md +2 -0
- package/src/components/Business/TreeSearchSelect/index.tsx +1 -2
- package/src/components/Business/TreeSearchSelect/utils.ts +7 -1
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +1 -1
- package/src/components/Business/columnSettingTable/utils.tsx +30 -28
- package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +1 -0
- package/src/components/Business/moreTreeTable/index.md +2 -2
- package/src/components/Business/moreTreeTable/index.tsx +24 -17
- package/src/components/Functional/AddSelect/helps.ts +65 -0
- package/src/components/Functional/AddSelect/index.tsx +13 -122
- package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -0
- package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -0
- package/src/components/Functional/BsAntdSula/index.ts +2 -0
- package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -0
- package/src/components/Functional/EllipsisTooltip/index.js +36 -0
- package/src/components/Functional/EllipsisTooltip/index.md +30 -0
- package/src/components/Functional/SearchSelect/index.tsx +93 -59
- package/src/components/Functional/TreeSearchSelect/index.tsx +44 -7
- package/src/components/Solution/RuleComponent/Formula.tsx +335 -0
- package/src/components/Solution/RuleComponent/index.d.ts +29 -0
- package/src/components/Solution/RuleComponent/index.js +2032 -0
- package/src/components/Solution/RuleComponent/index.less +230 -0
- package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -0
- package/src/components/Solution/RuleComponent/ruleFiled.js +2107 -0
- package/src/components/Solution/RuleComponent/services.ts +13 -0
- package/src/components/Solution/RuleComponent/util.js +139 -0
- package/src/index.ts +4 -0
- package/src/utils/LocalstorageUtils.ts +5 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +29 -0
|
@@ -15,25 +15,7 @@ import { setInitialShowColumn } from '@/plugin/TableColumnSetting/utils';
|
|
|
15
15
|
import { handleAntdColumnsSpecialParams, uuid } from '@/utils/utils';
|
|
16
16
|
import { getItemDefaultWidth, noEmptyArray } from '@/components/Business/columnSettingTable/utils';
|
|
17
17
|
import { getEmployeeId } from '@/utils/LocalstorageUtils';
|
|
18
|
-
import { getSelectDataList } from './helps';
|
|
19
|
-
|
|
20
|
-
const loadSelectSource = (url: string, params?: any) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
axios
|
|
23
|
-
.get(`${url}?${stringify(params)}`)
|
|
24
|
-
.then((result: any) => {
|
|
25
|
-
result = result.data;
|
|
26
|
-
if ((result?.status && result.status !== '0') || (result?.code && result.code !== '000000')) {
|
|
27
|
-
message.error(result.msg);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
resolve(result);
|
|
31
|
-
})
|
|
32
|
-
.catch((err) => {
|
|
33
|
-
reject(err);
|
|
34
|
-
});
|
|
35
|
-
})
|
|
36
|
-
};
|
|
18
|
+
import { getSelectDataList, loadSelectSource, formatFormSourceList } from './helps';
|
|
37
19
|
|
|
38
20
|
const checkSpuMatchCode = (data: any) => {
|
|
39
21
|
return new Promise((resolve, reject) => {
|
|
@@ -71,36 +53,6 @@ const ResizeableTitle = (props) => {
|
|
|
71
53
|
);
|
|
72
54
|
};
|
|
73
55
|
|
|
74
|
-
const formatSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['code', 'name']) => {
|
|
75
|
-
const data = reData && reData[position]?.data;
|
|
76
|
-
const list = Array.isArray(data) ? data :(data?.items || data?.list || data?.children || []);
|
|
77
|
-
const formatData = list?.length ? list.map((v: any) => ({ text: v[resKeyValue[1]], value: v[resKeyValue[0]] })) : [];
|
|
78
|
-
changeSearchForm[changePosition] = {...changeSearchForm[changePosition], initialSource: formatData}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// 格式化树选择器数据源
|
|
82
|
-
const mapSearchTree = (treeDataItem: any, resKeyValue: any) => {
|
|
83
|
-
const haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
|
|
84
|
-
return {
|
|
85
|
-
title: treeDataItem[resKeyValue[1]],
|
|
86
|
-
value: treeDataItem[resKeyValue[0]],
|
|
87
|
-
parentId: treeDataItem.parent,
|
|
88
|
-
data: { ...treeDataItem },
|
|
89
|
-
isLeaf: !haveChildren,
|
|
90
|
-
disabled: haveChildren,
|
|
91
|
-
children: haveChildren ? treeDataItem.children.map((i: any) => mapSearchTree(i, resKeyValue)) : [],
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
const formatTreeDataSource = (reData: any, position: number, changePosition: number,changeSearchForm: any,resKeyValue=['id', 'name']) => {
|
|
95
|
-
const data = reData && reData[position]?.data;
|
|
96
|
-
const formatData = (data &&
|
|
97
|
-
Array.isArray(data) &&
|
|
98
|
-
data.length &&
|
|
99
|
-
data.map((ites: any) => mapSearchTree(ites, resKeyValue))) ||
|
|
100
|
-
[]
|
|
101
|
-
changeSearchForm[changePosition].field.props.treeData = formatData;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
56
|
const initTableCode = {
|
|
105
57
|
'sku': ['skuSelect-tableOptionsToChoosePartCode','skuSelect-tableSelectedItemPartCode'],
|
|
106
58
|
'skc': ['skcSelect-tableOptionsToChoosePartCode','skcSelect-tableSelectedItemPartCode'],
|
|
@@ -127,7 +79,8 @@ const AddSelect = (props: any) => {
|
|
|
127
79
|
beforeShowModal,
|
|
128
80
|
tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
|
|
129
81
|
businessType = 'sku',
|
|
130
|
-
isAllowRepeatedSelect = false
|
|
82
|
+
isAllowRepeatedSelect = false,
|
|
83
|
+
|
|
131
84
|
} = props;
|
|
132
85
|
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField = 'name', mappingTextShowKeyField, mappingValueField = 'code', mappingTextShowTextField } = requestConfig || {};
|
|
133
86
|
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
@@ -665,76 +618,14 @@ const AddSelect = (props: any) => {
|
|
|
665
618
|
}
|
|
666
619
|
|
|
667
620
|
useEffect(() => {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
pageSize: 5000,
|
|
677
|
-
currentPage: 1,
|
|
678
|
-
}),
|
|
679
|
-
]).then((x: any)=>{
|
|
680
|
-
formatSource(x,0, 2, tableSearchForm,['id','name'])
|
|
681
|
-
formatTreeDataSource(x,1, 3, tableSearchForm)
|
|
682
|
-
})
|
|
683
|
-
}
|
|
684
|
-
if(businessType == 'skc') {
|
|
685
|
-
Promise.all([
|
|
686
|
-
loadSelectSource(`/items/item/propertyValue/sizeBySkcConfig`, {
|
|
687
|
-
pageSize: 10000,
|
|
688
|
-
currentPage: 1,
|
|
689
|
-
type: 2, // 类型:1尺码;2颜色
|
|
690
|
-
}),
|
|
691
|
-
loadSelectSource(`/items/category/queryCategoryTree`, {
|
|
692
|
-
pageSize: 5000,
|
|
693
|
-
currentPage: 1,
|
|
694
|
-
}),
|
|
695
|
-
loadSelectSource(`/items/class/withProperty`, {
|
|
696
|
-
pageSize: 5000,
|
|
697
|
-
currentPage: 1,
|
|
698
|
-
}),
|
|
699
|
-
loadSelectSource(`/items/brand/queryBrandList`, {
|
|
700
|
-
pageSize: 5000,
|
|
701
|
-
currentPage: 1,
|
|
702
|
-
'ctl-withAuth': true
|
|
703
|
-
}),
|
|
704
|
-
]).then((x: any)=>{
|
|
705
|
-
formatSource(x,0, 3, tableSearchForm,['value','value'])
|
|
706
|
-
formatTreeDataSource(x,1, 4, tableSearchForm)
|
|
707
|
-
formatSource(x,2, 5, tableSearchForm,['id','name'])
|
|
708
|
-
formatSource(x,3, 6, tableSearchForm,['id','name'])
|
|
709
|
-
})
|
|
710
|
-
}
|
|
711
|
-
if(businessType == 'spu') {
|
|
712
|
-
Promise.all([
|
|
713
|
-
loadSelectSource(`/user/orgViewNode/listNoPage`, {
|
|
714
|
-
'qp-employeeId-eq': getEmployeeId(),
|
|
715
|
-
'qp-orgViewCode-eq': 'business-organizational-view',
|
|
716
|
-
'ctl-withDefaultOrg': true,
|
|
717
|
-
}),
|
|
718
|
-
loadSelectSource(`/items/brand/queryBrandList`, {
|
|
719
|
-
pageSize: 5000,
|
|
720
|
-
currentPage: 1,
|
|
721
|
-
'ctl-withAuth': true
|
|
722
|
-
}),
|
|
723
|
-
loadSelectSource(`/items/category/queryCategoryTree`, {
|
|
724
|
-
pageSize: 5000,
|
|
725
|
-
currentPage: 1,
|
|
726
|
-
}),
|
|
727
|
-
loadSelectSource(`/items/class/withProperty`, {
|
|
728
|
-
pageSize: 5000,
|
|
729
|
-
currentPage: 1,
|
|
730
|
-
}),
|
|
731
|
-
]).then((x: any)=>{
|
|
732
|
-
formatSource(x,0, 2, tableSearchForm,['targetId','name'])
|
|
733
|
-
formatSource(x,1, 3, tableSearchForm,['id','name'])
|
|
734
|
-
formatTreeDataSource(x,2, 4, tableSearchForm)
|
|
735
|
-
formatSource(x,3, 5, tableSearchForm,['id','name'])
|
|
736
|
-
})
|
|
737
|
-
}
|
|
621
|
+
const pList = modalTableProps?.promiseLoadList || []
|
|
622
|
+
if(!pList?.length) return;
|
|
623
|
+
const list = pList.map((i: any) => {
|
|
624
|
+
return loadSelectSource(i.url, i.params)
|
|
625
|
+
});
|
|
626
|
+
Promise.all(list).then((x: any)=>{
|
|
627
|
+
formatFormSourceList(x,pList,tableSearchForm)
|
|
628
|
+
})
|
|
738
629
|
}, [businessType])
|
|
739
630
|
|
|
740
631
|
useEffect(() => {
|
|
@@ -1048,8 +939,8 @@ const AddSelect = (props: any) => {
|
|
|
1048
939
|
setPopValue(popvalue.filter(item => item.uuid !== record.uuid))
|
|
1049
940
|
setSelectedRowKeys([])
|
|
1050
941
|
} else {
|
|
1051
|
-
setPopValue(popvalue.filter(item => item
|
|
1052
|
-
setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record
|
|
942
|
+
setPopValue(popvalue.filter(item => item[selectRowKey] !== record[selectRowKey]))
|
|
943
|
+
setSelectedRowKeys([...selectedRowKeys.filter(item => item !== record[selectRowKey])])
|
|
1053
944
|
}
|
|
1054
945
|
}
|
|
1055
946
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
path: /components/functional
|
|
7
|
+
title: 功能组件
|
|
8
|
+
order: 0
|
|
9
|
+
title: 级联选择
|
|
10
|
+
order: 7
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## BsCascader
|
|
14
|
+
|
|
15
|
+
Demo:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import React, { useState } from 'react';
|
|
19
|
+
import { BsCascader } from '../../../../index';
|
|
20
|
+
import { request } from 'bssula';
|
|
21
|
+
|
|
22
|
+
export default () => {
|
|
23
|
+
const [value, setValue] = useState()
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<BsCascader
|
|
28
|
+
isAll={true}
|
|
29
|
+
needNameAndCode={true}
|
|
30
|
+
notChangeOnSelect={true}
|
|
31
|
+
initRequestSource={async () => {
|
|
32
|
+
return await request({
|
|
33
|
+
url: '/basic/bscArea/getBscAreaList?qp-level-eq=1&qp-pid-eq=100000',
|
|
34
|
+
method: 'get',
|
|
35
|
+
converter: ({ data }) => {
|
|
36
|
+
const handleData =
|
|
37
|
+
data && data[0]
|
|
38
|
+
? data?.map((item) => {
|
|
39
|
+
return {
|
|
40
|
+
text: item.name,
|
|
41
|
+
value: item.id,
|
|
42
|
+
level: item.level,
|
|
43
|
+
id: item.id,
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
: [];
|
|
47
|
+
return handleData;
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}}
|
|
51
|
+
value={value}
|
|
52
|
+
onChange={(value) => {
|
|
53
|
+
setValue(value);
|
|
54
|
+
}}
|
|
55
|
+
getPopupContainer={() => document.body}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
import { Cascader, message } from 'antd';
|
|
5
|
+
import type { CascaderProps as ACascaderProps } from 'antd/lib/cascader';
|
|
6
|
+
import { request } from 'bssula';
|
|
7
|
+
|
|
8
|
+
export type CascaderSourceItem = {
|
|
9
|
+
text: any;
|
|
10
|
+
value: any;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface CascaderSource {
|
|
14
|
+
text: any;
|
|
15
|
+
value: any;
|
|
16
|
+
children: CascaderSourceItem[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CascaderProps extends ACascaderProps {
|
|
20
|
+
source: CascaderSource[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const BsCascader = ({
|
|
24
|
+
source,
|
|
25
|
+
onChange,
|
|
26
|
+
value,
|
|
27
|
+
disabled,
|
|
28
|
+
needNameAndCode,
|
|
29
|
+
onlyCode,
|
|
30
|
+
requiredLength,
|
|
31
|
+
isAll,
|
|
32
|
+
notChangeOnSelect,
|
|
33
|
+
isFirstOnly,
|
|
34
|
+
initRequestSource,
|
|
35
|
+
style,
|
|
36
|
+
}: {
|
|
37
|
+
source: any;
|
|
38
|
+
onChange: Function;
|
|
39
|
+
}) => {
|
|
40
|
+
if (!source && !initRequestSource) return null;
|
|
41
|
+
|
|
42
|
+
const [handSource, setHandSource] = useState(
|
|
43
|
+
source?.map((item) => ({ ...item, label: item.text, isLeaf: false })) || [],
|
|
44
|
+
);
|
|
45
|
+
useEffect(async () => {
|
|
46
|
+
if (!source && initRequestSource) {
|
|
47
|
+
const resData = await initRequestSource();
|
|
48
|
+
const data =
|
|
49
|
+
resData?.map((item) => ({
|
|
50
|
+
...item,
|
|
51
|
+
label: item.text,
|
|
52
|
+
isLeaf: false,
|
|
53
|
+
})) || [];
|
|
54
|
+
setHandSource(data);
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setHandSource(
|
|
60
|
+
source?.map((item) => ({ ...item, label: item.text, isLeaf: false })) ||
|
|
61
|
+
[],
|
|
62
|
+
);
|
|
63
|
+
}, [source]);
|
|
64
|
+
|
|
65
|
+
const [valueSource, setValueSource] = useState([]);
|
|
66
|
+
const [options, setOptions] = React.useState(handSource);
|
|
67
|
+
if (options && handSource && options.length != handSource.length) {
|
|
68
|
+
setOptions(handSource);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (value && onlyCode) {
|
|
73
|
+
if (value?.length) {
|
|
74
|
+
request({
|
|
75
|
+
url: `/basic/bscArea/getBscAreaList?qp-code-in=${value}`,
|
|
76
|
+
method: 'get',
|
|
77
|
+
}).then((res) => {
|
|
78
|
+
res = res.sort((a, b) => {
|
|
79
|
+
return a.level - b.level;
|
|
80
|
+
});
|
|
81
|
+
setValueSource(res);
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
setValueSource([]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, [value]);
|
|
88
|
+
|
|
89
|
+
const onChangeInner = (value: string, selectedOptions: any[]) => {
|
|
90
|
+
if (requiredLength && value.length !== requiredLength) return;
|
|
91
|
+
if (needNameAndCode) {
|
|
92
|
+
onChange({
|
|
93
|
+
PCDName: selectedOptions
|
|
94
|
+
? selectedOptions.map((item) => item.text)
|
|
95
|
+
: [],
|
|
96
|
+
PCDCode: selectedOptions
|
|
97
|
+
? selectedOptions.map((item) => item.value)
|
|
98
|
+
: [],
|
|
99
|
+
});
|
|
100
|
+
} else if (onlyCode) {
|
|
101
|
+
onChange(
|
|
102
|
+
selectedOptions ? selectedOptions.map((item) => item.value) : [],
|
|
103
|
+
);
|
|
104
|
+
} else {
|
|
105
|
+
onChange(selectedOptions ? selectedOptions.map((item) => item.text) : []);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const loadData = (selectedOptions) => {
|
|
110
|
+
const targetOption = selectedOptions[selectedOptions.length - 1];
|
|
111
|
+
targetOption.loading = true;
|
|
112
|
+
request({
|
|
113
|
+
url: `/basic/bscArea/getBscAreaList?qp-pid-eq=${targetOption.id}`,
|
|
114
|
+
method: 'get',
|
|
115
|
+
converter: ({ data }) => {
|
|
116
|
+
const initialVal = data
|
|
117
|
+
? data.map((item) => {
|
|
118
|
+
return {
|
|
119
|
+
text: item.name,
|
|
120
|
+
value: item.id,
|
|
121
|
+
label: item.name,
|
|
122
|
+
level: item.level,
|
|
123
|
+
isLeaf: item.level > (isAll ? 2 : 1),
|
|
124
|
+
id: item.id,
|
|
125
|
+
};
|
|
126
|
+
})
|
|
127
|
+
: [];
|
|
128
|
+
return initialVal;
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
.then((res) => {
|
|
132
|
+
targetOption.loading = false;
|
|
133
|
+
if (res.length) {
|
|
134
|
+
targetOption.children = res;
|
|
135
|
+
} else {
|
|
136
|
+
targetOption.children = undefined;
|
|
137
|
+
}
|
|
138
|
+
setOptions([...options]);
|
|
139
|
+
})
|
|
140
|
+
.catch((err: any) => {
|
|
141
|
+
message.error('网络错误');
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const filter = (inputValue, path) => {
|
|
146
|
+
return path.some(
|
|
147
|
+
(option) =>
|
|
148
|
+
option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
let CascaderVal = value;
|
|
153
|
+
if (needNameAndCode) {
|
|
154
|
+
CascaderVal = value ? value.PCDName : value;
|
|
155
|
+
} else if (onlyCode) {
|
|
156
|
+
CascaderVal = valueSource?.map((item) => item.name)?.join() || [];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const showSearch = !!(options.length && options.length > 5);
|
|
160
|
+
|
|
161
|
+
if (disabled) return CascaderVal;
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Cascader
|
|
165
|
+
key={1}
|
|
166
|
+
style={style}
|
|
167
|
+
disabled={disabled}
|
|
168
|
+
value={CascaderVal}
|
|
169
|
+
options={options}
|
|
170
|
+
loadData={loadData}
|
|
171
|
+
onChange={onChangeInner}
|
|
172
|
+
showSearch={showSearch ? filter : false}
|
|
173
|
+
changeOnSelect={!notChangeOnSelect}
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default BsCascader;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip } from 'antd';
|
|
3
|
+
|
|
4
|
+
class EllipsisTooltip extends React.Component {
|
|
5
|
+
state = {
|
|
6
|
+
visible: false,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
handleVisibleChange = (visible) => {
|
|
10
|
+
if (this.props.title.length > this.props.maxLength) {
|
|
11
|
+
this.setState({
|
|
12
|
+
visible,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
const style = {
|
|
19
|
+
...this.props.style,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Tooltip
|
|
24
|
+
visible={this.state.visible}
|
|
25
|
+
onVisibleChange={this.handleVisibleChange}
|
|
26
|
+
title={this.props.title}
|
|
27
|
+
>
|
|
28
|
+
<div className="customEllipse" style={style}>
|
|
29
|
+
{this.props.showInfo && this.props.showInfo ||
|
|
30
|
+
(this.props.title.length > this.props.maxLength ? `${this.props.title.substring(0, this.props.maxLength)}...` : this.props.title)}
|
|
31
|
+
</div>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export default EllipsisTooltip;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 功能组件
|
|
7
|
+
order: 0
|
|
8
|
+
title: 字符超长处理组件
|
|
9
|
+
order: 6
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## EllipsisTooltip
|
|
13
|
+
|
|
14
|
+
字符超长处理组件
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useRef } from 'react';
|
|
18
|
+
import { EllipsisTooltip } from '../../../index';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<EllipsisTooltip maxLength={10} title={'一二三四五六七八九十十一十二十三'} />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
More skills for writing demo: https://d.umijs.org/guide/demo-principle
|