<!--未提交检查列表-->
<template>
  <div class="unsubmittedPageList">
    <div class="unsubmittedPageList-page" v-if="pageType == 1">
      <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true" v-show="showSearch">
        <el-form-item label="关键字" prop="searchValue" label-width="70px">
          <el-input
            style="width:230px;"
            v-model="queryParams.searchValue"
            placeholder="请输入实验室/负责人/检查单号"
            clearable
            size="small"
            maxLength="20"
          />
        </el-form-item>
        <el-form-item label="整改类型" prop="zgType" label-width="80px">
          <el-select v-model="queryParams.zgType" placeholder="请选择整改类型" clearable size="small">
            <el-option label="一般整改" value="0" />
            <el-option label="重大整改" value="1" />
          </el-select>
        </el-form-item>
        <el-form-item label="检查时间" label-width="80px">
          <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">查询</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="reset-button-one"
               @click="backPage"
            >返回</p>
          </el-col>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" border :data="checkRecordList">
        <el-table-column label="检查单号" align="left" prop="checkNum" width="200px" show-overflow-tooltip/>
        <el-table-column label="实验室名称" align="left" prop="laboratoryName" show-overflow-tooltip/>
        <el-table-column label="实验楼" align="left" prop="buildingName" width="200px" show-overflow-tooltip/>
        <el-table-column label="房间号" align="left" prop="fjNumber" width="180px"/>
        <el-table-column label="隐患数" align="left" prop="countYh" width="128px">
          <template slot-scope="scope">
            <span style="color:#FF5E5E;">{{scope.row.countYh}}</span>
          </template>
        </el-table-column>
        <el-table-column label="实验室负责人" align="left" prop="fzrName" width="130px" />
        <el-table-column label="负责人联系方式" align="left" prop="fzrLxfs" width="164px" />
        <el-table-column label="检查时间" align="left" prop="createTime" width="200px" />
        <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120" v-if="tableButtonType">
          <template slot-scope="scope">
            <div class="button-box" style="display: flex;margin-left:20px;">
            <p class="table-min-button"
               @click="goPageInfo(2,scope.row)"
               v-hasPermi="['laboratory:checkRecord:query']"
            >查看</p>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <unsubmitted-info v-if="pageType == 2" :infoId="infoId"></unsubmitted-info>
  </div>
</template>

<script>
  import { checkRecord, getCheckRecord, delCheckRecord, addCheckRecord, updateCheckRecord,listJcjl } from "@/api/laboratory/checkRecord";
  import unsubmittedInfo from "./unsubmittedInfo.vue"
  export default {
    name: 'unsubmittedPageList',
    components: {
      unsubmittedInfo
    },
    data() {
      return {
        tableButtonType:this.hasPermiDom(['laboratory:checkRecord:query']),
        //页面状态
        pageType:1,
        // 显示搜索条件
        showSearch: true,
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 安全检查表格数据
        checkRecordList: [],
        //查询时间
        dateRange:[],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize:20,
          isCg:1,
          searchValue: null,
          laboratoryName: null,
          fzrName: null,
          zgType: null,
        },
        infoId:"",
      }
    },
    created() {
    },
    mounted(){
      this.getList();
    },
    methods: {
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.dateRange = [];
        this.queryParams.searchValue = "";
        this.queryParams.beginTime = "";
        this.queryParams.endTime = "";
        this.handleQuery();
      },
      //页面状态切换
      goPageInfo(type,row){
        if(type == 2){
          this.pageType = 2;
          this.infoId = row.id;
        }else if(type == 1){
          this.pageType = 1;
          this.getList();
        }
      },
      //返回
      backPage(){
        this.$parent.goPageInfo(1);
      },
      /** 查询列表 */
      getList() {
        this.loading = true;
        if(this.dateRange&&this.dateRange.length>0){
          this.queryParams.beginTime=this.dateRange[0]
          this.queryParams.endTime=this.dateRange[1]
        }else{
          this.queryParams.beginTime=null;
          this.queryParams.endTime=null
        }
        // checkRecord(this.queryParams).then( response => {
        listJcjl(this.queryParams).then( response => {
          this.checkRecordList =  response.rows;
          this.total =  response.total;
          this.loading = false;
        });
      },
    }
  }
</script>

<style scoped lang="scss">
  .unsubmittedPageList{
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .unsubmittedPageList-page{
      flex:1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      padding:0 20px 20px;
    }
  }
</style>
