MrShi
2024-12-05 f67075dfb8757171d3287a31f9fc48cd15d37bd7
admin/src/views/contract/components/terminateLease.vue
@@ -121,7 +121,7 @@
                        <div style="display: flex; align-items: center;">
                            <el-tag type="success" v-if="row.billType === 0">收</el-tag>
                            <el-tag type="warning" v-if="row.billType === 1">付</el-tag>
                            <span style="margin-left: 10px;">{{row.price}}</span>
                            <span style="margin-left: 10px;">{{Math.abs(row.price)}}</span>
                        </div>
                    </template>
                </el-table-column>
@@ -155,9 +155,12 @@
                        {{row.startDate}} ~ {{row.endDate}}
                    </template>
                </el-table-column>
<!--                prop="receivableFee"-->
                <el-table-column
                    prop="receivableFee"
                    label="应收金额">
                    <template slot-scope="{row}">
                        0
                    </template>
                </el-table-column>
                <el-table-column
                    prop="actReceivableFee"
@@ -197,7 +200,7 @@
  import AddCollectionBill from './addCollectionBill'
  import AddPaymentBill from './addPaymentBill'
  import { getUserList } from '@/api/system/user'
  import { backRent, getCanBackBill } from '@/api/contract'
  import { backRent, getCanBackBill, findForBills } from '@/api/contract'
  import { mapState } from 'vuex'
  export default {
    name: "terminateLease",
@@ -255,36 +258,24 @@
        this.info = info
        this.form.id = info.id
        this.form.btSignDate = this.getDay()
        console.log(this.userInfo)
        this.form.btUserId = this.userInfo.id
        this.$nextTick(() => {
          this.$refs.form.resetFields()
        })
        this.info.canBackRentBills.forEach(item => {
          if ([2,3,7].includes(item.costType)) {
            this.$set(item, 'billType', 1)
            this.$set(item, 'price', item.actReceivableFee)
          } else {
            this.$set(item, 'receivableFeeCopy', item.receivableFee)
            this.$set(item, 'receivableFee', item.needReceivableFee)
            this.$set(item, 'price', item.needReceivableFee)
          }
        })
        this.info.terminateList = this.info.canBackRentBills.filter(item => {
          if ([0,1,4,5,6].includes(item.costType)) {
            item.billTypeCopy = JSON.parse(JSON.stringify(item.billType))
            return item
          }
        })
        this.info.depositList = this.info.canBackRentBills.filter(item => {
          if ([2,3,7].includes(item.costType)) {
            item.billTypeCopy = JSON.parse(JSON.stringify(item.billType))
            return item
          }
        })
        this.info.terminateList = []
        this.info.depositList = []
        this.form.btDate = this.getDay()
        this.countData()
        this.getUser()
        this.changeBtDate(this.form.btDate)
        this.visible = true
      },
      getDayTime () {
        const today = new Date();
        const year = today.getFullYear();
        const month = today.getMonth() + 1;
        const day = today.getDate();
        return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
      },
      countData () {
        const arr = [...this.info.terminateList, ...this.info.depositList]
@@ -292,9 +283,9 @@
        let total2 = 0
        arr.forEach(item => {
          if (item.billType === 0) {
            total1 += Number(item.price)
            total1 += Math.abs(Number(item.price))
          } else if (item.billType === 1) {
            total2 += Number(item.price)
            total2 += Math.abs(Number(item.price))
          }
        })
        this.receivable = total1.toFixed(2)
@@ -303,7 +294,7 @@
      getDay () {
        const today = new Date();
        const year = today.getFullYear();
        const month = today.getMonth() + 1; // 月份是从 0 开始的,因此需要加 1
        const month = today.getMonth() + 1;
        const day = today.getDate();
        return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
      },
@@ -331,19 +322,33 @@
          billTypeCopy: 1
        }, { startDate: this.info.startDate, endDate: this.form.btDate })
      },
      changeBtDate (planPayDateEnd) {
      changeBtDate (btDate) {
        this.loading = true
        getCanBackBill({
          contractId: this.info.id,
          planPayDateEnd
        findForBills({
          id: this.info.id,
          btDate
        }).then(res => {
          res.forEach(item => {
            this.$set(item, 'receivableFeeCopy', item.receivableFee)
            this.$set(item, 'receivableFee', item.needReceivableFee)
            this.$set(item, 'price', item.needReceivableFee)
          res.canBackRentBills.forEach(item => {
            if ([2,3,7].includes(item.costType)) {
              this.$set(item, 'billType', 1)
              this.$set(item, 'price', item.actReceivableFee)
            } else {
              this.$set(item, 'receivableFeeCopy', item.receivableFee)
              this.$set(item, 'receivableFee', item.needReceivableFee)
              this.$set(item, 'price', (item.needReceivableFee - item.actReceivableFee).toFixed(2))
            }
          })
          this.info.terminateList = res.filter(item => {
          this.info.terminateList = res.canBackRentBills.filter(item => {
            if ([0,1,4,5,6].includes(item.costType)) {
              item.billTypeCopy = JSON.parse(JSON.stringify(item.billType))
              if (Number(item.price) < 0) {
                item.billType = 1
              }
              return item
            }
          })
          this.info.depositList = res.canBackRentBills.filter(item => {
            if ([2,3,7].includes(item.costType)) {
              item.billTypeCopy = JSON.parse(JSON.stringify(item.billType))
              return item
            }
@@ -354,11 +359,10 @@
        })
      },
      getObjS (obj) {
        console.log(obj)
        obj.startDate = obj.startDate.substring(0, 10)
        obj.endDate = obj.endDate.substring(0, 10)
        this.info.terminateList.push(obj)
        // this.info.terminateList.forEach(item => {
        //   item.receivableFee = Number(item.receivableFee) + 1
        //   item.receivableFee = Number(item.receivableFee) - 1
        // })
        this.countData()
      },
      confirm () {