|
|
@ -1,17 +1,61 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { RouterView } from "vue-router"; |
|
|
|
import { RouterView, useRouter } from "vue-router"; |
|
|
|
import { createWebSocket, sharedWsUrl } from "./services/socket"; |
|
|
|
import { useEquipmentStatusStore } from "@/stores/equipmentStatus"; |
|
|
|
import { onMounted } from "vue"; |
|
|
|
import { onMounted, ref } from "vue"; |
|
|
|
import { getList } from "./services/matrix/manage"; |
|
|
|
import { useSettingStore } from "./stores/setting"; |
|
|
|
import Dialog, { type DialogParam } from "./components/Dialog.vue"; |
|
|
|
|
|
|
|
const equipmentStatusStore = useEquipmentStatusStore(); |
|
|
|
const settingStore = useSettingStore(); |
|
|
|
const router = useRouter(); |
|
|
|
|
|
|
|
const wsClient = createWebSocket(sharedWsUrl); |
|
|
|
wsClient.dataOb.subscribe((data: any) => { |
|
|
|
wsClient.dataOb.subscribe(data => { |
|
|
|
if (data.type === "status") { |
|
|
|
equipmentStatusStore.setEquipmentStatus(data["data"]); |
|
|
|
} else if (data.type === "warn") { |
|
|
|
if (data.data.code === "wash_complete") { |
|
|
|
dialogContent.value = { |
|
|
|
title: "提示", |
|
|
|
desc: "清洗管道已经完成", |
|
|
|
type: "alert", |
|
|
|
}; |
|
|
|
showDialog.value = true; |
|
|
|
} else if (data.data.code === "prefill_complete") { |
|
|
|
dialogContent.value = { |
|
|
|
title: "提示", |
|
|
|
desc: "预充管道已经完成", |
|
|
|
type: "alert", |
|
|
|
}; |
|
|
|
showDialog.value = true; |
|
|
|
} else if (data.data.code === "dehumidify_complete") { |
|
|
|
dialogContent.value = { |
|
|
|
title: "提示", |
|
|
|
desc: "除湿已完成", |
|
|
|
type: "confirm", |
|
|
|
okText: "去喷涂", |
|
|
|
_brand: "dehumidify_complete", |
|
|
|
}; |
|
|
|
showDialog.value = true; |
|
|
|
} else if (data.data.code === "spray_complete") { |
|
|
|
dialogContent.value = { |
|
|
|
title: "提示", |
|
|
|
desc: "喷涂结束,建议回首页清洗管道", |
|
|
|
type: "confirm", |
|
|
|
okText: "去清洗", |
|
|
|
_brand: "spray_complete", |
|
|
|
}; |
|
|
|
showDialog.value = true; |
|
|
|
} else if (data.data.code === "error") { |
|
|
|
dialogContent.value = { |
|
|
|
title: "错误", |
|
|
|
desc: data.data.msg, |
|
|
|
type: "alert", |
|
|
|
}; |
|
|
|
showDialog.value = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
wsClient.connect(); |
|
|
@ -24,9 +68,34 @@ onMounted(() => { |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const dialogContent = ref<DialogParam>({ desc: "描述" }); |
|
|
|
|
|
|
|
const showDialog = ref(false); |
|
|
|
|
|
|
|
function onOk() { |
|
|
|
showDialog.value = false; |
|
|
|
if (dialogContent.value._brand === "dehumidify_complete") { |
|
|
|
router.push("/spray"); |
|
|
|
} else if (dialogContent.value._brand === "spray_complete") { |
|
|
|
router.replace("/home"); |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<RouterView /> |
|
|
|
<van-overlay v-if="showDialog" :show="true"> |
|
|
|
<div class="flex justify-center items-center h-full"> |
|
|
|
<Dialog |
|
|
|
:title="dialogContent.title" |
|
|
|
:desc="dialogContent.desc" |
|
|
|
:type="dialogContent.type" |
|
|
|
:ok-text="dialogContent.okText" |
|
|
|
:cancel-text="dialogContent.cancelText" |
|
|
|
@on-ok="onOk" |
|
|
|
@on-cancel="showDialog = false"></Dialog> |
|
|
|
</div> |
|
|
|
</van-overlay> |
|
|
|
</template> |
|
|
|
<style scoped></style> |
|
|
|
<style lang="scss" scoped></style> |