lanan-app/pages/my/carManage.vue
2025-10-17 15:25:04 +08:00

393 lines
7.7 KiB
Vue
Raw Permalink 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="carManageContent">
<VNavigationBar class="navigationBar" title="车辆管理">
<template v-slot:extra>
<uni-icons size="28" type="plus" color="#fff" @click="goupdata('')"></uni-icons>
</template>
</VNavigationBar>
<scroll-view class="carManangeScrollView" scroll-y @scrolltolower="scrolltolower">
<!-- 顶部统计条 -->
<view class="statsContainer">
<!-- 车辆总数单独一行 -->
<view class="totalStatsRow">
<view class="totalStatCard">
<view class="totalStatValue">{{ statsOverview.totalCars || 0 }}</view>
<view class="totalStatLabel">车辆总数</view>
</view>
</view>
<!-- 分类统计一行最多4个 -->
<view class="categoryStatsGrid">
<view
class="categoryStatCard"
v-for="(count, category) in statsOverview.categoryCount"
:key="category"
>
<view class="categoryStatValue">{{ count }}</view>
<view class="categoryStatLabel">{{ category }}</view>
</view>
</view>
</view>
<view class="ail">
<view class="_box" v-for="(item,index) in carList" :key="index" @click="goupdata(item.id)">
<view class="_box-content">
<view class="img_">
<image :src="baseUrl+item.carImage" mode="aspectFill"></image>
</view>
<view class="right_">
<view class="cphInfo" style="">
<image class="cphIcon" src="../../static/icons/carManage/carNumIcon.png"
mode="aspectFit"></image>
<view class="cph">{{item.rescueCarNum}}</view>
</view>
<view class="right-top">
<view class="timesize">保养到期里程:</view>
<view class="time">{{item.carMaintenanceMileage}}</view>
</view>
<!-- <view class="right-top">
<view class="timesize">保养到期时间:</view>
<view class="time">{{item.carKeepTime}}</view>
</view> -->
<view class="right-top">
<view class="timesize">年检到期时间:</view>
<view class="time">{{item.carCheckTime}}</view>
</view>
</view>
</view>
<view class="_box-footer">
<view class="tag">{{item.rescueCarTypeStr}}</view>
<view class="tag">{{item.rescueCarBrand}}</view>
</view>
</view>
</view>
</scroll-view>
<tabBar msg="1"></tabBar>
<!-- <view class="anniu" @click="goupdata('')">
<u-icon name="plus" color="#fff" size="34"></u-icon>
</view> -->
</view>
</template>
<script>
import request from '../../utils/request'
import VNavigationBar from '@/components/VNavigationBar.vue'
import tabBarVue from '../../components/tabBar/tabBar.vue'
export default {
components: {
VNavigationBar,
tabBarVue
},
data() {
return {
baseUrl: this.$baseImageUrlNew,
carList: [],
searchName: null,
pageNum: 1,
pageSize: 10,
totalNum: '',
statsOverview: {
totalCars: 0,
categoryCount: {}
}
}
},
onShow() {
this.getCarList()
this.getStatsData()
// this.loadStatsData()
},
methods: {
// 根据分类名称返回对应图标
getCategoryIcon(category) {
const iconMap = {
'大拖车': '🚛',
'小拖车': '🚐',
'皮卡': '🛻',
'清障车': '🚨',
'吊车': '🏗️',
'救援车': '🚑',
'工程车': '🚜',
'货车': '📦'
};
// 如果有匹配的图标就返回,否则返回默认图标
return iconMap[category] || '🚙';
},
// 获取统计数据
async getStatsData() {
try {
const res = await request({
url: "/system/rescueCar/getStats",
method: 'get'
})
this.statsOverview = res.data
} catch (error) {
console.error('获取统计数据失败:', error)
uni.showToast({
title: '统计数据获取失败',
icon: 'none'
})
} finally {
this.statsLoading = false
}
},
scrolltolower() {
if (this.carList.length >= this.totalNum) {
uni.showToast({
title: '没有下一页数据',
icon: 'none'
})
} else {
this.pageNum++
this.getCarList()
}
},
getback() {
uni.navigateBack()
},
async getCarList() {
request({
url: "/system/rescueCar/list",
method: 'get',
params: {
rescueCarNum: this.searchName,
pageNum: this.pageNum,
pageSize: this.pageSize,
}
}).then(res => {
if (this.pageNum != 1) {
this.carList = this.carList.concat(res.rows)
} else {
this.carList = res.rows
}
console.log(this.carList.length);
this.totalNum = res.total
})
},
goupdata(id) {
uni.navigateTo({
url: '/pages/my/carManageForm?id=' + id
})
}
}
}
</script>
<style scoped lang="scss">
.statsContainer {
padding: 20rpx;
background: #f8f9fa;
}
// 车辆总数单独一行
.totalStatsRow {
margin-bottom: 20rpx;
}
.totalStatCard {
background: white;
border-radius: 12rpx;
padding: 30rpx;
text-align: center;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
}
.totalStatValue {
font-size: 48rpx;
font-weight: bold;
color: #333;
line-height: 1.2;
}
.totalStatLabel {
font-size: 28rpx;
color: #666;
margin-top: 8rpx;
}
// 分类统计网格布局
.categoryStatsGrid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16rpx;
}
.categoryStatCard {
background: white;
border-radius: 12rpx;
padding: 20rpx 12rpx;
text-align: center;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
min-height: 100rpx;
display: flex;
flex-direction: column;
justify-content: center;
}
.categoryStatValue {
font-size: 32rpx;
font-weight: bold;
color: #333;
line-height: 1.2;
}
.categoryStatLabel {
font-size: 22rpx;
color: #666;
margin-top: 6rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
// 响应式处理小屏幕时改为3列
@media (max-width: 750rpx) {
.categoryStatsGrid {
grid-template-columns: repeat(3, 1fr);
}
}
// 超小屏幕时改为2列
@media (max-width: 600rpx) {
.categoryStatsGrid {
grid-template-columns: repeat(2, 1fr);
}
}
.carManageContent {
height: 100%;
display: flex;
flex-direction: column;
background-color: #F7F8FC;
}
.carManangeScrollView {
flex: 1;
height: 0;
}
.top-icon {
display: flex;
align-items: center;
}
.ail {
width: 100%;
box-sizing: border-box;
padding: 15px;
}
._box {
width: 100%;
box-sizing: border-box;
padding: 50rpx 46rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.06);
border-radius: 16rpx;
margin: 24rpx 0;
}
._box-content {
display: flex;
align-items: center;
justify-content: space-between;
column-gap: 32rpx;
}
.img_ {
width: 196rpx;
height: 196rpx;
background: #D8D8D8;
border-radius: 16rpx;
overflow: hidden;
// border: 2rpx solid #979797;
image {
width: 100%;
height: 100%;
}
}
.right_ {
width: 70%;
}
.cphInfo {
display: flex;
align-items: center;
column-gap: 10rpx;
margin-bottom: 18rpx;
}
.cphIcon {
width: 100rpx;
height: 44rpx;
}
.cph {
font-weight: 500;
font-size: 32rpx;
color: #000000;
line-height: 1.5;
}
.right-top {
width: 100%;
display: flex;
align-items: center;
font-size: 28rpx;
color: #000000;
margin: 10rpx 0 0;
}
._box-footer {
display: flex;
align-items: center;
justify-content: flex-end;
column-gap: 40rpx;
padding-top: 22rpx;
}
.tag {
width: 104rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
background: rgba(70, 190, 55, 0.1);
border-radius: 4rpx;
font-size: 24rpx;
color: #30B922;
line-height: 1;
}
.anniu {
width: 55px;
height: 55px;
background: #0000ff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 30px;
right: 15px;
}
</style>