Skip to content

Commit 38532d0

Browse files
committed
feature(uniapp商品): 多规格新增
1 parent 03eed3b commit 38532d0

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/views/mall/product/spu/save.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@
5252
icon="el-icon-delete"
5353
circle
5454
class="spec-delete"
55-
@click="dynamicSpec.splice(index, 1)"
55+
@click="removeSpec(index)"
5656
></el-button>
57-
5857
<div class="spec-header">
5958
规格项:
6059
<el-select v-model="specs.specId" filterable placeholder="请选择" @change="changeSpec">
@@ -286,10 +285,15 @@ export default {
286285
},
287286
288287
created() {
288+
289289
this.getListCategory();
290290
this.getPropertyPageList();
291291
},
292292
methods: {
293+
removeSpec(index){
294+
this.dynamicSpec.splice(index, 1);
295+
this.changeRadio()
296+
},
293297
async confirmLeave(active, old){
294298
await this.$refs[old].validate((valid) => {
295299
console.log(valid)
@@ -306,12 +310,13 @@ export default {
306310
];
307311
},
308312
changeRadio() {
309-
this.$refs.ratesTable.doLayout()
313+
this.$refs.ratesTable.doLayout();
310314
if (this.ratesForm.spec == 1) {
311315
this.ratesForm.rates = [{}]
312316
} else {
313317
this.ratesForm.rates = []
314318
if (this.dynamicSpec.length > 0) {
319+
console.log( this.dynamicSpec)
315320
this.buildRatesFormRates()
316321
}
317322
}
@@ -360,12 +365,16 @@ export default {
360365
if (this.ratesForm.spec == 2) {
361366
rates.forEach(r => {
362367
let properties = []
363-
Array.of(r.spec).forEach((v, i) => {
364-
let specValue = this.dynamicSpec[i].specValue.find(o => o.name == v);
365-
let propertie = {};
366-
propertie.propertyId = this.dynamicSpec[i].specId;
367-
propertie.valueId = specValue.id;
368-
properties.push(propertie);
368+
Array.of(r.spec).forEach(s => {
369+
Array.of(s).forEach((v, i) => {
370+
console.log(this.dynamicSpec, r, s, v, i)
371+
let specValue = this.dynamicSpec[i].specValue.find(o => o.name == v);
372+
console.log(specValue)
373+
let propertie = {};
374+
propertie.propertyId = this.dynamicSpec[i].specId;
375+
propertie.valueId = specValue.id;
376+
properties.push(propertie);
377+
})
369378
})
370379
r.properties = properties;
371380
})

0 commit comments

Comments
 (0)