更新库存

This commit is contained in:
姜棚 2021-12-10 10:02:17 +08:00
parent f7008bdb01
commit fb1a1e3ca9
2 changed files with 16 additions and 2 deletions

View File

@ -149,6 +149,12 @@ export default class adduserinfo extends React.Component{
let product_id = sessionStorage.getItem("dataInfo"); let product_id = sessionStorage.getItem("dataInfo");
let code_batch_id = sessionStorage.getItem("code_id") let code_batch_id = sessionStorage.getItem("code_id")
if(this.state.model.quantity < this.state.model.usage)
{
Notify.error(`商品总库存量不能小于已使用数量`);
return;
}
let formdata = { let formdata = {
"product_type": this.state.model.type, "product_type": this.state.model.type,
"product_name": this.state.model.name, "product_name": this.state.model.name,
@ -157,7 +163,7 @@ export default class adduserinfo extends React.Component{
"account_type":this.state.model.account_type, "account_type":this.state.model.account_type,
"official_price":this.state.model.official_price, "official_price":this.state.model.official_price,
"quantity": this.state.model.quantity, "quantity": this.state.model.quantity,
"usage": 0, "usage": this.state.model.usage,
"show_url": this.state.model.show_url, "show_url": this.state.model.show_url,
"describe_url": this.state.model.describe_url "describe_url": this.state.model.describe_url
} }
@ -332,7 +338,8 @@ export default class adduserinfo extends React.Component{
{ {
this.state.loadshow? <FormItem labelname="商品库存总数量" prop="quantity" id="quantity"> this.state.loadshow? <FormItem labelname="商品库存总数量" prop="quantity" id="quantity">
<Ipt onChange={(e)=>{ <Ipt onChange={(e)=>{
let model2 = this.state.model; let model2 = this.state.model;
model2.quantity = e; model2.quantity = e;
model2.stock = model2.quantity - model2.usage; model2.stock = model2.quantity - model2.usage;
this.setState({model:model2}) this.setState({model:model2})

View File

@ -359,6 +359,13 @@ export default class exchangedit extends React.Component{
this.setState({tempdata:this.state.tempdata}) this.setState({tempdata:this.state.tempdata})
let value = e.target.value == "" ? 0 : e.target.value; let value = e.target.value == "" ? 0 : e.target.value;
let rowIndex =this.state.tempdata.findIndex((o)=>{return o.product_id == row.product_id}) let rowIndex =this.state.tempdata.findIndex((o)=>{return o.product_id == row.product_id})
if(value - this.state.tempdata[rowIndex].usage < 0)
{
Notify.error(`库存总数量不能小于已使用库存量`);
return;
}
this.state.tempdata[rowIndex].quantity = value; this.state.tempdata[rowIndex].quantity = value;
this.state.tempdata[rowIndex].stock = value - this.state.tempdata[rowIndex].usage ; this.state.tempdata[rowIndex].stock = value - this.state.tempdata[rowIndex].usage ;
this.setState({tempdata:this.state.tempdata}) this.setState({tempdata:this.state.tempdata})