@bit-sun/business-component 4.0.12-alpha.21 → 4.0.12-alpha.22
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/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/Functional/QueryMutipleInput/index.d.ts +4 -1
- package/dist/components/Functional/SearchSelect/index.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +709 -124
- package/dist/index.js +705 -119
- package/package.json +1 -1
- 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 +266 -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 +5 -1
- package/src/components/Functional/QueryMutipleInput/index.tsx +22 -4
- package/src/components/Functional/SearchSelect/index.tsx +151 -5
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
.property_classify_content {
|
|
2
|
+
margin-bottom: 15px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.property_classify_content1 {
|
|
6
|
+
max-height: 350px;
|
|
7
|
+
overflow-y: scroll;
|
|
8
|
+
overflow-x: hidden;
|
|
9
|
+
}
|
|
10
|
+
//滚动条
|
|
11
|
+
/* 滚动槽(轨道)宽高 */
|
|
12
|
+
.property_classify_content1::-webkit-scrollbar {
|
|
13
|
+
width: 5px; /*对垂直流动条有效*/
|
|
14
|
+
height: 5px; /*对水平流动条有效*/
|
|
15
|
+
}
|
|
16
|
+
/* 滚动槽(轨道)样式 */
|
|
17
|
+
.property_classify_content1::-webkit-scrollbar-track {
|
|
18
|
+
background-color: #ffffff;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*定义滑块颜色、内阴影及圆角*/
|
|
23
|
+
.property_classify_content1::-webkit-scrollbar-thumb {
|
|
24
|
+
border-radius: 7px;
|
|
25
|
+
background-color: #CECECE;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*定义两端按钮的样式*/
|
|
29
|
+
.property_classify_content1::-webkit-scrollbar-button {
|
|
30
|
+
display: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.propertyGroup_container {
|
|
34
|
+
display: flex;
|
|
35
|
+
margin-bottom: 16px;
|
|
36
|
+
.propertyGroup_container_left {
|
|
37
|
+
width: 100px;
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
flex-grow: 0;
|
|
40
|
+
}
|
|
41
|
+
.propertyGroup_container_right {
|
|
42
|
+
width: 560px;
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
flex-grow: 0;
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
}
|
|
48
|
+
.ant-checkbox-wrapper + .ant-checkbox-wrapper {
|
|
49
|
+
margin-left: 0px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.propertyGroup_checkbox_container {
|
|
54
|
+
width: 80px;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
text-overflow: ellipsis;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav:
|
|
3
|
+
title: '组件'
|
|
4
|
+
order: 1
|
|
5
|
+
group:
|
|
6
|
+
title: 业务组件
|
|
7
|
+
order: 1
|
|
8
|
+
title: PropertySelector 属性选择器
|
|
9
|
+
order: 1
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# PropertySelector
|
|
13
|
+
|
|
14
|
+
## 属性选择器
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import React, { useState } from 'react';
|
|
18
|
+
import PropertySelector from './index.tsx';
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
|
|
22
|
+
const [value, setValue] = useState({});
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div style={{ width: '200px' }}>
|
|
26
|
+
<PropertySelector
|
|
27
|
+
value={value}
|
|
28
|
+
onChange={(value) => setValue(value)}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
```
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
|
+
import { Modal, Select, Tag } from "antd";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
import { MockPropertyList } from "./mockData";
|
|
5
|
+
import PropertyGroup from "./propertyGroup";
|
|
6
|
+
import { CaretUpOutlined, CaretDownOutlined, CaretUpFilled, CaretDownFilled } from '@ant-design/icons';
|
|
7
|
+
import request from '@/utils/request';
|
|
8
|
+
import { judgeIsRequestError } from "@/utils";
|
|
9
|
+
|
|
10
|
+
interface propertyValueType {
|
|
11
|
+
propertyName: string;
|
|
12
|
+
propertyCode: string;
|
|
13
|
+
isCommonUse?: Boolean | String;
|
|
14
|
+
detailList: Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
isCommonUse?: Boolean | String;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface valueType {
|
|
22
|
+
classifyCode: string;
|
|
23
|
+
classifyName: string;
|
|
24
|
+
propertyList: propertyValueType[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface PropertyGroupValueType {
|
|
28
|
+
propertyCode: string;
|
|
29
|
+
propertyName: string;
|
|
30
|
+
detailList: Array<{
|
|
31
|
+
name: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
const PropertySelector = ({
|
|
36
|
+
value,
|
|
37
|
+
onChange,
|
|
38
|
+
width,
|
|
39
|
+
...restProps
|
|
40
|
+
}: { value: valueType, onChange: any, width: string }
|
|
41
|
+
) => {
|
|
42
|
+
const settingValue = useRef<valueType>({
|
|
43
|
+
classifyCode: '',
|
|
44
|
+
classifyName: '',
|
|
45
|
+
propertyList: []
|
|
46
|
+
});
|
|
47
|
+
const [choosedValues, setChoosedValues] = useState<any[]>([]);
|
|
48
|
+
const [choosedClassify, setChoosedClassify] = useState('');
|
|
49
|
+
const [commonProperty, setCommonUseProperty] = useState<any[]>([]);
|
|
50
|
+
const [notCommonProperty, setNotCommonProperty] = useState<any[]>([]);
|
|
51
|
+
|
|
52
|
+
const [visible, setVisible] = useState(false);
|
|
53
|
+
const [showNotCommon, setShowNotCommon] = useState(false); // 是否展示非常用属性
|
|
54
|
+
const [classifyOptionList, setClassifyOptionList] = useState<any[]>([]);
|
|
55
|
+
const [listKey, setListKey] = useState('1');
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
request({
|
|
59
|
+
url: '/items/class/withProperty?pageSize=500¤tPage=1',
|
|
60
|
+
method: 'GET',
|
|
61
|
+
})
|
|
62
|
+
.then(({data}: any) => {
|
|
63
|
+
if (judgeIsRequestError(data)) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
const items = data.data?.items || [];
|
|
67
|
+
setClassifyOptionList(items.map((item: any) => ({
|
|
68
|
+
label: item.name,
|
|
69
|
+
value: item.id,
|
|
70
|
+
})))
|
|
71
|
+
})
|
|
72
|
+
}, [])
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!choosedClassify) return;
|
|
76
|
+
request({
|
|
77
|
+
url: `/items/classProperty/${choosedClassify}`,
|
|
78
|
+
method: 'GET',
|
|
79
|
+
})
|
|
80
|
+
.then(({data}: any) => {
|
|
81
|
+
if (judgeIsRequestError(data)) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const newArr = (data?.data || []).map((item: any) => {
|
|
86
|
+
return {
|
|
87
|
+
propertyCode: item.property.propertyCode,
|
|
88
|
+
propertyName: item.property.name,
|
|
89
|
+
propertyId: item.property.id,
|
|
90
|
+
isCommonUse: item.property.isCommonUse === 'commonUse',
|
|
91
|
+
detailList: item.propertyValueList.map((detail: any) => ({
|
|
92
|
+
name: detail.value,
|
|
93
|
+
value: detail.value,
|
|
94
|
+
isCommonUse: detail.isCommonUse === 'commonUse',
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
setCommonUseProperty(newArr.filter((item: any) => item.isCommonUse))
|
|
100
|
+
setNotCommonProperty(newArr.filter((item: any) => !item.isCommonUse))
|
|
101
|
+
setListKey(listKey === '1' ? '2' : '1');
|
|
102
|
+
})
|
|
103
|
+
}, [choosedClassify])
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
// 获取选中品类信息
|
|
108
|
+
setChoosedClassify(value?.classifyCode);
|
|
109
|
+
|
|
110
|
+
// 获取选中属性值展示
|
|
111
|
+
const choosedPropertyList = (value?.propertyList || []).map(item => (item.detailList || []).map(detail => detail.name)).flat();
|
|
112
|
+
if ((value?.propertyList || []).some(item => !item.isCommonUse)) {
|
|
113
|
+
setShowNotCommon(true);
|
|
114
|
+
}
|
|
115
|
+
setChoosedValues(choosedPropertyList);
|
|
116
|
+
settingValue.current = {...value};
|
|
117
|
+
}, [value])
|
|
118
|
+
|
|
119
|
+
// 关闭弹窗回传组件值
|
|
120
|
+
const handleConfirm = () => {
|
|
121
|
+
setVisible(false);
|
|
122
|
+
onChange(settingValue.current);
|
|
123
|
+
}
|
|
124
|
+
const onCancel = () => {
|
|
125
|
+
setVisible(false);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 获取选中属性值信息
|
|
129
|
+
const handleProperyItemChange = (value: PropertyGroupValueType) => {
|
|
130
|
+
const newDetailList = settingValue.current?.propertyList || [];
|
|
131
|
+
const itemIndex = newDetailList.findIndex((item: any) => item.propertyCode === value.propertyCode);
|
|
132
|
+
if (itemIndex !== -1) {
|
|
133
|
+
newDetailList[itemIndex] = value;
|
|
134
|
+
} else {
|
|
135
|
+
newDetailList.push(value);
|
|
136
|
+
}
|
|
137
|
+
settingValue.current = {
|
|
138
|
+
...settingValue.current,
|
|
139
|
+
propertyList: newDetailList.filter(item => item.detailList && item.detailList.length),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//修改品类值
|
|
144
|
+
const onClassifyChange = (value: string, option: any) => {
|
|
145
|
+
setChoosedClassify(value);
|
|
146
|
+
settingValue.current = {
|
|
147
|
+
classifyCode: value,
|
|
148
|
+
classifyName: option.children,
|
|
149
|
+
propertyList: [],
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const tagRender = (props: any) => {
|
|
154
|
+
const { label, value, closable, onClose } = props;
|
|
155
|
+
const onPreventMouseDown = (event: any) => {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
event.stopPropagation();
|
|
158
|
+
};
|
|
159
|
+
return (
|
|
160
|
+
<Tag
|
|
161
|
+
closable={false}
|
|
162
|
+
style={{ marginRight: 3, height: '20px', fontSize: '12px' }}
|
|
163
|
+
>
|
|
164
|
+
{label}
|
|
165
|
+
</Tag>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<div>
|
|
171
|
+
<Select
|
|
172
|
+
maxTagCount={1}
|
|
173
|
+
tagRender={tagRender}
|
|
174
|
+
{...restProps}
|
|
175
|
+
mode="multiple"
|
|
176
|
+
value={choosedValues}
|
|
177
|
+
onClick={() => {
|
|
178
|
+
setVisible(true)
|
|
179
|
+
}}
|
|
180
|
+
style={{ width: width || '100%' }}
|
|
181
|
+
open={false}
|
|
182
|
+
/>
|
|
183
|
+
<Modal
|
|
184
|
+
title="属性设置"
|
|
185
|
+
width={700}
|
|
186
|
+
open={visible}
|
|
187
|
+
onOk={handleConfirm}
|
|
188
|
+
destroyOnClose
|
|
189
|
+
onCancel={onCancel}
|
|
190
|
+
cancelText={'取消'}
|
|
191
|
+
okText={'确定'}
|
|
192
|
+
>
|
|
193
|
+
<div>
|
|
194
|
+
<div className={'property_classify_content'}>
|
|
195
|
+
<span style={{ marginRight: '10px' }}>品类模板</span>
|
|
196
|
+
<Select
|
|
197
|
+
style={{ width: '200px' }}
|
|
198
|
+
value={choosedClassify}
|
|
199
|
+
options={classifyOptionList}
|
|
200
|
+
onChange={(value, option) => {
|
|
201
|
+
onClassifyChange(value, option);
|
|
202
|
+
}}
|
|
203
|
+
/>
|
|
204
|
+
</div>
|
|
205
|
+
<div className={'property_classify_content1'} key={listKey}>
|
|
206
|
+
<div>
|
|
207
|
+
{
|
|
208
|
+
commonProperty.map(item => (
|
|
209
|
+
<PropertyGroup
|
|
210
|
+
modalVisilbe={visible}
|
|
211
|
+
itemValue={settingValue.current}
|
|
212
|
+
propertyData={item}
|
|
213
|
+
handleProperyItemChange={handleProperyItemChange}
|
|
214
|
+
/>
|
|
215
|
+
))
|
|
216
|
+
}
|
|
217
|
+
</div>
|
|
218
|
+
<div>
|
|
219
|
+
{
|
|
220
|
+
showNotCommon && notCommonProperty.map(item => (
|
|
221
|
+
<PropertyGroup
|
|
222
|
+
modalVisilbe={visible}
|
|
223
|
+
itemValue={settingValue.current}
|
|
224
|
+
propertyData={item}
|
|
225
|
+
handleProperyItemChange={handleProperyItemChange}
|
|
226
|
+
/>
|
|
227
|
+
))
|
|
228
|
+
}
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
{
|
|
232
|
+
!!notCommonProperty.length && (
|
|
233
|
+
<div>
|
|
234
|
+
<div
|
|
235
|
+
style={{ width: '50px', cursor: 'pointer', color: '#005cff', fontSize: '10px' }}
|
|
236
|
+
onClick={() => setShowNotCommon(!showNotCommon)}
|
|
237
|
+
>
|
|
238
|
+
{
|
|
239
|
+
showNotCommon && (
|
|
240
|
+
<>
|
|
241
|
+
<CaretUpOutlined />
|
|
242
|
+
收起
|
|
243
|
+
</>
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
{
|
|
247
|
+
!showNotCommon && (
|
|
248
|
+
<>
|
|
249
|
+
<CaretDownOutlined />
|
|
250
|
+
展开
|
|
251
|
+
</>
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
</Modal>
|
|
261
|
+
</div>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export default PropertySelector;
|
|
266
|
+
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export const MockPropertyList = [
|
|
2
|
+
{
|
|
3
|
+
propertyCode: 'year',
|
|
4
|
+
propertyName: '年份',
|
|
5
|
+
isCommonUse: true,
|
|
6
|
+
detailList: [
|
|
7
|
+
{
|
|
8
|
+
name: '2022',
|
|
9
|
+
value: '2022',
|
|
10
|
+
isCommonUse: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: '2023',
|
|
14
|
+
value: '2023',
|
|
15
|
+
isCommonUse: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: '2024',
|
|
19
|
+
value: '2024',
|
|
20
|
+
isCommonUse: true,
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
propertyCode: 'season',
|
|
26
|
+
propertyName: '季节',
|
|
27
|
+
isCommonUse: true,
|
|
28
|
+
detailList: [
|
|
29
|
+
{
|
|
30
|
+
name: '春',
|
|
31
|
+
value: '1',
|
|
32
|
+
isCommonUse: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: '夏',
|
|
36
|
+
value: '2',
|
|
37
|
+
isCommonUse: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: '秋',
|
|
41
|
+
value: '3',
|
|
42
|
+
isCommonUse: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: '冬',
|
|
46
|
+
value: '4',
|
|
47
|
+
isCommonUse: true,
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
propertyCode: 'color',
|
|
53
|
+
propertyName: '色号',
|
|
54
|
+
isCommonUse: true,
|
|
55
|
+
detailList: [
|
|
56
|
+
{
|
|
57
|
+
name: '赤',
|
|
58
|
+
value: '1',
|
|
59
|
+
isCommonUse: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: '橙',
|
|
63
|
+
value: '2',
|
|
64
|
+
isCommonUse: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: '红',
|
|
68
|
+
value: '3',
|
|
69
|
+
isCommonUse: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: '绿',
|
|
73
|
+
value: '4',
|
|
74
|
+
isCommonUse: true,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: '青',
|
|
78
|
+
value: '5',
|
|
79
|
+
isCommonUse: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: '蓝',
|
|
83
|
+
value: '6',
|
|
84
|
+
isCommonUse: true,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: '紫',
|
|
88
|
+
value: '7',
|
|
89
|
+
isCommonUse: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: '橘红',
|
|
93
|
+
value: '8',
|
|
94
|
+
isCommonUse: false,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: '天蓝',
|
|
98
|
+
value: '9',
|
|
99
|
+
isCommonUse: false,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: '银白',
|
|
103
|
+
value: '10',
|
|
104
|
+
isCommonUse: false,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: '紫',
|
|
108
|
+
value: '11',
|
|
109
|
+
isCommonUse: false,
|
|
110
|
+
},
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
propertyCode: 'brandCode',
|
|
115
|
+
propertyName: '品牌',
|
|
116
|
+
isCommonUse: false,
|
|
117
|
+
detailList: [
|
|
118
|
+
{
|
|
119
|
+
name: '品牌2',
|
|
120
|
+
value: '2',
|
|
121
|
+
isCommonUse: true,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: '品牌3',
|
|
125
|
+
value: '3',
|
|
126
|
+
isCommonUse: true,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: '品牌4',
|
|
130
|
+
value: '4',
|
|
131
|
+
isCommonUse: true,
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
propertyCode: 'size',
|
|
138
|
+
propertyName: '尺码',
|
|
139
|
+
isCommonUse: false,
|
|
140
|
+
detailList: [
|
|
141
|
+
{
|
|
142
|
+
name: 'M',
|
|
143
|
+
value: '2',
|
|
144
|
+
isCommonUse: true,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'L',
|
|
148
|
+
value: '3',
|
|
149
|
+
isCommonUse: true,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'XL',
|
|
153
|
+
value: '4',
|
|
154
|
+
isCommonUse: true,
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
]
|