rax-medical/src/views/index.vue

302 lines
9.1 KiB
Vue
Raw Normal View History

2023-12-14 18:29:40 +08:00
<template>
2023-12-15 18:08:45 +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">
2023-12-17 16:05:38 +08:00
<li class="menu-item" v-for="item in menus" :key="item.path" :class="{ 'active': menuActive.indexOf(item.path) === 0 }"
2023-12-15 18:08:45 +08:00
@click="menuToPath(item)"><i :class="item.icon"></i><span>{{ item.label
}}</span></li>
</ul>
<div class="user-box">
<!-- 超级管理员可切换医院 -->
2023-12-20 15:12:29 +08:00
<el-select v-if="userInfo.permissions === '超级管理员'" class="select-hospital" style="width: 150px;"
2023-12-15 18:08:45 +08:00
: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">
<span class="el-dropdown-link">
{{ userInfo.name }}
<el-icon class="el-icon--right">
<arrow-down />
</el-icon>
</span>
<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 />
</div>
2023-12-19 14:03:07 +08:00
<el-drawer v-model="isShowUserInfoDrawer" size="35%" :with-header="false">
2023-12-15 18:08:45 +08:00
<userInfoForm @close="isShowUserInfoDrawer = false" />
</el-drawer>
2023-12-14 18:29:40 +08:00
</div>
</template>
<script lang='ts' setup>
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
2023-12-15 18:08:45 +08:00
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'
import userInfoForm from '@/components/user-info.vue'
2024-02-18 09:09:09 +08:00
import {wsApi} from "@/axios/ws";
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) => {
2023-12-28 14:56:06 +08:00
hospitals.value = res
2023-12-28 17:58:59 +08:00
// 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) {
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:
break;
}
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(() => {
menuActive.value = route.path
})
2023-12-17 16:05:38 +08:00
router.beforeEach((to, from, next) => {
menuActive.value = to.path
next()
});
2023-12-15 18:08:45 +08:00
onMounted(() => {
})
const menuToPath = (e: any) => {
menuActive.value = e.path
router.push(e.path)
}
// 切换医院
const selectHospital = (e: any) => {
// 根据实际情况看是否需要重新登录
ElMessageBox.confirm(
'是否跳转到登录页面登录到所选择医院?',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
2023-12-28 10:18:10 +08:00
draggable: true
2023-12-15 18:08:45 +08:00
}
).then(() => {
useLoginStore().setlogin('hospital', e)
router.push('/login')
}).catch(() => { })
}
const toggleFullscreen = () => {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
document.documentElement.requestFullscreen();
}
}
const userCommand = (e: string) => {
switch (e) {
case 'logout':
useLoginStore().logout()
router.push('/login')
break;
case 'info':
isShowUserInfoDrawer.value = true
break;
default:
break;
}
}
2024-02-18 09:09:09 +08:00
/*wsApi.init("").then(() => {
wsApi.openListener(fn1);
})
function fn1(res:any) {
console.log(res);
}*/
2023-12-14 18:29:40 +08:00
</script>
<style lang='scss' scoped>
2023-12-15 18:08:45 +08:00
.page-content {
width: 100%;
height: 100%;
.head-box {
2023-12-27 16:49:37 +08:00
position: relative;
2023-12-15 18:08:45 +08:00
width: 100%;
2023-12-19 14:03:07 +08:00
height: 70px;
2023-12-28 10:10:10 +08:00
padding: 0 464px 0 284px;
2023-12-15 18:08:45 +08:00
background: white;
display: flex;
2023-12-27 17:38:07 +08:00
justify-content: center;
2023-12-15 18:08:45 +08:00
align-items: center;
.logo-box {
2023-12-27 17:38:07 +08:00
position: absolute;
top: 0;
left: 24px;
2023-12-28 10:10:10 +08:00
margin-right: 10px;
2023-12-27 17:38:07 +08:00
display: flex;
align-items: center;
height: 100%;
2023-12-15 18:08:45 +08:00
img {
2023-12-27 17:38:07 +08:00
height: 50px;
2023-12-15 18:08:45 +08:00
}
}
2023-12-27 17:38:07 +08:00
2023-12-15 18:08:45 +08:00
.menu-box {
display: flex;
align-items: center;
2023-12-27 16:49:37 +08:00
flex-shrink: 0;
2023-12-15 18:08:45 +08:00
.menu-item {
cursor: pointer;
display: flex;
align-items: center;
2023-12-28 10:10:10 +08:00
font-size: 17px;
2023-12-15 18:08:45 +08:00
font-weight: 600;
color: $main-color;
2023-12-20 15:12:29 +08:00
height: 70px;
2023-12-28 10:10:10 +08:00
padding: 0 10px;
2023-12-15 18:08:45 +08:00
margin: 0;
2023-12-17 16:05:38 +08:00
transition: all .5s;
-webkit-transition: all .5s;
2023-12-15 18:08:45 +08:00
&:hover {
2023-12-27 16:49:37 +08:00
background: #f2f3f5;
2023-12-17 16:05:38 +08:00
transition: all .5s;
-webkit-transition: all .5s;
2023-12-15 18:08:45 +08:00
}
&.active {
2023-12-27 16:49:37 +08:00
background: #f2f3f5;
2023-12-17 16:05:38 +08:00
transition: all .5s;
-webkit-transition: all .5s;
2023-12-15 18:08:45 +08:00
}
2023-12-19 14:03:07 +08:00
i {
2023-12-28 10:10:10 +08:00
margin-right: 5px;
2023-12-15 18:08:45 +08:00
}
}
}
.user-box {
2023-12-27 16:49:37 +08:00
position: absolute;
width: 440px;
height: 100%;
top: 0;
right: 20px;
2023-12-15 18:08:45 +08:00
display: flex;
2023-12-27 16:49:37 +08:00
justify-content: flex-end;
2023-12-15 18:08:45 +08:00
align-items: center;
2023-12-27 16:49:37 +08:00
background: white;
2023-12-15 18:08:45 +08:00
.select-hospital {
margin-right: 20px;
}
.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;
}
&>.el-button {
margin: 0;
}
&>.el-dropdown {
2023-12-20 15:12:29 +08:00
flex-shrink: 0;
2023-12-15 18:08:45 +08:00
margin-left: 10px;
}
2023-12-14 18:29:40 +08:00
2023-12-15 18:08:45 +08:00
.el-dropdown-link {
cursor: pointer;
}
}
}
&>.main-content {
width: 100%;
2023-12-19 14:03:07 +08:00
height: calc(100% - 70px);
2023-12-15 18:08:45 +08:00
background: #f5f7fa;
}
}
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;
// }
// }
// }
2023-12-27 17:38:07 +08:00
2023-12-28 10:10:10 +08:00
// }
2023-12-14 18:29:40 +08:00
</style>