消毒机设备
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.

267 lines
6.9 KiB

2 months ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <script lang="ts" setup>
  2. import { syncSendCmd } from 'apis/system'
  3. import homeFinish from 'assets/images/home/home-finish.svg'
  4. import homeSettingSvg from 'assets/images/home/home-setting.svg'
  5. import Config from 'components/home/config.vue'
  6. import HomeFormula from 'components/home/HomeFormula.vue'
  7. import LineChart from 'components/home/LineChart.vue'
  8. import { stopTimer } from 'libs/countdownTimer'
  9. import { deviceStateMap } from 'libs/utils'
  10. import { cloneDeep } from 'lodash'
  11. import { computed, onMounted, onUnmounted, provide, ref, watchEffect } from 'vue'
  12. import { useRouter } from 'vue-router'
  13. import { useFormulaStore } from '@/stores/formulaStore'
  14. import { useHomeStore } from '@/stores/homeStore'
  15. const configRef = ref()
  16. provide<(methods: Home.GrandsonMethods) => void>('registerGrandsonMethods', (methods) => {
  17. configRef.value = methods
  18. })
  19. const router = useRouter()
  20. const formulaStore = useFormulaStore()
  21. const homeStore = useHomeStore()
  22. const formulaInfo = ref()
  23. const disinfectionState = ref(homeStore.disinfectionState)
  24. const curStateRemainTime = ref(homeStore.curStateRemainTime)
  25. const disinfectFormulaVisible = ref(false)
  26. const isDeviceIdle = ref(homeStore.isDeviceIdle)
  27. const loading = ref(false)
  28. watchEffect(() => {
  29. formulaInfo.value = formulaStore.currentSelectedFormulaInfo
  30. disinfectionState.value = homeStore.disinfectionState
  31. curStateRemainTime.value = homeStore.curStateRemainTime
  32. isDeviceIdle.value = homeStore.isDeviceIdle
  33. })
  34. const onDisinfectConfig = () => {
  35. disinfectFormulaVisible.value = true
  36. }
  37. // 结束消毒
  38. const onFinishDisinfect = async () => {
  39. stopTimer()
  40. const stopParams = {
  41. className: 'DisinfectionCtrlServiceExt',
  42. fnName: 'stop',
  43. params: {
  44. loglevel: formulaStore.loglevel,
  45. },
  46. }
  47. loading.value = true
  48. syncSendCmd(stopParams).then((res) => {
  49. if (res.ackcode === 0) {
  50. loading.value = false
  51. }
  52. })
  53. }
  54. const onSave = () => {
  55. const formData = configRef.value?.getFormData()
  56. formulaStore.updateSelectedFormula(cloneDeep(formData))
  57. onClose()
  58. }
  59. const goHome = () => {
  60. router.push('/home')
  61. }
  62. const onClose = () => {
  63. disinfectFormulaVisible.value = false
  64. }
  65. const chartList = ref<any[]>([])
  66. const operationState = computed(() => {
  67. return disinfectionState.value.state === 'idle' || disinfectionState.value.state === 'finished'
  68. })
  69. let poll = null
  70. const getData = async (type?: string) => {
  71. const data = await syncSendCmd({
  72. className: 'H2O2SensorMgr',
  73. fnName: 'getH2O2SensorList',
  74. })
  75. const list = data.rely
  76. !type && (chartList.value = list.map(item => ({ ...item, data: [] })))
  77. for (let i = 0; i < list.length; i++) {
  78. const item: any = list[i]
  79. const res = await syncSendCmd({
  80. className: 'H2O2SensorMgr',
  81. fnName: 'getDisinfectionH2O2DataRecordList',
  82. params: {
  83. type: item.type,
  84. id: item.id,
  85. interval: 30,
  86. },
  87. })
  88. item.data = res.rely
  89. }
  90. chartList.value = list
  91. console.log(chartList.value)
  92. }
  93. const chartLoading = ref(false)
  94. onMounted(async () => {
  95. chartLoading.value = true
  96. await getData()
  97. chartLoading.value = false
  98. poll = setInterval(() => {
  99. if (operationState.value) {
  100. clearInterval(poll)
  101. return
  102. }
  103. getData('interval')
  104. }, 1000 * 30)
  105. })
  106. onUnmounted(() => {
  107. clearInterval(poll)
  108. })
  109. </script>
  110. <template>
  111. <main class="main-content">
  112. <div class="line-chart-title">
  113. <div v-if="formulaInfo && formulaInfo.name" class="line-chart-formula">
  114. <HomeFormula style="background: #e0f0ff" />
  115. </div>
  116. <div class="line-chart-set">
  117. <bt-button
  118. v-if="!isDeviceIdle"
  119. button-text="运行参数"
  120. text-size="24px"
  121. border-radius="5px"
  122. height="3.5rem"
  123. text-color="#1989fa"
  124. padding="0.8vw"
  125. @click="onDisinfectConfig"
  126. >
  127. <template #icon>
  128. <img :src="homeSettingSvg" width="15" alt="">
  129. </template>
  130. </bt-button>
  131. </div>
  132. </div>
  133. <div
  134. v-loading="chartLoading"
  135. class="line-chart-content"
  136. :style="{ 'grid-template-columns': `repeat(${chartList.length},1fr)` }"
  137. >
  138. <div v-for="(item, index) in chartList" :key="index">
  139. <LineChart :env-data="item" />
  140. </div>
  141. </div>
  142. <div class="line-chart-bottom">
  143. <div class="home-chart-time">
  144. <div v-if="!homeStore.isDeviceIdle" class="home-remain-time">
  145. <div class="home-chart-label">
  146. <span v-if="disinfectionState.state === 'disinfection'"> 预计剩余时间: </span>
  147. <span v-else> 消毒状态 </span>
  148. </div>
  149. <div v-if="curStateRemainTime" class="home-chart-value">
  150. {{ curStateRemainTime }}
  151. </div>
  152. <div v-else class="home-chart-value">
  153. {{ deviceStateMap[disinfectionState.state] }}
  154. </div>
  155. </div>
  156. </div>
  157. <div class="home-chart-btn">
  158. <bt-button
  159. v-if="!isDeviceIdle"
  160. button-text="结束消毒"
  161. bg-color="#FF6767"
  162. text-color="#FFFFFF"
  163. width="15vw"
  164. height="7vh"
  165. text-size="24px"
  166. border-radius="12px"
  167. @click="onFinishDisinfect"
  168. >
  169. <template #icon>
  170. <img :src="homeFinish" alt="">
  171. </template>
  172. </bt-button>
  173. <bt-button
  174. button-text="返回"
  175. width="10vw"
  176. height="7vh"
  177. text-color="#1989fa"
  178. text-size="24px"
  179. border-radius="12px"
  180. @click="goHome"
  181. />
  182. </div>
  183. </div>
  184. <ft-dialog v-model="disinfectFormulaVisible" title="运行参数" width="80vw" :ok-handle="onSave" @cancel="onClose">
  185. <div>
  186. <Config ref="configRef" />
  187. </div>
  188. </ft-dialog>
  189. </main>
  190. </template>
  191. <style lang="scss" scoped>
  192. .main-content {
  193. overflow: hidden;
  194. background: $gradient-color;
  195. height: $main-container-height;
  196. .line-chart-formula {
  197. width: 40vw;
  198. //background: #E0F0FF;
  199. height: 3.5rem;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. //border: 1px solid #E0F0FF;
  204. border-radius: 10px;
  205. margin-left: 2rem;
  206. }
  207. .line-chart-set {
  208. display: flex;
  209. justify-content: end;
  210. align-items: center;
  211. width: 65vw;
  212. padding-right: 20px;
  213. }
  214. .line-chart-title {
  215. height: 15%;
  216. display: flex;
  217. align-items: center;
  218. }
  219. .line-chart-content {
  220. display: grid;
  221. height: 65%;
  222. }
  223. .line-chart-bottom {
  224. height: 15%;
  225. display: flex;
  226. padding-right: 20px;
  227. .home-chart-btn {
  228. display: flex;
  229. justify-content: end;
  230. width: 65%;
  231. }
  232. .home-chart-time {
  233. width: 35%;
  234. .home-remain-time {
  235. background: #f6fafe;
  236. width: 27vw;
  237. height: 8vh;
  238. border-radius: 12px;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. font-size: 24px;
  243. gap: 10px;
  244. margin-left: 1rem;
  245. .home-chart-value {
  246. color: #2892f3;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. </style>