<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="loading1" style="display: flex"> <div style="flex: 1"> <el-table :data="data" size="mini" height="380px" > <el-table-column label="抄表时间" prop="uptime" width="140" align="center"/> <!--<el-table-column label="日用水量" prop="dayCount" align="center"/>--> <el-table-column label="总用水量" prop="total" align="center"/> <el-table-column label="阀门状态" align="center"> <template slot-scope="scope">{{scope.status=='1'?'开':(scope.status=='0'?'关':'--')}}</template> </el-table-column> </el-table> </div> </div> </el-dialog> </template> <script> import { getDayTime } from '@/utils/dateutils' import { sevenDayData, totalData } from '@/api/device' export default { name: 'WaterHistory', data() { return { loading1: true, timeRange: [], dialogFormVisible: false, // 对话框是否显示 listQuery: { devCode: '', beginTime: '', endTime: '' }, data:[] } }, 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() { this.loading1 = true totalData(this.listQuery).then(response => { this.data = 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>