lanan-app/pages/my/carManage.vue

393 lines
7.7 KiB
Vue
Raw Normal View History

2024-08-20 20:02:05 +08:00
<template>
2024-08-22 19:34:47 +08:00
<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>
2025-10-17 15:25:04 +08:00
2024-08-22 19:34:47 +08:00
<scroll-view class="carManangeScrollView" scroll-y @scrolltolower="scrolltolower">
2025-10-17 15:25:04 +08:00
<!-- 顶部统计条 -->
<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>
2024-08-22 19:34:47 +08:00
<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="">
2025-09-24 10:20:09 +08:00
<image class="cphIcon" src="../../static/icons/carManage/carNumIcon.png"
mode="aspectFit"></image>
2024-08-22 19:34:47 +08:00
<view class="cph">{{item.rescueCarNum}}</view>
</view>
<view class="right-top">
2025-10-17 15:25:04 +08:00
<view class="timesize">保养到期里程:</view>
<view class="time">{{item.carMaintenanceMileage}}</view>
</view>
<!-- <view class="right-top">
2024-08-22 19:34:47 +08:00
<view class="timesize">保养到期时间:</view>
<view class="time">{{item.carKeepTime}}</view>
2025-10-17 15:25:04 +08:00
</view> -->
2024-08-22 19:34:47 +08:00
<view class="right-top">
<view class="timesize">年检到期时间:</view>
<view class="time">{{item.carCheckTime}}</view>
</view>
</view>
2024-08-20 20:02:05 +08:00
</view>
2024-08-22 19:34:47 +08:00
<view class="_box-footer">
<view class="tag">{{item.rescueCarTypeStr}}</view>
<view class="tag">{{item.rescueCarBrand}}</view>
2024-08-20 20:02:05 +08:00
</view>
</view>
</view>
2024-08-22 19:34:47 +08:00
</scroll-view>
<tabBar msg="1"></tabBar>
2025-09-24 10:20:09 +08:00
<!-- <view class="anniu" @click="goupdata('')">
2024-08-20 20:02:05 +08:00
<u-icon name="plus" color="#fff" size="34"></u-icon>
2024-08-22 19:34:47 +08:00
</view> -->
2024-08-20 20:02:05 +08:00
</view>
</template>
<script>
import request from '../../utils/request'
2024-08-22 19:34:47 +08:00
import VNavigationBar from '@/components/VNavigationBar.vue'
import tabBarVue from '../../components/tabBar/tabBar.vue'
2024-08-20 20:02:05 +08:00
export default {
2024-08-22 19:34:47 +08:00
components: {
VNavigationBar,
tabBarVue
},
2024-08-20 20:02:05 +08:00
data() {
return {
2025-10-17 15:25:04 +08:00
2025-09-24 10:20:09 +08:00
baseUrl: this.$baseImageUrlNew,
2024-08-20 20:02:05 +08:00
carList: [],
searchName: null,
pageNum: 1,
pageSize: 10,
totalNum: '',
2025-10-17 15:25:04 +08:00
statsOverview: {
totalCars: 0,
categoryCount: {}
}
2024-08-20 20:02:05 +08:00
}
},
onShow() {
this.getCarList()
2025-10-17 15:25:04 +08:00
this.getStatsData()
// this.loadStatsData()
2024-08-20 20:02:05 +08:00
},
methods: {
2025-10-17 15:25:04 +08:00
// 根据分类名称返回对应图标
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
}
},
2024-08-22 19:34:47 +08:00
scrolltolower() {
if (this.carList.length >= this.totalNum) {
uni.showToast({
title: '没有下一页数据',
icon: 'none'
})
} else {
this.pageNum++
this.getCarList()
}
},
2024-08-20 20:02:05 +08:00
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">
2025-10-17 15:25:04 +08:00
.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);
}
}
2024-08-22 19:34:47 +08:00
.carManageContent {
height: 100%;
2024-08-20 20:02:05 +08:00
display: flex;
2024-08-22 19:34:47 +08:00
flex-direction: column;
background-color: #F7F8FC;
}
2024-08-20 20:02:05 +08:00
2024-08-22 19:34:47 +08:00
.carManangeScrollView {
flex: 1;
height: 0;
2024-08-20 20:02:05 +08:00
}
.top-icon {
display: flex;
align-items: center;
}
.ail {
width: 100%;
box-sizing: border-box;
padding: 15px;
}
._box {
width: 100%;
box-sizing: border-box;
2024-08-22 19:34:47 +08:00
padding: 50rpx 46rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.06);
border-radius: 16rpx;
margin: 24rpx 0;
}
2024-08-20 20:02:05 +08:00
2024-08-22 19:34:47 +08:00
._box-content {
display: flex;
align-items: center;
2024-08-20 20:02:05 +08:00
justify-content: space-between;
2024-08-22 19:34:47 +08:00
column-gap: 32rpx;
2024-08-20 20:02:05 +08:00
}
.img_ {
2024-08-22 19:34:47 +08:00
width: 196rpx;
height: 196rpx;
background: #D8D8D8;
border-radius: 16rpx;
overflow: hidden;
// border: 2rpx solid #979797;
2024-08-20 20:02:05 +08:00
image {
width: 100%;
height: 100%;
}
}
.right_ {
width: 70%;
}
2024-08-22 19:34:47 +08:00
.cphInfo {
2024-08-20 20:02:05 +08:00
display: flex;
align-items: center;
2024-08-22 19:34:47 +08:00
column-gap: 10rpx;
margin-bottom: 18rpx;
2024-08-20 20:02:05 +08:00
}
2024-08-22 19:34:47 +08:00
.cphIcon {
width: 100rpx;
height: 44rpx;
2024-08-20 20:02:05 +08:00
}
.cph {
2024-08-22 19:34:47 +08:00
font-weight: 500;
font-size: 32rpx;
color: #000000;
line-height: 1.5;
2024-08-20 20:02:05 +08:00
}
2024-08-22 19:34:47 +08:00
.right-top {
width: 100%;
display: flex;
align-items: center;
font-size: 28rpx;
color: #000000;
margin: 10rpx 0 0;
2024-08-20 20:02:05 +08:00
}
2024-08-22 19:34:47 +08:00
._box-footer {
display: flex;
align-items: center;
justify-content: flex-end;
column-gap: 40rpx;
padding-top: 22rpx;
2024-08-20 20:02:05 +08:00
}
2024-08-22 19:34:47 +08:00
.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;
2024-08-20 20:02:05 +08:00
}
.anniu {
width: 55px;
height: 55px;
background: #0000ff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 30px;
right: 15px;
}
2025-10-17 15:25:04 +08:00
</style>