DeclarationListForm.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="document-form">
  3. <uv-loading-icon v-if="state.loading" mode="circle" text="正在加载预申报详情..."></uv-loading-icon>
  4. <template v-else-if="state.form">
  5. <!-- 基本信息 -->
  6. <view class="common-section-card">
  7. <view class="section-title">基本信息</view>
  8. <view class="info-row"><text class="label">项目名称</text><text class="value">{{ state.form.projectName }}</text></view>
  9. <view class="info-row">
  10. <text class="label">项目级别</text>
  11. <text class="value">{{ getDictLabel('sci_pjt_level', state.form.projectLevel) }}</text>
  12. </view>
  13. <view class="info-row"><text class="label">项目来源</text><text class="value">{{ state.form.projectSource || '-' }}</text></view>
  14. <view class="info-row">
  15. <text class="label">计划日期</text>
  16. <text class="value">{{ formatDate(state.form.planStartDate) }} 至 {{ formatDate(state.form.planEndDate) }}</text>
  17. </view>
  18. <view class="info-row">
  19. <text class="label">研究类型</text>
  20. <text class="value">{{ getDictLabel('sci_pjt_type', state.form.studyType) }}</text>
  21. </view>
  22. <view class="info-row"><text class="label">申请人</text><text class="value">{{ state.form.applyName || '-' }}</text></view>
  23. <view class="info-row"><text class="label">申报单位</text><text class="value">{{ state.form.applyUnit || '-' }}</text></view>
  24. <view class="info-row"><text class="label">所属科室</text><text class="value">{{ state.form.deptName || '-' }}</text></view>
  25. <view class="info-row"><text class="label">项目负责人</text><text class="value">{{ state.form.projectLeaderName || '-' }}</text></view>
  26. <view class="info-row"><text class="label">负责人电话</text><text class="value">{{ state.form.projectLeaderPhone || '-' }}</text></view>
  27. <view class="info-row"><text class="label">负责人邮箱</text><text class="value">{{ state.form.projectLeaderMail || '-' }}</text></view>
  28. </view>
  29. <!-- 附件信息 -->
  30. <view class="common-section-card mt20" v-if="state.form.fileList?.length">
  31. <view class="section-title">附件资料</view>
  32. <view class="common-file-list">
  33. <view class="file-item" v-for="(file, index) in state.form.fileList" :key="index" @click="previewFile(file.fileUrl, file.fileName)">
  34. <view class="file-info">
  35. <text class="f-name">{{ file.fileName }}</text>
  36. <view class="f-meta">
  37. <text class="f-type">{{ file.fileType || '附件' }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  45. </view>
  46. </template>
  47. <script setup lang="ts">
  48. import { reactive, onMounted, watch, nextTick } from 'vue';
  49. import { useDict } from '@/hooks/useDict';
  50. import { useDocumentApi } from '@/api/document';
  51. import { formatDate } from '@/utils/date';
  52. import { previewFile } from '@/utils/file';
  53. import to from 'await-to-js';
  54. const props = defineProps<{
  55. code: string;
  56. }>();
  57. const { getDictLabel } = useDict('sci_pjt_level', 'sci_pjt_type');
  58. const documentApi = useDocumentApi();
  59. const state = reactive({
  60. form: null as any,
  61. loading: false
  62. });
  63. const initForm = async (code: string) => {
  64. if (!code) return;
  65. state.loading = true;
  66. const [err, res] = await to(documentApi.getDeclarationById(code));
  67. if (!err && res?.data) {
  68. await nextTick();
  69. const data = res.data.entity || res.data.data || res.data;
  70. state.form = data;
  71. // 兼容附件处理
  72. if (!state.form.fileList && state.form.weedFile) {
  73. state.form.fileList = [{
  74. fileType: '申报书',
  75. fileName: state.form.fileName || '附件',
  76. fileUrl: state.form.weedFile,
  77. }];
  78. }
  79. state.form.fileList = state.form.fileList || [];
  80. }
  81. state.loading = false;
  82. };
  83. watch(() => props.code, (val) => {
  84. initForm(val);
  85. }, { immediate: true });
  86. defineExpose({
  87. initForm
  88. });
  89. </script>
  90. <style lang="scss" scoped>
  91. @import "./common.scss";
  92. </style>