<!--准入申请详情-->
<!--准入审核详情-->
<template>
  <div class="page-container info-page" v-if="pageType">
    <div class="page-top-title-box">
      <p class="page-top-title-name-p">准入信息</p>
      <p class="page-top-title-out-p" @click="backPage">返回</p>
      <p class="page-top-title-save-p" style="width:100px;"
         v-hasPermiRouter="['laboratory:apply:edit']"
         v-if="subjectData.labSecurityApply.auditStatus == 1" @click="backPageEdit()">重新申请</p>
    </div>
    <div class="info-page-box scrollbar-box">
      <div class="admittance_info">
        <li>申请实验室:<i>{{subjectData.labSecurityApply.deptName}}-{{subjectData.labSecurityApply.subName}}</i></li>
        <li>实验室负责人:<i>{{subjectData.fzrSysUser.userName}}</i></li>
        <li>申请时间:<i>{{parseTime(subjectData.labSecurityApply.creatTime,"{y}-{m}-{d} {h}:{i}")}}</i></li>
        <li>有效期:<i>{{parseTime(subjectData.labSecurityApply.validBeginTime,"{y}-{m}-{d} {h}:{i}")}} 至 {{parseTime(subjectData.labSecurityApply.validEndTime,"{y}-{m}-{d} {h}:{i}")}}</i></li>
        <li>申请状态:<i>{{subjectData.labSecurityApply.auditStatus == 0?'待审核':(subjectData.labSecurityApply.auditStatus == 1?'已驳回':(subjectData.labSecurityApply.auditStatus == 2?'已通过':''))}}</i></li>
        <li v-if="subjectData.labSecurityApply.auditStatus == 2 && subjectData.labSecurityApply.auditStatus != 0">审核时间:<i>{{parseTime(subjectData.labSecurityApply.auditTime,"{y}-{m}-{d} {h}:{i}")}}</i></li>
        <li v-if="subjectData.labSecurityApply.auditStatus == 1 && subjectData.labSecurityApply.auditStatus != 0">审核时间:<i>{{parseTime(subjectData.labSecurityApply.rejectTime,"{y}-{m}-{d} {h}:{i}")}}</i></li>
        <li>审核人:<i>{{subjectData.labSecurityApply.auditName?subjectData.labSecurityApply.auditName:'--'}}</i></li>
        <li v-if="subjectData.labSecurityApply.auditStatus != 0">审核备注:<i>{{subjectData.labSecurityApply.rejectCause}}</i></li>
      </div>
      <div class="admittance_materials">
        <p class="admittance_materials_title">准入材料</p>
        <div class="admittance_materials_for">
          <div class="item-max-box">
            <div class="item-title-box" style="margin-left: 0;">
              <p>*</p>
              <p>身份信息：</p>
              <p>(关联学生信息材料)</p>
            </div>
            <div class="identity">
              <li>姓名:<i>{{subjectData.sysUser.userName}}</i></li>
              <li>学号:<i>{{subjectData.sysUser.account}}</i></li>
              <li>卡号:<i>{{subjectData.sysUser.cardNumSimple}}</i></li>
              <li>联系方式:<i>{{subjectData.sysUser.mobile}}</i></li>
              <li>导师:<i>{{subjectData.sysUser.tutorUserName}}</i></li>
              <li>班级:<i>{{subjectData.sysUser.gradeName}}</i></li>
              <li>学院:<i>{{subjectData.labSecurityApply.deptName}}</i></li>
              <li>专业:<i>{{subjectData.sysUser.majorName}}</i></li>
              <li>申请备注:<i>{{subjectData.labSecurityApply.applyCause}}</i></li>
            </div>
          </div>
        </div>
        <div class="admittance_materials_for" v-for="(item,index) in subjectData.listTemp" :key="index">
          <div class="item-max-box" v-if="item.materialType==2&&item.relationType==2">
            <div class="item-title-box" style="margin-left: 0;">
              <p>*</p>
              <p>安全考试证书：</p>
              <p>(已同步证书信息)</p>
            </div>
            <img v-if="item.materialType==2&&item.relationType==2&&subjectData.userCertificate"
                 @click="fullScreenViewClick(subjectData.userCertificate)"
                 class="item-img-box" :src="subjectData.userCertificate">
            <p v-if="item.materialType==2&&item.relationType==2&&!subjectData.userCertificate"
               style="margin-left:40px;color:#999;font-size:14px;line-height:40px;">暂无证书</p>
          </div>
          <div class="item-max-box" v-if="item.materialType==1">
            <div class="item-title-box" style="margin-left: 0;">
              <p>*</p>
              <p>{{item.materialName}}：</p>
              <p></p>
            </div>
            <div class="file_list" v-for="(minItem,minIndex) in item.upList">
              <i >{{minItem.name}}</i>
              <i class="file_list_look" @click="fullScreenFileLookClick(minItem)">查看</i>
              <!--          <a class="file_list_look" :href="item2.dataUrl.split(';')[1].replace(/,/g,'')" target="_blank">查看</a>-->
            </div>
          </div>
        </div>
      </div>
    </div>
    <fullScreenView :fullScreenViewProps="fullScreenViewProps" ref="fullScreenView"></fullScreenView>
    <fullScreenFileLook ref="fullScreenFileLook"></fullScreenFileLook>
  </div>
