Commit edfe379848de5b5febbcc482f52b57acd3b836bb

Authored by luowenfeng
1 parent 8ad1439f

feature(uniapp商品): 多规格新增

yudao-ui-admin/src/views/mall/product/spu/save.vue
@@ -52,9 +52,8 @@ @@ -52,9 +52,8 @@
52 icon="el-icon-delete" 52 icon="el-icon-delete"
53 circle 53 circle
54 class="spec-delete" 54 class="spec-delete"
55 - @click="dynamicSpec.splice(index, 1)" 55 + @click="removeSpec(index)"
56 ></el-button> 56 ></el-button>
57 -  
58 <div class="spec-header"> 57 <div class="spec-header">
59 规格项: 58 规格项:
60 <el-select v-model="specs.specId" filterable placeholder="请选择" @change="changeSpec"> 59 <el-select v-model="specs.specId" filterable placeholder="请选择" @change="changeSpec">
@@ -286,10 +285,15 @@ export default { @@ -286,10 +285,15 @@ export default {
286 }, 285 },
287 286
288 created() { 287 created() {
  288 +
289 this.getListCategory(); 289 this.getListCategory();
290 this.getPropertyPageList(); 290 this.getPropertyPageList();
291 }, 291 },
292 methods: { 292 methods: {
  293 + removeSpec(index){
  294 + this.dynamicSpec.splice(index, 1);
  295 + this.changeRadio()
  296 + },
293 async confirmLeave(active, old){ 297 async confirmLeave(active, old){
294 await this.$refs[old].validate((valid) => { 298 await this.$refs[old].validate((valid) => {
295 console.log(valid) 299 console.log(valid)
@@ -306,12 +310,13 @@ export default { @@ -306,12 +310,13 @@ export default {
306 ]; 310 ];
307 }, 311 },
308 changeRadio() { 312 changeRadio() {
309 - this.$refs.ratesTable.doLayout() 313 + this.$refs.ratesTable.doLayout();
310 if (this.ratesForm.spec == 1) { 314 if (this.ratesForm.spec == 1) {
311 this.ratesForm.rates = [{}] 315 this.ratesForm.rates = [{}]
312 } else { 316 } else {
313 this.ratesForm.rates = [] 317 this.ratesForm.rates = []
314 if (this.dynamicSpec.length > 0) { 318 if (this.dynamicSpec.length > 0) {
  319 + console.log( this.dynamicSpec)
315 this.buildRatesFormRates() 320 this.buildRatesFormRates()
316 } 321 }
317 } 322 }
@@ -360,12 +365,16 @@ export default { @@ -360,12 +365,16 @@ export default {
360 if (this.ratesForm.spec == 2) { 365 if (this.ratesForm.spec == 2) {
361 rates.forEach(r => { 366 rates.forEach(r => {
362 let properties = [] 367 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 + })
369 }) 378 })
370 r.properties = properties; 379 r.properties = properties;
371 }) 380 })