Newer
Older
smartcity_env_front / src / views / alarmRule / simpleDeviceList.vue
StephanieGitHub on 27 Jul 2021 5 KB MOD:设备管理、报警阈值管理
<template>
  <app-container>
    <search-area :need-clear="true" :need-search-more="false" type="seperate" size="small" search-more-type="default" @search="fetchData" @clear="clearInput" @selection-change="handleSelectionChange">
      <!--一般查询条件-->
      <search-item>
        <el-input v-model.trim="listQuery.keywords" size="small" placeholder="编号/点位名称" clearable/>
      </search-item>
      <search-item>
        <el-input v-model.trim="listQuery.position" 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">
      <template slot="columns">
        <el-table-column label="操作" align="center" width="120">
          <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>
import { getToiletListPage, } from '@/api/environment/device'
export default {
  name: 'SimpleDeviceList',
  data() {
    return {
      listQuery: {
        keywords: '', // 关键字
        online: '', // 在线状态
        position: '', // 位置
        offset: 1,
        limit: 20,
        sort: '',
        order: 'desc'
      }, // 筛选条件
      columns: [
        {
          text: '设备编号',
          value: 'deviceNo',
          align: 'center',
          width: 160
        },
        {
          text: '点位名称',
          value: 'deviceName',
          align: 'center'
        },
        // {
        //   text: '市',
        //   value: 'responsiblePerson',
        //   align: 'center',
        //   width: 80
        // },
        {
          text: '区/县',
          value: 'area',
          align: 'center'
        },
        {
          text: '详细地址',
          value: 'position',
          align: 'center'
        },
        {
          text: '权属单位',
          value: 'deptName',
          align: 'center'
        },
        {
          text: '备注',
          value: 'notes',
          align: 'center'
        },
        {
          text: '安装时间',
          value: 'installDate',
          align: 'center'
        }
      ], // 显示列
      options:[
        {value:'1',name:'在线'},
        {value:'2',name:'离线'}
      ],
      timeRange: [], // 时间范围
      list: [], // 列表数据
      total: 0, // 数据总数
      listLoading: true, // 列表加载动画
      typeList: [],
      fileList: [],
      tableOption: {
        head: {
          show: true, // 是否需要标题栏,
          text: '数据列表' // 标题名称
        },
        options: {
          needIndex: true // 是否需要序号列
        },
        toolsOption: {
          selectColumns: false, // 是否需要筛选列
          refresh: false // 是否需要刷新按钮
        }
      }, // 表格属性
      editShow: false // 编辑页面是否显示
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      // getToiletListPage(this.listQuery).then(response => {
      //   this.list = response.data.rows
        this.list = [
            {id:"1", deviceNo:"2021030803100001", deviceName:"王泥岭", area:'崇仁县', online:'1', deptName:"城管局", areaCode:'361024', lat:27.77740600, lng:116.05673800, notes:"无", position:"王泥岭", ts:"2021-01-12", deptid:'24', installDate:"2021-07-01"},
            {id:"2", deviceNo:"2021030803100002", deviceName:"王泥岭", area:'崇仁县', online:'1', deptName:"城管局", areaCode:'361024', lat:27.77740600, lng:116.05673800, notes:"无", position:"王泥岭", ts:"2021-01-12", deptid:'24', installDate:"2021-07-01"},
            {id:"3", deviceNo:"2021030803100003", deviceName:"王泥岭", area:'崇仁县', online:'1', deptName:"城管局", areaCode:'361024', lat:27.77740600, lng:116.05673800, notes:"无", position:"王泥岭", ts:"2021-01-12", deptid:'24', installDate:"2021-07-01"},
            {id:"4", deviceNo:"2021030803100004", deviceName:"王泥岭", area:'崇仁县', online:'1', deptName:"城管局", areaCode:'361024', lat:27.77740600, lng:116.05673800, notes:"无", position:"王泥岭", ts:"2021-01-12", deptid:'24', installDate:"2021-07-01"},
            {id:"5", deviceNo:"2021030803100005", deviceName:"王泥岭", area:'崇仁县', online:'2', deptName:"城管局", areaCode:'361024', lat:27.77740600, lng:116.05673800, notes:"无", position:"王泥岭", ts:"2021-01-12", deptid:'24', installDate:"2021-07-01"},
            {id:"6", deviceNo:"2021030803100006", deviceName:"王泥岭", area:'崇仁县', online:'2', deptName:"城管局", areaCode:'361024', lat:27.77740600, lng:116.05673800, notes:"无", position:"王泥岭", ts:"2021-01-12", deptid:'24', installDate:"2021-07-01"}
        ]
        // that.total = response.data.total
        this.listLoading = false
      // })
    },
    // 点击详情
    goDetail(row) {
      const params = { deviceNo: row.deviceNo }
      this.$router.push({ name: 'DeviceAlarmRule', query: params })
    },
    // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
    changePage(val) {
      if (val && val.size) {
        this.listQuery.limit = val.size
      }
      if (val && val.page) {
        this.listQuery.offset = val.page
      }
      this.fetchData()
    },
    // 重置后的操作, 若不需要显示重置按钮则不需要写
    clearInput() {
      this.listQuery = {
        keywords: '', // 关键字
        online: '', // 在线状态
        position: '', // 位置
        offset: 1,
        limit: 20,
        sort: '',
        order: 'desc'
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .edit_btns{
    .edit_btn{
      float:right;
      margin-left:5px;
    }
  }
</style>