<script setup lang="ts">
import { ref } from "vue";
import request, { download } from '~/utils/request';

// #region (constant)
const TABLE_KEY = 'xtxm_id'
const URL_CUT = '/xdjx/xszhsz_xstjxm'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xxx_id': string; // 所属成绩报告单
  'xtxm_tjxmmc': string; // 体检项目名称
  'xtxm_tjxm_json': string; // 体检项目JSON
  'team_id': string; // 学期编号
  'team_name': string; // 学期名称
  'grade_id': string; // 年级编号
  'class_id': string; // 班号
  'grade_name': string; // 年级名称
  'cm_id': string; // 班级编号
}
// #endregion

// #region (variable)
const loading = ref(true)
// #endregion

// #region (props)
const props = defineProps<{
  aid: string,
}>()
// #endregion

function detailApi(_id: string) {
  return request({
    url: URL_CUT + '/detail',
    data: {
      [TABLE_KEY]: _id,
    }
  })
}

const detail_Data = ref<TYPE_TABLE_FIELD>()

// #region (page init)
async function init() {
  const res = await detailApi(props.aid)
  detail_Data.value = (res.data.one_info)
  loading.value = false
}
init()
// #endregion

</script>

<template>
  <div :loading="loading">
    <template v-if="detail_Data">
      <div class="flex">
        <div>所属成绩报告单</div><div>{{detail_Data.xxx_id}}</div>
      </div>
      <div class="flex">
        <div>体检项目名称</div><div>{{detail_Data.xtxm_tjxmmc}}</div>
      </div>
      <div class="flex">
        <div>体检项目JSON</div><div>{{detail_Data.xtxm_tjxm_json}}</div>
      </div>
      <div class="flex">
        <div>学期编号</div><div>{{detail_Data.team_id}}</div>
      </div>
      <div class="flex">
        <div>学期名称</div><div>{{detail_Data.team_name}}</div>
      </div>
      <div class="flex">
        <div>年级编号</div><div>{{detail_Data.grade_id}}</div>
      </div>
      <div class="flex">
        <div>班号</div><div>{{detail_Data.class_id}}</div>
      </div>
      <div class="flex">
        <div>年级名称</div><div>{{detail_Data.grade_name}}</div>
      </div>
      <div class="flex">
        <div>班级编号</div><div>{{detail_Data.cm_id}}</div>
      </div>
    </template>      
  </div>

</template>
