<!--
 * @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-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
				activeColor="#585b61"></uni-segmented-control>
			<view class="content">
				<view v-show="current === 0">
					<inspectionreportdetail :inspectionId="inspectionReportStatus.beforeRainSeasonReportId"
						v-if="inspectionReportStatus.beforeRainSeasonStatus==1">
					</inspectionreportdetail>
					<view v-else style="display: flex;flex-direction: row;justify-content: center;">
						<text style="color: red;font-size: 0.7rem;margin-top: 20px;">汛前巡检暂未填报</text>
					</view>
				</view>
				<view v-show="current === 1">
					<inspectionreportdetail :inspectionId="inspectionReportStatus.rainSeasonFirstReportId"
						v-if="inspectionReportStatus.rainSeasonFirstStatus==1">
					</inspectionreportdetail>
					<view v-else style="display: flex;flex-direction: row;justify-content: center;">
						<text style="color: red;font-size: 0.7rem;margin-top: 20px;">汛中第一次巡检暂未填报</text>
					</view>
				</view>
				<view v-show="current === 2">
					<inspectionreportdetail :inspectionId="inspectionReportStatus.rainSeasonSecondReportId"
						v-if="inspectionReportStatus.rainSeasonSecondStatus==1">
					</inspectionreportdetail>
					<view v-else style="display: flex;flex-direction: row;justify-content: center;">
						<text style="color: red;font-size: 0.7rem;margin-top: 20px;">汛中第二次巡检暂未填报</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';
	import inspectionreportdetail from '@/pages/equipment-inspection/inspectionreportdetail.vue'
	export default {
		components: {
			inspectionreportdetail
		},
		onLoad(options) {
			this.rtuCode = options.rtuCode;
			this.query['rtuCode'] = this.rtuCode;
			console.log("onLoad")
			this.getInspectionReportStatus();
		},
		data() {
			return {
				rtuCode: '',
				items: ['汛前巡检', '汛中（一）巡检', '汛中（二）巡检'],
				current: -1,
				inspectionReportStatus: {
					beforeRainSeasonReportId: 0,
					rainSeasonFirstReportId: 0,
					rainSeasonSecondReportId: 0,
					beforeRainSeasonStatus: 0,
					rainSeasonFirstStatus: 0,
					rainSeasonSecondStatus: 0,
				},
				query: {},
				title: '测站巡检填报详情',
			}
		},
		computed: {

		},
		onShow() {
			console.log("onShow")
		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			getInspectionReportStatus(params = {}) {
				let that = this;
				let postData = Object.assign(params, this.query);
				console.log(JSON.stringify(postData))
				http.request({
					url: '/galaxy-business/equipment/inspection/rtu/reportStatus',
					method: 'GET',
					data: postData
				}).then(res => {
					//console.log(JSON.stringify(res))
					if (res != null && res.success) {
						if (res.data != null) {
							that.inspectionReportStatus = res.data;
							if (that.inspectionReportStatus.rainSeasonSecondStatus == 1) {
								that.current = 2;
							} else if (that.inspectionReportStatus.rainSeasonFirstStatus == 1) {
								that.current = 1;
							} else if (that.inspectionReportStatus.beforeRainSeasonStatus == 1) {
								that.current = 0;
							}
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			},
		}
	}
</script>

<style>

</style>

<style lang="scss" scoped>
	.nav-title {
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;

		text {
			color: white;
			font-size: 1rem;
		}
	}

	.container {
		padding: 0 0 50rpx;
		width: 100%;
	}

	.content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: flex-start;
		flex-direction: column;
		width: 100%;

	}
</style>
