| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <view class="document-form">
- <uv-loading-icon v-if="loading" mode="circle" text="正在加载活动详情..."></uv-loading-icon>
- <template v-else-if="form">
- <!-- 基本信息 -->
- <CommonSection title="基本信息" :isFirst="true">
- <CommonInfoRow label="活动名称" :value="form.activityName" />
- <CommonInfoRow label="申请人" :value="form.applicantBy" />
- <CommonInfoRow label="所属部门" :value="deptName" />
- <CommonInfoRow label="所属年度" :value="form.belongYear" />
- <CommonInfoRow label="活动类型" :value="activityTypeLabel" />
- <CommonInfoRow label="活动地点" :value="form.activityPlace" />
- <CommonInfoRow label="展览类别" :value="exhibitionCategoryLabel" />
- <CommonInfoRow label="开始日期" :value="formatDate(form.activityStartTime)" />
- <CommonInfoRow label="结束日期" :value="formatDate(form.activityEndTime)" />
- <CommonInfoRow label="活动规模" :value="form.activityScale" />
- <CommonInfoRow label="产出成果" :value="form.outputAchievement" />
- <CommonInfoRow label="所属平台" :value="platformNames" />
- <CommonInfoRow label="备注" :value="form.remark" isColumn />
- </CommonSection>
- <!-- 审核信息 -->
- <CommonSection title="审核信息" v-if="showAuditOpinion">
- <CommonInfoRow label="审核意见" :value="form.auditOpinion" isColumn />
- </CommonSection>
- <!-- 佐证材料 -->
- <AttachmentList :list="mergedFileList" title="佐证材料" />
- </template>
- <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, onMounted, computed } from 'vue';
- import { useAchievementApi } from '@/api/achievement/index';
- import { useDeptApi } from '@/api/system/index';
- import { formatDate } from '@/utils/date';
- import to from 'await-to-js';
- import AttachmentList from './AttachmentList.vue';
- import CommonSection from '@/components/ui/CommonSection.vue';
- import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
- const props = defineProps<{
- code: string | number; // 接收 ID
- }>();
- const achievementApi = useAchievementApi();
- const deptApi = useDeptApi();
- const form = ref<any>(null);
- const loading = ref(false);
- const unitList = ref<any[]>([]);
- const activityTypeDict = ref<any[]>([]);
- const exhibitionCategoryDict = ref<any[]>([]);
- const deptName = computed(() => {
- if (!form.value?.belongDeptId) return '-';
- const findNode = (nodes: any[]): string | null => {
- for (const node of nodes) {
- if (node.id === form.value.belongDeptId) return node.deptName;
- if (node.children?.length) {
- const name = findNode(node.children);
- if (name) return name;
- }
- }
- return null;
- };
- return findNode(unitList.value) || form.value.deptName || '-';
- });
- const activityTypeLabel = computed(() => {
- const item = activityTypeDict.value.find(d => d.dictValue === form.value?.activityType);
- return item ? item.dictLabel : (form.value?.activityType || '-');
- });
- const exhibitionCategoryLabel = computed(() => {
- const item = exhibitionCategoryDict.value.find(d => d.dictValue === form.value?.exhibitionCategory);
- return item ? item.dictLabel : (form.value?.exhibitionCategory || '-');
- });
- const platformNames = computed(() => {
- return form.value?.platformInfo?.map((item: any) => item.platformName).join('、') || '-';
- });
- const showAuditOpinion = computed(() => {
- if (!form.value) return false;
- // 参考 PC 逻辑: 驳回(1) 或 审核通过(3) 时展示
- return form.value.auditOpinion && (form.value.auditStatus === 1 || form.value.auditStatus === 3);
- });
- const mergedFileList = computed(() => {
- if (!form.value?.evidenceMaterials) return [];
- let rawFiles: string[] = [];
- try {
- rawFiles = typeof form.value.evidenceMaterials === 'string'
- ? JSON.parse(form.value.evidenceMaterials)
- : form.value.evidenceMaterials;
- if (!Array.isArray(rawFiles)) rawFiles = [rawFiles];
- } catch (e) {
- return [];
- }
- return rawFiles.map(fileData => {
- if (!fileData) return null;
- const name = fileData.split('/').pop() || '文件';
- const startIndex = fileData.indexOf('/');
- const url = import.meta.env.VITE_SCIENTIFIC_FILE_URL + fileData.slice(startIndex + 1);
- return { name, url };
- }).filter(Boolean);
- });
- const fetchData = async () => {
- if (!props.code) return;
- loading.value = true;
- // 并行获取详情、部门树、字典
- const [
- [err, res],
- [deptErr, deptRes],
- [typeDictErr, typeDictRes],
- [categoryDictErr, categoryDictRes]
- ] = await Promise.all([
- to(achievementApi.getSpecialActivityDetail(props.code)),
- to(deptApi.getDeptTree()),
- to(achievementApi.getDictData('cxy_research_special_activity_type')),
- to(achievementApi.getDictData('cxy_research_special_exhibition_category'))
- ]);
- if (!err && res?.data) {
- form.value = res.data;
- }
- if (!deptErr && deptRes?.data) {
- unitList.value = deptRes.data || [];
- }
- if (!typeDictErr && typeDictRes?.data) {
- activityTypeDict.value = Array.isArray(typeDictRes.data) ? typeDictRes.data : [];
- }
- if (!categoryDictErr && categoryDictRes?.data) {
- exhibitionCategoryDict.value = Array.isArray(categoryDictRes.data) ? categoryDictRes.data : [];
- }
- loading.value = false;
- };
- onMounted(() => {
- fetchData();
- });
- </script>
- <style lang="scss" scoped>
- @import "./common.scss";
- </style>
|