<template>
  <div :class="{ curriculumVitaePreview: true, noFile: !isAll || !hasFile }">
    <div :class="{ allInfo: isAll && hasFile, info: !isAll || !hasFile }">
      <div class="title">{{ $t('curriculumVitae:preview:title') }}</div>
      <div class="message">
        <div class="userInfo">
          <span v-if="isAll">
            {{
              isEN
                ? reviewerData.BasicInfoView.LastName +
                  ' / ' +
                  reviewerData.BasicInfoView.FirstName
                : reviewerData.BasicInfoView.ChineseName
            }}
          </span>
          <span v-else>{{
            isEN
              ? reviewerData.BasicInfoView.BlindName
              : reviewerData.BasicInfoView.BlindNameCN
          }}</span>
          <span>{{ $fd('Sex', reviewerData.BasicInfoView.Sex) }}</span>
          <span v-if="isEN">
            {{
              Array.isArray(reviewerData.BasicInfoView.TitleList) &&
              reviewerData.BasicInfoView.TitleList.length > 0
                ? reviewerData.BasicInfoView.TitleList.join(', ')
                : ''
            }}
          </span>
          <span v-else>
            {{
              Array.isArray(reviewerData.BasicInfoView.TitleCNList) &&
              reviewerData.BasicInfoView.TitleCNList.length > 0
                ? reviewerData.BasicInfoView.TitleCNList.join(', ')
                : ''
            }}
          </span>
          <span v-if="isAll">
            <span v-if="isEN">{{
              reviewerData.BasicInfoView.HospitalName
            }}</span>
            <span v-else>{{ reviewerData.BasicInfoView.HospitalNameCN }}</span>
          </span>
          <span v-if="isAll">
            <span>
              {{ $t('system:Setting:title:Vacation') }}
              {{ InHoliday }}
            </span>
            <el-button type="text" @click="handleView">
              {{ $t('system:Setting:Planned Vacation') }}
            </el-button>
          </span>
        </div>
        <div class="userTitle">
          <span
            class="el-icon-first-aid-kit"
            v-if="
              reviewerData.EmploymentView.Department ||
              reviewerData.EmploymentView.DepartmentCN
            "
          >
            <span v-if="isEN">{{
              reviewerData.EmploymentView.Department
            }}</span>
            <span v-else>{{ reviewerData.EmploymentView.DepartmentCN }}</span>
          </span>
          <span class="el-icon-first-aid-kit" v-else>
            <span v-if="isEN">{{
              reviewerData.EmploymentView.DepartmentOther
            }}</span>
            <span v-else>{{
              reviewerData.EmploymentView.DepartmentOtherCN
            }}</span>
          </span>
          <span class="el-icon-user" v-if="reviewerData.EmploymentView.RankOther || reviewerData.EmploymentView.RankOtherCN">
            <span v-if="isEN">{{ reviewerData.EmploymentView.RankOther }}</span>
            <span v-else>{{ reviewerData.EmploymentView.RankOtherCN }}</span>
          </span>
          <span class="el-icon-user" v-else
            ><span v-if="isEN">{{ reviewerData.EmploymentView.Rank }}</span>
            <span v-else>{{ reviewerData.EmploymentView.RankCN }}</span></span
          >
        </div>
        <div class="userTel" v-if="isAll">
          <span class="el-icon-phone-outline">{{
            reviewerData.BasicInfoView.Phone
          }}</span>
          <span class="el-icon-message">{{
            reviewerData.BasicInfoView.EMail
          }}</span>
          <span class="el-icon-chat-dot-round">{{
            reviewerData.BasicInfoView.WeChat
          }}</span>
        </div>
        <div style="display: flex; font-size: 14px" v-if="isAll">
          <span style="display: inline-block; width: 70px; color: #606266">{{
            $t('curriculumVitae:info:meessage:partTimeJob')
          }}</span>
          <span
            class="break-word"
            style="
              white-space: pre-wrap;
              width: calc(100% - 80px);
              word-wrap: break-word;
            "
            v-html="
              isEN
                ? reviewerData.EmploymentView.WorkPartTimeEn
                : reviewerData.EmploymentView.WorkPartTime
            "
          ></span>
        </div>
      </div>
      <div class="message break-word">
        <div class="title">{{ $t('curriculumVitae:summarize:title') }}</div>
        <span
          class=""
          style="white-space: pre-wrap"
          v-html="isEN ? mainSummarize.SummarizeEn : mainSummarize.Summarize"
          v-if="mainSummarize.SummarizeEn || mainSummarize.Summarize"
        ></span>
        <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
      </div>
      <div class="message" v-if="isAll">
        <el-form class="demo-form-inline">
          <el-form-item :label="$t('curriculumVitae:specialty:specialty')">
            <span v-if="isEN">
              {{
                reviewerData.SpecialtyView.Speciality ||
                reviewerData.SpecialtyView.SpecialityOther
              }}
            </span>
            <span v-else>{{
              reviewerData.SpecialtyView.SpecialityCN ||
              reviewerData.SpecialtyView.SpecialityOtherCN
            }}</span>
          </el-form-item>
          <el-form-item :label="$t('curriculumVitae:specialty:submajor')">
            <template v-if="isEN">
              <el-tag
                type="info"
                v-for="item in reviewerData.SpecialtyView.SubspecialityOther
                  ? [
                      ...reviewerData.SpecialtyView.SubspecialityList,
                      reviewerData.SpecialtyView.SubspecialityOther,
                    ]
                  : reviewerData.SpecialtyView.SubspecialityList"
                :key="item"
              >
                {{ item }}
              </el-tag>
            </template>
            <template v-else>
              <el-tag
                type="info"
                v-for="item in reviewerData.SpecialtyView.SubspecialityOtherCN
                  ? [
                      ...reviewerData.SpecialtyView.SubspecialityCNList,
                      reviewerData.SpecialtyView.SubspecialityOtherCN,
                    ]
                  : reviewerData.SpecialtyView.SubspecialityCNList"
                :key="item"
              >
                {{ item }}
              </el-tag>
            </template>
          </el-form-item>
          <el-form-item :label="$t('curriculumVitae:specialty:equipment')">
            <template v-if="isEN">
              <el-tag
                type="info"
                v-for="item in reviewerData.SpecialtyView.ReadingTypeOther
                  ? [
                      ...reviewerData.SpecialtyView.ReadingTypeList,
                      reviewerData.SpecialtyView.ReadingTypeOther,
                    ]
                  : reviewerData.SpecialtyView.ReadingTypeList"
                :key="item"
              >
                {{ item }}
              </el-tag>
            </template>
            <template v-else>
              <el-tag
                type="info"
                v-for="item in reviewerData.SpecialtyView.ReadingTypeOtherCN
                  ? [
                      ...reviewerData.SpecialtyView.ReadingTypeCNList,
                      reviewerData.SpecialtyView.ReadingTypeOtherCN,
                    ]
                  : reviewerData.SpecialtyView.ReadingTypeCNList"
                :key="item"
              >
                {{ item }}
              </el-tag>
            </template>
          </el-form-item>
        </el-form>
      </div>
      <div class="message">
        <div class="title">
          {{ $t('curriculumVitae:EducationalExperience:title') }}
        </div>
        <el-table
          :data="[...reviewerData.EducationList]"
          v-loading="loading"
          style="width: 100%"
          :header-cell-style="{ background: '#eee', color: '#606266' }"
        >
          <el-table-column
            prop="date"
            :label="$t('curriculumVitae:EducationalExperience:table:time')"
          >
            <template slot-scope="scope">
              <span
                >{{ scope.row.BeginDateStr }} ~ {{ scope.row.EndDateStr }}</span
              >
            </template>
          </el-table-column>
          <el-table-column
            prop="Major"
            :label="$t('curriculumVitae:EducationalExperience:table:specialy')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span>
                {{ isEN ? scope.row.Major : scope.row.MajorCN }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="date"
            :label="$t('curriculumVitae:EducationalExperience:table:degree')"
            v-if="isAll"
          >
            <template slot-scope="scope">
              <span>
                {{ $fd('Degree', Number(scope.row.Degree)) }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="date"
            :label="$t('curriculumVitae:EducationalExperience:table:school')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span>
                {{ isEN ? scope.row.Organization : scope.row.OrganizationCN }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="date"
            :label="$t('curriculumVitae:EducationalExperience:table:city')"
            v-if="isAll"
          >
            <template slot-scope="scope">
              <span>
                {{ isEN ? scope.row.City : scope.row.CityCN }}
              </span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="message">
        <div class="title">
          {{ $t('curriculumVitae:continuingTraining:title') }}
        </div>
        <el-table
          :data="reviewerData.PostgraduateList"
          v-loading="loading"
          style="width: 100%"
          :header-cell-style="{ background: '#eee', color: '#606266' }"
        >
          <el-table-column
            prop="date"
            :label="$t('curriculumVitae:continuingTraining:table:time')"
          >
            <template slot-scope="scope">
              <span
                >{{ scope.row.BeginDateStr }} ~ {{ scope.row.EndDateStr }}</span
              >
            </template>
          </el-table-column>
          <el-table-column
            prop="Training"
            :label="$t('curriculumVitae:continuingTraining:table:type')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span>{{ $fd('Training', Number(scope.row.Training)) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="Major"
            :label="$t('curriculumVitae:continuingTraining:table:direction')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span>{{ isEN ? scope.row.Major : scope.row.MajorCN }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="school"
            :label="$t('curriculumVitae:continuingTraining:table:school')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span>{{ isEN ? scope.row.School : scope.row.SchoolCN }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="City"
            :label="$t('curriculumVitae:continuingTraining:table:city')"
            v-if="isAll"
          >
            <template slot-scope="scope">
              <span>{{ isEN ? scope.row.City : scope.row.CityCN }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="message">
        <div class="title">
          {{ $t('curriculumVitae:scientificResearchProject:title') }}
        </div>
        <div class="content">
          <el-form class="demo-form-inline">
            <!-- <el-form-item
              :label="$t('curriculumVitae:scientificResearchProject:direction')"
            >
              <span v-if="isEN" class="break-word">{{
                reviewerData.ResearchPublicationView.Research
              }}</span>
              <span v-else class="break-word">{{
                reviewerData.ResearchPublicationView.ResearchCN
              }}</span>
            </el-form-item> -->
            <div style="display: flex; font-size: 14px">
              <span
                style="display: inline-block; width: 80px; color: #606266"
                >{{
                  $t('curriculumVitae:scientificResearchProject:direction')
                }}</span
              >
              <span
                class="break-word"
                style="white-space: pre-wrap; width: calc(100% - 80px)"
                v-html="
                  isEN
                    ? reviewerData.ResearchPublicationView.Research
                    : reviewerData.ResearchPublicationView.ResearchCN
                "
              ></span>
            </div>
            <div style="display: flex; font-size: 14px">
              <span
                style="display: inline-block; width: 80px; color: #606266"
                >{{
                  $t('curriculumVitae:scientificResearchProject:subject')
                }}</span
              >
              <span
                class="break-word"
                style="white-space: pre-wrap; width: calc(100% - 80px)"
                v-html="
                  isEN
                    ? reviewerData.ResearchPublicationView.Grants
                    : reviewerData.ResearchPublicationView.GrantsCN
                "
              ></span>
            </div>
          </el-form>
        </div>
      </div>
      <div class="message">
        <!--临床试验-->
        <div class="title">
          {{ $t('curriculumVitae:clinicalTrials:title') }}
        </div>
        <el-table
          :data="reviewerData.TrialExperienceView.ClinicalTrialExperienceList"
          style="width: 100%"
          :header-cell-style="{ background: '#eee', color: '#606266' }"
        >
          <el-table-column
            prop="Phase"
            :label="$t('curriculumVitae:clinicalTrials:table:byStages')"
            v-if="true"
          >
            <template slot-scope="scope">
              {{
                scope.row.OtherStages ? scope.row.OtherStages : scope.row.Phase
              }}
            </template>
          </el-table-column>
          <el-table-column
            prop="EvaluationCriteriaList"
            :label="$t('curriculumVitae:clinicalTrials:table:criterion')"
            v-if="true"
          >
            <template slot-scope="scope">
              {{
                scope.row.EvaluationCriteriaList.length > 0
                  ? scope.row.EvaluationCriteriaList.join(', ')
                  : ''
              }}
              <span v-if="scope.row.OtherCriterion">
                {{
                  scope.row.EvaluationCriteriaList.length > 0
                    ? `, ${scope.row.OtherCriterion}`
                    : scope.row.OtherCriterion
                }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="EvaluationContent"
            :label="$t('curriculumVitae:clinicalTrials:table:indication')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.EvaluationContent">
                {{ scope.row.EvaluationContent }}
              </span>
              <span v-else>
                {{ $fd('Indication', scope.row.IndicationEnum) }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="VisitReadingCount"
            :label="$t('curriculumVitae:clinicalTrials:table:viewingVolumeNum')"
            v-if="isAll"
          >
          </el-table-column>
          <el-table-column
            prop="date"
            :label="$t('curriculumVitae:clinicalTrials:table:year')"
            v-if="true"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.StartTime"
                >{{ scope.row.StartTime.split('-')[0] }}-{{
                  scope.row.EndTime
                    ? scope.row.EndTime.split('-')[0]
                    : $t('curriculumVitae:lineIIcon:soFar')
                }}</span
              >
            </template>
          </el-table-column>
        </el-table>
        <!--GCP证书-->
        <template v-if="isAll">
          <div class="title">
            {{ $t('curriculumVitae:clinicalTrials:GCPtitle') }}
          </div>
          <el-table
            :data="GCPData"
            style="width: 100%"
            :header-cell-style="{ background: '#eee', color: '#606266' }"
          >
            <el-table-column
              prop="GCP"
              :label="$t('curriculumVitae:clinicalTrials:table:hasCertificate')"
              v-if="true"
            >
              <template slot-scope="scope">
                <span>{{ $fd('hasOrNo', scope.row.GCP) }}</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="GCPTime"
              :label="
                $t('curriculumVitae:clinicalTrials:table:certificateTime')
              "
              v-if="true"
            >
            </el-table-column>
            <el-table-column
              prop="GCPAgencies"
              v-if="true"
              :label="
                $t('curriculumVitae:clinicalTrials:table:certificateHospital')
              "
            >
            </el-table-column>
          </el-table>
        </template>
        <!--其他相关经历-->
        <div class="title">
          {{ $t('curriculumVitae:clinicalTrials:otherTitle') }}
        </div>
        <template
          v-if="
            reviewerData.TrialExperienceView.OtherClinicalExperience ||
            reviewerData.TrialExperienceView.OtherClinicalExperienceCN
          "
        >
          <div
            class="message break-word"
            style="white-space: pre-wrap"
            v-html="
              isEN
                ? reviewerData.TrialExperienceView.OtherClinicalExperience
                : reviewerData.TrialExperienceView.OtherClinicalExperienceCN
            "
          ></div>
        </template>
        <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
      </div>
      <template v-if="isAll">
        <div class="message">
          <div class="title">{{ $t('curriculumVitae:treatise:title') }}</div>
          <div
            class="message break-word"
            style="white-space: pre-wrap"
            v-html="reviewerData.ResearchPublicationView.Publications"
            v-if="reviewerData.ResearchPublicationView.Publications"
          ></div>
          <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
        </div>
      </template>
      <template v-else>
        <div class="message">
          <div class="title">{{ $t('curriculumVitae:treatise:title') }}</div>
          <div
            class="message break-word"
            style="white-space: pre-wrap"
            v-html="reviewerData.BasicInfoView.BlindPublications"
            v-if="reviewerData.BasicInfoView.BlindPublications"
          ></div>
          <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
        </div>
      </template>
      <div class="message break-word" v-if="isAll">
        <div class="title">{{ $t('curriculumVitae:other:AH') }}</div>
        <div class="message">
          <span
            style="white-space: pre-wrap"
            v-html="
              isEN
                ? reviewerData.ResearchPublicationView.AwardsHonors
                : reviewerData.ResearchPublicationView.AwardsHonorsCN
            "
            v-if="
              reviewerData.ResearchPublicationView.AwardsHonors ||
              reviewerData.ResearchPublicationView.AwardsHonorsCN
            "
          ></span>
          <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
        </div>
      </div>
      <div class="message" v-if="isAll">
        <div class="title">{{ $t('curriculumVitae:pay:title') }}</div>
        <div class="content">
          <el-form :inline="true" class="demo-form-inline">
            <el-form-item
              :label="$t('curriculumVitae:pay:form:payCardId')"
              style="width: 45%"
            >
              {{ reviewerData.PaymentModeInfo.BankNum }}
            </el-form-item>
            <el-form-item
              :label="$t('curriculumVitae:pay:form:username')"
              style="width: 45%"
            >
              {{ reviewerData.PaymentModeInfo.BankName }}
            </el-form-item>
            <el-form-item
              :label="$t('curriculumVitae:pay:form:bank')"
              style="width: 45%"
            >
              {{ reviewerData.PaymentModeInfo.OpeningBank }}
            </el-form-item>
            <el-form-item
              :label="$t('curriculumVitae:pay:form:idCard')"
              style="width: 45%"
            >
              {{ reviewerData.PaymentModeInfo.IdCard }}
            </el-form-item>
            <el-form-item
              :label="$t('curriculumVitae:pay:form:phone')"
              style="width: 45%"
            >
              {{ reviewerData.PaymentModeInfo.BankPhoneNum }}
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
    <div class="file" v-if="isAll && hasFile">
      <div
        class="curriculum"
        v-if="
          (resumeListCN && resumeListCN.length > 0) ||
          (resumeListEN && resumeListEN.length > 0)
        "
      >
        <div class="title">{{ $t('curriculumVitae:curriculum:title') }}</div>
        <div class="fileBox">
          <div
            class="file_title"
            v-if="resumeListCN && resumeListCN.length > 0"
          >
            {{ $t('curriculumVitae:curriculum:fileTitle:CN') }}
          </div>
          <template v-if="true">
            <div class="file" v-for="item in resumeListCN" :key="item.Id">
              <div class="name" :title="item.FileName">{{ item.FileName }}</div>
              <i
                class="el-icon-download"
                :title="$t('common:button:download')"
                @click.stop="handlePreview(item)"
              />
            </div>
          </template>
          <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
          <div
            class="file_title"
            v-if="resumeListEN && resumeListEN.length > 0"
          >
            {{ $t('curriculumVitae:curriculum:fileTitle:EN') }}
          </div>
          <template v-if="true">
            <div class="file" v-for="item in resumeListEN" :key="item.FileName">
              <div class="name" :title="item.FileName">{{ item.FileName }}</div>
              <i
                class="el-icon-download"
                :title="$t('common:button:download')"
                @click.stop="handlePreview(item)"
              />
            </div>
          </template>
          <div class="noData" v-else>{{ $t('curriculumVitae:noData') }}</div>
        </div>
      </div>
      <div
        class="certificate"
        v-if="
          diplomaFile ||
          certificateFile ||
          licenseFile ||
          (workPermitFiles && workPermitFiles.length > 0)
        "
      >
        <div class="title">{{ $t('curriculumVitae:certificate:title') }}</div>
        <div class="fileBox">
          <!--最高医学学位毕业证书-->
          <div class="file_title" v-if="diplomaFile">
            {{ $t('curriculumVitae:certificate:fileTitle:diploma') }}
          </div>
          <div class="file" v-if="diplomaFile">
            <div class="name" :title="diplomaFile.FileName">
              {{ diplomaFile.FileName }}
            </div>
            <i
              class="el-icon-view"
              :title="$t('common:button:preview')"
              @click.stop="preview(diplomaFile)"
            />
          </div>
          <!--医师资格证-->
          <div class="file_title" v-if="certificateFile">
            {{ $t('curriculumVitae:certificate:fileTitle:certificate') }}
          </div>
          <div class="file" v-if="certificateFile">
            <div class="name" :title="certificateFile.FileName">
              {{ certificateFile.FileName }}
            </div>
            <i
              class="el-icon-view"
              :title="$t('common:button:preview')"
              @click.stop="preview(certificateFile)"
            />
          </div>
          <!--医师执业证-->
          <div class="file_title" v-if="licenseFile">
            {{ $t('curriculumVitae:certificate:fileTitle:license') }}
          </div>
          <div class="file" v-if="licenseFile">
            <div class="name" :title="licenseFile.FileName">
              {{ licenseFile.FileName }}
            </div>
            <i
              class="el-icon-view"
              :title="$t('common:button:preview')"
              @click.stop="preview(licenseFile)"
            />
          </div>
          <!--大型医用设备上岗证-->
          <div class="file_title">
            {{ $t('curriculumVitae:certificate:fileTitle:workPermit') }}
          </div>
          <template v-if="workPermitFiles && workPermitFiles.length > 0">
            <div class="file_title">
              {{ $t('curriculumVitae:certificate:fileTitle:CT') }}
            </div>
            <div v-for="item in workPermitFiles" :key="item.Id">
              <div class="file">
                <div class="name" :title="item.FileName">
                  {{ item.FileName }}
                </div>
                <i
                  class="el-icon-view"
                  :title="$t('common:button:preview')"
                  @click.stop="preview(item)"
                />
              </div>
            </div>
          </template>
        </div>
      </div>
      <div
        class="agreement"
        v-if="
          (sowList && sowList.length > 0) ||
          (CounselorFiles && CounselorFiles.length > 0) ||
          (ackSowList && ackSowList.length > 0)
        "
      >
        <div class="title">{{ $t('curriculumVitae:agreement:title') }}</div>
        <div class="fileBox">
          <div class="file_title" v-if="sowList && sowList.length > 0">
            {{ $t('curriculumVitae:agreement:fileTitle') }}
          </div>
          <template v-if="sowList && sowList.length > 0">
            <div class="file" v-for="item in sowList" :key="item.Id">
              <div class="name" :title="item.FileName">{{ item.FileName }}</div>
              <i
                class="el-icon-view"
                :title="$t('common:button:preview')"
                @click.stop="handlePreview(item, true)"
              />
            </div>
          </template>
          <template v-if="CounselorFiles && CounselorFiles.length > 0">
            <div class="file_title">
              {{ $t('curriculumVitae:agreement:Counselor') }}
            </div>
            <div class="file" v-for="item in CounselorFiles" :key="item.Id">
              <div class="name" :title="item.FileName">{{ item.FileName }}</div>
              <i
                class="el-icon-view"
                :title="$t('common:button:preview')"
                @click.stop="preview(item)"
              />
            </div>
          </template>
          <template v-if="ackSowList && ackSowList.length > 0">
            <div class="file_title">
              {{ $t('curriculumVitae:agreement:confirmation') }}
            </div>
            <div class="file" v-for="item in ackSowList" :key="item.Id">
              <div class="name" :title="item.FileName">{{ item.FileName }}</div>
              <i
                class="el-icon-view"
                :title="$t('common:button:preview')"
                @click.stop="handlePreview(item, true)"
              />
            </div>
          </template>
        </div>
      </div>
    </div>
    <holiday
      v-if="holidayVisible"
      isPreview
      :reviewerId.sync="reviewerId"
      :visible.sync="holidayVisible"
    />
  </div>
</template>
<script>
import {
  getDetail,
  getIsVacation,
  getDoctorCriterionFile,
} from '@/api/reviewers'
import { getAttachmentByType } from '@/api/attachment'
import holiday from './components/info/holiday.vue'
export default {
  name: 'curriculumVitaePreview',
  components: { holiday },
  props: {
    isAll: {
      type: Boolean,
      default: true,
    },
    reviewerId: {
      type: String,
      default: '',
    },
    trialId: {
      type: String,
      default: '',
    },
    isEN: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      reviewerData: {
        BasicInfoView: {},
        EmploymentView: {},
        AckSowList: [],
        AttachmentList: [],
        AuditView: {},
        EducationList: [],
        IntoGroupInfo: {},
        PaymentModeInfo: {},
        PostgraduateList: [],
        ResearchPublicationView: {},
        SowList: [],
        SpecialtyView: {},
        SummarizeInfo: {},
        TrialExperienceView: {},
      },
      resumeList: [],
      resumeListEN: [],
      resumeListCN: [],
      sowList: [],
      ackSowList: [],
      loading: false,

      holidayVisible: false,
      InHoliday: '',
    }
  },
  computed: {
    mainSummarize() {
      if (
        Array.isArray(this.reviewerData.SummarizeInfo.SummarizeList) &&
        this.trialId
      ) {
        return this.reviewerData.SummarizeInfo.SummarizeList[0] || {}
      }
      if (Array.isArray(this.reviewerData.SummarizeInfo.SummarizeList)) {
        return (
          this.reviewerData.SummarizeInfo.SummarizeList.find(
            (item) => item.IsMain
          ) || {}
        )
      }
      return {}
    },
    hasFile() {
      return (
        (this.sowList && this.sowList.length > 0) ||
        (this.CounselorFiles && this.CounselorFiles.length > 0) ||
        (this.ackSowList && this.ackSowList.length > 0) ||
        this.diplomaFile ||
        this.certificateFile ||
        this.licenseFile ||
        (this.workPermitFiles && this.workPermitFiles.length > 0) ||
        (this.resumeListCN && this.resumeListCN.length > 0) ||
        (this.resumeListEN && this.resumeListEN.length > 0)
      )
    },
    GCPData() {
      if (!this.reviewerData.TrialExperienceView) return []
      return [
        {
          ExpiryDateStr: this.reviewerData.TrialExperienceView.ExpiryDateStr,
          FileName: this.reviewerData.TrialExperienceView.FileName,
          GCP: this.reviewerData.TrialExperienceView.GCP,
          GCPAgencies: this.reviewerData.TrialExperienceView.GCPAgencies,
          GCPFullPath: this.reviewerData.TrialExperienceView.GCPFullPath,
          GCPId: this.reviewerData.TrialExperienceView.GCPId,
          GCPTime: this.reviewerData.TrialExperienceView.GCPTime,
          Path: this.reviewerData.TrialExperienceView.Path,
          Type: this.reviewerData.TrialExperienceView.Type,
        },
      ]
    },
    //最高医学学位毕业证书
    diplomaFile() {
      if (
        !this.reviewerData.AttachmentList ||
        this.reviewerData.AttachmentList.length <= 0
      )
        return false
      return this.reviewerData.AttachmentList.find(
        (item) => item.Type === 'Diploma of the highest medical degree'
      )
    },
    //医师资格证
    certificateFile() {
      if (
        !this.reviewerData.AttachmentList ||
        this.reviewerData.AttachmentList.length <= 0
      )
        return false
      return this.reviewerData.AttachmentList.find(
        (item) => item.Type === 'Medical Qualification Certificate'
      )
    },
    //医师执业证
    licenseFile() {
      if (
        !this.reviewerData.AttachmentList ||
        this.reviewerData.AttachmentList.length <= 0
      )
        return false
      return this.reviewerData.AttachmentList.find(
        (item) => item.Type === 'Practice License'
      )
    },
    //大型医用设备上岗证
    workPermitFiles() {
      if (
        !this.reviewerData.AttachmentList ||
        this.reviewerData.AttachmentList.length <= 0
      )
        return false
      return this.reviewerData.AttachmentList.filter(
        (item) => item.Type && item.Type.indexOf('Modality Certificate') >= 0
      )
    },
    CounselorFiles() {
      if (
        !this.reviewerData.AttachmentList ||
        this.reviewerData.AttachmentList.length <= 0
      )
        return false
      return this.reviewerData.AttachmentList.filter(
        (item) => item.Type && item.Type.indexOf('Consultant Agreement') >= 0
      )
    },
  },
  mounted() {
    this.getDetail()
    this.getResumeList()
    this.initSowList()
    this.getIsVacation()
  },
  methods: {
    // 获取是否休假
    async getIsVacation() {
      try {
        let data = {
          DoctorId: this.reviewerId,
        }
        let res = await getIsVacation(data)
        if (res.IsSuccess) {
          this.InHoliday = res.Result.IsVacation ? 'Yes' : 'No'
        }
      } catch (err) {
        console.log(err)
      }
    },
    // 获取详情
    async getDetail() {
      try {
        let id = this.reviewerId
        this.loading = true
        let res = await getDetail(id, this.trialId)
        this.loading = false
        if (res.IsSuccess) {
          Object.keys(this.reviewerData).forEach((key) => {
            if (res.Result[key]) {
              this.reviewerData[key] = res.Result[key]
            }
          })
        }
      } catch (err) {
        this.loading = false
        console.log(err)
      }
    },
    getResumeList() {
      this.loading = true
      getAttachmentByType(this.reviewerId, 'Resume')
        .then((res) => {
          if (res.IsSuccess) {
            if (res.Result.length > 0) {
              this.resumeList = res.Result
              this.filterByLanguage()
            }
          }
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
    initSowList() {
      if (!this.reviewerId) return
      getDoctorCriterionFile({
        fileType: 0,
        DoctorId: this.reviewerId,
      }).then((res) => {
        this.sowList = res.Result
      })
      getDoctorCriterionFile({
        fileType: 1,
        DoctorId: this.reviewerId,
      }).then((res) => {
        this.ackSowList = res.Result
      })
    },
    filterByLanguage() {
      this.resumeListEN = []
      this.resumeListCN = []
      this.resumeList.map((resume) => {
        if (resume.Language === 2) {
          this.resumeListEN.push(resume)
        } else if (resume.Language === 1) {
          this.resumeListCN.push(resume)
        }
      })
    },
    handlePreview(row, isPreview = false) {
      if (isPreview) {
        this.preview(row)
      } else {
        if (row.FullPath || row.FilePath) {
          let path = row.FullPath || row.FilePath
          window.open(this.OSSclientConfig.basePath + path, '_blank')
        }
      }
    },
    preview(row) {
      let path = row.Path || row.FullPath || row.FilePath
      this.$preview({
        path: path,
        type: 'pdf',
        title: row.FileName,
      })
    },
    handleView() {
      this.holidayVisible = true
    },
  },
}
</script>
<style lang="scss" scoped>
.curriculumVitaePreview {
  display: flex;
  padding: 0 100px;
  justify-content: space-between;
  .title {
    font-size: 18px;
    border: none;
    background-color: transparent;
    font-weight: bold;
  }
  .message {
    padding: 20px 0;
    border-bottom: 1px solid #eee;
    word-wrap: break-word;
    .title {
      font-size: 14px;
      line-height: 30px;
      margin-bottom: 10px;
      font-weight: bold;
    }
    .text {
      color: #909399;
    }
    .content {
      background-color: #eee;
      padding: 10px;
      line-height: 30px;
      border-radius: 5px;
    }
  }
  .userInfo,
  .userTitle,
  .userTel {
    line-height: 30px;
    margin-bottom: 15px;
    span {
      margin-right: 20px;
      &:last-child {
        margin: 0;
      }
    }
    &:last-child {
      margin-bottom: 0;
    }
  }
  .userTitle,
  .userTel {
    span {
      display: inline-block;
      min-width: 80px;
      border-right: 1px solid #ddd;
      padding-right: 10px;
      &::before {
        margin-right: 5px;
      }
      &:last-child {
        border: none;
      }
    }
  }
}
.noFile {
  max-width: 1200px;
  margin: auto;
}
::v-deep .el-tag {
  margin-right: 10px;
  &:last-child {
    margin-right: 0;
  }
}
.info {
  width: 100%;
}
.allInfo {
  width: calc(100% - 300px);
}
.file {
  width: 300px;
  padding-left: 10px;
  ::v-deep .title {
    line-height: 50px;
    background-color: #fff;
    text-align: left;
    font-weight: bold;
  }
  ::v-deep .fileBox {
    background-color: #eee;
    padding: 10px;
    font-size: 14px;
    border-radius: 3px;
  }
  ::v-deep .file_title {
    line-height: 40px;
    font-weight: bold;
  }
  ::v-deep .btnBox {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
  }

  ::v-deep .file {
    width: 100%;
    display: flex;
    margin-bottom: 10px;
    .name {
      width: 70%;
      white-space: nowrap; /* 文本不会换行，会在同一行内继续，直到遇到<br>标签为止 */
      text-overflow: ellipsis; /* 当文本溢出包含它的容器时，显示省略号(...)来表示被截断的文本 */
      overflow: hidden; /* 隐藏溢出容器的文本 */
    }
    i {
      cursor: pointer;
      margin: 3px;
      color: #409eff;
    }
  }
}
break-word {
  display: inline-block;
  width: 100%;
  word-wrap: break-word;
}
.noData {
  color: #909399;
  text-align: center;
  font-size: 14px;
}
</style>