<template>
	<view class="container">
		<!-- 顶部导航 -->
		<view class="header">
			<view class="nav-bar">
				<text class="title">事件处理中心</text>
			</view>
		</view>
		<!-- 滚动区域 -->
		<scroll-view scroll-y class="content">
			<!-- 事件信息 -->
			<view class="event-info">
				<view class="event-header">
					<text class="event-id">事件编号: EV20240101001</text>
					<text class="event-status">处理中</text>
				</view>
				<view class="event-detail">
					<view class="detail-item">
						<text class="label">发生时间：</text>
						<text class="value">2024-01-01 10:30</text>
					</view>
					<view class="detail-item">
						<text class="label">事件地点：</text>
						<text class="value">A区域-1号楼-101室</text>
					</view>
					<view class="detail-item">
						<text class="label">事件类型：</text>
						<text class="value">安全隐患</text>
					</view>
					<view class="detail-item">
						<text class="label">严重程度：</text>
						<text class="value danger">高危</text>
					</view>
				</view>
				<view class="event-desc">
					<text class="desc-title">事件描述</text>
					<text class="desc-content">发现可疑人员在A区域徘徊，疑似携带危险物品，需要立即处理。</text>
				</view>
			</view>
			<!-- 紧急联动 -->
			<view class="emergency-section">
				<text class="section-title">紧急联动</text>
				<view class="emergency-grid">
					<view class="grid-item" v-for="(item, index) in emergencyList" :key="index" @click="handleEmergency(item)">
						<uni-icons :type="item.icon" size="28" :color="item.color" />
						<text class="grid-text">{{item.text}}</text>
					</view>
				</view>
			</view>
			<!-- 告警信息 -->
			<view class="alert-section">
				<text class="section-title">告警信息下发</text>
				<textarea class="alert-input" placeholder="请输入告警信息内容" v-model="alertMessage" />
				<view class="alert-actions">
					<uni-button class="select-btn" @click="selectReceivers">选择接收人</uni-button>
					<uni-button type="primary" @click="sendAlert">发送告警</uni-button>
				</view>
			</view>
		</scroll-view>
		<!-- 底部操作栏 -->
		<view class="footer">
			<uni-button type="default" @click="markComplete">标记处理完成</uni-button>
			<uni-button type="warn" @click="escalateEvent">事件升级</uni-button>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { ref } from 'vue';
	const alertMessage = ref('');
	const securityList = ref([
		{
			name: '张警官',
			avatar: 'https://ai-public.mastergo.com/ai/img_res/40599d84c3ff6f1f857d0d5b1209e880.jpg',
			location: 'A区域-2号楼',
			distance: '50',
			online: true
		},
		{
			name: '李警官',
			avatar: 'https://ai-public.mastergo.com/ai/img_res/ab6b488f45c3634c6f8a5b2b8c0df36e.jpg',
			location: 'B区域-1号楼',
			distance: '150',
			online: true
		},
		{
			name: '王警官',
			avatar: 'https://ai-public.mastergo.com/ai/img_res/9334d63f8a4889e90da6858a94fd5306.jpg',
			location: 'C区域-3号楼',
			distance: '200',
			online: false
		}
	]);
	const emergencyList = ref([
		{ text: '110警察', icon: 'phone-filled', color: '#2979ff' },
		{ text: '119消防', icon: 'fire-filled', color: '#f56c6c' },
		{ text: '120急救', icon: 'plus-filled', color: '#19be6b' }
	]);
	const goBack = () => {
		uni.navigateBack();
	};
	const handleEmergency = (item : any) => {
		uni.showModal({
			title: '确认操作',
			content: `是否确认拨打${item.text}？`,
			success: (res) => {
				if (res.confirm) {
					uni.showToast({ title: `正在拨打${item.text}`, icon: 'none' });
				}
			}
		});
	};
	const selectReceivers = () => {
		uni.showToast({ title: '选择接收人功能开发中', icon: 'none' });
	};
	const sendAlert = () => {
		if (!alertMessage.value) {
			uni.showToast({ title: '请输入告警信息', icon: 'none' });
			return;
		}
		uni.showToast({ title: '告警信息已发送', icon: 'success' });
		alertMessage.value = '';
	};
	const markComplete = () => {
		uni.showModal({
			title: '确认完成',
			content: '是否确认将该事件标记为已处理完成？',
			success: (res) => {
				if (res.confirm) {
					uni.showToast({ title: '事件已标记完成', icon: 'success' });
				}
			}
		});
	};
	const escalateEvent = () => {
		uni.showModal({
			title: '事件升级',
			content: '是否确认将该事件升级处理？',
			success: (res) => {
				if (res.confirm) {
					uni.showToast({ title: '事件已升级', icon: 'success' });
				}
			}
		});
	};
