| | |
| | | profitRate: { value: 0, trend: 0 }, |
| | | }) |
| | | |
| | | const fetchMonthlyIncome = async () => { |
| | | const res = await getMonthlyIncome() |
| | | const data = res?.data || {} |
| | | const toNumber = (val) => { |
| | | const num = Number(val) |
| | | return Number.isFinite(num) ? num : 0 |
| | | } |
| | | |
| | | income.value.amount = data.monthlyIncome ?? 0 |
| | | const collectionRate = Number(data.collectionRate ?? 0) |
| | | const overdueRate = Number(data.overdueRate ?? 0) |
| | | income.value.repayRate = { |
| | | value: collectionRate, |
| | | trend: collectionRate >= 0 ? 1 : -1, |
| | | } |
| | | income.value.overdueCount = data.overdueNum ?? 0 |
| | | income.value.overdueRate = { |
| | | value: overdueRate, |
| | | trend: overdueRate >= 0 ? 1 : -1, |
| | | const fetchMonthlyIncome = async () => { |
| | | try { |
| | | const res = await getMonthlyIncome() |
| | | const data = res?.data || {} |
| | | |
| | | income.value.amount = toNumber(data.monthlyIncome) |
| | | const collectionRate = toNumber(data.collectionRate) |
| | | const overdueRate = toNumber(data.overdueRate) |
| | | income.value.repayRate = { |
| | | value: collectionRate, |
| | | trend: collectionRate >= 0 ? 1 : -1, |
| | | } |
| | | income.value.overdueCount = toNumber(data.overdueNum) |
| | | income.value.overdueRate = { |
| | | value: overdueRate, |
| | | trend: overdueRate >= 0 ? 1 : -1, |
| | | } |
| | | } catch { |
| | | income.value.amount = 0 |
| | | income.value.repayRate = { value: 0, trend: 0 } |
| | | income.value.overdueCount = 0 |
| | | income.value.overdueRate = { value: 0, trend: 0 } |
| | | } |
| | | } |
| | | |
| | | const fetchMonthlyExpenditure = async () => { |
| | | const res = await getMonthlyExpenditure() |
| | | const data = res?.data || {} |
| | | try { |
| | | const res = await getMonthlyExpenditure() |
| | | const data = res?.data || {} |
| | | |
| | | expense.value.amount = data.monthlyExpenditure ?? 0 |
| | | const paymentRate = Number(data.paymentRate ?? 0) |
| | | expense.value.netProfit = { |
| | | value: paymentRate, |
| | | trend: paymentRate >= 0 ? 1 : -1, |
| | | } |
| | | expense.value.grossProfit = data.grossProfit ?? 0 |
| | | expense.value.amount = toNumber(data.monthlyExpenditure) |
| | | const paymentRate = toNumber(data.paymentRate) |
| | | expense.value.netProfit = { |
| | | value: paymentRate, |
| | | trend: paymentRate >= 0 ? 1 : -1, |
| | | } |
| | | expense.value.grossProfit = toNumber(data.grossProfit) |
| | | |
| | | const profitMarginRate = Number(data.profitMarginRate ?? 0) |
| | | expense.value.profitRate = { |
| | | value: profitMarginRate, |
| | | trend: profitMarginRate >= 0 ? 1 : -1, |
| | | const profitMarginRate = toNumber(data.profitMarginRate) |
| | | expense.value.profitRate = { |
| | | value: profitMarginRate, |
| | | trend: profitMarginRate >= 0 ? 1 : -1, |
| | | } |
| | | } catch { |
| | | expense.value.amount = 0 |
| | | expense.value.netProfit = { value: 0, trend: 0 } |
| | | expense.value.grossProfit = 0 |
| | | expense.value.profitRate = { value: 0, trend: 0 } |
| | | } |
| | | } |
| | | |
| | | const isWanAmount = (val) => { |
| | | const num = Number(val) || 0 |
| | | const num = toNumber(val) |
| | | return Math.abs(num) >= 10000 |
| | | } |
| | | |
| | | const formatAmountWanNumber = (val) => { |
| | | const num = Number(val) || 0 |
| | | const num = toNumber(val) |
| | | if (Math.abs(num) >= 10000) { |
| | | return (num / 10000).toFixed(2) |
| | | } |
| | |
| | | } |
| | | |
| | | const formatPercent = (val) => { |
| | | const num = Number(val) || 0 |
| | | const num = toNumber(val) |
| | | // 百分比展示始终用绝对值,小数保留两位 |
| | | return `${Math.abs(num).toFixed(2)}%` |
| | | } |