<template>
	<view class="container">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
				<text style="color: white;font-size: 1rem;">{{title}}</text>
			</view>
		</uni-nav-bar>
		<view v-if="reportInfo.orderStatusKey==orderStatusCreateKey">
			<uSection title="工单说明" titleFontSize="0.8rem" type="line">
				<uCard :is-shadow="false">
					<text class="uni-body">{{reportInfo.processDesc}}</text>
				</uCard>
			</uSection>
			<uSection title="工单来源" titleFontSize="0.8rem" type="line">
				<uCard :is-shadow="false">
					<text class="uni-body">{{reportInfo.orderFromText}}</text>
				</uCard>
			</uSection>
		</view>
		<view v-else-if="reportInfo.orderStatusKey==orderStatusConfirmKey">
			<uSection title="工单说明" titleFontSize="0.8rem" type="line">
				<uCard :is-shadow="false">
					<text class="uni-body">{{reportInfo.processDesc}}</text>
				</uCard>
			</uSection>
			<uSection title="接单运维人员姓名" titleFontSize="0.8rem" type="line">
				<uCard :is-shadow="false">
					<text class="uni-body">{{reportInfo.orderConfirmUserName}}</text>
				</uCard>
			</uSection>
		</view>
		<view v-else-if="reportInfo.orderStatusKey==orderStatusProcessKey">
			<uSection title="工单说明" titleFontSize="0.8rem" type="line">
				<uCard :is-shadow="false">
					<text class="uni-body">{{reportInfo.processDesc}}</text>
				</uCard>
				<uCard v-if="reportInfo.basePhoto1Take ==1" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.basePhoto1Url)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">图片一</text>
							</view>
						</view>
					</template>
				</uCard>
				<uCard v-if="reportInfo.basePhoto2Take" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.basePhoto2Url)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">图片二</text>
							</view>
						</view>
					</template>
				</uCard>
			</uSection>
			<uSection title="RTU设备信息" titleFontSize="0.8rem" type="line">
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;">运行状态:</text>
						<text v-if="reportInfo.rtuStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>

				<uCard title="是否更换RTU" :is-shadow="false">
					<text v-if="reportInfo.rtuReplace==0" class="uni-body">否</text>
					<text v-else class="uni-body">更换</text>
				</uCard>

				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.rtuDesc}}</text>
				</uCard>
				<uCard v-if="reportInfo.rtuPhotoTake" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.rtuPhotoUrl)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">RTU图片</text>
							</view>
						</view>
					</template>
				</uCard>
			</uSection>

			<!-- 			<uSection v-if="reportInfo.rainSensorActive ==1" title="雨量传感器" titleFontSize="0.8rem" type="line"> -->
			<uSection title="雨量传感器" titleFontSize="0.8rem" type="line">
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;">运行状态:</text>
						<text v-if="reportInfo.rainSensorStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>
				<uCard title="是否更换雨量传感器" :is-shadow="false">
					<text v-if="reportInfo.rainSensorReplace==0" class="uni-body">否</text>
					<text v-else class="uni-body">更换</text>
				</uCard>
				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.rainSensorDesc}}</text>
				</uCard>
				<uCard v-if="reportInfo.rainSensorPhotoTake" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.rainSensorPhotoUrl)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">雨量传感器图片</text>
							</view>
						</view>
					</template>
				</uCard>
			</uSection>
			<!-- 			<uSection v-if="reportInfo.waterLevelSensorActive ==1" title="水位传感器" titleFontSize="0.8rem" type="line"> -->
			<uSection title="水位传感器" titleFontSize="0.8rem" type="line">
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;">运行状态:</text>
						<text v-if="reportInfo.waterLevelSensorStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>
				<uCard title="是否更换水位传感器" :is-shadow="false">
					<text v-if="reportInfo.waterSensorReplace==0" class="uni-body">否</text>
					<text v-else class="uni-body">更换</text>
				</uCard>
				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.waterSensorDesc}}</text>
				</uCard>
				<uCard v-if="reportInfo.waterSensorPhotoTake" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.waterSensorPhotoUrl)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">水位传感器图片</text>
							</view>
						</view>
					</template>
				</uCard>
			</uSection>
			<uSection title="墒情传感器" titleFontSize="0.8rem" type="line">
				<!-- 	<uSection v-if="reportInfo.groundWaterSensorActive ==1" title="墒情传感器" titleFontSize="0.8rem" type="line"> -->
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;">运行状态:</text>
						<text v-if="reportInfo.groundWaterSensorStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>
				<uCard title="是否更换墒情传感器" :is-shadow="false">
					<text v-if="reportInfo.groundSensorReplace==0" class="uni-body">否</text>
					<text v-else class="uni-body">更换</text>
				</uCard>
				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.groundSensorDesc}}</text>
				</uCard>
				<uCard v-if="reportInfo.groundSensorPhotoTake" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.groundSensorPhotoUrl)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">墒情传感器图片</text>
							</view>
						</view>
					</template>
				</uCard>
			</uSection>
			<uSection title="供电系统" titleFontSize="0.8rem" type="line">
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;">运行状态:</text>
						<text v-if="reportInfo.powerStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>
				<uCard title="是否更换蓄电池" :is-shadow="false">
					<text v-if="reportInfo.batteryReplace==0" class="uni-body">否</text>
					<text v-else class="uni-body">更换</text>
				</uCard>
				<uCard title="是否更换太阳能板" :is-shadow="false">
					<text v-if="reportInfo.sunPowerReplace==0" class="uni-body">否</text>
					<text v-else class="uni-body">更换</text>
				</uCard>
				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.powerDesc}}</text>
				</uCard>
				<uCard v-if="reportInfo.batteryPhotoTake" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.batteryPhotoUrl)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">蓄电池图片</text>
							</view>
						</view>
					</template>
				</uCard>
				<uCard v-if="reportInfo.sunPhotoTake" padding="0" spacing="0" :is-shadow="false">
					<template v-slot:cover>
						<view class="custom-cover">
							<image class="cover-image" style="width: 100%;" mode="aspectFill"
								:src="toOss(reportInfo.sunPhotoUrl)">
							</image>
							<view class="cover-content" style="text-align: center;">
								<text class="uni-subtitle uni-white" style="color: gray;">太阳能板图片</text>
							</view>
						</view>
					</template>
				</uCard>
			</uSection>
			<!-- 			<uSection v-if="reportInfo.networkActive ==1" title="4G移动网络" titleFontSize="0.8rem" type="line"> -->
			<uSection title="4G移动网络" titleFontSize="0.8rem" type="line">
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;">运行状态:</text>
						<text v-if="reportInfo.networkStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>
				<uCard title="是否欠费" :is-shadow="false">
					<text v-if="reportInfo.networkOverdue==0" class="uni-body">否</text>
					<text v-else class="uni-body">欠费</text>
				</uCard>
				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.networkDesc}}</text>
				</uCard>
			</uSection>
			<!-- 			<uSection v-if="reportInfo.satelliteActive ==1" title="北斗通讯" titleFontSize="0.8rem" type="line"> -->
			<uSection title="北斗通讯" titleFontSize="0.8rem" type="line">
				<template v-slot:right>
					<view style="padding-right: 15px;">
						<text style="font-size: 0.7rem;color: gray;">运行状态:</text>
						<text v-if="reportInfo.satelliteStatus == 0"
							style="font-size: 0.7rem;color: green;margin-left: 4px;">正常</text>
						<text v-else style="font-size: 0.7rem;color: orangered;margin-left: 4px;">故障</text>
					</view>
				</template>
				<uCard title="备注说明" :is-shadow="false">
					<text class="uni-body">{{reportInfo.satelliteDesc}}</text>
				</uCard>
			</uSection>
		</view>
		<view v-else>
			<uSection title="工单说明" titleFontSize="0.8rem" type="line">
				<uCard :is-shadow="false">
					<text class="uni-body">{{reportInfo.processDesc}}</text>
				</uCard>
			</uSection>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';
	import {
		pathToBase64,
		base64ToPath
	} from '@/js_sdk/mmmm-image-tools/index.js';
	import {
		oss,
		devUrl,
		prodUrl
	} from '@/common/setting';

	import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
	import uDataPicker from '@/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue'
	import uGroup from '@/uni_modules/uni-group/uni-group.vue'
	import uSection from '@/uni_modules/uni-section/uni-section.vue'
	import uPagination from '@/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue'
	import uBreadcrumb from '@/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue'
	import uList from '@/uni_modules/uni-list/components/uni-list/uni-list.vue'
	import uListItem from '@/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue'
	import uIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
	import uCard from '@/uni_modules/uni-card/components/uni-card/uni-card.vue'
	export default {
		components: {
			uNavBar,
			uDataPicker,
			uPagination,
			uBreadcrumb,
			uList,
			uListItem,
			uIcons,
			uGroup,
			uSection,
			uCard,
		},
		onLoad(options) {
			this.processId = options.processId;
			//this.rtuCode = options.rtuCode;
			this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
			//初始化巡检填报字典
			this.getReportDict();
			//查询计划信息
			//this.getPlanInfo();
			//this.getReportInfo();
		},
		data() {
			return {
				baseURL: '',
				reportId: 0,
				orderStatusCreateKey: 0,
				orderStatusConfirmKey: 0,
				orderStatusProcessKey: 0,
				orderStatusCloseKey: 0,
				reportInfo: {
					orderStatusKey: -1,
					orderConfirmUserName: '',
					orderFromText: '',
					processDesc: '测试测试',
					basePhoto1Url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					basePhoto1Take: true,
					basePhoto2Url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					basePhoto2Take: true,

					rtuStatus: 0,
					rtuDesc: '测试测试',
					rtuReplace: 1,
					rtuPhotoUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					rtuPhotoTake: true,

					rainSensorActive: 1,
					rainSensorStatus: 0,
					rainSensorDesc: '测试测试',
					rainSensorReplace: 0,
					rainSensorPhotoUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					rainSensorPhotoTake: true,


					waterSensorReplace: 0,
					waterSensorDesc: '测试测试',
					waterSensorPhotoUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					waterSensorPhotoTake: true,
					waterLevelSensorActive: 1,
					waterLevelSensorStatus: 1,


					groundSensorReplace: 0,
					groundSensorDesc: '测试测试',
					groundSensorPhotoUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					groundSensorPhotoTake: true,
					groundWaterSensorActive: 1,
					groundWaterSensorStatus: 0,

					batteryReplace: 0,
					sunPowerReplace: 0,
					batteryPhotoUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					batteryPhotoTake: true,
					sunPhotoUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
					sunPhotoTake: true,
					powerDesc: '测试测试',
					powerStatus: 0,

					networkOverdue: 1,
					networkDesc: '111',
					networkStatus: 0,
					networkActive: 1,

					satelliteStatus: 0,
					satelliteDesc: '测试测试',
					satelliteActive: 0,
				},
				title: '工单填报详情',
				desc: '',
			}
		},
		computed: {
			getIcon() {
				return path => {
					return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
				}
			},
		},
		onShow() {

		},
		created() {

		},
		methods: {
			toOss(path) {
				return oss + path;
			},
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			dateFormat(dt) {
				var text = "" + dt.getFullYear();
				text += "-";
				text += ((dt.getMonth() + 1) < 10) ? ("0" + (dt.getMonth() + 1)) : (dt
					.getMonth() +
					1);
				text += "-";
				text += dt.getDate() < 10 ? "0" + dt.getDate() : dt.getDate();
				text += " ";
				text += dt.getHours() < 10 ? "0" + dt.getHours() : dt.getHours();
				text += ":";
				text += dt.getMinutes() < 10 ? "0" + dt.getMinutes() : dt.getMinutes();
				text += ":";
				text += dt.getSeconds() < 10 ? "0" + dt.getSeconds() : dt.getSeconds();
				return text;
			},
			getReportDict() {

				var that = this;
				//查询北斗模式

				http.request({
					url: '/galaxy-system/dict-biz/dictionary?code=rtu_check_order_status',
					method: 'GET'
				}).then(res => {
					console.log(res.data)
					if (res.data != null) {
						const dictLength = res.data['length'];
						for (var i = 0; i < dictLength; i++) {
							let dict = res.data[i];
							if (dict.dictKey === '1') {
								that.orderStatusCreateKey = dict.id;
							} else if (dict.dictKey === '2') {
								that.orderStatusConfirmKey = dict.id;
							} else if (dict.dictKey === '3') {
								that.orderStatusProcessKey = dict.id;
							} else if (dict.dictKey === '4') {
								that.orderStatusCloseKey = dict.id;
							}

						}

						that.getReportInfo();
					}

				}).catch(err => {
					console.log(err)
				})
			},
			getReportInfo() {
				var that = this;
				var postData = {};
				postData['id'] = this.processId;
				console.log("processId ", this.processId);
				http.request({
					url: '/galaxy-test/rtu/check/order/process/detail',
					method: 'GET',
					data: postData
				}).then(res => {
					console.log(res.data)
					if (res.data != null) {
						that.reportInfo = res.data;
						//that.reportInfo.orderStatusKey=res.data.orderStatusKey;
					}
				}).catch(err => {
					console.log(err)
				})
			},
		}
	}
