You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
5.6 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <script setup lang="ts">
  2. import { getDeviceStatus } from 'apis/system'
  3. import FtStream from 'components/common/FTStream/index.vue'
  4. import Check from 'components/home/Check/index.vue'
  5. import Stop from 'components/home/stop/index.vue'
  6. import { ElMessageBox } from 'element-plus'
  7. import { isClose, socket } from 'libs/socket'
  8. import { sendControl } from 'libs/utils'
  9. import { useSystemStore } from 'stores/useSystemStore' // 引入 systemStore
  10. import { computed, ref } from 'vue'
  11. import { useRoute, useRouter } from 'vue-router'
  12. const route = useRoute()
  13. const router = useRouter()
  14. const systemStore = useSystemStore() // 使用 systemStore
  15. const checkVisible = ref(false)
  16. getDeviceStatus().then((res: any) => {
  17. systemStore.updateSystemStatus(res)
  18. if (!systemStore.systemStatus.selfTestCompleted) {
  19. ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
  20. type: 'warning',
  21. confirmButtonText: '确定',
  22. showCancelButton: false,
  23. showClose: false,
  24. closeOnClickModal: false,
  25. closeOnPressEscape: false,
  26. closeOnHashChange: false,
  27. }).then(() => {
  28. checkVisible.value = true
  29. })
  30. }
  31. })
  32. const ok = () => {
  33. checkVisible.value = false
  34. }
  35. const statusMessage = (data: any) => {
  36. // 更新 systemStore 的 systemStatus
  37. console.log(data)
  38. systemStore.updateSystemStatus(data)
  39. }
  40. const sensorMessage = (data: any) => {
  41. // 更新 systemStore 的 systemInfo
  42. systemStore.updateSystemSensor(data)
  43. }
  44. socket.init(statusMessage, 'device_status_change')
  45. socket.init(sensorMessage, 'sensor')
  46. socket.init(() => {}, 'pong')
  47. const ingObj = {
  48. idle: '空闲',
  49. spraying: '正在喷涂中',
  50. paused: '喷涂暂停中',
  51. cleaningSyringePipeline: '正在清洗注射器管路',
  52. cleaningNozzlePipeline: '正在清洗喷嘴管路',
  53. prefilling: '正在预充中',
  54. dehumidifierRunning: '正在除湿中',
  55. stopPressed: '急停中',
  56. }
  57. const status = computed(() => {
  58. const keys = Object.keys(systemStore.systemStatus).filter((key) => {
  59. return !['paused', 'suspendable', 'selfTestCompleted'].includes(key)
  60. })
  61. let str = ''
  62. keys.forEach((key) => {
  63. if (systemStore.systemStatus[key as keyof typeof systemStore.systemStatus]) {
  64. str += `${ingObj[key as keyof typeof ingObj]} | `
  65. }
  66. })
  67. if (str === '') {
  68. return '空闲'
  69. }
  70. else {
  71. return str.slice(0, -2)
  72. }
  73. })
  74. const logoClickCount = ref(0)
  75. let clickTimeout: NodeJS.Timeout | null = null
  76. const handleLogoClick = () => {
  77. if (clickTimeout) {
  78. clearTimeout(clickTimeout)
  79. }
  80. logoClickCount.value++
  81. if (logoClickCount.value === 10) {
  82. systemStore.updateDebug()
  83. logoClickCount.value = 0 // 重置计数器
  84. }
  85. clickTimeout = setTimeout(() => {
  86. logoClickCount.value = 0 // 重置计数器
  87. }, 1000)
  88. }
  89. const slideTrayIn = async () => {
  90. const params = {
  91. cmdCode: 'slide_tray_in',
  92. cmdId: '',
  93. }
  94. await sendControl(params)
  95. }
  96. const slideTrayOut = async () => {
  97. const params = {
  98. cmdCode: 'slide_tray_out',
  99. cmdId: '',
  100. }
  101. await sendControl(params)
  102. }
  103. </script>
  104. <template>
  105. <el-container>
  106. <el-header>
  107. <div class="logo" @click="handleLogoClick">
  108. <div style="display: flex;align-items: center">
  109. <img src="@/assets/images/logo.svg" alt="">
  110. </div>
  111. <div v-if="route.path !== '/'">
  112. <el-divider direction="vertical" />
  113. <span class="router-name">{{ route.meta.tagName }}</span>
  114. </div>
  115. </div>
  116. <div style="display: flex">
  117. <img v-show="!isClose" class="wifi-icon" src="../../assets/images/icon_wifi.svg" alt="">
  118. <img v-show="isClose" class="wifi-icon" src="../../assets/images/icon_wifi_red.svg" alt="">
  119. <ft-button v-if="systemStore.isDebug" @click="router.push('/debug')">
  120. 调试
  121. </ft-button>
  122. <ft-button v-if="route.path !== '/'" @click="router.push('/')">
  123. 返回
  124. </ft-button>
  125. </div>
  126. </el-header>
  127. <el-main>
  128. <router-view v-slot="{ Component }" class="main-container">
  129. <Transition mode="out-in">
  130. <component :is="Component" :key="route.fullPath" />
  131. </Transition>
  132. </router-view>
  133. </el-main>
  134. <el-footer>
  135. <div>
  136. <ft-button type="info">
  137. 当前湿度: {{ systemStore.systemSensor.humidity }}%RH
  138. </ft-button>
  139. <ft-button type="info">
  140. 设备状态: {{ status }}
  141. </ft-button>
  142. </div>
  143. <div>
  144. <ft-button :click-handle="slideTrayIn">
  145. 推入托盘
  146. </ft-button>
  147. <ft-button :click-handle="slideTrayOut">
  148. 推出托盘
  149. </ft-button>
  150. </div>
  151. </el-footer>
  152. <FtStream :visible="systemStore.streamVisible" />
  153. <Stop v-if="systemStore.systemStatus.stopPressed" />
  154. <Check v-if="checkVisible" @ok="ok" @cancel="checkVisible = false" />
  155. </el-container>
  156. </template>
  157. <style scoped lang="scss">
  158. .el-container {
  159. background: #26509C;
  160. overflow: hidden;
  161. .el-header {
  162. height: 120px;
  163. display: flex;
  164. align-items: center;
  165. justify-content: space-between;
  166. padding:0 65px;
  167. .logo {
  168. margin-left: 35px;
  169. display: flex;
  170. img {
  171. width: 250px;
  172. }
  173. }
  174. .el-divider {
  175. margin: 0 60px;
  176. height: 62px;
  177. }
  178. }
  179. .el-main {
  180. padding:0 65px;
  181. .main-container {
  182. width: 100%;
  183. height: 100%;
  184. background: #EEF3FB;
  185. border-radius: 60px;
  186. padding: 60px;
  187. overflow: auto;
  188. }
  189. }
  190. .el-footer {
  191. padding:0 65px;
  192. height: 120px;
  193. display: flex;
  194. justify-content: space-between;
  195. align-items: center;
  196. }
  197. }
  198. .router-name {
  199. font-size: 50px;
  200. color: #fff;
  201. }
  202. .wifi-icon {
  203. width: 50px;
  204. margin: 0 30px;
  205. }
  206. </style>