changeLine.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <Drag :dom-class-name="'changeLine'">
  3. <div class="changeLine">
  4. <div class="title">
  5. 切换线路
  6. </div>
  7. <div
  8. v-show="show"
  9. class="content"
  10. >
  11. <n-input
  12. v-model:value="seastr"
  13. :bordered="false"
  14. round
  15. type="text"
  16. placeholder="搜索"
  17. />
  18. <div class="list">
  19. <div
  20. v-for="item in lineList"
  21. :key="item.lineId"
  22. class="item"
  23. :class="{'active': curLine.lineId === item.lineId}"
  24. @click="changeLine(item)"
  25. >
  26. {{ item.lineName }}
  27. </div>
  28. </div>
  29. </div>
  30. <div class="footer">
  31. <div class="cur">
  32. 当前:
  33. </div>
  34. <div> {{ curLine.lineName }}</div>
  35. </div>
  36. <div
  37. class="check"
  38. @click="show = !show"
  39. >
  40. {{ show ? '收起': '展开' }}
  41. </div>
  42. </div>
  43. </Drag>
  44. </template>
  45. <script lang="ts" setup>
  46. import NetService from '@/services/net.service'
  47. import Drag from './Drag.vue'
  48. import { computed, ref } from 'vue'
  49. import useStore from '@/pages/store'
  50. const store = useStore()
  51. const show = ref(false)
  52. const seastr = ref('')
  53. const netService = new NetService()
  54. const originLineList = ref([] as any[])
  55. const lineList = computed(() => originLineList.value.filter((item: any) => item.lineName.includes(seastr.value)))
  56. const curLine = ref({} as any)
  57. function changeLine(item: any) {
  58. curLine.value = item
  59. store.setCurrentLineId(item.lineId)
  60. store.setCurrentLinecode(item.lineCode)
  61. }
  62. async function getLine() {
  63. const res = await netService.get('/busLine/getList?hasModel=0')
  64. if (res.success) {
  65. originLineList.value = res.data
  66. // eslint-disable-next-line prefer-destructuring
  67. curLine.value = res.data[0]
  68. store.setCurrentLineId(res.data[0].lineId)
  69. store.setCurrentLinecode(res.data[0].lineCode)
  70. }
  71. }
  72. getLine()
  73. </script>
  74. <style lang="scss" scoped>
  75. .changeLine {
  76. position: absolute;
  77. color: #fff;
  78. width: 400px;
  79. border-radius: 5px;
  80. border: 1px solid #1891FF;
  81. background: #0F1A31;
  82. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.3137), inset 0px 1px 22px 0px #00BEFF;
  83. .title {
  84. height: 40px;
  85. line-height: 40px;
  86. text-align: center;
  87. background: rgba(33, 133, 232, 0.298);
  88. }
  89. .content {
  90. height: 260px;
  91. .n-input {
  92. margin: 10px 15px;
  93. width: 370px;
  94. background: none !important;
  95. border: solid 1.5px #2185E8;
  96. .n-input__input-el {
  97. color: #fff;
  98. }
  99. }
  100. .list {
  101. height: 200px;
  102. overflow-y: scroll;
  103. }
  104. .item {
  105. height: 50px;
  106. line-height: 50px;
  107. text-align: center;
  108. border-radius: 4px;
  109. box-sizing: border-box;
  110. &:hover {
  111. box-shadow: inset 0px 1px 12px 0px #80FFFF, inset 0px 1px 12px 0px #80FFFF;
  112. }
  113. &.active {
  114. background-color: #346274;
  115. border: 1px solid #80FFFF;
  116. }
  117. }
  118. }
  119. .footer {
  120. height: 55px;
  121. display: flex;
  122. justify-content: center;
  123. align-items: center;
  124. gap: 10px;
  125. .cur {
  126. color: #80FFFF;
  127. }
  128. }
  129. .check {
  130. position: absolute;
  131. top: 0;
  132. right: -54px;
  133. width: 54px;
  134. height: 40px;
  135. line-height: 40px;
  136. text-align: center;
  137. border-radius: 3px;
  138. border: 1px solid #1891FF;
  139. background: rgba(33, 133, 232, 0.298);
  140. cursor: pointer;
  141. }
  142. }
  143. </style>