</template>

<script>
let Base64 = require('js-base64').Base64;
import { laboratoryApplyGetDetails } from "@/api/secureAccess/index";
import fullScreenView from "@/components/fullScreenView/fullScreenView.vue";
import fullScreenFileLook from "@/components/fullScreenFileLook/fullScreenFileLook.vue";


export default {
  name: "info-page",
  components: {
    fullScreenView,
    fullScreenFileLook
  },
  props:{
    infoData: {},
  },
  data() {
    return {
      pageType:false,
      forIndex:0,
      subjectData:{},
      iframeSrc:"",
      //图片浏览
      fullScreenViewProps:[],
    };
  },
  created() {
    this.laboratoryApplyGetDetails();
  },


  methods: {
    //图片浏览
    fullScreenViewClick(url){
      this.$set(this,'fullScreenViewProps',[url]);
      this.$refs['fullScreenView'].initialize();
    },
    //文件浏览
    fullScreenFileLookClick(item){
      //判断类型
      let type = '';
      if(item.url.split('.')[1] == 'docx'){
        type = 'docx'
      }else if(item.url.split('.')[1] == 'xlsx'){
        type = 'excel'
      }else if(item.url.split('.')[1] == 'pdf'){
        type = 'pdf'
      }else if(item.url.split('.')[1] == 'png' || item.url.split('.')[1] == 'jpg' || item.url.split('.')[1] == 'gif'){
        type = 'img'
      }
      //整合地址
      let url = localStorage.getItem('fileBrowseEnvironment')+item.url;
      // 判断图片还是文件
      if(type == 'img'){
        this.$set(this,'fullScreenViewProps',[url]);
        this.$refs['fullScreenView'].initialize();
      }else if(type == 'docx' || type == 'excel' || type == 'pdf'){
        this.$refs['fullScreenFileLook'].initialize(item.name,url,type);
      }
    },
    //点击切换文件
    forClick(item,index,bigIndex){
      this.iframeSrc[bigIndex].url = this.urlJudge(item.url);
      this.iframeSrc[bigIndex].forIndex = index;
    },
    //获取数据
    laboratoryApplyGetDetails(){
      let self = this;
      laboratoryApplyGetDetails({id:this.infoData.applyId}).then(response => {
        let dataList = [];
        for(let i=0;i<response.data.listTemp.length;i++){
          if(response.data.listTemp[i].materialType == 2 && response.data.listTemp[i].materialType == 2){
            dataList.unshift(response.data.listTemp[i]);
          }
        }
        for(let i=0;i<response.data.listTemp.length;i++){
          if(response.data.listTemp[i].materialType == 1){
            dataList.push(response.data.listTemp[i]);
          }
        }
        for(let i=0;i<response.data.listTemp.length;i++){
          if(response.data.listTemp[i].materialType == 2 && response.data.listTemp[i].materialType == 1){
            dataList.unshift(response.data.listTemp[i]);
          }
        }
        this.$set(response.data,'listTemp',dataList);
        let newList = [];
        for(let i=0;i<response.data.listTemp.length;i++){
          if(response.data.listTemp[i].materialType == 1){
            let maxList = [];
            for(let o=0;o<response.data.listTemp[i].listMr.length;o++){
              let bigList = response.data.listTemp[i].listMr[o].dataUrl.split(',');
              for(let x=0;x<bigList.length;x++){
                if(bigList[x]){
                  let minList = bigList[x].split(';');
                  let obj = {
                    name:minList[0],
                    url:minList[1],
                  };
                  maxList.push(obj);
                }
              }
            }
            response.data.listTemp[i].upList = maxList;
            let obj ={};
            if(maxList.length>0){
              obj = {
                forIndex:0,
                url:this.urlJudge(maxList[0].url)
              }
            }
            newList.push(obj);
          }else{
            let obj = {
              forIndex:"",
              url:""
            }
            newList.push(obj);
          }
        }
        this.$set(this,"iframeSrc",newList);
        this.$set(this,"subjectData",response.data);
        this.$forceUpdate()
        this.pageType = true;
      })
    },
    //返回
    backPage(){
      this.$parent.pageClick(1);
    },
    //重新提交
    backPageEdit(){
      let obj = JSON.parse(JSON.stringify(this.subjectData));
      this.$parent.pageClick(4,obj);
    }
  }
};
</script>

