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

// #region (constant)
const TABLE_KEY = 'xkx_id'
const URL_CUT = '/xdjx/kbgl_xxzkb'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xkx_kbmc': string; // 课表名称
  'team_id': string; // 学期编号
  'team_name': string; // 学期名称
  'xkk_id': string; // 课表类型编号
  'xkk_kblxmc': string; // 课表类型名称
  'xkx_scr': string; // 上传人
  'xkx_kbxq_json': string; // 课表详情JSON
  'xkx_xls': string; // 课表文件
  'xkx_img': 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 text-3xl flex-none">
        <!-- <div>课表名称</div> -->
        <div>{{ detail_Data.xkx_kbmc }}</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.xkk_id}}</div>
      </div>
      <div class="flex">
        <div>课表类型名称</div><div>{{detail_Data.xkk_kblxmc}}</div>
      </div>
      <div class="flex">
        <div>上传人</div><div>{{detail_Data.xkx_scr}}</div>
      </div>
      <div class="flex">
        <div>课表详情JSON</div><div>{{detail_Data.xkx_kbxq_json}}</div>
      </div> -->
      <div class="flex my-4 flex-none">
        <div>课表文件：</div>
        <file-link :file="detail_Data.xkx_xls" />
      </div>

      <!-- <div class="w-full flex-grow">
        <!~~ <img class="w-full" :src="handleImageUrl(detail_Data?.xkx_img)" alt=""> ~~>
        <iframe class="w-full h-700px"
          :src="`https://view.officeapps.live.com/op/view.aspx?src=${handleImageUrl(detail_Data.xkx_xls)}`"
          frameborder="0"></iframe>
      </div> -->


    </template>
  </div>
</template>
