SciFundReverse.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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">{{ projectInfo?.projectName || '-' }}</text></view>
  9. <view class="info-row">
  10. <text class="label">经费类型</text>
  11. <text class="value">{{ getFundType(projectInfo?.type) }}</text>
  12. </view>
  13. <view class="info-row"><text class="label">项目负责人</text><text class="value">{{ projectInfo?.inchargeName || '-' }}</text></view>
  14. <view class="info-row"><text class="label">所属科室</text><text class="value">{{ projectInfo?.deptName || '-' }}</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">{{ formatDate(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. </template>
  46. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  47. </view>
  48. </template>
  49. <script setup lang="ts">
  50. import { ref, onMounted, watch } from 'vue';
  51. import { useDocumentApi } from '@/api/document';
  52. import { formatDate } from '@/utils/date';
  53. import to from 'await-to-js';
  54. const props = defineProps<{
  55. code: string;
  56. }>();
  57. const documentApi = useDocumentApi();
  58. const form = ref<any>(null);
  59. const projectInfo = ref<any>(null);
  60. const subjAmount = ref<any>(null);
  61. const loading = ref(false);
  62. const getFundType = (type: string) => {
  63. const types: Record<string, string> = {
  64. '10': '上级拨款',
  65. '20': '匹配经费',
  66. '30': '横向经费'
  67. };
  68. return types[type] || '-';
  69. };
  70. const formatMoney = (val: any) => {
  71. if (val === undefined || val === null) return '0.00';
  72. return Number(val).toLocaleString('zh-CN', { minimumFractionDigits: 2 });
  73. };
  74. const fetchData = async () => {
  75. if (!props.code) return;
  76. loading.value = true;
  77. const [err, res] = await to(documentApi.getFundReverseByCode(props.code));
  78. if (!err && res?.data) {
  79. form.value = res.data;
  80. // 同步 PC 逻辑:获取额外信息
  81. await Promise.all([
  82. getCardDetails(form.value.cardId),
  83. getAmountInfo(form.value)
  84. ]);
  85. }
  86. loading.value = false;
  87. };
  88. const getCardDetails = async (cardId: any) => {
  89. if (!cardId) return;
  90. const [err, res] = await to(documentApi.getFundCardById(cardId));
  91. if (!err && res?.data) {
  92. projectInfo.value = res.data;
  93. }
  94. };
  95. const getAmountInfo = async (f: any) => {
  96. if (!f.projectId || !f.subjCode) return;
  97. const params = {
  98. projectId: f.projectId,
  99. projectType: f.projectType,
  100. subjCode: f.subjCode,
  101. type: f.type,
  102. };
  103. const [err, res] = await to(documentApi.getSubjAmount(params));
  104. if (!err && res?.data) {
  105. subjAmount.value = res.data;
  106. }
  107. };
  108. onMounted(() => {
  109. fetchData();
  110. });
  111. watch(() => props.code, () => {
  112. fetchData();
  113. });
  114. </script>
  115. <style lang="scss" scoped>
  116. @import "./common.scss";
  117. .remark-content {
  118. font-size: 28rpx;
  119. color: #333;
  120. line-height: 1.6;
  121. padding: 10rpx 0;
  122. }
  123. </style>