rax-medical/src/views/index.vue

307 lines
8.3 KiB
Vue
Raw Normal View History

2023-12-14 18:29:40 +08:00
<template>
2024-04-10 09:25:33 +08:00
<div class="page-content">
<div class="head-box">
<div class="logo-box">
<img src="@/assets/imgs/logo.png"/>
</div>
<ul class="menu-box">
<li class="menu-item" v-for="item in menus" :key="item.path"
:class="{ 'active': menuActive.indexOf(item.path) === 0 }"
@click="menuToPath(item)"><i :class="item.icon"></i><span>{{
item.label
}}</span></li>
</ul>
<div class="user-box">
<!-- 超级管理员可切换医院 -->
<el-select v-if="userInfo.permissions === '超级管理员'" class="select-hospital" style="width: 150px;"
:model-value="userInfo.hospital" size="small" @change="selectHospital">
<el-option v-for="item in hospitals" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
<span v-else class="area">{{ userInfo.hospital }}</span>
<el-button text>
<el-icon>
<Search/>
</el-icon>
</el-button>
<el-button text>
<el-badge is-dot>
<el-icon>
<Bell/>
</el-icon>
</el-badge>
</el-button>
<el-button text @click="toggleFullscreen">
<el-icon>
<FullScreen/>
</el-icon>
</el-button>
<el-dropdown trigger="click" @command="userCommand">
2023-12-15 18:08:45 +08:00
<span class="el-dropdown-link">
{{ userInfo.name }}
<el-icon class="el-icon--right">
2024-04-10 09:25:33 +08:00
<arrow-down/>
2023-12-15 18:08:45 +08:00
</el-icon>
</span>
2024-04-10 09:25:33 +08:00
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="info">个人信息</el-dropdown-item>
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
<div class="main-content">
<RouterView/>
2023-12-14 18:29:40 +08:00
</div>
2024-04-10 09:25:33 +08:00
<el-drawer v-model="isShowUserInfoDrawer" size="35%" :with-header="false">
<userInfoForm @close="isShowUserInfoDrawer = false"/>
</el-drawer>
</div>
2023-12-14 18:29:40 +08:00
</template>
<script lang='ts' setup>
2024-04-10 09:25:33 +08:00
import {onMounted, reactive, ref, toRefs, watch} from 'vue'
import {useRouter, useRoute} from 'vue-router'
import {ElMessage, ElMessageBox} from 'element-plus'
import {useLoginStore} from '@/stores/user-info-store'
import {getHospitalsData} from '@/static-data/core'
2023-12-15 18:08:45 +08:00
import userInfoForm from '@/components/user-info.vue'
2024-04-10 09:25:33 +08:00
import {Session} from "@/utils/storage";
2024-04-10 19:07:22 +08:00
import {logout} from "@/api/login";
2023-12-14 18:29:40 +08:00
2023-12-15 18:08:45 +08:00
const router = useRouter()
const route = useRoute()
const userInfo = useLoginStore().getlogin()
2023-12-28 14:56:06 +08:00
const hospitals = ref([] as any)
getHospitalsData().then((res: any) => {
2024-04-10 09:25:33 +08:00
hospitals.value = res
// console.log(res)
})
2023-12-15 18:08:45 +08:00
2023-12-26 17:11:15 +08:00
const menus = [] as any
switch (userInfo.permissions) {
2024-04-23 09:42:25 +08:00
case '超级管理员':
menus.push({label: '首页', path: '/home', icon: 'icon-shouye'})
menus.push({label: '权限管理', path: '/permissions-manage', icon: 'icon-users'})
menus.push({label: '患者管理', path: '/patients-manage', icon: 'icon-renyuanguanli'})
menus.push({label: '远程管理', path: '/remote-manage', icon: 'icon-anquanbaozhang'})
menus.push({label: '后台管理', path: '/system-manage', icon: 'icon-houtaiguanli'})
menus.push({label: '系统管理', path: '/logs-manage', icon: 'icon-setting'})
break;
case '高级管理员':
menus.push({label: '首页', path: '/home', icon: 'icon-shouye'})
menus.push({label: '权限管理', path: '/permissions-manage', icon: 'icon-users'})
menus.push({label: '患者管理', path: '/patients-manage', icon: 'icon-renyuanguanli'})
menus.push({label: '远程管理', path: '/remote-manage', icon: 'icon-anquanbaozhang'})
menus.push({label: '系统管理', path: '/logs-manage', icon: 'icon-setting'})
break;
case '中级管理员':
menus.push({label: '首页', path: '/home', icon: 'icon-shouye'})
menus.push({label: '患者管理', path: '/patients-manage', icon: 'icon-renyuanguanli'})
menus.push({label: '远程管理', path: '/remote-manage', icon: 'icon-anquanbaozhang'})
break;
case '普通用户':
menus.push({label: '首页', path: '/home', icon: 'icon-shouye'})
menus.push({label: '患者管理', path: '/patients-manage', icon: 'icon-renyuanguanli'})
break;
default:
menus.push({label: '首页', path: '/home', icon: 'icon-shouye'})
menus.push({label: '权限管理', path: '/permissions-manage', icon: 'icon-users'})
menus.push({label: '患者管理', path: '/patients-manage', icon: 'icon-renyuanguanli'})
menus.push({label: '远程管理', path: '/remote-manage', icon: 'icon-anquanbaozhang'})
menus.push({label: '后台管理', path: '/system-manage', icon: 'icon-houtaiguanli'})
menus.push({label: '系统管理', path: '/logs-manage', icon: 'icon-setting'})
2023-12-26 17:11:15 +08:00
}
2023-12-15 18:08:45 +08:00
const isShowUserInfoDrawer = ref(false)
2023-12-17 16:05:38 +08:00
const menuActive = ref('/')
2023-12-15 18:08:45 +08:00
router.isReady().then(() => {
2024-04-10 09:25:33 +08:00
menuActive.value = route.path
2023-12-15 18:08:45 +08:00
})
2023-12-17 16:05:38 +08:00
router.beforeEach((to, from, next) => {
2024-04-10 09:25:33 +08:00
menuActive.value = to.path
next()
2023-12-17 16:05:38 +08:00
});
2023-12-15 18:08:45 +08:00
onMounted(() => {
})
const menuToPath = (e: any) => {
2024-04-10 09:25:33 +08:00
menuActive.value = e.path
router.push(e.path)
2023-12-15 18:08:45 +08:00
}
// 切换医院
const selectHospital = (e: any) => {
2024-04-10 09:25:33 +08:00
// 根据实际情况看是否需要重新登录
ElMessageBox.confirm(
'是否跳转到登录页面登录到所选择医院?',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
draggable: true
}
).then(() => {
// useLoginStore().setlogin('hospital', e)
router.push('/login')
}).catch(() => {
})
2023-12-15 18:08:45 +08:00
}
const toggleFullscreen = () => {
2024-04-10 09:25:33 +08:00
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
document.documentElement.requestFullscreen();
}
2023-12-15 18:08:45 +08:00
}
2024-04-10 09:25:33 +08:00
const userCommand = async (e: string) => {
switch (e) {
case 'logout':
// useLoginStore().logout()
await logout()
Session.clear();
window.location.reload();
break;
case 'info':
isShowUserInfoDrawer.value = true
break;
default:
break;
}
2023-12-15 18:08:45 +08:00
}
2023-12-14 18:29:40 +08:00
</script>
<style lang='scss' scoped>
2023-12-15 18:08:45 +08:00
.page-content {
2024-04-10 09:25:33 +08:00
width: 100%;
height: 100%;
.head-box {
position: relative;
2023-12-15 18:08:45 +08:00
width: 100%;
2024-04-10 09:25:33 +08:00
height: 70px;
padding: 0 464px 0 284px;
background: white;
display: flex;
justify-content: center;
align-items: center;
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
.logo-box {
position: absolute;
top: 0;
left: 24px;
margin-right: 10px;
display: flex;
align-items: center;
height: 100%;
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
img {
height: 50px;
}
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
.menu-box {
display: flex;
align-items: center;
flex-shrink: 0;
2024-02-22 20:48:08 +08:00
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
.menu-item {
cursor: pointer;
display: flex;
align-items: center;
font-size: 20px;
font-weight: 600;
color: $main-color;
height: 70px;
padding: 0 15px;
margin: 0;
transition: all .5s;
-webkit-transition: all .5s;
&:hover {
background: #f2f3f5;
transition: all .5s;
-webkit-transition: all .5s;
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
&.active {
background: #f2f3f5;
transition: all .5s;
-webkit-transition: all .5s;
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
i {
margin-right: 5px;
2023-12-15 18:08:45 +08:00
}
2024-04-10 09:25:33 +08:00
}
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
.user-box {
position: absolute;
width: 440px;
height: 100%;
top: 0;
right: 20px;
display: flex;
justify-content: flex-end;
align-items: center;
background: white;
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
.select-hospital {
margin-right: 20px;
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
.area {
cursor: pointer;
font-size: 14px;
color: $main-color;
line-height: 1.6;
padding: 0 20px;
border: 1px solid #8c9094;
border-radius: 7px;
margin-right: 20px;
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
& > .el-button {
margin: 0;
}
2023-12-15 18:08:45 +08:00
2024-04-10 09:25:33 +08:00
& > .el-dropdown {
flex-shrink: 0;
margin-left: 10px;
}
2023-12-14 18:29:40 +08:00
2024-04-10 09:25:33 +08:00
.el-dropdown-link {
cursor: pointer;
}
2023-12-15 18:08:45 +08:00
}
2024-04-10 09:25:33 +08:00
}
& > .main-content {
width: 100%;
height: calc(100% - 70px);
background: #f5f7fa;
}
2023-12-15 18:08:45 +08:00
}
2023-12-27 17:38:07 +08:00
2023-12-28 10:10:10 +08:00
// @media screen and (max-width: 1610px) {
// .page-content {
// .head-box {
// justify-content: flex-start;
// .logo-box {
// position: relative;
// top: auto;
// left: auto;
// }
// }
// }
2024-04-10 09:25:33 +08:00
2023-12-28 10:10:10 +08:00
// }
2023-12-14 18:29:40 +08:00
</style>