<!--
 * @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">
			<uni-section title="测站信息" titleFontSize="0.8rem" type="line">
				<uni-card :is-shadow="false">
					<view style="width: 100%;padding-left: 0px;padding-right: 10px;">
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">测站名称:</view>
							<view style="font-size: 0.7rem;color: gray;">{{orderInfo.rtuName}}</view>
						</view>
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">测站编码:</view>
							<view style="font-size: 0.7rem;color: gray;">{{orderInfo.rtuCode}}</view>
						</view>
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">测站类型:</view>
							<view style="display: flex;flex-direction: row;align-items: center;">
								<view v-if="orderInfo.isRain ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">雨量站</view>
								<view v-if="orderInfo.isRiver ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">水位站</view>
								<view v-else-if="orderInfo.isRes ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">水位站</view>
								<view v-if="orderInfo.isGround ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">墒情站</view>
							</view>
						</view>
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">行政区划:</view>
							<view style="font-size: 0.7rem;color: gray;">{{orderInfo.adCity}}/{{orderInfo.adDist}}
							</view>
						</view>
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">经纬度:</view>
							<view style="display: flex;flex-direction: row;align-items: center;">
								<view style="margin-right: 5px;font-size: 0.7rem;color: gray;">经度：{{orderInfo.lng}}
								</view>
								<view style="margin-right: 5px;font-size: 0.7rem;color: gray;">纬度：{{orderInfo.lat}}
								</view>
							</view>
						</view>
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">安装位置:</view>
							<view style="font-size: 0.7rem;color: gray;">{{orderInfo.locationDesc}}</view>
						</view>
					</view>
				</uni-card>
			</uni-section>
			<uni-section title="测站数据" titleFontSize="0.8rem" type="line">
				<uni-card :is-shadow="false">
					<view style="width: 100%;padding-left: 0px;padding-right: 10px;">
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">最近上报数据:</view>
							<view style="display: flex;flex-direction: row;align-items: center;">
								<view v-if="orderInfo.isRain ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">降水：{{orderInfo.drp}}</view>
								<view v-if="orderInfo.isRiver ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">水位：{{orderInfo.z}}</view>
								<view v-else-if="orderInfo.isRes ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">水位：{{orderInfo.rz}}
								</view>
								<view v-if="orderInfo.isGround ==1"
									style="margin-right: 5px;font-size: 0.7rem;color: gray;">墒情：</view>
							</view>
						</view>
						<view style="margin-top: 5px;display: flex;flex-direction: column;">
							<view style="font-size: 0.7rem;color: black;">最近上报时间:</view>
							<view style="font-size: 0.7rem;color: gray;">{{orderInfo.lastUpTime}}</view>
						</view>
					</view>
				</uni-card>
			</uni-section>
		</view>
	</view>
</template>

<script>
	import {
		role
	} from "@/api/role.js";
	import http from '@/http/api.js';

	export default {
		components: {},
		onLoad(option) {
			this.rtuCode = option.rtuCode;
			if (this.userInfo.role_name === role['admin']) {
				this.permission.admin = true;
			} else if (this.userInfo.role_name === role['orgAdmin']) {
				this.permission.orgAdmin = true;
			} else if (this.userInfo.role_name === role['companyAdmin']) {
				this.permission.companyAdmin = true;
			} else if (this.userInfo.role_name === role['companyServciePerson']) {
				this.permission.companyServciePerson = true;
			}
			this.getOrderInfo();
		},
		data() {
			return {
				permission: {
					'admin': false,
					'orgAdmin': false,
					'companyAdmin': false,
					'companyServciePerson': false,
				},
				rtuCode: '',
				orderInfo: {

				},
				title: '测站基础信息',
			}
		},
		computed: {},
		onShow() {
			this.getOrderInfo();
		},
		created() {},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 分页触发
			change(e) {
				this.selectedIndexs.length = 0
				this.pageCurrent = e.current;
				this.getOrderList()
			},
			getOrderInfo() {
				var that = this;
				var postData = {};
				postData['rtuCode'] = this.rtuCode;
				http.request({
					url: '/galaxy-business/rtu/base/detail',
					method: 'GET',
					data: postData
				}).then(res => {
					console.log(res)
					if (res.data != null) {
						that.orderInfo = res.data;
					}
				}).catch(err => {
					console.log(err)
				})

			},
			toOrderConfirm() {
				var that = this;
				uni.showModal({
					content: '确定进行维修确认操作？',
					showCancel: true,
					success(res) {
						if (res.confirm) {
							var postData2 = {};
							postData2['id'] = that.orderId;
							http.request({
								url: '/galaxy-business/rtu/check/order/confirm',
								method: 'POST',
								data: postData2
							}).then(res => {
								console.log(res)
								if (res.success) {
									uni.showModal({
										content: '确认已成功，是否立即填报？',
										showCancel: true,
										success(res) {
											if (res.confirm) {

												var url =
													'/pages/check-order/orderprocessreport?orderId=' +
													that.orderId;
												uni.navigateTo({
													url: url
												})
											}
										}
									});
								}
							}).catch(err => {
								console.log(err)
							})
						}
					}
				});
			},
			toOrderProcessReport() {
				var url = '/pages/check-order/orderprocessreport?orderId=' + this.orderId;
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

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

<style lang="scss" scoped>

</style>