</script>
<style>
	page {
		height: 100%;
	}

	.container {
		height: 100%;
		display: flex;
		flex-direction: column;
		background-color: #f5f5f5;
	}

	.header {
		flex-shrink: 0;
		background-color: #ffffff;
		border-bottom: 1px solid #eaeaea;
	}

	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 20rpx 30rpx;
	}

	.title {
		font-size: 16px;
		font-weight: 500;
		color: #333333;
	}

	.content {
		flex: 1;
		overflow: auto;
	}

	.event-info {
		background-color: #ffffff;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.event-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.event-id {
		font-size: 14px;
		color: #666666;
	}

	.event-status {
		font-size: 12px;
		color: #2979ff;
		background-color: #ecf5ff;
		padding: 4rpx 16rpx;
		border-radius: 4px;
	}

	.event-detail {
		margin-bottom: 30rpx;
	}

	.detail-item {
		display: flex;
		margin-bottom: 16rpx;
	}

	.label {
		font-size: 14px;
		color: #666666;
		width: 160rpx;
	}

	.value {
		font-size: 14px;
		color: #333333;
	}

	.value.danger {
		color: #f56c6c;
	}

	.event-desc {
		background-color: #f8f8f8;
		padding: 20rpx;
		border-radius: 8rpx;
	}

	.desc-title {
		font-size: 14px;
		color: #333333;
		font-weight: 500;
		margin-bottom: 16rpx;
		display: block;
	}

	.desc-content {
		font-size: 14px;
		color: #666666;
		line-height: 1.5;
	}

	.security-section {
		background-color: #ffffff;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.section-title {
		font-size: 16px;
		font-weight: 500;
		color: #333333;
	}

	.security-list {
		background-color: #ffffff;
	}

	.security-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 0;
		border-bottom: 1px solid #eaeaea;
	}

	.security-item:last-child {
		border-bottom: none;
	}

	.security-info {
		display: flex;
		align-items: center;
	}

	.avatar-box {
		position: relative;
		margin-right: 20rpx;
	}

	.avatar {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
	}

	.status-dot {
		position: absolute;
		right: 0;
		bottom: 0;
		width: 16rpx;
		height: 16rpx;
		border-radius: 50%;
		border: 2px solid #ffffff;
	}

	.online {
		background-color: #19be6b;
	}

	.offline {
		background-color: #999999;
	}

	.info-content {
		display: flex;
		flex-direction: column;
	}

	.name {
		font-size: 14px;
		color: #333333;
		margin-bottom: 8rpx;
	}

	.location {
		font-size: 12px;
		color: #999999;
	}

	.action-area {
		display: flex;
		align-items: center;
	}

	.distance {
		font-size: 12px;
		color: #666666;
		margin-right: 20rpx;
	}

	.emergency-section {
		background-color: #ffffff;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.emergency-grid {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		gap: 20rpx;
		margin-top: 20rpx;
	}

	.grid-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		background-color: #ffffff;
		padding: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	}

	.grid-text {
		font-size: 12px;
		color: #666666;
		margin-top: 12rpx;
	}

	.alert-section {
		background-color: #ffffff;
		padding: 30rpx;
		margin-bottom: 120rpx;
	}

	.alert-input {
		width: 100%;
		height: 200rpx;
		background-color: #f8f8f8;
		border-radius: 8rpx;
		padding: 20rpx;
		font-size: 14px;
		margin: 20rpx 0;
		box-sizing: border-box;
	}

	.alert-actions {
		display: flex;
		justify-content: flex-end;
		gap: 20rpx;
	}

	.select-btn {
		background-color: #ffffff !important;
		border: 1px solid #dcdfe6 !important;
	}

	.footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		background-color: #ffffff;
		box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
	}
</style>