App.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div id="app" v-loading="$store.state.loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
  3. <el-container>
  4. <el-aside width="230px">
  5. <el-menu router :unique-opened="true" :default-active="defaultActive" class="el-menu-vertical-demo"
  6. background-color="#545c64" text-color="#fff" active-text-color="#1890ff">
  7. <el-submenu :index="'menu-' + pIndex" v-for="(pItem, pIndex) in menus" :key="pIndex">
  8. <template slot="title">
  9. <i class="el-icon-location"></i>
  10. <span>{{pItem.name}}</span>
  11. </template>
  12. <el-menu-item-group>
  13. <el-menu-item :route="{ path: '/search', query: { tableid: cItem.tableid } }" :index="'/search?tableid=' + cItem.tableid"
  14. v-for="cItem in pItem.children" :key="cItem.tableid">{{cItem.tablename}}</el-menu-item>
  15. </el-menu-item-group>
  16. </el-submenu>
  17. <!-- <el-submenu index="menu-fjcsdb">
  18. <template slot="title">
  19. <i class="el-icon-location"></i>
  20. <span>参数对比</span>
  21. </template>
  22. <el-menu-item-group>
  23. <el-menu-item :route="{ path: '/lineChart' }" index="/lineChart">风机参数对比</el-menu-item>
  24. </el-menu-item-group>
  25. </el-submenu> -->
  26. </el-menu>
  27. </el-aside>
  28. <el-container>
  29. <!-- <el-header>Header</el-header> -->
  30. <el-main>
  31. <router-view />
  32. </el-main>
  33. </el-container>
  34. </el-container>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. data () {
  40. return {
  41. defaultActive: "/search",
  42. menus: []
  43. }
  44. },
  45. mounted () {
  46. let that = this;
  47. that.$nextTick(() => {
  48. // 获取左侧菜单数据
  49. that.API.get("datacenter/tables").then((res) => {
  50. let JSFW = {
  51. name: '计算服务',
  52. children: []
  53. };
  54. let MHS_FDC = {
  55. name: "麻黄山",
  56. children: []
  57. };
  58. let NSS_FDC = {
  59. name: "牛首山",
  60. children: []
  61. };
  62. let QS_FDC = {
  63. name: "青山",
  64. children: []
  65. };
  66. let SBQ_FDC = {
  67. name: "石板泉",
  68. children: []
  69. };
  70. let XS_FDC = {
  71. name: "香山",
  72. children: []
  73. };
  74. let DWK_GDC = {
  75. name: "大武口",
  76. children: []
  77. };
  78. let PL_GDC = {
  79. name: "平罗",
  80. children: []
  81. };
  82. let XH_GDC = {
  83. name: "宣和",
  84. children: []
  85. };
  86. let MCH_GDC = {
  87. name: "马场湖",
  88. children: []
  89. };
  90. res.data.forEach(ele => {
  91. if (ele.windpowerstationid === 'MHS_FDC') {
  92. MHS_FDC.children.push(ele);
  93. } else if (ele.windpowerstationid === 'NSS_FDC') {
  94. NSS_FDC.children.push(ele);
  95. } else if (ele.windpowerstationid === 'QS_FDC') {
  96. QS_FDC.children.push(ele);
  97. } else if (ele.windpowerstationid === 'SBQ_FDC') {
  98. SBQ_FDC.children.push(ele);
  99. } else if (ele.windpowerstationid === 'XS_FDC') {
  100. XS_FDC.children.push(ele);
  101. } else if (ele.windpowerstationid === 'DWK_GDC') {
  102. DWK_GDC.children.push(ele);
  103. } else if (ele.windpowerstationid === 'PL_GDC') {
  104. PL_GDC.children.push(ele);
  105. } else if (ele.windpowerstationid === 'XH_GDC') {
  106. XH_GDC.children.push(ele);
  107. } else if (ele.windpowerstationid === 'MCH_GDC') {
  108. MCH_GDC.children.push(ele);
  109. } else {
  110. JSFW.children.push(ele);
  111. }
  112. });
  113. that.menus.push(JSFW, MHS_FDC, NSS_FDC, QS_FDC, SBQ_FDC, XS_FDC, DWK_GDC, PL_GDC, XH_GDC, MCH_GDC);
  114. if (res.data && res.data.length) {
  115. that.defaultActive = '/search?tableid=JSFW'
  116. }
  117. });
  118. });
  119. },
  120. }
  121. </script>
  122. <style lang="scss">
  123. @import '@assets/css/base.scss';
  124. </style>
  125. <style lang="scss" scoped>
  126. #app {
  127. .el-container {
  128. height: 100%;
  129. }
  130. .el-aside {
  131. background: rgb(84, 92, 100);
  132. }
  133. }
  134. </style>