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