Files
property-manager-side/wuye-manager-uniapp/pageSubPack/inspection/toDays_inscpection.vue
2026-08-20 10:22:55 +08:00

332 lines
7.6 KiB
Vue
Raw 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="page_padding">
<view class="today_inspection_page flex flex-col">
<!-- 状态筛选标签 -->
<TabsComponents
:activeValue="activeValue"
:tabslist="tabslist"
@update="handleTabs"
></TabsComponents>
<!-- body -->
<view class="inspection_body flex-1" v-if="list.length > 0">
<view
class="inspection_items"
v-for="(item, index) in list"
:key="index"
@tap="handleTap(item)"
>
<view class="title">
<text class="subtitle">
<i></i>
{{ item.taskName }}
</text>
<text class="noactions" v-if="!isComputed(item.taskStatus)">未巡检</text>
<text class="noactions alaway_actions" v-else>已巡检</text>
</view>
<view class="inspection_item_box flex">
<text class="inspection_item" v-for="(ite, index) in item.itemslist" :key="index">
{{ ite }}
</text>
</view>
<view class="inspection_time">
<text>巡检时间:</text>
<text>{{ item.taskTime }}</text>
</view>
<view class="inspection_time flex items-center justify-between">
<view class="">
<text>巡检人:</text>
<text>{{ item.inspectorName }}</text>
</view>
<view class="actions" v-if="!isComputed(item.taskStatus)">
<text>去巡检</text>
</view>
</view>
</view>
</view>
<view class="nodata" v-else>
<text>暂无数据</text>
</view>
</view>
<!-- body -->
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import TabsComponents from '@/components/tabs/tabs.vue'
import { onShow, onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
import { InspectionListType, getInspectionList } from '@/api/insepction.js'
import { parseTime } from '@/utils/time.js'
// tabs =========================================================
const activeValue = ref(2)
const tabslist = ref([
{
name: '全部',
value: 2
},
{
name: '未巡检',
value: 0
},
{
name: '已巡检',
value: 1
}
])
// 点击事件
const handleTabs = (val: number) => {
activeValue.value = val
queryParmas.value.status = val
init()
}
// tabs =========================================================
// body =========================================================
const isComputed = (status: string) => {
const awaitlist = ['未完成', '待执行', '执行中']
return !awaitlist.includes(status)
}
const list = ref<InspectionListType[]>([])
const queryParmas = ref({
date: '',
status: 2,
pageNum: 1,
pageSize: 10
})
const isLoading = ref(false) // 加载锁
const hasMore = ref(true) // 是否还有更多数据
const total = ref(0)
function getlist() {
if (isLoading.value || !hasMore.value) {
if (isRefresh) {
uni.stopPullDownRefresh()
isRefresh = false
}
return
}
isLoading.value = true
const { pageNum, pageSize, date, status } = queryParmas.value
getInspectionList({
pageSize,
pageNum,
status,
date
})
.then(res => {
let items: Set<string> = new Set()
res.rows.forEach(item => {
if (!item.points || item.points.length <= 0) return
item.points.forEach(ite => {
ite.itemNames.forEach(it => items.add(it))
})
item.itemslist = Array.from(items)
})
list.value = res.rows
total.value = res.total
hasMore.value = list.value.length < res.total
})
.catch(() => {
uni.showToast({
icon: 'error',
title: '网络异常'
})
})
.finally(() => {
if (isRefresh) {
uni.stopPullDownRefresh()
isRefresh = false
}
isLoading.value = false
})
}
/** 跳转到巡检上传页面 */
function handleTap(ite: InspectionListType) {
if (isComputed(ite.taskStatus)) {
uni.navigateTo({
url: '/pageSubPack/inspection/inspection_main?id=' + ite.id
})
} else {
uni.navigateTo({
url: '/pageSubPack/inspection/inspection_upload?id=' + ite.id
})
}
}
function init() {
hasMore.value = true
queryParmas.value.date = parseTime(new Date(), '{y}-{m}-{d}')
getlist()
}
onLoad(options => {
activeValue.value = Number(options.type)
})
// 是否正在下拉刷新
let isRefresh = false
onPullDownRefresh(() => {
isRefresh = true
init()
})
onShow(() => {
handleTabs(activeValue.value)
})
</script>
<style scoped lang="scss">
/* 页面容器 */
.page_padding {
background: #f9f9f9;
}
.today_inspection_page {
background: #f9f9f9;
padding: 20rpx 40rpx;
flex: 1;
box-sizing: border-box;
overflow: hidden;
// tabs
.tabs_box {
height: 60rpx;
line-height: 60rpx;
width: 100%;
display: flex;
align-items: center;
overflow-y: hidden;
overflow-x: auto;
.tabs_items {
/* 关键:不压缩宽度 */
flex-shrink: 0;
margin-right: 60rpx;
color: #4d5dfa;
&.active {
position: relative;
&::after {
content: '';
display: block;
width: 100%;
height: 8rpx;
background-color: #6371fa;
background: linear-gradient(180deg, #4d5dfa 0%, #bac0fa 100%);
border-radius: 4rpx;
position: absolute;
left: 0;
bottom: 0rpx;
}
}
}
}
// body
.inspection_body {
margin-top: 20rpx;
position: relative;
overflow-x: hidden;
overflow-y: scroll;
.inspection_items {
margin-top: 20rpx;
padding: 40rpx;
border-radius: 16rpx;
background-color: #ffffff;
.title {
display: flex;
align-items: center;
justify-content: space-between;
.subtitle {
position: relative;
padding-left: 10rpx;
height: 40rpx;
line-height: 40rpx;
font-size: 32rpx;
color: #333333;
i {
display: block;
position: absolute;
left: 0;
top: 6rpx;
height: 100%;
width: 6rpx;
height: 28rpx;
background: #4d5dfa;
}
}
.noactions {
font-weight: 400;
font-size: 28rpx;
color: #4d5dfa;
line-height: 36rpx;
}
.alaway_actions {
color: #6d6d6d;
}
}
// 巡检项目
.inspection_item_box {
margin-top: 20rpx;
margin-bottom: 20rpx;
flex-wrap: wrap;
.inspection_item {
border: 1px solid #4d5dfa;
margin-bottom: 10rpx;
margin-right: 10rpx;
padding: 0 14rpx;
height: 48rpx;
line-height: 48rpx;
border-radius: 198rpx 198rpx 198rpx 198rpx;
border: 2rpx solid #4d5dfa;
font-size: 28rpx;
color: #4d5dfa;
}
}
// 巡检时间
.inspection_time {
margin-bottom: 22rpx;
font-weight: 400;
font-size: 28rpx;
color: #333333;
line-height: 36rpx;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
}
.actions {
width: 140rpx;
height: 50rpx;
background: #4d5dfa;
border-radius: 198rpx 198rpx 198rpx 198rpx;
text-align: center;
font-weight: 400;
font-size: 28rpx;
color: #ffffff;
line-height: 50rpx;
}
}
}
.nodata {
color: #ccc;
text-align: center;
margin-top: 200rpx;
letter-spacing: 1rpx;
}
}
</style>