Skip to content

Commit 0c122da

Browse files
committed
feature(uniapp商品): 新增商品数据
1 parent e29e43b commit 0c122da

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@
178178
/>
179179

180180

181-
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body >
182-
<save @closeDialog="open = false"/>
183-
</el-dialog>
181+
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body destroy-on-close>
182+
<save @closeDialog="open = false; getList()"/>
183+
</el-dialog>
184184
</div>
185185
</template>
186186

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,26 +309,33 @@ export default {
309309
if (this.ratesForm.spec == 1) {
310310
rates.forEach(r => {
311311
let properties = []
312-
r.spec.forEach((v, i) => {
313-
let specValue = this.dynamicSpec[i].specValue.find(o => o.name == v);
314-
let propertie = {};
315-
propertie.propertyId = this.dynamicSpec[i].specId;
316-
propertie.valueId = specValue.id;
317-
properties.push(propertie);
318-
})
312+
if(r.spec instanceof Array){
313+
r.spec.forEach((v, i) => {
314+
let specValue = this.dynamicSpec[i].specValue.find(o => o.name == v);
315+
let propertie = {};
316+
propertie.propertyId = this.dynamicSpec[i].specId;
317+
propertie.valueId = specValue.id;
318+
properties.push(propertie);
319+
})
320+
}else{
321+
let specValue = this.dynamicSpec[0].specValue.find(o => o.name == r.spec);
322+
let propertie = {};
323+
propertie.propertyId = this.dynamicSpec[0].specId;
324+
propertie.valueId = specValue.id;
325+
properties.push(propertie);
326+
}
319327
r.properties = properties;
320328
})
321329
}
322330
this.baseForm.skus = rates;
323331
this.baseForm.specType = this.ratesForm.spec;
324332
this.baseForm.categoryId = this.baseForm.categoryIds[this.baseForm.categoryIds.length - 1];
325-
console.log(this.baseForm)
326333
createSpu(this.baseForm).then((response) => {
334+
console.log(response)
327335
this.$modal.msgSuccess("新增成功");
328-
this.open = false;
329-
this.getList();
330336
this.$emit("closeDialog");
331337
});
338+
332339
},
333340
/** 查询规格 */
334341
getPropertyPageList() {

0 commit comments

Comments
 (0)