SciFundReverse.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. <view class="common-section-card">
  7. <view class="section-title">项目信息</view>
  8. <view class="info-row"><text class="label">项目名称</text><text class="value">{{ form.projectName || '-' }}</text></view>
  9. <view class="info-row">
  10. <text class="label">经费类型</text>
  11. <text class="value">{{ getFundType(form.type) }}</text>
  12. </view>
  13. <view class="info-row"><text class="label">项目负责人</text><text class="value">{{ form.projectIncharge || '-' }}</text></view>
  14. <view class="info-row"><text class="label">所属科室</text><text class="value">{{ form.projectDeptName || '-' }}</text></view>
  15. <view class="info-row">
  16. <text class="label">到账总额(元)</text>
  17. <text class="value red-color">¥{{ formatMoney(projectInfo?.amount) }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="label">结余金额(元)</text>
  21. <text class="value red-color">¥{{ formatMoney(projectInfo?.balanceAmount) }}</text>
  22. </view>
  23. </view>
  24. <!-- 报销经费 -->
  25. <view class="common-section-card mt20">
  26. <view class="section-title">报销经费</view>
  27. <view class="info-row"><text class="label">费用科目</text><text class="value">{{ form.subjName || '-' }}</text></view>
  28. <view class="info-row">
  29. <text class="label">入账金额(元)</text>
  30. <text class="value red-color">¥{{ formatMoney(subjAmount?.amount) }}</text>
  31. </view>
  32. <view class="info-row">
  33. <text class="label">可用金额(元)</text>
  34. <text class="value red-color">¥{{ formatMoney(subjAmount?.balanceAmount) }}</text>
  35. </view>
  36. <view class="info-row">
  37. <text class="label">冲销金额(元)</text>
  38. <text class="value red-color">¥{{ formatMoney(form.amount) }}</text>
  39. </view>
  40. <view class="info-row"><text class="label">冲销日期</text><text class="value">{{ form.reverseTime || '-' }}</text></view>
  41. <view class="info-row"><text class="label">冲销人</text><text class="value">{{ form.reverse || '-' }}</text></view>
  42. <view class="info-row"><text class="label">操作人</text><text class="value">{{ form.operator || '-' }}</text></view>
  43. <view class="info-row"><text class="label">记录人</text><text class="value">{{ form.record || '-' }}</text></view>
  44. </view>
  45. <!-- 备注 -->
  46. <view class="common-section-card mt20" v-if="form.remark">
  47. <view class="section-title">备注</view>
  48. <view class="remark-content">{{ form.remark }}</view>
  49. </view>
  50. </template>
  51. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  52. </view>
  53. </template>
  54. <script setup lang="ts">
  55. import { ref, onMounted, watch } from 'vue';
  56. import { useDocumentApi } from '@/api/document';
  57. import to from 'await-to-js';
  58. const props = defineProps<{
  59. code: string;
  60. }>();
  61. const documentApi = useDocumentApi();
  62. const form = ref<any>(null);
  63. const projectInfo = ref<any>(null);
  64. const subjAmount = ref<any>(null);
  65. const loading = ref(false);
  66. const getFundType = (type: string) => {
  67. const types: Record<string, string> = {
  68. '10': '上级拨款',
  69. '20': '匹配经费',
  70. '30': '横向经费'
  71. };
  72. return types[type] || '-';
  73. };
  74. const formatMoney = (val: any) => {
  75. if (val === undefined || val === null) return '0.00';
  76. return Number(val).toLocaleString('zh-CN', { minimumFractionDigits: 2 });
  77. };
  78. const fetchData = async () => {
  79. if (!props.code) return;
  80. loading.value = true;
  81. const [err, res] = await to(documentApi.getFundReverseByCode(props.code));
  82. if (!err && res?.data) {
  83. form.value = res.data;
  84. // 同步 PC 逻辑:获取额外信息
  85. await Promise.all([
  86. getCardDetails(form.value.cardId),
  87. getAmountInfo(form.value)
  88. ]);
  89. }
  90. loading.value = false;
  91. };
  92. const getCardDetails = async (cardId: any) => {
  93. if (!cardId) return;
  94. const [err, res] = await to(documentApi.getFundCardById(cardId));
  95. if (!err && res?.data) {
  96. projectInfo.value = res.data;
  97. }
  98. };
  99. const getAmountInfo = async (f: any) => {
  100. if (!f.projectId || !f.subjCode) return;
  101. const params = {
  102. projectId: f.projectId,
  103. projectType: f.projectType,
  104. subjCode: f.subjCode,
  105. type: f.type,
  106. };
  107. const [err, res] = await to(documentApi.getSubjAmount(params));
  108. if (!err && res?.data) {
  109. subjAmount.value = res.data;
  110. }
  111. };
  112. onMounted(() => {
  113. fetchData();
  114. });
  115. watch(() => props.code, () => {
  116. fetchData();
  117. });
  118. </script>
  119. <style lang="scss" scoped>
  120. @import "./common.scss";
  121. .remark-content {
  122. font-size: 28rpx;
  123. color: #333;
  124. line-height: 1.6;
  125. padding: 10rpx 0;
  126. }
  127. </style>