From fb1a1e3ca9ae1d17338814f59d3d38e02829686a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Fri, 10 Dec 2021 10:02:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/commodity/goodedit.js | 11 +++++++++-- src/pages/exchangecode/edit/edit.js | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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})