<template>
  <div class="app-container">
    <div class="header_main">
      文件预览
      <div class="return_btn" @click="onClickLeft"></div>
    </div>
    <div style="height: 58px;"></div>
    <pdf v-for="item in numPages" :key="item" :src="url" :page="item" ref="pdf"></pdf>
  </div>
</template>

<script>
  import { createAssistPDF,createSurveyPDF,createPutrecordPDF,createOnrecordPDF,createSamplingPDF,createTreatPDF,createDecisionPDF,createEvidencePDF,createExecutePDF,createEndingPDF,createBreakPDF,createResumePDF } from "@/api/lawEnforcement/index";
  import pdf from 'vue-pdf'
  export default {
    components:{
      pdf
    },
    name: "programmeDetail",
    data() {
      return {
        url:'',
        numPages: null, // pdf 总页数
      };
    },
    created() {
      const id = this.$route.query.id;
      const fileType = this.$route.query.fileType;
      const fileHalfName = this.$route.query.fileHalfName;
      const baseURL = process.env.VUE_APP_BASE_API;
      switch (fileType) {
        case "assistFile":  // 协助调查函
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createAssistPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "surveyRecordFile": // 现场检查(勘验)笔录
        case "surveyAskRecordFile":  // 询问笔录
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createSurveyPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "caseTransferLetter":  // 案件移送函
        case "noticeOfDesignatedJurisdiction":  // 指定管辖通知书
        case "notificationOfCaseSubmission":  // 案件交办通知书
        case "caseTransferLetter1":  // 案件移送函
        case "letterTransferSuspectedCriminalCase":  // 涉嫌犯罪案件移送书
        case "noticeOfRectificationOrder": // 责令改正通知书
        case "writtenDecisionOnAdministrativePenaltyOnTheSpot":  // 当场行政处罚决定书
        case "noFilingExaminationAndApprovalForm":  // 不予立案审批表
        case "revocationOfFilingApprovalForm":  // 撤销立案审批表
        case "notPunishDecisionNotice": // 不予行政处罚决定书
        case "caseHandlingOpinion":  // 案件处理意见书
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createOnrecordPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "evidenceSaveFile": // 证据先行保存通知书
        case "sealUpRecordFile":  // 查封(扣押)现场笔录
        case "sealUpDecisionFile":  // 查封(扣押)决定书
        case "sealUpDecisionGoodsList": // 查封(扣押)财物清单
        case "removeSealupFile": // 解除查封(扣押)决定书
        case "removeSealUpDecisionGoodsList": // 解除查封(扣押)财物清单
        case "filingExaminationAndApprovalForm":  // 立案审批表
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createPutrecordPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "productSureFile":  // 产品确认通知书
        case "samplingRecordFile":  // 抽样取证凭证
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createSamplingPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "noticeOfAdministrativePenaltyInAdvance":  // 行政处罚事先告知书(非听证)
        case "noticeOfHearingAdministrativePenaltyInAdvance":  // 行政处罚事先告知书(听证)
        case "noticeOfHearingOnAdministrativeTreatment":  // 行政处罚听证会通知书
        case "administrativeDispositionHearingReport":  // 行政处罚听证会报告书
        case "hearingRecord":  // 听证笔录
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createTreatPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "caseHandlingOpinionFromTreat":  // 案件处理意见书(处理页面按钮点击)
          var param = {
            id: id,
            fileType: "caseHandlingOpinion",
            fileHalfName: fileHalfName,
          };
          createTreatPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "proofOfService":  // 送达回证
        case "writtenDecisionOfAdministrativePenalty":  // 行政处罚决定书
        case "administrativePenaltyDecisionExaminationAndApprovalForm":  // 行政处罚决定审批表
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createDecisionPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "detectResultFile":  // 抽样检测结果告知书
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createEvidencePDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "noticeForExecutionOfAdministrativePenaltyDecision":  // 履行行政处罚决定催告书
        case "applicationForEnforcement":  // 强制执行申请书
        case "goodsHandleNotice":  // 登记保存物品处理通知书
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createExecutePDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "delayedOrStageNotice": // 延期（分期）缴纳罚款通知书
        case "caseEndReport": // 行政处罚结案报告
        case "punishGoodsHandleNotice": // 罚没物品处理记录
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createEndingPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "breakCaseFile": // 案件中止调查决定书
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createBreakPDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
        case "resumeCaseFile": // 案件恢复调查决定书
          var param = {
            id: id,
            fileType: fileType,
            fileHalfName: fileHalfName,
          };
          createResumePDF(param).then(response => {
            this.url = baseURL + response.msg;
            let loadingTask = pdf.createLoadingTask(this.url)
            loadingTask.promise.then(pdf => {
              this.numPages = pdf.numPages
            })
          });
          break;
      }

    },
    methods: {
      goBack(){
        window.history.go(-1)
      }
    },
  }
