输入框金额相互转换

    // 输入框输入时做校验处理   本次金额输入框要求展示为千分位隔开,但是输入时不能有千分位的逗号,因此在聚焦和失焦事件做了一些处理
    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'])
      }
    },


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值