docking-vue/src/layout/header/index.vue

213 lines
5.5 KiB
Vue
Raw Normal View History

2025-06-10 09:31:15 +08:00
<template>
<div class="header">
<div class="logo">
<!-- <img-->
<!-- src="/src/assets/images/public/logo1.png"-->
<!-- alt=""-->
<!-- width="134"-->
<!-- height="28"-->
<!-- />-->
2025-06-27 14:01:42 +08:00
{{ logoValue.title }}
2025-06-10 09:31:15 +08:00
</div>
<div class="breadcrumb">
<layout-breadcrumb v-if="route.meta.isBreadcrumb !== false" />
</div>
<div class="right">
2025-06-27 14:01:42 +08:00
<div class="user">
2025-08-25 08:38:59 +08:00
<!-- <span class="pl-20">姓名{{ userInfo.name }}</span>-->
2025-06-27 14:01:42 +08:00
</div>
2025-08-25 08:38:59 +08:00
<div
v-for="item in menuList"
:key="item.model"
:style="{
color:
item.model !== model ? 'var(--el-text-color-regular)' : '#79bbff',
}"
class="right-menu-item hover-effect menu mr-20"
@click="fnMenuDropdownCommand(item.model)"
>
<span>{{ item.title }}</span>
</div>
<!-- <div class="menu ml-20 mr-20">
2025-06-27 14:01:42 +08:00
<el-dropdown
trigger="click"
placement="bottom-end"
@command="fnMenuDropdownCommand"
>
<div class="more">
更多导航栏
<icon-down
2025-06-10 09:31:15 +08:00
theme="filled"
2025-06-27 14:01:42 +08:00
size="16"
fill="#a2c2d3"
2025-06-10 09:31:15 +08:00
:stroke-width="3"
/>
2025-06-27 14:01:42 +08:00
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
v-for="(item, index) in menuList"
:key="index"
:command="item.model"
:style="{
color:
item.model !== model
? 'var(--el-text-color-regular)'
: '#79bbff',
}"
@click="fnMenuDropdownMenu(item)"
>
{{ item.title }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
2025-08-25 08:38:59 +08:00
</div> -->
2025-06-27 14:01:42 +08:00
<div class="user_dropdown">
2025-06-10 09:31:15 +08:00
<el-dropdown
trigger="click"
placement="bottom-end"
2025-06-27 14:01:42 +08:00
@command="fnUserDropdownCommand"
2025-06-10 09:31:15 +08:00
>
<div class="user_info">
<el-avatar shape="circle" :size="30" fit="fill" :src="tx" />
<span>{{ userInfo.name }}</span>
2025-06-10 09:31:15 +08:00
<icon-down
theme="filled"
size="16"
fill="#a2c2d3"
:stroke-width="3"
/>
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="modifyPassword">
修改密码
</el-dropdown-item>
<el-dropdown-item command="signOut">退出</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
<change-password
v-model:visible="passwordDialogVisible"
@submit="fnSignOut"
/>
</div>
</template>
<script setup>
2025-06-27 14:01:42 +08:00
import { ref, computed } from "vue";
2025-06-10 09:31:15 +08:00
import { useRoute, useRouter } from "vue-router";
import { useMenuStore } from "@/pinia/menu.js";
import { useUserStore } from "@/pinia/user.js";
2025-06-27 14:01:42 +08:00
import { useNavStore } from "@/pinia/nav.js";
2025-06-10 09:31:15 +08:00
import { logout } from "@/request/api.js";
import LayoutBreadcrumb from "@/layout/breadcrumb/index.vue";
import tx from "@/assets/images/public/tx.png";
import ChangePassword from "./components/change_password.vue";
defineOptions({
name: "LayoutHeader",
});
const route = useRoute();
const router = useRouter();
const menuStore = useMenuStore();
const userStore = useUserStore();
2025-06-27 14:01:42 +08:00
const navStore = useNavStore();
const menuList = navStore.getNavList;
const model = computed(() => menuStore.getModel);
const userInfo = userStore.getUserInfo;
const logoValue = ref({
title: "",
});
2025-06-10 09:31:15 +08:00
const passwordDialogVisible = ref(false);
2025-06-27 14:01:42 +08:00
const fnUserDropdownCommand = async (command) => {
2025-06-10 09:31:15 +08:00
if (command === "signOut") {
await fnSignOut();
}
if (command === "modifyPassword") {
passwordDialogVisible.value = true;
}
};
2025-06-27 14:01:42 +08:00
const fnMenuDropdownCommand = (command) => {
if (command === "jg_visualization") {
router.push({ path: "/bigScreen" });
return;
}
if (command === "jg_map") {
// window.open(
// `${import.meta.env.VITE_FORMAL_JUMP_MAP_URL}?userId=${userInfo.userId}`
// );
router.push({ path: "/map" });
return;
}
if (command === "jg_double_prevention")
router.push({ path: "/double_prevention_page" });
else if (command === "jg_related_parties")
router.push({ path: "/stakeholder_page" });
else router.push({ path: "/index" });
menuStore.setModel(command);
2025-06-10 09:31:15 +08:00
};
const fnSignOut = async () => {
await logout();
userStore.$reset();
await router.replace("/login");
};
2025-08-25 08:38:59 +08:00
// const fnMenuDropdownMenu = (command) => {
// logoValue.value.title = command.title;
// };
2025-06-10 09:31:15 +08:00
</script>
<style lang="scss" scoped>
.header {
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 1px 4px rgb(0 21 41 / 8%);
padding-right: 20px;
background-color: #fff;
.logo {
width: 210px;
height: 50px;
background-color: #2b2f3a;
color: #ffffff;
text-align: center;
line-height: 60px;
margin-right: 20px;
}
.right {
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
.menu {
2025-06-27 14:01:42 +08:00
cursor: pointer;
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
.more {
2025-06-10 09:31:15 +08:00
display: flex;
2025-06-27 14:01:42 +08:00
align-items: center;
2025-06-10 09:31:15 +08:00
}
}
2025-06-27 14:01:42 +08:00
.user_dropdown {
2025-06-10 09:31:15 +08:00
margin-top: 5px;
cursor: pointer;
.el-avatar {
margin-right: 5px;
}
.user_info {
display: flex;
align-items: center;
}
}
}
}
</style>