rax-medical/src/views/index.vue

363 lines
8.6 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 }"
2024-05-17 12:06:29 +08:00
@click="menuToPath(item)"><i :class="item.meta.icon"></i><span>{{
item.name
2024-04-10 09:25:33 +08:00
}}</span></li>
</ul>
<div class="user-box">
<!-- 超级管理员可切换医院 -->
2024-05-17 12:06:29 +08:00
<el-select class="select-hospital" style="width: 150px;"
v-model="hospital" size="small" @change="selectHospital">
<el-option v-for="item in hospitals" :key="item.id" :label="item.name" :value="item.id"/>
2024-04-10 09:25:33 +08:00
</el-select>
2024-05-17 12:06:29 +08:00
<!-- <el-button text>
<el-icon>
<Search/>
</el-icon>
</el-button>-->
<el-button text @click="userStore.showHomeMsg=true">
2024-04-10 09:25:33 +08:00
<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">
2024-05-17 12:06:29 +08:00
<span class="el-dropdown-link">
{{ userInfo.name }}
<el-icon class="el-icon--right">
<arrow-down/>
</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>
2024-05-29 10:57:20 +08:00
<el-drawer
class="message-drawer-box"
v-model="userStore.showHomeMsg"
title="通知消息"
>
<div class="body">
<el-card style="margin-top: 10px;" v-for="(item, index) in messageTable">
<template #header>
<div class="card-header">
<span>{{ item.category }}</span>
</div>
</template>
<p class="text item">{{ item.message }}</p>
<template #footer>
<span>{{ item.creatorName }}</span>
<span style="float: inline-end;">{{ item.createTime }}</span>
</template>
</el-card>
</div>
<div class="footer">
<el-pagination
v-model:page-size="size"
v-model:current-page="current"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
background
layout="prev, pager, next, jumper, sizes"
:page-sizes="[10, 20, 30, 50]"
:total="total"
/>
</div>
</el-drawer>
2024-04-10 09:25:33 +08:00
</div>
2023-12-14 18:29:40 +08:00
</template>
<script lang='ts' setup>
2024-05-17 12:06:29 +08:00
import {onMounted, ref} from 'vue'
import {useRoute, useRouter} from 'vue-router'
2024-04-10 09:25:33 +08:00
import {ElMessage, ElMessageBox} from 'element-plus'
2024-05-17 12:06:29 +08:00
import {useUserStore} from '@/stores/user-info-store'
2023-12-15 18:08:45 +08:00
import userInfoForm from '@/components/user-info.vue'
2024-04-10 19:07:22 +08:00
import {logout} from "@/api/login";
2024-05-17 12:06:29 +08:00
import * as hospitalApi from "@/api/hospital";
2024-05-29 10:57:20 +08:00
import * as msgApi from "@/api/sys-message";
2023-12-14 18:29:40 +08:00
2023-12-15 18:08:45 +08:00
const router = useRouter()
const route = useRoute()
2024-05-17 12:06:29 +08:00
const userStore = useUserStore();
const userInfo = userStore.getlogin()
const hospital = ref("");
const preHospital = ref("");
2023-12-28 14:56:06 +08:00
const hospitals = ref([] as any)
2024-05-17 12:06:29 +08:00
const menus = ref([] as any)
2023-12-15 18:08:45 +08:00
const isShowUserInfoDrawer = ref(false)
2023-12-17 16:05:38 +08:00
const menuActive = ref('/')
2024-05-29 10:57:20 +08:00
const messageTable = ref([] as any)
const current = ref(1);
const size = ref(10);
const total = ref(0);
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(() => {
2024-05-17 12:06:29 +08:00
init();
2023-12-15 18:08:45 +08:00
})
2024-05-17 12:06:29 +08:00
function init() {
getHospitalList();
handleMenu();
2024-05-29 10:57:20 +08:00
messageTable.value = [];
current.value = 1
total.value = 0
2024-05-17 12:06:29 +08:00
}
function handleMenu() {
useUserStore().getMenuPathList().then((res: any) => {
menus.value = res.menus;
});
}
2024-05-29 10:57:20 +08:00
function handleSizeChange() {
messageTable.value = [];
loadMsg()
}
function handleCurrentChange() {
messageTable.value = [];
loadMsg()
}
async function loadMsg() {
const res = await msgApi.page(current.value, size.value)
if (res.code == 0) {
total.value = res.data.total
res.data.records.forEach((row: any) => {
messageTable.value.push(row)
})
}
}
2023-12-15 18:08:45 +08:00
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
}
2024-05-17 12:06:29 +08:00
async function getHospitalList() {
const data: any = await hospitalApi.getCurrentHospital();
hospitalApi.getMyHospitalList().then((res: any) => {
hospitals.value = [];
if (res.code == 0 && res.data.length > 0) {
hospitals.value = res.data;
2024-05-29 10:47:41 +08:00
if (data.data && data.data != 'null') {
2024-05-17 12:06:29 +08:00
hospital.value = data.data;
}
preHospital.value = hospital.value
}
})
}
2023-12-15 18:08:45 +08:00
// 切换医院
const selectHospital = (e: any) => {
2024-05-17 12:06:29 +08:00
if (hospitals.value.length == 0) return;
2024-04-10 09:25:33 +08:00
// 根据实际情况看是否需要重新登录
ElMessageBox.confirm(
2024-05-17 12:06:29 +08:00
'是否跳转到所选择医院?',
2024-04-10 09:25:33 +08:00
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
draggable: true
}
).then(() => {
2024-05-17 12:06:29 +08:00
hospitalApi.changeHospital(hospital.value).then((res: any) => {
if (res.code == 0) {
window.location.reload();
} else {
hospital.value = preHospital.value;
ElMessage.error("切换失败")
}
})
2024-04-10 09:25:33 +08:00
}).catch(() => {
2024-05-17 12:06:29 +08:00
hospital.value = preHospital.value;
2024-04-10 09:25:33 +08:00
})
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-05-17 12:06:29 +08:00
2024-04-10 09:25:33 +08:00
const userCommand = async (e: string) => {
switch (e) {
case 'logout':
await logout()
2024-05-17 12:06:29 +08:00
useUserStore().logout();
window.location.replace("/");
2024-04-10 09:25:33 +08:00
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>