AchAwardsForm.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.deptName" />
  8. <CommonInfoRow label="批文年月日" :value="formatDate(form.awardDate)" />
  9. <CommonInfoRow label="奖项所属年度" :value="form.awardYear ? formatDate(form.awardYear, 'YYYY') : '-'" />
  10. <CommonInfoRow label="获奖项目名称" :value="form.projectSource" />
  11. <CommonInfoRow label="获奖类别" :value="form.awardType === '10' ? '教学成果' : '科研奖项'" />
  12. <CommonInfoRow label="获奖等级" :value="getDictLabel('sci_awards_grade', form.awardGrade)" />
  13. <CommonInfoRow label="获奖级别" :value="getDictLabel('sci_awards_level', form.awardLevel)" />
  14. <CommonInfoRow label="获奖人(备案人)" :value="form.members || showMembers(form.memberList)" />
  15. <CommonInfoRow label="全部获奖完成人(按获奖顺序排列)" :value="form.remark" isColumn />
  16. <CommonInfoRow label="颁奖机构" :value="form.awardIssueAuthority" />
  17. <CommonInfoRow label="完成单位" :value="form.completionUnit" />
  18. <CommonInfoRow label="获奖金额" :value="'¥' + amountUnitTransferToYuan(form.awardAmount) + '元'" isAmount />
  19. <CommonInfoRow label="所属平台" isColumn>
  20. <view class="platform-tags">
  21. <template v-if="platformList.length > 0">
  22. <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>
  23. </template>
  24. <text v-else>-</text>
  25. </view>
  26. </CommonInfoRow>
  27. <CommonInfoRow label="所属团队" :value="form.belongTeam || '-'" />
  28. </CommonSection>
  29. <!-- 电子附件 -->
  30. <CommonSection title="电子附件">
  31. <CommonInfoRow label="获奖批文" isColumn>
  32. <view class="file-links">
  33. <template v-if="awardIssueAuthorityProofList.length">
  34. <view class="file-item" v-for="(item, index) in awardIssueAuthorityProofList" :key="'award-proof-' + index" @click="handlePreview(item)">
  35. <text class="file-link">{{ item.fileName || item.name || '-' }}</text>
  36. </view>
  37. </template>
  38. <text v-else>-</text>
  39. </view>
  40. </CommonInfoRow>
  41. <CommonInfoRow label="获奖证书" isColumn>
  42. <view class="file-links">
  43. <template v-if="awardCertificateList.length">
  44. <view class="file-item" v-for="(item, index) in awardCertificateList" :key="'award-certificate-' + index" @click="handlePreview(item)">
  45. <text class="file-link">{{ item.fileName || item.name || '-' }}</text>
  46. </view>
  47. </template>
  48. <text v-else>-</text>
  49. </view>
  50. </CommonInfoRow>
  51. <CommonInfoRow label="获奖金额证明" isColumn>
  52. <view class="file-links">
  53. <template v-if="awardAmountProofList.length">
  54. <view class="file-item" v-for="(item, index) in awardAmountProofList" :key="'award-amount-proof-' + index" @click="handlePreview(item)">
  55. <text class="file-link">{{ item.fileName || item.name || '-' }}</text>
  56. </view>
  57. </template>
  58. <text v-else>-</text>
  59. </view>
  60. </CommonInfoRow>
  61. </CommonSection>
  62. <!-- 审批记录 -->
  63. <CommonSection title="审批记录" v-if="form.id">
  64. <FlowTable :id="form.id" :businessCode="'奖项荣誉-' + String(form.awardCode)" defCode="sci_academic_achievement" />
  65. </CommonSection>
  66. <!-- 授权审核进度 -->
  67. <CommonSection title="授权审核进度" v-if="form.id">
  68. <FlowTable :id="form.id" :businessCode="'奖项荣誉授权-' + String(form.awardCode)" defCode="sci_academic_achievement_reward_auth" />
  69. </CommonSection>
  70. </template>
  71. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  72. </view>
  73. </template>
  74. <script setup lang="ts">
  75. import { ref, onMounted, watch, computed } from 'vue';
  76. import { useDict } from '@/hooks/useDict';
  77. import { useDocumentApi } from '@/api/document';
  78. import { formatDate } from '@/utils/date';
  79. import { previewFile } from '@/utils/file';
  80. import to from 'await-to-js';
  81. import FlowTable from '@/pages/project/components/detail/FlowTable.vue';
  82. import CommonSection from '@/components/ui/CommonSection.vue';
  83. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  84. const props = defineProps<{
  85. code: string;
  86. }>();
  87. const { getDictLabel } = useDict('sci_awards_grade', 'sci_awards_level');
  88. const documentApi = useDocumentApi();
  89. const form = ref<any>(null);
  90. const loading = ref(false);
  91. const platformList = computed(() => {
  92. if (form.value?.belongPlatform) {
  93. try {
  94. const data = JSON.parse(form.value.belongPlatform);
  95. return Array.isArray(data) ? data : [];
  96. } catch (e) {
  97. if (form.value.belongPlatform === '其他') return [{ platformName: '其他' }];
  98. return [{ platformName: form.value.belongPlatform }];
  99. }
  100. }
  101. return [];
  102. });
  103. const parseFileList = (fileStr: string) => {
  104. if (!fileStr) return [];
  105. try {
  106. const files = JSON.parse(fileStr);
  107. return Array.isArray(files) ? files : [files];
  108. } catch (e) {
  109. return [];
  110. }
  111. };
  112. const awardIssueAuthorityProofList = computed(() => parseFileList(form.value?.awardIssueAuthorityProof));
  113. const awardCertificateList = computed(() => parseFileList(form.value?.awardCertificate));
  114. const awardAmountProofList = computed(() => parseFileList(form.value?.awardAmountProof));
  115. const handlePreview = (file: any) => {
  116. const url = file.fileUrl || file.url;
  117. const name = file.fileName || file.name;
  118. if (url) {
  119. previewFile(url, name);
  120. }
  121. };
  122. const fetchData = async () => {
  123. if (!props.code) return;
  124. loading.value = true;
  125. const awardCode = props.code.includes('-') ? props.code.split('-')[1] : props.code;
  126. const [err, res] = await to(documentApi.getAwardsByCode(awardCode));
  127. if (!err && res?.data) {
  128. form.value = res.data;
  129. }
  130. loading.value = false;
  131. };
  132. onMounted(() => {
  133. fetchData();
  134. });
  135. watch(() => props.code, () => {
  136. fetchData();
  137. });
  138. const showMembers = (list: any[]) => {
  139. return list?.map(m => m.memberName).join(', ') || '-';
  140. };
  141. const amountUnitTransferToYuan = (amount: number | string) => {
  142. const num = Number(amount || 0);
  143. const amountInYuan = num * 10000;
  144. const formattedYuan = amountInYuan.toFixed(2);
  145. const parts = formattedYuan.split('.');
  146. const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  147. const decimalPart = parts[1];
  148. return `${integerPart}.${decimalPart}`;
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. @import "./common.scss";
  153. .platform-tags {
  154. display: flex;
  155. flex-wrap: wrap;
  156. justify-content: flex-end;
  157. gap: 8rpx;
  158. .platform-tag {
  159. font-size: 20rpx;
  160. padding: 2rpx 12rpx;
  161. background-color: #f6f8fa;
  162. color: #64748b;
  163. border-radius: 4rpx;
  164. border: 1rpx solid #e2e8f0;
  165. }
  166. }
  167. .file-links {
  168. .file-item {
  169. padding: 6rpx 0;
  170. }
  171. .file-link {
  172. color: #2979ff;
  173. text-decoration: underline;
  174. word-break: break-all;
  175. }
  176. }
  177. </style>