464 lines
10 KiB
Vue
464 lines
10 KiB
Vue
<template>
|
||
<view class="report-record-page page_padding">
|
||
<!-- 顶部导航栏 -->
|
||
<navBar @clickLeft="navBack" title="工单大厅"></navBar>
|
||
<view class="hall_body flex flex-col">
|
||
<view class="bgaction"> </view>
|
||
<!-- 状态筛选标签 -->
|
||
<TabsComponents
|
||
:tabslist="statusTabs"
|
||
:activeValue="activeStatus"
|
||
:options="{ label: 'label', value: 'value' }"
|
||
@update="switchStatus"
|
||
></TabsComponents>
|
||
|
||
<!-- 类型筛选标签 -->
|
||
<view class="type-tabs">
|
||
<view
|
||
v-for="item in typeTabs"
|
||
:key="item.value"
|
||
class="type-tab-item"
|
||
:class="{ active: activeType === item.value }"
|
||
@tap="switchType(item.value)"
|
||
>
|
||
{{ item.label }}
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 上报记录列表 -->
|
||
<scroll-view class="record-list" scroll-y lower-threshold="60" @scrolltolower="scrolltolower">
|
||
<!-- 空状态 -->
|
||
<view v-if="reportRecords.length === 0" class="empty-state">
|
||
<uni-icons type="empty" size="60" color="#ccc"></uni-icons>
|
||
<text class="empty-text">暂无上报记录</text>
|
||
</view>
|
||
<!-- 记录卡片 -->
|
||
<view
|
||
v-for="(record, index) in reportRecords"
|
||
:key="index"
|
||
class="record-card"
|
||
@tap="handleMain(record.id)"
|
||
>
|
||
<!-- 标题 + 状态标签 -->
|
||
<view class="card-header">
|
||
<text class="card-title">{{ record.item }}</text>
|
||
<view
|
||
class="status-tag"
|
||
:class="{
|
||
pending: record.problemStatus === statusMap.pending,
|
||
processing: record.problemStatus === statusMap.processing,
|
||
completed: record.problemStatus === statusMap.completed
|
||
}"
|
||
>
|
||
{{ getStatusText(record.problemStatus) }}
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 类型标签 -->
|
||
<view class="tag-group" v-if="record.maintenanceItemName || record.projectTypeStr">
|
||
<view class="tag-item" v-if="record.projectTypeStr">{{ record.projectTypeStr }}</view>
|
||
<view class="tag-item" v-if="record.maintenanceItemName">{{
|
||
record.maintenanceItemName
|
||
}}</view>
|
||
</view>
|
||
|
||
<!-- 内容 -->
|
||
<view class="card-content">
|
||
{{ record.problem }}
|
||
</view>
|
||
<!-- 工单图片 -->
|
||
<view class="card-image" v-if="record.repairImageUrlList.length > 0">
|
||
<image
|
||
lazy-load
|
||
v-for="(item, index) in record.repairImageUrlList"
|
||
:key="index"
|
||
:src="item"
|
||
class="images"
|
||
mode="scaleToFill"
|
||
></image>
|
||
</view>
|
||
|
||
<!-- 底部信息 -->
|
||
<view class="card-footer">
|
||
<text class="create-time">{{ record.createTime }}</text>
|
||
<text v-if="record.problemStatus === statusMap.processing" class="repairman"
|
||
>维修师傅:{{ record.repairName }}</text
|
||
>
|
||
<view class="share" v-if="record.problemStatus === statusMap.pending">
|
||
<text>分配</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, computed, nextTick } from 'vue'
|
||
import { onReady, onShow } from '@dcloudio/uni-app'
|
||
import TabsComponents from '@/components/tabs/tabs.vue'
|
||
import NavBar from '@/components/navbar/navbar.vue'
|
||
import { getTicketHallList } from '@/api/ticket.js'
|
||
// 导航栏/标签高度(适配不同设备)
|
||
|
||
// 筛选状态
|
||
const activeStatus = ref(-1) // 全部/待分配/待解决/已完成
|
||
const activeType = ref(-1) // 全部/公共报修/个人报修
|
||
|
||
// 0 已提交 1已分配 2维修完成
|
||
// 状态筛选选项
|
||
const statusTabs = ref([
|
||
{ label: '全部', value: -1 },
|
||
{ label: '待分配', value: 0 },
|
||
{ label: '待解决', value: 1 },
|
||
{ label: '已完成', value: 2 }
|
||
])
|
||
|
||
// 类型筛选选项
|
||
const typeTabs = ref([
|
||
{ label: '全部', value: -1 },
|
||
{ label: '公共报修', value: 0 },
|
||
{ label: '个人报修', value: 1 }
|
||
])
|
||
|
||
// 模拟上报记录数据(实际项目替换为接口请求)
|
||
const reportRecords = ref([])
|
||
const queryParmas = ref({
|
||
pageNum: 1,
|
||
pageSize: 5,
|
||
itemType: undefined, // -1 全部/ 0 公共报修/ 1 个人报修
|
||
problemStatus: undefined // 0 已提交 1已分配 2维修完成
|
||
})
|
||
const isLoading = ref(false) // 加载锁
|
||
const hasMore = ref(true) // 是否还有更多数据
|
||
const total = ref(0)
|
||
|
||
function scrolltolower() {
|
||
// 必须加这两个判断!
|
||
if (isLoading.value || !hasMore.value) {
|
||
return
|
||
}
|
||
queryParmas.value.pageNum += 1
|
||
getlist()
|
||
}
|
||
|
||
function getlist() {
|
||
if (isLoading.value || !hasMore.value) return
|
||
isLoading.value = true
|
||
getTicketHallList(queryParmas.value)
|
||
.then(res => {
|
||
reportRecords.value = [...reportRecords.value, ...res.rows]
|
||
reportRecords.value.forEach(item => {
|
||
item.repairImageUrlList = item.repairImageUrl
|
||
? item.repairImageUrl.split(',').filter(item => item)
|
||
: []
|
||
})
|
||
total.value = res.total
|
||
hasMore.value = reportRecords.value.length < total.value
|
||
})
|
||
.catch(err => {
|
||
uni.showToast({
|
||
icon: 'error',
|
||
title: '网络错误'
|
||
})
|
||
})
|
||
.finally(() => {
|
||
isLoading.value = false
|
||
})
|
||
}
|
||
|
||
onShow(() => {
|
||
resetList()
|
||
})
|
||
|
||
function resetList() {
|
||
reportRecords.value = []
|
||
queryParmas.value.pageNum = 1
|
||
queryParmas.value.pageSize = 5
|
||
hasMore.value = true
|
||
getlist()
|
||
}
|
||
|
||
// 切换状态(全部/待分配/待解决/已完成)筛选
|
||
const switchStatus = value => {
|
||
activeStatus.value = value
|
||
if (value === -1) {
|
||
queryParmas.value.problemStatus = undefined
|
||
} else {
|
||
queryParmas.value.problemStatus = value
|
||
}
|
||
resetList()
|
||
}
|
||
|
||
// 切换类型(公共/个人)筛选
|
||
const switchType = value => {
|
||
activeType.value = value
|
||
if (value === -1) {
|
||
queryParmas.value.itemType = undefined
|
||
} else {
|
||
queryParmas.value.itemType = value
|
||
}
|
||
resetList()
|
||
}
|
||
|
||
const statusMap = {
|
||
已提交: '待分配',
|
||
已分配: '待解决',
|
||
已完成: '已完成',
|
||
|
||
pending: '已提交',
|
||
processing: '已分配',
|
||
completed: '已完成'
|
||
}
|
||
// 获取状态文本
|
||
const getStatusText = status => {
|
||
return statusMap[status] || ''
|
||
}
|
||
|
||
// 返回上一页
|
||
const navBack = () => {
|
||
uni.navigateBack()
|
||
}
|
||
/* 0 待分配,1待解决 2已完成*/
|
||
function handleMain(id) {
|
||
const find = reportRecords.value.find(item => item.id === id)
|
||
if (find) {
|
||
const status = find.repairStatus
|
||
if (status === 2) {
|
||
uni.navigateTo({
|
||
url: `/pageSubPack/ticket/repairMain?id=${id}&showbtn=${false}&path=hall`
|
||
})
|
||
} else {
|
||
uni.navigateTo({
|
||
url: `/pageSubPack/ticket/repairMain?id=${id}&showbtn=${false}&path=hall`
|
||
})
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 预览图片 */
|
||
function handlePrivew(imgs) {
|
||
// if (imgs.length > 0) {
|
||
// uni.previewImage({
|
||
// urls: imgs,
|
||
// success(e) {
|
||
// console.log(JSON.stringify(e))
|
||
// }
|
||
// })
|
||
// }
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.bgaction {
|
||
position: absolute;
|
||
right: 0;
|
||
top: 20%;
|
||
width: 100%;
|
||
height: 100%;
|
||
z-index: 0;
|
||
background: linear-gradient(225deg, #e2f0ff 0%, #f9f9f9 25%);
|
||
}
|
||
.report-record-page {
|
||
height: 100vh;
|
||
background: linear-gradient(225deg, #e2f0ff 0%, #f9f9f9 25.71%);
|
||
}
|
||
|
||
.hall_body {
|
||
flex: 1;
|
||
padding: 0 40rpx;
|
||
overflow: hidden;
|
||
position: relative;
|
||
}
|
||
/* 状态筛选标签 */
|
||
.status-tabs {
|
||
display: flex;
|
||
/* background-color: #fff; */
|
||
padding: 0 40rpx;
|
||
height: 88rpx;
|
||
align-items: center;
|
||
}
|
||
|
||
/* 类型筛选标签 */
|
||
.type-tabs {
|
||
display: flex;
|
||
height: 48rpx;
|
||
/* background-color: #fff; */
|
||
margin: 20rpx 0;
|
||
justify-content: flex-start;
|
||
gap: 20rpx;
|
||
}
|
||
|
||
.type-tab-item {
|
||
width: 142rpx;
|
||
height: 48rpx;
|
||
border-radius: 24rpx;
|
||
border: 2rpx solid #999999;
|
||
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #999999;
|
||
line-height: 48rpx;
|
||
text-align: center;
|
||
}
|
||
|
||
.type-tab-item.active {
|
||
color: #4d5dfa;
|
||
border: 2rpx solid #4d5dfa;
|
||
border-radius: 24rpx;
|
||
}
|
||
|
||
/* 记录列表 */
|
||
.record-list {
|
||
box-sizing: border-box;
|
||
padding-bottom: 40rpx;
|
||
overflow-y: auto;
|
||
flex: 1;
|
||
}
|
||
|
||
/* 空状态 */
|
||
.empty-state {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 100rpx 0;
|
||
color: #ccc;
|
||
}
|
||
|
||
.empty-text {
|
||
font-size: 32rpx;
|
||
color: #999;
|
||
margin-top: 20rpx;
|
||
}
|
||
|
||
/* 记录卡片 */
|
||
.record-card {
|
||
background-color: #fff;
|
||
border-radius: 16rpx;
|
||
padding: 34rpx 32rpx;
|
||
margin-bottom: 20rpx;
|
||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
||
}
|
||
|
||
.card-header {
|
||
display: flex;
|
||
justify-content: flex-start;
|
||
align-items: center;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
|
||
.card-title {
|
||
margin-right: 20rpx;
|
||
|
||
font-weight: 400;
|
||
color: #222222;
|
||
line-height: 40rpx;
|
||
font-size: 32rpx;
|
||
}
|
||
|
||
/* 状态标签 */
|
||
.status-tag {
|
||
width: 82rpx;
|
||
height: 30rpx;
|
||
border-radius: 15rpx;
|
||
|
||
font-weight: 400;
|
||
font-size: 20rpx;
|
||
color: #ffffff;
|
||
line-height: 30rpx;
|
||
text-align: center;
|
||
line-height: 30rpx;
|
||
}
|
||
|
||
.status-tag.pending {
|
||
background-color: #e34d59; /* 待分配-红色 */
|
||
}
|
||
|
||
.status-tag.processing {
|
||
background-color: #09c2bd; /* 待解决-绿色 */
|
||
}
|
||
|
||
.status-tag.completed {
|
||
background-color: #4d5dfa; /* 已完成-蓝色 */
|
||
}
|
||
|
||
/* 类型标签组 */
|
||
.tag-group {
|
||
display: flex;
|
||
gap: 20rpx;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
|
||
.tag-item {
|
||
width: 112rpx;
|
||
height: 42rpx;
|
||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||
border: 1rpx solid #999999;
|
||
|
||
font-weight: 400;
|
||
font-size: 24rpx;
|
||
color: #999999;
|
||
line-height: 42rpx;
|
||
text-align: center;
|
||
}
|
||
|
||
/* 内容 */
|
||
.card-content {
|
||
margin-bottom: 20rpx;
|
||
letter-spacing: 2rpx;
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #666666;
|
||
line-height: 40rpx;
|
||
}
|
||
/* 图片 */
|
||
.card-image {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, 1fr);
|
||
gap: 20rpx;
|
||
min-width: 186rpx;
|
||
min-height: 104rpx;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
.images {
|
||
width: 186rpx;
|
||
height: 104rpx;
|
||
}
|
||
|
||
/* 底部信息 */
|
||
.card-footer {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
font-size: 28rpx;
|
||
color: #999;
|
||
}
|
||
.create-time {
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #999999;
|
||
line-height: 40rpx;
|
||
}
|
||
.share {
|
||
width: 127rpx;
|
||
height: 44rpx;
|
||
background: #4d5dfa;
|
||
border-radius: 22rpx;
|
||
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #ffffff;
|
||
line-height: 44rpx;
|
||
text-align: center;
|
||
}
|
||
|
||
.repairman {
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #999999;
|
||
line-height: 40rpx;
|
||
}
|
||
</style>
|