AchAwardsForm.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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.awardName || '-'" />
  8. <CommonInfoRow label="编号" :value="form.awardCode || '-'" />
  9. <CommonInfoRow label="所在部门" :value="form.deptName" />
  10. <CommonInfoRow label="奖项所属年度" :value="form.awardYear ? formatDate(form.awardYear, 'YYYY') : '-'" />
  11. <CommonInfoRow label="获奖类别" :value="awardTypeText" />
  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.completionUnit" />
  16. <CommonInfoRow label="所属平台" isColumn>
  17. <view class="platform-tags">
  18. <template v-if="platformList.length > 0">
  19. <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>
  20. </template>
  21. <text v-else>-</text>
  22. </view>
  23. </CommonInfoRow>
  24. <CommonInfoRow label="所属团队" :value="form.belongTeam || '-'" />
  25. <CommonInfoRow label="全部获奖完成人(按获奖顺序排列)" :value="form.remark || '-'" isColumn />
  26. </CommonSection>
  27. <!-- 授权信息 -->
  28. <CommonSection title="授权信息">
  29. <CommonInfoRow label="批文年月日" :value="formatDate(form.awardDate)" />
  30. <CommonInfoRow label="颁奖机构" :value="form.awardIssueAuthority || '-'" />
  31. <CommonInfoRow label="获奖金额(万元)" :value="formatAmountInTenThousand(form.awardAmount)" />
  32. </CommonSection>
  33. <!-- 附件 -->
  34. <CommonSection title="附件">
  35. <CommonInfoRow label="获奖批文" isColumn>
  36. <view class="file-links">
  37. <template v-if="awardIssueAuthorityProofList.length">
  38. <view class="file-item" v-for="(item, index) in awardIssueAuthorityProofList" :key="'award-proof-' + index" @click="handlePreview(item)">
  39. <text class="file-link">{{ item.fileName || item.name || '-' }}</text>
  40. </view>
  41. </template>
  42. <text v-else>-</text>
  43. </view>
  44. </CommonInfoRow>
  45. <CommonInfoRow label="获奖证书" isColumn>
  46. <view class="file-links">
  47. <template v-if="awardCertificateList.length">
  48. <view class="file-item" v-for="(item, index) in awardCertificateList" :key="'award-certificate-' + index" @click="handlePreview(item)">
  49. <text class="file-link">{{ item.fileName || item.name || '-' }}</text>
  50. </view>
  51. </template>
  52. <text v-else>-</text>
  53. </view>
  54. </CommonInfoRow>
  55. <CommonInfoRow label="获奖金额证明" isColumn>
  56. <view class="file-links">
  57. <template v-if="awardAmountProofList.length">
  58. <view class="file-item" v-for="(item, index) in awardAmountProofList" :key="'award-amount-proof-' + index" @click="handlePreview(item)">
  59. <text class="file-link">{{ item.fileName || item.name || '-' }}</text>
  60. </view>
  61. </template>
  62. <text v-else>-</text>
  63. </view>
  64. </CommonInfoRow>
  65. </CommonSection>
  66. <!-- 关联项目 -->
  67. <CommonSection title="关联项目">
  68. <view class="related-list" v-if="relatedProjectList.length">
  69. <view class="related-item" v-for="(item, index) in relatedProjectList" :key="item.id || item.projectSource || index">
  70. <text class="related-index">{{ Number(index) + 1 }}</text>
  71. <view class="related-content">
  72. <view class="related-top">
  73. <text class="related-type-tag" :class="{ subject: item.sourceType === '20' }">
  74. {{ item.sourceType === '10' ? '项目' : item.sourceType === '20' ? '学科' : '-' }}
  75. </text>
  76. </view>
  77. <text class="related-name">{{ item.projectSource || '-' }}</text>
  78. </view>
  79. </view>
  80. </view>
  81. <text v-else>-</text>
  82. </CommonSection>
  83. <!-- 审批信息 -->
  84. <CommonSection title="审批信息" v-if="form.id">
  85. <FlowTable :id="form.id" :businessCode="'奖项荣誉-' + String(form.awardCode)" defCode="sci_academic_achievement" />
  86. </CommonSection>
  87. <!-- 授权审核进度 -->
  88. <CommonSection title="授权审核进度" v-if="form.id">
  89. <FlowTable :id="form.id" :businessCode="'奖项荣誉授权-' + String(form.awardCode)" defCode="sci_academic_achievement_reward_auth" />
  90. </CommonSection>
  91. </template>
  92. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  93. </view>
  94. </template>
  95. <script setup lang="ts">
  96. import { ref, onMounted, watch, computed } from 'vue';
  97. import { useDict } from '@/hooks/useDict';
  98. import { useDocumentApi } from '@/api/document';
  99. import { formatDate } from '@/utils/date';
  100. import { previewFile } from '@/utils/file';
  101. import to from 'await-to-js';
  102. import FlowTable from '@/pages/project/components/detail/FlowTable.vue';
  103. import CommonSection from '@/components/ui/CommonSection.vue';
  104. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  105. const props = defineProps<{
  106. code: string;
  107. }>();
  108. const { getDictLabel } = useDict('sci_awards_grade', 'sci_awards_level');
  109. const documentApi = useDocumentApi();
  110. const form = ref<any>(null);
  111. const loading = ref(false);
  112. const platformList = computed(() => {
  113. if (form.value?.belongPlatform) {
  114. try {
  115. const data = JSON.parse(form.value.belongPlatform);
  116. return Array.isArray(data) ? data : [];
  117. } catch (e) {
  118. if (form.value.belongPlatform === '其他') return [{ platformName: '其他' }];
  119. return [{ platformName: form.value.belongPlatform }];
  120. }
  121. }
  122. return [];
  123. });
  124. const parseFileList = (fileStr: string) => {
  125. if (!fileStr) return [];
  126. try {
  127. const files = JSON.parse(fileStr);
  128. return Array.isArray(files) ? files : [files];
  129. } catch (e) {
  130. return [];
  131. }
  132. };
  133. const awardIssueAuthorityProofList = computed(() => parseFileList(form.value?.awardIssueAuthorityProof));
  134. const awardCertificateList = computed(() => parseFileList(form.value?.awardCertificate));
  135. const awardAmountProofList = computed(() => parseFileList(form.value?.awardAmountProof));
  136. const relatedProjectList = computed(() => Array.isArray(form.value?.projList) ? form.value.projList : []);
  137. const awardTypeText = computed(() => {
  138. if (form.value?.awardType === '10') return '教学成果';
  139. if (form.value?.awardType === '20') return '科研奖项';
  140. return '-';
  141. });
  142. const handlePreview = (file: any) => {
  143. const url = file.fileUrl || file.url;
  144. const name = file.fileName || file.name;
  145. if (url) {
  146. previewFile(url, name);
  147. }
  148. };
  149. const fetchData = async () => {
  150. if (!props.code) return;
  151. loading.value = true;
  152. const awardCode = props.code.includes('-') ? props.code.split('-')[1] : props.code;
  153. const [err, res] = await to(documentApi.getAwardsByCode(awardCode));
  154. if (!err && res?.data) {
  155. form.value = res.data;
  156. }
  157. loading.value = false;
  158. };
  159. onMounted(() => {
  160. fetchData();
  161. });
  162. watch(() => props.code, () => {
  163. fetchData();
  164. });
  165. const showMembers = (list: any[]) => {
  166. return list?.map(m => m.memberName).join(', ') || '-';
  167. };
  168. const formatAmountInTenThousand = (amount: number | string) => {
  169. const num = Number(amount);
  170. if (Number.isNaN(num)) return '-';
  171. return num.toFixed(2);
  172. };
  173. </script>
  174. <style lang="scss" scoped>
  175. @import "./common.scss";
  176. .platform-tags {
  177. display: flex;
  178. flex-wrap: wrap;
  179. justify-content: flex-end;
  180. gap: 8rpx;
  181. .platform-tag {
  182. font-size: 20rpx;
  183. padding: 2rpx 12rpx;
  184. background-color: #f6f8fa;
  185. color: #64748b;
  186. border-radius: 4rpx;
  187. border: 1rpx solid #e2e8f0;
  188. }
  189. }
  190. .file-links {
  191. .file-item {
  192. padding: 6rpx 0;
  193. }
  194. .file-link {
  195. color: #2979ff;
  196. text-decoration: underline;
  197. word-break: break-all;
  198. }
  199. }
  200. .related-list {
  201. width: 100%;
  202. }
  203. .related-item {
  204. display: flex;
  205. align-items: flex-start;
  206. padding: 16rpx 18rpx;
  207. border-radius: 12rpx;
  208. background: #f8fafc;
  209. border: 1rpx solid #e2e8f0;
  210. margin-bottom: 12rpx;
  211. &:last-child {
  212. margin-bottom: 0;
  213. }
  214. }
  215. .related-index {
  216. min-width: 36rpx;
  217. height: 36rpx;
  218. line-height: 36rpx;
  219. text-align: center;
  220. border-radius: 50%;
  221. background: #e0f2fe;
  222. color: #0284c7;
  223. font-size: 22rpx;
  224. font-weight: 700;
  225. margin-right: 12rpx;
  226. }
  227. .related-content {
  228. display: flex;
  229. flex-direction: column;
  230. gap: 8rpx;
  231. flex: 1;
  232. min-width: 0;
  233. }
  234. .related-top {
  235. display: flex;
  236. align-items: center;
  237. gap: 10rpx;
  238. }
  239. .related-label {
  240. font-size: 22rpx;
  241. color: #64748b;
  242. }
  243. .related-type-tag {
  244. font-size: 20rpx;
  245. color: #2563eb;
  246. background: #dbeafe;
  247. border: 1rpx solid #bfdbfe;
  248. border-radius: 100rpx;
  249. padding: 2rpx 12rpx;
  250. &.subject {
  251. color: #7c3aed;
  252. background: #ede9fe;
  253. border-color: #ddd6fe;
  254. }
  255. }
  256. .related-name {
  257. font-size: 24rpx;
  258. color: #1e293b;
  259. line-height: 1.5;
  260. word-break: break-all;
  261. }
  262. </style>