优化跳转
This commit is contained in:
@@ -54,7 +54,7 @@ import {
|
||||
type ContractSegmentPackage
|
||||
} from '@/lib/contractSegment'
|
||||
import { industryTypeList } from '@/sql'
|
||||
import { roundTo } from '@/lib/decimal'
|
||||
import { roundTo, sumNullableNumbers, toFiniteNumber } from '@/lib/decimal'
|
||||
import { formatThousands } from '@/lib/numberFormat'
|
||||
import {
|
||||
AlertDialogAction,
|
||||
@@ -228,12 +228,6 @@ const getCurrentProjectIndustry = async (): Promise<string> => {
|
||||
return typeof data?.projectIndustry === 'string' ? data.projectIndustry.trim() : ''
|
||||
}
|
||||
|
||||
const toFiniteNumber = (value: unknown): number | null => {
|
||||
if (value == null || value === '') return null
|
||||
const num = Number(value)
|
||||
return Number.isFinite(num) ? num : null
|
||||
}
|
||||
|
||||
const formatBudgetAmount = (value: number | null | undefined) =>
|
||||
typeof value === 'number' && Number.isFinite(value) ? `${formatThousands(value, 2)} 元` : '--'
|
||||
|
||||
@@ -296,9 +290,8 @@ const loadHtMethodTotalByRow = async (mainStorageKey: string, rowId: string) =>
|
||||
sumHourlyMethodFee(hourlyState),
|
||||
sumQuantityMethodFee(quantityState)
|
||||
]
|
||||
const validParts = parts.filter((item): item is number => typeof item === 'number' && Number.isFinite(item))
|
||||
if (validParts.length === 0) return null
|
||||
return roundTo(validParts.reduce((sum, value) => sum + value, 0), 2)
|
||||
const total = sumNullableNumbers(parts)
|
||||
return total == null ? null : roundTo(total, 2)
|
||||
}
|
||||
|
||||
const loadHtMainTotalFee = async (mainStorageKey: string) => {
|
||||
@@ -309,9 +302,8 @@ const loadHtMainTotalFee = async (mainStorageKey: string) => {
|
||||
.filter(Boolean)
|
||||
if (rowIds.length === 0) return null
|
||||
const rowTotals = await Promise.all(rowIds.map(rowId => loadHtMethodTotalByRow(mainStorageKey, rowId)))
|
||||
const validTotals = rowTotals.filter((item): item is number => typeof item === 'number' && Number.isFinite(item))
|
||||
if (validTotals.length === 0) return null
|
||||
return roundTo(validTotals.reduce((sum, value) => sum + value, 0), 2)
|
||||
const total = sumNullableNumbers(rowTotals)
|
||||
return total == null ? null : roundTo(total, 2)
|
||||
}
|
||||
|
||||
const loadContractBudgetFee = async (contractId: string) => {
|
||||
@@ -322,9 +314,8 @@ const loadContractBudgetFee = async (contractId: string) => {
|
||||
loadHtMainTotalFee(`htExtraFee-${contractId}-reserve`)
|
||||
])
|
||||
const parts = [serviceFee, additionalFee, reserveFee]
|
||||
const validParts = parts.filter((item): item is number => typeof item === 'number' && Number.isFinite(item))
|
||||
if (validParts.length === 0) return null
|
||||
return roundTo(validParts.reduce((sum, value) => sum + value, 0), 2)
|
||||
const total = sumNullableNumbers(parts)
|
||||
return total == null ? null : roundTo(total, 2)
|
||||
}
|
||||
|
||||
const refreshContractBudgets = async () => {
|
||||
|
||||
Reference in New Issue
Block a user