<style scoped lang="scss">
.info-page {
  .info-page-box{
    padding-bottom:40px;
    /*准入信息*/
    .admittance_info{
      display: flex;
      justify-content: flex-start;
      flex-wrap: wrap;
      padding-left: 80px;
      box-sizing: border-box;
      >li{
        list-style-type:none;
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 500;
        color: #999999;
        line-height: 70px;
        margin-right: 20px;
        >i{
          margin-left: 10px;
          display: inline-block;
          font-style:normal;
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: 500;
          color: #333333;
          line-height: 70px;
        }
      }
    }
    /*准入材料*/
    .admittance_materials{
      box-sizing: border-box;
      .admittance_materials_title{
        flex: 1;
        line-height:60px;
        color: #0045AF;
        font-size:16px;
        border-bottom: 1px solid #E0E0E0;
        margin-top: 0;
        padding:0 20px;
      }
      .admittance_materials_for{
        padding:0 40px;
      }
      .identity{
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        padding-left: 40px;
        box-sizing: border-box;
        >li{
          list-style-type:none;
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: 500;
          color: #999999;
          line-height: 40px;
          margin-right: 20px;
          >i{
            margin-left: 10px;
            display: inline-block;
            font-style:normal;
            font-size: 16px;
            font-family: Microsoft YaHei;
            font-weight: 500;
            color: #333333;
            line-height: 40px;
          }
        }
      }
      .file_list{
        padding-left: 80px;
        box-sizing: border-box;
        >i{
          display: inline-block;
          overflow:hidden;
          text-overflow:ellipsis;
          white-space:nowrap;
          width:300px;
          font-style: normal;
          font-size: 14px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          color: #0183FA;
          line-height: 40px;
        }
        .file_list_look{
          padding-left: 40px;
          cursor: pointer;
          font-style: normal;
          font-size: 14px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          color: #0183FA;
          line-height: 40px;
        }

      }
    }
    .item-max-box{
      .item-title-box{
        display: flex;
        margin-left: 0px;
        p{
          font-size:16px;
          line-height:60px;
        }
        p:nth-child(1){
          color:red;
          margin-right:10px;
        }
        p:nth-child(2){
          color:#333;
          font-weight:700;
        }
        p:nth-child(3){
          color:#999;
        }
      }
      .item-user-box{
        display: flex;

        div{
          display: flex;
          margin-right:60px;
          p{
            font-size:14px;
          }
          p:nth-child(1){
            color:#999;
          }
          p:nth-child(2){
            color:#666;
          }
        }
      }
      .item-title-text{
        margin-left:15px;
        font-size:14px;
        line-height:20px;
        color:#999;
      }
      .item-input-box{
        display: flex;
        margin:20px 0 0 15px;
        input{
          width:390px;
          height:40px;
          padding:0 20px;
          margin-right:20px;
        }
      }
      .item-input-for-box{
        margin:20px 0 0 5px;
        .item-input-for-big{
          display: inline-block;
          border-radius:6px;
          background: rgba(1,131,250,0.2);
          margin:0 10px 10px;
          .item-input-for-min{
            display: flex;
            p{
              flex:1;
              padding:0 20px;
              margin:0;
              line-height:30px;
              color:#0183FA;
            }
            i{
              line-height:30px;
              color:#0183FA;
              margin-right: 8px;
              cursor: pointer;
            }
            a{
              line-height:30px;
              color:#0183FA;
              margin-right: 8px;
              cursor: pointer;
            }
            img{
              width:16px;
              height:16px;
              margin:7px 7px;
              cursor: pointer;
            }
          }
        }
      }
      .item-img-box{
        width:240px;
        margin-left:35px;
        cursor: pointer;
      }
    }
  }
}
</style>
