index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="content">
  3. <div class="content-info">
  4. <div class="content-info-left">
  5. <div class="content-info-left-style">
  6. <div class="content-info-left-style-title">
  7. {{ device.callsign }}
  8. </div>
  9. </div>
  10. <div class="content-info-left-style">
  11. <div class="content-info-left-style-info">
  12. <img class="content-info-left-style-info-icon" :src="aircraftSrc">
  13. <div class="content-info-left-style-info-text"
  14. :style="deviceInfo[device.sn] && deviceInfo[device.sn].mode_code !== EModeCode.Disconnected ? 'color:#00EE8B' : 'color:red'">
  15. {{ getTextByModeCode(deviceInfo[device.sn] ? deviceInfo[device.sn].mode_code : EModeCode.Disconnected) }}
  16. </div>
  17. </div>
  18. <div :class="['content-info-left-style-other', deviceReason ? 'warn' : '']">
  19. <div v-if="deviceReason">
  20. <span class="word-loop">
  21. {{ deviceReason }}
  22. </span>
  23. </div>
  24. <div v-else>
  25. N/A
  26. </div>
  27. </div>
  28. </div>
  29. <div class="content-info-left-style">
  30. <div class="content-info-left-style-info">
  31. <img class="content-info-left-style-info-icon" :src="controllerSrc">
  32. <div class="content-info-left-style-info-text" v-if="capacity">
  33. {{ device.gateway.callsign }}
  34. </div>
  35. <div class="content-info-left-style-info-text" style="color: red;" v-else>
  36. 未连接
  37. </div>
  38. </div>
  39. <div class="content-info-left-style-other">
  40. <div class="capacity" v-if="capacity">
  41. <img :src="batteryOneSrc" v-if="capacity >= 75">
  42. <img :src="batteryTwoSrc" v-else-if="capacity >= 50 && capacity < 75">
  43. <img :src="batteryThreeSrc" v-else-if="capacity >= 25 && capacity < 50">
  44. <img :src="batteryFourSrc" v-else-if="capacity < 25">
  45. <div>
  46. {{ capacity }}%
  47. </div>
  48. </div>
  49. <div v-else>
  50. N/A
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="content-info-right">
  56. <a-button style="padding: 0;" type="text"
  57. :disabled="!(deviceInfo[device.sn] && deviceInfo[device.sn].mode_code !== EModeCode.Disconnected)"
  58. @click.stop="onClickLookInfo">
  59. <img :src="infoSelectedSrc" v-if="osdVisible.visible && osdVisible.sn === device.sn">
  60. <img :src="infoSrc" v-else>
  61. </a-button>
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script lang="ts" setup>
  67. import { computed } from 'vue';
  68. import controllerSrc from './icons/controller.svg';
  69. import aircraftSrc from './icons/aircraft.svg';
  70. import batteryOneSrc from './icons/batteryOne.svg';
  71. import batteryTwoSrc from './icons/batteryTwo.svg';
  72. import batteryThreeSrc from './icons/batteryThree.svg';
  73. import batteryFourSrc from './icons/batteryFour.svg';
  74. import infoSrc from './icons/info.svg';
  75. import infoSelectedSrc from './icons/info_selected.svg';
  76. import { useMyStore } from '/@/store';
  77. import { getTextByModeCode } from '/@/utils/index'
  78. import { OnlineDevice, EModeCode } from '/@/types/device';
  79. interface Props {
  80. device: OnlineDevice,
  81. onClickLookInfo: () => void,
  82. };
  83. const props = withDefaults(defineProps<Props>(), {
  84. });
  85. const store = useMyStore()
  86. const deviceInfo = computed(() => store.state.deviceState.deviceInfo)
  87. const osdVisible = computed(() => store.state.osdVisible);
  88. // 设备原因
  89. const deviceReason = computed(() => {
  90. const device = store.state.deviceReason[props.device.sn];
  91. if (device) {
  92. return device.modeCodeReason;
  93. } else {
  94. return '';
  95. }
  96. })
  97. // 电池容量
  98. const capacity = computed(() => {
  99. const device: any = deviceInfo.value[props.device.sn];
  100. if (device) {
  101. return device.battery.capacity_percent;
  102. } else {
  103. return 0;
  104. }
  105. });
  106. </script>
  107. <style lang="scss" scoped>
  108. .content {
  109. width: 208px;
  110. border: 1px solid #3d3d3d;
  111. border-radius: 4px;
  112. overflow: hidden;
  113. color: #FFFFFF;
  114. cursor: pointer;
  115. &-info {
  116. display: flex;
  117. &-left {
  118. width: calc(100% - 20px);
  119. padding: 5px;
  120. font-size: 12px;
  121. &-style {
  122. width: 100%;
  123. height: 24px;
  124. display: flex;
  125. margin-bottom: 5px;
  126. &-title {
  127. font-size: 13px;
  128. white-space: nowrap;
  129. overflow: hidden;
  130. text-overflow: ellipsis;
  131. }
  132. &-info {
  133. width: 100px;
  134. padding-left: 5px;
  135. background: #3d3d3d;
  136. display: flex;
  137. align-items: center;
  138. &-icon {
  139. width: 14px;
  140. height: 14px;
  141. margin-right: 5px;
  142. }
  143. &-text {
  144. white-space: nowrap;
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. }
  148. }
  149. &-other {
  150. width: calc(100% - 100px);
  151. height: 100%;
  152. padding-left: 5px;
  153. background: #4a4d4e;
  154. display: flex;
  155. align-items: center;
  156. overflow: hidden;
  157. .capacity {
  158. width: 100%;
  159. height: 100%;
  160. display: flex;
  161. align-items: center;
  162. img {
  163. width: 14px;
  164. height: 14px;
  165. margin-right: 5px;
  166. }
  167. }
  168. }
  169. }
  170. &-style:first-child {
  171. margin: 0;
  172. }
  173. }
  174. &-right {
  175. width: 24px;
  176. background: #3d3d3d;
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. img {
  181. width: 16px;
  182. height: 16px;
  183. }
  184. }
  185. }
  186. }
  187. .warn {
  188. background: red;
  189. }
  190. .word-loop {
  191. white-space: nowrap;
  192. display: inline-block;
  193. animation: 5s loop linear infinite normal;
  194. }
  195. @keyframes loop {
  196. 0% {
  197. transform: translateX(20px);
  198. -webkit-transform: translateX(20px);
  199. }
  200. 100% {
  201. transform: translateX(-100%);
  202. -webkit-transform: translateX(-100%);
  203. }
  204. }
  205. </style>