<template>
|
<view>
|
<view class="tab">
|
<u-tabs :itemStyle="{width: '160rpx' ,height: '88rpx' }" :activeStyle="{color: '#99bada' }" lineWidth="60"
|
:current="currentIndex" :list="tabList" @click="tabClick">
|
</u-tabs>
|
</view>
|
<view class="list">
|
|
<scroll-view scroll-y style="height: 85vh;width: 100%;" @scrolltolower="scrolltolower">
|
<card v-for="(item,index) in patrolTaskList" :key="index">
|
<template slot="insideHead">
|
<view class="head">
|
<u-row>
|
<u-col span="9">
|
<u-text :text="item.title" />
|
</u-col>
|
<u-col span="1">
|
</u-col>
|
<u-col span="3">
|
<u-text :text="item.patrolTypeName" />
|
</u-col>
|
</u-row>
|
</view>
|
</template>
|
<template slot="content">
|
<u-row>
|
<u-col span="9">
|
<view class="address">
|
<u-text :text="'描述:'+ item.content" />
|
</view>
|
</u-col>
|
<u-col span="1">
|
</u-col>
|
<u-col span="2">
|
<view class="start-patrol-button">
|
<u-button v-if="item.state !=3" type="primary" size="small"
|
:disabled="item.state == 3" :text="item.state=='1'?'开始巡查':'继续巡查'"
|
@click="startPatrol(item)" />
|
<u-button v-if="item.state == 3" type="primary" size="small" text="巡查详情"
|
@click="patrolDetail(item)" />
|
</view>
|
</u-col>
|
</u-row>
|
</template>
|
</card>
|
</scroll-view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import card from "@/components/my-components/card.vue"
|
import {
|
getPatrolTaskList,
|
getPatrolTaskStatistic,
|
updatePatrolTask
|
} from "@/api/patrol/patrol"
|
import {
|
dateFormat
|
} from "@/utils/date"
|
export default {
|
components: {
|
card
|
},
|
data() {
|
return {
|
patrolCountList: [],
|
patrolTaskList: [],
|
searchKey: "",
|
page: {
|
pageSize: 20,
|
currentPage: 1,
|
total: 0
|
},
|
query: {},
|
tabList: [{
|
name: "未开始"
|
},
|
{
|
name: "进行中"
|
},
|
{
|
name: "已完成"
|
},
|
],
|
currentIndex: 0
|
}
|
},
|
onShow() {},
|
created() {
|
this.init()
|
},
|
mounted() {},
|
methods: {
|
init() {
|
this.currentIndex = 0
|
this.getList(1)
|
},
|
//搜索
|
search(searchValue) {
|
this.query.title = searchValue
|
this.getList()
|
},
|
//清空搜索
|
clearSearch() {
|
this.query = {}
|
this.getList()
|
},
|
//开始巡查或继续巡查
|
startPatrol(item) {
|
if (item.state == "1") {
|
item.state = "2"
|
let date = new Date()
|
let realStartTime = dateFormat(date)
|
updatePatrolTask({
|
id: item.id,
|
state: item.state,
|
realStartTime: realStartTime
|
})
|
}
|
|
let url = "/subPackage/patrol/patrolReport?task=" + JSON.stringify(item)
|
this.$u.func.globalNavigator(url, "navTo")
|
},
|
|
//获取任务列表
|
getList(state) {
|
// 获取任务列表
|
// this.query.currentUserId = this.userInfo.user_id
|
this.query.toUserId = this.userInfo.user_id
|
this.query.state = state
|
getPatrolTaskList(this.page.currentPage, this.page.pageSize, this.query).then(res => {
|
const data = res.data;
|
this.page.total = data.total;
|
this.patrolTaskList = data.records
|
})
|
},
|
//上拉加载更多
|
scrolltolower() {
|
this.page.currentPage += 1
|
// 获取任务列表
|
this.query.currentUserId = this.userInfo.user_id
|
getPatrolTaskList(this.page.currentPage, this.page.pageSize, this.query).then(res => {
|
const data = res.data;
|
this.page.total = data.total;
|
this.patrolTaskList = this.patrolTaskList.concat(data.records)
|
})
|
},
|
//tab点击事件
|
tabClick(item) {
|
this.currentIndex = item.index
|
|
if (this.currentIndex == 0) {
|
this.page.currentPage = 1
|
this.getList(1)
|
} else if (this.currentIndex == 1) {
|
this.page.currentPage = 1
|
this.getList(2)
|
} else if (this.currentIndex == 2) {
|
this.page.currentPage = 1
|
this.getList(3)
|
}
|
|
},
|
//巡查详情
|
patrolDetail(task) {
|
let url = "/subPackage/patrol/patrolDetail?task=" + JSON.stringify(task)
|
this.$u.func.globalNavigator(url, "navTo")
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.tab {
|
display: flex;
|
align-items: center;
|
justify-content: space-around;
|
}
|
|
.search {
|
margin: 20rpx 0;
|
}
|
|
.content {
|
display: flex;
|
}
|
|
.footer {
|
display: flex;
|
justify-content: space-between;
|
}
|
|
.footer .icon {
|
display: flex;
|
|
}
|
|
.grid-text {
|
font-size: 2rpx;
|
color: #ada8a8;
|
margin: 20rpx 0;
|
}
|
</style>
|