免租金 v-decorator如何取值

这边是vue2+antd+使用的是v-decorator  

那么如果想要获取表单的值需要getFieldsValue

getFieldsValue获取一组输入控件的值,如不传入参数,则获取全部组件的值
 <a-input-number v-decorator="['freeRentMonth', { rules: validatorRules.inputIf.rules }]" :min="0" @change="changedataSource" />
                      <span class="text"> (免租金额:{{automatic}})</span>
  data() {
    return {
     
      visible: false,
      visible2: false,
      formData: {},
      form: null,

      validatorRules: {
        // 表单验证
        inputIf: { rules: [{ required: true, message: "此项不能为空" }] },
        uploadIf: { rules: [{ required: true, message: "请上传" }] },
      },
      editForm: this.$form.createForm(this),
      dataSource: [],
      loading: false,
      type: "add",
      title: "",
      automatic: '待计算'
    };
  },

   // 计算 资产租金
    changedataSource() {
      if (this.houseType == 1) {
        this.dataSource = this.dataSource.map((item) => {
          return {
            ...item,
            areas: Number(item.areas),
            monthRentMoney: item.assetRentAreas > 0 && item.singlePrice > 0 ? (item.singlePrice * item.assetRentAreas).toFixed(2) : 0,
            yearRentMoney: item.assetRentAreas > 0 && item.singlePrice > 0 ? (item.singlePrice * item.assetRentAreas * 12).toFixed(2) : 0,
          };
        });
      } else {
        this.dataSource = this.dataSource.map((item) => {
          return {
            ...item,
            monthRentMoney: item.number > 0 && item.singlePrice > 0 ? (item.number * item.singlePrice).toFixed(2) : 0,
            yearRentMoney: item.number > 0 && item.singlePrice > 0 ? (item.number * item.singlePrice * 12).toFixed(2) : 0,
          };
        });
      }
      this.$nextTick(()=>{
        let freeRentMonth = this.editForm.getFieldValue('freeRentMonth')
        if(freeRentMonth===0){
          this.automatic = 0
          return
        }
        if(this.dataSource.every(item=>{return item.monthRentMoney>0})&&freeRentMonth>0){
          let mMoney = 0
          this.dataSource.forEach(item=>{
            mMoney=mMoney+Number(item.monthRentMoney)
          })
          this.automatic = mMoney*freeRentMonth.toFixed(2)
        }else{
          this.automatic = '待计算'
        }
      })
     
    },

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值