市北互联平台前端仓库
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.

167 lines
4.8 KiB

4 years ago
<template>
3 years ago
<div
v-loading.fullscreen.lock="loading"
:element-loading-text="$t('loading')"
:class="[
4 years ago
'aui-wrapper',
{ 'aui-sidebar--fold': $store.state.sidebarFold },
{
'aui-sidebar--noside':
3 years ago
$store.state.sidebarActiveSubMenuList.length == 0 ||
$store.state.inIframe,
4 years ago
},
{ 'z-iframe': $store.state.inIframe },
3 years ago
]"
>
4 years ago
<template v-if="!loading">
3 years ago
<main-navbar ref="ref_navbar" v-if="!$store.state.inIframe" />
4 years ago
<main-sidebar v-if="!$store.state.inIframe" />
4 years ago
<div class="aui-content__wrapper">
3 years ago
<main-content
v-if="!$store.state.contentIsNeedRefresh"
@changeCustomerName="changeCustomerName"
/>
4 years ago
</div>
4 years ago
<main-theme-tools v-if="!$store.state.inIframe" />
3 years ago
<!-- <secretary-log-notice 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";
3 years ago
import SecretaryLogNotice from "./modules/secretaryLog/cpts/notice";
4 years ago
import debounce from "lodash/debounce";
import { mapGetters } from "vuex";
import nextTick from "dai-js/tools/nextTick";
import { requestPost } from "@/js/dai/request";
4 years ago
export default {
3 years ago
provide() {
4 years ago
return {
// 刷新
3 years ago
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
},
3 years ago
data() {
4 years ago
return {
loading: true,
4 years ago
userType: localStorage.getItem("userType"),
};
4 years ago
},
components: {
MainNavbar,
MainSidebar,
MainContent,
4 years ago
MainThemeTools,
3 years ago
SecretaryLogNotice,
4 years ago
},
watch: {
4 years ago
$route: "routeHandle",
4 years ago
},
3 years ago
async created() {
this.$store.state.sidebarMenuList = window.SITE_CONFIG["menuList"];
console.log(this.$store.state.sidebarMenuList);
4 years ago
this.windowResizeHandle();
this.routeHandle(this.$route);
Promise.all([this.getWorkUserInfo()]).then(() => {
this.loading = false;
});
4 years ago
},
computed: {},
methods: {
3 years ago
changeCustomerName(customerName) {
4 years ago
this.$refs["ref_navbar"].changeCustomerName(customerName);
4 years ago
},
// 窗口改变大小
3 years ago
windowResizeHandle() {
4 years ago
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
},
// 路由, 监听
3 years ago
routeHandle(route) {
4 years ago
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
},
3 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
},
// 获取当前管理员信息
3 years ago
async getWorkUserInfo() {
4 years ago
const url = "/epmetuser/customerstaff/staffbasicinfo";
let params = {};
const { data, code, msg } = await requestPost(url, params);
if (code === 0) {
this.$store.state.user = { ...data };
console.log("user---hahha", this.$store.state.user);
localStorage.setItem("roleList", data.roleList);
localStorage.setItem("customerId", data.customerId);
localStorage.setItem("staffId", data.id);
localStorage.setItem("agencyId", data.agencyId);
if (!localStorage.getItem("customerName")) {
localStorage.setItem("customerName", data.customerName || "");
4 years ago
}
} else {
this.$message.error(rspMsg);
}
4 years ago
},
},
};
4 years ago
</script>