<template> <app-container> <search-area :need-clear="false" :need-search-more="false" type="seperate" size="small" search-more-type="default" @search="fetchData" @clear="clearInput"> <!--一般查询条件--> <search-item> <el-input v-model.trim="listQuery.keywords" size="small" placeholder="请输入关键字" clearable/> </search-item> </search-area> <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="columns"> <el-table-column label="历史数据" align="center" width="140"> <template slot-scope="scope"> <el-button type="text" size="small" @click.stop="goDetail(scope.row)">历史数据</el-button> </template> </el-table-column> </template> </normal-table> </app-container> </template> <script> export default { name: 'EnvironmentPoint', components: { }, data() { return { listQuery: { keywords: '', offset: 1, limit: 20 }, // 筛选条件 columns: [ { text: '名称', value: 'name', align: 'center' }, { text: 'PM2.5', value: 'PM25', align: 'center', width: 100 }, { text: 'PM10', value: 'PM10', align: 'center', width: 100 }, { text: 'SO2', value: 'SO2', align: 'center', width: 100 }, { text: 'NO2', value: 'NO2', align: 'center', width: 100 }, { text: 'CO', value: 'CO', align: 'center', width: 100 }, { text: 'O3', value: 'O3', align: 'center', width: 100 }, { text: '温度', value: 'temperature', align: 'center', width: 100 }, { text: '湿度', value: 'humidity', align: 'center', width: 100 }, { text: '风速', value: 'windSpeed', align: 'center', width: 100 }, { text: '风向', value: 'windDirection', align: 'center', width: 100 }, { text: '时间', value: 'time', align: 'center' } ], // 显示列 timeRange: [], // 时间范围 list: [], // 列表数据 total: 0, // 数据总数 listLoading: true, // 列表加载动画 tableOption: { head: { show: true, // 是否需要标题栏, text: '数据列表' // 标题名称 }, options: { needIndex: false // 是否需要序号列 }, toolsOption: { selectColumns: false, // 是否需要筛选列 refresh: false // 是否需要刷新按钮 } } // 表格属性 } }, created() { this.fetchData() }, methods: { goDetail(row) { this.$router.push({ name: 'EnvironmentData', query: { name: row.name } }) }, fetchData() { this.listLoading = true const that = this setTimeout(function() { that.list = [ { name: '宝水新城监控点', PM25: '23.40', PM10: '25.80', SO2: '0.00', NO2: '3.40', CO: '0.40', O3: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', windDirection: '122.50', time: '05-07 11:15' }, { name: '宝水新城监控点', PM25: '23.40', PM10: '25.80', SO2: '0.00', NO2: '3.40', CO: '0.40', O3: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', windDirection: '122.50', time: '05-07 11:15' }, { name: '宝水新城监控点', PM25: '23.40', PM10: '25.80', SO2: '0.00', NO2: '3.40', CO: '0.40', O3: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', windDirection: '122.50', time: '05-07 11:15' }, { name: '宝水新城监控点', PM25: '23.40', PM10: '25.80', SO2: '0.00', NO2: '3.40', CO: '0.40', O3: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', windDirection: '122.50', time: '05-07 11:15' } ] that.total = 200 that.listLoading = false }, 500) }, // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 changePage(val) { if (val && val.size) { this.listQuery.limit = val.size } if (val && val.page) { this.listQuery.offset = val.page } this.fetchData() }, // 重置后的操作, 若不需要显示重置按钮则不需要写 clearInput() { this.$message.success('clearInput') } } } </script> <style scoped> </style>