ClaimForm.vue 3.4 KB

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