screenFront/src/views/MicrofactoryDevOnline/index.vue

122 lines
2.7 KiB
Vue
Raw Normal View History

<template>
<div :class="$style['container']">
<div class="header">
<div class="title">
2023-07-14 10:01:06 +00:00
<header2 ref="headerref" :width="'100%'" :height="'120px'" :title="t('messages.微工厂缝纫设备看板')" :titleTip="titleTip"
:typeFun="['time']" :alarmType="[]">
</header2>
</div>
</div>
<div class="content" ref="Acontent">
2023-07-14 10:01:06 +00:00
<div v-for="item in arr" class="ringchart">
<RingChart :data="item"></RingChart>
</div>
2023-07-14 10:01:06 +00:00
</div>
</div>
</template>
<script setup lang='ts'>
import header2 from "@/components/headerBox/header2.vue";
import RingChart from "./components/RingChart.vue";
2023-07-14 10:01:06 +00:00
import { ref,onMounted,onUnmounted } from 'vue'
import {getSewingBoard} from '@/http/device'
2024-07-08 08:23:32 +00:00
import { connectWebsocket, closeWebsocket } from "@/utils/websocket";
import { useI18n } from 'vue-i18n'
2023-07-14 10:01:06 +00:00
let { t } = useI18n();
document.title = t('messages.微工厂缝纫设备看板');
let titleTip = [
2024-07-01 10:04:29 +00:00
// {
// color: "#95A2FF",
// name: t('messages.工作时间'),
// },
// {
// color: "#FA8080",
// name: t('messages.空闲时间'),
// },
];
2023-07-14 10:01:06 +00:00
let timer = null;
let arr = ref([]);
2024-07-08 08:23:32 +00:00
let arr_num = ref([]);
function reqSewingBoard() {
getSewingBoard().then((res:any) => {
if (res.code == 200) {
2024-07-08 08:23:32 +00:00
let nums = []
arr.value = res.data.map(item=>{
2024-07-08 08:23:32 +00:00
nums.push(item.num)
return {
2024-07-08 08:23:32 +00:00
id: item.id,
num: item.num,
status: item.status == 'true'? '在线':'离线',
name: item.name,
label: item.label,
2024-07-08 08:23:32 +00:00
count: item.in4TodayCount,
todayRunTime: item.todayRunTime,
todayWorkTime: item.todayWorkTime,
}
});
2024-07-08 08:23:32 +00:00
arr_num.value = nums;
}
})
2023-07-14 10:01:06 +00:00
}
2024-07-08 08:23:32 +00:00
function getWebsocket(val) {
try {
let data = JSON.parse(val);
//
if (data.type == "mDeviceStatus"&&arr_num.value.includes(data.msg.num)) {
let msg = arr.value.find(item=>item.num == data.msg.num)
msg.status = data.msg.status === 0? '离线':'在线'
}
} catch (err) {
console.log(err, "报错了大哥", console.log(val)
);
}
}
function errWebsocket(val) {
console.log(val);
}
2023-07-14 10:01:06 +00:00
onMounted(()=>{
reqSewingBoard()
2023-07-14 10:01:06 +00:00
timer = setInterval(() => {
reqSewingBoard()
}, 60000);
2024-07-08 08:23:32 +00:00
connectWebsocket(null, null, getWebsocket, errWebsocket);
2023-07-14 10:01:06 +00:00
})
onUnmounted(()=>{
clearInterval(timer);
})
</script>
<style module>
.container {
height: 1080px;
width: 1920px;
color: #20aec5;
background-color: #100c2a;
}
</style>
<style scoped>
.content {
width: 100%;
--header: 120px;
height: calc(1080px - var(--header));
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
.ringchart {
2024-07-08 08:23:32 +00:00
width: 280px;
height: 300px;
}
</style>