|
|
@ -1,57 +1,60 @@ |
|
|
|
<template> |
|
|
|
<div :class="{ 'has-logo': showLogo }"> |
|
|
|
<div :class="{'has-logo':showLogo}"> |
|
|
|
<logo v-if="showLogo" :collapse="isCollapse" /> |
|
|
|
<el-scrollbar wrap-class="scrollbar-wrapper"> |
|
|
|
<el-menu |
|
|
|
:default-active="activeMenu" |
|
|
|
:background-color="variables.menuBg" |
|
|
|
:text-color="variables.menuText" |
|
|
|
:unique-opened="true" |
|
|
|
:active-text-color="variables.menuActiveText" |
|
|
|
:collapse-transition="true" |
|
|
|
mode="vertical" |
|
|
|
router |
|
|
|
> |
|
|
|
<!--:key:"'/anruifinmanagement'"--> |
|
|
|
<el-menu-item :key="'/anruifinmanagement/finginvoiceapply'" :index="'/anruifinmanagement/finginvoiceapply'"><span slot="title">开票管理</span></el-menu-item> |
|
|
|
|
|
|
|
<el-menu-item :key="'/anruifinmanagement/finreceipt'" :index="'/anruifinmanagement/finreceipt'"><span slot="title">款项确认</span></el-menu-item> |
|
|
|
|
|
|
|
<!-- <el-menu-item :key="'/anruifinmanagement'" :index="'/anruifinmanagement/finmaterial'"><span slot="title">物料信息管理</span></el-menu-item>--> |
|
|
|
|
|
|
|
<el-menu-item :key="'/anruifinmanagement/finitem'" :index="'/anruifinmanagement/finitem'"><span slot="title">费用项目管理</span></el-menu-item> |
|
|
|
|
|
|
|
<el-menu :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText" |
|
|
|
:unique-opened="false" :active-text-color="variables.menuActiveText" :collapse-transition="false" |
|
|
|
mode="vertical"> |
|
|
|
<sidebar-item v-for="route in routes" :key="route.path" :item="route" :base-path="route.path" /> |
|
|
|
</el-menu> |
|
|
|
</el-scrollbar> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { mapGetters } from 'vuex' |
|
|
|
import { |
|
|
|
mapGetters |
|
|
|
} from 'vuex' |
|
|
|
import Logo from './Logo' |
|
|
|
// import SidebarItem from './SidebarItem' |
|
|
|
import SidebarItem from './SidebarItem' |
|
|
|
import variables from '@/styles/variables.scss' |
|
|
|
import { getrolemenus } from '@/api/system/Role/role.js' |
|
|
|
import Layout from '@/layout' |
|
|
|
import { |
|
|
|
getrolemenus, |
|
|
|
loginDetails |
|
|
|
} from '@/api/system/Role/role.js' |
|
|
|
import { |
|
|
|
getStorage |
|
|
|
} from '@/utils/auth' |
|
|
|
export default { |
|
|
|
components: { |
|
|
|
// SidebarItem, |
|
|
|
SidebarItem, |
|
|
|
Logo |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
routes: [] |
|
|
|
YongHuid: [], |
|
|
|
routes: [], |
|
|
|
params: { |
|
|
|
sourceSid: '8825edb1-3b9f-48e0-8d78-a62aa8037fcb', |
|
|
|
userSid: '' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
...mapGetters(['sidebar']), |
|
|
|
// routes() { |
|
|
|
// console.log(this.$router.options.routes) |
|
|
|
// return this.$router.options.routes |
|
|
|
// }, |
|
|
|
...mapGetters([ |
|
|
|
'sidebar' |
|
|
|
]), |
|
|
|
// routes() { |
|
|
|
// f4d2e507-c4ed-451c-b364-04c08f962045 |
|
|
|
// console.log('78979789', this.$router.options.routes) |
|
|
|
// return this.$router.options.routes |
|
|
|
// }, |
|
|
|
activeMenu() { |
|
|
|
const route = this.$route; |
|
|
|
const { meta, path } = route; |
|
|
|
const route = this.$route |
|
|
|
const { |
|
|
|
meta, |
|
|
|
path |
|
|
|
} = route |
|
|
|
// if set path, the sidebar will highlight the path you set |
|
|
|
if (meta.activeMenu) { |
|
|
|
return meta.activeMenu |
|
|
@ -68,56 +71,31 @@ export default { |
|
|
|
return !this.sidebar.opened |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
this.getRoleRouter() |
|
|
|
created() { |
|
|
|
this.postHuoquyonghu() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getRoleRouter() { |
|
|
|
const userSid = window.sessionStorage.getItem('userSid') |
|
|
|
// let rolemenus = getrolemenus({userSid: userSid}) |
|
|
|
const params = { |
|
|
|
sourceSid: 'df3e44ae-412e-4b02-b9e4-6893dbf5f83b', |
|
|
|
userSid: userSid |
|
|
|
} |
|
|
|
getrolemenus(params).then(res => { |
|
|
|
console.log(res) |
|
|
|
|
|
|
|
const userRoles = this.resRouter(res.data) |
|
|
|
userRoles.push({ path: '*', redirect: '/404', hidden: true }) |
|
|
|
return userRoles |
|
|
|
}) |
|
|
|
}, |
|
|
|
resRouter(menus) { |
|
|
|
// 递归,将后台传来数组 |
|
|
|
for (var i = 0; i < menus.length; i++) { |
|
|
|
if (menus[i].children && menus[i].children.length != 0) { |
|
|
|
this.resRouter(menus[i].children) |
|
|
|
} |
|
|
|
if (menus[i].children.length == 0) { |
|
|
|
delete menus[i].children |
|
|
|
delete menus[i].redirect |
|
|
|
} |
|
|
|
if (menus[i].component == '') { |
|
|
|
// menus[i].component = eval(menus[i].path.substr(1)) |
|
|
|
console.log(menus[i]) |
|
|
|
menus[i] = { |
|
|
|
path: menus[i].path, |
|
|
|
component: Layout, |
|
|
|
redirect: menus[i].path, |
|
|
|
children: [menus[i]], |
|
|
|
name: menus[i].meta.title |
|
|
|
} |
|
|
|
// 获取用户信息 |
|
|
|
postHuoquyonghu() { |
|
|
|
var token = getStorage() |
|
|
|
loginDetails(token).then((response) => { |
|
|
|
if (response.code === '200') { |
|
|
|
this.YongHuid = response.data |
|
|
|
this.params.userSid = this.YongHuid.sid |
|
|
|
getrolemenus(this.params).then((res) => { |
|
|
|
// const userRoles = this.resRouter(res.data) |
|
|
|
this.routes = res.data |
|
|
|
console.log('userRoles:', this.routes) |
|
|
|
this.routes.push({ |
|
|
|
path: '*', |
|
|
|
redirect: '/404', |
|
|
|
hidden: true |
|
|
|
}) |
|
|
|
// return this.routes |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(menus) |
|
|
|
this.routes = menus |
|
|
|
return menus |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
<style scoped="scoped"> |
|
|
|
/deep/.scrollbar-wrapper { |
|
|
|
padding-bottom: 40px; |
|
|
|
} |
|
|
|
</style> |
|
|
|