# up 温度

This commit is contained in:
xianfuxing 2019-09-01 13:30:56 +08:00
parent c9d28e4cc8
commit a56751b0b6
4 changed files with 40 additions and 11 deletions

View File

@ -53,3 +53,13 @@ export function fetchLogStatisticHistory(query) {
params: query
})
}
// device temp log statistic api
export function fetchDeviceTempLog(query) {
return request({
url: '/api/mosq/temp/',
method: 'get',
params: query
})
}

View File

@ -94,7 +94,6 @@ export default {
},
showChart(val) {
if (val) {
console.log(val)
this.chart.resize()
}
},
@ -166,7 +165,6 @@ export default {
},
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
console.log(this.chartData)
// this.setOptions(this.chartData)
}
}

View File

@ -25,7 +25,7 @@ export default {
type: Boolean,
default: true
},
chartData: {
HumitureData: {
type: Object
},
showHumiture: {
@ -86,7 +86,7 @@ export default {
this.chart = null
},
watch: {
chartData: {
HumitureData: {
deep: true,
handler(val) {
this.setOptions(val)
@ -94,7 +94,6 @@ export default {
},
showHumiture(val) {
if (val) {
console.log(val)
this.chart.resize()
}
},
@ -102,10 +101,10 @@ export default {
this.screenWidth = val
if (val <= 400) {
this.rotate = 30
this.setOptions(this.chartData)
this.setOptions(this.HumitureData)
} else {
this.rotate = 0
this.setOptions(this.chartData)
this.setOptions(this.HumitureData)
}
}
},
@ -166,8 +165,8 @@ export default {
},
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
console.log(this.chartData)
// this.setOptions(this.chartData)
console.log(this.HumitureData)
// this.setOptions(this.HumitureData)
}
}
}

View File

@ -23,7 +23,7 @@
<el-tab-pane :label="$t('counter.humitureChart')" name="humiture">
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
<humiture
:chart-data="lineChartData.total"
:humiture-data="HumitureData.total"
:showHumiture="showHumiture"
>
</humiture>
@ -67,7 +67,7 @@
</template>
<script>
import { fetchDeviceList, fetchDeviceLogsHistory } from '@/api/counter'
import { fetchDeviceList, fetchDeviceLogsHistory, fetchDeviceTempLog } from '@/api/counter'
import Screen from './components/screen'
import Chart from './components/chart'
import Humiture from './components/humiture'
@ -94,6 +94,13 @@ export default {
title: 'Trend'
}
},
HumitureData: {
total: {
historyData: [],
xAxis: [],
title: 'Humiture'
}
},
listLoading: true,
deviceLogs: [],
activeName: 'screen',
@ -129,6 +136,20 @@ export default {
this.listLoading = false
})
},
getDeviceTempLog(params) {
fetchDeviceTempLog(params).then(response => {
const dateList = []
this.deviceTempLogs = response.data.results
this.deviceTempLogs.forEach((item, index) => {
if (index % 2 === 0) {
this.HumitureData.total.historyData.push(item.temperature)
dateList.push(item.last_time.substr(11, 5))
}
})
this.HumitureData.total.xAxis = dateList
console.log(this.HumitureData.total)
})
},
getDevices(params) {
let device_id = params.device_id
fetchDeviceList(params).then(response => {
@ -174,6 +195,7 @@ export default {
created() {
const device_id = this.$store.getters.deviceID
this.getDevices({ device_id })
this.getDeviceTempLog({ device_id, last_day: 1, limit: 30 })
}
}
</script>