This commit is contained in:
Zy
2026-05-21 11:06:03 +08:00
parent af98d07d7d
commit 5909be9a15
4 changed files with 255 additions and 212 deletions

View File

@@ -1,13 +1,14 @@
<template>
<view class="report-record-page">
<view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
<view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
<!-- 顶部导航栏 -->
<uni-nav-bar
left-icon="back"
title="上报记录"
backgroundColor="transparent"
:border= "false"
@clickLeft="navBack"/>
backgroundColor="transparent"
:border="false"
@clickLeft="navBack"
/>
<!-- 状态筛选标签 -->
<view class="status-tabs">
@@ -41,13 +42,8 @@
scroll-y
:style="{ height: `calc(100vh - ${navHeight + statusTabHeight + typeTabHeight}px)` }"
>
<!-- 记录卡片 -->
<view
v-for="record in reportRecords"
:key="record.id"
class="record-card"
>
<view v-for="record in reportRecords" :key="record.id" class="record-card">
<!-- 标题 + 状态标签 -->
<view class="card-header">
<text class="card-title">{{ record.item }}</text>
@@ -58,8 +54,10 @@
<!-- 类型标签 -->
<view class="tag-group">
<view class="tag-item" v-if="record.projectTypeStr">{{ record.projectTypeStr}}</view>
<view class="tag-item" v-if="record.maintenanceItemName">{{ record.maintenanceItemName}}</view>
<view class="tag-item" v-if="record.projectTypeStr">{{ record.projectTypeStr }}</view>
<view class="tag-item" v-if="record.maintenanceItemName">{{
record.maintenanceItemName
}}</view>
</view>
<!-- 内容 -->
@@ -81,17 +79,15 @@
</view>
<!-- 空数据 -->
<view class="empty" v-if="reportRecords.length === 0 && !loading">
暂无上报记录
</view>
<view class="empty" v-if="reportRecords.length === 0 && !loading"> 暂无上报记录 </view>
</scroll-view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import {onReady, onReachBottom, onPullDownRefresh,onShow} from "@dcloudio/uni-app"
import {getMyOrderList} from '../../api/api.js'
import { onReady, onReachBottom, onPullDownRefresh, onShow } from '@dcloudio/uni-app'
import { getMyOrderList } from '../../api/api.js'
// 导航栏/标签高度(适配不同设备)
const navHeight = ref(44)
@@ -99,14 +95,14 @@ const statusTabHeight = ref(88)
const typeTabHeight = ref(88)
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
// 分页
const pageNum = ref(1) // 当前页
const pageSize = ref(5) // 每页条数
const total = ref(0) // 总条数
const loading = ref(false) // 加载状态
const noMore = ref(false) // 是否没有更多
const pageNum = ref(1) // 当前页
const pageSize = ref(5) // 每页条数
const total = ref(0) // 总条数
const loading = ref(false) // 加载状态
const noMore = ref(false) // 是否没有更多
// 筛选状态
const activeStatus = ref('all') // 全部/待分配/待解决/已完成
const activeType = ref('all') // 全部/公共报修/个人报修
const activeType = ref('all') // 全部/公共报修/个人报修
// 状态筛选选项
const statusTabs = ref([
@@ -142,29 +138,32 @@ const getReportList = (isRefresh = false) => {
if (activeStatus.value !== 'all') {
params.problemStatus = activeStatus.value
}
getMyOrderList(params).then(res => {
if (res.code === 200) {
total.value = res.total || 0
const data = res.rows || []
getMyOrderList(params)
.then(res => {
if (res.code === 200) {
total.value = res.total || 0
const data = res.rows || []
// 第一页:覆盖,分页:追加
if (pageNum.value === 1) {
reportRecords.value = data
} else {
reportRecords.value = [...reportRecords.value, ...data]
// 第一页:覆盖,分页:追加
if (pageNum.value === 1) {
reportRecords.value = data
} else {
reportRecords.value = [...reportRecords.value, ...data]
}
// 判断是否还有更多
noMore.value = reportRecords.value.length >= total.value
}
// 判断是否还有更多
noMore.value = reportRecords.value.length >= total.value
}
}).catch(() => {
uni.showToast({ title: '加载失败', icon: 'none' })
}).finally(() => {
loading.value = false
if (isRefresh) {
uni.stopPullDownRefresh()
}
})
})
.catch(() => {
uni.showToast({ title: '加载失败', icon: 'none' })
})
.finally(() => {
loading.value = false
if (isRefresh) {
uni.stopPullDownRefresh()
}
})
}
// 上拉加载更多
onReachBottom(() => {
@@ -189,14 +188,14 @@ const reloadList = () => {
}
// 切换状态(全部/待解决/已完成)筛选
const switchStatus = (value) => {
const switchStatus = value => {
if (activeStatus.value === value) return
activeStatus.value = value
reloadList()
}
// 切换类型(公共/个人)筛选
const switchType = (value) => {
const switchType = value => {
if (activeType.value === value) return
activeType.value = value
reloadList()
@@ -205,24 +204,24 @@ const switchType = (value) => {
// 返回上一页
const navBack = () => {
uni.navigateBack({
delta: 1
delta: 1
})
}
// 获取状态文本
const getStatusText = (status) => {
const getStatusText = status => {
const statusMap = {
// "pending": '已分配',
"1": '待解决',
'2': '已完成'
// "pending": '已分配',
1: '待解决',
2: '已完成'
}
return statusMap[status] || ''
}
// 获取状态标签样式类名
const getStatusClass = (status) => {
const getStatusClass = status => {
const classMap = {
'1': 'processing',
'2': 'completed'
1: 'processing',
2: 'completed'
}
return classMap[status] || ''
}
@@ -236,7 +235,7 @@ onShow(() => {
onReady(() => {
// 可根据实际设备调整高度
uni.getSystemInfo({
success: (res) => {
success: res => {
if (res.platform === 'ios') {
navHeight.value = 44
} else {
@@ -251,13 +250,13 @@ onReady(() => {
.report-record-page {
width: 100%;
height: 100vh;
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%)
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
}
.status-bar{
width: 100%;
.status-bar {
width: 100%;
/* height: var(--status-bar-height); */
flex-shrink: 0;
/* height: 46px; */
/* height: 46px; */
}
/* 状态筛选标签 */
.status-tabs {
@@ -282,7 +281,7 @@ onReady(() => {
}
.status-tab-item.active {
color: #4D5DFA;
color: #4d5dfa;
font-weight: 500;
}
@@ -294,7 +293,7 @@ onReady(() => {
transform: translateX(-50%);
width: 80rpx;
height: 8rpx;
background: linear-gradient(to bottom, #4D5DFA, #BAC0FA);
background: linear-gradient(to bottom, #4d5dfa, #bac0fa);
border-radius: 6rpx;
}
@@ -318,8 +317,8 @@ onReady(() => {
}
.type-tab-item.active {
color: #4D5DFA;
border: 2rpx solid #4D5DFA;
color: #4d5dfa;
border: 2rpx solid #4d5dfa;
border-radius: 198rpx;
/* background-color: #007AFF; */
}
@@ -363,15 +362,15 @@ onReady(() => {
}
.status-tag.pending {
background-color: #E34D59; /* 待分配-红色 */
background-color: #e34d59; /* 待分配-红色 */
}
.status-tag.processing {
background-color: #09C2BD; /* 待解决-绿色 */
background-color: #09c2bd; /* 待解决-绿色 */
}
.status-tag.completed {
background-color: #4D5DFA; /* 已完成-蓝色 */
background-color: #4d5dfa; /* 已完成-蓝色 */
}
/* 类型标签组 */