<!--
 * @Title: 
 * @Description: 任务确认
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<view style="margin-top: 10px;margin-bottom: 10px;padding-left: 10px;padding-right: 10px;">
				<button style="background-color: lightcoral;" type="default" @click="toOrderConfirm()">任务确认</button>
			</view>
			<view style="padding-left: 10px;padding-right: 10px;">
				<text style="font-size: 0.6rem;color:gray;">备注：如您确认将负责处理该维修任务，请点击上方按钮，提交确认请求，开始进入维修处理流程。</text>
			</view>
			<uni-section title="辅助决策信息" titleFontSize="0.8rem" type="line">
				<uni-group style="margin-top: 0px;">
					<view class="items-line">
						<view class="item-text-lable">测站名称:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.rtuName}}</view>
 -->					</view>
					<view class="items-line">
<!-- 						<view class="item-text-lable">测站名称:</view> -->
						<view class="item-text-content"  style="margin-left: 0px;color: deepskyblue;">{{orderInfo.rtuName}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">测站编码:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.rtuCode}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">测站编码:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{orderInfo.rtuCode}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">行政区划:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">
							{{orderInfo.adCity}}/{{orderInfo.adDist}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">行政区划:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">
							{{orderInfo.adCity}}/{{orderInfo.adDist}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">经纬度:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.lng}},{{orderInfo.lat}}
						</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">经纬度:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{orderInfo.lng}},{{orderInfo.lat}}
						</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">安装位置:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.locationDesc}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">安装位置:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{orderInfo.locationDesc}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">测站类型:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{getSiteKind(orderInfo)}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">测站类型:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{getSiteKind(orderInfo)}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">最近上报数据:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{getSiteData(orderInfo)}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">最近上报数据:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{getSiteData(orderInfo)}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">最近上报时间:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.lastUpTime}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">最近上报时间:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{orderInfo.lastUpTime}}</view>
					</view>
					
					<view class="items-line line-space">
						<view class="item-text-lable">维修任务产生时间:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.createTime}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">维修任务产生时间:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{orderInfo.createTime}}</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">维修任务持续时长:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">{{orderInfo.taskCreateDuration}}
						</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">维修任务持续时长:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">{{orderInfo.taskCreateDuration}}
						</view>
					</view>
					<view class="items-line line-space">
						<view class="item-text-lable">异常类型:</view>
<!-- 						<view class="item-text-content" style="color: deepskyblue;">
							{{orderInfo.warnKindInfo}}</view>
 -->					</view>
					<view class="items-line line-space">
<!-- 						<view class="item-text-lable">异常类型:</view>
 -->						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">
							{{orderInfo.warnKindInfo}}</view>
					</view>
					<view class="items-line line-space">
						<view class="title">异常信息:</view>
					</view>
					<view class="items-line">
						<view class="item-text-content" style="margin-left: 0px;color: deepskyblue;">
							{{orderInfo.orderDesc}}</view>
					</view>
				</uni-group>
			</uni-section>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';

	export default {
		components: {

		},
		onLoad(option) {
			this.id = option.id;
			this.getDetail();
		},
		data() {
			return {
				title: '维修任务确认处理',
				id: '',
				orderInfo: {
					'id': 0,
					'updateTime': '',
					'orderDesc': '',
					'orderConfirm': 0,
				},
			}
		},
		computed: {
		},
		onShow() {
		},
		created() {
		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			getSiteKind(val) {
				let htmltext = '';
				if (val.isRain === 1) {
					htmltext = htmltext + "雨量站";
				}
				if (val.isRiver == 1 || val.isRes == 1) {
					if (htmltext.length > 0) {
						htmltext = htmltext + ' / ';
					}
					htmltext = htmltext + '水位站';
				}
				if (val.isGround == 1) {
					if (htmltext.length > 0) {
						htmltext = htmltext + ' / ';
					}
					htmltext = htmltext + '墒情站';
				}
				if (val.isVideo == 1) {
					if (htmltext.length > 0) {
						htmltext = htmltext + ' / ';
					}
					htmltext = htmltext + '视频站';
				}
				return htmltext;
			},
			getSiteData(val) {
				let htmltext = '';
				if (val.isRain === 1) {
					htmltext = htmltext + "降水：";
					if (val.drp) {
						htmltext = htmltext + val.drp;
					} else {
						htmltext = htmltext + "--";
					}
				}
				if (val.isRiver == 1) {
					if (htmltext.length > 0) {
						htmltext = htmltext + ' / ';
					}
					htmltext = htmltext + '水位：';
					if (val.z) {
						htmltext = htmltext + val.z;
					} else {
						htmltext = htmltext + "--";
					}
				} else if (val.isRes == 1) {
					if (htmltext.length > 0) {
						htmltext = htmltext + ' / ';
					}
					htmltext = htmltext + '水位：';
					if (val.rz) {
						htmltext = htmltext + val.rz;
					} else {
						htmltext = htmltext + "--";
					}
				}
				if (val.isGround == 1) {
					if (htmltext.length > 0) {
						htmltext = htmltext + ' / ';
					}
					htmltext = htmltext + '墒情含水层：';
					if (val.ground) {
						htmltext = htmltext + val.ground;
					} else {
						htmltext = htmltext + "--";
					}
				}
				return htmltext;
			},
			getDetail() {
				let that = this;
				let postData = {};
				postData['id'] = this.id;
				http.request({
					url: '/galaxy-business/rtu/check/order/detail',
					method: 'GET',
					data: postData
				}).then(res => {
					console.log(res)
					if (res.data != null) {
						that.orderInfo = res.data;
					}
				}).catch(err => {
					console.log(err)
				})
			},
			toOrderConfirm() {
				let that = this;
				uni.showModal({
					content: '确定接受该维修任务？',
					showCancel: true,
					success(res) {
						if (res.confirm) {
							let postData = {};
							postData['id'] = that.id;
							http.request({
								url: '/galaxy-business/rtu/check/order/confirm',
								method: 'POST',
								data: postData
							}).then(res => {
								console.log(res)
								if (res.success) {
									uni.showModal({
										content: '任务已确认，是否立即填报？',
										showCancel: true,
										cancelText: "返回",
										success(res) {
											if (res.confirm) {
												that.toOrderProcessReport();
											} else {
												that.toBack();
											}
										}
									});
								}
							}).catch(err => {
								console.log(err)
							})
						}
					}
				});
			},
			toOrderProcessReport() {
				var url = '/pages/check-order/orderprocessreport?orderId=' + this.id + '&skipPage=2';
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>

	.line-space {
		margin-top: 4px;
	}
</style>
