<template> <el-dialog :visible.sync="dialogFormVisible" width="1200px" title="历史数据" append-to-body class="lineDialog"> <div style="margin-bottom: 10px"> <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" value-format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始时间" end-placeholder="结束时间" size="small"/> <el-button class="filter-item" type="primary" icon="el-icon-search" size="small" @click="fetchData">搜索</el-button> </div> <div v-loading="loading" style="display: flex" > <ve-line :data="chartData" :settings="chartSettings" :title="title" style="width: 900px"/> <div style="flex: 1"> <el-table :data="chartData.rows" size="mini" height="380px"> <el-table-column label="时间" prop="time" width="150" align="center"/> <el-table-column label="用水量" prop="value" align="center"/> </el-table> </div> </div> <div v-loading="loading1" style="display: flex"> <ve-line :data="chartData1" :settings="chartSettings" :title="title1" style="width: 900px"/> <div style="flex: 1"> <el-table :data="chartData1.rows" size="mini" height="380px" > <el-table-column label="时间" prop="time" width="140" align="center"/> <el-table-column label="总用水量" prop="value" align="center" width="70"/> <el-table-column label="阀门状态" prop="statusName" align="center" width="70"/> </el-table> </div> </div> </el-dialog> </template> <script> import { getDayTime } from '@/utils/dateutils' import { sevenDayData, totalData } from '@/api/device' export default { name: 'WatchSevenDay', data() { this.chartSettings = { labelMap: { 'alarmTimes': '用水量' }, metrics: ['alarmTimes'], dimension: ['date'] } return { loading: true, loading1: true, title: { text: '日用水量' }, title1: { text: '累计用水量' }, timeRange: [], dialogFormVisible: false, // 对话框是否显示 listQuery: { devCode: '', beginTime: '', endTime: '' }, chartData: { columns: ['date', 'alarmTimes'], rows: [] }, chartData1: { columns: ['date', 'alarmTimes'], rows: [] } } }, watch: { timeRange(val) { if (val && val.length > 0) { this.listQuery.beginTime = val[0] this.listQuery.endTime = val[1] } else { this.listQuery.beginTime = '' this.listQuery.endTime = '' } } }, methods: { initDialog: function(dialogFormVisible, row = null) { this.listQuery.devCode = row.devcode this.dialogFormVisible = dialogFormVisible const beginTime = getDayTime(new Date().getTime() - 24 * 7 * 60 * 60 * 1000).Format('yyyy-MM-dd hh:mm:ss') const endTime = new Date().Format('yyyy-MM-dd hh:mm:ss') this.timeRange = [beginTime, endTime] this.fetchData() // 传row }, fetchData() { sevenDayData(this.listQuery).then(response => { this.loading = true this.chartData.rows = response.data this.loading = false }) totalData(this.listQuery).then(response => { this.loading1 = true this.chartData1.rows = response.data this.loading1 = false }) } } } </script> <style> .el-dialog__header { padding: 10px !important; } .el-dialog__body { padding: 10px !important; } .lineDialog .el-table th{ color: white !important; background-color: #488f7d !important; } </style>