巡检接口

This commit is contained in:
Zy
2026-05-19 17:31:17 +08:00
parent 82200a3617
commit abc8086ad0
15 changed files with 433 additions and 253 deletions

View File

@@ -38,27 +38,29 @@
<!-- 记录卡片 -->
<view
v-for="(record, index) in reportRecords"
@tap="handleComplted(record.id)"
@tap="handleComplted(record)"
:key="index"
class="record-card"
>
<!-- 标题 + 状态标签 -->
<view class="card-header">
<text class="card-title">{{ record.title }}</text>
<view class="status-tag" :class="record.status">
{{ getStatusText(record.status) }}
</view>
<text class="card-title">{{ record.item }}</text>
<view class="status-tag pending" v-if="record.problemStatus === '0'"> 待分配 </view>
<view class="status-tag processing" v-if="record.problemStatus === '1'"> 待解决 </view>
<view class="status-tag completed" v-if="record.problemStatus === '2'"> 已完成 </view>
</view>
<!-- 类型标签 -->
<view class="tag-group">
<view class="tag-item">{{ record.reportType }}</view>
<view class="tag-item">{{ record.category }}</view>
<view class="tag-group" v-if="record.projectTypeStr || record.maintenanceItemName">
<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.content }}
{{ record.problem }}
</view>
<!-- 工单图片 -->
<!-- <view class="card-image">
@@ -75,10 +77,10 @@
<!-- 底部信息 -->
<view class="card-footer">
<text class="create-time">{{ record.createTime }}</text>
<text v-if="record.repairStatus === 2" class="repairman"
>维修师傅:{{ record.repairman }}</text
<text v-if="record.problemStatus === '1'" class="repairman"
>维修师傅:{{ record.repairName }}</text
>
<view class="share" v-if="record.repairStatus === 1">
<view class="share" v-if="record.problemStatus === '2'">
<text>维修完成</text>
</view>
</view>
@@ -93,60 +95,38 @@ import { ref, computed } from 'vue'
import { onReady } from '@dcloudio/uni-app'
import TabsComponents from '@/components/tabs/tabs.vue'
import NavBar from '@/components/navbar/navbar.vue'
// 导航栏/标签高度(适配不同设备)
const navHeight = ref(44)
const statusTabHeight = ref(88)
const typeTabHeight = ref(88)
import { getUserTicketlist } from '@/api/ticket.js'
// 筛选状态
const activeStatus = ref('all') // 全部/待分配/待解决/已完成
const activeType = ref('all') // 全部/公共报修/个人报修
const activeStatus = ref(0) // 全部/待分配/待解决/已完成
const activeType = ref(-1) // 全部/公共报修/个人报修
// 状态筛选选项
const statusTabs = ref([
{ label: '全部', value: 'all' },
{ label: '待解决', value: 'processing' },
{ label: '已完成', value: 'completed' }
{ label: '全部', value: 0 },
{ label: '待解决', value: 1 },
{ label: '已完成', value: 2 }
])
// 类型筛选选项
const typeTabs = ref([
{ label: '全部', value: 'all' },
{ label: '公共报修', value: 'public' },
{ label: '个人报修', value: 'private' }
{ label: '全部', value: -1 },
{ label: '公共报修', value: 0 },
{ label: '个人报修', value: 1 }
])
// 模拟上报记录数据(实际项目替换为接口请求)
const reportRecords = ref([
{
id: 1,
title: '标题巴拉巴拉巴拉',
status: 'processing', // pending/processing/completed
reportType: '公共报修',
category: '路灯',
content: '1栋楼下道路路灯不亮,并且有的亮度不够,请物业公司及时更换,防止发生意外事故。',
createTime: '2026-08-01 10:05:46',
repairman: '张胜',
images: [
'https://picsum.photos/93',
'https://picsum.photos/93',
'https://picsum.photos/93',
'https://picsum.photos/93',
'https://picsum.photos/93'
],
repairStatus: 1 // 1待解决 2已完成
}
])
const reportRecords = ref([])
const queryParmas = ref({
pageNum: 1,
pageSize: 10,
value: ''
itemType: undefined,
problemStatus: undefined
})
const isLoading = ref(false) // 加载锁
const hasMore = ref(true) // 是否还有更多数据
const total = ref(21)
const total = ref(0)
function scrolltolower() {
// 必须加这两个判断!
if (isLoading.value || !hasMore.value) {
@@ -164,37 +144,16 @@ function getlist() {
title: '加载中',
mask: true
})
const { pageNum, pageSize } = queryParmas.value
const startId = (pageNum - 1) * pageSize + 1
const arr = Array.from({ length: pageSize }).map((_, index) => {
const realId = startId + index
const randomStatus = Math.floor(Math.random() * 2)
return {
id: realId,
title: '标题巴拉巴拉巴拉',
status: 'processing', // pending/processing/completed
reportType: '公共报修',
category: '路灯',
content: '1栋楼下道路路灯不亮,并且有的亮度不够,请物业公司及时更换,防止发生意外事故。',
createTime: '2026-08-01 10:05:46',
repairman: '',
images: [
'https://picsum.photos/93',
'https://picsum.photos/93',
'https://picsum.photos/93',
'https://picsum.photos/93',
'https://picsum.photos/93'
],
repairStatus: randomStatus // 1待解决 2已完成
}
})
// 追加数据(正确方式)
reportRecords.value = [...reportRecords.value, ...arr]
// 判断是否还有更多
hasMore.value = reportRecords.value.length < total.value
isLoading.value = false
uni.hideLoading()
getUserTicketlist(queryParmas.value)
.then(res => {
reportRecords.value = [...reportRecords.value, ...res.rows]
hasMore.value = reportRecords.value.length < total.value
total.value = res.total
})
.finally(() => {
isLoading.value = false
uni.hideLoading()
})
}
getlist()
function resetList() {
@@ -207,20 +166,29 @@ function resetList() {
// 切换状态(全部/待分配/待解决/已完成)筛选
const switchStatus = value => {
activeStatus.value = value
if (value === 0) {
queryParmas.value.problemStatus = undefined
} else {
queryParmas.value.problemStatus = value
}
hasMore.value = true
reportRecords.value = []
queryParmas.value.pageNum = 1
getlist()
}
// 切换类型(公共/个人)筛选
const switchType = value => {
activeType.value = value
}
// 获取状态文本
const statusMap = {
processing: '待解决',
completed: '已完成'
}
const getStatusText = status => {
return statusMap[status] || ''
if (value === -1) {
queryParmas.value.itemType = undefined
} else {
queryParmas.value.itemType = value
}
hasMore.value = true
reportRecords.value = []
queryParmas.value.pageNum = 1
getlist()
}
// 返回上一页
@@ -228,17 +196,16 @@ const navBack = () => {
uni.navigateBack()
}
// 1待解决 2已完成
function handleComplted(id) {
const find = reportRecords.value.find(item => item.id === id)
if (find) {
const status = find.repairStatus
function handleComplted(row) {
if (row) {
const status = row.repairStatus
if (status === 2) {
uni.navigateTo({
url: `/pageSubPack/ticket/repairMain?id=${id}&showbtn=${false}&path=myticket`
url: `/pageSubPack/ticket/repairMain?id=${row.id}&showbtn=${false}&path=myticket`
})
} else {
uni.navigateTo({
url: `/pageSubPack/ticket/repairMain?id=${id}&showbtn=${true}&path=myticket`
url: `/pageSubPack/ticket/repairMain?id=${row.id}&showbtn=${true}&path=myticket`
})
}
}

View File

@@ -57,7 +57,6 @@ const form = ref({
})
/** 返回上一页 */
function handleSelecthouse() {
console.log('compltee')
uni.navigateBack()
}
</script>

View File

@@ -131,8 +131,9 @@
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onShow } from '@dcloudio/uni-app'
import Stops from '@/components/stops/stops.vue'
import { getTicketMainById } from '@/api/ticket.js'
// --------------------------------------
/** 维修步骤:0提交 1分配 2维修完成 / 待解决 3记录完成 完成*/
const currentStep = ref(2)
@@ -163,7 +164,6 @@ const repairInfo = ref({
'https://picsum.photos/80',
'https://picsum.photos/80'
],
repairUser: {
name: '盘下但',
status: '正常',
@@ -184,6 +184,19 @@ onLoad(options => {
Showbtn.value = JSON.parse(options.showbtn)
prevPath.value = options.path
})
onShow(() => {
getTicketById()
})
function getTicketById() {
getTicketMainById(queryParams.value.id)
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
// --------------------------------------
/** 选择维修人员 */