detail.vue.hbs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import request, { download } from '~/utils/request';
  4. // #region (constant)
  5. const TABLE_KEY = '{{tableKey}}'
  6. const URL_CUT = '{{url}}'
  7. // #endregion
  8. // #region (type)
  9. type TYPE_TABLE_FIELD = {
  10. [TABLE_KEY]: string;
  11. {{#each tableColFields}}
  12. '{{prop}}': string; // {{label}}
  13. {{/each}}
  14. }
  15. // #endregion
  16. // #region (variable)
  17. const loading = ref(true)
  18. // #endregion
  19. // #region (props)
  20. {{#if props}}
  21. const props = defineProps<{
  22. {{#each props}}
  23. {{this}}: string,
  24. {{/each}}
  25. }>()
  26. {{/if}}
  27. // #endregion
  28. function detailApi(_id: string) {
  29. return request({
  30. url: URL_CUT + '/detail',
  31. data: {
  32. [TABLE_KEY]: _id,
  33. }
  34. })
  35. }
  36. const detail_Data = ref<TYPE_TABLE_FIELD>()
  37. // #region (page init)
  38. async function init() {
  39. const res = await detailApi(props.{{detailParam}})
  40. detail_Data.value = (res.data.one_info)
  41. loading.value = false
  42. }
  43. init()
  44. // #endregion
  45. </script>
  46. <template>
  47. <div :loading="loading">
  48. <template v-if="detail_Data">
  49. {{#each tableColFields}}
  50. <div class="flex">
  51. <div>{{label}}</div><div>{{> Mustache obj="detail_Data" }}</div>
  52. </div>
  53. {{/each}}
  54. </template>
  55. </div>
  56. </template>