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

// #region (constant)
const TABLE_KEY = 'xwj_id'
const URL_CUT = '/xdjy/wljy_jpkc'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xwj_kcmc': string; // 课程名称
  'xwj_kt': string; // 课题
  'xwj_scr': string; // 上传人
  'xwj_ja': string; // 教案
  'xwj_xa': string; // 学案
  'xwj_jpksp': string; // 精品课视频
  'grade_id': string; // 年级编号
  'xwj_jxcg': string; // 教学成果
  'grade_name': string; // 年级名称
  'xwj_jxfs': string; // 教学反思
  'subject_id': string; // 学科编号
  'subject_name': 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">
        <!-- <div>课程名称</div> -->
        <div>{{ detail_Data.xwj_kcmc }}</div>
      </div>
      <div class="flex text-gray-500 justify-between flex-wrap py-2">
        <div class="flex">
          <div>课题：</div>
          <div>{{ detail_Data.xwj_kt }}</div>
        </div>
        <div class="flex">
          <div>上传人：</div>
          <div>{{ detail_Data.xwj_scr }}</div>
        </div>
        <!-- <div class="flex">
          <div>年级编号</div>
          <div>{{ detail_Data.grade_id }}</div>
        </div> -->
        <div class="flex">
          <div>年级名称：</div>
          <div>{{ detail_Data.grade_name }}</div>
        </div>
        <!-- <div class="flex">
          <div>学科编号</div>
          <div>{{ detail_Data.subject_id }}</div>
        </div> -->
        <div class="flex">
          <div>学科名称：</div>
          <div>{{ detail_Data.subject_name }}</div>
        </div>
      </div>


      <div class="flex flex-col mt-4">
        <div class="pre">教案</div>
        <!-- <div>{{detail_Data.xwj_ja}}</div> -->
        <file-link :file="detail_Data.xwj_ja"></file-link>
      </div>
      <div class="flex flex-col mt-4">
        <div class="pre">学案</div>
        <!-- <div>{{detail_Data.xwj_xa}}</div> -->
        <file-link :file="detail_Data.xwj_xa"></file-link>
      </div>
      <div class="flex flex-col mt-4">
        <div class="pre">精品课视频</div>
        <!-- <div>{{detail_Data.xwj_jpksp}}</div> -->
        <file-link :file="detail_Data.xwj_jpksp"></file-link>
      </div>

      <div class="flex flex-col mt-4">
        <div class="pre">教学成果</div>
        <div class="area h-200px">{{ detail_Data.xwj_jxcg }}</div>
      </div>

      <div class="flex flex-col mt-4">
        <div class="pre">教学反思</div>
        <div class="area h-200px">{{ detail_Data.xwj_jxfs }}</div>
      </div>

    </template>
  </div>

</template>
