Newer
Older
smartwell_front / src / views / dataManage / dataManage.vue
<template>
  <div class="container">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane v-if="hasPerm('/welldata/list')" label="井盖状态监测仪" name="wellcover">
        <list-well-cover-data ref="welldatacomp"/>
      </el-tab-pane>
      <el-tab-pane v-if="hasPerm('/liquiddata/list')" label="液位监测仪" name="liquid">
        <list-liquid-data ref="liquiddatacomp"/>
      </el-tab-pane>
      <el-tab-pane v-if="hasPerm('/gasdata/list')" label="燃气智能终端" name="gas">
        <list-gas-data ref="gasdatacomp"/>
      </el-tab-pane>
      <el-tab-pane v-if="hasPerm('/digdata/list')" label="开挖监测仪" name="dig">
        <list-dig-data ref="digdatacomp"/>
      </el-tab-pane>
      <el-tab-pane v-if="hasPerm('/harmfuldata/list')" label="有害气体监测仪" name="harmful">
        <list-harmful-data ref="harmfuldatacomp"/>
      </el-tab-pane>
      <el-tab-pane v-if="hasPerm('/tempdata/list')" label="温湿度监测仪" name="temp">
        <list-temp-data ref="tempdatacomp"/>
      </el-tab-pane>
      <el-tab-pane v-if="hasPerm('/welllocadata/list')" label="井盖定位监测仪" name="wellloca">
        <list-well-loca-data ref="welllocadatacomp"/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import ListLiquidData from './deviceData/listLiquidData'
import ListWellCoverData from './deviceData/listWellCoverData'
import ListGasData from './deviceData/listGasData'
import ListDigData from './deviceData/listDigData'
import ListHarmfulData from './deviceData/listHarmfulData'
import ListTempData from './deviceData/listTempData'
import ListWellLocaData from './deviceData/listWellLocaData'
export default {
  name: 'DataManage',
  components: { ListWellLocaData, ListTempData, ListHarmfulData, ListDigData, ListGasData, ListLiquidData, ListWellCoverData },
  data() {
    return {
      activeName: 'wellcover'
    }
  },
  mounted() {
    if (window.location.href) {
      var query = window.location.href.split('?')
      var values = query[1].split('&')
      for (var i = 0; i < values.length; i++) {
        var pos = values[i].indexOf('=')
        if (pos === -1) continue
        var paramname = values[i].substring(0, pos)
        var value = values[i].substring(pos + 1)
        if (paramname === 'deviceType') {
          if (value === '1') {
            this.activeName = 'wellcover'
          } else if (value === '2') {
            this.activeName = 'liquid'
          } else if (value === '3') {
            this.activeName = 'harmful'
          } else if (value === '4') {
            this.activeName = 'gas'
          } else if (value === '5') {
            this.activeName = 'temp'
          } else if (value === '6') {
            this.activeName = 'dig'
          } else if (value === '7') {
            this.activeName = 'wellloca'
          }
        }
      }
    }
    if (this.$route.params && this.$route.params.deviceType && this.$route.params.deviceType !== '') {
      if (this.$route.params.deviceTypedeviceType === '1') {
        this.activeName = 'wellcover'
      } else if (this.$route.params.deviceType === '2') {
        this.activeName = 'liquid'
      } else if (this.$route.params.deviceType === '3') {
        this.activeName = 'harmful'
      } else if (this.$route.params.deviceType === '4') {
        this.activeName = 'gas'
      } else if (this.$route.params.deviceType === '5') {
        this.activeName = 'temp'
      } else if (this.$route.params.deviceType === '6') {
        this.activeName = 'dig'
      } else if (this.$route.params.deviceType === '7') {
        this.activeName = 'wellloca'
      }
    }
  },
  methods: {
    handleClick(tab, event) {
      if (tab.name === 'wellcover') {
        this.$refs.welldatacomp.fetchData()
      } else if (tab.name === 'liquid') {
        this.$refs.liquiddatacomp.fetchData()
      } else if (tab.name === 'harmful') {
        this.$refs.harmfuldatacomp.fetchData()
      } else if (tab.name === 'gas') {
        this.$refs.gasdatacomp.fetchData()
      } else if (tab.name === 'temp') {
        this.$refs.tempdatacomp.fetchData()
      } else if (tab.name === 'dig') {
        this.$refs.digdatacomp.fetchData()
      } else if (tab.name === 'wellloca') {
        this.$refs.welllocadatacomp.fetchData()
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .container{
    padding: 5px;
  }
</style>