</script>

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

	.cell-hover-class {
		background-color: rgb(235, 237, 238);
	}

	.view-flex-rs {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
	}

	.view-flex-rc {
		display: flex;
		flex-direction: row;
		justify-content: center;
	}

	.view-flex-re {
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
	}

	.view-flex-cs {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}

	.view-flex-cc {
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

	.view-flex-ce {
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
	}

	.line-body {
		padding-left: 10px;
		padding-right: 10px;
	}

	.required-star {
		color: #FF0000;
		font-size: 15px;
		width: 20px;
		text-align: center;
		padding-left: 0px;
		padding-right: 2px;
	}

	.item-title {
		color: #909399;
		font-size: 15px;
	}

	.mline-text {
		padding-left: 2px;
		width: 100%;
		/* background-color:#909399; */
		height: 70px;
		border: 1px solid #FF5A5F;
		border-radius: 5px;
	}
</style>

<style lang="scss" scoped>
	.container {
		padding: 0 0 50rpx;
	}

	.uni-body {
		font-size: 0.8rem;
	}

	.u-cell-icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 8rpx;
	}

	.slot-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
	}

	.slot-image {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		margin-right: 10px;
		width: 30px;
		height: 30px;
	}

	.slot-text {
		flex: 1;
		font-size: 14px;
		color: #4cd964;
		margin-right: 10px;
	}

	.img-container {
		margin-bottom: 0px;
		width: 100px;
		height: 100px;

		.note-image-box {
			margin-top: 0px;
			display: flex;
			flex-wrap: wrap;
			padding: 10px;

			.note-image-item {
				position: relative;
				width: 100%;
				height: 0;
				padding-top: 100%;
				box-sizing: border-box;
				// background-color: #18B566;


				.close-icon {
					display: flex;
					justify-content: center;
					align-items: center;
					position: absolute;
					right: 0px;
					top: 0px;
					width: 22px;
					height: 22px;
					border-radius: 50%;
					background-color: #d5d5d5;
					z-index: 2;
				}

				.image-box {
					display: flex;
					justify-content: center;

					align-items: center;
					position: absolute;
					top: 5px;
					right: 5px;
					border: 5px;
					left: 5px;
					border: 1px #eee solid;
					border-radius: 5px;
					overflow: hidden;
					width: 98%;
					height: 98%;

				}


			}
		}
	}

	.input-body {
		background-color: #fff;
		padding: 10px;
	}
</style>
