餐饮油烟智能监测与监管一体化平台
feiyu02
2026-03-20 20cdb83586daabfb15fc056c4c97eb8e7ccaf928
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<template>
  <el-aside>
    <!-- <el-button
      type="default"
      :icon="collapse ? 'ArrowRightBold' : 'ArrowLeftBold'"
      circle
      size="small"
      class="toggle-btn"
      @click="collapse = !collapse"
    >
    </el-button> -->
    <el-scrollbar>
      <!-- 标题 -->
      <el-row ref="headerRef" class="header" align="center" justify="start">
        <el-space>
          <el-image :src="appIcon" style="width: 40px; height: 40px" />
          <span v-show="!collapse">{{ title }}</span>
        </el-space>
      </el-row>
      <!-- <el-scrollbar :height="menuHeight"> -->
      <el-menu
        :default-active="homePage"
        active-text-color="#ffd04b"
        background-color="#545c64"
        text-color="#fff"
        :collapse="collapse"
        @open="handleOpen"
        @close="handleClose"
        router
      >
        <MenuItems :routes="menus" @navPage="navPage"> </MenuItems>
      </el-menu>
      <!-- </el-scrollbar> -->
      <!-- 商标 -->
      <el-row ref="subTitleRef" class="sub-title" justify="center">
        <!-- <el-space>{{ collapse ? '' : subTitle }}</el-space> -->
      </el-row>
    </el-scrollbar>
  </el-aside>
</template>
 
<script>
import { MENU } from '@/constants/index'
import AppIcon from '@/assets/app-icon.png'
 
export default {
  props: {
    collapse: {
      type: Boolean,
      default: false,
    },
  },
  emits: ['navPage'],
  data() {
    return {
      // collapse: false,
      menuHeight: '80vh',
      title: '餐饮油烟智能监测监管',
      subTitle: '©上海飞羽环保科技有限公司',
      appIcon: AppIcon,
    }
  },
  computed: {
    homePage() {
      const paths = this.menuPath(this.menus[0])
      return paths[paths.length - 1].path
    },
    menus() {
      return MENU()
    },
  },
  methods: {
    handleOpen() {},
    handleClose() {},
    navPage(...item) {
      const titles = item.map((value) => {
        return value.name
      })
      this.$emit('navPage', titles)
    },
    calMenuHeight() {
      const h1 = this.$refs.headerRef?.$el.offsetHeight || 0
      // const h2 = this.$refs.header2Ref.$el.offsetHeight
      const h2 = 0
      const h3 = this.$refs.subTitleRef?.$el.offsetHeight || 0
      return `calc(100vh - ${h1}px - ${h2}px - ${h3}px)`
    },
    menuPath(m) {
      function getFirstMenu(menu) {
        if (menu.children) {
          return [menu, ...getFirstMenu(menu.children[0])]
        } else {
          return [menu]
        }
      }
      return getFirstMenu(m)
    },
  },
  created() {
    this.$router.push(this.homePage)
    this.navPage(...this.menuPath(this.menus[0]))
  },
  mounted() {
    this.menuHeight = this.calMenuHeight()
  },
}
</script>
 
<style lang="scss" scoped>
.el-aside {
  --background-color: #545c64;
  position: relative;
  background-color: var(--background-color);
  width: initial;
  // overflow: hidden;
}
.el-menu {
  // background-color: rgb(41,45,62);
  // background-color: rgb(50, 155, 185);
  // width: 200px;
  margin-bottom: 60px;
  border-right: none;
}
.toggle-btn {
  position: absolute;
  z-index: 10 !important;
  right: 0;
  top: 50%;
  margin-top: -12px;
}
.header {
  position: sticky;
  top: 0;
  color: white;
  background-color: var(--background-color);
  padding: 10px;
  /* margin-bottom: 10px; */
  // box-shadow: 0 0.2rem 0.2rem 0 #42484e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  // position: absolute;
  z-index: 2;
}
 
.title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
 
.sub-title {
  // background-color: aqua;
  width: 200px;
  position: fixed;
  left: 0;
  // right: 0;
  bottom: 0px;
  color: white;
  background-color: var(--background-color);
  // line-height: 40px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
 
.el-icon {
  font-size: 22px !important;
}
</style>