Browse Source

增加路由守卫

pull/14/head
zq 1 month ago
parent
commit
642af783aa
  1. 28
      src/router/index.js
  2. 21
      src/views/HomeView.vue
  3. 13
      src/views/hospitalManage.vue

28
src/router/index.js

@ -34,7 +34,8 @@ const routes = [
},
meta: {
title: '医院管理',
hideBreadcrumb: true // 首页不显示面包屑
hideBreadcrumb: true, // 首页不显示面包屑
requiresAuth:true
}
},
{
@ -62,9 +63,6 @@ const routes = [
meta: {
title: '编辑医院',
breadcrumbParent: '医生信息' // 手动指定父级
// r如果想隐藏中间层级
// breadcrumbParent: '首页', // 跳过医生信息
// hideInBreadcrumb: true // 可选:隐藏当前项
}
},
{
@ -74,9 +72,6 @@ const routes = [
meta: {
title: '微信收款',
breadcrumbParent: '编辑医院' // 手动指定父级
// r如果想隐藏中间层级
// breadcrumbParent: '首页', // 跳过医生信息
// hideInBreadcrumb: true // 可选:隐藏当前项
}
},
@ -103,7 +98,8 @@ const routes = [
name: '收款方式',
meta: {
title: '收款管理',
hideBreadcrumb: true // 首页不显示面包屑
hideBreadcrumb: true, // 首页不显示面包屑
requiresAuth:true
}
},
]
@ -113,7 +109,22 @@ const router = new VueRouter({
base: process.env.BASE_URL,
routes
})
router.beforeEach((to, from, next) => {
// 检查本地存储是否有nick
const hasNick = localStorage.getItem('nick');
// 如果有nick且访问的是根路径,则重定向到/hospitalManage
if (hasNick && to.path === '/') {
next('/hospitalManage');
return;
}
// 如果没有nick且尝试访问需要认证的页面(如/hospitalManage),则重定向到首页
if (!hasNick && to.meta.requiresAuth) {
next('/');
return;
}
if (whiteSlideList.includes(to.path)) {
store.commit('SET_SIDEBAR', true); // 登录页面不显示侧边栏
} else {
@ -129,6 +140,7 @@ router.beforeEach((to, from, next) => {
} else {
store.commit('SET_HEADER', true); // 其他页面显示顶部
}
next();
});

21
src/views/HomeView.vue

@ -17,7 +17,7 @@
批量启用</GuipButton>
</div>
<div class="right" v-if="onlyHosFlag">
<GuipButton type="system" size="form" @click="addHospital(item)">添加医院</GuipButton>
<GuipButton type="system" size="form" @click="addHospitalUser">添加医院</GuipButton>
</div>
<div class="right flex" v-else>
<span>搜索医生</span>
@ -176,6 +176,8 @@ export default {
store.commit('SET_CUSTOMIZE', false);
store.commit('SET_SLIDER_MENU', 'menuData');
this.getInitData()
if(this.onlyHosFlag)return
// --
this.getBindpayList()
},
computed: {
@ -183,8 +185,8 @@ export default {
},
methods: {
//
getInitData() {
this.$http('POST', '/api/admin/doctor_depart_list', {
async getInitData() {
await this.$http('POST', '/api/admin/doctor_depart_list', {
name: this.doctorName
}).then(response => {
if (response.code == 0) {
@ -209,7 +211,6 @@ export default {
depart_id: 4
}).then(response => {
this.payList.push(...response.data[2],...response.data[3])
console.log(this.payList,response,'this.payList====00000');
}).catch(error => {
console.error(error, 'error')
})
@ -294,7 +295,7 @@ export default {
})
},
onSwitchChange1(row) {
console.log(row, '------flag');
// console.log(row, '------flag');
row.status = row.status == 0 ? 1 : 0;
this.$http('POST', '/api/admin/depart_mutil_option', {
depart_index_ids:row.id,
@ -314,7 +315,7 @@ export default {
this.$set(this.doctorList, row)
},
batchOperate(status) {
console.log(this.tableSelections,'this.tableSelections----');
// console.log(this.tableSelections,'this.tableSelections----');
if(!this.tableSelections || this.tableSelections.length <= 0) {
this.$message.error('未选择要'+(status == '0' ? '禁用':'启用')+'的科室')
return;
@ -386,6 +387,14 @@ export default {
query: { doctor_id: item.id }
})
},
addHospitalUser(){
// id token
let id = this.doctor_id;
this.$router.push({
name: '医院信息',
query: { doctor_id: id }
})
},
editDoctor(item) {
this.$router.push({
name: '医生信息',

13
src/views/hospitalManage.vue

@ -1,13 +0,0 @@
<template>
<div>
<el-form>
</el-form>
</div>
</template>
<script>
</script>
<style>
</style>
Loading…
Cancel
Save