This commit is contained in:
2026-07-12 00:53:38 +08:00
parent d254377951
commit 25ae6f610c
14 changed files with 1208 additions and 835 deletions
+51 -21
View File
@@ -1,24 +1,43 @@
/**
* 企业级页面渲染模块。
* 负责企业总览、企业指标分析、项目图表和项目清单弹窗,数据来源主要是 core 模块按企业派生的项目样本。
* 负责企业总览、企业指标分析、项目图表和项目清单弹窗,数据来自企业监控接口。
*/
function renderEnterpriseView() {
const enterprise = getEnterprise(state.enterpriseName);
const stats = getStats(enterprise);
const projects = generateProjects(enterprise, state.dimension);
const indicators = buildEnterpriseIndicatorItems(getWarningIndicators(), projects, stats);
const summary = getProjectMasterSummary();
const indicators = getWarningIndicators();
const analysisIndicators = projectMasterDataState.metricDatas.length ? projectMasterDataState.metricDatas : indicators;
const projects = (projectMasterDataState.projectAnalysises || []).map((item) => ({
id: item.projectId,
unitId: item.unitId,
unit: enterprise.name,
name: item.name,
created: item.isOnline,
usageRate: item.usageRate,
accuracyRate: item.accuracyRate,
warningCount: item.usageRate < 80 ? 1 : 0,
systemStatus: item.isOnline ? "已上线" : "未上线",
lastUpdate: summary.dataDate || "",
owner: "-",
risk: item.usageRate < 65 ? "高" : item.usageRate < 80 ? "中" : "低"
}));
const enterpriseOnlineRate = summary.onlineRate;
const belowStandardProjects = summary.failProjectNum;
// 新开工维度下部分企业没有项目,单独展示空态,避免图表按空数组渲染出异常坐标。
if (!stats.projectCount) {
if (projectMasterDataState.loading) {
app.innerHTML = '<div class="empty-state">正在获取企业监控数据...</div>';
return;
}
if (!projects.length && projectMasterDataState.error) {
app.innerHTML = `
<section class="panel">
<div class="panel-header">
<div>
<h2 class="panel-title">${enterprise.name} · ${dimLabel()}看板</h2>
<div class="panel-note">当前维度暂无项目数据,可切换到“所有项目”查看企业总体情况。</div>
<div class="panel-note">${projectMasterDataState.error}</div>
</div>
</div>
<div class="empty-state">当前企业在「${dimLabel()}」维度暂无数据。</div>
<div class="empty-state">企业监控接口数据加载失败。</div>
</section>
`;
return;
@@ -26,17 +45,16 @@
app.innerHTML = `
<section class="metric-cards">
${miniMetric("项目数量", stats.projectCount, "个", `${enterprise.name} 当前${dimLabel()}项目数量`, "enterprise-project-list")}
${miniMetric("上线率", fmtPercent(stats.onlineRate), "", "项目已建档并进入系统", "enterprise-offline-list")}
${miniMetric("使用率", fmtPercent(stats.usageRate), "", "连续三天无更新视未使用")}
${miniMetric("准确率", fmtPercent(stats.accuracyRate), "", "数据准确情况")}
${miniMetric("项目上线率", summary.proInfoText, "", `上线率 ${fmtFixedPercent(enterpriseOnlineRate, 2)}`, "group-online-stats")}
${miniMetric("预立项项目数", summary.preProjectTotal, "个", "点击查看项目上线统计", "group-online-stats")}
${miniMetric("待建项目数", summary.pendingTotal, "个", "点击查看项目上线统计", "group-online-stats")}
${miniMetric("未达标项目数", belowStandardProjects, "个", "指标使用率低于 80% 的项目", "below-standard-projects")}
${miniMetric("项目指标使用率", fmtPercent(summary.usageRate), "", "指标使用率低于 80% 的项目计入未达标项目")}
${miniMetric("项目指标准确率", fmtPercent(summary.accuracyRate), "", "")}
</section>
<section class="indicator-strip">
${renderFocusIndicators(indicators.slice(0, 8), 0, { highlightHigh: false })}
<div class="indicator-more-cell">
<button type="button" class="more-btn" data-action="enterprise-more-indicators">更多</button>
</div>
</section>
<article class="panel trend-panel enterprise-trend-panel">
@@ -52,9 +70,10 @@
</div>
</div>
<div class="chart-box">${renderTrendChart({
online: enterprise.trend.online,
usage: enterprise.trend.usage,
accuracy: enterprise.trend.accuracy
date: projectMasterDataState.trendCurve?.Date || [],
online: projectMasterDataState.trendCurve?.OnlineRate || [],
usage: projectMasterDataState.trendCurve?.UsageRate || [],
accuracy: projectMasterDataState.trendCurve?.AccuracyRate || []
}, 1840, 112)}</div>
</article>
@@ -85,7 +104,7 @@
<button type="button" class="more-btn" data-action="enterprise-more-indicators">更多</button>
</div>
</div>
${renderEnterpriseIndicatorAnalysis(indicators)}
${renderEnterpriseIndicatorAnalysis(analysisIndicators)}
</article>
</section>
`;
@@ -148,7 +167,18 @@
*/
function renderEnterpriseProjectListModal(type) {
const enterprise = getEnterprise(state.enterpriseName);
const projects = generateProjects(enterprise, state.dimension);
const projects = (projectMasterDataState.projectAnalysises || []).map((item) => ({
id: item.projectId,
unitId: item.unitId,
name: item.name,
created: item.isOnline,
usageRate: item.usageRate,
accuracyRate: item.accuracyRate,
warningCount: item.usageRate < 80 ? 1 : 0,
lastUpdate: getProjectMasterSummary().dataDate || "-",
owner: "-",
risk: item.usageRate < 65 ? "高" : item.usageRate < 80 ? "中" : "低"
}));
const rows = type === "offline"
? projects.filter((project) => !project.created)
: projects;
@@ -190,7 +220,7 @@
</thead>
<tbody>
${rows.map((project) => `
<tr class="clickable-row" data-project="${project.id}">
<tr class="clickable-row" data-project="${project.id}" data-project-unit-id="${escapeHtmlAttr(project.unitId || "")}">
<td>${project.name}</td>
<td>${project.created ? '<span class="status-pill ok">已上线</span>' : '<span class="status-pill bad">未上线</span>'}</td>
<td class="num">${fmtPercent(project.usageRate)}</td>