|
|
@ -7,95 +7,22 @@ |
|
|
|
<script lang="ts"> |
|
|
|
import { defineComponent } from 'vue' |
|
|
|
import * as echarts from 'echarts' |
|
|
|
import { getTeamAndHumidity } from 'api/api' |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
name: 'saturate1', |
|
|
|
data() { |
|
|
|
return { |
|
|
|
myCharts: {}, |
|
|
|
temps: [], |
|
|
|
time: null, |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
// 温度 |
|
|
|
tempArray() { |
|
|
|
const { temps } = this |
|
|
|
let arr = [] |
|
|
|
if (temps && temps.length) { |
|
|
|
temps.forEach((item) => { |
|
|
|
arr.push(item.temp) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// arr = [45, 55, 56, 73, 76, 95, 98] |
|
|
|
} |
|
|
|
return arr |
|
|
|
}, |
|
|
|
|
|
|
|
// 时间 |
|
|
|
timeArray() { |
|
|
|
const { temps } = this |
|
|
|
let arr = [] |
|
|
|
if (temps && temps.length) { |
|
|
|
temps.forEach((item) => { |
|
|
|
arr.push(item.time) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// arr = ['10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00'] |
|
|
|
} |
|
|
|
return arr |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
watch: { |
|
|
|
temps: { |
|
|
|
deep: true, |
|
|
|
handler(value) { |
|
|
|
if (value) { |
|
|
|
this.getOptions() |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
mounted() { |
|
|
|
this.getTeamAndHumidity() |
|
|
|
this.time = setInterval(() => { |
|
|
|
// 获取数据 |
|
|
|
this.getTeamAndHumidity() |
|
|
|
}, 60000) |
|
|
|
// 绘制图表 |
|
|
|
this.getOptions() |
|
|
|
}, |
|
|
|
|
|
|
|
unmounted() { |
|
|
|
clearInterval(this.time) |
|
|
|
this.time = null |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
/** 查询温度与湿度 |
|
|
|
* @param {number} endTime 结束时间 |
|
|
|
* @param {number} startTime 开始时间 |
|
|
|
* @param {number} warehouseId 仓库id |
|
|
|
*/ |
|
|
|
async getTeamAndHumidity() { |
|
|
|
try { |
|
|
|
const { parkId, warehouseId } = this.$route.query |
|
|
|
const param = { parkId: parkId || 2, warehouseId: warehouseId || 7 } |
|
|
|
const data = await getTeamAndHumidity(param) |
|
|
|
this.temps = data.temps |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
getOptions() { |
|
|
|
// 绘制图表 |
|
|
|
const { tempArray, timeArray } = this |
|
|
|
|
|
|
|
// 基于准备好的dom,初始化echarts实例 |
|
|
|
let saturate1 = document.getElementById('saturate1') |
|
|
|
saturate1.removeAttribute('_echarts_instance_') |
|
|
|