menusIndex.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <el-row class="menus">
  3. <el-col :span="20" class="left">
  4. <el-col :span="6" class="imgs">
  5. <el-image class="images" :src="logoUrl"></el-image>
  6. </el-col>
  7. <el-col :span="18" class="menusInfo">
  8. <el-menu
  9. :router="true"
  10. :default-active="activeIndex"
  11. mode="horizontal"
  12. background-color="transparent"
  13. text-color="#4E5051"
  14. active-text-color="#000000"
  15. >
  16. <el-menu-item index="/">首页</el-menu-item>
  17. <el-menu-item index="/introduceIndex">集团介绍</el-menu-item>
  18. <el-menu-item index="/newsIndex">集团新闻</el-menu-item>
  19. <el-menu-item index="/messIndex">信息公开</el-menu-item>
  20. <el-menu-item index="/popularwillIndex">民意征集</el-menu-item>
  21. <el-menu-item index="/watersupplyIndex">供水信息</el-menu-item>
  22. <el-menu-item index="/inwaterIndex">走进水务</el-menu-item>
  23. </el-menu>
  24. </el-col>
  25. </el-col>
  26. <el-col :span="4" class="right">
  27. <el-input v-model="key" placeholder="请输入查询内容">
  28. <template #append>
  29. <el-button @click="toSearch" :icon="Search" />
  30. </template>
  31. </el-input>
  32. </el-col>
  33. </el-row>
  34. </template>
  35. <script setup lang="ts">
  36. defineOptions({ name: 'menusIndex' })
  37. // 基础
  38. import { ref, watch } from 'vue'
  39. import { Search } from '@element-plus/icons-vue'
  40. import { useRouter } from 'vue-router'
  41. const router = useRouter()
  42. const logoUrl = ref('logo.png')
  43. const activeIndex = ref('/')
  44. const key = ref('')
  45. const toSearch = () => {
  46. if (key.value) {
  47. window.open(`/queryIndex?key=${key.value}`)
  48. }
  49. }
  50. /* 监听 */
  51. watch(
  52. () => router.currentRoute.value,
  53. (to) => {
  54. activeIndex.value = to.path
  55. },
  56. { deep: true, immediate: true },
  57. )
  58. </script>
  59. <style scoped lang="scss">
  60. .menus {
  61. padding: 0 10%;
  62. .left {
  63. display: flex;
  64. align-items: center;
  65. .imgs {
  66. height: 46px;
  67. .images {
  68. width: 203px;
  69. height: 46px;
  70. }
  71. }
  72. .menusInfo {
  73. height: 46px;
  74. }
  75. }
  76. .right {
  77. display: flex;
  78. align-items: center;
  79. }
  80. }
  81. .el-menu--horizontal {
  82. height: 46px;
  83. }
  84. .el-menu--horizontal.el-menu {
  85. border-bottom: none;
  86. }
  87. .el-menu--horizontal > .el-menu-item.is-active {
  88. border-bottom: 2px solid #1586ff;
  89. }
  90. .el-menu-item:hover {
  91. background-color: transparent !important;
  92. color: #000000 !important;
  93. border-bottom: 2px solid #1586ff;
  94. }
  95. .el-menu--horizontal > .el-menu-item {
  96. font-weight: bold;
  97. width: 100px;
  98. }
  99. </style>