Skip to content

Commit bb686d8

Browse files
author
guhao
committed
fix: classifcation bug
1 parent ed81798 commit bb686d8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

frontend/pc-tool/src/packages/pc-editor/utils/classification.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,39 @@ export function traverseClassification2Arr(data: any[]) {
55
let classifications = [] as IClassification[];
66

77
data.forEach((e: any) => {
8+
let attribute = e.attribute || e;
89
let classificationId = e.id + '';
10+
911
let classification: IClassification = {
1012
id: classificationId,
1113
name: e.name,
1214
label: e.name,
1315
attrs: [],
1416
};
15-
let options = e.options || [];
17+
let options = attribute.options || [];
18+
if (e.inputType) {
19+
attribute.type = e.inputType;
20+
}
1621
let classificationAttr: IClassificationAttr = {
17-
id: e.id,
18-
key: e.name,
22+
id: attribute.id,
23+
key: attribute.name,
1924
classificationId,
2025
parent: '',
2126
parentValue: '',
2227
parentAttr: e.name,
23-
type: e.inputType,
24-
name: e.name,
25-
label: e.name,
26-
value: e.inputType === AttrType.MULTI_SELECTION ? [] : '',
27-
required: e.isRequired,
28+
type: attribute.type,
29+
name: attribute.name,
30+
label: attribute.name,
31+
value: attribute.type === AttrType.MULTI_SELECTION ? [] : '',
32+
required: attribute.required,
2833
options: options.map((e: any) => {
2934
return { value: e.name, label: e.name };
3035
}),
3136
};
3237

3338
classification.attrs.push(classificationAttr);
3439
options.forEach((option: any) => {
35-
traverseOption(classification, option, classificationAttr.id, e.name);
40+
traverseOption(classification, option, classificationAttr.id, attribute.name);
3641
});
3742
classifications.push(classification);
3843
});
@@ -50,7 +55,7 @@ export function traverseClassification2Arr(data: any[]) {
5055
option.attributes.forEach((attr: any) => {
5156
let name = attr.name;
5257
let classificationAttr: IClassificationAttr = {
53-
id: attr.id || attr.uuid,
58+
id: attr.id,
5459
key: `${parent}[${option.name}]-${name}`,
5560
classificationId: classification.id,
5661
parent,
@@ -72,6 +77,7 @@ export function traverseClassification2Arr(data: any[]) {
7277
});
7378
}
7479
}
80+
7581
export function traverseClass2Arr(data: any) {
7682
let classTypes = [] as IClassType[];
7783
data.forEach((config: any) => {

0 commit comments

Comments
 (0)