long_IslandOcean/src/views/screen/index.vue

242 lines
5.8 KiB
Vue

<script setup>
import { ref, onMounted } from "vue";
import { getOperatingState, getBigScreen } from "@/api/screen";
const faultAlarmList = ref([]);
const runTimeList = ref([]);
// 楼层控制
const floorList = ref([
{
name: "一层",
},
{
name: "二层",
},
{
name: "三层",
},
]);
const floorIndex = ref(-1);
const emit = defineEmits(["sendVal"]);
// 楼层选择方法
const toggleFloor = (item, index) => {
if (item.name === "一层") {
emit("sendVal", 10);
} else if (item.name === "二层") {
emit("sendVal", 11);
} else if (item.name === "三层") {
emit("sendVal", 12);
}
floorIndex.value = index;
};
//初始化获取故障报警数据
function faultalarm() {
getBigScreen().then((res)=>{
if (res.code == 200) {
faultAlarmList.value = res.data
}else{
return false
}
}).catch((err)=>{
console.log(err);
})
}
//初始化获取运行状态数据
function runningState() {
getOperatingState()
.then((res) => {
if (res.code == 200) {
res.data.forEach((item) => {
if (item.State == "1") {
item.State = true;
} else {
item.State = false;
}
});
runTimeList.value = res.data;
} else {
return false;
}
})
.catch((err) => {
console.log(err);
});
}
onMounted(() => {
//获取报警数据、
faultalarm()
//获取运行状态
runningState();
});
</script>
<template>
<div class="page m100">
<!-- 层级控制 -->
<div class="floor">
<div
v-for="(item, index) in floorList"
:class="index === floorIndex ? 'floor-select' : 'floor-default'"
@click="toggleFloor(item, index)"
>
{{ item.name }}
</div>
</div>
<div class="page-left-box">
<div class="title">
<span>故障报警</span>
</div>
<div
class="page-big-box margin10"
style="display: flex; align-items: center"
>
<div class="alarm">
<div
class="alarmList"
v-for="(item, index) in faultAlarmList"
:key="index"
>
<span class="name">{{ item.Device }}</span>
<div class="content">
<span class="location">地点:{{ item.Place }}</span>
<span class="time">时间:{{ item.time }}</span>
</div>
</div>
</div>
</div>
</div>
<div class="page-right-box">
<div class="title">
<span>运行状态</span>
</div>
<div class="page-big-box margin10">
<div class="runningState">
<div class="tableTitle">
<span>区域名称</span>
<span>状态</span>
</div>
<div class="tableContent">
<div
class="tableBoby"
v-for="(item, index) in runTimeList"
:key="index"
>
<span>{{ item.Name }}</span>
<el-switch v-model="item.State" style="left: 8px" />
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped lang="scss">
.alarm {
width: 100%;
height: 94%;
padding: 0 3%;
box-sizing: border-box;
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
align-content: flex-start;
overflow: auto;
scrollbar-width: none; /* firefox */
-ms-overflow-style: none; /* IE 10+ */
.alarmList {
width: 93.2%;
height: 6.2%;
margin-top: 2.6%;
display: flex;
align-items: center;
justify-content: space-between;
background: url("../../assets/images/overview/alarm.png") no-repeat;
background-size: 100% 100%;
padding: 0 2%;
.content {
display: flex;
flex-direction: column;
.location {
font-size: 16px;
color: rgba(255, 255, 255, 1);
}
.time {
font-size: 12px;
color: rgba(218, 218, 218, 1);
}
}
.name {
font-size: 22px;
font-weight: 700;
color: rgba(91, 250, 241, 1);
position: relative;
margin-left: 14%;
}
}
}
::-webkit-scrollbar {
display: none; /* Chrome Safari */
}
.runningState {
height: 98%;
width: 100%;
padding: 3% 3%;
box-sizing: border-box;
.tableTitle {
background: url("../../assets/images/overview/runTime.png") no-repeat;
background-size: 100% 100%;
width: 100%;
height: 4.5%;
display: flex;
justify-content: space-evenly;
align-items: center;
font-size: 16px;
}
.tableContent {
width: 100%;
height: calc(100% - 4.5%);
overflow: auto;
display: flex;
flex-direction: column;
scrollbar-width: none; /* firefox */
-ms-overflow-style: none; /* IE 10+ */
.tableBoby {
background: url("../../assets/images/overview/runTime.png") no-repeat;
background-size: 100% 100%;
width: 88%;
height: 3.5%;
display: flex;
justify-content: space-around;
align-items: center;
font-size: 14px;
margin-top: 2%;
}
}
::-webkit-scrollbar {
display: none; /* Chrome Safari */
}
}
:deep(.el-switch__core) {
border-radius: 0;
background: transparent;
border: 1px solid rgba(223, 94, 94, 1);
}
:deep(.el-switch.is-checked .el-switch__core) {
background: transparent;
border: 1px solid rgba(80, 233, 83, 1);
}
:deep(.el-switch__core .el-switch__action) {
border-radius: 0;
height: 13px;
width: 13px;
background: rgba(223, 94, 94, 1);
}
:deep(.el-switch.is-checked .el-switch__action) {
border-radius: 0;
height: 13px;
width: 13px;
background: rgba(80, 233, 83, 1);
}
</style>