bottomMenu.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="bottom-btn-group">
  3. <div
  4. v-for="item in navList"
  5. :key="item.pathName"
  6. class="vent-row-center btn-item"
  7. :class="{ 'btn-item-active': isBtnActive === item.pathName || item.isHover }"
  8. @click="setBtn('click', item)"
  9. >
  10. {{ item.title }}
  11. </div>
  12. </div>
  13. </template>
  14. <script lang="ts">
  15. import { ref, defineComponent } from 'vue';
  16. type navListType = { title: string; pathName: string; isHover: Boolean };
  17. export default defineComponent({
  18. name: 'BottomMenu',
  19. props: {
  20. navList: {
  21. type: Array<navListType>,
  22. default: () => [
  23. {
  24. title: '监控界面',
  25. pathName: 'monitor',
  26. isHover: false,
  27. },
  28. {
  29. title: '历史监测记录',
  30. pathName: 'monitor_history',
  31. isHover: false,
  32. },
  33. {
  34. title: '操作历史记录',
  35. pathName: 'handler_history',
  36. isHover: false,
  37. },
  38. {
  39. title: '故障诊断历史记录',
  40. pathName: 'faultRecord',
  41. isHover: false,
  42. },
  43. ],
  44. },
  45. },
  46. emits: ['change'],
  47. setup(props, { emit }) {
  48. const isBtnActive = ref(props.navList[0].pathName);
  49. function setBtn(type, activeObj) {
  50. if (type === 'click') {
  51. isBtnActive.value = activeObj.pathName;
  52. activeObj.isHover = true;
  53. }
  54. props.navList.forEach((item) => {
  55. if (item.title !== activeObj.title) {
  56. activeObj.isHover = false;
  57. }
  58. });
  59. emit('change', isBtnActive.value);
  60. }
  61. return {
  62. setBtn,
  63. isBtnActive,
  64. };
  65. },
  66. });
  67. </script>
  68. <style lang="less" scoped>
  69. .bottom-btn-group {
  70. display: flex;
  71. position: fixed;
  72. width: 100%;
  73. height: 100px;
  74. bottom: 10px;
  75. align-items: center;
  76. justify-content: center;
  77. pointer-events: auto;
  78. z-index: 999;
  79. .btn-item {
  80. width: 182px;
  81. height: 53px;
  82. margin: 10px;
  83. color: #fff;
  84. cursor: pointer;
  85. padding-bottom: 2px;
  86. pointer-events: auto;
  87. background: url('/@/assets/images/vent/bottom-btn.png');
  88. font-family: 'ysbtFont';
  89. font-size: 18px;
  90. }
  91. .btn-item-active {
  92. background: url('/@/assets/images/vent/bottom-btn-active.png') !important;
  93. color: #ffffff !important;
  94. }
  95. }
  96. </style>