<!--
 * @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="查询" type="line">
				<view class="search-block">
					<view class="rtu-name">
						<uni-easyinput :styles="inputStyles" @input="adNameValInput" prefixIcon="search"
							v-model="adNameVal" placeholder="请录入行政区名称">
						</uni-easyinput>
					</view>
					<view class="rtu-name">
						<uni-easyinput :styles="inputStyles" @input="dangerAreaNameValInput" prefixIcon="search"
							v-model="dangerAreaNameVal" placeholder="请录入危险区名称">
						</uni-easyinput>
					</view>
					<view class="rtu-name">
						<uni-easyinput :styles="inputStyles" @input="personNameValInput" prefixIcon="search"
							v-model="personNameVal" placeholder="请录入户主名称">
						</uni-easyinput>
					</view>
					<view class="submit-btn">
						<button type="default" @click="search">查 询</button>
					</view>
				</view>
			</uni-section>
			<uni-list>
				<uni-list-item v-for="item in list" :key="item.id">
					<template v-slot:body>
						<view class="list-item-block">
							<view class="line">
								<text class="text text-ellipsis">行政区：{{item.adName}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis">危险区：{{item.dangerAreaName}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis">户主姓名：{{item.personName}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis">身份证号：{{item.personId}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis">住址经纬度：{{item.longitude}},{{item.latitude}}</text>
							</view>
							<view class="item-button-group" style="padding-right: 10px;">
								<view class="item-button mid-size" @click="onAddLocationClick(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="onOpenFamilyListClick(item)">
									<view class="items-line">
										<uni-icons class="input-uni-icon" type="staff" 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>
</template>

<script>
	import {
		role
	} from "@/api/role.js";
	import http from '@/http/api.js';
	export default {
		components: {},
		onLoad(option) {
			this.query = {};
			this.query['isHouseholder'] = 1;
		},
		data() {
			return {
				title: '登记人员清单',
				pageSize: 10,
				pageCurrent: 1,
				total: 0,
				list: [],
				query: {},
				warnId: '',
				adNameVal: '',
				dangerAreaNameVal: '',
				personNameVal: '',
				inputStyles: {
					color: '#808080',
					borderColor: '#d3d3d3'
				},
			}
		},
		computed: {},
		onShow() {
			this.getPage();
		},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			adNameValInput(e) {
				if (e == null || e.length == 0) {
					this.adNameVal = '';
				}
			},
			dangerAreaNameValInput(e) {
				if (e == null || e.length == 0) {
					this.dangerAreaNameVal = '';
				}
			},
			personNameValInput(e) {
				if (e == null || e.length == 0) {
					this.personNameVal = '';
				}
			},
			search() {
				this.pageCurrent = 1;
				let params = {};
				if (this.adNameVal.length > 0) {
					params['adName'] = this.adNameVal;
				}
				if (this.dangerAreaNameVal.length > 0) {
					params['dangerAreaName'] = this.dangerAreaNameVal;
				}
				if (this.personNameVal.length > 0) {
					params['personName'] = this.personNameVal;
				}
				this.getPage(params);
			},
			onAddLocationClick(item) {
				var url = '/pages/yjxt/resident/dangerarearesidentlocation?id=' + item.id + '&lng=' + item.longitude +
					'&lat=' + item.latitude;
				uni.navigateTo({
					url: url
				})
			},
			onOpenFamilyListClick(item) {
				var url = '/pages/yjxt/resident/dangerarearesidentfamilylist?personId=' + item.personId;
				uni.navigateTo({
					url: url
				})
			},
			pageChange(e) {
				this.pageCurrent = e.current;
				this.getPage()
			},
			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/resident/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>