// 输入框输入时做校验处理 本次金额输入框要求展示为千分位隔开,但是输入时不能有千分位的逗号,因此在聚焦和失焦事件做了一些处理
upNum(lamt, row, type) {
// 模型金额输入时,校验,输入值实时传给原数组,保证原数组与页面数据同步
if (type === 1) {
const index = row.$index
this.newSec[index].approvedAmt = Number(lamt.replace(/[^\d]/g, ''))
this.boxMsg.secondQuotaResult[index].approvedAmt = _.cloneDeep(this.newSec[index].approvedAmt)
if (this.zeroAmt[index].approvedAmt < this.newSec[index].approvedAmt) {
// 只允许输入小于原来的值,不允许增加,一旦超过就恢复原值
this.newSec[index].approvedAmt = this.zeroAmt[index].approvedAmt
this.boxMsg.secondQuotaResult[index].approvedAmt = _.cloneDeep(this.newSec[index].approvedAmt)
return
}
} else {
const index = row.$index
this.newFir[index].approvedAmt = Number(lamt.replace(/[^\d]/g, ''))
this.boxMsg.firstQuotaResult[index].approvedAmt = _.cloneDeep(this.newFir[index].approvedAmt)
if (this.oneAmt[index].approvedAmt < this.newFir[index].approvedAmt) {
this.newFir[index].approvedAmt = this.oneAmt[index].approvedAmt
this.boxMsg.firstQuotaResult[index].approvedAmt = _.cloneDeep(this.newFir[index].approvedAmt)
return
}
}
},
// 失去焦点,金额转化为千分位
blur(index, type) {
Loading.start()
if (type === 1) {
if (this.oldAmteS[index].approvedAmt === this.boxMsg.secondQuotaResult[index].approvedAmt) {
this.newSec = _.cloneDeep(this.boxMsg.secondQuotaResult)
this.newSec.forEach(el => {
el.approvedAmt = this.moneyFormat(el.approvedAmt)
})
Loading.end()
} else {
this.linkageAdjustment(this.boxMsg.secondQuotaResult, 1)
}
} else {
if (this.oldAmteF[index].approvedAmt === this.boxMsg.firstQuotaResult[index].approvedAmt) {
this.newFir = _.cloneDeep(this.boxMsg.firstQuotaResult)
this.newFir.forEach(el => {
el.approvedAmt = this.moneyFormat(el.approvedAmt)
})
Loading.end()
} else {
this.linkageAdjustment(this.boxMsg.firstQuotaResult, 0)
}
}
},
// 获取焦点 把当前输入框的值替换为原数组的数据
focus(index, type) {
// type===1是复审金额
if (type === 1) {
this.$set(this.newSec[index], 'approvedAmt', this.boxMsg.secondQuotaResult[index]['approvedAmt'])
} else {
this.$set(this.newFir[index], 'approvedAmt', this.boxMsg.firstQuotaResult[index]['approvedAmt'])
}
},
输入框金额相互转换
于 2023-07-21 13:42:26 首次发布