<!--
 * @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-list>
				<uni-list-item v-for="item in list" :key="item.id">
					<template v-slot:body>
						<view class="list-item-block">
							<view class="items-line">
								<image class="item-title-run-status-icon" style="box-shadow:0 0 2px 2px lightblue"
									src="/static/images/list/inspection_item.png" mode="widthFix">
								</image>
								<text class="item-title-rtu-name">{{item.rtuName}}</text>
								<text class="item-title-rtu-code">[{{item.rtuCode}}]</text>
							</view>
							<view v-if="rainSeasonKind==0" style="margin-top: 2px;">
								<view class="items-line">
									<text v-if="item.beforeRainSeasonStatus ==1"
										class="item-text-content">汛前：{{item.beforeRainSeasonReportUserName}}/{{item.beforeRainSeasonReportTime}}</text>
								</view>
								<view class="items-line">
									<text v-if="item.rainSeasonFirstStatus ==1"
										class="item-text-content">汛中（一）：{{item.rainSeasonFirstReportUserName}}/{{item.rainSeasonFirstReportTime}}</text>
								</view>
								<view class="items-line">
									<text v-if="item.rainSeasonSecondStatus ==1"
										class="item-text-content">汛中（二）：{{item.rainSeasonSecondReportUserName}}/{{item.rainSeasonSecondReportTime}}</text>
								</view>
							</view>
							<view v-else>
								<view class="items-line" style="margin-top: 2px;">
									<uni-icons class="input-uni-icon" type="auth" size="18" color="lightblue" />
									<text class="item-text-lable">填报人：</text>
									<text v-if="rainSeasonKind ==1"
										class="item-text-content">{{item.beforeRainSeasonReportUserName}}</text>
									<text v-else-if="rainSeasonKind ==2"
										class="item-text-content">{{item.rainSeasonFirstReportUserName}}</text>
									<text v-else-if="rainSeasonKind ==3"
										class="item-text-content">{{item.rainSeasonSecondReportUserName}}</text>
								</view>
								<view class="items-line" style="margin-top: 2px;">
									<uni-icons class="input-uni-icon" type="calendar" size="18" color="lightblue" />
									<text class="item-text-lable">填报时间：</text>
									<text v-if="rainSeasonKind ==1"
										class="item-text-content">{{item.beforeRainSeasonReportTime}}</text>
									<text v-else-if="rainSeasonKind ==2"
										class="item-text-content">{{item.rainSeasonFirstReportTime}}</text>
									<text v-else-if="rainSeasonKind ==3"
										class="item-text-content">{{item.rainSeasonSecondReportTime}}</text>
								</view>
							</view>
							<view class="item-button-group">
								<view v-if="item.beforeRainSeasonStatus ==1" class="item-button"
									@click="onBeforeRainDetailViewClick(item.beforeRainSeasonReportId)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="info" size="18" color="coral" />
										<text class="button-text">汛前详情</text>
									</view>
								</view>
								<view v-if="item.rainSeasonFirstStatus ==1" class="item-button"
									@click="onRainFirstDetailViewClick(item.rainSeasonFirstReportId)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="info" size="18" color="coral" />
										<text class="button-text">汛中(一)详情</text>
									</view>
								</view>
								<view v-if="item.rainSeasonSecondStatus ==1" class="item-button"
									@click="onRainSencodDetailViewClick(item.rainSeasonSecondReportId)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="info" size="18" color="coral" />
										<text class="button-text">汛中(二)详情</text>
									</view>
								</view>
							</view>
						</view>
					</template>
				</uni-list-item>
			</uni-list>
			<uni-group>
				<view class="pagination-block">
					<uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total"
						@change="pageChange" />
				</view>
			</uni-group>
		</view>
	</view>
</template>

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

	export default {
		components: {},
		onLoad(option) {
			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.rainSeasonKind = option.rainSeasonKind;
			this.query['deptId'] = option.deptId;

			if (this.rainSeasonKind == 0) {
				this.title = '年度已巡检设备信息';
			} else if (this.rainSeasonKind == 1) {
				this.title = '汛前已巡检设备信息';
				this.query['rainSeasonKind'] = option.rainSeasonKind;
			} else if (this.rainSeasonKind == 2) {
				this.title = '汛中(一)已巡检设备信息';
				this.query['rainSeasonKind'] = option.rainSeasonKind;
			} else if (this.rainSeasonKind == 3) {
				this.title = '汛中(二)已巡检设备信息';
				this.query['rainSeasonKind'] = option.rainSeasonKind;
			}
			console.log(JSON.stringify(this.query))
			this.getPage();
		},
		data() {
			return {
				rainSeasonKind: 0,
				title: '已巡检设备信息',
				permission: {
					'admin': false,
					'orgAdmin': false,
					'companyAdmin': false,
					'companyServciePerson': false,
				},
				list: [],
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				query: {},
				inputStyles: {
					color: '#808080',
					borderColor: '#d3d3d3'
				}
			}
		},
		computed: {
		},
		onShow() {
		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			onBackPress() {
				// #ifdef APP-PLUS
				plus.key.hideSoftKeybord();
				// #endif
			},
			// 分页触发
			pageChange(e) {
				this.pageCurrent = e.current;
				this.getPage()
			},
			onBeforeRainDetailViewClick(id) {
				console.log("onDetailViewClick " + id)
				var url = '/pages/equipment-inspection/inspectionreportview?type=1&id=' + id;
				uni.navigateTo({
					url: url
				})
			},
			onRainFirstDetailViewClick(id) {
				console.log("onDetailViewClick " + id)
				var url = '/pages/equipment-inspection/inspectionreportview?type=2&id=' + id;
				uni.navigateTo({
					url: url
				})
			},
			onRainSencodDetailViewClick(id) {
				console.log("onDetailViewClick " + id)
				var url = '/pages/equipment-inspection/inspectionreportview?type=3&id=' + id;
				uni.navigateTo({
					url: url
				})
			},
			getPage(params = {}) {
				let that = this;
				const current = this.pageCurrent;
				const size = this.pageSize;
				let postData = Object.assign(this.query, params);
				http.request({
					url: '/galaxy-business/equipment/inspection/rain/page',
					method: 'GET',
					params: {
						current,
						size,
					},
					data: postData,
				}).then(res => {
					if (res.data != null) {
						if (res.data.records != null) {
							that.list = res.data.records;
						}
						this.total = res.data.total;
					}
				}).catch(err => {
					console.log(err)
				})
			},
		}
	}
</script>

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

<style lang="scss" scoped>

</style>
