Commit ae7b542f by caoyanzhi

fix: 修复单规格商品保存后库存丢失的bug

parent 5db0caf0
......@@ -428,7 +428,6 @@ export default {
uploadAction: 'https://four.gicdev.com/api-marketing/upload/upload-image',
// uploadAction: '/welfare/upload/upload-image',
openStorePick: 0,
btnLoading: false,
loading: false,
enterpriseName: '', // 商户名称
handleData: {
......@@ -446,6 +445,7 @@ export default {
relationId: '', // 账号分组relationId
isEcho: false, // 控制操作人权限是否回显数据
sceneType: 10, // 场景值,现在测试使用,后期提供确定的
singleSkuList: [], // 单规格的商品skuList
};
},
mounted() {
......@@ -563,6 +563,7 @@ export default {
let skuList = resResult.skuList || []; // 礼品规格值信息
if(this.goodsStandardInfo.length > 0){
// 多规格商品
if(skuList.length > 1){
let arr2 = [];
for(let key1 in skuList){
......@@ -580,6 +581,9 @@ export default {
}
}else{
this.goodsForm.costPrice = Number(resResult.costPrice).toFixed(2);
// 单规格商品
// 缓存单规格商品的skuList,为将来保存时提交的数据做准备
this.singleSkuList = skuList;
}
let mapData = [];
let skuSellObj = {};
......@@ -627,7 +631,7 @@ export default {
} else {
this.$message.error(res.message);
}
}).finally(() => this.$emit('updateLoading'));
}).finally(() => this.$emit('updateLoading', false));
},
// 上传前
beforeUpload(file) {
......@@ -1253,7 +1257,6 @@ export default {
},
// 保存
submitForm(goodsForm) {
if(this.btnLoading) return;
if (this.goodsStandardInfo.length > 0) {
for (let item of this.goodsStandardInfo) {
if (item.specId == '') {
......@@ -1345,10 +1348,16 @@ export default {
}
}
} else {
skuList = [];
// 编辑单sku商品为单sku时,需要传skuList
// 处理单sku的数据
skuList = this.singleSkuList.map(el => {
el.stockAlter = Math.abs(this.goodsForm.stock - el.totalStock); // 库存变动的数量
el.stockType = this.goodsForm.stock > el.totalStock ? 1 : 0; // 0:减少库存 1:增加库存
el.stock = this.goodsForm.stock;
return el;
});
}
// this.btnLoading = true;
this.$emit('updateLoading');
let params = {
giftId: this.giftId,
giftType: 1, // 实物礼品
......@@ -1375,16 +1384,14 @@ export default {
shopCodeList: this.diliveryData.shopCodeList, // 门店CodeList
stockUseType: this.goodsForm.stockUseType, // 库存使用类型
};
this.btnLoading = true;
console.log(params);
this.$emit('updateLoading');
if (this.isEdit) {
// params.giftId = this.giftId;
giftUpdate(params).then(res =>{
if (res.code === '0000') {
this.$router.push({ path: '/gift-manage/real-gift' });
this.btnLoading = false;
} else {
this.btnLoading = false;
this.$message.error(res.message);
}
}).finally(() => this.$emit('updateLoading', false));
......@@ -1394,9 +1401,7 @@ export default {
if (res.code === '0000') {
this.$store.commit('updateShowCornerCanUseApp', true);
this.$router.push({ path: '/gift-manage/real-gift' });
this.btnLoading = false;
} else {
this.btnLoading = false;
this.$message.error(res.message);
}
let callbackId = this.$route.query.callbackId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment