diff --git a/src/pages/exchangecode/commodity/goodedit.js b/src/pages/exchangecode/commodity/goodedit.js index 1d31c5a4..8e699d45 100644 --- a/src/pages/exchangecode/commodity/goodedit.js +++ b/src/pages/exchangecode/commodity/goodedit.js @@ -149,6 +149,12 @@ export default class adduserinfo extends React.Component{ let product_id = sessionStorage.getItem("dataInfo"); let code_batch_id = sessionStorage.getItem("code_id") + + if(this.state.model.quantity < this.state.model.usage) + { + Notify.error(`商品总库存量不能小于已使用数量`); + return; + } let formdata = { "product_type": this.state.model.type, "product_name": this.state.model.name, @@ -157,7 +163,7 @@ export default class adduserinfo extends React.Component{ "account_type":this.state.model.account_type, "official_price":this.state.model.official_price, "quantity": this.state.model.quantity, - "usage": 0, + "usage": this.state.model.usage, "show_url": this.state.model.show_url, "describe_url": this.state.model.describe_url } @@ -332,7 +338,8 @@ export default class adduserinfo extends React.Component{ { this.state.loadshow? { - let model2 = this.state.model; + let model2 = this.state.model; + model2.quantity = e; model2.stock = model2.quantity - model2.usage; this.setState({model:model2}) diff --git a/src/pages/exchangecode/edit/edit.js b/src/pages/exchangecode/edit/edit.js index 5b233c5f..176fb1fc 100644 --- a/src/pages/exchangecode/edit/edit.js +++ b/src/pages/exchangecode/edit/edit.js @@ -359,6 +359,13 @@ export default class exchangedit extends React.Component{ this.setState({tempdata:this.state.tempdata}) let value = e.target.value == "" ? 0 : e.target.value; 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].stock = value - this.state.tempdata[rowIndex].usage ; this.setState({tempdata:this.state.tempdata})