Files
ys-app/src/pages/business/polling/taskList.vue

389 lines
12 KiB
Vue
Raw Normal View History

2025-11-14 18:30:34 +08:00
<template>
2025-11-20 17:45:41 +08:00
<view class="con-body">
<view class="con-bg">
<!-- 头部 -->
<customHeader ref="customHeaderRef" title="巡检任务查询"
:leftFlag="true" :rightFlag="false"
></customHeader>
<!-- 高度来避免头部遮挡 -->
<view class="top-height"></view>
<!-- 查询条件 -->
<view class="search">
<view class="search-bg s-b-left" @click="chooseDate">
<img :src="'static/images/polling/icon-search-clock.png'" class="img-icon" />
2025-11-20 17:54:50 +08:00
{{dateStrName}}
2025-11-20 17:45:41 +08:00
<uni-icons type="down" size="16" color="#C8DCFF" style="margin-left:auto;"></uni-icons>
</view>
<view class="search-bg s-b-right">
<img :src="'static/images/polling/icon-type.png'" class="img-type" />
<picker @change="changeTaskType" :value="taskTypeIndex" :range="taskTypeArr">
<view class="uni-input">{{taskTypeArr[taskTypeIndex]}}</view>
</picker>
<uni-icons type="down" size="16" color="#C8DCFF" style="margin-left:auto;"></uni-icons>
</view>
2025-11-20 18:14:15 +08:00
<view class="search-btn" @click="handleSearch">查询</view>
2025-11-20 17:45:41 +08:00
</view>
<view class="week">{{dateStr}}</view>
2025-11-14 18:30:34 +08:00
2025-11-20 17:45:41 +08:00
<!-- 列表 -->
<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:up="upOption" :down="downOption" :fixed="false" class="scroll-h" :class="{'loading-scroll':cssFlag}">
2025-11-28 16:42:57 +08:00
<view class="white-bg" v-if="list.length>0">
<!-- <view class="r-title">{{ parseTime(obj.dateStr,'{y}-{m}-{d} 星期{a}')}}</view> -->
<view class="report-list" v-for="(item, index) in list" :key="index" @click="handleDetail(item)">
<view class="r-list" style="padding-bottom:0">
<view class="r-name">{{ item.taskName }}</view>
<view class="r-right">
<!-- 任务(巡检)状态 1=未发布 2=已发布 3 进行中 4 已完成 5 已过期 -->
<!-- 状态为3进行中时 进度>0执行中 进度=0为待执行 -->
<block v-if="item.taskStatus==3">
2025-12-18 17:57:09 +08:00
<img v-if="item.beginTime" :src="'static/images/polling/icon-pending.png'" class="img-w" />
<img v-else :src="'static/images/polling/icon-start.png'" class="img-w" />
2025-11-28 16:42:57 +08:00
</block>
<img v-else-if="item.taskStatus==4" :src="'static/images/polling/icon-complete.png'" class="img-complete" />
<img v-else-if="item.taskStatus==5" :src="'static/images/polling/icon-Expired.png'" class="img-w" />
</view>
</view>
<view class="r-list">
<view class="r-left">
<view class="r-l-left">巡检单号<span class="r-gray">{{ item.taskId }}</span></view>
<view class="r-l-right">类型<span class="r-gray">{{ formatTaskType(item.taskType) }}</span></view>
</view>
</view>
<view class="r-list">
<view class="r-left">
2025-12-18 17:57:09 +08:00
<view v-if="item.beginTime">
执行时间<span class="r-gray">{{ parseTime(item.beginTime,'{y}-{m}-{d} {h}:{i}') }}</span>
</view>
<view v-else>
开始时间<span class="r-gray">{{ parseTime(item.planTime,'{y}-{m}-{d} {h}:{i}') }}</span>
</view>
2025-11-28 16:42:57 +08:00
</view>
</view>
<view class="r-list">
<view class="r-left">
<view class="r-l-left">
2025-12-18 17:57:09 +08:00
任务状态<span class="r-gray" v-if="item.taskStatus==3">
<block v-if="item.beginTime">执行中</block>
<block v-else>待执行</block>
</span>
<span class="r-gray" v-else>{{formatTaskStatus(item.taskStatus) }}</span>
</view>
<view class="r-l-right">
任务时长<span class="r-gray">{{ item.workHour }}小时</span>
2025-11-20 17:45:41 +08:00
</view>
2025-11-28 16:42:57 +08:00
</view>
</view>
<view class="r-list">
<view class="r-left">
2025-12-18 17:57:09 +08:00
<view class="r-l-left">
完成进度<span class="r-gray"><span :class="{'r-red':item.groupFinishNum<item.groupNum}">{{item.groupFinishNum}}</span>/{{item.groupNum}}</span>
</view>
<view class="r-l-right">
完成比率<span class="r-blue">{{(item.groupFinishNum/item.groupNum*100).toFixed()+'%'}}</span>
2025-11-20 17:45:41 +08:00
</view>
</view>
2025-11-27 18:18:19 +08:00
</view>
2025-12-18 17:57:09 +08:00
2025-11-28 16:42:57 +08:00
<view class="report-border" v-if="index<list.length-1"></view>
2025-11-20 17:45:41 +08:00
</view>
2025-11-28 16:42:57 +08:00
2025-11-20 17:45:41 +08:00
</view>
</mescroll-uni>
2025-11-14 18:30:34 +08:00
</view>
2025-11-20 17:45:41 +08:00
<!-- 选择日期 -->
<searchDate :isShow="isShow" @close="dateClose" @confirm="dateConfirm"></searchDate>
</view>
</template>
2025-11-14 18:30:34 +08:00
<script setup>
2025-11-20 17:45:41 +08:00
import { ref,onMounted,getCurrentInstance } from 'vue'
import { onLoad,onHide } from '@dcloudio/uni-app';
import customHeader from '@/components/customHeader.vue';
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
import searchDate from '@/components/searchDate.vue';
2025-11-20 17:54:50 +08:00
import { parseTime,getDateRange,getDateRangeName } from '@/utils/datetime.js';
2025-11-20 17:45:41 +08:00
import { taskTypeOptions,formatTaskType,formatTaskStatus } from '@/utils/status.js';
2025-11-27 18:18:19 +08:00
import { taskLists } from '@/api/polling.js'
2025-11-20 17:45:41 +08:00
const { proxy } = getCurrentInstance();
// 底部日期选择
let isShow = ref(false);
const chooseDate = ()=>{
isShow.value = true;
}
const dateClose=()=>{
isShow.value = false;
}
2025-11-20 17:54:50 +08:00
// 选完日期提交回显
2025-11-20 17:45:41 +08:00
const dateConfirm=(dateObj)=>{
isShow.value = false;
2025-11-20 17:54:50 +08:00
dateStr.value = dateObj.startDate + ' 至 '+dateObj.endDate;
dateStrName.value = getDateRangeName(dateObj.lastType)
2025-11-27 18:18:19 +08:00
form.value.startDate = dateObj.startDate;
form.value.endDate = dateObj.endDate
2025-11-20 17:45:41 +08:00
}
// 类型索引
let taskTypeIndex = ref(0);
let taskTypeArr = ref([]);
let dateStr = ref('');
2025-11-20 17:54:50 +08:00
let dateStrName=ref('');
2025-11-28 16:42:57 +08:00
onLoad(async option => {
2025-11-20 17:45:41 +08:00
taskTypeOptions.forEach(item => {
taskTypeArr.value.push(item.label)
});
let dateObj = getDateRange('3days');
2025-11-20 17:54:50 +08:00
dateStr.value = dateObj.startDate + ' 至 '+dateObj.endDate;
dateStrName.value="近3天"
2025-11-27 18:18:19 +08:00
form.value.startDate = dateObj.startDate;
form.value.endDate = dateObj.endDate
2025-11-28 16:42:57 +08:00
// let res = await getList(0,3);
// cssFlag.value = false;
// list.value = res.list;
2025-11-27 18:18:19 +08:00
2025-11-20 17:45:41 +08:00
})
// 选择类型筛选
const changeTaskType = (e)=>{
taskTypeIndex.value = e.detail.value
let obj = taskTypeOptions[taskTypeIndex.value];
console.log('obj=>', obj)
}
2025-11-14 18:30:34 +08:00
2025-11-20 17:45:41 +08:00
// 查询列表
2025-11-28 16:42:57 +08:00
let lastId = ref('');
2025-11-20 17:45:41 +08:00
let list = ref([]);
let form = ref({
2025-11-27 18:18:19 +08:00
startDate:''
2025-11-20 17:45:41 +08:00
})
const mescrollRef = ref(null);
const upOption = ref({
// use: false,
2025-11-28 16:42:57 +08:00
auto: true, // 禁用自动上拉
2025-11-20 17:45:41 +08:00
page: { num: 0, size: 10 },
noMoreSize: 5,
empty: {
tip: '~ 空空如也 ~',
icon: "../../../static/images/mescroll-empty.png"
},
textLoading: '加载中...',
textNoMore: '已经到底了'
});
const downOption = ref({
auto: false,
textInOffset: '下拉刷新',
textOutOffset: '释放更新',
textLoading: '刷新中...'
});
let cssFlag=ref(false);//控制样式
const mescrollInit = (mescroll) => {
cssFlag.value = true;
mescrollRef.value = mescroll;
2025-11-28 16:42:57 +08:00
// mescrollRef.value.triggerUpScroll();
2025-11-20 17:45:41 +08:00
};
// 下拉刷新
const downCallback = async (mescroll) => {
try {
2025-11-28 16:42:57 +08:00
console.log("下拉刷新");
const res = await getList(1, upOption.value.page.size,undefined);
2025-11-20 17:45:41 +08:00
cssFlag.value = false;
list.value = res.list;
2025-12-18 17:57:09 +08:00
// mescroll.resetUpScroll()
2025-11-20 17:45:41 +08:00
} catch (error) {
mescroll.endErr();
} finally {
setTimeout(async ()=>{
mescroll.endSuccess();
},500);
}
}
// 上拉加载更多
const upCallback = async (mescroll) => {
try {
2025-11-28 16:42:57 +08:00
console.log("上拉加载更多",mescroll)
let res = await getList(mescroll.num, mescroll.size,lastId.value);
2025-11-20 17:45:41 +08:00
if (mescroll.num === 1) {
list.value = res.list;
} else {
list.value.push(...res.list);
}
mescroll.endBySize(res.list.length, res.total);
} catch (error) {
mescroll.endErr();
}
}
// 获取数据列表
2025-11-28 16:42:57 +08:00
const getList = (pageIndex, pageSize,last) => {
2025-11-20 17:45:41 +08:00
return new Promise(async (resolve) => {
let param = {
2025-11-28 16:42:57 +08:00
// pageIndex,
2025-11-20 17:45:41 +08:00
pageSize,
2025-11-27 18:18:19 +08:00
timeBegin: form.value.startDate,
timeEnd: form.value.endDate,
2025-11-28 16:42:57 +08:00
lastId:last,
taskType:taskTypeOptions[taskTypeIndex.value].value
2025-11-20 17:45:41 +08:00
}
2025-11-27 18:18:19 +08:00
let res = await taskLists(param);
let data = res ||{};
2025-11-28 16:42:57 +08:00
lastId.value = data.isEnd==1?undefined:data.lastId
2025-11-20 17:45:41 +08:00
resolve({
...data,
2025-11-28 16:42:57 +08:00
total: (data.isEnd==1?0:data.lastId) || 1, //是否最后一页(1-是,0-否)
lastId: data.isEnd==1?undefined:data.lastId
2025-11-20 17:45:41 +08:00
});
});
}
2025-11-20 18:14:15 +08:00
// 执行查询
2025-11-28 16:42:57 +08:00
const handleSearch= async ()=>{
let res = await getList(0,10);
cssFlag.value = false;
list.value = res.list;
2025-11-20 18:14:15 +08:00
}
2025-11-20 17:45:41 +08:00
// 查看详情
const handleDetail = (item,type) =>{
let url='/pages/business/polling/taskDetail?id='+item.taskId;
uni.navigateTo({
url
});
}
2025-11-14 18:30:34 +08:00
</script>
2025-11-20 17:45:41 +08:00
<style scoped>
.scroll-h{
/* #ifdef APP-PLUS */
2025-11-28 16:42:57 +08:00
height: calc(100vh - 148px);
2025-11-20 17:45:41 +08:00
/* #endif */
/* #ifndef APP-PLUS */
2025-11-28 16:42:57 +08:00
height: calc(100vh - 132px);
2025-11-20 17:45:41 +08:00
/* #endif */
}
.search{
display: flex;
align-items: center;
padding:0 30rpx;
}
.search .search-bg{
margin:20rpx 0;
line-height:56rpx;
}
.search .s-b-left{
width:230rpx;
display: flex;
align-items: center;
}
.search .s-b-right{
width:270rpx;
margin-left:20rpx;
margin-right:20rpx;
display: flex;
align-items: center;
}
.search .search-bg .img-icon,
.search .search-bg .img-type{
width:28rpx;
height: 28rpx;
margin-right:20rpx;
}
.search .search-bg .img-icon{
width:30rpx;
height:30rpx;
}
.search .search-btn{
width:150rpx;
color:#fff;
font-size:28rpx;
}
.week{
padding:0 40rpx;
color: #fff;
font-size:28rpx;
margin-bottom:10rpx;
}
.white-bg{
width: 670rpx;
padding: 30rpx 40rpx 40rpx;
margin-bottom: 0;
border-radius: 8px 8px 0 0;
}
.white-bg2{
border-radius: 0;
margin-top:20rpx;
}
.r-title{
width:670rpx;
color:#919191;
font-size:28rpx;
background-color: #F5F5F5;
margin-left:-40rpx;
padding:40rpx 40rpx 30rpx;
margin-bottom:15rpx;
}
.report-list{
position: relative;
}
.img-w{
width:50rpx;
height:50rpx;
}
.img-complete{
position: absolute;
right:-40rpx;
top:60rpx;
width:133rpx;
height:150rpx;
}
.report-border{
border-bottom:1px solid #E7E7E7;
width:710rpx;
height: 1px;
margin:20rpx 0;
}
2025-11-14 18:30:34 +08:00
2025-11-20 17:45:41 +08:00
.report-list .r-list{
padding: 5rpx 0;
}
.report-list .r-list .r-left{
display: flex;
}
.report-list .r-list .r-gray{
margin-left:10rpx;
}
.report-list .r-list .r-blue{
margin-left:10rpx;
font-weight: bold;
}
.report-list .r-list .r-red{
font-weight: bold;
}
.report-list .r-list .r-name{
width:525rpx
}
.r-left .r-l-left{
2025-11-28 16:42:57 +08:00
width:350rpx;
2025-11-20 17:45:41 +08:00
}
.r-left .r-l-right{
}
.no-data .no-pic{
display: block;
width:440rpx;
height:210rpx;
margin:40rpx auto;
}
2025-11-14 18:30:34 +08:00
</style>