Browse Source

修复数据平台导航栏显示问题

V1.0
dai 4 years ago
parent
commit
ae3ffba7f1
  1. 32
      src/views/main-shuju/main-navbar.vue
  2. 118
      src/views/main-shuju/main.vue

32
src/views/main-shuju/main-navbar.vue

@ -3,9 +3,7 @@
<nav v-if="showHeader" class="m-navbar">
<div class="navbar__header">
<h1 class="navbar__brand" @click="$router.push({ name: 'home' })">
<a class="navbar__brand-lg" href="javascript:;">{{
userType === "work" ? customerName : $t("brand.lg")
}}</a>
<a class="navbar__brand-lg" href="javascript:;">{{ customerName }}</a>
<a class="navbar__brand-mini" href="javascript:;">{{
customerName.slice(0, 2)
}}</a>
@ -46,7 +44,9 @@
<template v-for="(menu, idx) in $store.state.mainShuju.menuList">
<li
class="sub-menu"
:class="$store.state.mainShuju.activeName==menu.name ? 'z-on':''"
:class="
$store.state.mainShuju.activeName == menu.name ? 'z-on' : ''
"
v-if="menu.children"
:key="menu.id"
@click="gotoRouteHandle(menu.id, idx)"
@ -150,22 +150,18 @@ export default {
UpdatePasswordWork,
},
created() {
let platformToken = localStorage.getItem("showHeader") || "";
if (
typeof platformToken !== "undefined" &&
platformToken !== "undefined" &&
platformToken !== ""
) {
this.showHeader = false;
}
console.log("=============================", this.userType);
// let platformToken = localStorage.getItem("showHeader") || "";
// if (
// typeof platformToken !== "undefined" &&
// platformToken !== "undefined" &&
// platformToken !== ""
// ) {
// this.showHeader = false;
// }
this.$store.state.mainShuju.menuList = window.SITE_CONFIG["menuShujuList"];
},
computed: {
userType() {
return localStorage.getItem("userType");
},
},
computed: {},
methods: {
toIndexPage() {
this.$router.replace("/indexWork");

118
src/views/main-shuju/main.vue

@ -6,8 +6,8 @@
'g-bd',
{ 'z-sidebar--fold': $store.state.sidebarFold },
{
'z-sidebar--noside':true
}
'z-sidebar--noside': true,
},
]"
>
<template v-if="!loading">
@ -23,29 +23,29 @@
</template>
<script>
import MainNavbar from './main-navbar'
import MainContent from './main-content'
import debounce from 'lodash/debounce'
import { mapGetters } from 'vuex'
import nextTick from 'dai-js/tools/nextTick'
import MainNavbar from "./main-navbar";
import MainContent from "./main-content";
import debounce from "lodash/debounce";
import { mapGetters } from "vuex";
import nextTick from "dai-js/tools/nextTick";
export default {
provide() {
return {
//
refresh() {
this.$store.state.contentIsNeedRefresh = true
this.$store.state.contentIsNeedRefresh = true;
this.$nextTick(() => {
this.$store.state.contentIsNeedRefresh = false
})
}
}
this.$store.state.contentIsNeedRefresh = false;
});
},
};
},
data() {
return {
loading: true,
userType: localStorage.getItem('userType')
}
userType: localStorage.getItem("userType"),
};
},
components: {
MainNavbar,
@ -53,105 +53,77 @@ export default {
},
watch: {
$route: 'routeHandle'
$route: "routeHandle",
},
async created() {
this.windowResizeHandle()
this.routeHandle(this.$route)
this.windowResizeHandle();
this.routeHandle(this.$route);
Promise.all([this.getWorkUserInfo()]).then(() => {
this.loading = false
})
this.loading = false;
});
},
computed: {},
methods: {
changeCustomerName(customerName) {
this.$refs['ref_navbar'].changeCustomerName(customerName)
this.$refs["ref_navbar"].changeCustomerName(
customerName || "数据分析可视化平台"
);
},
//
windowResizeHandle() {
this.$store.state.sidebarFold =
document.documentElement['clientWidth'] <= 992 || false
document.documentElement["clientWidth"] <= 992 || false;
window.addEventListener(
'resize',
"resize",
debounce(() => {
this.$store.state.sidebarFold =
document.documentElement['clientWidth'] <= 992 || false
document.documentElement["clientWidth"] <= 992 || false;
}, 150)
)
);
},
// ,
routeHandle(route) {
if (!route.meta.isTab) {
return false
return false;
}
var tab = this.$store.state.contentTabs.filter(
(item) => item.name === route.name
)[0]
)[0];
if (!tab) {
tab = {
...window.SITE_CONFIG['contentTabDefault'],
...window.SITE_CONFIG["contentTabDefault"],
...route.meta,
name: route.name,
params: { ...route.params },
query: { ...route.query }
}
query: { ...route.query },
};
this.$store.state.contentTabs =
this.$store.state.contentTabs.concat(tab)
this.$store.state.contentTabs.concat(tab);
}
this.$store.state.mainShuju.activeName = tab.menuId
this.$store.state.mainShuju.contentTabsActiveName = tab.name
},
//
getUserInfo() {
const url = '/epmetuser/operuser/queryOperUserDto'
return this.$http
.get(url)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.$store.state.user.id = res.data.id
this.$store.state.user.realName = res.data.realName
this.$store.state.user.superAdmin = res.data.superAdmin
this.$store.state.user.gender = data.gender
localStorage.setItem('customerId', '')
})
.catch(() => {})
this.$store.state.mainShuju.activeName = tab.menuId;
this.$store.state.mainShuju.contentTabsActiveName = tab.name;
},
//
getWorkUserInfo() {
const url = '/epmetuser/customerstaff/staffbasicinfo'
let params = {}
const url = "/epmetuser/customerstaff/staffbasicinfo";
let params = {};
window.app.ajax.post(
url,
params,
(data, rspMsg) => {
this.$store.state.user = { ...data }
// this.$store.state.user.id = data.id
// this.$store.state.user.realName = data.realName
// this.$store.state.user.superAdmin = data.superAdmin
// this.$store.state.user.gender = data.gender
localStorage.setItem('roleList', data.roleList)
localStorage.setItem('customerId', data.customerId)
// this.$store.state.user.roleList = data.roleList
// this.$store.state.user.customerId = data.customerId
this.$store.state.user = { ...data };
localStorage.setItem("roleList", data.roleList);
localStorage.setItem("customerId", data.customerId);
localStorage.setItem("customerName", data.customerName || "");
},
(rspMsg, data) => {
this.$message.error(rspMsg)
this.$message.error(rspMsg);
}
)
// return this.$http.get(url).then(({ data: res }) => {
// if (res.code !== 0) {
// return this.$message.error(res.msg)
// }
// }).catch(() => { })
}
}
}
);
},
},
};
</script>
<style lang="scss" src="@/assets/scss/main-shuju.scss" scoped></style>

Loading…
Cancel
Save