|
|
@@ -0,0 +1,127 @@
|
|
|
+<template>
|
|
|
+ <div class="l-flex--col u-font-size--sm">
|
|
|
+ <div class="c-sibling-item--v u-font-size--sm u-bold">
|
|
|
+ 温度传感器
|
|
|
+ <i
|
|
|
+ v-if="!config"
|
|
|
+ class="el-icon-loading"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-if="config"
|
|
|
+ class="c-sibling-item--v"
|
|
|
+ >
|
|
|
+ <div class="l-flex--row c-sibling-item--v">
|
|
|
+ <div
|
|
|
+ class="c-sibling-item o-button"
|
|
|
+ @click="onTrigger(0)"
|
|
|
+ >
|
|
|
+ 触发{{ temperature[0] }}°C
|
|
|
+ </div>
|
|
|
+ <div class="c-sibling-item far">低于一级预警阈值</div>
|
|
|
+ </div>
|
|
|
+ <div class="l-flex--row c-sibling-item--v">
|
|
|
+ <div
|
|
|
+ class="c-sibling-item o-button"
|
|
|
+ @click="onTrigger(1)"
|
|
|
+ >
|
|
|
+ 触发{{ temperature[1] }}°C
|
|
|
+ </div>
|
|
|
+ <div class="c-sibling-item far">一级预警阈值:{{ config[0] }}°C</div>
|
|
|
+ <div class="c-sibling-item u-color--error dark">发送提示性预警</div>
|
|
|
+ </div>
|
|
|
+ <div class="l-flex--row c-sibling-item--v far">
|
|
|
+ <div
|
|
|
+ class="c-sibling-item o-button"
|
|
|
+ @click="onTrigger(2)"
|
|
|
+ >
|
|
|
+ 触发{{ temperature[2] }}°C
|
|
|
+ </div>
|
|
|
+ <div class="c-sibling-item far">二级预警阈值:{{ config[1] }}°C</div>
|
|
|
+ <div class="c-sibling-item u-color--error dark">发送中级预警,开启风机;低于一级预警阈值后关闭风机</div>
|
|
|
+ </div>
|
|
|
+ <div class="l-flex--row c-sibling-item--v far">
|
|
|
+ <div
|
|
|
+ class="c-sibling-item o-button"
|
|
|
+ @click="onTrigger(3)"
|
|
|
+ >
|
|
|
+ 触发{{ temperature[3] }}°C
|
|
|
+ </div>
|
|
|
+ <div class="c-sibling-item far">三级预警阈值:{{ config[2] }}°C</div>
|
|
|
+ <div class="c-sibling-item u-color--error dark">发送紧急预警</div>
|
|
|
+ </div>
|
|
|
+ <div class="l-flex--row c-sibling-item--v far">
|
|
|
+ <div
|
|
|
+ class="c-sibling-item o-button"
|
|
|
+ @click="onTrigger(4)"
|
|
|
+ >
|
|
|
+ 触发{{ temperature[4] }}°C
|
|
|
+ </div>
|
|
|
+ <div class="c-sibling-item far">四级预警阈值:{{ config[3] }}°C</div>
|
|
|
+ <div class="c-sibling-item u-color--error dark">发送紧急预警,关闭大屏电源</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { ThirdPartyDevice } from '@/constant'
|
|
|
+import {
|
|
|
+ TEMPERATURE,
|
|
|
+ getTenantAttributeByBackground
|
|
|
+} from '@/views/realm/settings/api.js'
|
|
|
+import { triggerSensor } from './api'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'AnolgTemperature',
|
|
|
+ props: {
|
|
|
+ deviceId: {
|
|
|
+ type: String,
|
|
|
+ required: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ config: null,
|
|
|
+ temperature: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.getAttribute()
|
|
|
+ this.$timer = -1
|
|
|
+ },
|
|
|
+ beforeDestroy () {
|
|
|
+ this.$timer = -1
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getAttribute () {
|
|
|
+ getTenantAttributeByBackground(TEMPERATURE).then(
|
|
|
+ ({ data }) => {
|
|
|
+ if (data) {
|
|
|
+ this.config = data.attributeValue.split(',').map(Number)
|
|
|
+ this.temperature = [
|
|
|
+ Number((this.config[0] - Math.random() * 5).toFixed(1)),
|
|
|
+ Number((this.config[0] + ((this.config[1] - this.config[0]) * Math.random())).toFixed(1)),
|
|
|
+ Number((this.config[1] + ((this.config[2] - this.config[1]) * Math.random())).toFixed(1)),
|
|
|
+ Number((this.config[2] + ((this.config[3] - this.config[2]) * Math.random())).toFixed(1)),
|
|
|
+ Number((this.config[3] - Math.random() * 5).toFixed(1))
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ if (this.$timer !== -1) {
|
|
|
+ this.getAttribute()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ onTrigger (level) {
|
|
|
+ triggerSensor({
|
|
|
+ deviceId: this.deviceId,
|
|
|
+ type: ThirdPartyDevice.TEMPERATURE_SENSOR,
|
|
|
+ sensorValue: this.temperature[level]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|