SpecialActivityForm.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.activityName" />
  8. <CommonInfoRow label="申请人" :value="form.applicantBy" />
  9. <CommonInfoRow label="所属部门" :value="deptName" />
  10. <CommonInfoRow label="所属年度" :value="form.belongYear" />
  11. <CommonInfoRow label="活动类型" :value="activityTypeLabel" />
  12. <CommonInfoRow label="活动地点" :value="form.activityPlace" />
  13. <CommonInfoRow label="展览类别" :value="exhibitionCategoryLabel" />
  14. <CommonInfoRow label="开始日期" :value="formatDate(form.activityStartTime)" />
  15. <CommonInfoRow label="结束日期" :value="formatDate(form.activityEndTime)" />
  16. <CommonInfoRow label="活动规模" :value="form.activityScale" />
  17. <CommonInfoRow label="产出成果" :value="form.outputAchievement" />
  18. <CommonInfoRow label="所属平台" isColumn>
  19. <view class="platform-tags">
  20. <template v-if="platformList.length > 0">
  21. <uv-tags v-for="(p, index) in platformList" :key="index" :text="p.platformName === '其他' ? '其他' : (p.platformType ? p.platformName + ' (' + p.platformType + ')' : p.platformName)" type="primary" plain size="mini" class="mr5"></uv-tags>
  22. </template>
  23. <text v-else>-</text>
  24. </view>
  25. </CommonInfoRow>
  26. <CommonInfoRow label="佐证材料" isColumn>
  27. <view class="file-links">
  28. <template v-if="mergedFileList.length">
  29. <view class="file-item" v-for="(item, index) in mergedFileList" :key="'evidence-' + index" @click="handlePreview(item)">
  30. <text class="file-link">{{ item.name || '-' }}</text>
  31. </view>
  32. </template>
  33. <text v-else>-</text>
  34. </view>
  35. </CommonInfoRow>
  36. <CommonInfoRow label="备注" :value="form.remark" isColumn />
  37. </CommonSection>
  38. <!-- 审核信息 -->
  39. <CommonSection title="审核信息" v-if="showAuditOpinion">
  40. <CommonInfoRow label="审核意见" :value="form.auditOpinion" isColumn />
  41. </CommonSection>
  42. </template>
  43. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  44. </view>
  45. </template>
  46. <script setup lang="ts">
  47. import { ref, onMounted, computed } from 'vue';
  48. import { useAchievementApi } from '@/api/achievement/index';
  49. import { useDeptApi } from '@/api/system/index';
  50. import { formatDate } from '@/utils/date';
  51. import { previewFile } from '@/utils/file';
  52. import to from 'await-to-js';
  53. import CommonSection from '@/components/ui/CommonSection.vue';
  54. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  55. const props = defineProps<{
  56. code: string | number; // 接收 ID
  57. }>();
  58. const achievementApi = useAchievementApi();
  59. const deptApi = useDeptApi();
  60. const form = ref<any>(null);
  61. const loading = ref(false);
  62. const unitList = ref<any[]>([]);
  63. const activityTypeDict = ref<any[]>([]);
  64. const exhibitionCategoryDict = ref<any[]>([]);
  65. const deptName = computed(() => {
  66. if (!form.value?.belongDeptId) return '-';
  67. const findNode = (nodes: any[]): string | null => {
  68. for (const node of nodes) {
  69. if (node.id === form.value.belongDeptId) return node.deptName;
  70. if (node.children?.length) {
  71. const name = findNode(node.children);
  72. if (name) return name;
  73. }
  74. }
  75. return null;
  76. };
  77. return findNode(unitList.value) || form.value.deptName || '-';
  78. });
  79. const activityTypeLabel = computed(() => {
  80. const item = activityTypeDict.value.find(d => d.dictValue === form.value?.activityType);
  81. return item ? item.dictLabel : (form.value?.activityType || '-');
  82. });
  83. const exhibitionCategoryLabel = computed(() => {
  84. const item = exhibitionCategoryDict.value.find(d => d.dictValue === form.value?.exhibitionCategory);
  85. return item ? item.dictLabel : (form.value?.exhibitionCategory || '-');
  86. });
  87. const platformNames = computed(() => {
  88. return form.value?.platformInfo?.map((item: any) => item.platformName).join('、') || '-';
  89. });
  90. const showAuditOpinion = computed(() => {
  91. if (!form.value) return false;
  92. // 参考 PC 逻辑: 驳回(1) 或 审核通过(3) 时展示
  93. return form.value.auditOpinion && (form.value.auditStatus === 1 || form.value.auditStatus === 3);
  94. });
  95. const platformList = computed(() => {
  96. if (form.value?.belongPlatform) {
  97. try {
  98. const data = JSON.parse(form.value.belongPlatform);
  99. return Array.isArray(data) ? data : [];
  100. } catch (e) {
  101. if (form.value.belongPlatform === '其他') return [{ platformName: '其他' }];
  102. return [{ platformName: form.value.belongPlatform }];
  103. }
  104. }
  105. return [];
  106. });
  107. const mergedFileList = computed(() => {
  108. if (!form.value?.evidenceMaterials) return [];
  109. let rawFiles: string[] = [];
  110. try {
  111. rawFiles = typeof form.value.evidenceMaterials === 'string'
  112. ? JSON.parse(form.value.evidenceMaterials)
  113. : form.value.evidenceMaterials;
  114. if (!Array.isArray(rawFiles)) rawFiles = [rawFiles];
  115. } catch (e) {
  116. return [];
  117. }
  118. return rawFiles.map(fileData => {
  119. if (!fileData) return null;
  120. const name = fileData.split('/').pop() || '文件';
  121. const startIndex = fileData.indexOf('/');
  122. const url = import.meta.env.VITE_SCIENTIFIC_FILE_URL + fileData.slice(startIndex + 1);
  123. return { name, url };
  124. }).filter((item): item is { name: string; url: string } => Boolean(item));
  125. });
  126. const handlePreview = (file: any) => {
  127. const url = file.fileUrl || file.url;
  128. const name = file.fileName || file.name;
  129. if (url) {
  130. previewFile(url, name);
  131. }
  132. };
  133. const fetchData = async () => {
  134. if (!props.code) return;
  135. loading.value = true;
  136. // 并行获取详情、部门树、字典
  137. const [
  138. [err, res],
  139. [deptErr, deptRes],
  140. [typeDictErr, typeDictRes],
  141. [categoryDictErr, categoryDictRes]
  142. ] = await Promise.all([
  143. to(achievementApi.getSpecialActivityDetail(props.code)),
  144. to(deptApi.getDeptTree()),
  145. to(achievementApi.getDictData('cxy_research_special_activity_type')),
  146. to(achievementApi.getDictData('cxy_research_special_exhibition_category'))
  147. ]);
  148. if (!err && res?.data) {
  149. form.value = res.data;
  150. }
  151. if (!deptErr && deptRes?.data) {
  152. unitList.value = deptRes.data || [];
  153. }
  154. if (!typeDictErr && typeDictRes?.data) {
  155. activityTypeDict.value = Array.isArray(typeDictRes.data) ? typeDictRes.data : [];
  156. }
  157. if (!categoryDictErr && categoryDictRes?.data) {
  158. exhibitionCategoryDict.value = Array.isArray(categoryDictRes.data) ? categoryDictRes.data : [];
  159. }
  160. loading.value = false;
  161. };
  162. onMounted(() => {
  163. fetchData();
  164. });
  165. </script>
  166. <style lang="scss" scoped>
  167. @import "./common.scss";
  168. .file-links {
  169. .file-item {
  170. padding: 6rpx 0;
  171. }
  172. .file-link {
  173. color: #2979ff;
  174. text-decoration: underline;
  175. word-break: break-all;
  176. }
  177. }
  178. </style>