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

update:库存问题修改

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