Files
gjt_mini/pages/maintain/index.vue
2025-12-30 09:44:46 +08:00

310 lines
7.9 KiB
Vue

<template>
<view>
<u-sticky>
<view style="background-color: #fff">
<u-subsection
mode="subsection"
:list="list"
:current="current"
@change="sectionChange"
activeColor="#7ba746"
:fontSize="30"
>
</u-subsection>
</view>
<u-search
placeholder="请输入"
v-model="keyword"
:showAction="false"
@search="searchList()"
></u-search>
</u-sticky>
<view class="list">
<view class="item" v-for="item in dataList" :key="item.id">
<view class="line" v-if="item.maintenanceStatus === 0">
<u-badge :isDot="true" type="error"></u-badge>
<view class="text-normal" style="margin-left: 10rpx">未保养</view>
</view>
<view class="line" v-else-if="item.maintenanceStatus == 1">
<u-badge :isDot="true" type="success"></u-badge>
<view class="text-normal" style="margin-left: 10rpx">已保养</view>
</view>
<!-- <u-badge
:isDot="true"
type="warning"
v-if="item.preparationStatus === 0"
></u-badge>
<u-badge
:isDot="true"
type="error"
v-if="item.preparationStatus === 2"
></u-badge>
<u-badge
:isDot="true"
type="success"
v-if="item.preparationStatus === 1"
></u-badge> -->
<view class="line">
<view class="text-small"
>项目名称: {{ item.projectName || "--" }}</view
>
</view>
<view class="line">
<view class="text-small"
>资产状态: {{ item.truckRentStatusName }}</view
>
</view>
<view class="line" v-if="current === 1">
<view class="text-small"
>维修站: {{ item.maintainSiteName || "--" }}</view
>
</view>
<view class="line">
<view class="text-small">负责人: {{ item.handlerName || "--" }}</view>
</view>
<view
class="line"
v-if="current === 1"
style="justify-content: space-between"
>
<view class="text-small left"
>公司应支付: {{ item.companyPayable || 0 }}</view
>
<view class="text-small"
>公司已支付: {{ item.companyPayed || 0 }}</view
>
</view>
<view
class="line"
v-if="current === 1"
style="justify-content: space-between"
>
<view class="text-small left"
>客户应支付: {{ item.customerPayable || 0 }}</view
>
<view class="text-small"
>客户已支付: {{ item.customerPayed || 0 }}</view
>
</view>
<view class="line" style="justify-content: flex-end">
<view class="text-small right">车牌号: {{ item.plateNumber }}</view>
</view>
<view class="buttons">
<!-- 仅待运维备车的数据才显示编辑按钮 v-if="[0, 2].includes(item.preparationStatus)" -->
<button
@tap="goto"
:data-url="`/pages/maintain/detail?id=${item.id}`"
>
编辑
</button>
<button
@tap="goto"
:data-url="`/pages/maintain/detail?id=${item.id}&isRead=1`"
>
查看
</button>
</view>
</view>
<view class="no-more" v-if="noMoreData">没有更多数据了</view>
</view>
<view
clas="line"
style="margin-top: 150rpx"
v-if="!dataList || dataList.length === 0"
>
<u-empty mode="search" text="暂无数据" width="400" textSize="16">
</u-empty
></view>
<u-loading-page
bg-color="#ffffff"
:loading="loading"
color="#7ba746"
font-size="24"
></u-loading-page>
</view>
</template>
<script>
export default {
options: {
styleIsolation: "shared", // 解除样式隔离
},
data() {
return {
current: 0,
list: ["未保养", "已保养"],
queryPage: {
pageNo: 1, // 页码
pageSize: 10, //每页查询条数
total: 0, //总页数
pages: -1, //总页数
},
dataList: [],
pageNo: 1,
noMoreData: false,
loading: false,
keyword: "",
};
},
methods: {
// 新增的搜索方法
searchList() {
this.queryPage.plateNumber = this.keyword.trim(); // 设置车牌号条件
this.queryPage.pageNo = 1; // 重置页码为1
this.dataList = []; // 清空数据列表
this.noMoreData = false; // 重置没有更多数据的标志
this.loadmore(); // 重新加载数据
},
sectionChange(index) {
this.current = index;
this.queryPage.plateNumber = ""; // 清空搜索关键字
this.keyword = ""; // 清空搜索关键字
if (index == 1) {
// 显示已整备
this.queryPage.maintenanceStatus = 1;
} else {
// 显示未整备
this.queryPage.maintenanceStatus = 0;
}
this.queryPage.pageNo = 1;
this.dataList = [];
this.loadmore();
},
formatDateTime(obj) {
if (obj == null) {
return "";
}
let date = new Date(obj);
let y = 1900 + date.getYear();
let m = "0" + (date.getMonth() + 1);
let d = "0" + date.getDate();
return (
y +
"-" +
m.substring(m.length - 2, m.length) +
"-" +
d.substring(d.length - 2, d.length)
);
},
loadmore() {
this.loading = true;
this.$api.maintainTodo
.queryPageList(this.queryPage)
.then((res) => {
this.queryPage.pageNo = res.data.current;
this.queryPage.pages = res.data.pages;
this.queryPage.total = res.data.total;
this.dataList.push(...(res.data.records || []));
this.loading = false;
})
.catch((errors) => {
this.loading = false;
});
},
goto(e) {
uni.navigateTo({ url: e.target.dataset.url });
},
},
onLoad() {},
onPullDownRefresh() {
this.sectionChange(this.current);
uni.stopPullDownRefresh(); //刷新数据之后停止刷新效果
},
onReachBottom() {
console.log("触底了");
//当前页数小于总页数
if (this.queryPage.pageNo < this.queryPage.pages) {
this.queryPage.pageNo++;
this.loadmore();
} else {
this.noMoreData = true;
console.log("没有更多数据了");
}
},
onShow() {
this.sectionChange(this.current);
},
};
</script>
<style lang="less" scoped>
/deep/ .u-badge--error {
background-color: red !important;
}
/deep/ .u-badge--success {
background-color: #4cd964 !important;
}
/deep/ .u-badge--dot {
height: 20rpx !important;
width: 20rpx !important;
}
/deep/ .u-search {
background: #d7d7d7 !important;
padding: 20rpx 10rpx !important;
}
// /deep/ .u-search__content__input {
// height: 50rpx !important;
// padding-top: 20rpx !important; /* 上边距 */
// padding-bottom: 20rpx !important; /* 下边距 */
// }
.list {
background: #d7d7d7;
padding: 0 20px 20rpx;
.item {
background: white;
width: calc(100% - 40rpx);
padding: 20rpx;
margin-bottom: 20rpx;
position: relative;
border-radius: 15rpx;
.line {
display: flex;
align-items: center;
margin-bottom: 15rpx;
.left {
margin-right: 50rpx;
width: 300rpx;
}
.text-small {
font-size: x-small;
}
.text-normal {
font-size: small;
}
}
.buttons {
position: absolute;
top: 20rpx;
right: 20rpx;
button {
width: 130rpx;
height: 50rpx;
padding: 12rpx 0;
font-size: 26rpx;
line-height: 26rpx;
margin-bottom: 10rpx;
}
}
}
.no-more {
width: 100%;
text-align: center;
font-size: xx-small;
color: white;
}
}
</style>