<!--暂无法整改隐患-->
<template>
  <div class="cannotListPage">
    <div class="title-box">
      <el-form :model="queryParams" class="form-box" ref="queryForm" :inline="true" label-width="80px">
        <div class="form-button-max-big-box">
          <div class="form-button-big-box" style="margin-left:10px;">
            <div :class="queryParams.hazardType==1?'checkDiv':''" @click="topLeftClickType(1)">
              <p class="text-p">校院巡查</p>
            </div>
            <div :class="queryParams.hazardType==2?'checkDiv':''" @click="topLeftClickType(2)">
              <p class="text-p">实验室自查</p>
            </div>
          </div>
        </div>
        <el-form-item label="关键字" prop="searchValue">
          <el-input
            maxLength="30"
            v-model="queryParams.searchValue"
            placeholder="计划标题/实验室/房间号"
            clearable
            style="width: 200px"
          />
        </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>
        <!--与我相关-->
        <div class="form-button-max-big-box-me">
          <div class="form-button-big-box-me">
            <div :class="queryParams.myRelated==1?'checkDiv-me':''" @click="topRightClickType">
              <p class="text-p-me">与我有关{{correlationNum}}</p>
              <p class="el-icon-check icon-p-me" v-if="queryParams.myRelated==1"></p>
            </div>
          </div>
        </div>
      </el-form>
    </div>
    <div class="content-box">
      <el-table  border :data="tableList" ref="multipleTable" @sort-change="sortChange">
        <el-table-column label="序号" align="center"  type="index" width="60" />
        <el-table-column label="计划标题" align="center" prop="title" show-overflow-tooltip/>
        <el-table-column label="检查类型" align="center" prop="deptName" show-overflow-tooltip width="180">
          <template slot-scope="scope">
            {{scope.row.hazardType == 1?'校院巡查':(scope.row.hazardType == 2?'实验室自查':'')}}
          </template>
        </el-table-column>
        <el-table-column label="实验室" align="center" prop="subRoom" show-overflow-tooltip width="240"/>
        <el-table-column label="检查时间" sortable align="center" prop="checkTime" show-overflow-tooltip width="160"/>
        <el-table-column label="处理人" align="center" prop="rectifyName" show-overflow-tooltip width="90"/>
        <el-table-column label="原因描述" align="center" prop="rectifyMeasure" show-overflow-tooltip width="435"/>
        <el-table-column label="操作" align="center" width="80">
          <template slot-scope="scope">
            <div class="table-button-box">
              <p class="table-button-null"></p>
              <p class="table-button-p" v-hasPermi="['safety:rectifyHazard:query']"
                 @click="addDialogOpen(true,scope.row)">详情</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>
    <infoDialog v-if="infoDialogType" :propsInfoDialogData="propsInfoDialogData"></infoDialog>
  </div>
</template>

<script>
  import { unableRectifyList } from '@/api/safetyCheck/index'
  import infoDialog from '@/views/safetyCheck/components/infoDialog/infoDialog.vue'
  export default {
    name: 'cannotListPage',
    components: {
      infoDialog
    },
    data(){
      return{
        propsInfoDialogData:{},
        infoDialogType:false,
        queryParams:{
          pageNum:1,
          pageSize:20,
          rectifyStatus:4,
          hazardType:1,
          searchValue:"",
          checkTimeOrder:"",
          myRelated:1,
        },
        dateRange:[],
        tableList:[],
        total:0,
        correlationNum:'',
      }
    },
    created(){},
    mounted(){
      this.getList();
    },
    methods:{
      //获取相关数量
      getCorrelationNum(){
        unableRectifyList({
          pageNum:1,
          pageSize:20,
          rectifyStatus:4,
          hazardType:1,
          searchValue:"",
          checkTimeOrder:"",
          myRelated:1,
        }).then(response => {
          this.$set(this,'correlationNum',response.data.total>999?' 999+':(response.data.total<1?'':' '+response.data.total));
        });
      },
      //与我相关按钮
      topRightClickType(){
        this.$set(this.queryParams,'myRelated',this.queryParams.myRelated==1?0:1);
        this.handleQuery();
      },
      //开关详情页面
      addDialogOpen(type,data){
        if(this.infoDialogType != type){
          if(type){
            let obj = {
              id:data.id
            }
            this.$set(this,'propsInfoDialogData',obj);
            this.$set(this,'infoDialogType',type);
          }else{
            this.getList();
            this.$set(this,'infoDialogType',type);
          }
        }
      },
      //范围选择
      topLeftClickType(type){
        if(this.queryParams.hazardType != type){
          this.$set(this.queryParams,'hazardType',type);
          this.handleQuery();
        }
      },
      //时间排序方法
      sortChange(val){
        if(val.prop == 'checkTime'){
          this.$set(this.queryParams,'checkTimeOrder',val.order=='ascending'?'1':(val.order=='descending'?'2':''));
          this.$set(this.queryParams,'zgTimeOrder','');
          this.$set(this.queryParams,'zgTermOrder','');
          this.handleQuery();
        }
      },
      //获取数据列表
      getList(){
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        if(this.dateRange[0]){
          obj.beginTime = this.dateRange[0];
        }else{
          obj.beginTime = "";
        }
        if(this.dateRange[1]){
          obj.endTime = this.dateRange[1];
        }else{
          obj.endTime = "";
        }
        this.getCorrelationNum();
        unableRectifyList(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,
          rectifyStatus:4,
          hazardType:1,
          searchValue:"",
          checkTimeOrder:"",
          myRelated:1,
        });
        this.handleQuery();
      },
    },
  }
</script>

<style scoped lang="scss">
  .cannotListPage{
    flex: 1;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    .title-box{
      padding-top:20px;
      .form-button-max-big-box{
        display: inline-block;
        .form-button-big-box{
          display: flex;
          div{
            position: relative;
            height:40px;
            width:100px;
            line-height: 40px;
            text-align: center;
            color:#0045AF;
            font-size:14px;
            border:1px solid #0045AF;
            border-radius:4px;
            margin-left:10px;
            font-weight:500;
            cursor: pointer;
          }
          .checkDiv{
            color:#fff;
            background-color:#0045AF;
            border:1px solid #0045AF;
          }
        }
      }
      .form-button-max-big-box-me{
        display: inline-block;
        .form-button-big-box-me{
          display: flex;
          div{
            position: relative;
            height:40px;
            width:130px;
            line-height: 40px;
            text-align: center;
            color:#999;
            font-size:14px;
            border:1px solid #999;
            border-radius:4px;
            margin-left:10px;
            font-weight:500;
            cursor: pointer;
            .icon-p-me{
              width:15px;
              height:15px;
              line-height:15px;
              text-align: center;
              position: absolute;
              right:0;
              bottom:0;
              color:#fff;
              background: #0183fa;
              border-top-left-radius:4px;
            }
          }
          .checkDiv-me{
            color:#0183FA!important;
            border:1px solid #0183FA!important;
          }
        }
      }
    }
    .content-box{
      flex: 1;
      display: flex;
      flex-direction: column;
      padding:0 20px 20px;
      overflow: hidden;
    }
  }
</style>
