<!--资格申请-添加-->
<template>
  <div class="addPage">
    <div class="addPage_title">
      <p>查看资格</p>
      <p  class="reset-button-one" @click="backPage">返回</p>
    </div>
    <!--基本信息-->
    <div class="info" v-if="form.apply">
      <li><i>申请人：</i><i>{{form.apply.applyUser}}</i></li>
      <li><i>联系方式：</i><i>{{form.apply.phone}}</i></li>
      <li><i>实验地点：</i><i>{{form.apply.location}}</i></li>
      <li><i>使用气体：</i><i>{{form.apply.useGasName}}</i></li>
      <li><i>使用期限：</i><i>{{form.apply.startTime}}-{{form.apply.endTime}}</i></li>
      <li><i>气瓶用途：</i><i>{{form.apply.gasUse}}</i></li>
      <li><i>主要安全措施：</i><i>{{form.apply.safetyPrecautions}}</i></li>
      <li class="look_img" @click="lookFile(form.apply.applyCertificate)"><i>用气申请表：</i><i>查看图片</i></li>
    </div>
    <div class="addPage_b">
      <!--气瓶信息-->
      <div  class="addPage_b_t">
        <!--  leadAuditStatus==0 待审核状态 并且isAdmin是实验室管理员  并且 audit有审核权限   -->
        <div class="check_operate" v-if="form.apply.leadAuditStaus==0 && form.apply.remark!=1  && form.isAdmin">
          <el-input type="textarea" class="apply_tree_b2" v-model="queryParamsCheck.leadAuditCause" placeholder="请输入审核说明"  maxlength="50" />
          <div class="sub_btn">
            <p class="reset-button-one" style="width:150px;margin-right: 30px" @click="handleClick('','','reject')">审核驳回</p>
            <p class="inquire-button-one" style="width:150px;" @click="handleClick('','','pass')">审核通过</p>
          </div>
        </div>
        <!-- 实验中心-->
        <div class="check_operate" v-if="form.apply.leadAuditStaus==1 && form.apply.centerAuditStatus!=2 && form.audit && form.apply.remark!=1">
          <el-input type="textarea" class="apply_tree_b2" v-model="queryParamsCheck2.centerAuditCause" placeholder="请输入审核说明"  maxlength="50" />
          <div class="sub_btn">
            <p class="reset-button-one" style="width:150px;margin-right: 30px" @click="handleClick('','','reject2')">审核驳回</p>
            <p class="inquire-button-one" style="width:150px;" @click="handleClick('','','pass2')">审核通过</p>
          </div>
        </div>

      </div>
      <!--审核记录-->
      <div  class="addPage_b_t">
        <div class="addPage_b_t_title">审核记录</div>
        <el-table border v-loading="loading" :data="form.auditlist" height="300">
          <el-table-column label="审核人" align="left" prop="auditUser"/>
          <el-table-column label="审核时间" align="left" prop="auditTime"></el-table-column>
          <el-table-column label="审核操作" align="left" prop="auditStatus">
            <template slot-scope="scope">
              <p :class="scope.row.auditStatus == 0?'color_warn':(scope.row.auditStatus == 1?'color_14AE10':(scope.row.auditStatus == 2?'color_red':''))">{{scope.row.auditStatus == 0?'待审核':(scope.row.auditStatus == 1?'通过':(scope.row.auditStatus == 2?'驳回':''))}}</p>
            </template>
          </el-table-column>
          <el-table-column label="审核说明" align="left" prop="remark"></el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
<script>

