ClaimForm.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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">
  9. <text class="label">项目到款</text>
  10. <text class="value">{{ form.projectName || '-' }}</text>
  11. </view>
  12. <view class="info-row">
  13. <text class="label">到款金额</text>
  14. <text class="value red-color">¥{{ formatAmount(netAmount) }} 元</text>
  15. </view>
  16. <view class="info-row">
  17. <text class="label">到款日期</text>
  18. <text class="value">{{ formatDate(paymentForm?.date) }}</text>
  19. </view>
  20. <view class="info-row">
  21. <text class="label">到款类型</text>
  22. <text class="value">{{ getDictLabel('PaymentReceivedType', paymentForm?.type) }}</text>
  23. </view>
  24. <view class="info-row">
  25. <text class="label">打款单位</text>
  26. <text class="value">{{ paymentForm?.unit || '-' }}</text>
  27. </view>
  28. <view class="info-row">
  29. <text class="label">管理费</text>
  30. <text class="value red-color">{{ paymentForm?.proportion || 0 }}% (¥{{ formatAmount(paymentForm?.manageAmount) }} 元)</text>
  31. </view>
  32. <view class="info-row">
  33. <text class="label">税费</text>
  34. <text class="value red-color">¥{{ formatAmount(paymentForm?.taxAmount) }} 元</text>
  35. </view>
  36. </view>
  37. <!-- 认领详情 -->
  38. <view class="common-section-card mt20" v-if="form.detail?.length">
  39. <view class="section-title">认领经费</view>
  40. <view class="funds-list">
  41. <view class="funds-item" v-for="(item, index) in form.detail" :key="index">
  42. <view class="f-row">
  43. <text class="f-name">{{ item.subjName }}</text>
  44. <text class="f-class">{{ item.subjCode }}</text>
  45. </view>
  46. <view class="f-grid">
  47. <view class="g-item highlight">
  48. <text class="gl">本次入账</text>
  49. <text class="gv red-color">¥{{ formatAmount(item.amount) }} 元</text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  57. </view>
  58. </template>
  59. <script setup lang="ts">
  60. import { ref, onMounted, watch, computed } from 'vue';
  61. import { useDocumentApi } from '@/api/document';
  62. import { useDict } from '@/hooks/useDict';
  63. import { formatDate } from '@/utils/date';
  64. import to from 'await-to-js';
  65. const props = defineProps<{
  66. code: string;
  67. }>();
  68. const { getDictLabel } = useDict('PaymentReceivedType');
  69. const documentApi = useDocumentApi();
  70. const form = ref<any>(null);
  71. const paymentForm = ref<any>(null);
  72. const loading = ref(false);
  73. // 计算纯到款金额 (总额 - 税费 - 管理费)
  74. const netAmount = computed(() => {
  75. if (!paymentForm.value) return 0;
  76. const amount = Number(paymentForm.value.amount || 0);
  77. const tax = Number(paymentForm.value.taxAmount || 0);
  78. const manage = Number(paymentForm.value.manageAmount || 0);
  79. return amount - tax - manage;
  80. });
  81. const formatAmount = (num: number | string) => {
  82. if (!num && num !== 0) return '0.00';
  83. return Number(num).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
  84. };
  85. const fetchData = async () => {
  86. if (!props.code) return;
  87. loading.value = true;
  88. // 1. 获取认领申请详情
  89. const [err, res] = await to(documentApi.getFundClaimById(props.code));
  90. if (!err && res?.data) {
  91. form.value = res.data;
  92. // 2. 如果有关联的财务到账ID,获取原始到账详情
  93. if (form.value.fundId) {
  94. const [fErr, fRes] = await to(documentApi.getFundById(form.value.fundId));
  95. if (!fErr && fRes?.data) {
  96. paymentForm.value = fRes.data;
  97. }
  98. }
  99. }
  100. loading.value = false;
  101. };
  102. onMounted(() => {
  103. fetchData();
  104. });
  105. watch(() => props.code, () => {
  106. fetchData();
  107. });
  108. </script>
  109. <style lang="scss" scoped>
  110. @import "./common.scss";
  111. </style>