fix:通风系统对接接口

This commit is contained in:
zhaohy
2024-08-21 14:47:12 +08:00
parent 6cb09f631b
commit 933e4b26a8
7 changed files with 101 additions and 79 deletions

View File

@@ -177,7 +177,7 @@
// 温泉颜色
import sunRed from '../image/airConditioningSystem/sunRed.png';
import sunYellow from '../image/airConditioningSystem/sunYellow.png';
import sunBlue from '../image/airConditioningSystem/sunBlue.png';
import sunGreen from '../image/airConditioningSystem/sunGreen.png';
import singleModel from '../components/singleModel.vue';
import doubleSingleModel from '../components/doubleSingleModel.vue';
@@ -230,7 +230,7 @@
type: '温度',
unit: '℃',
number: 20,
url: sunBlue,
url: sunGreen,
},
{
title: 'D区多功能传感器',

View File

@@ -57,7 +57,7 @@
<script lang="ts" setup>
import sunRed from '../image/airConditioningSystem/sunRed.png';
import sunYellow from '../image/airConditioningSystem/sunYellow.png';
import sunBlue from '../image/airConditioningSystem/sunBlue.png';
import sunGreen from '../image/airConditioningSystem/sunGreen.png';
import electricFan from '../image/airConditioningSystem/electricFan.png';
import setUp from '../image/airConditioningSystem/setUp.png';
@@ -70,7 +70,7 @@
});
const getSunUrl = () => {
if (props.dataSource.number > 0 && props.dataSource.number < 20) {
return sunBlue;
return sunGreen;
} else if (props.dataSource.number >= 20 && props.dataSource.number < 30) {
return sunYellow;
} else {

View File

@@ -17,6 +17,7 @@
class="box-number"
:style="{
left: dataSource.type === '二氧化碳' ? '95px' : '90px',
color: dataSource.fontColor ? dataSource.fontColor : '#0dffa4',
}"
>{{ dataSource.number }}</div
>
@@ -90,7 +91,6 @@
margin-right: 4px;
}
.box-number {
color: #0dffa4;
font-size: 18px;
left: 72%;
top: 45%;

View File

@@ -1,3 +1,11 @@
//传感器位置
export const devicePosition = [
{ styleText: { left: '46.8%', bottom: '74%' } },
{ styleText: { left: '47%', bottom: '62%' } },
{ styleText: { left: '47.2%', bottom: '47%' } },
{ styleText: { left: '47.3%', bottom: '34%' } },
];
// 排风扇
export const devicePosition1 = [
{

View File

@@ -287,6 +287,7 @@
import selectImg from '../image/airConditioningSystem/selectImg.png';
import sunRed from '../image/airConditioningSystem/sunRed.png';
import sunYellow from '../image/airConditioningSystem/sunYellow.png';
import sunGreen from '../image/airConditioningSystem/sunGreen.png';
import boxModel from './components/boxModel.vue';
import singleModel from '../components/singleModel.vue';
@@ -301,7 +302,12 @@
// 全局变量
import { items } from '/@/store/item';
// 定位数据
import { devicePosition1, devicePosition2, devicePosition3 } from './devicePosition';
import {
devicePosition1,
devicePosition2,
devicePosition3,
devicePosition,
} from './devicePosition';
// 父子组件交互 =======================================================================
@@ -433,81 +439,13 @@
});
};
// 温度数组
const sensorData = ref([
{
title: '多功能传感器A',
styleText: { left: '48%', bottom: '64%' },
type: '温度',
unit: '℃',
number: 20,
url: sunRed,
},
{
title: '多功能传感器B',
styleText: { left: '48.2%', bottom: '43%' },
type: '温度',
unit: '℃',
number: 20,
url: sunYellow,
},
]);
const sensorData = ref([]);
// 湿度数组
const humidityData = ref([
{
title: '多功能传感器A',
styleText: { left: '48%', bottom: '64%' },
type: '湿度',
unit: '%',
number: 20,
url: humidity,
},
{
title: '多功能传感器B',
styleText: { left: '48.2%', bottom: '43%' },
type: '湿度',
unit: '%',
number: 20,
url: humidity,
},
]);
const humidityData = ref([]);
// PM2.5数组
const pmData = ref([
{
title: '多功能传感器A',
styleText: { left: '48%', bottom: '64%' },
type: 'pm2.5',
unit: '',
number: 20,
url: PM25,
},
{
title: '多功能传感器B',
styleText: { left: '48.2%', bottom: '43%' },
type: 'pm2.5',
unit: '',
number: 20,
url: PM25,
},
]);
const pmData = ref([]);
// 二氧化碳 浓度
const CO2Data = ref([
{
title: '多功能传感器A',
styleText: { left: '48%', bottom: '64%' },
type: '二氧化碳',
unit: 'CO2e',
number: 20,
url: CO2,
},
{
title: '多功能传感器B',
styleText: { left: '48.2%', bottom: '43%' },
type: '二氧化碳',
unit: 'CO2e',
number: 99,
url: CO2,
},
]);
const CO2Data = ref([]);
// 排风扇
const fanData = ref([]);
// 风幕机
@@ -536,11 +474,85 @@
const tabs2Ref = ref();
// 抽屉tab3组件的引用
const tabs3Ref = ref();
//根据温度获取图片
const getSunUrl = (number: any) => {
if (number > 0 && number < 20) {
return sunGreen;
} else if (number >= 20 && number < 30) {
return sunYellow;
} else {
return sunRed;
}
};
//获取温度颜色
const getColor = (number: any) => {
if (number > 0 && number < 20) {
return '#0dffa4';
} else if (number >= 20 && number < 30) {
return '#f59a23';
} else {
return '#f36163';
}
};
// 获取传感器数据
const getSensorData = () => {
sensorData.value = [];
humidityData.value = [];
pmData.value = [];
CO2Data.value = [];
http
.get(ventilating.getSensorData, { projectId: state.projectId, siteId: state.siteId })
.then((res) => {
if (res.msg === 'success') {
res.data.forEach((item: any, index: number) => {
sensorData.value.push({
title: item.deviceInfoName,
styleText: devicePosition[index].styleText,
type: '温度',
unit: item.record.tempUnit,
number: item.record.temp,
url: getSunUrl(item.record.temp),
fontColor: getColor(item.record.temp),
});
humidityData.value.push({
title: item.deviceInfoName,
styleText: devicePosition[index].styleText,
type: '湿度',
unit: item.record.humidityUnit,
number: item.record.humidity,
url: humidity,
});
pmData.value.push({
title: item.deviceInfoName,
styleText: devicePosition[index].styleText,
type: 'pm2.5',
unit: item.record.pm2_5Unit,
number: item.record.pm2_5,
url: PM25,
});
CO2Data.value.push({
title: item.deviceInfoName,
styleText: devicePosition[index].styleText,
type: '二氧化碳',
unit: item.record.co_CO2Unit,
number: item.record.co_CO2,
url: CO2,
});
});
}
});
};
//实时获取数据 暂定一分钟
const intervalId = setInterval(getSensorData, 60000);
onMounted(() => {
//获取传感器数据
getSensorData();
// 获得枚举
getStateEnum();
});
onUnmounted(() => {});
onUnmounted(() => {
clearInterval(intervalId);
});
</script>
<style lang="less">
@import url('../style/color.less');