Headers.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div>
  3. <div class="header">
  4. <div class="title-card">
  5. <li class="bg-img" @click="ConfirmBtn({ id: 1, url: '/home' })" :class="getClass(1)">
  6. <img src="../assets/images/Vector.png" alt="" />
  7. <linear-text
  8. text="总览"
  9. startColor="#95CCFF"
  10. endColor="#fff"
  11. fontSize="20px"
  12. />
  13. </li>
  14. <ul v-for="(item, index) in titleList" :key="index">
  15. <li
  16. class="bg-img"
  17. @click="ConfirmBtn(item)"
  18. :class="getClass(item.id)"
  19. >
  20. <linear-text
  21. :text="item.name"
  22. startColor="#95CCFF"
  23. endColor="#fff"
  24. fontSize="20px"
  25. />
  26. </li>
  27. </ul>
  28. </div>
  29. <div class="title-card">
  30. <ul v-for="(item, index) in titleList1" :key="index">
  31. <li
  32. class="bg-img"
  33. @click="ConfirmBtn(item)"
  34. :class="getClass(item.id)"
  35. >
  36. <linear-text
  37. :text="item.name"
  38. startColor="#95CCFF"
  39. endColor="#fff"
  40. fontSize="20px"
  41. />
  42. </li>
  43. </ul>
  44. <li class="bg-img" @click="ConfirmBtn(8)" :class="getClass(8)">
  45. <img src="../assets/images/out.png" alt="" />
  46. </li>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import Image1 from "../assets/images/fxyj2.png";
  53. import Image2 from "../assets/images/fxyj4.png";
  54. import Image3 from "../assets/images/fxyj7.png";
  55. import Image4 from "../assets/images/fxyj8.png";
  56. export default {
  57. // eslint-disable-next-line vue/multi-word-component-names
  58. name: "Headers",
  59. data() {
  60. return {
  61. imgList: [
  62. { load: Image1 },
  63. { load: Image2 },
  64. { load: Image3 },
  65. { load: Image4 },
  66. ],
  67. titleList: [
  68. {
  69. name: "基础信息",
  70. id: 2,
  71. url: '/basic'
  72. },
  73. {
  74. name: "消防管理",
  75. id: 3,
  76. url:'/fire'
  77. },
  78. {
  79. name: "风险预警",
  80. id: 4,
  81. },
  82. ],
  83. titleList1: [
  84. {
  85. name: "警情动态",
  86. id: 5,
  87. },
  88. {
  89. name: "火灾情况",
  90. id: 6,
  91. },
  92. {
  93. name: "消防物联网",
  94. id: 7,
  95. },
  96. ],
  97. test: 1,
  98. flag: -1,
  99. };
  100. },
  101. mounted() {
  102. console.log(this.test);
  103. },
  104. methods: {
  105. ConfirmBtn(item) {
  106. if (item.url && this.$route.path !== item.url) {
  107. this.flag = item.id
  108. this.$router.push(item.url)
  109. <<<<<<< HEAD
  110. } else if (item.url) {
  111. =======
  112. } else if (this.$route.path !== item.url) {
  113. >>>>>>> de5e4fd (fix: 修复在当前页面重复点击提示未开发的问题)
  114. alert("【" + item.name + "】模块开发中...")
  115. }
  116. },
  117. getClass(v) {
  118. return this.flag == v ? "bg-img active" : "bg-img";
  119. },
  120. },
  121. created() {
  122. console.log(this);
  123. },
  124. watch: {
  125. $route: {
  126. handler(route) {
  127. this.flag = route.meta.id
  128. },
  129. immediate: true,
  130. deep: true
  131. }
  132. }
  133. };
  134. </script>
  135. <style scoped>
  136. .header {
  137. width: 100%;
  138. height: 120px;
  139. /* background: url('../assets/top.png') center no-repeat; */
  140. background: url("../assets/images/top.png") center no-repeat;
  141. display: flex;
  142. justify-content: space-between;
  143. }
  144. .title-card {
  145. /* width: 400px; */
  146. display: flex;
  147. padding: 40px 20px;
  148. font-size: 20px;
  149. }
  150. img {
  151. width: 16px;
  152. height: 15px;
  153. margin-right: 8px;
  154. }
  155. .tab-list {
  156. width: 100%;
  157. display: flex;
  158. justify-content: space-between;
  159. }
  160. .bg-img {
  161. width: 118px;
  162. height: 48px;
  163. font-size: 18px;
  164. background: url("../assets/images/btn.png") no-repeat;
  165. background-size: 100% 100%;
  166. text-align: center;
  167. display: flex;
  168. justify-content: center;
  169. align-items: center;
  170. padding-left: 10px;
  171. line-height: 49px;
  172. }
  173. .bg-img:hover {
  174. cursor: pointer;
  175. }
  176. /* 选中效果 */
  177. .active {
  178. width: 150px;
  179. height: 48px;
  180. font-size: 18px;
  181. background: url("../assets/images/active-btn.png") no-repeat !important;
  182. background-size: 100% 100%;
  183. text-align: center;
  184. line-height: 49px;
  185. }
  186. </style>