1
0

feat: 增加财务指标显示

This commit is contained in:
2025-09-15 18:42:36 +08:00
parent b569d62a25
commit 697a58a0e4
3 changed files with 161 additions and 22 deletions

View File

@@ -4,7 +4,6 @@ import {amisRender, commonInfo, readOnlyDialogOptions, remoteMappings} from '../
import type {Schema} from 'amis'
import {isNil} from 'es-toolkit'
// 格式化财务数字显示的公共函数
const formatFinanceNumber = (value: number): string => {
if (isNil(value)) {
return '-'
@@ -25,7 +24,13 @@ const formatFinanceNumber = (value: number): string => {
return isNegative ? `-${formatted}` : formatted
}
// 格式化百分比数字显示的公共函数
const formatDaysNumber = (value: number): string => {
if (isNil(value)) {
return '-'
}
return `${value.toFixed(0)}`
}
const formatPercentageNumber = (value: number): string => {
if (isNil(value)) {
return '-'
@@ -33,7 +38,7 @@ const formatPercentageNumber = (value: number): string => {
return `${(value * 100).toFixed(2)}%`
}
type FinanceType = 'PERCENTAGE' | 'FINANCE'
type FinanceType = 'PERCENTAGE' | 'FINANCE' | 'DAYS'
const financePropertyLabel = (id: string | undefined, label: string, type: FinanceType, field: string): Schema => {
if (!id) {
@@ -43,7 +48,20 @@ const financePropertyLabel = (id: string | undefined, label: string, type: Finan
}
}
let current = new Date().getFullYear()
let formatter: (value: number) => string = type === 'PERCENTAGE' ? formatPercentageNumber : formatFinanceNumber
let formatter: (value: number) => string
switch (type) {
case 'PERCENTAGE':
formatter = formatPercentageNumber
break
case 'FINANCE':
formatter = formatFinanceNumber
break
case 'DAYS':
formatter = formatDaysNumber
break
default:
formatter = (v: number) => v.toFixed(2)
}
return {
type: 'wrapper',
size: 'none',
@@ -229,29 +247,21 @@ function StockDetail() {
{
label: financePropertyLabel(id, '总资产', 'FINANCE', 'totalAssets'),
content: '${balanceSheet.totalAssets}',
span: 4,
span: 2,
},
{
label: financePropertyLabel(id, '总负债', 'FINANCE', 'totalLiabilities'),
content: '${balanceSheet.totalLiabilities}',
span: 2,
},
{
label: financePropertyLabel(id, '流动资产', 'FINANCE', 'currentAssets'),
content: '${balanceSheet.currentAssets}',
},
{
label: financePropertyLabel(id, '流动资产占比', 'PERCENTAGE', 'currentAssetsToTotalAssetsRatio'),
content: '${balanceSheet.currentAssetsRatio}',
},
{
label: financePropertyLabel(id, '非流动资产', 'FINANCE', 'fixedAssets'),
content: '${balanceSheet.fixedAssets}',
},
{
label: financePropertyLabel(id, '非流动资产占比', 'PERCENTAGE', 'fixedAssetsToTotalAssetsRatio'),
content: '${balanceSheet.fixedAssetsRatio}',
},
{
label: financePropertyLabel(id, '总负债', 'FINANCE', 'totalLiabilities'),
content: '${balanceSheet.totalLiabilities}',
span: 4,
},
{
label: financePropertyLabel(id, '流动负债', 'FINANCE', 'currentLiabilities'),
content: '${balanceSheet.currentLiabilities}',
@@ -260,6 +270,14 @@ function StockDetail() {
label: financePropertyLabel(id, '流动负债占比', 'PERCENTAGE', 'currentLiabilitiesToTotalAssetsRatio'),
content: '${balanceSheet.currentLiabilitiesRatio}',
},
{
label: financePropertyLabel(id, '流动资产占比', 'PERCENTAGE', 'currentAssetsToTotalAssetsRatio'),
content: '${balanceSheet.currentAssetsRatio}',
},
{
label: financePropertyLabel(id, '非流动资产', 'FINANCE', 'fixedAssets'),
content: '${balanceSheet.fixedAssets}',
},
{
label: financePropertyLabel(id, '非流动负债', 'FINANCE', 'longTermLiabilities'),
content: '${balanceSheet.longTermLiabilities}',
@@ -300,6 +318,62 @@ function StockDetail() {
},
],
},
'财务指标',
{
className: 'my-2',
type: 'property',
column: 4,
items: [
{
label: financePropertyLabel(id, '流动比率', 'FINANCE', 'currentRatio'),
content: '${indicate.currentRatio}',
},
{
label: financePropertyLabel(id, '速动比率', 'FINANCE', 'quickRatio'),
content: '${indicate.quickRatio}',
},
{
label: financePropertyLabel(id, 'ROE', 'FINANCE', 'returnOnEquity'),
content: '${indicate.roe}',
},
{
label: financePropertyLabel(id, 'ROA', 'FINANCE', 'returnOnAssets'),
content: '${indicate.roa}',
},
{
label: financePropertyLabel(id, '应收账款周转率', 'FINANCE', 'accountsReceivableTurnover'),
content: '${indicate.accountsReceivableTurnover}',
},
{
label: financePropertyLabel(id, '应收账款周转天', 'DAYS', 'daysAccountsReceivableTurnover'),
content: '${indicate.daysAccountsReceivableTurnover}',
},
{
label: financePropertyLabel(id, '存货周转率', 'FINANCE', 'inventoryTurnover'),
content: '${indicate.inventoryTurnover}',
},
{
label: financePropertyLabel(id, '存货周转天', 'DAYS', 'daysInventoryTurnover'),
content: '${indicate.daysInventoryTurnover}',
},
{
label: financePropertyLabel(id, '固定资产周转率', 'FINANCE', 'fixedAssetsTurnover'),
content: '${indicate.fixedAssetsTurnover}',
},
{
label: financePropertyLabel(id, '固定资产周转天', 'DAYS', 'daysFixedAssetsTurnover'),
content: '${indicate.daysFixedAssetsTurnover}',
},
{
label: financePropertyLabel(id, '总资产周转率', 'FINANCE', 'totalAssetsTurnover'),
content: '${indicate.totalAssetsTurnover}',
},
{
label: financePropertyLabel(id, '总资产周转天', 'DAYS', 'daysTotalAssetsTurnover'),
content: '${indicate.daysTotalAssetsTurnover}',
},
],
},
{type: 'divider'},
],
},