ReimbursementForm.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. <!-- 1. 项目信息 -->
  6. <CommonSection title="项目信息" :isFirst="true">
  7. <CommonInfoRow label="项目类型" :value="getProjectTypeName(form.projectType)" />
  8. <CommonInfoRow label="项目名称" :value="form.projectName" />
  9. <CommonInfoRow label="项目编号" :value="form.projectNo" />
  10. <CommonInfoRow label="项目来源" :value="form.projectSource" />
  11. <CommonInfoRow label="负责人" :value="form.projectIncharge" />
  12. <CommonInfoRow label="所属科室" :value="form.projectDeptName" />
  13. <CommonInfoRow label="经费卡" :value="cardLabel" />
  14. <CommonInfoRow label="费用科目" :value="form.subjName" />
  15. <CommonInfoRow label="入款/可用">
  16. <text class="value primary-color">¥{{ formatAmount(showAmount) }} / ¥{{ formatAmount(showBalanceAmount) }}</text>
  17. </CommonInfoRow>
  18. <CommonInfoRow label="费用类型" :value="form.subSubjName" />
  19. <CommonInfoRow label="事项" :value="form.purpose" isColumn />
  20. </CommonSection>
  21. <!-- 2. 报销经费 -->
  22. <CommonSection title="报销经费">
  23. <CommonInfoRow label="经办人" :value="form.handle" />
  24. <CommonInfoRow label="支出金额" :value="form.amount" isAmount />
  25. </CommonSection>
  26. <!-- 3. 发票信息 -->
  27. <CommonSection title="发票信息" v-if="form.invoice?.length">
  28. <view class="invoice-list">
  29. <view class="invoice-item" v-for="(inv, idx) in form.invoice" :key="idx">
  30. <view class="i-main">
  31. <text class="i-no">No.{{ inv.invoiceNo }}</text>
  32. <text class="i-amount red-color">¥{{ formatAmount(inv.amount) }}</text>
  33. </view>
  34. <view class="i-date">{{ formatDate(inv.invoiceBy) }}</view>
  35. <view class="i-files" v-if="inv.fileUrl">
  36. <text class="link-text" @click="previewFile(inv.fileUrl, inv.fileName)">查看发票文件</text>
  37. </view>
  38. </view>
  39. </view>
  40. </CommonSection>
  41. <!-- 4. 支付信息 -->
  42. <CommonSection title="支付信息" v-if="form.payment?.length">
  43. <view class="payment-list">
  44. <view class="pay-item" v-for="(pay, pIdx) in form.payment" :key="pIdx">
  45. <view class="p-header">
  46. <text class="p-type">{{ getPayTypeLabel(pay.payType) }}</text>
  47. <text class="p-amount red-color">¥{{ formatAmount(pay.amount) }}</text>
  48. </view>
  49. <view class="p-row">
  50. <text class="pl">收款人/单位</text>
  51. <text class="pv">{{ pay.receiver }}</text>
  52. </view>
  53. <view class="p-row">
  54. <text class="pl">类型</text>
  55. <text class="pv">{{ getDictLabel('sci_receiver_type', pay.receiverType) }}</text>
  56. </view>
  57. </view>
  58. </view>
  59. </CommonSection>
  60. <!-- 5. 附件 -->
  61. <AttachmentList :list="form.fileList" title="附件信息" />
  62. </template>
  63. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  64. </view>
  65. </template>
  66. <script setup lang="ts">
  67. import { ref, onMounted, watch, computed } from 'vue';
  68. import { useDocumentApi } from '@/api/document';
  69. import { useDict } from '@/hooks/useDict';
  70. import { formatDate } from '@/utils/date';
  71. import { previewFile } from '@/utils/file';
  72. import { formatAmount } from '@/utils/format';
  73. import to from 'await-to-js';
  74. import CommonSection from '@/components/ui/CommonSection.vue';
  75. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  76. import AttachmentList from './AttachmentList.vue';
  77. const props = defineProps<{
  78. code: string;
  79. }>();
  80. const { getDictLabel } = useDict('sci_receiver_type');
  81. const documentApi = useDocumentApi();
  82. const form = ref<any>(null);
  83. const loading = ref(false);
  84. const projectTypeOptions = [
  85. { dictValue: '10', dictLabel: '纵向项目' },
  86. { dictValue: '20', dictLabel: '横向项目' },
  87. { dictValue: '30', dictLabel: '内部项目' },
  88. { dictValue: '50', dictLabel: '人才类项目' },
  89. { dictValue: '60', dictLabel: '科研平台' },
  90. ];
  91. const getProjectTypeName = (val: string) => {
  92. const item = projectTypeOptions.find(opt => opt.dictValue === val);
  93. return item ? item.dictLabel : val;
  94. };
  95. const showAmount = ref(0);
  96. const showBalanceAmount = ref(0);
  97. const cardLabel = computed(() => {
  98. if (!form.value) return '';
  99. const typeMap: Record<string, string> = { '10': '上级拨款', '20': '匹配经费', '30': '横向经费' };
  100. return `${form.value.cardNo || ''}_${typeMap[form.value.type] || ''}`;
  101. });
  102. const getPayTypeLabel = (val: string) => {
  103. const map: Record<string, string> = { '10': '银行转账', '20': '现金', '30': '国库集中支付' };
  104. return map[val] || val;
  105. };
  106. const fetchData = async () => {
  107. if (!props.code) return;
  108. loading.value = true;
  109. // 1. 获取报销单详情
  110. const [err, res] = await to(documentApi.getFundExpenseById(props.code));
  111. if (!err && res?.data) {
  112. form.value = res.data;
  113. // 2. 获取经费余额情况 (对齐PC预览逻辑)
  114. if (form.value.projectId && form.value.subjCode) {
  115. const balanceParams = {
  116. projectId: form.value.projectId,
  117. projectType: form.value.projectType,
  118. subjCode: form.value.subjCode,
  119. type: form.value.type,
  120. };
  121. const [bErr, bRes] = await to(documentApi.getSubjAmount(balanceParams));
  122. if (!bErr && bRes?.data) {
  123. showAmount.value = bRes.data.amount || 0;
  124. showBalanceAmount.value = bRes.data.balanceAmount || 0;
  125. }
  126. }
  127. }
  128. loading.value = false;
  129. };
  130. onMounted(() => {
  131. fetchData();
  132. });
  133. watch(() => props.code, () => {
  134. fetchData();
  135. });
  136. </script>
  137. <style lang="scss" scoped>
  138. @import "./common.scss";
  139. .invoice-list {
  140. .invoice-item {
  141. padding: 24rpx 0;
  142. border-bottom: 2rpx dashed #e2e8f0;
  143. &:last-child { border-bottom: none; }
  144. .i-main {
  145. display: flex;
  146. justify-content: space-between;
  147. .i-no { font-size: 28rpx; color: #1e293b; font-weight: 600; }
  148. .i-amount { font-size: 30rpx; color: #ef4444; font-weight: 800; font-family: 'Inter', sans-serif; }
  149. }
  150. .i-date { font-size: 24rpx; color: #64748b; margin-top: 8rpx; }
  151. .i-files { margin-top: 10rpx; }
  152. }
  153. }
  154. .payment-list {
  155. .pay-item {
  156. background: #f8fafc;
  157. padding: 24rpx;
  158. border-radius: 12rpx;
  159. margin-bottom: 20rpx;
  160. border: 1rpx solid #f1f5f9;
  161. .p-header {
  162. display: flex;
  163. justify-content: space-between;
  164. margin-bottom: 16rpx;
  165. .p-type {
  166. font-size: 22rpx;
  167. background: #eff6ff;
  168. color: #3b82f6;
  169. padding: 4rpx 16rpx;
  170. border-radius: 100rpx;
  171. font-weight: 700;
  172. border: 1rpx solid #dbeafe;
  173. }
  174. .p-amount { font-size: 30rpx; color: #1e293b; font-weight: 800; }
  175. }
  176. .p-row {
  177. display: flex;
  178. justify-content: space-between;
  179. margin-top: 8rpx;
  180. font-size: 26rpx;
  181. .pl { color: #64748b; }
  182. .pv { color: #334155; font-weight: 500; }
  183. }
  184. }
  185. }
  186. .link-text { color: #3b82f6; font-size: 26rpx; font-weight: 600; }
  187. </style>