<!--
 * @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="line" @click="toWarnDetailView(item)">
								<view class="block">
									<uni-icons class="input-uni-icon" type="notification" size="18" color="red" />
								</view>
								<text class="title text-ellipsis text-underline"
									style="color: blue;">{{item.warnName}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis" style="color: gray;">预警信息：{{item.warnInfo}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis" style="color: gray;">预警时间：{{item.warnTime}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis"
									style="color: gray;">应转移人员：{{item.totalTransferPerson}}</text>
							</view>
							<view class="line">
								<text class="text text-ellipsis"
									style="color: gray;">已转移：{{item.safetyTransferPerson}}</text>
							</view>
							<uni-row>
								<uni-col :span="8">
									<image style="height: 80px;" :src="toOss(item.warnQrUrl)" mode="heightFix"
										@click="toFullQrImage(item)"></image>
								</uni-col>
								<uni-col :span="16">
									<view class="item-button-group">
										<view class="item-button" @click="onDangerAreaCheckClick(item)">
											<view class="view-flex-inline-center">
												<uni-icons class="input-uni-icon" type="map-pin-ellipse" size="18"
													color="coral" />
												<text class="button-text">巡查</text>
											</view>
										</view>
										<view class="item-button" @click="onTransferRecordClick(item)">
											<view class="view-flex-inline-center">
												<uni-icons class="input-uni-icon" type="auth" size="18" color="coral" />
												<text class="button-text">转移登记</text>
											</view>
										</view>
										<view class="item-button" @click="onTransferResidentListClick(item)">
											<view class="view-flex-inline-center">
												<uni-icons class="input-uni-icon" type="staff" size="18"
													color="coral" />
												<text class="button-text">转移清单</text>
											</view>
										</view>
									</view>
								</uni-col>
							</uni-row>
						</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 {
		oss
	} from '@/common/setting';
	import http from '@/http/api.js';
	export default {
		components: {},
		data() {
			return {
				title: '预警响应',
				pageSize: 10,
				pageCurrent: 1,
				baseOSS: '',
				total: 0,
				list: [],
				query: {},
			}
		},
		computed: {},
		onLoad(option) {
			this.baseOSS = oss;
			this.query = {};
			this.query['warnStatus'] = 5;
			this.getPage();
		},
		onShow() {},
		methods: {
			toOss(path) {
				return this.baseOSS + path;
			},
			//返回上一页
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			onBackPress() {
				// #ifdef APP-PLUS
				plus.key.hideSoftKeybord();
				// #endif
			},
			// 分页触发
			pageChange(e) {
				this.pageCurrent = e.current;
				this.getPage()
			},
			onDangerAreaCheckClick(item) {
				let url =
					'/pages/yjxt/check/dangerareacheck?type=2&id=' + item.warnId;
				uni.navigateTo({
					url: url
				})
			},
			onTransferRecordClick(item) {
				let url = '/pages/yjxt/transfer/residenttransferrecord?id=' + item.warnId;
				uni.navigateTo({
					url: url
				})
			},
			onTransferResidentListClick(item) {
				let url = '/pages/yjxt/transfer/transferresidentlist?id=' + item.warnId;
				uni.navigateTo({
					url: url
				})
			},
			toWarnDetailView(item) {
				uni.navigateTo({
					url: '/pages/yjxt/warn/yjwarndetail?id=' + item.id
				})
			},
			toFullQrImage(item) {
				uni.navigateTo({
					url: '/pages/yjxt/warn/yjwarnqr?id=' + item.id
				})
			},
			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/warn/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>