<!--自查子项管理-->
<template>
  <div class="rectificationReport-listPage">
    <div class="rectificationReport-listPage-page" v-if="pageType == 1">
      <div class="page-top-title-box title-max-box">
        <p class="page-top-title-name-p">检查详情</p>
        <p class="page-top-title-out-p" @click="outButton">返回</p>
      </div>
      <div class="content-box">
        <el-table class="table-box" 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="hazardDescribe" show-overflow-tooltip width="220"/>
          <el-table-column label="实验室" align="center" prop="subRoom" show-overflow-tooltip width="170"/>
          <el-table-column label="检查时间" sortable="custom" 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="整改期限" sortable="custom" align="center" prop="rectifyDeadline" show-overflow-tooltip width="130"/>
          <el-table-column label="整改状态" align="center" prop="rectifyStatus" show-overflow-tooltip width="110">
            <template slot-scope="scope">
              <p :class="scope.row.rectifyStatus==1?'rectifyStatusColorA':(scope.row.rectifyStatus==2||scope.row.rectifyStatus==3?'rectifyStatusColorB':(scope.row.rectifyStatus==4?'rectifyStatusColorC':''))">{{scope.row.rectifyStatus==1?'已完成':(scope.row.rectifyStatus==2?'待整改':(scope.row.rectifyStatus==3?'待复核':(scope.row.rectifyStatus==4?'暂无法整改':'')))}}</p>
            </template>
          </el-table-column>
          <el-table-column label="整改时间" sortable="custom" align="center" prop="rectifyTime" show-overflow-tooltip width="220">
            <template slot-scope="scope">
              <p>{{scope.row.rectifyTime}}<span v-if="scope.row.overdueStatus==1" style="margin-left:10px;color:#EE0606;">已逾期</span></p>
            </template>
          </el-table-column>
          <el-table-column label="审核状态" align="center" prop="examineResult" show-overflow-tooltip width="80">
            <template slot-scope="scope">
              {{scope.row.examineResult == 1?'已通过':(scope.row.examineResult == 2?'已驳回':(scope.row.examineResult == 3?'待审核':''))}}
            </template>
          </el-table-column>
          <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" @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.page"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
        />
      </div>
    </div>
    <infoDialog v-if="infoDialogType" :propsInfoDialogData="propsInfoDialogData"></infoDialog>
    <lookDocumentDataDialog v-if="lookDocumentType" :propsLookDocumentData="propsLookDocumentData"></lookDocumentDataDialog>
  </div>
</template>

<script>
  import { checkHazardList } from '@/apiDemo/safetyCheck/index'
  import infoDialog from '@/views/safetyCheck/components/infoDialog/infoDialog.vue'
  import lookDocumentDataDialog from '@/components/lookDocumentDialog/lookDocumentDataDialog.vue'
  export default {
    name: 'index',
    props:{
      propsListPageData:{},
    },
    components: {
      lookDocumentDataDialog,
      infoDialog
    },
    data(){
      return{
        //子组件数据
        lookDocumentType:false,
        propsLookDocumentData:{},
        infoDialogType:false,
        propsInfoDialogData:{},
        //学院列表
        deptSelectList:[],
        pageType:1,
        queryParams:{
          page:1,
          pageSize:20,
          manageStatus:'-1',
          checkTimeSort:0,
          searchValue:"",
          deptId:""
        },
        dateRange:[],
        tableList:[],
        total:0,
      }
    },
    created(){

    },
    mounted(){
      this.getList();
    },
    methods:{
      //开关详情页面
      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);
          }
        }
      },
      //返回按钮
      outButton(){
        this.$parent.goPage(1);
      },
      //开始检查
      goAddPage(type,id){
        if(this.pageType != type){
          if(type == 1){
            //返回
            this.$set(this,'pageType',type);
          }else if(type == 2){
            //开始检查/编辑
            this.$set(this,'propsAddData',{
              id:id,
              title:'实验室自查',
            });
            this.$set(this,'pageType',type);
          }else if(type == 3){
            //详情
            this.$set(this,'propsInfoData',{id:id});
            this.$set(this,'pageType',type);
          }else if(type == 4){
            //返回并刷新
            this.getList();
            this.$set(this,'pageType',1);
          }
        }
      },
      //时间排序方法
      sortChange(val){
        if(val.prop == 'checkTime'){
          this.$set(this.queryParams,'checkTimeSort',val.order=='ascending'?'1':(val.order=='descending'?'2':"0"));
          this.handleQuery();
        }
      },
      //范围选择
      topLeftClickType(type){
        if(this.queryParams.buttonType != type){
          this.$set(this.queryParams,'buttonType',type);
          this.handleQuery();
        }
      },
      //获取数据列表
      getList(){
        checkHazardList({managerId:this.propsListPageData.id}).then(response => {
          this.total = response.data.total;
          this.tableList = response.data.records;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.$set(this,'dateRange',[]);
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          manageStatus:'-1',
          checkTimeSort:0,
          searchValue:"",
          deptId:""
        });
        this.handleQuery();
      },
    },
  }
</script>

<style scoped lang="scss">
  .rectificationReport-listPage{
    flex: 1;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    .rectificationReport-listPage-page{
      flex: 1;
      display: flex !important;
      flex-direction: column;
      overflow: hidden;
      .title-box{
        border-bottom:1px solid #dedede;
        display: flex;
        p:nth-child(1){
          flex:1;
          font-size:16px;
          margin-left:20px;
          line-height:80px;
          color:#0045AF;
          font-weight:500;
        }
        p:nth-child(2){
          margin:20px 20px 0 0;
        }
      }
      .content-box{
        flex: 1;
        display: flex;
        flex-direction: column;
        padding:20px;
        overflow: hidden;
        .rectifyStatusColorA{
          color:#23B303;
        }
        .rectifyStatusColorB{
          color:#0183FA;
        }
        .rectifyStatusColorC{
          color:#EE0606;
        }
      }
    }
  }
</style>
