<template>
  <div class="mod-config">
    <el-form style="display: flex; align-items: center; justify-content: right;" :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-select size="small" v-model="dataForm.equipmentId" clearable filterable placeholder="窑炉名称">
          <el-option
            v-for="item in kilnList"
            :key="item.id"
            :label="item.kilnName"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item>
        <el-date-picker
          size="small"
          v-model="dataForm.time"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item> -->
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      :stripe="true"
      :header-cell-style="{background:'#eef1f6',color:'#606266',height: '56px'}"
      v-loading="dataListLoading"
      style="width: 100%"
    >
      <el-table-column
        type="index"
        header-align="center"
        align="center"
        label="序号"
        width="50"
      >
      </el-table-column>
      <el-table-column
        prop="equipmentName"
        label="窑炉名称"
      >
      </el-table-column>
      <el-table-column
        prop="taskCode"
        label="任务编码"
      >
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="报警时间"
      >
      </el-table-column>
      <!-- <el-table-column
        prop="time"
        label="报警级别"
      > -->
      <!-- </el-table-column> -->
      <el-table-column
        prop="alarmInfo"
        label="报警内容"
      >
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      dataForm: {
        equipmentId: null
      },
      dataList: [],
      options: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      selectionDataList: [],
      kilnList: []
    }
  },
  created () {
    this.getKilnList()
  },
  methods: {
    // 获取窑炉列表
    getKilnList () {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/kilnInfo/page'),
        method: 'post',
        data: this.$http.adornData({
          current: 1,
          size: 999
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.kilnList = data.data.records
          this.getDataList()
        } else {
          this.kilnList = []
        }
      })
    },
    // 获取数据列表
    getDataList () {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/alarmInfo/page'),
        method: 'post',
        data: this.$http.adornData({
          current: this.pageIndex,
          size: this.pageSize,
          type: 0,
          equipmentId: this.dataForm.equipmentId
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.data.records
          this.totalPage = data.data.total
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
      })
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val
      this.getDataList()
    }
  }
}
</script>
