DisciplineForm.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="document-form">
  3. <uv-loading-icon v-if="loading" mode="circle" text="正在加载详情..."></uv-loading-icon>
  4. <template v-else-if="form">
  5. <!-- 基本信息 -->
  6. <view class="common-section-card">
  7. <view class="section-title">基本信息</view>
  8. <view class="info-row">
  9. <text class="label">学科名称</text>
  10. <text class="value">{{ form.disciplineTitle || '-' }}</text>
  11. </view>
  12. <view class="info-row">
  13. <text class="label">申报级别</text>
  14. <text class="value">{{ getDictLabel('sci_pjt_level', form.declarationLevel) }}</text>
  15. </view>
  16. <view class="info-row">
  17. <text class="label">项目来源</text>
  18. <text class="value">{{ form.projectSource || '-' }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="label">申报类别</text>
  22. <text class="value">{{ getDictLabel('sci_pjt_type', form.declarationType) }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="label">开始日期</text>
  26. <text class="value">{{ form.startDate || '-' }}</text>
  27. </view>
  28. <view class="info-row">
  29. <text class="label">完成日期</text>
  30. <text class="value">{{ form.endDate || '-' }}</text>
  31. </view>
  32. <view class="info-row">
  33. <text class="label">研究方向</text>
  34. <text class="value">{{ form.researchDirection || '-' }}</text>
  35. </view>
  36. <view class="info-row">
  37. <text class="label">评分模板</text>
  38. <text class="value">{{ currentTemplateName || '-' }}</text>
  39. </view>
  40. </view>
  41. </template>
  42. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  43. </view>
  44. </template>
  45. <script setup lang="ts">
  46. import { ref, onMounted, watch, computed } from 'vue';
  47. import { useDict } from '@/hooks/useDict';
  48. import { useDocumentApi } from '@/api/document';
  49. import to from 'await-to-js';
  50. const props = defineProps<{
  51. code: string;
  52. }>();
  53. const { getDictLabel } = useDict('sci_pjt_level', 'sci_pjt_type');
  54. const documentApi = useDocumentApi();
  55. const form = ref<any>(null);
  56. const tmplOptions = ref<any[]>([]);
  57. const loading = ref(false);
  58. const currentTemplateName = computed(() => {
  59. if (form.value?.gradeTemplateName) return form.value.gradeTemplateName;
  60. if (!form.value?.gradeTemplateId) return '';
  61. const item = tmplOptions.value.find(t => t.id === form.value.gradeTemplateId);
  62. return item ? item.name : form.value.gradeTemplateId;
  63. });
  64. const fetchData = async () => {
  65. if (!props.code) return;
  66. loading.value = true;
  67. // 1. 获取学科详情
  68. const [err, res] = await to(documentApi.getDisciplineByCode(props.code));
  69. if (!err && res?.data) {
  70. form.value = res.data;
  71. }
  72. // 2. 获取评价模板列表(用于翻译ID)
  73. const [tErr, tRes] = await to(documentApi.getDisciplineTmplList());
  74. if (!tErr && tRes?.data?.list) {
  75. tmplOptions.value = tRes.data.list;
  76. }
  77. loading.value = false;
  78. };
  79. onMounted(() => {
  80. fetchData();
  81. });
  82. watch(() => props.code, () => {
  83. fetchData();
  84. });
  85. </script>
  86. <style lang="scss" scoped>
  87. @import "./common.scss";
  88. </style>