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

// #region (constant)
const TABLE_KEY = 'xktj_id'
const URL_CUT = '/xdjx/kcpzgl_bbtj'
// #endregion

// #region (type)
type TYPE_TABLE_FIELD = {
  [TABLE_KEY]: string;
  'xktj_bbmc': string; // 报表名称
  'xktj_cjr': string; // 创建人
  'xktj_cjsj': string; // 创建时间
  'xktj_bbsz_json': string; // 报表设置JSON
}
// #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 mb-10">
        <!-- <div>报表名称</div> -->
        <div>{{ detail_Data.xktj_bbmc }}</div>
      </div>
      <!-- <div class="flex">
        <div>创建人</div><div>{{detail_Data.xktj_cjr}}</div>
      </div>
      <div class="flex">
        <div>创建时间</div><div>{{detail_Data.xktj_cjsj}}</div>
      </div>
      <div class="flex">
        <div>报表设置JSON</div><div>{{detail_Data.xktj_bbsz_json}}</div>
      </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.xktj_bbsz_json)}`"
          frameborder="0"></iframe>
      </div>
    </template>
  </div>

</template>
