| | |
| | | <script setup> |
| | | import { RouterLink,useRouter} from 'vue-router' |
| | | import useUserInfoStore from '@/stores/userInfo' |
| | | import request from "@/utils/request"; |
| | | import {ElMessage} from "element-plus"; |
| | | import request from "@/utils/request" |
| | | import {ElMessage} from "element-plus" |
| | | import {onMounted, reactive, ref, watch} from "vue" |
| | | import deepClone from "@/utils/deepClone" |
| | | import userInfo from '@/stores/userInfo' |
| | | import {Close, Grid, Histogram, MessageBox, SwitchButton} from "@element-plus/icons-vue"; |
| | | |
| | | import {Close, Grid, Histogram, MessageBox, SwitchButton} from "@element-plus/icons-vue" |
| | | import { useI18n } from 'vue-i18n' |
| | | import i18n from "@/lang/index" |
| | | const lang = i18n.global.locale.value |
| | | //语言获取 |
| | | const { t } = useI18n() |
| | | const store=userInfo() |
| | | |
| | | const router = useRouter() |
| | | const userStore = useUserInfoStore() |
| | | const user = userStore.user.userName |
| | | store.createWebSocket(); |
| | | const user = userStore.user?.userName |
| | | |
| | | |
| | | //监听异步返回代码 |
| | | watch(()=>userStore.responseCode,(newVal) => { |
| | | switch (newVal){ |
| | | case 401:{ |
| | | if(userStore.msg.split('.')[1] === 'search'){ |
| | | router.push({path:'/main/user/notPermission'}); |
| | | }else{ |
| | | ElMessage.warning(t('error.Code_401')) |
| | | } |
| | | userStore.responseCode=null |
| | | break |
| | | } |
| | | case 402:{ |
| | | ElMessage.warning(t('error.Code_402')) |
| | | router.push("/login") |
| | | break |
| | | } |
| | | /*case 500:{ |
| | | ElMessage.warning(t('main.connectErr')) |
| | | break |
| | | }*/ |
| | | default:{ |
| | | break |
| | | } |
| | | } |
| | | } |
| | | ) |
| | | |
| | | //store.createWebSocket(); |
| | | |
| | | // 退出登录 |
| | | function quit(){ |
| | | userStore.$patch({ |
| | | user:null |
| | | }) |
| | | router.push("/login") |
| | | request.post('/userInfo/logout').finally(()=>{ |
| | | router.push("/login") |
| | | }) |
| | | |
| | | // |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //提取模块列表 |
| | | let menuList=$ref([]) |
| | | request.get("/menu").then((res) => { |
| | | if(res.code==200){ |
| | | menuList= deepClone(res.data) |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | onMounted(async ()=>{ |
| | | await request.get(`/menu/getMenu/${lang}`).then((res) => { |
| | | if(res.code==200){ |
| | | menuList= deepClone(res.data) |
| | | } |
| | | }) |
| | | |
| | | if(userStore.user.address!==null){ |
| | | router.push({path:'/main/reportingWorks/addReportingWork'}) |
| | | } |
| | | |
| | | }) |
| | | |
| | | |
| | | //获取菜单列表 |
| | | let menuItemList=$ref([]) |
| | | request.get("/menuItem").then((res) => { |
| | | request.get(`/menuItem/getMenuItem/${lang}`).then((res) => { |
| | | if(res.code==200){ |
| | | menuItemList= deepClone(res.data) |
| | | }else{ |
| | |
| | | {deep:true} |
| | | ) |
| | | |
| | | router.beforeEach((to, from) => { |
| | | //return false |
| | | }) |
| | | |
| | | |
| | | |
| | | let openFlag = $ref(null) |
| | |
| | | </script> |
| | | |
| | | <template> |
| | | <div> |
| | | <el-container> |
| | | <div style="height:100%;width:100%"> |
| | | <el-container id="el-container1"> |
| | | <el-header > |
| | | <div style="height: 100%;width: 100%;display: flex"> |
| | | <img src="../assets/northGlass.ico" alt="" style="max-width: 100%;max-height: 100%"> |
| | | <h3 style="margin: 1rem ;font-weight: bold;width: 20vw;"> 欢迎{{ user }}使用北玻ERP系统!</h3> |
| | | <span style="height: 70%;width: 78vw;margin-top: 1rem;" > |
| | | |
| | | <el-button class="sys-quit" @click="quit" type="info" round> |
| | | <el-icon size="large"><SwitchButton size=""/></el-icon> |
| | | </el-button> |
| | | <h3 style="margin: 1rem ;font-weight: bold;width: 95%;"> {{$t('main.titleFirst') + user + $t('main.titleLast')}}</h3> |
| | | <span style="height: 70%;width: 10%;margin-top: 1.5rem;" > |
| | | <el-icon @click="quit" style="float: right;margin-right: 1rem" size="large" ><SwitchButton size=""/></el-icon> |
| | | </span> |
| | | |
| | | </div> |
| | | </el-header> |
| | | <el-container > |
| | | <el-container id="el-container2"> |
| | | <el-aside width="160px" style="height: 97%; " > |
| | | <!-- <el-menu |
| | | style=" border-radius:0.5rem;border: 0.01rem solid #409EFF;margin-bottom: 0.5rem" |
| | |
| | | </el-menu>--> |
| | | <div class="menu" > |
| | | <div v-for="items in menuList"> |
| | | <div class='menu_title' @click="openMenu(items.id)" >{{items.menuName}}<span class='indicator' >▼</span></div> |
| | | <el-tooltip |
| | | class="box-item" |
| | | effect="dark" |
| | | :content="$t('menu.'+items.id)" |
| | | placement="right" |
| | | show-after="500" |
| | | > |
| | | <div class='menu_title' @click="openMenu(items.id)" >{{$t('menu.'+items.id)}}<span class='indicator' >▼</span></div> |
| | | </el-tooltip> |
| | | <ul class='enter-x-left' v-show="openFlag==items.id"> |
| | | |
| | | <li v-for="menuItem in menuItemList" |
| | | v-show="items.id==menuItem.menuID" |
| | | style="margin-bottom: 2px" |
| | | <el-tooltip |
| | | v-for="menuItem in menuItemList" |
| | | class="box-item" |
| | | effect="dark" |
| | | :content="$t('menu.'+menuItem.menu)" |
| | | placement="right" |
| | | show-after="500" |
| | | > |
| | | <router-link |
| | | :to="{path:menuItem.url}"> |
| | | {{ menuItem.itemName}} |
| | | </router-link> |
| | | <li |
| | | v-show="items.id==menuItem.menuID" |
| | | style="margin-bottom: 2px" |
| | | > |
| | | |
| | | </li> |
| | | <router-link |
| | | :to="{path:menuItem.url}"> |
| | | {{ $t('menu.'+menuItem.menu)}} |
| | | </router-link> |
| | | |
| | | </li> |
| | | </el-tooltip> |
| | | </ul> |
| | | </div> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <style scoped> |
| | | .el-container{ |
| | | height: 100vh; |
| | | width: 100vw |
| | | |
| | | #el-container1{ |
| | | height: 100%; |
| | | width: 100%; |
| | | } |
| | | #el-container2{ |
| | | height:calc(100% - 60px); |
| | | width: 100%; |
| | | } |
| | | |
| | | *{ |