index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!-- vue 页面模板 -->
  2. <template>
  3. <div class="layout">
  4. <Layout>
  5. <PageHeader title=" ">
  6. <template #action>
  7. <div class="login_out" @click="login_out">退出</div>
  8. </template>
  9. <template #content> </template>
  10. </PageHeader>
  11. <Layout>
  12. <Sider hide-trigger :style="{ background: '#fff' }">
  13. <Menu
  14. :active-name="active_name"
  15. theme="primary"
  16. width="auto"
  17. @on-select="changePage"
  18. accordion
  19. v-if="menu_list.length"
  20. >
  21. <div v-for="(item, i) in menu_list" :key="i">
  22. <Submenu
  23. v-if="item.children && item.children.length"
  24. :name="item.router"
  25. >
  26. <template #title>
  27. <Icon :type="item.icon || 'ios-browsers'" />
  28. {{ item.name }}
  29. </template>
  30. <MenuItem
  31. v-for="v in item.children"
  32. :key="v.moduleId"
  33. :name="v.router"
  34. >
  35. {{ v.name }}
  36. </MenuItem>
  37. </Submenu>
  38. <MenuItem v-else :name="item.router">
  39. <Icon :type="item.icon || 'ios-browsers'" />
  40. {{ item.name }}
  41. </MenuItem>
  42. </div>
  43. </Menu>
  44. </Sider>
  45. <Layout :style="{ padding: '24px' }">
  46. <Content
  47. :style="{
  48. padding: '24px',
  49. height: content_height + 'px',
  50. overflow: 'auto',
  51. background: '#fff',
  52. }"
  53. >
  54. <router-view></router-view>
  55. </Content>
  56. </Layout>
  57. </Layout>
  58. </Layout>
  59. </div>
  60. </template>
  61. <script>
  62. import api from '../../api/index.js';
  63. export default {
  64. data() {
  65. return {
  66. content_height: 0,
  67. active_name: '',
  68. menu_list: [],
  69. };
  70. },
  71. mounted() {
  72. // 计算内容区域高度
  73. this.content_height = document.documentElement.clientHeight - 120;
  74. this.active_name = this.$route.path;
  75. api.menu_api().then(r => {
  76. this.menu_list = r || [];
  77. });
  78. },
  79. methods: {
  80. changePage(p) {
  81. this.$router.push(p);
  82. },
  83. login_out() {
  84. api.login_out_api().then(r => {
  85. console.log(r);
  86. localStorage.setItem('neican_token', '');
  87. this.$router.replace('/');
  88. });
  89. },
  90. },
  91. };
  92. </script>
  93. <style lang="scss">
  94. .layout {
  95. border: 1px solid #d7dde4;
  96. background: #f5f7f9;
  97. position: relative;
  98. border-radius: 4px;
  99. overflow: hidden;
  100. width: 100%;
  101. height: 100%;
  102. .login_out {
  103. cursor: pointer;
  104. }
  105. }
  106. </style>