39
39
<el-tab-pane label =" 价格库存" name =" rates" class =" rates" >
40
40
<el-form ref =" rates" :model =" ratesForm" :rules =" rules" >
41
41
<el-form-item label =" 启用多规格" >
42
- <!-- TODO @luowenfeng: 1) activeSwitch 可以考虑改成; specSwitch, 更清晰一点, activeSwitch 太通用了; changeRadio 改成 changeSpecSwitch -->
43
- <el-switch v-model =" activeSwitch" @change =" changeRadio" ></el-switch >
42
+ <el-switch v-model =" specSwitch" @change =" changeSpecSwitch" ></el-switch >
44
43
</el-form-item >
45
44
46
45
<!-- 动态添加规格属性 -->
67
66
<!-- 规格明细 -->
68
67
<el-form-item label =" 规格明细" >
69
68
<el-table :data =" ratesForm.rates" border style =" width : 100% " ref =" ratesTable" >
70
- <template v-if =" this .activeSwitch " >
69
+ <template v-if =" this .specSwitch " >
71
70
<el-table-column :key =" index" v-for =" (item, index) in dynamicSpec.filter(v => v.specName !== undefined)"
72
71
:label =" item.specName" >
73
72
<template slot-scope="scope">
81
80
style =" width : 100px ; height : 50px " />
82
81
</template >
83
82
</el-table-column >
84
- <template v-if =" this .activeSwitch " >
83
+ <template v-if =" this .specSwitch " >
85
84
<el-table-column label =" sku名称" :render-header =" addRedStar" key =" 91" >
86
85
<template slot-scope="scope">
87
86
<el-form-item :prop =" 'rates.'+ scope.$index + '.name'"
148
147
<el-input v-model =" scope.row.barCode" ></el-input >
149
148
</template >
150
149
</el-table-column >
151
- <template v-if =" this .activeSwitch " >
150
+ <template v-if =" this .specSwitch " >
152
151
<el-table-column fixed =" right" label =" 操作" width =" 50" key =" 100" >
153
152
<template slot-scope="scope">
154
153
<el-button @click =" scope.row.status = 1" type =" text" size =" small"
155
- v-show =" scope.row.status == undefined || scope.row.status == 0 " >禁用
154
+ v-show =" scope.row.status === undefined || scope.row.status = == 0 " >禁用
156
155
</el-button >
157
- <el-button @click =" scope.row.status = 0" type =" text" size =" small" v-show =" scope.row.status == 1" >
156
+ <el-button @click =" scope.row.status = 0" type =" text" size =" small" v-show =" scope.row.status === 1" >
158
157
启用
159
158
</el-button >
160
159
</template >
@@ -220,7 +219,7 @@ export default {
220
219
},
221
220
data () {
222
221
return {
223
- activeSwitch : false ,
222
+ specSwitch : false ,
224
223
activeName: " base" ,
225
224
propName: {
226
225
checkStrictly: true ,
@@ -287,7 +286,7 @@ export default {
287
286
methods: {
288
287
removeSpec (index ) {
289
288
this .dynamicSpec .splice (index, 1 );
290
- this .changeRadio ()
289
+ this .changeSpecSwitch ()
291
290
},
292
291
// 必选标识
293
292
addRedStar (h , {column}) {
@@ -296,10 +295,10 @@ export default {
296
295
h (' span' , ' ' + column .label )
297
296
];
298
297
},
299
- changeRadio () {
300
- this .activeSwitch ? this .ratesForm .spec = 2 : this .ratesForm .spec = 1 ;
298
+ changeSpecSwitch () {
299
+ this .specSwitch ? this .ratesForm .spec = 2 : this .ratesForm .spec = 1 ;
301
300
this .$refs .ratesTable .doLayout ();
302
- if (this .ratesForm .spec == 1 ) {
301
+ if (this .ratesForm .spec === 1 ) {
303
302
this .ratesForm .rates = [{}]
304
303
} else {
305
304
this .ratesForm .rates = []
@@ -380,7 +379,7 @@ export default {
380
379
})
381
380
382
381
// 动态规格调整字段
383
- if (this .activeSwitch ) {
382
+ if (this .specSwitch ) {
384
383
rates .forEach (r => {
385
384
let properties = []
386
385
Array .of (r .spec ).forEach (s => {
@@ -391,7 +390,7 @@ export default {
391
390
obj = Array .of (s);
392
391
}
393
392
obj .forEach ((v , i ) => {
394
- let specValue = this .dynamicSpec [i].specValue .find (o => o .name == v);
393
+ let specValue = this .dynamicSpec [i].specValue .find (o => o .name === v);
395
394
let propertie = {};
396
395
propertie .propertyId = this .dynamicSpec [i].specId ;
397
396
propertie .valueId = specValue .id ;
@@ -414,17 +413,20 @@ export default {
414
413
}
415
414
form .skus = rates;
416
415
form .specType = this .ratesForm .spec ;
417
- form .categoryId = form .categoryIds [this .baseForm .categoryIds .length - 1 ];
416
+
417
+ let category = form .categoryIds instanceof Array ? form .categoryIds : Array .of (form .categoryIds )
418
+ console .log (category)
419
+ form .categoryId = category[category .length - 1 ];
418
420
419
421
if (form .id == null ) {
420
- createSpu (form).then ((response ) => {
422
+ createSpu (form).then (() => {
421
423
this .$modal .msgSuccess (" 新增成功" );
422
424
})
423
425
.then (()=> {
424
426
this .cancel ();
425
427
})
426
428
} else {
427
- updateSpu (form).then ((response ) => {
429
+ updateSpu (form).then (() => {
428
430
this .$modal .msgSuccess (" 修改成功" );
429
431
})
430
432
.then (()=> {
@@ -443,8 +445,8 @@ export default {
443
445
},
444
446
// 添加规格项目
445
447
changeSpec (val ) {
446
- let obj = this .propertyPageList .find (o => o .id == val);
447
- let spec = this .dynamicSpec .find (o => o .specId == val)
448
+ let obj = this .propertyPageList .find (o => o .id === val);
449
+ let spec = this .dynamicSpec .find (o => o .specId === val)
448
450
spec .specId = obj .id ;
449
451
spec .specName = obj .name ;
450
452
spec .specValue = obj .values ;
@@ -471,8 +473,8 @@ export default {
471
473
r .price = this .divide (r .price , 100 )
472
474
r .costPrice = this .divide (r .costPrice , 100 )
473
475
})
474
- if (this .ratesForm .spec == 2 ) {
475
- this .activeSwitch = true ;
476
+ if (this .ratesForm .spec === 2 ) {
477
+ this .specSwitch = true ;
476
478
data .productPropertyViews .forEach (p => {
477
479
let obj = {};
478
480
obj .specId = p .propertyId ;
@@ -483,7 +485,7 @@ export default {
483
485
data .skus .forEach (s => {
484
486
s .spec = [];
485
487
s .properties .forEach (sp => {
486
- let spec = data .productPropertyViews .find (o => o .propertyId == sp .propertyId ).propertyValues .find (v => v .id == sp .valueId ).name ;
488
+ let spec = data .productPropertyViews .find (o => o .propertyId === sp .propertyId ).propertyValues .find (v => v .id = == sp .valueId ).name ;
487
489
s .spec .push (spec)
488
490
})
489
491
})
0 commit comments