Commit 0c6eb041 by LJM

寄售库存

parent b5740f64
......@@ -439,14 +439,14 @@
<el-table-column prop="stock" label="可用库存数量" min-width="25%"></el-table-column>
<el-table-column label="申请召回数量" min-width="25%">
<template slot-scope="scope">
<el-input v-model="scope.row.updateStock" placeholder="申请召回数量" @input="validateInput(scope.row)" onkeyup="if(event.keyCode !=37 &amp;&amp; event.keyCode != 39){if (!/^[\d]+$/ig.test(this.value)){this.value='';}}"></el-input>
<el-input v-model="scope.row.recall_num" placeholder="申请召回数量" @input="validateInput(scope.row)" onkeyup="if(event.keyCode !=37 &amp;&amp; event.keyCode != 39){if (!/^[\d]+$/ig.test(this.value)){this.value='';}}"></el-input>
</template>
</el-table-column>
</el-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisibleConsignmentRecall = false">取 消</el-button>
<el-button type="primary">确 定</el-button>
<el-button type="primary" @click="addConsignmentRecallFromStock">确 定</el-button>
</span>
</el-dialog>
<Menu/>
......@@ -681,7 +681,8 @@ export default {
brand_id: this.formParam.brand_id,
brand_name: this.formParam.brand_name,
action_time: this.formParam.date[0],
end_time: this.formParam.date[1]
end_time: this.formParam.date[1],
source: 12
}).then(res => {
if (res.code == 0) {
this.disabled = true
......@@ -769,7 +770,6 @@ export default {
*/
getTimes(date, type) {
if (type) {
var cp_time_day = localStorage.getItem('cp_time_day');
if (cp_time_day == -1) {
// “无限制”,则修改上架有效期默认为:2035-01-01
......@@ -777,8 +777,6 @@ export default {
} else {
var date = new Date(new Date().getTime() + cp_time_day * 24 * 60 * 60 * 1000);
}
// var date = new Date(new Date(date).getTime() + 30 * 24 * 60 * 60 * 1000);
} else {
var date = new Date(date);
}
......@@ -990,25 +988,25 @@ export default {
// 使用reduce将库存数据转换为对象
const stockUpdates = this.kucundata.reduce((acc, item) => ({
...acc,
[item.goods_id]: { stock: item.updateStock }
[item.goods_id]: {stock: item.updateStock}
}), {});
this.$http('post', "/api/sku/updateSku", stockUpdates)
.then(res => {
if (res.code === 0) {
this.$message({
message: '修改成功',
type: 'success'
});
this.getData();
this.dialogVisible = false;
} else {
this.$message({
message: res.msg,
type: 'error'
});
}
});
.then(res => {
if (res.code === 0) {
this.$message({
message: '修改成功',
type: 'success'
});
this.getData();
this.dialogVisible = false;
} else {
this.$message({
message: res.msg,
type: 'error'
});
}
});
},
/**
* 上下架
......@@ -1111,7 +1109,8 @@ export default {
goods_name: item.goods_name,
brand_name: item.brand_name,
stock: item.stock,
updateStock: item.stock
date_code: item.batch_sn,//批次
recall_num: item.stock
}
});
this.dialogVisibleConsignmentRecall = true;
......@@ -1152,17 +1151,49 @@ export default {
*/
validateInput(row) {
// 转换为数字进行比较
let inputValue = Number(row.updateStock) || 0;
let inputValue = Number(row.recall_num) || 0;
let stockValue = Number(row.stock) || 0;
// 如果输入值大于库存,则设置为库存值
if (inputValue > stockValue) {
row.updateStock = stockValue;
row.recall_num = stockValue;
this.$message({
message: '申请召回数量不能大于可用库存数量',
type: 'warning'
});
}
},
/**
* 寄售库存-新增寄售召回单
*/
addConsignmentRecallFromStock() {
// 检查是否有空的召回数量
const hasEmptyRecallNum = this.consignmentRecallData.some(item => !item.recall_num);
if (hasEmptyRecallNum) {
this.$message({
message: '请填写申请召回数量',
type: 'warning'
});
return;
}
this.$http('POST', "/api/consignmentRecall/addConsignmentRecallFromStock", {
recall_json: JSON.stringify(this.consignmentRecallData)
}).then(res => {
if (res.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
onClose: () => {
this.dialogVisibleConsignmentRecall = false;
this.getData();
}
});
} else {
this.$message.error(res.msg || '操作失败');
}
})
}
},
components: {
......
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 sign in to comment