Newer
Older
smartcity_env_front / src / views / data / allDeviceData.vue
StephanieGitHub on 27 Jul 2021 4 KB MOD:设备管理、报警阈值管理
<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"/>
    </normal-table>
  </app-container>
</template>

<script>
import { getToday } from '@/utils/dateutils'
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',
          value: 'pm25'
        },
        {
          text: 'PM10',
          value: 'pm10'
        },
        {
          text: 'TSP',
          value: 'tsp'
        },
        {
          text: '噪声',
          value: 'noise'
        },
        {
          text: '风速',
          value: 'windSpeed'
        },
        {
          text: '风向',
          value: 'windDirection'
        },
        {
          text: '风力',
          value: 'windPower'
        },
        {
          text: '温度',
          value: 'temperature'
        },
        {
          text: '湿度',
          value: 'humidity'
        },
        {
          text: '气压',
          value: 'pressure'
        },
        {
          text: '时间',
          value: 'ts'
        }
      ], // 显示列
      timeRange: [], // 时间范围
      list: [], // 列表数据
      total: 0, // 数据总数
      listLoading: true, // 列表加载动画
      tableOption: {
        head: {
          show: true, // 是否需要标题栏,
          text: '实时数据' // 标题名称
        },
        options: {
          needIndex: false // 是否需要序号列
        },
        toolsOption: {
          selectColumns: false, // 是否需要筛选列
          refresh: false // 是否需要刷新按钮
        }
      } // 表格属性
    }
  },
  watch: {
    timeRange(val) {
      if (val && val.length > 0) {
        this.listQuery.startTime = val[0]
        this.listQuery.endTime = val[1]
        this.fetchData()
      } else {
        this.listQuery.startTime = ''
        this.listQuery.endTime = ''
      }
    }
  },
  activated() {
    if (this.$route.query) {
      this.listQuery.keywords = this.$route.query.name
    }
  },
  created() {
    if (this.$route.query) {
      this.listQuery.keywords = this.$route.query.name
    }
    this.listQuery.startTime = getToday('yyyy-MM-dd 00:00:00')
    this.listQuery.endTime = getToday('yyyy-MM-dd hh:mm:ss')
    this.timeRange = [this.listQuery.startTime, this.listQuery.endTime]
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      const that = this
      setTimeout(function() {
        that.list = [
          { deviceNo:'1245521111141', deviceName: '宝水新城监控点', pm25: '23.40', pm10: '25.80', tsp: '0.00', noise: '3.40', windPower: '0.40', windDirection: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', pressure: '122.50', ts: '2021-05-07 11:15' },
          { deviceNo:'1245521111141', deviceName: '宝水新城监控点', pm25: '23.40', pm10: '25.80', tsp: '0.00', noise: '3.40', windPower: '0.40', windDirection: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', pressure: '122.50', ts: '2021-05-07 11:15' },
          { deviceNo:'1245521111141', deviceName: '宝水新城监控点', pm25: '23.40', pm10: '25.80', tsp: '0.00', noise: '3.40', windPower: '0.40', windDirection: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', pressure: '122.50', ts: '2021-05-07 11:15' },
          { deviceNo:'1245521111141', deviceName: '宝水新城监控点', pm25: '23.40', pm10: '25.80', tsp: '0.00', noise: '3.40', windPower: '0.40', windDirection: '7.40', temperature: '22.50', humidity: '80.50', windSpeed: '2.50', pressure: '122.50', ts: '2021-05-07 11:15' }
        ]
        that.total = 4
        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>
  .table-container{
    border-width: 0px !important;
  }
</style>