市北互联平台前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
5.5 KiB

4 years ago
<template>
<div
v-loading.fullscreen.lock="loading"
:element-loading-text="$t('loading')"
:class="[
'aui-wrapper',
{ 'aui-sidebar--fold': $store.state.sidebarFold },
{
'aui-sidebar--noside':
4 years ago
$store.state.sidebarActiveSubMenuList.length == 0,
},
{ 'z-iframe': $store.state.inIframe },
4 years ago
]"
>
<template v-if="!loading">
4 years ago
<main-navbar ref="ref_navbar" v-if="!$store.state.inIframe" />
<main-sidebar v-if="!$store.state.inIframe" />
4 years ago
<div class="aui-content__wrapper">
<main-content
v-if="!$store.state.contentIsNeedRefresh"
@changeCustomerName="changeCustomerName"
/>
</div>
4 years ago
<main-theme-tools v-if="!$store.state.inIframe" />
4 years ago
</template>
</div>
</template>
<script>
4 years ago
import MainNavbar from "./main-navbar";
import MainSidebar from "./main-sidebar";
import MainContent from "./main-content";
import MainThemeTools from "./main-theme-tools";
import debounce from "lodash/debounce";
import { mapGetters } from "vuex";
import nextTick from "dai-js/tools/nextTick";
4 years ago
export default {
provide() {
return {
// 刷新
refresh() {
4 years ago
this.$store.state.contentIsNeedRefresh = true;
4 years ago
this.$nextTick(() => {
4 years ago
this.$store.state.contentIsNeedRefresh = false;
});
},
};
4 years ago
},
data() {
return {
loading: true,
4 years ago
userType: localStorage.getItem("userType"),
};
4 years ago
},
components: {
MainNavbar,
MainSidebar,
MainContent,
4 years ago
MainThemeTools,
4 years ago
},
watch: {
4 years ago
$route: "routeHandle",
4 years ago
},
async created() {
4 years ago
this.windowResizeHandle();
this.routeHandle(this.$route);
if (localStorage.getItem("userType") === "work") {
4 years ago
Promise.all([this.getWorkUserInfo()]).then(() => {
4 years ago
this.loading = false;
});
4 years ago
} else {
Promise.all([this.getUserInfo()]).then(() => {
4 years ago
this.loading = false;
});
4 years ago
}
},
computed: {},
methods: {
changeCustomerName(customerName) {
4 years ago
this.$refs["ref_navbar"].changeCustomerName(customerName);
4 years ago
},
// 窗口改变大小
windowResizeHandle() {
this.$store.state.sidebarFold =
4 years ago
document.documentElement["clientWidth"] <= 992 || false;
4 years ago
window.addEventListener(
4 years ago
"resize",
4 years ago
debounce(() => {
this.$store.state.sidebarFold =
4 years ago
document.documentElement["clientWidth"] <= 992 || false;
4 years ago
}, 150)
4 years ago
);
4 years ago
},
// 路由, 监听
routeHandle(route) {
if (!route.meta.isTab) {
4 years ago
return false;
4 years ago
}
var tab = this.$store.state.contentTabs.filter(
(item) => item.name === route.name
4 years ago
)[0];
4 years ago
if (!tab) {
tab = {
4 years ago
...window.SITE_CONFIG["contentTabDefault"],
4 years ago
...route.meta,
name: route.name,
params: { ...route.params },
4 years ago
query: { ...route.query },
};
4 years ago
this.$store.state.contentTabs =
4 years ago
this.$store.state.contentTabs.concat(tab);
4 years ago
}
4 years ago
this.$store.state.sidebarMenuActiveName = tab.menuId;
this.$store.state.contentTabsActiveName = tab.name;
this.syncLevelOneMenuActive(tab.menuId);
4 years ago
},
async syncLevelOneMenuActive(menuId) {
4 years ago
await nextTick();
4 years ago
console.log(
4 years ago
"*******************************",
4 years ago
menuId,
this.$store.state.sidebarMenuList
4 years ago
);
4 years ago
const fn = (item) => {
if (item.id == menuId) {
4 years ago
return true;
4 years ago
} else if (item.children.length > 0) {
4 years ago
return item.children.findIndex(fn) !== -1;
4 years ago
} else {
4 years ago
return false;
4 years ago
}
4 years ago
};
let idx = this.$store.state.sidebarMenuList.findIndex(fn);
4 years ago
this.$store.state.LevelOneMenuActiveName =
4 years ago
idx !== -1 ? this.$store.state.sidebarMenuList[idx].id : "";
4 years ago
this.$store.state.sidebarActiveSubMenuList =
4 years ago
idx !== -1 ? this.$store.state.sidebarMenuList[idx].children : [];
4 years ago
},
// 获取当前管理员信息
getUserInfo() {
4 years ago
const url = "/epmetuser/operuser/queryOperUserDto";
4 years ago
return this.$http
.get(url)
.then(({ data: res }) => {
if (res.code !== 0) {
4 years ago
return this.$message.error(res.msg);
4 years ago
}
4 years ago
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", "");
4 years ago
})
4 years ago
.catch(() => {});
4 years ago
},
// 获取当前管理员信息
getWorkUserInfo() {
4 years ago
const url = "/epmetuser/customerstaff/staffbasicinfo";
let params = {};
4 years ago
window.app.ajax.post(
url,
params,
(data, rspMsg) => {
4 years ago
this.$store.state.user = { ...data };
console.log("user---hahha", this.$store.state.user);
4 years ago
// 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
4 years ago
localStorage.setItem("roleList", data.roleList);
localStorage.setItem("customerId", data.customerId);
4 years ago
// this.$store.state.user.roleList = data.roleList
// this.$store.state.user.customerId = data.customerId
},
(rspMsg, data) => {
4 years ago
this.$message.error(rspMsg);
4 years ago
}
4 years ago
);
4 years ago
// return this.$http.get(url).then(({ data: res }) => {
// if (res.code !== 0) {
// return this.$message.error(res.msg)
// }
// }).catch(() => { })
4 years ago
},
},
};
4 years ago
</script>