@bit-sun/business-component 4.0.12-alpha.18 → 4.0.12-alpha.19
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/index.d.ts +1 -0
- package/dist/index.esm.js +979 -513
- package/dist/index.js +978 -511
- 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 +4 -1
- package/src/components/Functional/SearchSelect/index.tsx +23 -6
- package/src/index.ts +1 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Checkbox } from 'antd';
|
|
3
|
+
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons';
|
|
4
|
+
import './index.less';
|
|
5
|
+
import { set } from "lodash";
|
|
6
|
+
|
|
7
|
+
interface PropertyItem {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
isChecked: boolean;
|
|
11
|
+
isCommonUse: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface propertyInfoProps {
|
|
15
|
+
propertyName: string;
|
|
16
|
+
propertyCode: string;
|
|
17
|
+
detailList: Array<PropertyItem>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const PropertyGroup = (props: any) => {
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
propertyData,
|
|
24
|
+
handleProperyItemChange,
|
|
25
|
+
modalVisilbe,
|
|
26
|
+
itemValue,
|
|
27
|
+
} = props;
|
|
28
|
+
const [commonUseProperty, setCommonUseProperty] = useState<Array<PropertyItem> | any>([]); // 常用属性值
|
|
29
|
+
const [notCommonUseProperty, setNotCommonUseProperty] = useState<Array<PropertyItem> | any>([]); // 非常用属性值
|
|
30
|
+
const [indeterminate, setIndeterminate] = useState(false);
|
|
31
|
+
const [showNotCommon, setShowNotCommon] = useState(false);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const proItemValue = (itemValue.propertyList || []).find((item: any) => item.propertyCode === propertyData.propertyCode);
|
|
35
|
+
const checkedList = proItemValue?.detailList || [];
|
|
36
|
+
|
|
37
|
+
const proDetailList = JSON.parse(JSON.stringify( propertyData?.detailList || []));
|
|
38
|
+
proDetailList.forEach((item: any) => {
|
|
39
|
+
if (checkedList.some((checkItem: any) => checkItem.value === item.value)){
|
|
40
|
+
item.isChecked = true;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const commonUseProperty = (proDetailList).filter((item: any) => item.isCommonUse);
|
|
44
|
+
|
|
45
|
+
const notCommonUseProperty = (proDetailList).filter((item: any) => !item.isCommonUse);
|
|
46
|
+
if (checkedList.some((item: any) => !item.isCommonUse)) {
|
|
47
|
+
setShowNotCommon(true)
|
|
48
|
+
}
|
|
49
|
+
setCommonUseProperty(commonUseProperty);
|
|
50
|
+
setNotCommonUseProperty(notCommonUseProperty);
|
|
51
|
+
}, [modalVisilbe])
|
|
52
|
+
|
|
53
|
+
const parseDataToParent = (comUse: any[], notComUse: any[]) => {
|
|
54
|
+
let choosedPropertyList = (comUse|| []).filter(item => item.isChecked);
|
|
55
|
+
if (showNotCommon) {
|
|
56
|
+
choosedPropertyList = [...choosedPropertyList, ...((notComUse|| []).filter(item => item.isChecked))]
|
|
57
|
+
}
|
|
58
|
+
handleProperyItemChange({
|
|
59
|
+
propertyCode: propertyData?.propertyCode,
|
|
60
|
+
propertyName: propertyData?.propertyName,
|
|
61
|
+
propertyId: propertyData?.propertyId,
|
|
62
|
+
isCommonUse: propertyData?.isCommonUse,
|
|
63
|
+
detailList: choosedPropertyList
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const handleChangeAll = (e: any) => {
|
|
69
|
+
if (showNotCommon) {
|
|
70
|
+
notCommonUseProperty.map((item: any) => item.isChecked = e.target.checked);
|
|
71
|
+
setNotCommonUseProperty([...notCommonUseProperty])
|
|
72
|
+
}
|
|
73
|
+
commonUseProperty.map((item: any) => item.isChecked = e.target.checked);
|
|
74
|
+
parseDataToParent(commonUseProperty, notCommonUseProperty)
|
|
75
|
+
setCommonUseProperty([...commonUseProperty])
|
|
76
|
+
setIndeterminate(false)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const handleIndeterminate = (commonUseProperty: any[], notCommonUseProperty: any[]) => {
|
|
80
|
+
let checkList = [...commonUseProperty];
|
|
81
|
+
if (showNotCommon) {
|
|
82
|
+
checkList = [...checkList, ...notCommonUseProperty]
|
|
83
|
+
}
|
|
84
|
+
const indeterminate = !!checkList.filter(item => item.isChecked).length && checkList.filter(item => item.isChecked).length !== checkList.length;
|
|
85
|
+
setIndeterminate(indeterminate);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const handleItemChecked = (e: any, item: any, type: number) => {
|
|
89
|
+
if (type === 1) { // 常用属性
|
|
90
|
+
(commonUseProperty || []).forEach((info: any) => {
|
|
91
|
+
if (info.value === item.value) {
|
|
92
|
+
info.isChecked = e.target.checked;
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
handleIndeterminate(commonUseProperty, notCommonUseProperty)
|
|
96
|
+
parseDataToParent(commonUseProperty, notCommonUseProperty)
|
|
97
|
+
setCommonUseProperty([...commonUseProperty])
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (type === 2) { // 非常用属性
|
|
101
|
+
(notCommonUseProperty || []).forEach((info: any) => {
|
|
102
|
+
if (info.value === item.value) {
|
|
103
|
+
info.isChecked = e.target.checked;
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
handleIndeterminate(commonUseProperty, notCommonUseProperty)
|
|
107
|
+
parseDataToParent(commonUseProperty, notCommonUseProperty)
|
|
108
|
+
setNotCommonUseProperty([...notCommonUseProperty])
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const checkAllChecked = () => {
|
|
113
|
+
const checkData = showNotCommon ? [...commonUseProperty, ...notCommonUseProperty] : [...commonUseProperty];
|
|
114
|
+
return checkData.length && checkData.every(item => item.isChecked) ? true : false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className={'propertyGroup_container'}>
|
|
120
|
+
<div className={'propertyGroup_container_left'}>
|
|
121
|
+
<Checkbox
|
|
122
|
+
checked={checkAllChecked()}
|
|
123
|
+
indeterminate={indeterminate}
|
|
124
|
+
onChange={handleChangeAll}
|
|
125
|
+
>
|
|
126
|
+
<div title={propertyData.name} className="propertyGroup_checkbox_container">{propertyData.propertyName}</div>
|
|
127
|
+
</Checkbox>
|
|
128
|
+
</div>
|
|
129
|
+
<div className={'propertyGroup_container_right'}>
|
|
130
|
+
{
|
|
131
|
+
(commonUseProperty || []).map((item: any) => (
|
|
132
|
+
<Checkbox
|
|
133
|
+
checked={item.isChecked}
|
|
134
|
+
key={item.value}
|
|
135
|
+
onChange={(e) => {
|
|
136
|
+
handleItemChecked(e, item, 1)
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<div title={item.name} className="propertyGroup_checkbox_container">
|
|
140
|
+
{item.name}
|
|
141
|
+
</div>
|
|
142
|
+
</Checkbox>
|
|
143
|
+
))
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
{
|
|
147
|
+
showNotCommon && (notCommonUseProperty || []).map((item: any) => (
|
|
148
|
+
<Checkbox
|
|
149
|
+
checked={item.isChecked}
|
|
150
|
+
key={item.value}
|
|
151
|
+
onChange={(e) => {
|
|
152
|
+
handleItemChecked(e, item, 2)
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<div title={item.name} className="propertyGroup_checkbox_container">
|
|
156
|
+
{item.name}
|
|
157
|
+
</div>
|
|
158
|
+
</Checkbox>
|
|
159
|
+
))
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
{
|
|
163
|
+
!!notCommonUseProperty.length && (
|
|
164
|
+
<div
|
|
165
|
+
style={{
|
|
166
|
+
width: '50px',
|
|
167
|
+
cursor: 'pointer',
|
|
168
|
+
color: '#005cff',
|
|
169
|
+
fontSize: '10px',
|
|
170
|
+
display: 'flex',
|
|
171
|
+
alignItems: 'center',
|
|
172
|
+
}}
|
|
173
|
+
onClick={() => {
|
|
174
|
+
setShowNotCommon(!showNotCommon);
|
|
175
|
+
handleIndeterminate(commonUseProperty, notCommonUseProperty)
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
{
|
|
179
|
+
showNotCommon && (
|
|
180
|
+
<>
|
|
181
|
+
<CaretUpOutlined />
|
|
182
|
+
收起
|
|
183
|
+
</>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
{
|
|
187
|
+
!showNotCommon && (
|
|
188
|
+
<>
|
|
189
|
+
<CaretDownOutlined />
|
|
190
|
+
展开
|
|
191
|
+
</>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
</div>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export default React.memo(PropertyGroup, (props, nextProps) => {
|
|
203
|
+
if (props.modalVisilbe !== nextProps.modalVisilbe) return false;
|
|
204
|
+
return true;
|
|
205
|
+
});
|
|
@@ -295,7 +295,7 @@ export function commonFun (type?: string, prefixUrl: any, parentProps?:any) {
|
|
|
295
295
|
// 商品选择器sku
|
|
296
296
|
if(type === 'skuCommodity') {
|
|
297
297
|
requestConfig = {
|
|
298
|
-
url: `${prefixUrl.selectPrefix}/sku/doPageBySelect/
|
|
298
|
+
url: `${prefixUrl.selectPrefix}/sku/doPageBySelect/v4`,
|
|
299
299
|
filter: 'skuCodeAndSkuName', // 过滤参数
|
|
300
300
|
searchStartLength: 4,
|
|
301
301
|
mappingTextField: 'name',
|
|
@@ -365,6 +365,9 @@ export function commonFun (type?: string, prefixUrl: any, parentProps?:any) {
|
|
|
365
365
|
dropdownStyle: { maxHeight: 400, maxWidth: 100, overflow: 'auto' }
|
|
366
366
|
},
|
|
367
367
|
} },
|
|
368
|
+
{ name: 'UNIQUE_SPEC', label: '属性', field: {
|
|
369
|
+
type: 'proppertySelector',
|
|
370
|
+
} },
|
|
368
371
|
]
|
|
369
372
|
Promise.all([
|
|
370
373
|
loadSelectSource(`${prefixUrl.formSelectFix}/brand/queryBrandList`, {
|
|
@@ -11,6 +11,7 @@ import { BusinessSearchSelect, QueryMutipleInput } from '@/index';
|
|
|
11
11
|
import { handleSourceName, getFormRowInfo, hasMoreQueryFields, defaultVisibleFieldsCount, getRealStr, ColSpan, getTableHeigth, getCurrentSRKs, getRenderSource } from './utils';
|
|
12
12
|
import { judgeIsRequestError } from '@/utils/requestUtils';
|
|
13
13
|
import zhankaitiaojian from '../../../assets/zhankaitiaojian-icon.svg';
|
|
14
|
+
import PropertySelector from '@/components/Business/PropertyModal';
|
|
14
15
|
|
|
15
16
|
const { Option } = Select;
|
|
16
17
|
|
|
@@ -180,7 +181,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
180
181
|
}))
|
|
181
182
|
|
|
182
183
|
// 获取数据源 (type: 1下拉框 2/3弹框 不传值默认为下拉框)
|
|
183
|
-
const getData = (params = {}, type = 1,callback?: any) => {
|
|
184
|
+
const getData = (params = {}, type = 1,callback?: any, bodyParams?: any) => {
|
|
184
185
|
if (!requestConfig) return;
|
|
185
186
|
|
|
186
187
|
setFetching(true)
|
|
@@ -327,12 +328,12 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
327
328
|
if (isNil(queryParams[selectParamsKey])) {
|
|
328
329
|
queryParams[selectParamsKey] = searchValue;
|
|
329
330
|
}
|
|
331
|
+
|
|
332
|
+
|
|
330
333
|
request
|
|
331
|
-
.
|
|
334
|
+
.post(
|
|
332
335
|
`${url}?${stringify(queryParams)}`,
|
|
333
|
-
|
|
334
|
-
headers: { ...extralHeaders }
|
|
335
|
-
})
|
|
336
|
+
bodyParams || null,)
|
|
336
337
|
.then((result: any) => {
|
|
337
338
|
setFetching(false)
|
|
338
339
|
result = result.data;
|
|
@@ -632,12 +633,18 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
632
633
|
|
|
633
634
|
const onSearchTable = () => {
|
|
634
635
|
const params = form.getFieldsValue();
|
|
636
|
+
console.log('dddd', params);
|
|
635
637
|
|
|
636
638
|
// const isHaveParams = params && Object.keys(params).filter(item => params[item]).length > 0;
|
|
637
639
|
setModalSearched(true);
|
|
640
|
+
|
|
641
|
+
let unique_params = null;
|
|
642
|
+
if (params['UNIQUE_SPEC']) {
|
|
643
|
+
unique_params = params['UNIQUE_SPEC']?.propertyList || [];
|
|
644
|
+
}
|
|
638
645
|
|
|
639
646
|
setTableFormParams(params);
|
|
640
|
-
getData({ ...params, pageSize: tableInitPageSize }, 2)
|
|
647
|
+
getData({ ...params, pageSize: tableInitPageSize }, 2, null, unique_params);
|
|
641
648
|
}
|
|
642
649
|
|
|
643
650
|
const onResetTable = () => {
|
|
@@ -817,6 +824,16 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
817
824
|
</Col>
|
|
818
825
|
);
|
|
819
826
|
}
|
|
827
|
+
if (i?.field?.type === 'proppertySelector') {
|
|
828
|
+
return (
|
|
829
|
+
<Col span={ColSpan} key={i.name}>
|
|
830
|
+
<Form.Item name={i.name} label={i.label} key={i.name}>
|
|
831
|
+
<PropertySelector
|
|
832
|
+
/>
|
|
833
|
+
</Form.Item>
|
|
834
|
+
</Col>
|
|
835
|
+
);
|
|
836
|
+
}
|
|
820
837
|
|
|
821
838
|
// 默认type是input
|
|
822
839
|
return (
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { default as JsonQueryTable } from './components/Business/JsonQueryTable'
|
|
|
35
35
|
export { default as TableColumnSetting} from './plugin/TableColumnSetting';
|
|
36
36
|
export { default as AuthButton } from './components/Functional/AuthButton';
|
|
37
37
|
export { default as CustomSelector } from './components/Solution/RuleComponent/CustomPlugin/CustomSelector';
|
|
38
|
+
export { default as PropertySelector} from './components/Business/PropertyModal';
|
|
38
39
|
|
|
39
40
|
export { default as EllipsisTooltip} from './components/Functional/EllipsisTooltip';
|
|
40
41
|
export * from './components/Functional/BsAntdSula/index';
|