Browse Source

修复报无comsterId问题

V1.0
dai 4 years ago
parent
commit
3de6ed2c77
  1. 2
      src/views/main-shuju/main-navbar.vue
  2. 15
      src/views/main-shuju/main.vue
  3. 68
      src/views/main.vue

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

@ -45,7 +45,7 @@
<li <li
class="sub-menu" class="sub-menu"
:class=" :class="
$store.state.mainShuju.activeName == menu.name ? 'z-on' : '' $store.state.mainShuju.activeName == menu.id ? 'z-on' : ''
" "
v-if="menu.children" v-if="menu.children"
:key="menu.id" :key="menu.id"

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

@ -102,25 +102,24 @@ export default {
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;
}, },
// //
getWorkUserInfo() { async getWorkUserInfo() {
const url = "/epmetuser/customerstaff/staffbasicinfo"; const url = "/epmetuser/customerstaff/staffbasicinfo";
let params = {}; let params = {};
window.app.ajax.post( const { data, code, msg } = await requestPost(url, params);
url, if (code === 0) {
params,
(data, rspMsg) => {
this.$store.state.user = { ...data }; this.$store.state.user = { ...data };
console.log("user---hahha", this.$store.state.user);
localStorage.setItem("roleList", data.roleList); localStorage.setItem("roleList", data.roleList);
localStorage.setItem("customerId", data.customerId); localStorage.setItem("customerId", data.customerId);
localStorage.setItem("staffId", data.id);
if (!localStorage.getItem("customerName")) { if (!localStorage.getItem("customerName")) {
localStorage.setItem("customerName", data.customerName || ""); localStorage.setItem("customerName", data.customerName || "");
} }
}, } else {
(rspMsg, data) => {
this.$message.error(rspMsg); this.$message.error(rspMsg);
} }
);
}, },
}, },
}; };

68
src/views/main.vue

@ -1,5 +1,6 @@
<template> <template>
<div v-loading.fullscreen.lock="loading" <div
v-loading.fullscreen.lock="loading"
:element-loading-text="$t('loading')" :element-loading-text="$t('loading')"
:class="[ :class="[
'aui-wrapper', 'aui-wrapper',
@ -9,14 +10,16 @@
$store.state.sidebarActiveSubMenuList.length == 0, $store.state.sidebarActiveSubMenuList.length == 0,
}, },
{ 'z-iframe': $store.state.inIframe }, { 'z-iframe': $store.state.inIframe },
]"> ]"
>
<template v-if="!loading"> <template v-if="!loading">
<main-navbar ref="ref_navbar" <main-navbar ref="ref_navbar" v-if="!$store.state.inIframe" />
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 v-if="!$store.state.contentIsNeedRefresh" <main-content
@changeCustomerName="changeCustomerName" /> v-if="!$store.state.contentIsNeedRefresh"
@changeCustomerName="changeCustomerName"
/>
</div> </div>
<main-theme-tools v-if="!$store.state.inIframe" /> <main-theme-tools v-if="!$store.state.inIframe" />
</template> </template>
@ -31,6 +34,7 @@ import MainThemeTools from "./main-theme-tools";
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";
import { requestPost } from "@/js/dai/request";
export default { export default {
provide() { provide() {
@ -63,15 +67,9 @@ export default {
async created() { async created() {
this.windowResizeHandle(); this.windowResizeHandle();
this.routeHandle(this.$route); this.routeHandle(this.$route);
if (localStorage.getItem("userType") === "work") {
Promise.all([this.getWorkUserInfo()]).then(() => { Promise.all([this.getWorkUserInfo()]).then(() => {
this.loading = false; this.loading = false;
}); });
} else {
Promise.all([this.getUserInfo()]).then(() => {
this.loading = false;
});
}
}, },
computed: {}, computed: {},
methods: { methods: {
@ -137,54 +135,22 @@ export default {
idx !== -1 ? this.$store.state.sidebarMenuList[idx].children : []; idx !== -1 ? this.$store.state.sidebarMenuList[idx].children : [];
}, },
// //
getUserInfo () { async getWorkUserInfo() {
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 () {
const url = "/epmetuser/customerstaff/staffbasicinfo"; const url = "/epmetuser/customerstaff/staffbasicinfo";
let params = {}; let params = {};
window.app.ajax.post( const { data, code, msg } = await requestPost(url, params);
url, if (code === 0) {
params,
(data, rspMsg) => {
this.$store.state.user = { ...data }; this.$store.state.user = { ...data };
console.log("user---hahha", this.$store.state.user); console.log("user---hahha", this.$store.state.user);
// 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("roleList", data.roleList);
localStorage.setItem("customerId", data.customerId); localStorage.setItem("customerId", data.customerId);
localStorage.setItem("staffId", data.id); localStorage.setItem("staffId", data.id);
// this.$store.state.user.roleList = data.roleList if (!localStorage.getItem("customerName")) {
// this.$store.state.user.customerId = data.customerId localStorage.setItem("customerName", data.customerName || "");
}, }
(rspMsg, data) => { } else {
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(() => { })
}, },
}, },
}; };

Loading…
Cancel
Save