statisticsTabs.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="statistics-tabs">
  3. <div
  4. v-for="(tab, index) in tabList"
  5. :key="tab.path"
  6. :class="['tab-bar', { 'tab-active': activeIndex === index }]"
  7. @click="clickHandler(index)"
  8. >
  9. <img
  10. class="tab-icon"
  11. :src="activeIndex === index ? tab.activeIcon : tab.defaultIcon"
  12. :alt="tab.title"
  13. >
  14. <span class="tab-title">{{ tab.title }}</span>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. const defaultIcon = require('@/assets/nav/ic_statistical_top_default.png')
  20. const activeIcon = require('@/assets/nav/ic_statistical_top_check.png')
  21. export default {
  22. name: 'StatisticsTabs',
  23. data() {
  24. return {
  25. tabList: [
  26. {
  27. path: '/statisticsCharts/flight',
  28. title: '航班量统计',
  29. defaultIcon,
  30. activeIcon
  31. },
  32. {
  33. path: '/statisticsCharts/node',
  34. title: '扫描节点与位置分析',
  35. defaultIcon,
  36. activeIcon
  37. },
  38. {
  39. path: '/statisticsCharts/baggage',
  40. title: '行李量统计',
  41. defaultIcon,
  42. activeIcon
  43. },
  44. {
  45. path: '/statisticsCharts/specialBaggage',
  46. title: '特殊行李量统计',
  47. defaultIcon,
  48. activeIcon
  49. },
  50. {
  51. path: '/statisticsCharts/passenger',
  52. title: '旅客量统计',
  53. defaultIcon,
  54. activeIcon
  55. }
  56. ],
  57. activeIndex: null
  58. }
  59. },
  60. watch: {
  61. '$route.path': {
  62. handler(val) {
  63. this.activeIndex = this.tabList.findIndex(tab => tab.path === val)
  64. },
  65. immediate: true
  66. },
  67. activeIndex(val) {
  68. this.$router.push({
  69. path: this.tabList[val].path
  70. })
  71. }
  72. },
  73. methods: {
  74. clickHandler(index) {
  75. this.activeIndex = index
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .statistics-tabs {
  82. display: flex;
  83. .tab-bar {
  84. min-width: 216px;
  85. height: 56px;
  86. background-color: #ffffff;
  87. padding-left: 24px;
  88. display: flex;
  89. align-items: center;
  90. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  91. border-radius: 4px;
  92. cursor: pointer;
  93. &:not(:last-child) {
  94. margin-right: 16px;
  95. }
  96. .tab-icon {
  97. width: 16px;
  98. height: 16px;
  99. margin-right: 15px;
  100. }
  101. .tab-title {
  102. font-size: 16px;
  103. font-family: Helvetica 'Microsoft YaHei';
  104. font-weight: bold;
  105. color: #101116;
  106. }
  107. &.tab-active {
  108. background-color: #2d67e3;
  109. .tab-title {
  110. color: #ffffff;
  111. }
  112. }
  113. }
  114. }
  115. </style>