import { getToken } from "@/utils/auth";
import {
  useGasManagecenterCheck,
  useGasManageCheckDetail,
  useGasManagelabCheck
} from '@/api/gasManage3_0/index'
let Base64 = require('js-base64').Base64;
export default {
  name: "addPage",
  props:{
    pageData2:{},
  },
  data() {
    return {
      pageType:1,
      uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      // 设置只能选择当前日期及之后的日期
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
        }
      },
      loading:false,
      form:{
        apply:{
          leadAuditStatus:'',
        },
      },
      dateRange:[],
      laboratoryOptions:[],

      // 查询参数
      queryParams: {
        page: 1,
        pageSize:20,
      },
      // 实验室审核参数
      queryParamsCheck: {
        id: '',

        leadAuditStaus:'',//1通过2驳回
        leadAuditCause:'',//	审核内容
      },
      // 实验室审核参数
      queryParamsCheck2: {
        id: '',
        centerAuditStatus:'',//1通过2驳回
        centerAuditCause:'',//	审核内容
      },

      total:0,
      tableData:[],
    };
  },
  created() {

  },
  methods: {
    handleClick(index,row,doType){
      let _this=this;
      if(doType=='reject'){//实验室驳回
        _this.queryParamsCheck.leadAuditStaus=2;
        if(_this.queryParamsCheck.leadAuditCause){
          _this.checkFun();
        }else{
          this.$message({
            type: 'error',
            message:'请输入审核说明!',
            duration:2000,
          });
        }
      }else if(doType=='pass'){//实验室通过
        _this.queryParamsCheck.leadAuditStaus=1;
        _this.checkFun();
      }else if(doType=='reject2'){//实验中心驳回
        _this.queryParamsCheck2.centerAuditStatus=2;
        if(_this.queryParamsCheck2.centerAuditCause){
          _this.checkFun2();
        }else{
          this.$message({
            type: 'error',
            message:'请输入审核说明!',
            duration:2000,
          });
        }
      }else if(doType=='pass2'){//实验中心通过
        _this.queryParamsCheck2.centerAuditStatus=1;
        _this.checkFun2();
      }
    },
    //审核按钮
    checkFun(){
      let _this=this;
      useGasManagelabCheck(this.queryParamsCheck).then( response => {
        if(response.code==200){
          this.$message({
            type: 'success',
            message:response.message,
            duration:2000,
            onClose:function(){
              _this.backPage();
              _this.loading = false;
            }
          });
        }
      });
    },
    //实验中心审核按钮
    checkFun2(){
      let _this=this;
      useGasManagecenterCheck(this.queryParamsCheck2).then( response => {
        if(response.code==200){
          this.$message({
            type: 'success',
            message:response.message,
            duration:2000,
            onClose:function(){
              _this.backPage();
              _this.loading = false;
            }
          });
        }
      });
    },

    /**查看图片  */
    lookFile(item){
      let visitUrl=window.location.href.split('://')[0]+'://'+this.judgmentNetworkReturnAddress()+'/admin/'+item;
      window.open(localStorage.getItem('filePreviewUrl') + '/onlinePreview?url='+encodeURIComponent(Base64.encode(visitUrl)));
    },
    /* 详情 */
    getInfo(id){
      let _this=this;
      useGasManageCheckDetail({id:id}).then( response => {
        let res=response.data;
        if(response.code==200){
          _this.form=res;
        }
      });

    },
    //返回
    backPage(){
      this.$parent.handleClick('','','back');
      this.$parent.getList();

    },

  },
  mounted() {
    this.queryParamsCheck.id=this.pageData2.id;
    this.queryParamsCheck2.id=this.pageData2.id;
    this.getInfo(this.pageData2.id);
  }

};
</script>

<style scoped lang="scss">
.addPage {
  flex:1;
  display: flex!important;
  flex-direction: column;
  box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  border-radius:10px;
  /*顶部*/
  .addPage_title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E0E0E0;
    padding-top:20px;
    p:nth-child(1){
      flex: 1;
      line-height:60px;
      color: #0045AF;
      font-size:18px;
      margin:0 12px 0 20px;
    }
    p:nth-child(2){
      margin-right:20px;
    }
    p:nth-child(3){
      margin-right:20px;
    }
  }
  /*基本信息*/
  .info{
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: center;
    >li{
      list-style-type: none;
      margin: 20px;
      >i{
        font-style: normal;
      }
      >i:nth-of-type(1){
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #999999;
        line-height: 16px;
      }
      >i:nth-of-type(2){
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #333333;
        line-height: 16px;
      }
    }
    .look_img{
      cursor: pointer;
      >i:nth-of-type(2){
        color: #0183FA;
      }
    }
  }
  .addPage_b{

    /*气瓶信息*/
    .addPage_b_t{
      padding: 0 20px;
      box-sizing: border-box;
      .addPage_b_t_title{
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        color: #333333;
        line-height: 16px;
        margin: 40px 0 30px 0;
      }
    }
    .check_operate{
      text-align: center;
      margin-top: 20px;
      .apply_tree_b2{
        width: 800px;
      }
      .sub_btn{
        display: flex;
        justify-content: center;
        margin: 30px 0;
      }
    }

  }

}
</style>
