| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <template>
- <div ref="layouts" :class="{ 'app-container': !$route.meta.hideTabBar }">
- <div class="layout-content">
- <keep-alive :include="include">
- <router-view v-if="$route.meta.keepAlive"></router-view>
- </keep-alive>
- <router-view v-if="!$route.meta.keepAlive"></router-view>
- </div>
- <div v-if="!$route.meta.hideTabBar" class="layout-footer">
- <TabBar />
- </div>
- </div>
- </template>
- <script>
- import TabBar from '@/components/TabBar'
- import { userInfo } from '@/api/public'
- export default {
- name:"home",
- data() {
- return {
- container: null,
- include: [],
- }
- },
- components: {
- TabBar
- },
- created() {
- this.getUserInfo();
- },
- watch: {
- $route(to, from) {
- //console.log("home route",to,from);
- if(to.query && to.query.event=='SwitchUser')
- {
- this.getUserInfo();
- }
- //如果 要 to(进入) 的页面是需要 keepAlive 缓存的,把 name push 进 include数组
- if (to.meta.keepAlive) {
- !this.include.includes(to.name) && this.include.push(to.name)
- console.log(this.include, '缓存列表')
- }
- /**
- * 如果要form(离开)的页面是keepAlive缓存的,
- * 再根据deep来判断是前进还是后退
- */
- //后退
- console.log(from.meta.keepAlive, to.meta.deep, from.meta.deep, 'ppppppppp')
- if (from.meta.keepAlive && to.meta.deep < from.meta.deep) {
- let index = this.include.indexOf(from.name)
- index !== -1 && this.include.splice(index, 1)
- console.log(this.include, '缓存列表2')
- }
- console.log(this.include, '缓存列表3')
- }
- },
- methods: {
- getUserInfo() {
- userInfo().then(info => {
- this.$store.commit('SET_USER_NAME', info.user.name)
- this.$store.commit('SET_USER_ROLELIST', info.roleList)
- this.$store.commit('SET_USER_ID', info.user.id)
- this.$store.commit('SET_USER_ORGID', info.user.orgId)
- this.$store.commit('SET_USER_ORGNAME', info.user.orgName)
- this.$store.commit('SET_USER_ORGTYPE', info.user.orgType)
- // this.$store.commit('SET_USER_SUBUSERLIST', info.subUserList??null)
- this.$store.commit('SET_MASTER_USER_ID', info.masterUserId)
- this.$store.commit('SET_MASTER_USER_NAME', info.masterUserName)
- this.$store.commit('SET_MASTER_SIGNATURE_SEAL', info.user.signatureSeal)
- //登陆之后手动触发一次水印数据刷新
- this.$parent.$refs.watercom.getWater(1)
- })
- this.$store.dispatch('getOrgTree');
- this.$store.dispatch('getOrgTreeHangshe');
- this.$store.dispatch('redDot')
- },
- }
- }
- </script>
|