screenFront/src/views/Mechanics/indexNew.vue

312 lines
8.2 KiB
Vue
Raw Normal View History

2023-06-13 10:07:18 +00:00
<template>
<div :class="$style['container']">
<div class="header">
<div class="title">
2023-06-14 07:52:17 +00:00
<header2 ref="headerref" :width="'100%'" :height="'100px'" :title="t('messages.Mechanics')" :titleTip="[]"
:typeFun="['AbnormalData', 'time']" :alarmType="['machinefactory']">
2023-06-13 10:07:18 +00:00
</header2>
</div>
</div>
<div class="content" ref="Acontent">
<el-row class="layout" :gutter="20">
<el-col :span="7" class="flex-left">
2023-06-14 07:52:17 +00:00
<div style="width: 100%; height: 68%;">
<border13>
<div style="width: 100%;height: 100%;">
<h2 class="module-header">设备总览</h2>
<div class="module-content">
<DevOverview :title="'设备总数'" :value="{ onLine: facTotal.onLine, total: facTotal.total }"></DevOverview>
<DevOverview :title="item.name" :value="{ onLine: item.onLine, total: item.total }"
v-for="(item) in facList"></DevOverview>
</div>
</div>
</border13>
</div>
<div style="width: 100%; height: 28%;">
<border13>
<div style="width: 98%;height: 100%;">
2023-06-15 06:57:40 +00:00
<devStatusTip :title="'设备故障提醒'" :tipList="faultList"
:label='{ name: "设备名称", date: "维修日期", duration: "维修时长" }' :per_view="3"></devStatusTip>
2023-06-14 07:52:17 +00:00
</div>
</border13>
</div>
</el-col>
<el-col :span="10" class="flex-left">
<div style="width: 100%; height: 18%;">
<gateway :title="'物联网关状态'" :data="gatewayData"></gateway>
</div>
<div style="width: 100%; height: 78%;">
<border13>
<scrollBoard :config="scrollBoardConfig"></scrollBoard>
</border13>
</div>
2023-06-13 10:07:18 +00:00
</el-col>
<el-col :span="7" class="flex-left">
<div style="width: 100%; height: 48%;">
<border13>
2023-06-15 06:57:40 +00:00
<ringChart :data="ringData" :total="facTotal.total"></ringChart>
2023-06-13 10:07:18 +00:00
</border13>
2023-06-14 07:52:17 +00:00
</div>
2023-06-13 10:07:18 +00:00
<div style="width: 100%; height: 48%;">
2023-06-14 07:52:17 +00:00
<border13>
<div style="width: 100%;height: 100%;">
2023-06-15 06:57:40 +00:00
<devStatusTip :title="'设备保养提醒'" :tipList="upkeepList"
:label='{ name: "设备名称", date: "保养日期", duration: "保养时长" }' :per_view="5"></devStatusTip>
2023-06-14 07:52:17 +00:00
</div>
</border13>
</div>
2023-06-13 10:07:18 +00:00
</el-col>
</el-row>
</div>
</div>
</template>
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, reactive, ref } from "vue";
import header2 from "@/components/headerBox/header2.vue";
import border13 from '@/components/border/Border13.vue'
import DevOverview from "./components/DevOverview.vue";
import devStatusTip from "./components/devStatusTip.vue";
import ringChart from "./components/ringChart.vue";
import scrollBoard from "./components/scrollBoard.vue";
import gateway from "./components/gateway.vue";
import { connectWebsocket, closeWebsocket } from "@/utils/websocket";
import { ElRow, ElCol } from "element-plus";
import { useMechanicsStore } from "@/store/module/Mechanics";
2023-06-15 06:57:40 +00:00
import { gatewayOfMachineryFactory, gatcountsOfMachineryFactory, reqDeviceTotelListMF, reqDeviceTotelStatusMF, reqDeviceRemind } from "@/http/Mechanics";
2023-06-13 10:07:18 +00:00
import { useI18n } from "vue-i18n";
let { t } = useI18n();
const store = useMechanicsStore();
let Acontent = ref();
let headerref = ref();
2023-06-14 07:52:17 +00:00
let DevOverviewData = ref([])
let devFaultTipData = ref([])
let devStatusTipData = ref([])
let ringData = ref([])
2023-06-13 10:07:18 +00:00
let scrollBoardConfig = reactive({
2023-06-14 07:52:17 +00:00
header: ['序号', '设备名称', '所属车间', '设备状态', '稼动率', '故障率'],
headerBGC: 'rgb(52, 105, 243)',
oddRowBGC: '#100c2a',
evenRowBGC: '#100c2a',
rowNum: 10,
columnWidth: [80, 290, 120, 120, 120, 120],
align: ['center', 'center', 'center', 'center', 'center', 'center'],
data: [],
rawData:[]
2023-06-14 07:52:17 +00:00
})
let gatewayData = ref([])
let devNumTimer: any = null
2023-06-14 07:52:17 +00:00
//车间列表
let facList = ref([])
//机械分厂总数
let facTotal = reactive({
total: 0,
onLine: 0,
offLine: 0
2023-06-13 10:07:18 +00:00
})
function getWebsocket(val) {
headerref.value.HeadergetWebsocket(val);
try {
let data = JSON.parse(val);
if (data.type == "CountsOfMachineryFactoryInStatusTime") {
store.changedevstatus(data.msg);
}
if (data.type == "gatewayMF") {
store.changegateway(data.msg);
2023-06-14 07:52:17 +00:00
gatewayData.value = store.getmechanicsData
2023-06-13 10:07:18 +00:00
store.changegatewaynum(data.msg);
// store.changePM(data.msg)
}
} catch (err) {
console.log(err);
}
}
function errWebsocket(val) {
headerref.value ? headerref.value.HeadererrWebsocket(val) : "";
// console.log(val);
}
2023-06-14 07:52:17 +00:00
//获取机械分厂网关状态
async function gatewayOfMachineryFactoryfun() {
let result: any = await gatewayOfMachineryFactory()
if (result.code == 200) {
store.changegateway(result.data)
gatewayData.value = store.getmechanicsData
2023-06-13 10:07:18 +00:00
}
2023-06-14 07:52:17 +00:00
}
// async function gatcountsOfMachineryFactoryfun() {
// let result: any = await gatcountsOfMachineryFactory()
// if (result.code == 200) {
// store.changegatewaynum(result.data)
// }
// }
//获取机械分厂设备列表
async function reqDeviceTotelListMFfun() {
let result: any = await reqDeviceTotelListMF()
if (result.code == 200) {
2023-06-15 06:57:40 +00:00
let compare = {
H_OFF: '待机',
H_ON: '工作',
H_IDLE: '停机',
H_STOP: '急停',
}
2023-06-14 07:52:17 +00:00
scrollBoardConfig.data = result.data.map((item, index) => {
return [
index + 1,
item.name,
item.dept,
2023-06-15 06:57:40 +00:00
compare[item.status]? compare[item.status] : '停机',
item.activation + '%',
item.failure + '%'
2023-06-14 07:52:17 +00:00
]
})
scrollBoardConfig.rawData = result.data;
2023-06-13 10:07:18 +00:00
}
2023-06-14 07:52:17 +00:00
}
//获取机械分厂设备总数
async function getDeviceTotelStatusMF() {
let result: any = await reqDeviceTotelStatusMF()
if (result.code == 200) {
facList.value = result.data.list
facTotal.total = result.data.total
facTotal.onLine = result.data.list.reduce((total, item) => {
return total + item.onLine
}, 0)
facTotal.offLine = facTotal.total - facTotal.onLine
ringData.value = [
{ name: '在线', value: facTotal.onLine },
{ name: '离线', value: facTotal.offLine }
]
}
}
2023-06-15 06:57:40 +00:00
let faultList = ref([]); //故障列表
let upkeepList = ref([]); //保养列表
//获取设备提醒 保养及故障
async function getDeviceRemind() {
let result: any = await reqDeviceRemind()
if (result.code == 200) {
faultList.value = result.data.fault
upkeepList.value = result.data.upkeep
}
}
2023-06-14 07:52:17 +00:00
2023-06-13 10:07:18 +00:00
onMounted(() => {
// let Timedombox=Timedom.value
window.document.title = t("messages.Mechanics");
devNumTimer = setInterval(() => {
getDeviceTotelStatusMF()
2023-06-15 06:57:40 +00:00
}, 1000 * 60)
2023-06-13 10:07:18 +00:00
gatewayOfMachineryFactoryfun()
2023-06-14 07:52:17 +00:00
// gatcountsOfMachineryFactoryfun()
//获取机械分厂设备总数
getDeviceTotelStatusMF()
//获取机械分厂设备列表
reqDeviceTotelListMFfun()
2023-06-15 06:57:40 +00:00
//获取设备提醒 保养及故障
getDeviceRemind()
2023-06-13 10:07:18 +00:00
connectWebsocket(null, null, getWebsocket, errWebsocket);
});
onUnmounted(() => {
closeWebsocket();
clearInterval(devNumTimer)
2023-06-13 10:07:18 +00:00
});
</script>
<style module>
.container {
height: 1080px;
width: 1920px;
color: #20aec5;
background-color: #100c2a;
}
</style>
<style scoped>
.title {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
2023-06-14 07:52:17 +00:00
.title>h1 {
2023-06-13 10:07:18 +00:00
font-size: 30px;
position: absolute;
top: 10px;
}
2023-06-14 07:52:17 +00:00
2023-06-13 10:07:18 +00:00
.header {
position: relative;
}
2023-06-14 07:52:17 +00:00
2023-06-13 10:07:18 +00:00
.header p {
position: absolute;
right: 50px;
bottom: 20px;
font-size: 20px;
}
2023-06-14 07:52:17 +00:00
.module-header {
width: 100%;
text-align: center;
color: #fff;
font-size: 20px;
margin-bottom: 10px;
2023-06-13 10:07:18 +00:00
}
2023-06-14 07:52:17 +00:00
.module-content {
display: flex;
flex-wrap: wrap;
height: 98%;
width: 100%;
2023-06-13 10:07:18 +00:00
}
2023-06-14 07:52:17 +00:00
.layout {
height: 100%;
2023-06-13 10:07:18 +00:00
}
2023-06-14 07:52:17 +00:00
.flex-left {
2023-06-13 10:07:18 +00:00
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
2023-06-14 07:52:17 +00:00
2023-06-13 10:07:18 +00:00
.content {
width: 100%;
--header: 100px;
height: calc(1080px - var(--header));
}
</style>
<style>
body {
/* --content:calc(100vh - var(--header)) */
overflow: hidden !important;
2023-06-14 07:52:17 +00:00
-ms-overflow-style: none;
/* IE + Edge */
scrollbar-width: none;
/* Firefox */
2023-06-13 10:07:18 +00:00
}
2023-06-14 07:52:17 +00:00
2023-06-13 10:07:18 +00:00
::-webkit-scrollbar {
display: none;
}
</style>