Update add.js

This commit is contained in:
姜棚 2021-12-01 18:50:59 +08:00
parent 2147063834
commit 239294fe0c
1 changed files with 7 additions and 10 deletions

View File

@ -595,25 +595,22 @@ export default class acclist extends React.Component{
} }
onNameChange(e,row){ onNameChange(e,row,rowIndex){
let rowIndex =this.state.tempdata.findIndex((o)=>{return o.product_id == row.product_id})
this.state.tempdata[rowIndex].product_name =e.target.value; this.state.tempdata[rowIndex].product_name =e.target.value;
this.setState({tempdata:this.state.tempdata}) this.setState({tempdata:this.state.tempdata})
} }
onQuantityChange(e,row){ onQuantityChange(e,row,rowIndex){
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].quantity =e.target.value;
this.setState({tempdata:this.state.tempdata}) this.setState({tempdata:this.state.tempdata})
} }
onPriceChange(e,row){ onPriceChange(e,row,rowIndex){
let str = e.target.value; let str = e.target.value;
let value= str.replace(/[^\d^\.]+/g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.') 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.state.tempdata[rowIndex].contract_price = value;
this.setState({tempdata:this.state.tempdata}) this.setState({tempdata:this.state.tempdata})
@ -1014,18 +1011,18 @@ export default class acclist extends React.Component{
}} }}
ComponentHandler={(com,rowData)=>{ ComponentHandler={(com,rowData,rowIndex)=>{
if(com=="product_name") if(com=="product_name")
{ {
return <Input width={140} placeholder="请输入商品名称" value={rowData.product_name} onChange={(e)=>{this.onNameChange(e,rowData)}} /> return <Input width={140} placeholder="请输入商品名称" value={rowData.product_name} onChange={(e)=>{this.onNameChange(e,rowData,rowIndex)}} />
} }
if(com=="quantity") if(com=="quantity")
{ {
return <Input width={140} placeholder="请输入数量" type="number" value={rowData.quantity} onChange={(e)=>{this.onQuantityChange(e,rowData)}} /> return <Input width={140} placeholder="请输入数量" type="number" value={rowData.quantity} onChange={(e)=>{this.onQuantityChange(e,rowData,rowIndex)}} />
} }
if(com =="contract_price" ) if(com =="contract_price" )
{ {
return <Input width={140} placeholder="请输入合同价" value={rowData.contract_price} onChange={(e)=>{this.onPriceChange(e,rowData)}} /> return <Input width={140} placeholder="请输入合同价" value={rowData.contract_price} onChange={(e)=>{this.onPriceChange(e,rowData,rowIndex)}} />
} }
if(com == "show_url") if(com == "show_url")