<template>
  <div class="currentStudy">
    <div class="functions" style="text-align: right">
      <!-- 预览 -->
      <!-- <el-button
        type="primary"
        size="small"
        :disabled="list.length === 0"
        icon="el-icon-view"
        @click="handlePreviewAllFiles"
      >
        {{ $t("trials:uploadedDicoms:action:preview") }}
      </el-button> -->
    </div>
    <!--当前检查--->
    <div class="topTable">
      <!--当前检查列表  @selection-change="handleSelectChange"--->
      <el-table
        ref="addTrialsList"
        v-loading="loading"
        :data="list"
        stripe
        v-adaptive="{ bottomOffset: 60 }"
        height="300"
        :default-sort="{ prop: 'StudyTime', order: 'descending' }"
      >
        <!-- <el-table-column type="selection" align="center" width="45" /> -->
        <!--患者编号-->
        <el-table-column
          align="center"
          prop="PatientIdStr"
          :label="$t('trials:uploadDicomList:table:pId')"
          sortable
          show-overflow-tooltip
        ></el-table-column>
        <!-- 患者姓名 -->
        <el-table-column
          prop="PatientName"
          :label="$t('trials:uploadDicomList:table:patientName')"
          min-width="80"
          sortable
          show-overflow-tooltip
        />
        <!--检查描述-->
        <el-table-column
          align="center"
          prop="Description"
          :label="$t('trials:inspection:table:studyDescription')"
          show-overflow-tooltip
          sortable
          min-width="100"
        ></el-table-column>
        <!--检查类型-->
        <el-table-column
          align="center"
          prop="Modalities"
          :label="$t('trials:audit:table:modality')"
          sortable
          show-overflow-tooltip
        ></el-table-column>
        <!--序列数量-->
        <el-table-column
          align="center"
          prop="SeriesCount"
          :label="$t('trials:audit:table:seriesCount')"
          sortable
          show-overflow-tooltip
        ></el-table-column>
        <!--图像数量-->
        <el-table-column
          align="center"
          prop="InstanceCount"
          :label="$t('trials:audit:table:instanceCount')"
          sortable
          show-overflow-tooltip
        ></el-table-column>
        <!--检查日期-->
        <el-table-column
          align="center"
          prop="StudyTime"
          :label="$t('trials:audit:table:studyDate')"
          sortable
          show-overflow-tooltip
        ></el-table-column>
        <!--所属访视-->
        <el-table-column
          align="center"
          prop="VisitName"
          :label="$t('trials:hirVisit:table:ownershipVisit')"
          sortable
          show-overflow-tooltip
        ></el-table-column>
        <!--操作-->
        <el-table-column
          :label="$t('common:action:action')"
          width="300"
          class-name="actionBox"
        >
          <template slot-scope="scope">
            <!-- 预览 -->
            <el-button
              icon="el-icon-view"
              :disabled="scope.row.SeriesCount === 0 || scope.row.IsDeleted"
              :title="$t('trials:uploadedDicoms:action:preview')"
              circle
              @click="handleViewStudy(scope.row)"
            />
            <!-- 诊断报告 -->
            <el-button
              icon="el-icon-document"
              v-hasPermi="['trials:trials-panel:hirVisit:result']"
              disabled
              :title="$t('trials:inspection:button:diagnosticReport')"
              circle
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { getCurrentVisitPatientStudyList } from "@/api/trials/visit.js";
import { getToken } from "@/utils/auth";
export default {
  name: "currentStudy",
  props: {
    data: {
      required: true,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 当前检查列表
      list: [],
      loading: false,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 获取当前检查列表
    async getList() {
      try {
        let data = {
          SujectVisitId: this.data.SubjectVisitId,
        };
        this.loading = true;
        let res = await getCurrentVisitPatientStudyList(data);
        this.loading = false;
        if (res.IsSuccess) {
          this.list = res.Result;
        }
      } catch (err) {
        this.loading = false;
        console.log(err);
      }
    },
    // 预览所有影像
    handlePreviewAllFiles() {
      var tokenKey = getToken();
      const routeData = this.$router.resolve({
        path: `/showvisitdicoms?trialId=${this.data.TrialId}&visitInfo=${this.data.VisitName}(${this.data.VisitNum})&subjectVisitId=${this.data.Id}&TokenKey=${tokenKey}`,
      });
      var newWindow = window.open(routeData.href, "_blank");
      this.$emit("setOpenWindow", newWindow);
      this.$setOpenWindow(newWindow);
    },
    // 预览影像
    handleViewStudy(row) {
      var token = getToken();
      const routeData = this.$router.resolve({
        path: `/showdicom?studyId=${row.SCPStudyId}&TokenKey=${token}&type=Patient`,
      });
      var newWindow = window.open(routeData.href, "_blank");
      this.$emit("setOpenWindow", newWindow);
      this.$setOpenWindow(newWindow);
    },
  },
};
</script>
<style lang="scss" scoped>
.currentStudy {
  .delete-row {
    text-decoration-line: line-through;
    color: #c0c4cc;
  }
}
</style>