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

// #region (constant)
const TABLE_KEY = 'xss_id'
const URL_CUT = '/xdjx/stxkgl_skdm'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xss_mc': string; // 名称
  'xss_dmsj': string; // 点名时间
  'xss_dmsc': string; // 点名时长
  'xss_qkrs': string; // 缺课人数
  'xss_qkrs_json': string; // 缺课人数JSON
  'xsxk_id': string; // 所属课程编号
}
// #endregion

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

// #region (props)
const props = defineProps<{
  aid: string,
  bid: 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.bid)
  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.xss_mc}}</div>
      </div>
      <div class="flex">
        <div>点名时间</div><div>{{detail_Data.xss_dmsj}}</div>
      </div>
      <div class="flex">
        <div>点名时长</div><div>{{detail_Data.xss_dmsc}}</div>
      </div>
      <div class="flex">
        <div>缺课人数</div><div>{{detail_Data.xss_qkrs}}</div>
      </div>
      <div class="flex">
        <div>缺课人数JSON</div><div>{{detail_Data.xss_qkrs_json}}</div>
      </div>
      <div class="flex">
        <div>所属课程编号</div><div>{{detail_Data.xsxk_id}}</div>
      </div>
    </template>      
  </div>

</template>
