plantScreen/src/components/detail/centerBottom.vue
2023-12-24 21:56:23 +08:00

142 lines
3.4 KiB
Vue

<template>
<div class="bottom-li" :class="(item.flag) ? '' : 'act'" v-for="(item, index) in environmentData">
<span class="color-font">{{ item.name }}</span>
<span>{{ item.value }}{{ item.unit }}</span>
<span v-if="item.flag">状态正常</span>
<span v-else>状态正常</span>
</div>
</template>
<script setup>
import { monitorInfoApi } from "@/api.js"
import {ref,reactive} from "vue"
const props = defineProps({
data:Object,
})
const statusFn=(min,max,item )=>{
if(item.value>=min&&item.value<=max ) item.flag=true
else item.flag=false
}
monitorInfoApi(
{
...props.data
}
).then(res => {
for (let key in res.data.monitorThreshold){
monitorThreshold[key]=res.data.monitorThreshold[key]
}
for (let key in environmentData){
environmentData[key].value=res.data.landCollection[key]
}
statusFn(monitorThreshold.wind_speed_min,monitorThreshold.wind_speed_max,environmentData.wind_speed )
// statusFn(monitorThreshold.wind_speed_min,monitorThreshold.wind_speed_max,environmentData.wind_direction )
statusFn(monitorThreshold.air_mois_mix,monitorThreshold.air_mois_max,environmentData.ambient_humidity )
statusFn(monitorThreshold.air_temp_min,monitorThreshold.air_temp_max,environmentData.ambient_temperature )
statusFn(monitorThreshold.air_co2_content_min,monitorThreshold.air_co2_content_max,environmentData.carbon_dioxide )
statusFn(monitorThreshold.ambient_air_pressure_min,monitorThreshold.ambient_air_pressure_max,environmentData.ambient_air_pressure )
// statusFn(monitorThreshold.ambient_air_pressure_min,monitorThreshold.ambient_air_pressure_max,environmentData.rainfall )
// statusFn(monitorThreshold.ambient_air_pressure_min,monitorThreshold.ambient_air_pressure_max,environmentData.ambient_lighting )
})
const environmentData = reactive({
wind_speed: {
name: "风速",
value: 10,
unit: "m/s",
flag: true
},
wind_direction: {
name: "风向",
value: 10,
unit: "",
flag: true
},
ambient_humidity: {
name: "环境湿度",
value: 10,
unit: "%",
flag: true
},
ambient_temperature: {
name: "环境温度",
value: 10,
unit: "℃",
flag: true
},
carbon_dioxide: {
name: "二氧化碳",
value: 10,
unit: "ppm",
flag: true
},
ambient_air_pressure: {
name: "环境气压",
value: 10,
unit: "pa",
flag: true
},
rainfall: {
name: "雨量",
value: 10,
unit: "mm/h",
flag: true
},
ambient_lighting: {
name: "环境光照",
value: 10,
unit: "%",
flag: true
},
}
)
const monitorThreshold=reactive({})
</script>
<style lang="scss">
.bottom-li {
// background-color: #fff;
width: 49%;
height: 4vh;
display: flex;
box-sizing: border-box;
justify-content: space-between;
// border: 1px solid red;
background-image: url('/static/detail/ZC.png');
background-size: 100% 100%;
align-items: center;
font-size: 16px;
color: #E5EFFF;
font-family: FZCYJ;
padding: 0 1VW;
}
.act {
background-image: url('/static/detail/YC.png');
color: #C65956;
}
</style>