From 2147063834c5c3c8035124e2d24dc6c4f031c6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Wed, 1 Dec 2021 18:49:12 +0800 Subject: [PATCH] Update step2.js --- src/pages/plan/add/step2.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index 8490721c..f2f2b8e9 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -449,26 +449,33 @@ export default class acclist extends React.Component{ } - onNameChange(e,row){ - let rowIndex =this.state.tempdata.findIndex((o)=>{return o.product_id == row.product_id}) - - this.state.tempdata[rowIndex].product_name =e.target.value; - this.setState({tempdata:this.state.tempdata}) + onNameChange(e,row,rowIndex){ + + this.state.tempdata[rowIndex].product_name =e.target.value; + + let arr = _.map(this.state.tempdata,(res)=>{ + let obj = {}; + obj.key = res.product_id; + obj.text= res.product_name; + return obj; + }) + this.setState({rankoptions:arr}) + this.setState({rank:arr}) + this.setState({tempdata:this.state.tempdata}) + } - onQuantityChange(e,row){ - let rowIndex =this.state.tempdata.findIndex((o)=>{return o.product_id == row.product_id}) - + onQuantityChange(e,row,rowIndex){ + this.state.tempdata[rowIndex].quantity =e.target.value; this.setState({tempdata:this.state.tempdata}) } - onPriceChange(e,row){ + onPriceChange(e,row,rowIndex){ let str = e.target.value; let value= str.replace(/[^\d^\.]+/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.') - let rowIndex =this.state.tempdata.findIndex((o)=>{return o.product_id == row.product_id}) - + this.state.tempdata[rowIndex].contract_price = value; this.setState({tempdata:this.state.tempdata}) } @@ -927,18 +934,18 @@ export default class acclist extends React.Component{ }} - ComponentHandler={(com,rowData)=>{ + ComponentHandler={(com,rowData,rowIndex)=>{ if(com=="product_name") { - return {this.onNameChange(e,rowData)}} /> + return {this.onNameChange(e,rowData,rowIndex)}} /> } if(com=="quantity") { - return {this.onQuantityChange(e,rowData)}} /> + return {this.onQuantityChange(e,rowData,rowIndex)}} /> } if(com =="contract_price" ) { - return {this.onPriceChange(e,rowData)}} /> + return {this.onPriceChange(e,rowData,rowIndex)}} /> } if(com == "show_url")