面积:
@@ -161,12 +161,6 @@
-
-
-
-
-
-
@@ -245,8 +239,6 @@ export default {
id: '',
roomId: '',
tenantName: '',
- tenantPhone: '',
- tenantIdCard: '',
startDate: '',
endDate: '',
rent: '',
@@ -338,8 +330,7 @@ export default {
const data = response.data || response
this.rentalHistory = data.map(rental => {
return {
- ...rental,
- tenantName: rental.Tenant ? rental.Tenant.name : ''
+ ...rental
}
})
@@ -431,6 +422,11 @@ export default {
})
},
async handleCheckout() {
+ if (!this.room.id) {
+ this.$message.error('房间信息加载失败,无法进行退房操作')
+ return
+ }
+
this.$confirm('确定要退房吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -439,7 +435,7 @@ export default {
try {
// 找到当前房间的租房记录
const roomId = this.$route.params.id
- const rental = this.rentals.find(r => r.roomId == roomId && r.status === 'active')
+ const rental = this.rentalHistory.find(r => r.roomId == roomId && r.status === 'active')
if (rental) {
// 更新租房记录状态
@@ -454,7 +450,8 @@ export default {
this.$message.error('未找到活跃的租房记录')
}
} catch (error) {
- this.$message.error('退房失败')
+ console.error('退房失败:', error)
+ this.$message.error('退房失败:' + (error.message || '未知错误'))
}
}).catch(() => {
// 取消退房
@@ -635,11 +632,26 @@ export default {
type: 'danger'
}).then(async () => {
try {
+ // 先获取租赁记录的详细信息
+ const rental = this.rentalHistory.find(r => r.id == id)
+
+ // 删除租赁记录
await rentalApi.delete(id)
this.$message.success('租赁记录删除成功')
+
+ // 如果是在租状态,更新房间状态为空房
+ if (rental && rental.status === 'active' && rental.roomId) {
+ await roomApi.update(rental.roomId, {
+ status: 'empty',
+ subStatus: 'normal'
+ })
+ this.$message.success('房间状态已更新为空房')
+ }
+
this.loadData()
} catch (error) {
- this.$message.error('删除失败')
+ console.error('删除失败:', error)
+ this.$message.error('删除失败:' + (error.message || '未知错误'))
}
}).catch(() => {
// 取消删除
diff --git a/src/views/rental/Edit.vue b/src/views/rental/Edit.vue
index 8dc3c69..51e78c8 100644
--- a/src/views/rental/Edit.vue
+++ b/src/views/rental/Edit.vue
@@ -21,12 +21,6 @@
-
-
-
-
-
-
合同信息
-
租客: {{ room.Rentals[0].Tenant.name }}
+
租客: {{ room.Rentals[0].tenantName }}
租期: {{ room.Rentals[0].startDate }} 至 {{ room.Rentals[0].endDate }}
diff --git a/src/views/tenant/Add.vue b/src/views/tenant/Add.vue
deleted file mode 100644
index a62825b..0000000
--- a/src/views/tenant/Add.vue
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 提交
- 重置
- 返回
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/views/tenant/Edit.vue b/src/views/tenant/Edit.vue
deleted file mode 100644
index fbfca12..0000000
--- a/src/views/tenant/Edit.vue
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 提交
- 重置
- 返回
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/views/tenant/List.vue b/src/views/tenant/List.vue
deleted file mode 100644
index c82b052..0000000
--- a/src/views/tenant/List.vue
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 搜索
- 重置
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file