</script>

<style scoped lang="scss">
  .app-container {
    padding: 2% 0;
  }
  /deep/ .van-collapse-item__content{
    padding: 0;
  }
  .cf{
    padding: 0 3%;
    margin-top: 20PX;
    margin-bottom: 20PX;
    .van-row{
      background: #F0F3F5;
      display: flex;
      align-items: center;
      .van-col{
        padding: 5PX 0;
        font-size: 12PX!important;
        text-align: center;
        p{
          color: #1D6FE9;
          text-align: left;
          font-size: .4rem;
        }
      }
      &:first-child{
        background: transparent;
      }
    }
  }
  .header_main{
    height: 116px;
    background: url('../../../../static/images/lawEnforcement/new/list_head.png') no-repeat;
    background-size: 100% 100%;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    font-size: 36px;
    line-height: 116px;
    text-align: center;
    color: #fff;
    z-index: 999;
    .return_btn{
      width: 24px;
      height: 43.2px;
      background: url('../../../assets/images/sunVillage_info/list_icon_5.png') center center no-repeat;
      background-size: 20px 36px;
      position: absolute;
      left: 38px;
      top: 36px;
    }
    .add_btn{
      width: 56.4px;
      height: 40.8px;
      background: url('../../../assets/images/sunVillage_info/list_icon_9.png') center center no-repeat;
      background-size: 47px 34px;
      position: absolute;
      right: 38px;
      top: 36px;
    }
  }
  /deep/ .van-radio--horizontal{
    margin-left: 0.32rem;
    margin-right: 0;
  }
  .peopleList{
    padding: 0 3%;
    text-align: left;
    .van-row{
      border-bottom: 1px solid #dddddd;
      display: flex;
      align-items: center;
      &:last-child{
        border: none;
      }
      .van-col--17{
        display: flex;
        align-items: center;
        p{
          margin-left: 10PX;
        }
      }
      .van-col--7{
        display: flex;
        justify-content: space-between;
        p{
          color: #1D6FE9;
          border: 1px solid #1D6FE9;
          text-align: center;
          border-radius: 15PX;
          display: inline-block;
          padding: 5px 15px;
        }
      }
      .van-col{
        text-align: left;
        font-size: 14PX;
        color: #333333;
        padding: 15PX 0;
        img{
          display: block;
        }
      }
    }
  }
  .main_title{
    font-size: 0.4rem;
    color: #1D6FE9;
    margin: 0.2rem 6%;
    margin-top: 0;
    position: relative;
  }
  .main_box{
    width: 96%;
    margin: 0 auto;
    border-radius: 10PX;
    box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
    overflow: hidden;
    background-color: #FFF;
    .van-icon{
      vertical-align: middle;
    }
    .custom-title{
      font-size: 17PX;
      color: #333333;
      vertical-align: middle;
      line-height: 1;
      position: relative;
    }
    .tap{
      color: #1D6FE9;
    }
    .bgBlue{
      display: block;
      position: absolute;
      width: 17PX;
      height: 17PX;
      border-radius: 50%;
      background-color: rgba(29,111,233,0.26);
      top: -2PX;
      right: -8PX;
    }
  }
  .submitButton{
    width: 40%;
    margin: 0 auto;
    background-image: linear-gradient(to right, #77A6EF , #2E79E9);
    text-align: center;
    color: #ffffff;
    height: 70px;
    line-height: 70px;
    border-radius: 8PX;
    margin-top: 25PX;
    &:first-child{
      background-image: linear-gradient(to right, #21CAC3 , #17A8A2);
    }
  }
  .submit_box{
    display: flex;
    align-items: center;
    justify-content: space-around;
  }

  .addFamily{
    position: absolute;
    top: -2px;
    right: 0;
    border-radius: 50%;
  }

</style>
