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

// #region (constant)
const TABLE_KEY = 'xsxk_id'
const URL_CUT = '/xdjx/stxkgl_kcxkgl'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xsxk_kcmc': string; // 课程名称
  'xsxk_kclx': string; // 课程类型
  'xsxk_rkjs': string; // 任课教师
  'team_id': string; // 学期编号
  'team_name': string; // 学期名称
  'grade_id': string; // 年级编号
  'grade_name': string; // 年级名称
  'xsxk_xkzt': string; // 选课状态
  'xsxk_kcsm': string; // 课程说明
  'xsxk_kcfm': string; // 课程封面
  'xsxk_kksj': string; // 开课时间
  'xsxk_jksj': string; // 结课时间
  'xsxk_kbrs': string; // 开班人数
  'xsxk_xkkssj': string; // 选课开始时间
  'xsxk_xkjssj': 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" class="flex flex-col h-full">
    <template v-if="detail_Data">
      <div class="flex flex-none">
        <!-- <div>课程名称</div> -->
        <div class="text-3xl">{{ detail_Data.xsxk_kcmc }}</div>
      </div>
      <div class="flex text-gray-500 flex-none py-2 flex-wrap">
        <div class="flex mr-30">
          <div>课程类型</div>
          <div>{{ detail_Data.xsxk_kclx }}</div>
        </div>
        <div class="flex mr-30">
          <div>任课教师：</div>
          <div>{{ detail_Data.xsxk_rkjs }}</div>
        </div>
        <!-- <div class="flex">
        <div>学期编号</div><div>{{detail_Data.team_id}}</div>
      </div> -->
        <div class="flex mr-30">
          <div>学期名称：</div>
          <div>{{ detail_Data.team_name }}</div>
        </div>
        <!-- <div class="flex">
        <div>年级编号</div><div>{{detail_Data.grade_id}}</div>
      </div> -->
        <div class="flex mr-30">
          <div>年级名称：</div>
          <div>{{ detail_Data.grade_name }}</div>
        </div>
        <!-- <div class="flex mr-30">
          <div>选课状态</div>
          <div>{{ detail_Data.xsxk_xkzt }}</div>
        </div> -->
        <!-- <div class="flex">
          <div>课程说明</div>
          <div>{{detail_Data.xsxk_kcsm}}</div>
        </div> -->
        <!-- <div class="flex">
          <div>课程封面</div>
          <div>{{detail_Data.xsxk_kcfm}}</div>
        </div> -->
        <div class="flex mr-30">
          <div>开课时间：</div>
          <div>{{ detail_Data.xsxk_kksj }}</div>
        </div>
        <div class="flex mr-30">
          <div>结课时间：</div>
          <div>{{ detail_Data.xsxk_jksj }}</div>
        </div>

        <div class="flex mr-30">
          <div>开班人数：</div>
          <div>{{ detail_Data.xsxk_kbrs }}</div>
        </div>
        <!-- <div class="flex mr-30">
          <div>选课开始时间：</div>
          <div>{{ detail_Data.xsxk_xkkssj }}</div>
        </div>
        <div class="flex">
          <div>选课结束时间：</div>
          <div>{{ detail_Data.xsxk_xkjssj }}</div>
        </div> -->
        <div class="flex">
          <div>选课时间：</div>
          <div>{{ detail_Data.xsxk_xkkssj }} - {{ detail_Data.xsxk_xkjssj }}</div>
        </div>
      </div>
      <div class="flex flex-auto bg-gray-100 text-gray-600 p-4 text-sm">
        <div class="flex">
          <div>课程说明</div>
          <div>{{ detail_Data.xsxk_kcsm }}</div>
        </div>
      </div>
    </template>
  </div>

</template>
