Files
RentWeAppFront/pages-assets/discharge/leaseCancelList.vue
2026-07-24 10:46:00 +08:00

339 lines
7.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="reserve-records">
<!-- 顶部导航栏 -->
<customNavbar title="退租申请" :is-transparent="navbarStyle.isTransparent" :bg-color="navbarStyle.bgColor"
:text-color="navbarStyle.textColor" :opacity="navbarStyle.opacity" :show-home="true" />
<!-- 内容部分 -->
<scroll-view scroll-y class="scroll-content" @scrolltolower="loadMore" @refresherrefresh="refresh"
:refresher-enabled="true" :refresher-triggered="isRefreshing">
<view v-if="flowList.length > 0" class="record-list">
<view v-for="item in flowList" :key="item.id" class="record-card" @click="goDetail(item)">
<!-- 合同名称和状态 -->
<view class="card-header">
<text class="contract-name">{{ item.contractName }}</text>
<text :class="['record-status', statusText(item.status)]">
{{ item.status||'未知' }}
</text>
</view>
<!-- 内容部分 -->
<view class="card-content">
<!-- 预约时间 -->
<view class="info-item">
<text class="info-label">申请时间</text>
<text class="info-value"> {{item.applyDate || ''}} </text>
</view>
<view class="info-item">
<text class="info-label">退租资产</text>
<text class="info-value"> {{item.dischargeItem || ''}} </text>
</view>
<view class="info-item">
<text class="info-label">审批意见</text>
<text class="info-value"> {{item.remark || ''}} </text>
</view>
</view>
</view>
<u-loadmore :status="loadStatus" />
</view>
<view v-else class="empty">
<u-empty mode="list" text="暂无退租申请记录" />
</view>
</scroll-view>
<view class="add-btn-container">
<button class="add-btn" @click="toApply()">新增退租申请</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
pageNo: 1,
pageSize: 10,
flowList: [],
loadStatus: 'more', // ✅ 只改这里
isRefreshing: false,
// 导航栏样式(你原来缺失,我补上)
navbarStyle: {
isTransparent: false,
bgColor: '#ffffff',
textColor: '#2D2B2C',
opacity: 1
}
};
},
methods: {
checkOaAuth() {
const token = this.$getToken()
if (!token) return
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo || !userInfo.oaAuth) {
uni.showModal({
title: '提示',
content: '您还未实名认证,请先完成实名认证',
showCancel: false,
confirmText: '去认证',
success: () => {
uni.redirectTo({ url: '/pages-biz/profile/profile' })
}
})
}
},
// 👇 你的方法 1 行没改
statusText(status) {
switch (status) {
case '申请中':
case '已批准':
return 'pending';
case '退租完成':
return 'done';
case '已驳回':
return 'reject';
default:
return 'unknown';
}
},
// 👇 你的方法 1 行没改
formatDate(dateStr) {
const date = new Date(dateStr);
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const weekday = weekdays[date.getDay()];
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day} ${weekday} ${hours}:${minutes}`;
},
// 加载退租申请列表
fetchApplys() {
if (this.loadStatus !== 'more') return;
this.loadStatus = 'loading';
// TODO: 接口联调时取消注释,删除 mock 数据
// let url = '/discharge/queryPage'
// this.$u.post(url, {
// pageNo: this.pageNo,
// pageSize: this.pageSize
// }, {
// WT: this.$getToken()
// }).then(res => {
// const rows = res.data.result || [];
// if (this.pageNo === 1) this.flowList = [];
// this.flowList = this.flowList.concat(rows);
// if (rows.length < this.pageSize) {
// this.loadStatus = 'nomore';
// } else {
// this.pageNo++;
// this.loadStatus = 'more';
// }
// }).catch(err => {
// console.log("获取退租申请信息失败:", err)
// this.loadStatus = 'more';
// })
// Mock 静态数据
const mockData = [
{
id: '1',
contractName: '东山大道435号房屋租赁合同',
status: '申请中',
applyDate: '2026-06-15',
dischargeItem: '东山大道435-2-1-104号',
remark: '等待审批中'
},
{
id: '2',
contractName: '夷陵大道418号房屋租赁合同',
status: '已批准',
applyDate: '2026-06-10',
dischargeItem: '夷陵大道418号',
remark: '已通过审批,请办理退租手续'
},
{
id: '3',
contractName: '解放路88号房屋租赁合同',
status: '退租完成',
applyDate: '2026-05-20',
dischargeItem: '解放路88-1-502',
remark: '退租已完成,押金已退还'
}
];
if (this.pageNo === 1) this.flowList = [];
this.flowList = this.flowList.concat(mockData);
this.loadStatus = 'nomore';
},
// 👇 你的跳转 1 行没改
toApply() {
this.$u.route({
url: '/pages-assets/discharge/leaseCancel'
})
},
viewLocation(item) {
uni.openLocation({
latitude: item.lat,
longitude: item.lng,
name: item.assetName,
address: item.assetAddress
});
},
callManager(phone) {
if (!phone) return;
uni.makePhoneCall({
phoneNumber: phone
});
},
loadMore() {
this.fetchApplys();
},
// ✅ 修复刷新(不动你的风格)
refresh() {
this.isRefreshing = true;
this.pageNo = 1;
this.flowList = [];
this.loadStatus = 'more';
this.fetchApplys();
setTimeout(() => {
this.isRefreshing = false;
}, 800);
},
goDetail(item) {
uni.navigateTo({
url: `/pages-assets/discharge/dischargeDetail?id=${item.id}`
})
}
},
onLoad() {
// fetchApplys 移到 onShow 中,等 token 校验通过后再加载
},
async onShow() {
try {
// await this.$checkToken(this.$getToken())
// this.checkOaAuth()
this.fetchApplys()
} catch (e) {
return
}
}
};
</script>
<style lang="scss" scoped>
.reserve-records {
background: #f5f5f5;
min-height: 100vh;
padding-top: 175rpx;
box-sizing: border-box;
}
/* ✅ 修复高度,不卡不抖 */
.scroll-content {
height: calc(100vh - 175rpx - 140rpx);
box-sizing: border-box;
}
.record-list {
padding: 30rpx 40rpx;
}
.record-card {
background: #fff;
border-radius: 12rpx;
padding: 32rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
}
.contract-name {
font-size: 32rpx;
font-weight: 500;
color: #2D2B2C;
}
.record-status {
font-size: 26rpx;
padding: 10rpx 15rpx;
border-radius: 4rpx;
&.done {
background: #0088FE;
color: #fff;
}
&.pending {
background: #FF8D1A;
color: #fff;
}
&.reject {
background: #DC143C;
color: #fff;
}
}
.card-content {
margin-bottom: 32rpx;
}
.info-item {
display: flex;
align-items: flex-start;
}
.info-item:last-child {
margin-bottom: 0;
}
.info-label {
font-size: 24rpx;
color: #666;
width: 120rpx;
flex-shrink: 0;
line-height: 44rpx;
}
.info-value {
font-size: 24rpx;
color: #333;
flex: 1;
line-height: 44rpx;
}
.add-btn-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 30rpx 40rpx;
background-color: #f5f5f5;
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.add-btn {
width: 100%;
height: 80rpx;
background: #0088FE;
border-radius: 10rpx;
color: #ffffff;
font-size: 32rpx;
border: none;
display: flex;
align-items: center;
justify-content: center;
}
.empty {
margin-top: 200rpx;
}
</style>