<template>
  <div class="trial-information">
    <el-descriptions :column="2" border style="width: 1000px">
      <!--项目编号-->
      <el-descriptions-item :label="$t('trials:trials-list:form:trialId')">
        {{ trialInfo.TrialCode }}
        <el-tag
          v-show="trialInfo.TrialStatusStr"
          size="small"
          style="margin-left: 10px"
        >
          ( {{ $fd("TrialStatusEnum", trialInfo.TrialStatusStr) }} )
        </el-tag>
      </el-descriptions-item>
      <!--项目类型-->
      <el-descriptions-item :label="$t('trials:trials-list:form:trialType')">
        {{ $fd("TrialType", trialInfo.TrialType) }}
      </el-descriptions-item>
      <!--试验名称-->
      <el-descriptions-item
        :label="$t('trials:trials-list:form:experimentName')"
      >
        {{ trialInfo.ExperimentName }}
      </el-descriptions-item>
      <!--研究方案号-->
      <el-descriptions-item
        :label="$t('trials:trials-list:form:researchNumber')"
      >
        {{ trialInfo.ResearchProgramNo }}
      </el-descriptions-item>
      <!--主要研究者-->
      <el-descriptions-item :label="$t('trials:trials-list:form:pi')">
        {{ trialInfo.HeadPI }}
      </el-descriptions-item>
      <!--申办方-->
      <el-descriptions-item :label="$t('trials:trials-list:form:sponsor')">
        {{ trialInfo.Sponsor }}
      </el-descriptions-item>
      <!--CRO-->
      <el-descriptions-item :label="$t('trials:trials-list:form:cro')">
        {{ trialInfo.CRO }}
      </el-descriptions-item>
      <!--药物/器械名称-->
      <el-descriptions-item :label="$t('trials:trials-list:message:D/Dname')">
        {{ trialInfo.MedicineName }}
      </el-descriptions-item>
      <!--临床分期-->
      <el-descriptions-item :label="$t('trials:trials-list:form:phase')">
        {{ $fd("Trial_Phase", trialInfo.PhaseId, "id") }}
      </el-descriptions-item>
      <!--适应症-->
      <el-descriptions-item :label="$t('trials:trials-list:form:indication')">
        {{ trialInfo.Indication }}
      </el-descriptions-item>
      <!--检查技术-->
      <el-descriptions-item :label="$t('trials:trials-list:form:modality')">
        {{
          trialInfo.ModalityIds
            ? trialInfo.ModalityIds.map((item) =>
                $fd("Modality", item, "id")
              ).join(", ")
            : ""
        }}
      </el-descriptions-item>
      <!--阅片标准-->
      <el-descriptions-item
        :span="2"
        :label="$t('trials:trials-list:form:criterion')"
      >
        {{
          trialInfo.CriterionTypeList
            ? trialInfo.CriterionTypeList.map((item) =>
                $fd("CriterionType", item)
              ).join(", ")
            : ""
        }}
      </el-descriptions-item>
      <!--联系人-->
      <el-descriptions-item
        :label="$t('trials:researchRecord:table:contactor')"
      >
        {{ trialInfo.ContactUser }}
      </el-descriptions-item>
      <!--电话-->
      <el-descriptions-item :label="$t('trials:trials-myinfo:form:phone')">
        {{ trialInfo.ContactPhone }}
      </el-descriptions-item>
      <!--项目周期-->
      <el-descriptions-item :label="$t('trials:trials-list:form:projectCycle')">
        {{ trialInfo.AuthorizationDuration }}
      </el-descriptions-item>
      <!--授权日期-->
      <el-descriptions-item
        :label="$t('trials:trials-list:table:dateAuthorized')"
      >
        {{ trialInfo.AuthorizationDate }}
      </el-descriptions-item>
    </el-descriptions>
    <div v-if="otherInfo && otherInfo.TrialId">
      <p>项目授权信息</p>
      <el-descriptions :column="2" border style="width: 1000px">
        <!--单位名称-->
        <el-descriptions-item
          :label="$t('trials:trials-list:activate:organizationName')"
        >
          {{ otherInfo.HospitalName }}
        </el-descriptions-item>
        <!--项目编号-->
        <el-descriptions-item :label="$t('trials:trials-list:table:trialId')">
          {{ otherInfo.TrialCode }}
        </el-descriptions-item>
        <!--评估标准-->
        <el-descriptions-item
          :label="$t('trials:trials-list:activate:evaluationCriteria')"
        >
          {{
            otherInfo.CriterionTypeList.map((item) =>
              $fd("CriterionType", Number(item))
            ).join(",")
          }}
        </el-descriptions-item>
        <!--授权时长-->
        <el-descriptions-item
          :label="$t('trials:trials-list:activate:durationAuthorized')"
        >
          {{ otherInfo.PurchaseDuration }}
        </el-descriptions-item>
      </el-descriptions>
      <el-button
        type="primary"
        size="small"
        style="margin-top: 10px"
        @click.stop="putActivate"
        >{{ $t("trials:activate:renewalAuthorization") }}</el-button
      >
    </div>
    <activate-project
      v-if="activateVisible"
      :visible.sync="activateVisible"
      :data="otherInfo"
      @getList="initForm"
    />
  </div>
</template>
<script>
import { getTrialInfoHir } from "@/api/trials";
import activateProject from "@/views/trials/trials-list/components/activate-project.vue";
export default {
  components: { "activate-project": activateProject },
  data() {
    return {
      trialInfo: {},
      trialId: "",
      trialStatus: "",
      formLoading: false,
      otherInfo: {},
      activateVisible: false,
    };
  },
  mounted() {
    this.trialId = this.$route.query.trialId;
    this.initForm();
  },
  methods: {
    // 更新授权
    putActivate() {
      this.activateVisible = true;
    },
    initForm() {
      this.formLoading = true;
      getTrialInfoHir(this.trialId)
        .then((res) => {
          this.formLoading = false;
          this.otherInfo = res.OtherInfo;
          this.trialInfo = res.Result;
          this.trialInfo.ReviewTypeList =
            this.trialInfo.ReviewTypeList.length > 0
              ? this.trialInfo.ReviewTypeList.join(", ")
              : "";
          var modalityArr = [];
          res.Result.ModalityIds.map((i) => {
            modalityArr.push(this.$fd("Modality", i, "id"));
          });
          this.trialInfo.ModalityList = modalityArr.join(", ");
          this.trialInfo.Criterion =
            res.Result.CriterionList && res.Result.CriterionList.length > 0
              ? res.Result.CriterionList.join(", ")
              : "";
          // this.trialInfo.Expedited = this.$fd('Trial_BasicInfo', res.Result.Expedited)
          // this.trialInfo.AttendedReviewerType = this.$fd('Trial_BasicInfo', res.Result.AttendedReviewerType)
        })
        .catch(() => {
          this.formLoading = false;
        });
    },
  },
};
</script>
<style lang="scss">
.trial-information {
  height: 100%;
  padding: 10px 0 0 10px;
  background: #fff;
}
</style>
