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

// #region (constant)
const TABLE_KEY = 'xhs_id'
const URL_CUT = '/xdhq/hqgl_sbsg'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xhs_zcmc': string; // 资产名称
  'xhs_ggxh': string; // 规格型号
  'xhs_zcfl': string; // 资产分类
  'xhs_zcfl_lj': string; // 资产分类路径
  'xhs_zcpc': string; // 资产批次
  'xhs_zcdj': string; // 单价
  'xhs_dw': string; // 单位
  'xhs_sl': string; // 数量
  'xhs_ssbm': string; // 所属部门
  'xhs_ssbm_lj': string; // 所属部门路径
  'xhs_zj': string; // 总价
  'xhs_gmsj': string; // 购买时间
  'xhs_spr': string; // 审批人
  'xhs_spr_uid': string; // 审批人ID
  'xhs_spzt': string; // 状态
  'xhs_xwhtl': 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.xhs_zcmc}}</div>
      </div>
      <div class="flex">
        <div>规格型号</div><div>{{detail_Data.xhs_ggxh}}</div>
      </div>
      <div class="flex">
        <div>资产分类</div><div>{{detail_Data.xhs_zcfl}}</div>
      </div>
      <div class="flex">
        <div>资产分类路径</div><div>{{detail_Data.xhs_zcfl_lj}}</div>
      </div>
      <div class="flex">
        <div>资产批次</div><div>{{detail_Data.xhs_zcpc}}</div>
      </div>
      <div class="flex">
        <div>单价</div><div>{{detail_Data.xhs_zcdj}}</div>
      </div>
      <div class="flex">
        <div>单位</div><div>{{detail_Data.xhs_dw}}</div>
      </div>
      <div class="flex">
        <div>数量</div><div>{{detail_Data.xhs_sl}}</div>
      </div>
      <div class="flex">
        <div>所属部门</div><div>{{detail_Data.xhs_ssbm}}</div>
      </div>
      <div class="flex">
        <div>所属部门路径</div><div>{{detail_Data.xhs_ssbm_lj}}</div>
      </div>
      <div class="flex">
        <div>总价</div><div>{{detail_Data.xhs_zj}}</div>
      </div>
      <div class="flex">
        <div>购买时间</div><div>{{detail_Data.xhs_gmsj}}</div>
      </div>
      <div class="flex">
        <div>审批人</div><div>{{detail_Data.xhs_spr}}</div>
      </div>
      <div class="flex">
        <div>审批人ID</div><div>{{detail_Data.xhs_spr_uid}}</div>
      </div>
      <div class="flex">
        <div>状态</div><div>{{detail_Data.xhs_spzt}}</div>
      </div>
      <div class="flex">
        <div>校务会讨论</div><div>{{detail_Data.xhs_xwhtl}}</div>
      </div>
    </template>      
  </div>

</template>
