<template> <app-container> <normal-table :data="list" :head="tableOption.head" :query="listQuery" :total="total" :columns="columns" :list-loading="listLoading" :options="tableOption.options" :tools-option="tableOption.toolsOption" size="small" @change="changePage"> <template slot="btns"/> <template slot="preColumns"> <el-table-column type="expand"> <template slot-scope="props"> <el-form label-position="left" inline class="table-expand"> <el-form-item label="风速(m/s):"> <span>{{ props.row.windSpeed }}</span> </el-form-item> <el-form-item label="风力(级):"> <span>{{ props.row.windPower }}</span> </el-form-item> <el-form-item label="风向(°):"> <span>{{ props.row.windDirection }}</span> </el-form-item> <el-form-item label="气压(kpa):"> <span>{{ props.row.pressure }}</span> </el-form-item> </el-form> </template> </el-table-column> </template> </normal-table> </app-container> </template> <script> import { getToday } from '@/utils/dateutils' import { getRealData } from '@/api/environment/data' export default { name: 'EnvironmentData', components: { getToday }, data() { return { listQuery: { keywords: '', startTime: '', // 开始时间 endTime: '', // 结束时间 offset: 1, limit: 20 }, // 筛选条件 columns: [ { text: '设备编号', value: 'deviceNo' }, { text: '点位名称', value: 'deviceName' }, { text: 'PM2.5(ug/m³)', value: 'pm25' }, { text: 'PM10(ug/m³)', value: 'pm10' }, { text: 'TSP(ug/m³)', value: 'tsp' }, // { // text: '噪声(db)', // value: 'noise' // }, // { // text: '风速(m/s)', // value: 'windSpeed' // }, // { // text: '风向(°)', // value: 'windDirection' // }, // { // text: '风力(级)', // value: 'windPower' // }, { text: '温度(℃)', value: 'temperature' }, { text: '湿度(%RH)', value: 'humidity' }, // { // text: '气压(kpa)', // value: 'pressure' // }, { text: '更新时间', value: 'ts' } ], // 显示列 timeRange: [], // 时间范围 list: [], // 列表数据 total: 0, // 数据总数 listLoading: true, // 列表加载动画 tableOption: { head: { show: true, // 是否需要标题栏, text: '实时数据' // 标题名称 }, options: { needIndex: false // 是否需要序号列 }, toolsOption: { selectColumns: false, // 是否需要筛选列 refresh: false // 是否需要刷新按钮 } } // 表格属性 } }, created() { this.fetchData() }, methods: { // 获取数据 fetchData() { this.listLoading = true getRealData(this.listQuery).then(res =>{ this.list = res.data.rows this.total = res.data.total this.listLoading = false }) }, // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 changePage(val) { if (val && val.size) { this.listQuery.limit = val.size } if (val && val.page) { this.listQuery.offset = val.page } this.fetchData() } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .table-container{ border-width: 0px !important; } </style> <style rel="stylesheet/scss" lang="scss"> .table-container{ border-width: 0px !important; } .table-expand{ margin-left: 50px; .el-form-item{ margin-bottom: 0px; /*margin-right: 20px;*/ padding:0px 20px; border-right: 1px solid #EBEEF5; font-size: 12px; } .el-form-item__label{ font-size: 12px; color:#909399; } .el-form-item__content{ font-size: 12px; } } </style>