<!--
 * @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 v-if="type==1">
				<uni-collapse @change="searchAreaStatus">
					<uni-collapse-item :show-animation="true" :open="true">
						<template v-slot:title>
							<view class="view-flex-block-center" style="height: 40px;width: 100%;">
								<view class="view-flex-inline-center">
									<text v-if="showSearch" style="color: coral;font-size: 1rem;">点击收起查询区</text>
									<text v-else style="color: coral;font-size: 1rem;">点击展开查询区</text>
								</view>
							</view>
						</template>
					</uni-collapse-item>
				</uni-collapse>
				<view v-if="showSearch" class="search-block">
					<view style="padding-left: 10px;padding-right: 10px;margin-top: 10px;">
						<view>
							<uni-data-select v-model="cityRegionValue" :localdata="cityRegionData"
								@change="cityRegionChange" :clear="false" placeholder="请选择盟市"></uni-data-select>
						</view>
						<view style="margin-top: 10px;">
							<uni-data-select v-model="districtRegionValue" :localdata="districtRegionData"
								@change="districtRegionChange" placeholder="请选择区旗县"></uni-data-select>
						</view>
						<view style="margin-top: 10px;">
							<uni-data-select v-model="townRegionValue" :localdata="townRegionData"
								@change="townRegionChange" placeholder="请选择乡镇"></uni-data-select>
						</view>
						<view style="margin-top: 10px;">
							<uni-data-select v-model="countryRegionValue" :localdata="countryRegionData"
								@change="countryRegionChange" placeholder="请选择村"></uni-data-select>
						</view>
						<view style="margin-top: 10px;">
							<uni-data-select v-model="dangerAreaValue" :localdata="dangerAreaData"
								@change="dangerAreaChange" placeholder="请选择危险区"></uni-data-select>
						</view>
					</view>
				</view>
			</view>
			<view v-if="list.length>0">
				<uni-list>
					<uni-list-item v-for="item in list" :key="item.id">
						<template v-slot:body>
							<view class="list-item-block">
								<view v-if="item.checkType == 1" class="line">
									<text class="content" style="color: blue;">独立巡查</text>
								</view>
								<view v-else class="line">
									<text class="content" style="color: blue;">应急发起巡查</text>
								</view>
								<view class="line">
									<text class="content">巡查时间：{{item.createTime}}</text>
								</view>
								<view class="line">
									<text class="content text-ellipsis">行政区：{{item.adName}}</text>
								</view>
								<view class="line">
									<text class="content text-ellipsis">危险区：{{item.dangerAreaName}}</text>
								</view>
								<view v-if="item.isFlood == 0" class="line">
									<text class="content">是否有山洪：否</text>
								</view>
								<view v-else class="line">
									<text class="content">是否有山洪：有</text>
								</view>
								<view v-if="item.isDamage == 0" class="line">
									<text class="content">是否成灾：否</text>
								</view>
								<view v-else class="line">
									<text class="content">是否成灾：是</text>
								</view>
								<view v-if="item.isWarn == 0" class="line">
									<text class="content">是否预警：否</text>
								</view>
								<view v-else class="line">
									<text class="content">是否预警：是</text>
								</view>
								<view v-if="item.isTransfer == 0" class="line">
									<text class="content">是否转移：否</text>
								</view>
								<view v-else class="line">
									<text class="content">是否转移：是</text>
								</view>
								<!-- 					<view class="line">
									<text class="content text-ellipsis">备注：{{item.remark}}</text>
								</view> -->
								<view class="item-button-group" style="padding-right: 10px;">
									<!-- 					<view class="item-button mid-size" @click="onCheckPhotoClick(item)">
										<view class="items-line">
											<uni-icons class="input-uni-icon" type="location" size="18" color="coral" />
											<text class="button-text">查看图片</text>
										</view>
									</view> -->
									<view class="item-button mid-size" @click="onCheckPhotoClick(item)">
										<view class="items-line">
											<uni-icons class="input-uni-icon" type="location" 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 :pageSize="pageSize" :current="pageCurrent" :total="total"
							@change="pageChange" />
					</view>
				</uni-group>
			</view>
			<view v-else class="view-flex-inline-center">
				<view style="margin-top: 10px;color: gray;font-size: 1rem;">暂无数据</view>
			</view>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';
	export default {
		components: {},
		data() {
			return {
				title: '巡查信息',
				showSearch: true,
				cityRegionValue: '',
				cityRegionData: [],
				districtRegionValue: '',
				districtRegionData: [],
				townRegionValue: '',
				townRegionData: [],
				countryRegionValue: '',
				countryRegionData: [],
				dangerAreaValue: '',
				dangerAreaData: [],
				pageSize: 10,
				pageCurrent: 1,
				total: 0,
				list: [],
				query: {},
				type: 1,
				warnId: '',
			}
		},
		computed: {},
		onLoad(option) {
			this.type = option.type;
			this.query = {};
			if (this.type == 1) {
				this.getCityRegion({});
			} else if (this.type == 2) {
				this.warnId = option.warnId;
				this.query['warnId'] = this.warnId;
			}
		},
		onShow() {
			this.pageCurrent = 1;
			this.getPage();
		},
		methods: {
			//返回上一页
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			searchAreaStatus(e) {
				if (e.length > 0) {
					this.showSearch = true;
				} else {
					this.showSearch = false;
				}
			},
			cityRegionChange(e) {
				this.cityRegionValue = e;
				this.districtRegionData = [];
				this.districtRegionValue = '';
				this.townRegionData = [];
				this.townRegionValue = '';
				this.countryRegionData = [];
				this.countryRegionValue = '';
				this.dangerAreaData = [];
				this.dangerAreaValue = '';
				let p = {
					'parentCode': this.cityRegionValue
				}
				this.getDistrictRegion(p);
				this.query['adcd'] = this.cityRegionValue;
				this.pageCurrent = 1;
				this.list = [];
				this.getPage({});
			},
			districtRegionChange(e) {
				if (e == undefined || e == null || e == '') {
					this.districtRegionValue = '';
					this.townRegionData = [];
					this.townRegionValue = '';
					this.countryRegionData = [];
					this.countryRegionValue = '';
					this.dangerAreaData = [];
					this.dangerAreaValue = '';
					this.query['adcd'] = this.cityRegionValue;
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				} else {
					this.districtRegionValue = e;
					this.townRegionData = [];
					this.townRegionValue = '';
					this.countryRegionData = [];
					this.countryRegionValue = '';
					this.dangerAreaData = [];
					this.dangerAreaValue = '';
					let p = {
						'parentCode': this.districtRegionValue
					}
					this.getTownRegion(p);
					this.query['adcd'] = this.districtRegionValue;
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				}
			},
			townRegionChange(e) {
				if (e == undefined || e == null || e == '') {
					this.townRegionValue = '';
					this.countryRegionData = [];
					this.countryRegionValue = '';
					this.dangerAreaData = [];
					this.dangerAreaValue = '';
					this.query['adcd'] = this.districtRegionValue;
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				} else {
					this.townRegionValue = e;
					this.countryRegionData = [];
					this.countryRegionValue = '';
					this.dangerAreaData = [];
					this.dangerAreaValue = '';
					let p = {
						'parentCode': this.townRegionValue
					}
					this.getCountryRegion(p);
					this.query['adcd'] = this.townRegionValue;
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				}
			},
			countryRegionChange(e) {
				if (e == undefined || e == null || e == '') {
					this.countryRegionValue = '';
					this.dangerAreaValue = '';
					this.dangerAreaData = [];
					this.query['adcd'] = this.townRegionValue;
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				} else {
					this.countryRegionValue = e;
					this.dangerAreaValue = '';
					this.dangerAreaData = [];
					this.query['adcd'] = this.countryRegionValue;
					this.getDangerAreaList({})
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				}
			},
			dangerAreaChange(e) {
				if (e == undefined || e == null || e == '') {
					this.dangerAreaValue = '';
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({});
				} else {
					this.dangerAreaValue = e;
					this.pageCurrent = 1;
					this.list = [];
					this.getPage({
						dangerAreaPid: this.dangerAreaValue
					});
				}
			},
			getCityRegion(params = {}) {
				let that = this;
				http.request({
					url: '/galaxy-business/baseinfo/region/whole/yj/list',
					method: 'GET',
					data: params,
				}).then(res => {
					that.cityRegionData = res.data.map(item => {
						return {
							value: item.adcd,
							text: item.adnm,
						}
					})
				}).catch(err => {
					console.log(err)
				})
			},
			getDistrictRegion(params = {}) {
				let that = this;
				http.request({
					url: '/galaxy-business/baseinfo/region/whole/yj/list',
					method: 'GET',
					data: params,
				}).then(res => {
					that.districtRegionData = res.data.map(item => {
						return {
							value: item.adcd,
							text: item.adnm,
						}
					})
				}).catch(err => {
					console.log(err)
				})
			},
			getTownRegion(params = {}) {
				let that = this;
				http.request({
					url: '/galaxy-business/baseinfo/region/whole/yj/list',
					method: 'GET',
					data: params,
				}).then(res => {
					that.townRegionData = res.data.map(item => {
						return {
							value: item.adcd,
							text: item.adnm,
						}
					})
				}).catch(err => {
					console.log(err)
				})
			},
			getCountryRegion(params = {}) {
				let that = this;
				http.request({
					url: '/galaxy-business/baseinfo/region/whole/yj/list',
					method: 'GET',
					data: params,
				}).then(res => {
					that.countryRegionData = res.data.map(item => {
						return {
							value: item.adcd,
							text: item.adnm,
						}
					})
				}).catch(err => {
					console.log(err)
				})
			},
			getDangerAreaList(params = {}) {
				let postData = Object.assign(params, this.query);
				let that = this;
				http.request({
					url: '/galaxy-business/map/dangerarea/select',
					method: 'GET',
					data: postData,
				}).then(res => {
					that.dangerAreaData = res.data.map(item => {
						return {
							value: item.dangerAreaPid,
							text: item.dangerAreaName,
						}
					})
				}).catch(err => {
					console.log(err)
				})
			},
			// 分页触发
			pageChange(e) {
				this.pageCurrent = e.current;
				this.getPage()
			},
			onCheckPhotoClick(item) {
				let url = '/pages/yjxt/check/dangerareacheckdetail?id=' + item.id;;
				uni.navigateTo({
					url: url
				})

			},
			getPage(params = {}) {
				const current = this.pageCurrent;
				const size = this.pageSize;
				let postData = Object.assign(params, this.query);
				let that = this;
				http.request({
					url: '/galaxy-business/yj/check/page',
					method: 'GET',
					params: {
						current,
						size,
					},
					data: postData,
				}).then(res => {
					if (res.data.records != null) {
						that.list = res.data.records;
					}
					this.total = res.data.total;
				}).catch(err => {
					console.log(err)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>