LectureForm.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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.lectureName || '-' }}</text>
  11. </view>
  12. <view class="info-row">
  13. <text class="label">讲座类型</text>
  14. <text class="value">{{ getLecTypeLabel(form.lectureType) }}</text>
  15. </view>
  16. <view class="info-row">
  17. <text class="label">讲座日期</text>
  18. <text class="value">{{ form.lectureDate || '-' }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="label">讲座时间</text>
  22. <text class="value">{{ form.lectureStartTime || '-' }} 至 {{ form.lectureEndTime || '-' }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="label">参会申请人</text>
  26. <text class="value">{{ form.applicantName || '-' }}</text>
  27. </view>
  28. <view class="info-row">
  29. <text class="label">所属科室</text>
  30. <text class="value">{{ form.deptName || '-' }}</text>
  31. </view>
  32. <view class="info-row">
  33. <text class="label">讲座地点</text>
  34. <text class="value">{{ form.lectureAddress || '-' }}</text>
  35. </view>
  36. </view>
  37. <!-- 讲座细节 -->
  38. <view class="common-section-card mt20">
  39. <view class="section-title">讲座细节</view>
  40. <view class="info-row">
  41. <text class="label">主讲人职务</text>
  42. <text class="value">{{ form.lectureSpeakerDuties || '-' }}</text>
  43. </view>
  44. <view class="info-row">
  45. <text class="label">主讲人职称</text>
  46. <text class="value">{{ form.lectureSpeakerTitles || '-' }}</text>
  47. </view>
  48. <view class="info-row">
  49. <text class="label">主持人</text>
  50. <text class="value">{{ form.lectureHost || '-' }}</text>
  51. </view>
  52. <view class="info-row">
  53. <text class="label">嘉宾</text>
  54. <text class="value">{{ form.lectureGuests || '-' }}</text>
  55. </view>
  56. <view class="info-row column">
  57. <text class="label">主讲人学术简历</text>
  58. <text class="value remark">{{ form.lectureSpeakerResume || '-' }}</text>
  59. </view>
  60. <view class="info-row column">
  61. <text class="label">观点综述</text>
  62. <text class="value remark">{{ form.lectureOpinion || '-' }}</text>
  63. </view>
  64. </view>
  65. <!-- 相关附件 -->
  66. <view class="common-section-card mt20" v-if="attachment.url">
  67. <view class="section-title">相关附件</view>
  68. <view class="common-file-list">
  69. <view class="file-item" @click="previewFile(attachment.url, attachment.name)">
  70. <view class="file-info">
  71. <text class="f-name">{{ attachment.name }}</text>
  72. <view class="f-meta">
  73. <text class="f-type">相关文档</text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  81. </view>
  82. </template>
  83. <script setup lang="ts">
  84. import { ref, onMounted, watch, computed } from 'vue';
  85. import { useDocumentApi } from '@/api/document';
  86. import { previewFile } from '@/utils/file';
  87. import to from 'await-to-js';
  88. const props = defineProps<{
  89. code: string;
  90. }>();
  91. const documentApi = useDocumentApi();
  92. const form = ref<any>(null);
  93. const loading = ref(false);
  94. const LecTypeList = [
  95. { value: '10', label: '学校会议' },
  96. { value: '20', label: '省级会议' },
  97. { value: '30', label: '国内学术会议' },
  98. { value: '40', label: '国际学术会议' }
  99. ];
  100. const getLecTypeLabel = (value: string | number) => {
  101. const item = LecTypeList.find(i => i.value === String(value));
  102. return item ? item.label : (value || '-');
  103. };
  104. const attachment = computed(() => {
  105. if (!form.value || !form.value.lectureDocument) return { name: '', url: '' };
  106. try {
  107. const file = JSON.parse(form.value.lectureDocument);
  108. return {
  109. name: file.fileName || '讲座相关附件',
  110. url: file.lectureDocument || ''
  111. };
  112. } catch (e) {
  113. console.error('Failed to parse lectureDocument JSON', e);
  114. return { name: '附件', url: form.value.lectureDocument };
  115. }
  116. });
  117. const fetchData = async () => {
  118. if (!props.code) return;
  119. loading.value = true;
  120. const [err, res] = await to(documentApi.getLectureById(props.code));
  121. if (!err && res?.data) {
  122. form.value = res.data;
  123. }
  124. loading.value = false;
  125. };
  126. onMounted(() => {
  127. fetchData();
  128. });
  129. watch(() => props.code, () => {
  130. fetchData();
  131. });
  132. </script>
  133. <style lang="scss" scoped>
  134. @import "./common.scss";
  135. </style>