table中循环一行生成n行子项

// 校验开票金额
    validApllyMoney () {
      this.initProductList = []
      this.initProductList = this.records // 复原产品列表
      const applyMoney = this.formData.productInfo.applyMoney // 申请开票金额
      // 申请开票金额不能大于最低开票金额
      // if (applyMoney > 12345) {
      //   this.$message({
      //     message: '开票金额不能大于最低开票金额',
      //     type: 'warning'
      //   })
      // }
      this.initProductList.map(item => {
        // 每个产品均分 开票金额
        const shareMoney = Number(applyMoney) * Number(item.iSumProportion.replace('%', '') / 100)
        // 单张发票最大额度
        const taxMoney = 100000 * (1 + (Number(item.iTaxRate) / 100))
        // 末尾发票额度
        const lastTaxMoney = shareMoney % taxMoney
        // 申请开票金额*备案金额占比/10w*(1+税率%) 要新增的行数
        const addLength = shareMoney / taxMoney
        console.log(shareMoney, 'shareMoney', taxMoney, 'taxMoney', lastTaxMoney, 'lastTaxMoney', addLength, 'addLength')
        // 循环遍历添加行数
        const addLen = Math.ceil(addLength)
        var self = this
        for (let i = 0; i < addLen; i++) {
          // 克隆下item 如果不克隆相当于 循环n次都在一个item上更改;现在要在n个item上改
          let itemCopy = JSON.parse(JSON.stringify(item))
          if (i === addLen - 1) {
            // 生成最大开票含税金额 ;最后一位输入开票额取余最大税额赋值,其他最大税额;
            itemCopy.taxAmount = lastTaxMoney
          } else {
            // 平均开票金额除
            itemCopy.taxAmount = taxMoney
          }
          // 最后一位输入开票额取余最大税额赋值
          self.buffArr.push(itemCopy)
        }
      })
      this.formData.productInfo.productList = this.buffArr
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值