<!--用气审核-详情-->
<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">
      <li><i>申请人：</i><i>{{form.applyUserName}}</i></li>
      <li><i>联系方式：</i><i>{{form.applyUserPhone}}</i></li>
      <li><i>使用气体：</i><i>{{form.useGasName}}</i></li>
      <li><i>使用期限：</i><i>{{form.startTime}} 至 {{form.endTime}}</i></li>
      <li><i>气瓶用途：</i><i>{{form.gasUse}}</i></li>
      <li><i>主要安全措施：</i><i>{{form.safetyPrecautions}}</i></li>
      <li class="look_img" @click="lookFile(form.applyCertificate)"><i>用气申请表：</i><i>查看图片</i></li>
<!--      <a :href="lookImgUrl+form.applyCertificate"></a>-->
    </div>
    <div class="check_btn" v-if="status==0">
      <el-input type="textarea" class="apply_tree_b2" v-model="queryParams.remark" placeholder="请输入审核意见"  maxlength="200" />
      <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="addPage_b" v-if="tableData">
      <!--气瓶信息-->
      <div  class="addPage_b_t">
        <div class="addPage_b_t_title">审核记录</div>
        <el-table border v-loading="loading" :data="tableData" height="300px">
          <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 {
  qualificationApplyDetail,
  qualificationApplyList,
  subjectList,
  useAgsApplyDetail
} from '@/api/gasManage3_0/gasManage'
import { usegasAuditRecordList, usegasCheck } from '@/api/gasManage3_0/gasManageSYD'
let Base64 = require('js-base64').Base64;
export default {
  name: "addPage",
  props:{
    pageData2: {},
  },
  data() {
    return {
      lookImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API, // 图片服务器地址
      pageType:1,
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      loading:false,
      form:{
      },
      status:0,
      total:0,
      tableData:[],
      queryParams:{
        usegasApplyId:'',
        remark:'',
        auditStatus:'',//0未审核1.通过 2.驳回
      }
    };
  },
  methods: {
    handleClick(index,row,doType){
      let _this=this;
      _this.queryParams.usegasApplyId=_this.form.id
      if(doType=='pass'){//审核通过
        _this.queryParams.auditStatus=1
        _this.usegasCheck()
      }else if(doType=='reject'){//审核驳回
        _this.queryParams.auditStatus=2
        _this.usegasCheck()
      }
    },
    /**查看图片  */
    lookFile(item){
      let visitUrl=window.location.href.split('://')[0]+'://'+process.env.VUE_APP_BASE_API+'/admin/'+item;
      console.log(visitUrl)
      window.open(localStorage.getItem('filePreviewUrl') + '/onlinePreview?url='+encodeURIComponent(Base64.encode(visitUrl)));
    },
    //审核
    usegasCheck(){
      let _this=this;
      usegasCheck(_this.queryParams).then( response => {
        let res=response.data;
        if(response.code==200){
          this.$parent.handleClick('','','back');
        }

      });
    },
    /* 审核记录 */
    getRecordList(id){
      let _this=this;
      usegasAuditRecordList({usegasApplyId:id}).then( response => {
        let res=response.rows;
        _this.tableData=res;
      });

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

  },
  mounted() {
    this.status=this.pageData2.status;
    this.form=this.pageData2.item;
    this.getRecordList(this.pageData2.item.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;
    >li{
      list-style-type: none;
      margin: 20px 0;
      >i{
        font-style: normal;
        display: inline-block;
        vertical-align:text-top;
      }
      >i:nth-of-type(1){
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #999999;
        line-height: 16px;
        width: 120px;
        text-align: right;
      }
      >i:nth-of-type(2){
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #333333;
        line-height: 16px;
        width: 240px;
        text-align: left;
      }
    }
    .look_img{
      cursor: pointer;
      >i:nth-of-type(2){
        color: #0183FA;
      }
    }
  }
  /*审核按钮*/
  .check_btn{
    text-align: center;
    .apply_tree_b2{
      width: 90%;
      margin: 46px 30px 38px 30px;
    }
    .sub_btn{
      display: flex;
      justify-content: center;
      margin: 30px 0;
    }
  }
  .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;
      }
    }
  }

}
</style>
