Browse Source

同上一条

feature
dai 3 years ago
parent
commit
fe25d9fbd9
  1. 303
      src/views/main.vue

303
src/views/main.vue

@ -1,33 +1,33 @@
<template> <template>
<div <div
v-loading.fullscreen.lock="loading" v-loading.fullscreen.lock="loading"
:element-loading-text="$t('loading')" :element-loading-text="$t('loading')"
:class="[ :class="[
'aui-wrapper', 'aui-wrapper',
{ {
'aui-sidebar--fold': 'aui-sidebar--fold':
$store.state.sidebarActiveSubMenuList.length == 0 || $store.state.sidebarActiveSubMenuList.length == 0 ||
$store.state.sidebarFold, $store.state.sidebarFold,
}, },
{ {
'aui-sidebar--noside': $store.state.inIframe, 'aui-sidebar--noside': $store.state.inIframe,
}, },
{ 'z-iframe': $store.state.inIframe }, { 'z-iframe': $store.state.inIframe },
]" ]"
> >
<template v-if="!loading"> <template v-if="!loading">
<main-navbar ref="ref_navbar" v-if="!$store.state.inIframe" /> <main-navbar ref="ref_navbar" v-if="!$store.state.inIframe" />
<main-sidebar v-if="!$store.state.inIframe" /> <main-sidebar v-if="!$store.state.inIframe" />
<div class="aui-content__wrapper"> <div class="aui-content__wrapper">
<main-content <main-content
v-if="!$store.state.contentIsNeedRefresh" v-if="!$store.state.contentIsNeedRefresh"
@changeCustomerName="changeCustomerName" @changeCustomerName="changeCustomerName"
/> />
</div> </div>
<!-- <secretary-log-notice v-if="!$store.state.inIframe" /> --> <!-- <secretary-log-notice v-if="!$store.state.inIframe" /> -->
</template> </template>
</div> </div>
</template> </template>
<script> <script>
@ -39,128 +39,139 @@ 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";
import { requestPost } from "@/js/dai/request"; import { requestPost } from "@/js/dai/request";
import { clearLoginInfo } from "@/utils";
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,
MainSidebar, MainSidebar,
MainContent, MainContent,
SecretaryLogNotice, SecretaryLogNotice,
}, },
watch: { watch: {
$route: "routeHandle", $route: "routeHandle",
}, },
async created() { async created() {
this.$store.state.sidebarMenuList = window.SITE_CONFIG["menuList"]; this.$store.state.sidebarMenuList = window.SITE_CONFIG["menuList"];
console.log(this.$store.state.sidebarMenuList); console.log(this.$store.state.sidebarMenuList);
// 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.sidebarMenuActiveName = tab.menuId; this.$store.state.sidebarMenuActiveName = tab.menuId;
this.$store.state.contentTabsActiveName = tab.name; this.$store.state.contentTabsActiveName = tab.name;
this.syncLevelOneMenuActive(tab.menuId); this.syncLevelOneMenuActive(tab.menuId);
}, },
async syncLevelOneMenuActive(menuId) { async syncLevelOneMenuActive(menuId) {
await nextTick(); await nextTick();
console.log( console.log(
"*******************************", "*******************************",
menuId, menuId,
this.$store.state.sidebarMenuList this.$store.state.sidebarMenuList
); );
const fn = (item) => { const fn = (item) => {
if (item.id == menuId) { if (item.id == menuId) {
return true; return true;
} else if (item.children.length > 0) { } else if (item.children.length > 0) {
return item.children.findIndex(fn) !== -1; return item.children.findIndex(fn) !== -1;
} else { } else {
return false; return false;
} }
}; };
let idx = this.$store.state.sidebarMenuList.findIndex(fn); let idx = this.$store.state.sidebarMenuList.findIndex(fn);
this.$store.state.LevelOneMenuActiveName = this.$store.state.LevelOneMenuActiveName =
idx !== -1 ? this.$store.state.sidebarMenuList[idx].id : ""; idx !== -1 ? this.$store.state.sidebarMenuList[idx].id : "";
this.$store.state.sidebarActiveSubMenuList = this.$store.state.sidebarActiveSubMenuList =
idx !== -1 ? this.$store.state.sidebarMenuList[idx].children : []; idx !== -1
}, ? this.$store.state.sidebarMenuList[idx].children
// : [];
async getWorkUserInfo() { },
const url = "/epmetuser/customerstaff/staffbasicinfo"; //
let params = {}; async getWorkUserInfo() {
const { data, code, msg } = await requestPost(url, params); const url = "/epmetuser/customerstaff/staffbasicinfo";
if (code === 0 && data) { let params = {};
this.$store.state.user = { ...data }; const { data, code, msg } = await requestPost(url, params);
console.log("user---hahha", this.$store.state.user); if (code === 0) {
localStorage.setItem("roleList", data.roleList); if (data) {
localStorage.setItem("customerId", data.customerId); this.$store.state.user = { ...data };
localStorage.setItem("staffId", data.id); console.log("user---hahha", this.$store.state.user);
localStorage.setItem("agencyId", data.agencyId); localStorage.setItem("roleList", data.roleList);
localStorage.setItem("level", data.level); localStorage.setItem("customerId", data.customerId);
if (!localStorage.getItem("customerName")) { localStorage.setItem("staffId", data.id);
localStorage.setItem("customerName", data.customerName || ""); localStorage.setItem("agencyId", data.agencyId);
} localStorage.setItem("level", data.level);
} else { if (!localStorage.getItem("customerName")) {
this.$message.error(msg); localStorage.setItem(
} "customerName",
}, data.customerName || ""
}, );
}
} else {
clearLoginInfo();
this.$router.push({ name: "login" });
}
} else {
this.$message.error(msg);
}
},
},
}; };
</script> </script>

Loading…
Cancel
Save