DeviceStatusInfo.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!-- components/DeviceStatusInfo.vue -->
  2. <template>
  3. <view class="device-status-info" >
  4. <!-- 运行模式信息 -->
  5. <view class="info-section">
  6. <view class="info-title">运行模式:</view>
  7. <view class="info-content">
  8. <text class="mode-text" :class="modeClass">{{ currentMode }}</text>
  9. </view>
  10. </view>
  11. <!-- 故障信息 -->
  12. <view class="info-section">
  13. <view class="info-title">故障状态:</view>
  14. <view class="info-content">
  15. <text class="fault-text" :class="faultClass">{{ faultInfo }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: "DeviceStatusInfo",
  23. computed: {
  24. bleConnected() {
  25. return this.$store.getters['ble/connected']
  26. },
  27. bleData() {
  28. return this.$store.getters['ble/data']
  29. },
  30. // 当前运行模式
  31. currentMode() {
  32. if (!this.bleData) return '未知';
  33. // 根据 WorkModle_41 二进制值判断模式(与set.vue中逻辑一致)
  34. const workMode = this.bleData.WorkModle_41;
  35. if (workMode !== undefined) {
  36. const workModeBits = workMode.toString();
  37. switch (workModeBits) {
  38. case "100000": // 自动
  39. return '自动';
  40. case "10000": // 手动
  41. return '手动';
  42. case "1000000": // 放平
  43. return '放平';
  44. case "1000000000": // 雨
  45. return '雨';
  46. case "100000000": // 雪
  47. return '雪';
  48. case "10000000000": // 风
  49. return '风';
  50. case "10000000": // 指定
  51. return '指定';
  52. case "11000": // 向东
  53. return '向东';
  54. case "10100": // 向西
  55. return '向西';
  56. default:
  57. return '未知模式';
  58. }
  59. }
  60. return '未知模式';
  61. },
  62. // 故障信息 (按照modbus.js中的逻辑)
  63. faultInfo() {
  64. if (!this.bleData) return '无数据';
  65. // 使用已解析的故障码信息(与modbus.js中逻辑一致)
  66. if (this.bleData.FaultCode_10 !== undefined) {
  67. if (this.bleData.FaultCode_10 === '0') {
  68. return '无故障';
  69. } else {
  70. return this.bleData.FaultCodeDescription || '未知故障';
  71. }
  72. }
  73. return '未知状态';
  74. },
  75. // 获取模式显示样式类
  76. modeClass() {
  77. const mode = this.currentMode;
  78. if (mode === '手动') {
  79. return 'manual-mode';
  80. } else if (mode === '自动') {
  81. return 'auto-mode';
  82. } else if (['放平', '雨', '雪', '风', '指定', '向东', '向西'].includes(mode)) {
  83. return 'other-mode';
  84. }
  85. return 'unknown-mode';
  86. },
  87. // 获取故障显示样式类
  88. faultClass() {
  89. if (this.faultInfo === '无故障') {
  90. return 'no-fault';
  91. } else {
  92. return 'has-fault';
  93. }
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .device-status-info {
  100. background-color: #fff;
  101. border-top: 1px solid #ddd;
  102. padding: 10px 15px;
  103. margin-top: auto;
  104. display: flex;
  105. height: 40px;
  106. justify-content: space-around;
  107. }
  108. .info-section {
  109. display: flex;
  110. margin-bottom: 8px;
  111. &:last-child {
  112. margin-bottom: 0;
  113. }
  114. }
  115. .info-title {
  116. font-size: 14px;
  117. font-weight: bold;
  118. color: #333;
  119. width: 65px;
  120. flex-shrink: 0;
  121. }
  122. .info-content {
  123. flex: 1;
  124. }
  125. .mode-text {
  126. font-size: 14px;
  127. padding: 0px 10px 0px 2px;
  128. border-radius: 4px;
  129. &.manual-mode {
  130. color: #e17055;
  131. }
  132. &.auto-mode {
  133. color: #666;
  134. }
  135. &.other-mode {
  136. color: #666;
  137. }
  138. &.unknown-mode {
  139. color: #666;
  140. }
  141. }
  142. .fault-text {
  143. font-size: 14px;
  144. padding: 0px 10px 0px 2px;
  145. border-radius: 4px;
  146. &.no-fault {
  147. color: #666;
  148. }
  149. &.has-fault {
  150. color: #666;
  151. }
  152. }
  153. </style>