SciFundReverse.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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">{{ 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 to from 'await-to-js';
  53. const props = defineProps<{
  54. code: string;
  55. }>();
  56. const documentApi = useDocumentApi();
  57. const form = ref<any>(null);
  58. const projectInfo = ref<any>(null);
  59. const subjAmount = ref<any>(null);
  60. const loading = ref(false);
  61. const getFundType = (type: string) => {
  62. const types: Record<string, string> = {
  63. '10': '上级拨款',
  64. '20': '匹配经费',
  65. '30': '横向经费'
  66. };
  67. return types[type] || '-';
  68. };
  69. const formatMoney = (val: any) => {
  70. if (val === undefined || val === null) return '0.00';
  71. return Number(val).toLocaleString('zh-CN', { minimumFractionDigits: 2 });
  72. };
  73. const fetchData = async () => {
  74. if (!props.code) return;
  75. loading.value = true;
  76. const [err, res] = await to(documentApi.getFundReverseByCode(props.code));
  77. if (!err && res?.data) {
  78. form.value = res.data;
  79. // 同步 PC 逻辑:获取额外信息
  80. await Promise.all([
  81. getCardDetails(form.value.cardId),
  82. getAmountInfo(form.value)
  83. ]);
  84. }
  85. loading.value = false;
  86. };
  87. const getCardDetails = async (cardId: any) => {
  88. if (!cardId) return;
  89. const [err, res] = await to(documentApi.getFundCardById(cardId));
  90. if (!err && res?.data) {
  91. projectInfo.value = res.data;
  92. }
  93. };
  94. const getAmountInfo = async (f: any) => {
  95. if (!f.projectId || !f.subjCode) return;
  96. const params = {
  97. projectId: f.projectId,
  98. projectType: f.projectType,
  99. subjCode: f.subjCode,
  100. type: f.type,
  101. };
  102. const [err, res] = await to(documentApi.getSubjAmount(params));
  103. if (!err && res?.data) {
  104. subjAmount.value = res.data;
  105. }
  106. };
  107. onMounted(() => {
  108. fetchData();
  109. });
  110. watch(() => props.code, () => {
  111. fetchData();
  112. });
  113. </script>
  114. <style lang="scss" scoped>
  115. @import "./common.scss";
  116. .remark-content {
  117. font-size: 28rpx;
  118. color: #333;
  119. line-height: 1.6;
  120. padding: 10rpx 0;
  121. }
  122. </style>