# up chart

This commit is contained in:
xianfuxing 2018-08-23 18:58:58 +08:00
parent ebf2ff9b96
commit 50614aa654
1 changed files with 34 additions and 3 deletions

View File

@ -9,8 +9,16 @@
v-if="flag" v-if="flag"
></screen> ></screen>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="趋势图" name="chart">配置管理</el-tab-pane> <el-tab-pane label="趋势图" name="chart">
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
<chart
:chart-data="lineChartData.total"
>
</chart>
</el-row>
</el-tab-pane>
</el-tabs> </el-tabs>
<el-table <el-table
v-loading="listLoading" v-loading="listLoading"
:data="deviceLogs" :data="deviceLogs"
@ -65,27 +73,50 @@
<script> <script>
import { fetchDeviceList, fetchDeviceLogs } from '@/api/counter' import { fetchDeviceList, fetchDeviceLogs } from '@/api/counter'
import Screen from './components/screen' import Screen from './components/screen'
import Chart from './components/chart'
export default { export default {
name: 'deviceDetail', name: 'deviceDetail',
components: { components: {
Screen Screen,
Chart
}, },
data() { data() {
return { return {
lineChartData: {
total: {
historyData: [],
xAxis: [],
title: 'Trend'
}
},
listLoading: true, listLoading: true,
deviceLogs: [], deviceLogs: [],
activeName: 'screen', activeName: 'screen',
total: 0, total: 0,
lastItem: {}, lastItem: {},
status: 0, status: 0,
showChat: false,
flag: false flag: false
} }
}, },
// watch: {
// activeName(val) {
// if (val === 'chart') {
// this.showChat = true
// }
// }
// },
methods: { methods: {
getDeviceLogs(params) { getDeviceLogs(params) {
fetchDeviceLogs(params).then(response => { fetchDeviceLogs(params).then(response => {
const dateList = []
this.deviceLogs = response.data.results this.deviceLogs = response.data.results
this.deviceLogs.forEach((item, index) => {
this.lineChartData.total.historyData.push(item.mosq_count)
dateList.push(item.calc_time.substr(11))
})
this.total = response.data.count this.total = response.data.count
this.lineChartData.total.xAxis = dateList.reverse()
this.listLoading = false this.listLoading = false
this.lastItem = this.deviceLogs[0] this.lastItem = this.deviceLogs[0]
this.flag = true this.flag = true
@ -111,7 +142,7 @@ export default {
this.getDeviceLogs({ device_id, page }) this.getDeviceLogs({ device_id, page })
}, },
handleTabClick(tab, event) { handleTabClick(tab, event) {
console.log(tab, event) // console.log(tab, event)
} }
}, },
created() { created() {