LectureForm.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. <CommonSection title="基本信息" :isFirst="true">
  7. <CommonInfoRow label="讲座名称" :value="form.lectureName" />
  8. <CommonInfoRow label="讲座类型" :value="getLecTypeLabel(form.lectureType)" />
  9. <CommonInfoRow label="讲座日期" :value="formatDate(form.lectureDate)" />
  10. <CommonInfoRow label="讲座时间" :value="formatDate(form.lectureStartTime) + ' 至 ' + formatDate(form.lectureEndTime)" />
  11. <CommonInfoRow label="参会申请人" :value="form.applicantName" />
  12. <CommonInfoRow label="所属科室" :value="form.deptName" />
  13. <CommonInfoRow label="讲座地点" :value="form.lectureAddress" />
  14. </CommonSection>
  15. <!-- 讲座细节 -->
  16. <CommonSection title="讲座细节">
  17. <CommonInfoRow label="主讲人职务" :value="form.lectureSpeakerDuties" />
  18. <CommonInfoRow label="主讲人职称" :value="form.lectureSpeakerTitles" />
  19. <CommonInfoRow label="主持人" :value="form.lectureHost" />
  20. <CommonInfoRow label="嘉宾" :value="form.lectureGuests" />
  21. <CommonInfoRow label="主讲人学术简历" :value="form.lectureSpeakerResume" isColumn />
  22. <CommonInfoRow label="观点综述" :value="form.lectureOpinion" isColumn />
  23. </CommonSection>
  24. <!-- 相关附件 -->
  25. <AttachmentList :list="attachmentList" title="相关附件" />
  26. </template>
  27. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  28. </view>
  29. </template>
  30. <script setup lang="ts">
  31. import { ref, onMounted, watch, computed } from 'vue';
  32. import { useDocumentApi } from '@/api/document';
  33. import { formatDate } from '@/utils/date';
  34. import to from 'await-to-js';
  35. import CommonSection from '@/components/ui/CommonSection.vue';
  36. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  37. import AttachmentList from './AttachmentList.vue';
  38. const props = defineProps<{
  39. code: string;
  40. }>();
  41. const documentApi = useDocumentApi();
  42. const form = ref<any>(null);
  43. const loading = ref(false);
  44. const LecTypeList = [
  45. { value: '10', label: '学校会议' },
  46. { value: '20', label: '省级会议' },
  47. { value: '30', label: '国内学术会议' },
  48. { value: '40', label: '国际学术会议' }
  49. ];
  50. const getLecTypeLabel = (value: string | number) => {
  51. const item = LecTypeList.find(i => i.value === String(value));
  52. return item ? item.label : (value || '-');
  53. };
  54. const attachmentList = computed(() => {
  55. if (!form.value || !form.value.lectureDocument) return [];
  56. try {
  57. const file = JSON.parse(form.value.lectureDocument);
  58. return [{
  59. name: file.fileName || '讲座相关附件',
  60. url: file.lectureDocument || '',
  61. type: '相关文档'
  62. }];
  63. } catch (e) {
  64. return [{
  65. name: '附件',
  66. url: form.value.lectureDocument,
  67. type: '相关文档'
  68. }];
  69. }
  70. });
  71. const fetchData = async () => {
  72. if (!props.code) return;
  73. loading.value = true;
  74. const [err, res] = await to(documentApi.getLectureById(props.code));
  75. if (!err && res?.data) {
  76. form.value = res.data;
  77. }
  78. loading.value = false;
  79. };
  80. onMounted(() => {
  81. fetchData();
  82. });
  83. watch(() => props.code, () => {
  84. fetchData();
  85. });
  86. </script>
  87. <style lang="scss" scoped>
  88. @import "./common.scss";
  89. </style>