You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

490 lines
12 KiB
Vue

2 years ago
<template>
<div class="container">
2 years ago
<div class="title1">监控单元</div>
2 years ago
<div class="centerImg"></div>
<div class="title">监控单元</div>
2 years ago
<div class="tree">
<el-tree
:data="treeData"
accordion
node-key="id"
@node-click="treeClick">
2 years ago
<span slot-scope="{ node, data }" class="custom-tree-node">
<span>{{ node.label }}</span>
</span>
</el-tree>
</div>
2 years ago
<div v-if="show" class="equipmentInfo">
2 years ago
<p>
<span>名称</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitName }}</span>
2 years ago
</p>
<p>
<span>ID</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitId }}</span>
2 years ago
</p>
<p>
<span>状态</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitStatus === '1' ? '正常' : '异常' }}</span>
2 years ago
</p>
<p>
<span>类型</span>
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitTypeName }}</span>
2 years ago
</p>
</div>
2 years ago
<div v-if="show"
:style="'background-image: url('+(MonitorInfo.monitorPic ? MonitorInfo.monitorPic :defaultImg)+');'"
class="img"></div>
2 years ago
<div class="terminal">
<!--el-form :model="form" class="demo-form-inline">
2 years ago
<el-form-item label="传感器名称:">
<el-input v-model="form.data1" placeholder="传感器名称" style="width:calc(100% - 100px)"></el-input>
</el-form-item>
</el-form-->
2 years ago
<div class="terminalList">
2 years ago
<div v-for="(i,k) in controlList" class="item">
2 years ago
<div :style="'background-image: url('+(i.devicePic ? i.devicePic :defaultImg1)+');'" class="icon"></div>
<div class="title">{{ i.deviceName + ' - ' + i.deviceModeFunction.functionName }}</div>
2 years ago
<div class="switch">
<el-button
2 years ago
size="mini"
type="primary"
@click="switchChange(i.deviceModeFunction.functionIdentifier,i.deviceId,i.deviceCode,i.deviceModeFunction.modeFunctionId)">
执行
</el-button>
2 years ago
<!-- <el-switch-->
<!-- v-model="i.deviceType==='1'"-->
<!-- active-color="#1165a1"-->
<!-- inactive-color="#1facf4"-->
<!-- @change="switchChange(i.deviceModeFunction.functionIdentifier,i.deviceId,i.deviceCode,i.deviceModeFunction.modeFunctionId)">-->
<!-- </el-switch>-->
2 years ago
</div>
</div>
</div>
</div>
<div class="right">
<div v-for="i in acquisitionList" class="item">
2 years ago
<div class="iconBg"></div>
<div
class="icon">
<el-image
v-if="i.deviceDataMap[Object.keys(i.deviceDataMap).find(e=> i.deviceDataMap[e].toString().includes('http'))]"
:preview-src-list="[i.deviceDataMap[Object.keys(i.deviceDataMap).find(e=> i.deviceDataMap[e].toString().includes('http'))]]"
:src="i.deviceDataMap[Object.keys(i.deviceDataMap).find(e=> i.deviceDataMap[e].toString().includes('http'))]"
style="width: 100%; height: 100%">
</el-image>
</div>
2 years ago
<div class="rightBg">
<div class="title">{{ i.deviceName }}</div>
<div style="position: absolute;left: 24%;top: 0px;width: 55%;height: 100%;">
<div
v-for="val in Object.keys(i.deviceDataMap).slice(0,6).filter(e=> !(i.deviceDataMap[e].toString().includes('http')))"
2 years ago
:style="'height:'+(Object.keys(i.deviceDataMap).length<4 ? '100%':'50%')" class="infoItem">
<div class="span">{{ val }}:</div>
<div class="spanBg"></div>
<div class="num">{{ i.deviceDataMap[val] }}</div>
</div>
2 years ago
</div>
<div class="btn">
2 years ago
<div class="btnC" style="top: 50%">
<el-button type="primary" @click="toHistory(i.deviceId,i.deviceModeId)"></el-button>
2 years ago
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
2 years ago
import {
treeList,
2 years ago
selectDevicesByMonitorUnitId,
getMonitorById,
publishControlCommand
2 years ago
} from '@/api/board/equipment'
2 years ago
import defaultImg from '@/assets/board/equipment/icon.png'
import defaultImg1 from '@/assets/board/equipment/icon2.png'
2 years ago
2 years ago
let getDeviceInterval = null
2 years ago
export default {
components: {},
2 years ago
data() {
return {
2 years ago
defaultImg,
defaultImg1,
2 years ago
show: false,
monitorUnitId: '',
2 years ago
data1: true,
form: {
2 years ago
data1: ''
2 years ago
},
treeData: [],
controlList: [],
acquisitionList: [],
MonitorInfo: {},
sceneId: 0,
2 years ago
deviceId: ''
2 years ago
}
},
async mounted() {
2 years ago
await this.getData()
2 years ago
this.sceneId = this.$store.getters.sceneId
if (this.$route.query.monitorUnitId) {
2 years ago
this.deviceId = this.$route.query.monitorUnitId
await this.treeClick({id: this.$route.query.monitorUnitId})
2 years ago
}
2 years ago
},
2 years ago
methods: {
async getData() {
await this.getTree()
},
2 years ago
switchChange(functionIdentifier, deviceId, deviceCode, modeFunctionId) {
console.log(this.controlList)
console.log(this.controlList)
this.$confirm('确定执行么?', '提示', {
2 years ago
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
publishControlCommand({
2 years ago
deviceId: deviceId,
modeFunctionId: modeFunctionId,
deviceCode: deviceCode,
type: functionIdentifier,
}).then(e => {
if (e.code === 200) {
this.$message({
type: 'success',
message: '成功!'
});
this.controlList.find(e => e.deviceId === deviceId).deviceType === '1' ? this.controlList.find(e => e.deviceId === deviceId).deviceType = '0' : this.controlList.find(e => e.deviceId === deviceId).deviceType = '1'
2 years ago
} else {
this.$message({
type: 'info',
message: '网络错误'
});
}
})
2 years ago
}).catch(() => {
this.$message({
type: 'info',
message: '取消'
});
});
},
2 years ago
async getTree() {
2 years ago
if (this.$store.getters.sceneId) {
const {data} = await treeList(this.$store.getters.sceneId)
this.treeData = data
}
2 years ago
},
treeClick(e) {
2 years ago
if (!e.children?.length > 0) {
this.monitorUnitId = e.id
this.getDevice(e.id)
2 years ago
this.setMonitorById(e)
2 years ago
this.show = true
2 years ago
if (typeof getDeviceInterval === 'number') {
2 years ago
clearInterval(getDeviceInterval)
}
2 years ago
getDeviceInterval = setInterval(() => {
this.getDevice(this.deviceId)
}, 30 * 1000)
2 years ago
}
},
async getDevice(e) {
const {data} = await selectDevicesByMonitorUnitId(e, this.$store.getters.sceneId)
2 years ago
this.deviceId = e
this.controlList = data.control
this.acquisitionList = data.acquisition
2 years ago
},
2 years ago
async setMonitorById(e) {
const {data} = await getMonitorById(e.id)
this.MonitorInfo = data
2 years ago
},
2 years ago
toHistory(e, i) {
console.log(i)
2 years ago
this.$router.push({path: "/board/senso", query: {id: e, deviceModeId: i}});
}
2 years ago
},
beforeDestroy() {
clearInterval(getDeviceInterval)
2 years ago
}
2 years ago
};
</script>
<style lang="less" scoped>
.title1 {
2 years ago
position: absolute;
top: 12%;
left: 73%;
font-size: 1vw;
color: #00f8ff;
transform: translateX(-50%);
}
2 years ago
.container {
background-image: url("~@/assets/board/equipment/bg.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
width: 100%;
height: calc(100vh);
position: relative;
}
.title {
position: absolute;
top: 12.9%;
left: 6%;
font-size: 0.9vw;
color: #d9dee3;
}
.tree {
position: absolute;
top: 18.9%;
left: 2%;
width: 13%;
height: 78%;
/deep/ .el-tree {
background-color: #0000;
color: #d9dee3;
}
/deep/ .el-tree-node__content:hover {
background-color: #0d5e93;
}
/deep/ .el-tree-node__content {
height: 40px;
border-bottom: 1px solid #fff2;
}
/deep/ .is-current {
background-color: #0d5e93;
}
/deep/ .custom-tree-node {
padding-left: 8px;
}
}
.equipmentInfo {
position: absolute;
top: 11.6%;
left: 17.2%;
width: 16%;
height: 20%;
color: #1684c2;
padding: 2vh 0 0 1vw;
p {
margin: 0;
line-height: 4vh;
font-size: 0.9vw;
}
}
.img {
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
top: 11.5%;
left: 33.7%;
width: 12%;
height: 20.4%;
}
.terminal {
position: absolute;
top: 35.6%;
left: 17.2%;
width: 28%;
height: 61%;
padding-top: 14px;
/deep/ .el-form-item__label {
color: #25bffc !important;
font-weight: normal;
}
/deep/ .el-input__inner {
background-color: #0000;
border-color: #25bffc;
}
.terminalList::-webkit-scrollbar {
width: 0;
}
.terminalList {
position: absolute;
top: 1%;
2 years ago
left: 0%;
width: 100%;
height: 95%;
2 years ago
overflow: auto;
::-webkit-scrollbar {
width: 0;
}
.item {
background-image: url("~@/assets/board/equipment/item.png");
background-repeat: no-repeat;
background-size: 100% 100%;
position: relative;
width: 100%;
height: 7vw;
margin-top: 12px;
.icon {
background-image: url("~@/assets/board/equipment/icon.png");
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
2 years ago
top: 21%;
left: 5.8%;
width: 14.5%;
height: 57%;
2 years ago
}
.title {
position: absolute;
top: 50%;
left: 30%;
transform: translateY(-50%);
font-size: 1vw;
color: #1facf4;
}
.switch {
position: absolute;
top: 50%;
right: 5%;
transform: translateY(-50%);
}
}
}
}
.right::-webkit-scrollbar {
width: 0;
}
.right {
position: absolute;
top: 16%;
left: 48%;
width: 50%;
height: 80%;
overflow: auto;
.item {
position: relative;
width: 100%;
margin-bottom: 12px;
height: 18vh;
padding: 1vh 0;
.iconBg {
background-image: url("~@/assets/board/equipment/iconBg.png");
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
top: 16%;
left: 5%;
width: 16vh;
height: 16vh;
}
.icon {
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
top: calc(16% + 1vh);
left: calc(5% + 0.5vw);
width: 14vh;
height: 14vh;
}
2 years ago
.rightBg {
background-image: url("~@/assets/board/equipment/right.png");
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
top: 16%;
left: calc(10% + 16vh);
width: calc(90% - 16vh);;
height: 16vh;
.title {
position: absolute;
top: 50%;
left: 12%;
color: #1facf4;
transform: translate(-50%, -50%);
font-size: 1vw;
}
.infoItem {
display: inline-block;
position: relative;
width: 6vw;
height: 50%;
2 years ago
.spanBg {
//background-image: url("~@/assets/board/equipment/icon.png");
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
bottom: 55%;
left: 12%;
width: 2vw;
height: 0.8vw;
}
.span {
position: absolute;
bottom: 55%;
left: 12%;
color: #f4f4f4;
font-size: 0.5vw;
}
.num {
position: absolute;
top: 55%;
left: 12%;
color: #f4f4f4;
font-size: 0.5vw;
}
}
.btn {
position: absolute;
top: 0%;
right: 5%;
width: 6vw;
height: 100%;
}
.btnC {
position: absolute;
left: 50%;
2 years ago
transform: translate(-50%, -50%);
2 years ago
}
}
}
}
</style>