diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 8004adf6..598da271 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -646,7 +646,8 @@ export default class acclist extends React.Component{ } onQuantityChange(e,row,rowIndex){ - this.state.tempdata[rowIndex].quantity =e.target.value; + this.state.tempdata[rowIndex].quantity =e.target.value == "" ? 0 : e.target.value; + this.state.tempdata[rowIndex].stock = e.target.value == "" ? 0 : e.target.value; this.setState({tempdata:this.state.tempdata}) } onPriceChange(e,row,rowIndex){ diff --git a/src/pages/exchangecode/edit/edit.js b/src/pages/exchangecode/edit/edit.js index 4235d2be..5b233c5f 100644 --- a/src/pages/exchangecode/edit/edit.js +++ b/src/pages/exchangecode/edit/edit.js @@ -355,9 +355,12 @@ export default class exchangedit extends React.Component{ this.setState({tempdata:this.state.tempdata}) } onQuantityChange(e,row){ + + 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}) - this.state.tempdata[rowIndex].quantity =e.target.value; - this.state.tempdata[rowIndex].stock =e.target.value - this.state.tempdata[rowIndex].usage ; + this.state.tempdata[rowIndex].quantity = value; + this.state.tempdata[rowIndex].stock = value - this.state.tempdata[rowIndex].usage ; this.setState({tempdata:this.state.tempdata}) } onPriceChange(e,row){ diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index 730c3537..bcf92bb6 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -231,6 +231,7 @@ export default class acclist extends React.Component{ sum += parseInt( o.quantity); }) + console.log("sum",sum) if(sum < this.state.codeInfo.issued) { @@ -487,9 +488,8 @@ export default class acclist extends React.Component{ } onQuantityChange(e,row,rowIndex){ - - this.state.tempdata[rowIndex].quantity =e.target.value; - this.state.tempdata[rowIndex].stock = e.target.value; + this.state.tempdata[rowIndex].quantity =e.target.value == "" ? 0 : e.target.value; + this.state.tempdata[rowIndex].stock = e.target.value == "" ? 0 : e.target.value; this.setState({tempdata:this.state.tempdata}) } onPriceChange(e,row,rowIndex){ diff --git a/src/pages/plan/key/edit.js b/src/pages/plan/key/edit.js index 37a3e434..20747e03 100644 --- a/src/pages/plan/key/edit.js +++ b/src/pages/plan/key/edit.js @@ -525,9 +525,12 @@ export default class acclist extends React.Component{ this.setState({tempdata:this.state.tempdata}) } onQuantityChange(e,row,rowIndex){ - - this.state.tempdata[rowIndex].stock = e.target.value - this.state.tempdata[rowIndex].usage; - this.state.tempdata[rowIndex].quantity =e.target.value; + let value = e.target.value == "" ? 0 : e.target.value; + + + + this.state.tempdata[rowIndex].stock = value - this.state.tempdata[rowIndex].usage; + this.state.tempdata[rowIndex].quantity =value; this.setState({tempdata:this.state.tempdata}) } onPriceChange(e,row,rowIndex){