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

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

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

Loading…
Cancel
Save