<template>
  <div class="app-container warningNotice">
    <div class="warningNotice-page" v-if="pageType == 1">
      <div class="title-box">
        <el-form :model="queryParams" class="form-box" ref="queryForm" :inline="true" label-width="80px">
          <el-form-item label="预警类型" prop="deptId" label-width="100px">
            <el-select v-model="queryParams.deptId" clearable placeholder="全部" style="width:150px;">
              <el-option
                v-for="item in selectListA"
                :key="item.key"
                :label="item.value"
                :value="item.key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="预警方式" prop="deptId">
            <el-select v-model="queryParams.deptId" clearable placeholder="全部" style="width:150px;">
              <el-option
                v-for="item in selectListB"
                :key="item.key"
                :label="item.value"
                :value="item.key">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="预警时间" prop="dateRange" style="margin-left:10px;" label-width="70px">
            <el-date-picker
              :clearable="false"
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
            <p class="reset-button-one" @click="resetQuery">重置</p>
          </el-form-item>
          <el-form-item style="float: right;">
            <el-col :span="1.5">
              <p class="inquire-button-one"
                 style="width:100px;"
                 @click="goPage(3)"
              >危险源预警</p>
            </el-col>
          </el-form-item>
          <el-form-item style="float: right;">
            <el-col :span="1.5">
              <p class="inquire-button-one"
                 style="width:100px;"
                 @click="goPage(2)"
              >算法预警</p>
            </el-col>
          </el-form-item>
        </el-form>
      </div>
      <div class="content-box">
        <el-table  border :data="tableList" ref="multipleTable">
          <el-table-column label="预警时间" align="center" prop="checkSchedule" show-overflow-tooltip />
          <el-table-column label="预警类型" align="center" prop="checkSchedule" show-overflow-tooltip width="300"/>
          <el-table-column label="预警内容" align="center" prop="checkSchedule" show-overflow-tooltip width="300"/>
          <el-table-column label="预警方式" align="center" prop="createName" show-overflow-tooltip width="300"/>
          <el-table-column label="实验室" sortable="custom" align="center" prop="createTime" show-overflow-tooltip width="300"/>
          <el-table-column label="操作" align="center" prop="deptName" width="150">
            <template slot-scope="scope">
              <div class="table-button-box">
                <p class="table-button-null"></p>
                <p class="table-button-p">详情</p>
                <p class="table-button-null"></p>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <pagination :page-sizes="[20, 30, 40, 50]"
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
        />
      </div>
    </div>
    <algorithmForewarning v-if="pageType == 2"></algorithmForewarning>
    <sourceOfDangerForewarning v-if="pageType == 3"></sourceOfDangerForewarning>
    <infoPage v-if="pageType == 4"></infoPage>
  </div>
</template>

<script>
  import algorithmForewarning from './algorithmForewarning.vue'
  import sourceOfDangerForewarning from './sourceOfDangerForewarning.vue'
  import infoPage from './infoPage.vue'
  export default {
    name: 'index',
    components: {
      algorithmForewarning,
      sourceOfDangerForewarning,
      infoPage
    },
    data(){
      return{
        pageType:1,
        selectListA:[{key:"1",value:"选项1"}],
        selectListB:[{key:"1",value:"选项2"}],
        queryParams:{},
        dateRange:[],
        tableList:[],
        total:0,
      }
    },
    created(){

    },
    mounted(){

    },
    methods:{
      goPage(type){
        if(type != this.pageType){
          this.$set(this,'pageType',type);
        }
      },
      //获取数据列表
      getList(){
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        if(this.dateRange[0]){
          obj.startTime = this.dateRange[0];
        }else{
          obj.startTime = "";
        }
        if(this.dateRange[1]){
          obj.endTime = this.dateRange[1];
        }else{
          obj.endTime = "";
        }
        checkManageList(obj).then(response => {
          this.total = response.data.total;
          this.tableList = response.data.records;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.$set(this.queryParams,'pageNum',1);
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.$set(this,'dateRange',[]);
        this.$set(this,'queryParams',{
          pageNum:1,
          pageSize:20,
          checkType:2,
          manageStatus:'-1',
          checkTimeSort:0,
          searchValue:"",
          deptId:"",
          isSelf:0,
        });
        this.handleQuery();
      },
    }
  }
</script>

<style scoped lang="scss">
  .warningNotice{
    flex: 1;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    .warningNotice-page{
      flex: 1;
      display: flex !important;
      flex-direction: column;
      overflow: hidden;
      .title-box{
        margin-top:20px;
        border-bottom:1px solid #dedede;
      }
      .content-box{
        padding:20px;
        flex: 1;
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
      }
    }
  }
</style>
