screenFront/src/views/realtimeSecurity/content/content.vue

213 lines
6.2 KiB
Vue
Raw Normal View History

2023-05-12 08:41:33 +00:00
<template>
2023-06-08 07:58:40 +00:00
<div>
<!-- <div class="topTip">
2023-05-12 08:41:33 +00:00
<toptip ref="toptip1"></toptip>
</div> -->
2023-10-12 09:01:52 +00:00
<div style="display: flex;justify-content: space-between;align-items: center;">
2023-06-08 07:58:40 +00:00
<div
style="width: 20%; height: 250px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-evenly;"
v-for="item in store.newVerticalNum">
<verticalNumLoop @click="gotoTrendChart(item.value, item.unit)" :title="item.title" :icon="item.icon"
:limit="item.limit" :unit="item.unit" :value="item.value"></verticalNumLoop>
</div>
</div>
<div>
<el-row>
<el-col :span="6">
<pressure ref="perssure1" name="east" :title="t('messages.EastPumpPressure_Mpa')"></pressure>
</el-col>
<el-col :span="6">
<pressure ref="perssure2" name="west" :title="t('messages.WestPumpPressure_Mpa')"></pressure>
</el-col>
<el-col :span="12">
<pipe ref="pipe1" :title="t('messages.PipelinePressure_Mpa')"></pipe>
</el-col>
</el-row>
2023-05-12 08:41:33 +00:00
</div>
2023-06-08 07:58:40 +00:00
</div>
2023-05-12 08:41:33 +00:00
</template>
<script setup lang="ts">
2023-06-08 07:58:40 +00:00
import { ElMessage, ElMessageBox } from 'element-plus'
2023-05-12 08:41:33 +00:00
import pressure from "./chart/pressure.vue"
import pipe from "./chart/pipe.vue"
// import toptip from "./chart/toptip.vue"
2023-06-08 07:58:40 +00:00
import { onMounted, reactive, ref, watch } from "vue"
2023-05-12 08:41:33 +00:00
import { calcWH } from "@/components/ts/selfAdaption";
import verticalNumLoop from './chart/verticalNumLoop.vue'
// import { getPressureData,getSafeWarningData } from "@/http/environment";
2023-06-08 07:58:40 +00:00
import { getPressureData, getSafeWarningData, getpipeData } from "@/http/realtimeSecurity";
2023-05-12 08:41:33 +00:00
import { useSocketStore } from "@/store/moduleSocket"
2023-06-08 07:58:40 +00:00
import { useRouter } from "vue-router"
import { gettime, clacendTime } from "@/utils/time"
2023-05-12 08:41:33 +00:00
import { useI18n } from 'vue-i18n'
2023-06-08 07:58:40 +00:00
let { t } = useI18n();
let router = useRouter()
2023-05-12 08:41:33 +00:00
const store = useSocketStore()
2023-06-08 07:58:40 +00:00
let props = defineProps<{
width: number,
height: number,
}>()
watch(() => props, (newVal, oldVal) => {
2023-05-12 08:41:33 +00:00
//监听父组件宽高变化,随时重置本组件尺寸
2023-06-08 07:58:40 +00:00
2023-05-12 08:41:33 +00:00
reset(newVal)
2023-06-08 07:58:40 +00:00
}, { immediate: true, deep: true, flush: 'post' })
2023-05-12 08:41:33 +00:00
// let toptip1=ref()
2023-06-08 07:58:40 +00:00
let perssure1 = ref()
let perssure2 = ref()
let pipe1 = ref()
2023-05-12 08:41:33 +00:00
const verticalType = {
2023-06-08 07:58:40 +00:00
'TVOC': { icon: 'icon-TVOC-Outlined', title: t('messages.TVOCDetection'), unit: 'mg/m³' },
'Smoke': { icon: 'icon-yanwubaojingqi', title: t('messages.smokeDetection'), unit: "ppm" },
'Methane': { icon: 'icon-ranqi', title: t('messages.gasDetection'), unit: null },
'CH2O': { icon: 'icon-app_icons--', title: t('messages.CH2ODetection'), unit: 'mg/m³' },
'FIRE': { icon: 'icon-weibiaoti1', title: t('messages.flameDetection'), unit: null },
2023-05-12 08:41:33 +00:00
}
2023-06-08 07:58:40 +00:00
/**
* 跳转到趋势图
*/
function gotoTrendChart(value, unit) {
let ids = value.map((item) => item.devId).toString();
ElMessageBox.confirm(
'即将跳转到趋势图页面,是否继续?',
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'info',
}
)
.then(() => {
router.push({ path: '/TrendChart', query: { ids: ids, unit: unit } })
})
.catch(() => {
})
2023-05-12 08:41:33 +00:00
2023-06-08 07:58:40 +00:00
}
function reset(val: any) {
2023-05-12 08:41:33 +00:00
//宽高为0时跳出该方法
2023-06-08 07:58:40 +00:00
if (!val.width && !val.height) return
2023-05-12 08:41:33 +00:00
//重置盒子尺寸
2023-06-08 07:58:40 +00:00
PressureBox(val.width, val.height)
pipeBox(val.width, val.height)
verticalNumBox(val.width, val.height)
2023-05-12 08:41:33 +00:00
// toptip1.value.setchartWH()
}
2023-06-08 07:58:40 +00:00
const PressureBox = (width: any, height: any) => {
let a = calcWH(height, width, 3, 4, 0)
2023-05-12 08:41:33 +00:00
//修改高度
2023-06-08 07:58:40 +00:00
perssure1.value.setchartWH(a.oWidth - 50, a.oHeight * 2)
perssure2.value.setchartWH(a.oWidth - 50, a.oHeight * 2)
2023-05-12 08:41:33 +00:00
}
2023-06-08 07:58:40 +00:00
const pipeBox = (width: any, height: any) => {
let a = calcWH(height, width, 3, 2, 0)
2023-05-12 08:41:33 +00:00
//修改高度
2023-05-22 03:44:13 +00:00
// pipe1.value.setchartWH(a.oWidth-50,a.oHeight*2)
2023-06-08 07:58:40 +00:00
pipe1.value.setchartWH(a.oWidth - 50, a.oHeight * 2)
2023-05-12 08:41:33 +00:00
}
2023-06-08 07:58:40 +00:00
const verticalNumBox = (width: any, height: any) => {
let a = calcWH(height, width, 3, 5, 0)
a.oHeight = a.oHeight - 40
2023-05-12 08:41:33 +00:00
}
watch(
() => store.Pressure,
(newVal, oldVal) => {
//动态更新echarts
//泵房气压
2023-06-08 07:58:40 +00:00
perssure1.value.setData(newVal.east, 2)
perssure2.value.setData(newVal.west, 2)
2023-05-12 08:41:33 +00:00
},
{ deep: true, flush: "post" }
);
2023-06-08 07:58:40 +00:00
async function getPressureDatafun() {
let result: any = await getPressureData()
if (result.code == 200) {
perssure1.value.setData(result.data.east, 1)
perssure2.value.setData(result.data.west, 1)
store.changePressure({ east: result.data.east, west: result.data.west })
2023-05-12 08:41:33 +00:00
}
}
2023-06-08 07:58:40 +00:00
let vertical = reactive([])
async function getSafeWarningDatafun() {
let result: any = await getSafeWarningData()
if (result.code == 200) {
let datetime = new Date().getTime();
let handle_vertical = result.data.map((item: any) => {
2023-05-12 08:41:33 +00:00
item.value.forEach(element => {
if (element.name.includes("TVOC")) {
element.name = element.name.split('TVOC')[0] + verticalType[item.type].title
}
2023-06-08 07:58:40 +00:00
if (element.val > item.limit) {
2023-05-12 08:41:33 +00:00
element.date = gettime(element.ts),
2023-06-08 07:58:40 +00:00
element.time = element.ts || datetime
element.continuous = clacendTime(datetime, element.ts || datetime)
2023-05-12 08:41:33 +00:00
} else {
element.date = null
element.time = null
element.continuous = null
}
});
return {
2023-06-08 07:58:40 +00:00
type: item.type,
icon: verticalType[item.type].icon,
title: verticalType[item.type].title,
limit: item.limit,
unit: verticalType[item.type].unit,
value: item.value
2023-05-12 08:41:33 +00:00
}
})
2023-06-08 07:58:40 +00:00
2023-05-12 08:41:33 +00:00
//console.log(result.data,'安全预警----------');
store.setNewVerticalNum(handle_vertical)
}
}
watch(
() => store.pipe,
(newVal, oldVal) => {
//动态更新echarts
//泵房气压
2023-06-08 07:58:40 +00:00
pipe1.value.setData(newVal, 2)
2023-05-12 08:41:33 +00:00
},
{ deep: true, flush: "post" }
);
2023-06-08 07:58:40 +00:00
async function getpipeDatafun() {
let result: any = await getpipeData({})
if (result.code == 200) {
2023-05-12 08:41:33 +00:00
//设置组件样式
2023-06-08 07:58:40 +00:00
pipe1.value.setData({ listData: result.data.listData, top: result.data.top }, 1)
2023-05-12 08:41:33 +00:00
//将数据存入pinia
2023-06-08 07:58:40 +00:00
store.changePipe({ listData: result.data.listData, top: result.data.top })
2023-05-12 08:41:33 +00:00
}
}
2023-06-08 07:58:40 +00:00
onMounted(() => {
2023-05-12 08:41:33 +00:00
getPressureDatafun()
getSafeWarningDatafun()
getpipeDatafun()
})
</script>
<style scoped>
2023-06-08 07:58:40 +00:00
.topTip {
width: 100%;
height: 150px;
}</style>