Commit 9f754125 authored by v-yuchenglong's avatar v-yuchenglong

update:库存问题修改

parent 3c70e391
......@@ -123,7 +123,7 @@
<el-input
v-model="commodityForm.inventory_total"
placeholder=""
oninput="this.value = this.value.replace(/[^0-9]/g, '');"
@input="inventoryIpt"
></el-input>
</el-form-item>
<div style="display: inline-block; height: 42px; margin-left: 33px">
......@@ -294,21 +294,24 @@ export default {
multipleSelection: [], // 勾选的数据
goodsSkuID: "",
inventoryTotal: 0, // 总库存
inventoryRest: 0, // 剩余库存
};
},
computed: {
// 计算剩余库存
inventoryRest() {
if (this.commodityForm.inventory_total == null) {
return 0;
} else {
return Number(
this.commodityForm.inventory_total -
this.commodityForm.total_amount_order
);
}
},
},
// computed: {
// // 计算剩余库存
// inventoryRest() {
// if (this.commodityForm.inventory_total == null) {
// return 0;
// } else {
// return Number(
// this.commodityForm.inventory_total -
// this.commodityForm.total_amount_order
// );
// }
// },
// },
methods: {
// 上移
upMove(index) {
......@@ -332,6 +335,21 @@ export default {
}
},
// 库存计算
inventoryIpt(val) {
var pattern = /^-?[1-9]\d*$|^0$/g;
if (!pattern.test(this.commodityForm.inventory_total)) {
this.commodityForm.inventory_total = "";
this.inventoryRest =
this.inventoryTotal - this.commodityForm.total_amount_order;
} else {
this.inventoryRest =
Number(val) +
this.inventoryTotal -
this.commodityForm.total_amount_order;
}
},
// 展示商品大图
previewImage(file) {
this.popoverImage = file.url;
......@@ -377,6 +395,8 @@ export default {
this.picUrlList = [];
let params = { goods_sku_id: goodSkuID, marketing_type: "4" };
const res = await markGoodsInfo(params);
this.inventoryRest = res.result.goods_info.inventory_rest;
this.inventoryTotal = res.result.goods_info.inventory_total;
this.commodityForm = res.result.goods_info;
this.commodityForm.business1 = res.result.goods_info.ota_id;
for (var i in res.result.goods_info.desc_pic_url_list) {
......
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