<template>
  <base-model :config="model_cfg">
    <div slot="dialog-body">
      <el-table :data="modelList" style="width: 100%" height="300">
        <!--检查编号-->
        <el-table-column
          prop="StudyCode"
          :label="$t('trials:uploadImage:table:StudyCode')"
        />
        <!--检查类型-->
        <el-table-column
          prop="ModalityForEdit"
          :label="$t('trials:uploadImage:table:ModalityForEdit')"
          v-if="IsDicom"
        />
        <!--检查模态-->
        <el-table-column
          prop="Modalities"
          :label="$t('trials:uploadImage:table:Modalities')"
          v-if="IsDicom"
        />
        <!--检查部位-->
        <el-table-column
          prop="BodyPartForEdit"
          :label="$t('trials:uploadImage:table:BodyPartForEdit')"
          v-if="IsDicom"
        >
          <template slot-scope="scope">
            <span>{{
              $fd(
                'Bodypart',
                scope.row.BodyPartForEdit,
                'Code',
                { Bodypart: bodyPart },
                'Name'
              )
            }}</span>
          </template>
        </el-table-column>
        <!--序列数量-->
        <el-table-column
          prop="SeriesCount"
          :label="$t('trials:uploadImage:table:SeriesCount')"
          v-if="IsDicom"
        />
        <!--图像数量-->
        <el-table-column
          prop="InstanceCount"
          :label="$t('trials:uploadImage:table:InstanceCount')"
          v-if="IsDicom"
        />
        <!--检查时间-->
        <el-table-column
          prop="StudyTime"
          :label="$t('trials:uploadImage:table:StudyTime')"
          v-if="IsDicom"
          min-width="130"
        />
        <!--检查模态-->
        <el-table-column
          prop="Modality"
          :label="$t('trials:uploadImage:table:Modalities')"
          v-if="!IsDicom"
        />
        <!--检查部位-->
        <el-table-column
          prop="BodyPart"
          :label="$t('trials:uploadImage:table:BodyPartForEdit')"
          v-if="!IsDicom"
        >
          <template slot-scope="scope">
            <span>{{
              $fd(
                'Bodypart',
                scope.row.BodyPart,
                'Code',
                { Bodypart: bodyPart },
                'Name'
              )
            }}</span>
          </template>
        </el-table-column>
        <!--文件数量-->
        <el-table-column
          prop="FileCount"
          :label="$t('trials:uploadImage:table:FileCount')"
          v-if="!IsDicom"
        />
        <!--检查时间-->
        <el-table-column
          prop="ImageDate"
          :label="$t('trials:uploadImage:table:StudyTime')"
          v-if="!IsDicom"
          min-width="130"
        />
        <el-table-column
          :label="$t('common:action:action')"
          fixed="right"
          width="80"
        >
          <template slot-scope="scope">
            <!--预览--->
            <el-button
              circle
              icon="el-icon-view"
              :title="$t('trials:uploadImage:button:preview')"
              @click.stop="preview(scope.row)"
            />
          </template>
        </el-table-column>
      </el-table>
    </div>
  </base-model>
</template>
<script>
import baseModel from '@/components/BaseModel'
import { getToken } from '@/utils/auth'
export default {
  name: 'studyView',
  props: {
    model_cfg: {
      type: Object,
      default: () => {
        return {}
      },
    },
    bodyPart: {
      type: Array,
      default: () => {
        return []
      },
    },
    modelList: {
      type: Array,
      default: () => {
        return []
      },
    },
    visitTaskId: {
      type: String,
    },
    IsDicom: {
      required: true,
      type: Boolean,
      default: true,
    },
  },
  components: {
    'base-model': baseModel,
  },
  methods: {
    // 预览
    preview(row) {
      let routeData = null
      if (this.IsDicom) {
        var token = getToken()
        routeData = this.$router.resolve({
          path: `/showdicom?studyId=${row.Id}&TokenKey=${token}&type=Study&visitTaskId=${this.visitTaskId}`,
        })
      } else {
        let trialId = this.$route.query.trialId
        var token = getToken()
        routeData = this.$router.resolve({
          path: `/showNoneDicoms?trialId=${trialId}&subjectVisitId=${row.SourceSubjectVisitId}&studyId=${row.Id}&TokenKey=${token}`,
        })
      }
      window.open(routeData.href, '_blank')
    },
  },
}
</script>
<style lang="scss" scoped>
</style>