<template>
	<div id="app">
		<div class="pro-wrapper">
			<div class="navbar">
				<div class="nav-brand">
					<div class="brand-icon">
						<img src="@/assets/icons/header-logo.png" alt="" />
					</div>
					<div class="brand-text" @click="handleToHome">
						<div class="text-ch">某方向风险监测预警系统</div>
					</div>
				</div>
				<div class="user-info">
					<div class="email">
						<img src="@/assets/icons/header-icon.png" alt="" />
					</div>
					<div class="avator">
						<img src="@/assets/icons/header-avator.png" alt="" />
					</div>
					<span class="user">管理员</span>
				</div>
			</div>
			<div class="main-container">
				<router-view />
			</div>
			<div class="ai-btn" @click="openAiBox">
				<div class="icon">
					<img src="@/assets/icons/ai-icon.png" alt="" />
				</div>
				<div class="text">智能问答</div>
			</div>

			<div class="ai-dialog" v-if="isShowAiBox">
				<AiBox @close="closeAiBox" />
			</div>
		</div>
	</div>
</template>

<script setup>
import { ref, computed, onMounted } from "vue";
import { Monitor, House, User, Location, Document, Bell, Message, ArrowDown } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import Breadcrumb from "@/components/BreadCrumb/index.vue";
import AiBox from "./components/AiBox.vue";
import { getPersonType } from "@/api/common/index";
// import { useDraggable } from "@vueuse/core";

const router = useRouter();

// const target = ref(null);

// const { x, y, isDragging } = useDraggable(target, {
// 	initialValue: { x: 1770, y: 800 },
// 	onStart: () => console.log("开始拖动"),
// 	onEnd: () => console.log("结束拖动")
// });

// const style = computed(() => ({
// 	position: "absolute",
// 	left: `${x.value}px`,
// 	top: `${y.value}px`,
// 	cursor: isDragging.value ? "grabbing" : "grab"
// }));

const handleToHome = () => {
	router.push({
		path: "/ZMOverView"
		// path: "/overview"
	});
};

const isShowAiBox = ref(false);

const closeAiBox = () => {
	isShowAiBox.value = false;
};

const openAiBox = () => {
	isShowAiBox.value = true;
};

const handleHomeCommand = command => {
	router.push(command);
};

const personTypeList = ref([]);

// 获取人物类别
const handleGetPersonType = async () => {
	try {
		const res = await getPersonType();
		console.log("res", res);
		if (res.code === 200) {
			personTypeList.value = res.data;
		} else {
			personTypeList.value = [];
		}
		window.sessionStorage.setItem("personTypeList", JSON.stringify(personTypeList.value));
	} catch (error) {}
};

onMounted(() => {
	handleGetPersonType();
});
</script>

<style>
/* 全局样式重置 */
* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
}

body {
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.el-popover {
	width: 100%;
	font-family: "Microsoft YaHei";
	color: rgba(95, 101, 108, 1);
	font-style: Regular;
	font-size: 16px;
	font-weight: 400;
	line-height: 30px;
	letter-spacing: 0px;
	text-align: justify;
}

.el-popper[data-popper-placement^="top"] > .el-popper__arrow:before {
	display: none;
}
</style>

<style lang="scss" scoped>
#app {
	font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.pro-wrapper {
	width: 100vw;
	height: 100vh;
	position: relative;
	overflow: hidden;
	.navbar {
		display: flex;
		justify-content: center;
		align-items: center;
		background: #fff;
		color: rgba(10, 18, 30, 1);
		border-bottom: 1px solid #e5e7eb;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
		position: relative;
		box-sizing: border-box;
		height: 72px;
		.nav-brand {
			display: flex;
			align-items: center;
			gap: 12px;
			position: absolute;
			left: 160px;

			.brand-icon {
				width: 48px;
				height: 48px;
				img {
					width: 100%;
					height: 100%;
				}
			}

			.brand-text {
				cursor: pointer;
				.text-ch {
					height: 37px;
					color: rgba(10, 18, 30, 1);
					font-family: Microsoft YaHei;
					font-size: 32px;
					font-weight: 700;
					line-height: 37px;
				}

				.text-en {
					color: rgba(10, 18, 30, 1);
					font-family: Microsoft YaHei;
					font-size: 10px;
					font-weight: 400;
					line-height: 13px;
				}
			}
		}

		.user-info {
			display: flex;
			align-items: center;
			gap: 20px;
			padding: 8px 12px;
			border-radius: 6px;
			color: #333;
			position: absolute;
			right: 160px;

			.email {
				width: 20px;
				height: 20px;

				img {
					width: 100%;
					height: 100%;
				}
			}

			.avator {
				width: 32px;
				height: 32px;

				img {
					width: 100%;
					height: 100%;
				}
			}

			.user {
				color: rgba(59, 65, 75, 1);
				font-family: Microsoft YaHei;
				font-size: 16px;
				font-weight: 400;
				line-height: 30px;
			}
		}
	}
	.main-container {
		width: 100%;
		height: calc(100vh - 72px);
		position: relative;
		overflow: hidden;
	}
	.ai-btn {
		position: absolute;
		bottom: 240px;
		right: 10px;
		z-index: 9999;
		cursor: pointer;

		.icon {
			width: 96px;
			height: 96px;

			img {
				width: 100%;
				height: 100%;
			}
		}

		.text {
			margin-top: -15px;
			height: 24px;
			color: rgba(59, 65, 75, 1);
			font-family: Microsoft YaHei;
			font-size: 16px;
			font-weight: 400;
			line-height: 24px;
			text-align: center;
		}
	}
	.ai-dialog {
		position: absolute;
		right: 100px;
		top: 100px;
		z-index: 9999;
	}
}
</style>
