index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="inner-container">
  3. <el-col :span="3"
  4. ><el-tabs
  5. tab-position="left"
  6. v-model="activeName"
  7. @tab-click="handleClick"
  8. >
  9. <el-tab-pane
  10. v-for="(item, index) in routerList"
  11. :key="index"
  12. :name="item.path"
  13. :label="item.label"
  14. ></el-tab-pane>
  15. </el-tabs>
  16. </el-col>
  17. <el-col :span="21" style="background: #f4f4f4;">
  18. <div style="height: 100%">
  19. <router-view />
  20. </div>
  21. </el-col>
  22. </div>
  23. </template>
  24. <script>
  25. import { userInfo } from 'os';
  26. export default {
  27. data() {
  28. return {
  29. activeName: "",
  30. showList: [],
  31. routerList: [
  32. { label: "地市", path: "/competitors", name: "competitors" },
  33. // { label: "省公司", path: "/company", name: "company" }
  34. ],
  35. };
  36. },
  37. computed: {
  38. menuList: function () {
  39. let arr = [];
  40. this.routerList.map((item) => {
  41. this.showList.map((row) => {
  42. if (item.path == row) {
  43. arr.push(item);
  44. }
  45. });
  46. });
  47. return arr;
  48. },
  49. },
  50. methods: {
  51. handleClick(val) {
  52. console.log(val);
  53. if (this.$route.path != this.activeName) {
  54. this.$router.push(this.activeName);
  55. }
  56. },
  57. },
  58. mounted() {
  59. if(!JSON.parse(window.sessionStorage.getItem('userInfo')).cityName){
  60. this.routerList.push({ label: "省公司", path: "/company", name: "company" })
  61. }
  62. this.activeName = this.$route.path;
  63. },
  64. created() {
  65. JSON.parse(sessionStorage.childrenMenus).map((item) => {
  66. this.showList.push(item.jspUrl);
  67. });
  68. },
  69. watch: {
  70. $route(to, from) {
  71. this.activeName = this.$route.path;
  72. },
  73. },
  74. };
  75. </script>
  76. <style>
  77. .el-tabs__content {
  78. display: none;
  79. }
  80. </style>