fix : 菜单显示问题

This commit is contained in:
邓洁
2023-12-29 23:42:53 +08:00
parent 182b29bb17
commit 4430b9c651
2 changed files with 204 additions and 168 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div class="manage-btn">
<div v-for="(item,index) in btnList" :key="item.name" class="btn-box" @click="select(item,index)">
<div v-for="(item,index) in list" :key="item.name" class="btn-box" @click="select(item,index)">
<div :style="{ backgroundImage:'url(' +getImageUrl(item.icon)+')' }"></div>
<div :class="{'select-active':selectButton===index}">{{ item.name }}</div>
</div>
@@ -18,17 +18,17 @@ const props = defineProps({
default: []
},
})
watch(() => props.list, (now) => {
let newArr=[]
btnList.value.forEach((btnList) => {
now.forEach((item) => {
if (btnList.route==item) {
newArr.push(btnList)
}
})
})
btnList.value=newArr
}, {deep: true});
// watch(() => props.list, (now) => {
// let newArr=[]
// btnList.value.forEach((btnList) => {
// now.forEach((item) => {
// if (btnList.route==item) {
// newArr.push(btnList)
// }
// })
// })
// btnList.value=newArr
// }, {deep: true});
const emit = defineEmits(["update:modelValue", "select"]);
const btnList = ref([
{
@@ -56,6 +56,7 @@ const btnList = ref([
// name: '模拟仿真'
// },
])
const newList=ref([])
const selectButton = ref(props.modelValue);
const getImageUrl = (name) => {
return new URL(`../../assets/images/topAndDown/${name}`, import.meta.url).href

View File

@@ -106,6 +106,32 @@ const tunnelLength = ref(0);
const constructionLength = ref(0);
const routeList = ref([]);
let socket = reactive("");
const btnList = ref([
{
route: '/site',
icon: 'sp_icon_zdgl.png',
name: '站点管理'
},
{
route: '/tunnel',
icon: 'sp_icon_sdgl.png',
name: '隧道管理'
},
{
route: '/user',
icon: 'sp_icon_yhgl.png',
name: '用户管理'
},
// {
// route: '/system',
// icon: 'sp_icon_xtgl.png',
// name: '系统管理'
// },
// {
// icon: 'sp_icon_mngl.png',
// name: '模拟仿真'
// },
])
const serialNumber = ref("SC00DY00GH00ELBT");
let token = getToken();
let send = {
@@ -126,7 +152,6 @@ onMounted(() => {
});
const getUser = () => {
getUserInfo().then(res => {
showMenu.value=true
currentUser.value = res.data.user.userName
currentUserId.value = res.data.user.userId
})
@@ -140,7 +165,17 @@ const getDefaultSite = (siteId) => {
const getOtherInfo = () => {
getLargeScreenInfo().then((res) => {
if (res?.code === 1000) {
routeList.value = res.data.routeList
let routeArr = [];
console.log(res.data.routeList,"res.data.routeList")
res.data.routeList.forEach((item, index) => {
for (let btn of btnList.value) {
if (item === btn.route){
routeArr.push(btn)
}
}
})
routeList.value = routeArr
showMenu.value = true
siteList.value = res.data.siteOption
currentSiteId.value = res.data.siteOption[res.data.siteOption.length - 1].value
currentSite.value = res.data.siteOption[res.data.siteOption.length - 1].label