态势感知平台-首页概览的数据格式修改

This commit is contained in:
d266377
2026-02-02 09:34:00 +08:00
parent 3fc27a684b
commit 483c6d5c6b
4 changed files with 821 additions and 349 deletions

View File

@@ -42,15 +42,20 @@ const hmCompanies = ref<string>('加载中...');
const loading = ref(true);
// 格式化数字的工具函数
const formatNumber = (num: number, unit: string = ''): string => {
if (num >= 100000000) {
return (num / 100000000).toFixed(1) + '亿';
} else if (num >= 10000) {
return (num / 10000).toFixed(1) + '万';
} else if (num >= 1000) {
return (num / 1000).toFixed(1) + '千';
const formatNumber = (num: number, unit: string = '', forceUnit?: string): string => {
if (forceUnit === 'wan') {
// 强制以"万"为单位显示
return Math.floor(num) + '万+';
}
return num.toString();
if (num >= 100000000) {
return Math.floor(num / 100000000) + '亿+';
} else if (num >= 10000) {
return Math.floor(num / 10000) + '万+';
} else if (num >= 1000) {
return Math.floor(num / 1000) + '千+';
}
return num.toString() + '+';
};
// 获取统计数据
@@ -64,11 +69,11 @@ const fetchStats = async () => {
const { developer, certificationDeveloper, wuhanCertificationDeveloper, project, company } = businessData.data;
// 格式化数据显示
hmDevelopers.value = `${formatNumber(developer)}+`;
hmCertificationDevelopers.value = `${formatNumber(certificationDeveloper)}+`;
whHmCertificationDevelopers.value = `${formatNumber(wuhanCertificationDeveloper)}+`;
hmProjects.value = `${formatNumber(project)}`;
hmCompanies.value = `${formatNumber(company)}+`;
hmDevelopers.value = `${formatNumber(developer, '', 'wan')}`;
hmCertificationDevelopers.value = `${formatNumber(certificationDeveloper, '', 'wan')}`;
whHmCertificationDevelopers.value = `${formatNumber(wuhanCertificationDeveloper, '', 'wan')}`;
hmProjects.value = `${project}`; // 项目数不需要特殊格式化
hmCompanies.value = `${company}+`; // 公司数直接加+号
} else {
console.error('获取鸿蒙统计数据失败:', businessData.msg || '未知错误');
// 设置默认值