From cbfeb239d857131a3fa66747f10c44422e303a24 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Tue, 28 Jul 2026 16:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E7=99=BB=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 8 ++++++++ .../contract/components/examineRegistration.vue | 5 ++--- .../contract/components/paymentRegistration.vue | 4 ++-- src/views/contract/contractLedger.vue | 7 +++---- src/views/contract/contractList.vue | 12 +++++------- src/views/contract/contractProgress.vue | 7 +++---- src/views/contract/seeContract.vue | 6 +++--- 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index fc12e4b..bd2d5f6 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -131,6 +131,14 @@ export function debounce(fn,delay=500){ export function moneyFormatter(money,precision=2){ return Number(money).toFixed(precision).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') } +/** 支付占比(%),签订价为 0 或未填时返回 0.00,避免 Infinity */ +export function calcPayPercent(paid, money, precision = 2) { + const contractMoney = Number(money) + if (!contractMoney) { + return (0).toFixed(precision) + } + return (((Number(paid) || 0) / contractMoney) * 100).toFixed(precision) +} //金额分隔复原 export function moneyRecovery(money){ return parseFloat(money.replace(/[^\d\.-]/g, "")); diff --git a/src/views/contract/components/examineRegistration.vue b/src/views/contract/components/examineRegistration.vue index 652a802..8c82684 100644 --- a/src/views/contract/components/examineRegistration.vue +++ b/src/views/contract/components/examineRegistration.vue @@ -134,7 +134,7 @@ import {getFundLog,detailFundLog,editorFundLog} from "@/api/paymentRegistration/ import {getBudget} from "@/api/budget/budget"; import {detailContract} from "@/api/contract/contract"; import {Message} from "element-ui"; -import {parseTime} from "@/utils"; +import {parseTime, calcPayPercent} from "@/utils"; export default { data() { @@ -234,8 +234,7 @@ export default { }, //支付占比 percentPay(){ - let total = this.totalMoney() - return (total/this.contract.money)*100 || 0 + return calcPayPercent(this.totalMoney(), this.contract.money) }, async getRegistration(id){ diff --git a/src/views/contract/components/paymentRegistration.vue b/src/views/contract/components/paymentRegistration.vue index 29dcc33..1bc8757 100644 --- a/src/views/contract/components/paymentRegistration.vue +++ b/src/views/contract/components/paymentRegistration.vue @@ -281,7 +281,7 @@ import { getFundLog, addFundLog } from "@/api/paymentRegistration/fundLog"; import { getBudget } from "@/api/budget/budget"; import { detailContract, editorContract } from "@/api/contract/contract"; import { Message } from "element-ui"; -import { parseTime } from "@/utils"; +import { parseTime, calcPayPercent } from "@/utils"; export default { data() { @@ -453,7 +453,7 @@ export default { //支付占比 percentPay() { let total = this.totalMoney(); - return Number(this.contract.money) ? ((total / Number(this.contract.money)) * 100).toFixed(2) : 0; + return calcPayPercent(total, this.contract.money); }, closeDetailLoading() { diff --git a/src/views/contract/contractLedger.vue b/src/views/contract/contractLedger.vue index 33bdff3..c88693b 100644 --- a/src/views/contract/contractLedger.vue +++ b/src/views/contract/contractLedger.vue @@ -985,7 +985,7 @@ import { getparameter } from "@/api/system/dictionary"; import { listdeptNoAuth } from "@/api/system/department"; import { getBudget } from "@/api/budget/budget"; import { getOatoken } from "@/api/oatoken"; -import { deepCopy, parseTime, resetSelect,moneyFormatter } from '@/utils' +import { deepCopy, parseTime, resetSelect,moneyFormatter, calcPayPercent } from '@/utils' import { Message } from "element-ui"; import { getInfo } from "@/api/user.js"; import { getToken } from "@/utils/auth"; @@ -1231,12 +1231,11 @@ export default { label: "支付占比", width: 140, customFn: (row) => { - let per = - ((row.fund_log_total / row.money || 0) * 100)?.toFixed(2) || 0; + let per = calcPayPercent(row.fund_log_total, row.money); return (