From 22e97d76d38070506accdeee4ef78c919fd3cf78 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期六, 30 十一月 2024 10:34:43 +0800
Subject: [PATCH] 开发

---
 admin/src/views/contract/components/terminateLease.vue |  112 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 80 insertions(+), 32 deletions(-)

diff --git a/admin/src/views/contract/components/terminateLease.vue b/admin/src/views/contract/components/terminateLease.vue
index ed32531..982e7f0 100644
--- a/admin/src/views/contract/components/terminateLease.vue
+++ b/admin/src/views/contract/components/terminateLease.vue
@@ -24,6 +24,7 @@
                             </el-select>
                         </el-form-item>
                         <el-form-item label="閫�绉熸棩鏈�" prop="btDate" style="width: 33%;">
+<!--                            @change="changeBtDate"-->
                             <el-date-picker
                                 v-model="form.btDate"
                                 type="date"
@@ -69,13 +70,14 @@
             <div class="title">
                 <span>閫�绉熶俊鎭�</span>
                 <div style="display: flex; align-items: center;">
-                    <el-button type="primary" @click="$refs.addCollectionBill.open('鍒涘缓鏀舵璐﹀崟', { contractCode: info.code, contractId: info.id, renterName: info.renterName, renterId: info.renterId, billType: 0, billTypeCopy: 0, feeType: 0 })">娣诲姞鏀舵</el-button>
-                    <el-button type="primary" @click="$refs.AddPaymentBill.open('鍒涘缓浠樻璐﹀崟', { contractCode: info.code, contractId: info.id, renterName: info.renterName, renterId: info.renterId, billType: 1, billTypeCopy: 1 })">娣诲姞浠樻</el-button>
+                    <el-button type="primary" @click="addZD">娣诲姞鏀舵</el-button>
+                    <el-button type="primary" @click="addFK">娣诲姞浠樻</el-button>
                 </div>
             </div>
             <el-table
                 :data="info.terminateList"
                 border
+                v-loading="loading"
                 style="width: 100%; margin-bottom: 15px;">
                 <el-table-column
                     prop="code"
@@ -193,7 +195,7 @@
   import AddCollectionBill from './addCollectionBill'
   import AddPaymentBill from './addPaymentBill'
   import { getUserList } from '@/api/system/user'
-  import { backRent } from '@/api/contract'
+  import { backRent, getCanBackBill } from '@/api/contract'
   export default {
     name: "terminateLease",
     components: {
@@ -236,7 +238,9 @@
         agentList: [],
 
         receivable: '',
-        meet: ''
+        meet: '',
+        
+        loading: false
       }
     },
     watch: {
@@ -264,28 +268,74 @@
         this.title = title
         this.info = info
         this.form.id = info.id
-        this.info.billList.forEach(item => {
+        this.info.canBackRentBills.forEach(item => {
           this.$set(item, 'receivableFeeCopy', item.receivableFee)
+          this.$set(item, 'receivableFee', item.needReceivableFee)
           if ([2,3,7].includes(item.costType)) {
+            this.$set(item, 'billType', 1)
             this.$set(item, 'price', item.actReceivableFee)
           } else {
-            this.$set(item, 'price', item.receivableFee)
+            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 = item.billType
+            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 = item.billType
+            item.billTypeCopy = JSON.parse(JSON.stringify(item.billType))
             return item
           }
         })
         this.getUser()
         this.visible = true
+      },
+      addZD () {
+        if (!this.form.btDate) return this.$message.warning('璇烽�夋嫨閫�绉熸棩鏈�')
+        this.$refs.addCollectionBill.open('鍒涘缓鏀舵璐﹀崟', {
+          contractCode: this.info.code,
+          contractId: this.info.id,
+          renterName: this.info.renterName,
+          renterId: this.info.renterId,
+          billType: 0,
+          billTypeCopy: 0,
+          feeType: 0
+        }, { startDate: this.info.startDate, endDate: this.form.btDate })
+      },
+      addFK () {
+        if (!this.form.btDate) return this.$message.warning('璇烽�夋嫨閫�绉熸棩鏈�')
+        this.$refs.AddPaymentBill.open('鍒涘缓浠樻璐﹀崟', {
+          contractCode: this.info.code,
+          contractId: this.info.id,
+          renterName: this.info.renterName,
+          renterId: this.info.renterId,
+          billType: 1,
+          billTypeCopy: 1
+        }, { startDate: this.info.startDate, endDate: this.form.btDate })
+      },
+      changeBtDate (planPayDateEnd) {
+        this.loading = true
+        getCanBackBill({
+          contractId: this.info.id,
+          planPayDateEnd
+        }).then(res => {
+          res.forEach(item => {
+            this.$set(item, 'receivableFeeCopy', item.receivableFee)
+            this.$set(item, 'receivableFee', item.needReceivableFee)
+            this.$set(item, 'price', item.needReceivableFee)
+          })
+          this.info.terminateList = res.filter(item => {
+            if ([0,1,4,5,6].includes(item.costType)) {
+              item.billTypeCopy = JSON.parse(JSON.stringify(item.billType))
+              return item
+            }
+          })
+        }).finally(() => {
+          this.loading = false
+        })
       },
       getObjS (obj) {
         this.info.terminateList.push(obj)
@@ -336,34 +386,32 @@
           row.price = 0
           this.$message.warning('涓嶈兘澶т簬鍘熷搴旀敹浠橀噾棰�')
         } else {
-          row.price = Number(num) - row.actReceivableFee
-          // 鏀�
-          if (row.billTypeCopy === 0) {
-            if (row.price > 0) {
-              row.billType = 0
-            } else if (row.price < 0) {
-              row.billType = 1
+          if (num) {
+            row.price = Number(num) - row.actReceivableFee
+            // 鏀�
+            if (row.billTypeCopy === 0) {
+              if (row.price > 0) {
+                row.billType = 0
+              } else if (row.price < 0) {
+                row.billType = 1
+              } else {
+                row.billType = 0
+              }
             } else {
-              row.billType = 0
+              if (row.price > 0) {
+                row.billType = 1
+              } else if (row.price < 0) {
+                row.billType = 0
+              } else {
+                row.billType = 1
+              }
             }
           } else {
-            if (row.price > 0) {
-              row.billType = 1
-            } else if (row.price < 0) {
-              row.billType = 0
-            } else {
-              row.billType = 1
-            }
+            row.price = 0
+            row.billType = row.billTypeCopy
+            console.log('billTypeCopy', row.billTypeCopy)
           }
-          // if (row.price > 0) {
-          //   row.billType = 0
-          // } else if (row.price < 0) {
-          //   row.billType = 1
-          // }
-          row.price = String(row.price)
-          if (row.price.indexOf('-') > 0) {
-            row.price = row.price.substring(0, row.price.length)
-          }
+          row.price = Math.abs(row.price);
         }
       }
     }

--
Gitblit v1.9.3