xytSk-App/pages/xcrw/detail/index.vue

264 lines
6.0 KiB
Vue
Raw Normal View History

2024-10-15 15:05:52 +08:00
<template>
2024-11-07 16:40:56 +08:00
<view :style="{height:'100vh'}">
2024-10-15 15:05:52 +08:00
<u-status-bar></u-status-bar>
<u-navbar :title="taskTitle" :autoBack="true" :titleStyle="{
fontSize:'18px'
}" :height='44' :safeAreaInsetTop=true leftIconSize='20' leftIconColor='rgb(153, 153, 153)'>
</u-navbar>
2024-11-08 18:00:54 +08:00
<view class=""
style="margin-top: 44px;;background-color: #f0f0f0;border-top: 1px solid #f0f0f0; height:calc(100vh - 44px)">
<view style="margin: 10px;background-color: #fff;padding: 10px;" v-show="btnStatus == 0">
2024-10-15 15:05:52 +08:00
<view class="item">
<view class="blueTiao"></view>
<view class="title">
基本信息
</view>
</view>
<view class="contentItem">
2024-11-08 18:00:54 +08:00
<view class="itemC">
2024-10-15 15:05:52 +08:00
<text>任务标题</text>
<text>{{taskTitle}}</text>
</view>
<view class="itemC">
<text>任务类型</text>
2024-11-11 11:55:29 +08:00
<text>{{taskType == 0? "日常巡查" : taskType == 2 ? "特别检查" : taskType == 3 ? "汛前巡检" : '' }}</text>
2024-10-15 15:05:52 +08:00
</view>
<view class="itemC">
<text>任务内容</text>
<text>{{taskContent ? taskContent : ''}}</text>
</view>
<view class="itemC">
<text>开始日期</text>
<text>{{startDate}}</text>
</view>
<view class="itemC">
<text>结束日期</text>
<text>{{endDate}}</text>
</view>
</view>
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
</view>
2024-11-08 18:00:54 +08:00
<view v-show="status !== 2 && btnStatus == 0" style="display:flex;justify-content: center;margin-top: 20%;">
<view v-show="status !== 2 && btnStatus == 0" class="circle-btn" @click="startXc">{{statusType[status]}}
2024-10-15 15:05:52 +08:00
</view>
2024-11-08 18:00:54 +08:00
</view>
<view class="" style="height: calc(100vh - 50px);overflow: auto;">
<view v-show="btnStatus != 0" style="margin: 10px;background-color: #fff;padding: 10px;height: calc(100% - 40px);">
2024-10-15 15:05:52 +08:00
<view class="item">
2024-11-08 18:00:54 +08:00
<view class="blueTiao"></view>
<view class="title">
巡检项
</view>
</view>
<view class="contentItem1" style="height: calc(100% - 32px);">
<db-form :xjItem="xjItem"></db-form>
2024-10-15 15:05:52 +08:00
</view>
</view>
2024-11-08 18:00:54 +08:00
</view>
2024-10-15 15:05:52 +08:00
</view>
</view>
</template>
<script>
import moment from 'moment'
2024-10-16 18:02:59 +08:00
import DbForm from './dbForm.vue'
2024-10-15 15:05:52 +08:00
export default {
2024-11-08 18:00:54 +08:00
components: {
2024-10-16 18:02:59 +08:00
DbForm
},
2024-10-15 15:05:52 +08:00
data() {
return {
2024-11-08 18:00:54 +08:00
taskTitle: '',
taskType: '',
taskContent: '',
startDate: '',
endDate: '',
status: '',
id: '',
2024-10-15 15:05:52 +08:00
btnStatus: 0,
2024-11-08 18:00:54 +08:00
xjItem: [],
list: ["正常", "异常"],
current: 3,
statusType: {
0: '开始巡查',
1: '继续巡查',
2: '已完成'
2024-11-07 16:40:56 +08:00
},
2024-10-15 15:05:52 +08:00
};
},
methods: {
// 开始巡查
2024-11-08 18:00:54 +08:00
async startXc() {
2024-10-15 15:05:52 +08:00
try {
2024-11-08 18:00:54 +08:00
if (this.status == 0) {
const {
data
} = await uni.$http.get(`/gunshiApp/xyt/inspect/task/startInspect/${this.id}`)
if (data.code == 200) {
2024-11-07 16:40:56 +08:00
this.btnStatus = 1;
this.getXjItem(this.id)
}
2024-11-08 18:00:54 +08:00
} else if (this.status == 1) {
2024-11-07 16:40:56 +08:00
this.btnStatus = 1;
this.getXjItem(this.id)
}
this.getLocationWithInterval();
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
} catch (error) {
uni.$showMsg();
}
},
2024-11-08 18:00:54 +08:00
// 获取巡查项
async getXjItem(id) {
2024-10-15 15:05:52 +08:00
try {
2024-11-08 18:00:54 +08:00
const {
data
} = await uni.$http.get(`/gunshiApp/xyt/inspect/detail/info?taskId=${id}`)
if (data.code == 200) {
2024-10-15 15:05:52 +08:00
this.xjItem = data.data
}
} catch (error) {
uni.$showMsg();
}
},
getLocationWithInterval() {
this.getLocation(); // 首次获取经纬度信息
// 设置定时器每隔5秒获取一次经纬度信息
2024-11-08 18:00:54 +08:00
let timer = setInterval(() => {
this.getLocation();
}, 300000); // 五分钟
uni.setStorageSync("timer", timer);
},
// 获取经纬度
getLocation() {
uni.getLocation({
type: 'gcj02',
success: (res) => {
this.latitude = res.latitude;
this.longitude = res.longitude;
2024-11-08 18:00:54 +08:00
this.sendLocation(res.latitude, res.longitude)
},
fail: (err) => {
console.log('Failed to get location:', err);
}
});
},
// 将经纬度传给服务器
async sendLocation(latitude, longitude) {
2024-11-08 18:00:54 +08:00
try {
const {
data
} = await uni.$http.post(`/gunshiApp/xyt/inspectTaskTrack/insert`, {
taskId: this.id,
lttd: latitude,
lgtd: longitude
})
if (data.code == 200) {
console.log('Location sent successfully')
}
} catch (error) {
uni.$showMsg();
}
}
2024-10-15 15:05:52 +08:00
},
2024-11-08 18:00:54 +08:00
onLoad(option) {
2024-10-15 15:05:52 +08:00
this.taskTitle = option.taskTitle
2024-11-07 16:40:56 +08:00
this.taskType = option.taskType
2024-11-08 18:00:54 +08:00
this.taskContent = option.taskContent == "null" ? null : option.taskContent
2024-11-11 14:09:30 +08:00
this.startDate = option.startDate == "null" ? "" : option.startDate
2024-10-15 15:05:52 +08:00
this.endDate = option.endDate == "null" ? "" : option.endDate
this.status = option.status
this.id = option.id
}
}
</script>
<style lang="scss" scoped>
.myTitleStyle {
font-size: 30px;
background-color: red;
height: 200px;
}
.tabsClass {
margin-top: 44px;
height: 44px;
padding: 0 40px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
}
2024-11-08 18:00:54 +08:00
.circle-btn {
2024-11-07 16:40:56 +08:00
width: 120px;
height: 120px;
background-color: #007aff;
border-radius: 50%;
2024-11-08 18:00:54 +08:00
color: #fff;
2024-11-07 16:40:56 +08:00
text-align: center;
line-height: 120px;
}
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
.item {
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
padding-bottom: 10px;
display: flex;
align-items: center;
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
// justify-content: space-between;
2024-11-08 18:00:54 +08:00
.blueTiao {
2024-10-15 15:05:52 +08:00
background-color: #007aff;
width: 5px;
height: 16px;
margin-right: 10px;
}
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
.title {
border-width: 0px;
font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑', sans-serif;
font-weight: 700;
font-style: normal;
font-size: 15px;
color: #666666
}
.titleRight {
display: flex;
2024-11-08 18:00:54 +08:00
2024-10-15 15:05:52 +08:00
.border {
border-width: 0px;
background-color: rgba(236, 245, 255, 1);
box-sizing: border-box;
border-width: 1px;
border-style: solid;
border-color: rgba(187, 220, 255, 1);
border-radius: 5px;
box-shadow: none;
width: 58px;
height: 25px;
color: #689FFF;
text-align: center;
}
}
}
2024-11-08 18:00:54 +08:00
.contentItem {
.itemC {
2024-10-15 15:05:52 +08:00
display: flex;
justify-content: space-between;
display: flex;
color: #666666;
padding: 10px;
border-bottom: 1px solid #f0f0f0;
}
2024-11-08 18:00:54 +08:00
.itemNo {
2024-10-15 15:05:52 +08:00
color: #666666;
padding: 10px;
}
}
</style>