优化 默认规格

This commit is contained in:
java110 2020-10-29 11:15:48 +08:00
parent a5e2b2c63b
commit 9096ea7ff2
5 changed files with 73 additions and 2 deletions

View File

@ -144,6 +144,11 @@
<button class="btn-white btn btn-xs"
v-on:click="_openDeleteProductSpec(productSpec)">删除</button>
</div>
<div class="btn-group" v-if="productSpec.isDefault != 'T'">
<button class="btn-white btn btn-xs"
v-on:click="_doDefaultProductSpec(addProductInfo,productSpec)">默认规格</button>
</div>
</td>
</tr>

View File

@ -26,6 +26,14 @@
}
},
watch: {
"addProductInfo.productSpecs": {
deep: true,
handler: function () {
}
}
},
_initMethod: function () {
$that._listAddProductCategorys();
@ -148,12 +156,31 @@
});
},
saveProductInfo: function () {
let hasDefault = false;
vc.component.addProductInfo.productSpecs.forEach(item =>{
if(item.isDefault != 'T' && item.isDefault != 'F'){
hasDefault = false;
return ;
}
if(item.isDefault == 'T'){
hasDefault = true;
}
});
if(!hasDefault){
vc.toast("未选择默认规格");
return;
}
if (!vc.component.addProductValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.component.addProductInfo.communityId = vc.getCurrentCommunity().communityId;
//不提交数据将数据 回调给侦听处理
if (vc.notNull($props.callBackListener)) {
@ -302,6 +329,15 @@
if (index > -1) {
_productSpecs.splice(index, 1);
}
},
_doDefaultProductSpec:function(_product,_defaultProductSpec){
_product.productSpecs.forEach(item => {
item.isDefault = "F";
});
_defaultProductSpec.isDefault="T";
$that.addProductInfo.productSpecs = JSON.parse(JSON.stringify(_product.productSpecs));
}
}
});

View File

@ -144,6 +144,10 @@
<button class="btn-white btn btn-xs"
v-on:click="_openDeleteProductSpec(productSpec)">删除</button>
</div>
<div class="btn-group" v-if="productSpec.isDefault != 'T'">
<button class="btn-white btn btn-xs"
v-on:click="_doEditDefaultProductSpec(editProductInfo,productSpec)">默认规格</button>
</div>
</td>
</tr>

View File

@ -145,6 +145,22 @@
});
},
_editProductInfo: function () {
let hasDefault = false;
vc.component.editProductInfo.productSpecs.forEach(item =>{
if(item.isDefault != 'T' && item.isDefault != 'F'){
hasDefault = false;
return ;
}
if(item.isDefault == 'T'){
hasDefault = true;
}
});
if(!hasDefault){
vc.toast("未选择默认规格");
return;
}
if (!vc.component.editProductValidate()) {
vc.toast(vc.validate.errInfo);
@ -183,6 +199,7 @@
let _productCategorys = $that.editProductInfo.productCategorys;
vc.component.editProductInfo = {
productId: '',
categoryId: '',
prodName: '',
prodDesc: '',
@ -338,6 +355,15 @@
}
);
},
_doEditDefaultProductSpec:function(_product,_defaultProductSpec){
_product.productSpecs.forEach(item => {
item.isDefault = "F";
});
_defaultProductSpec.isDefault="T";
$that.addProductInfo.editProductInfo = JSON.parse(JSON.stringify(_product.productSpecs));
}
}
});

View File

@ -63,7 +63,7 @@
<th class="text-center">商品名称</th>
<th class="text-center">销量</th>
<th class="text-center">库存</th>
<th class="text-center">产品条码</th>
<th class="text-center">价格</th>
<th class="text-center">排序</th>
<th class="text-center">状态</th>
<th class="text-right">操作</th>
@ -80,7 +80,7 @@
<td class="text-center">{{product.prodName}}</td>
<td class="text-center">{{product.sales}}</td>
<td class="text-center">{{product.stock}}</td>
<td class="text-center">{{product.barCode}}</td>
<td class="text-center">{{product.defaultSpecValue.price}}</td>
<td class="text-center">{{product.sort}}</td>
<th class="text-center">{{product.stateName}}</th>
<td class="text-right">