智慧园区前端大屏
shuishen
2024-11-11 0bc7df816454853315ae524792fa44847a298b0a
home页layout相关
1 files added
120 ■■■■■ changed files
src/views/first/components/mainMenu.vue 120 ●●●●● patch | view | raw | blame | history
src/views/first/components/mainMenu.vue
New file
@@ -0,0 +1,120 @@
<template>
  <div class="page-mode">
    <div @mouseenter="item.childrenFlag = true" :class="{ active: currentUrl.indexOf(item.path) != -1 }"
      @mouseleave="item.childrenFlag = false" @click="goToPath(item)" v-for="(item, index) in menuList" :key="index">
      {{ item.menuName }}
    </div>
  </div>
</template>
<script setup>
import { ref, reactive, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { Search } from '@element-plus/icons-vue'
import { getTime } from '@/utils/getTime.js'
import { useRouterStore } from 'store/router'
const store = useRouterStore()
let router = useRouter()
let currentUrl = ref('statistics')
const menuList = ref(
  [
    {
      menuName: '园区概况',
      path: '/layout/first/survey'
    },
    {
      menuName: '风险源',
      path: '/layout/first/rs'
    },
    {
      menuName: '应急空间',
      path: '/layout/first/space'
    },
    {
      menuName: '应急物资',
      path: '/layout/first/supplies'
    },
    {
      menuName: '三级防控',
      path: '/layout/first/pac'
    },
    {
      menuName: '救援队伍',
      path: '/layout/first/rt'
    },
    {
      menuName: '污染物处理',
      path: '/layout/first/pd'
    },
  ]
)
const goToPath = (params) => {
  if (params.children && params.children.length > 0) return
  if (params.path) {
    if (router.currentRoute.value.path == params.path) return
    if (params.path == '/layout/first/supplies' || params.path == '/layout/first/rt') {
      store.setLoadSingle(true)
    } else {
      store.setLoadSingle(false)
    }
    router.push(params.path)
  } else {
    params.childrenFlag = !params.childrenFlag
  }
}
watch(
  () => router.currentRoute.value,
  (newValue, oldValue) => {
    currentUrl.value = newValue.path
  },
  { immediate: true }
)
const userName = ref('管理员')
</script>
<style lang="scss" scoped>
.page-mode {
  position: absolute;
  top: auto;
  bottom: 55px;
  left: 50%;
  z-index: 99;
  transform: translateX(-50%);
  display: flex;
  pointer-events: auto;
  &>div {
    background-image: url(/images/mode-tab.png);
    background-size: cover;
    width: 136px;
    height: 50px;
    font-size: 16px;
    text-align: center;
    font-weight: bold;
    color: #BFD3E5;
    line-height: 32px;
    padding-top: 12px;
    margin-right: -20px;
    font-style: italic;
    cursor: pointer;
    box-sizing: border-box;
    &:last-child {
      margin-right: 0px;
    }
    &.active {
      color: #F6FCFF;
      background-image: url(/images/mode-tab-ac.png);
    }
  }
}
</style>