update:修复类型管理某个类型编辑报错

This commit is contained in:
lihaoyuan 2025-10-28 15:32:23 +08:00
parent 7d1bd2dee8
commit f0b6e85620

View File

@ -660,40 +660,49 @@
},
//
defaultSelected(specIds) {
const values = this.flatten(Object.values(this.specForm))
const selects = values.filter((item) =>
specIds.includes(item.spec_id.toString())
)
this.selectedSpecs = this.selectSpecs = selects
this.type_spec_names = this.selectedSpecs
.map((item) => {
return item.spec_name
})
.join(', ')
this.form.type_spec_ids = this.selectedSpecs
.map((item) => {
return item.spec_id
})
.join(',')
// specForm
if (!this.specForm || Object.keys(this.specForm).length === 0) {
this.selectedSpecs = this.selectSpecs = [];
this.type_spec_names = '';
this.form.type_spec_ids = '';
return;
}
const values = this.flatten(Object.values(this.specForm));
const selects = values.filter((item) =>
specIds.includes(item.spec_id.toString())
);
this.selectedSpecs = this.selectSpecs = selects;
this.type_spec_names = selects.length > 0
? selects.map(item => item.spec_name).join(', ')
: '';
this.form.type_spec_ids = selects.length > 0
? selects.map(item => item.spec_id).join(',')
: '';
},
//
brandDefaultSelected(brandIds) {
const values = this.flatten(Object.values(this.brandForm))
// brandForm Object.values
if (!this.brandForm || Object.keys(this.brandForm).length === 0) {
this.selectedBrands = this.selectBrands = [];
this.type_brand_names = '';
this.form.type_brand_ids = '';
return;
}
const values = this.flatten(Object.values(this.brandForm));
const selects = values.filter((item) =>
brandIds.includes(item.brand_id.toString())
)
this.selectedBrands = this.selectBrands = selects
this.type_brand_names = this.selectedBrands
.map((item) => {
return item.brand_name
})
.join(', ')
this.form.type_brand_ids = this.selectedBrands
.map((item) => {
return item.brand_id
})
.join(',')
);
this.selectedBrands = this.selectBrands = selects;
// join ", "
this.type_brand_names = selects.length > 0
? selects.map(item => item.brand_name).join(', ')
: '';
this.form.type_brand_ids = selects.length > 0
? selects.map(item => item.brand_id).join(',')
: '';
},
//
flatten(arr) {