index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <el-scrollbar wrapClass="scrollbar-wrapper">
  3. <el-menu
  4. ref="xiu"
  5. mode="vertical"
  6. :unique-opened="true"
  7. :show-timeout="200"
  8. :default-active="activeIndex"
  9. :collapse="isCollapse"
  10. text-color="#303133"
  11. active-text-color="#26A2FF"
  12. >
  13. <!-- :default-openeds="['/performance']" -->
  14. <!-- <div class="logo">
  15. <img @click="$router.push({path: '/dashboard'})" style="width: 100%; height: 36px; cursor: pointer;" v-if="classObj.hideSidebar" :src="logoUrlMini" alt="">
  16. <img @click="$router.push({path: '/dashboard'})" v-else style="width: 100%; height: 60px;cursor: pointer;" :src="logoUrl" alt="">
  17. </div> -->
  18. <sidebar-item v-for="(item, index) in menu" :key="item.name" :item="item" :base-path="item.path"></sidebar-item>
  19. </el-menu>
  20. <!-- <div style="height: 30px;"></div> -->
  21. <!-- <p style="background-color: rgb(72, 119, 230);color: rgba(175, 199, 255, 0.39);z-index: 1002;text-align: center;left: 0px;position: absolute;font-size: 14px;bottom: 0px;width: 100%;line-height: 30px; height: 30px; margin:0;">功道云 v7.0</p> -->
  22. </el-scrollbar>
  23. </template>
  24. <script>
  25. import { mapGetters } from 'vuex';
  26. import SidebarItem from './SidebarItem';
  27. export default {
  28. props: {
  29. classObj: Object
  30. },
  31. data() {
  32. return {
  33. menu: [],
  34. imageUrl: '',
  35. isSetLogo: false,
  36. logoImgUrl: 'static/images/logo.png',
  37. logoImgUrlMini: 'static/images/logo_icon.png',
  38. activeIndex: this.$route.path
  39. };
  40. },
  41. components: { SidebarItem },
  42. watch: {
  43. $route(val) {
  44. switch (val.path) {
  45. case '/new_employee':
  46. this.activeIndex = '/employee_table';
  47. break;
  48. case '/examine_unit':
  49. this.activeIndex = '/performance_review';
  50. break;
  51. case '/participation_detail':
  52. this.activeIndex = '/performance_review';
  53. break;
  54. case '/team_detail':
  55. this.activeIndex = '/team_performance';
  56. break;
  57. case '/add_team_performance':
  58. this.activeIndex = '/team_performance';
  59. break;
  60. default:
  61. this.activeIndex = this.$route.path;
  62. }
  63. }
  64. },
  65. computed: {
  66. ...mapGetters(['permission_routers', 'sidebar']),
  67. isCollapse() {
  68. return !this.sidebar.opened;
  69. },
  70. logoUrl() {
  71. return this.logoImgUrl;
  72. },
  73. logoUrlMini() {
  74. return this.logoImgUrlMini;
  75. }
  76. },
  77. created() {
  78. const addRouters = [];
  79. let mo_list = [];
  80. let permission_list = [];
  81. var routerArr = this.$store.getters.addRouters;
  82. for (let i in mo_list) {
  83. permission_list.push(mo_list[i].code);
  84. }
  85. for (const item in routerArr) {
  86. const obj = [];
  87. for (const ritem in routerArr[item].children) {
  88. if (
  89. permission_list.indexOf(routerArr[item].children[ritem].name) >= 0 ||
  90. routerArr[item].children[ritem].hidden === true ||
  91. routerArr[item].children[ritem].common === true
  92. ) {
  93. obj.push(routerArr[item].children[ritem]);
  94. }
  95. obj.push(routerArr[item].children[ritem]);
  96. }
  97. if (obj.length > 0) {
  98. const _R = routerArr[item];
  99. _R['children'] = obj;
  100. addRouters.push(_R);
  101. }
  102. }
  103. this.menu = addRouters;
  104. this.$nextTick(() => {
  105. try {
  106. this.$refs.xiu.open('', '');
  107. } catch (e) {}
  108. });
  109. },
  110. methods: {
  111. handleAvatarSuccess(res, file) {
  112. this.imageUrl = URL.createObjectURL(file.raw);
  113. },
  114. beforeAvatarUpload(file) {
  115. const isJPG = file.type === 'image/jpeg';
  116. const isLt2M = file.size / 1024 / 1024 < 2;
  117. if (!isJPG) {
  118. this.$message.error('上传头像图片只能是 JPG 格式!');
  119. }
  120. if (!isLt2M) {
  121. this.$message.error('上传头像图片大小不能超过 2MB!');
  122. }
  123. return isJPG && isLt2M;
  124. }
  125. }
  126. };
  127. </script>
  128. <style rel="stylesheet/scss" lang="scss" scoped>
  129. $logoUrl: 'static/images/logo.png';
  130. .scrollbar-wrapper .logo {
  131. width: 100%;
  132. height: 60px;
  133. // background-image: url($logoUrl);
  134. background-repeat: no-repeat;
  135. background-position: center;
  136. }
  137. .hideSidebar .logo {
  138. // background-image: url(/static/images/logo_icon.png);
  139. background-size: 80%;
  140. }
  141. // .scrollbar-wrapper .el-menu:before{
  142. // content: " ";
  143. // width: 100%;
  144. // height: 60px;
  145. // background-image: url(/static/images/logo.png);
  146. // background-repeat: no-repeat;
  147. // background-position: center;
  148. // }
  149. .el-menu--popup {
  150. background: #5b8bf7;
  151. }
  152. // .hideSidebar .el-menu:before{
  153. // background-image: url(/static/images/logo_icon.png);
  154. // background-size: 80%;
  155. // }
  156. </style>
  157. <style>
  158. .scrollbar-wrapper .avatar-uploader .el-upload {
  159. width: 100%;
  160. }
  161. </style>