This commit is contained in:
cjw
2026-02-16 18:28:20 +08:00
parent 3c76e05fba
commit 6b3cd204f0
2 changed files with 64 additions and 423 deletions
-52
View File
@@ -167,58 +167,6 @@ body {
gap: 15px;
}
.key-info-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
}
/* 关键工艺参数布局由result.html内联样式控制 */
.data-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px;
}
.category-section {
background: #f8f9fa;
border-radius: 10px;
padding: 20px;
border-left: 4px solid #3498db;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.category-section:nth-child(1) {
border-left-color: #e74c3c;
}
.category-section:nth-child(2) {
border-left-color: #27ae60;
}
.category-section:nth-child(3) {
border-left-color: #f39c12;
}
.category-title {
font-size: 1.2em;
font-weight: bold;
margin-bottom: 15px;
color: #2c3e50;
display: flex;
align-items: center;
gap: 8px;
padding-bottom: 10px;
border-bottom: 2px solid rgba(0,0,0,0.1);
}
.category-content {
display: flex;
flex-direction: column;
gap: 12px;
}
.data-item {
background: white;
padding: 20px;
+64 -371
View File
@@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>分析结果 - STP文件几何分析工具</title>
<link rel="stylesheet" href="/static/style.css?v=14">
<link rel="stylesheet" href="/static/style.css">
<style>
.result-container {
max-width: 1200px;
@@ -107,70 +107,19 @@
gap: 10px;
}
/* 绝对强制关键工艺参数一行显示 - 三列并排 */
.key-info-categories {
display: flex !important;
flex-direction: row !important;
justify-content: space-between !important;
align-items: stretch !important;
gap: 15px !important;
margin-bottom: 20px !important;
width: 100% !important;
min-height: 220px !important;
flex-wrap: nowrap !important;
overflow: visible !important;
white-space: nowrap !important;
box-sizing: border-box !important;
.data-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0;
border-bottom: 1px solid #f5f5f5;
}
.key-info-categories .category-section {
display: flex !important;
flex-direction: column !important;
width: 32% !important;
min-width: 280px !important;
max-width: 380px !important;
min-height: 220px !important;
background: #f8f9fa !important;
border: 1px solid #e0e0e0 !important;
border-radius: 8px !important;
padding: 15px !important;
flex-shrink: 0 !important;
flex-grow: 0 !important;
box-sizing: border-box !important;
}
.key-info-categories .category-title {
font-weight: bold !important;
font-size: 16px !important;
color: #333 !important;
margin-bottom: 15px !important;
padding-bottom: 8px !important;
border-bottom: 1px solid #ddd !important;
}
.key-info-categories .category-content {
display: flex !important;
flex-direction: column !important;
gap: 12px !important;
}
.key-info-categories .data-item {
display: flex !important;
justify-content: space-between !important;
align-items: center !important;
padding: 8px 0 !important;
border-bottom: 1px solid #f0f0f0 !important;
}
.key-info-categories .data-item:last-child {
border-bottom: none !important;
}
.data-label {
font-weight: bold;
color: #666;
}
.data-value {
color: #333;
text-align: right;
@@ -232,23 +181,38 @@
</div>
<script>
// 从模板获取任务数据
const task = JSON.parse('{{ task | tojson | safe }}');
// 页面加载完成后显示任务数据
// 从URL获取任务ID
const pathParts = window.location.pathname.split('/');
const taskId = pathParts[pathParts.length - 1];
// 页面加载完成后获取任务数据
document.addEventListener('DOMContentLoaded', function() {
if (task && task.task_id) {
loadTaskData(taskId);
});
async function loadTaskData(taskId) {
try {
const response = await fetch(`/status/${taskId}`);
if (!response.ok) {
throw new Error('获取任务数据失败');
}
const task = await response.json();
displayTaskInfo(task);
displayResults(task);
} else {
} catch (error) {
document.getElementById('taskInfo').innerHTML = `
<div class="error-message">
<h3>❌ 加载失败</h3>
<p>无法获取任务数据</p>
<p>${error.message}</p>
<button class="upload-btn" onclick="loadTaskData('${taskId}')">
重试
</button>
</div>
`;
}
});
}
function displayTaskInfo(task) {
const taskInfo = document.getElementById('taskInfo');
@@ -313,15 +277,10 @@
</div>
</div>
<div class="result-section" style="grid-column: 1 / -1;">
<div class="section-title">🔧 关键工艺参数</div>
${displayKeyInfo(task.key_info)}
</div>
<div class="result-section">
<div class="section-title">🏭 模具型腔数据</div>
<div class="section-title">🔧 关键工艺参数</div>
<div class="data-grid">
${displayCavityData(task)}
${displayKeyInfo(task.key_info)}
</div>
</div>
@@ -338,34 +297,6 @@
${displayTopologyData(task.geometry_data)}
</div>
</div>
<div class="result-section">
<div class="section-title">🎯 检测到的特征</div>
<div class="data-grid">
${displayFeaturesData(task)}
</div>
</div>
<div class="result-section">
<div class="section-title">💡 设计建议</div>
<div class="data-grid">
${displayRecommendationsData(task)}
</div>
</div>
<div class="result-section">
<div class="section-title">📈 质量指标</div>
<div class="data-grid">
${displayMetricsData(task)}
</div>
</div>
<div class="result-section">
<div class="section-title">🔍 分析信息</div>
<div class="data-grid">
${displayAnalysisInfo(task)}
</div>
</div>
`;
}
@@ -398,63 +329,37 @@
const geoChars = cavityKeyInfo.geometric_characteristics || {};
return `
<div style="display: flex; flex-direction: row; justify-content: space-between; gap: 15px; width: 100%; flex-wrap: nowrap; box-sizing: border-box;">
<!-- 模具参数 -->
<div style="display: flex; flex-direction: column; width: 32%; min-width: 280px; background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 8px; padding: 15px; flex-shrink: 0; box-sizing: border-box;">
<div style="font-weight: bold; font-size: 16px; color: #333; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px solid #ddd;">🔧 模具参数</div>
<div style="display: flex; flex-direction: column; gap: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0;">
<div style="font-weight: bold; color: #666;">收缩率</div>
<div style="color: #333; text-align: right;">${metadata.shrinkage_rate !== undefined ? metadata.shrinkage_rate : 'N/A'}</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0;">
<div style="font-weight: bold; color: #666;">拔模角</div>
<div style="color: #333; text-align: right;">${metadata.draft_angle !== undefined ? metadata.draft_angle + '°' : 'N/A'}</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0;">
<div style="font-weight: bold; color: #666;">型腔材料</div>
<div style="color: #333; text-align: right;">${manufacturingInfo.mold_material || 'N/A'}</div>
</div>
</div>
</div>
<!-- 几何特性 -->
<div style="display: flex; flex-direction: column; width: 32%; min-width: 280px; background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 8px; padding: 15px; flex-shrink: 0; box-sizing: border-box;">
<div style="font-weight: bold; font-size: 16px; color: #333; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px solid #ddd;">📐 几何特性</div>
<div style="display: flex; flex-direction: column; gap: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0;">
<div style="font-weight: bold; color: #666;">产品体积</div>
<div style="color: #333; text-align: right;">${geoChars.product_volume || 'N/A'}</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0;">
<div style="font-weight: bold; color: #666;">产品重量</div>
<div style="color: #333; text-align: right;">${geoChars.product_weight || 'N/A'}</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0;">
<div style="font-weight: bold; color: #666;">壁厚范围</div>
<div style="color: #333; text-align: right;">${geoChars.wall_thickness_range || 'N/A'}</div>
</div>
</div>
</div>
<!-- 制造要求 -->
<div style="display: flex; flex-direction: column; width: 32%; min-width: 280px; background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 8px; padding: 15px; flex-shrink: 0; box-sizing: border-box;">
<div style="font-weight: bold; font-size: 16px; color: #333; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px solid #ddd;">🏭 制造要求</div>
<div style="display: flex; flex-direction: column; gap: 12px;">
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0;">
<div style="font-weight: bold; color: #666;">分型线长度</div>
<div style="color: #333; text-align: right;">${manufacturingInfo.parting_line_length || 'N/A'}</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0;">
<div style="font-weight: bold; color: #666;">预估周期</div>
<div style="color: #333; text-align: right;">${manufacturingInfo.estimated_cycle_time || 'N/A'}</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0;">
<div style="font-weight: bold; color: #666;">制造精度</div>
<div style="color: #333; text-align: right;">${manufacturingInfo.manufacturing_tolerance || 'N/A'}</div>
</div>
</div>
</div>
<div class="data-item">
<div class="data-label">收缩率</div>
<div class="data-value">${metadata.shrinkage_rate !== undefined ? metadata.shrinkage_rate : 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">拔模角</div>
<div class="data-value">${metadata.draft_angle !== undefined ? metadata.draft_angle + '°' : 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">分型线长度</div>
<div class="data-value">${manufacturingInfo.parting_line_length || 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">产品体积</div>
<div class="data-value">${geoChars.product_volume || 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">产品重量</div>
<div class="data-value">${geoChars.product_weight || 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">壁厚范围</div>
<div class="data-value">${geoChars.wall_thickness_range || 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">型腔材料</div>
<div class="data-value">${manufacturingInfo.mold_material || 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">预估周期</div>
<div class="data-value">${manufacturingInfo.estimated_cycle_time || 'N/A'}</div>
</div>
`;
}
@@ -499,218 +404,6 @@
`;
}
function displayCavityData(task) {
// 检查是否有型腔数据
let cavityData = {};
// 检查多个可能的数据位置
if (task.mold_cavity_data) {
cavityData = task.mold_cavity_data;
} else if (task.cavity_data) {
cavityData = task.cavity_data;
} else if (task.key_info && task.key_info.mold_cavities) {
cavityData = task.key_info;
}
if (!cavityData || Object.keys(cavityData).length === 0) {
return '<div class="no-data">无型腔数据</div>';
}
// 显示完整的JSON格式数据
return `
<div style="background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; padding: 15px; margin-top: 10px;">
<div style="font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-x: auto;">
${JSON.stringify(cavityData, null, 2)}
</div>
</div>
`;
}
function displayFeaturesData(task) {
// 检查是否有特征数据
let features = [];
// 检查多个可能的数据位置
if (task.features && task.features.length > 0) {
features = task.features;
} else if (task.mold_cavity_data && task.mold_cavity_data.detected_features) {
features = task.mold_cavity_data.detected_features;
} else if (task.detected_features) {
features = task.detected_features;
}
if (features.length > 0) {
return features.map(feature => `
<div class="data-item">
<div class="data-label">${feature.feature_type || '未知特征'}</div>
<div class="data-value">
${feature.description ? feature.description + '<br>' : ''}
置信度: ${(feature.confidence || 0).toFixed(2)}
${feature.location ? '<br>位置: ' + feature.location : ''}
</div>
</div>
`).join('');
}
return '<div class="no-data">无特征数据</div>';
}
function displayRecommendationsData(task) {
// 检查是否有建议数据
let recommendations = [];
// 检查多个可能的数据位置
if (task.recommendations && task.recommendations.length > 0) {
recommendations = task.recommendations;
} else if (task.mold_cavity_data && task.mold_cavity_data.design_recommendations) {
recommendations = task.mold_cavity_data.design_recommendations;
} else if (task.design_recommendations) {
recommendations = task.design_recommendations;
}
if (recommendations.length > 0) {
return recommendations.map(rec => `
<div class="data-item">
<div class="data-label">${rec.rec_type || '建议'}</div>
<div class="data-value">
优先级: ${rec.priority || '中'}
${rec.description ? '<br>' + rec.description : ''}
${rec.reason ? '<br>原因: ' + rec.reason : ''}
</div>
</div>
`).join('');
}
return '<div class="no-data">无建议数据</div>';
}
function displayMetricsData(task) {
// 检查是否有质量指标数据
let metrics = {};
// 检查多个可能的数据位置
if (task.quality_metrics) {
metrics = task.quality_metrics;
} else if (task.mold_cavity_data && task.mold_cavity_data.quality_metrics) {
metrics = task.mold_cavity_data.quality_metrics;
}
let metricsHTML = '';
// 如果有质量指标数据
if (Object.keys(metrics).length > 0) {
// 体积利用率
if (metrics.volume_utilization) {
metricsHTML += `
<div class="data-item">
<div class="data-label">体积利用率</div>
<div class="data-value">${metrics.volume_utilization}%</div>
</div>
`;
}
// 壁厚均匀性
if (metrics.wall_thickness_uniformity) {
metricsHTML += `
<div class="data-item">
<div class="data-label">壁厚均匀性</div>
<div class="data-value">${metrics.wall_thickness_uniformity}%</div>
</div>
`;
}
// 几何复杂度
if (metrics.geometric_complexity) {
metricsHTML += `
<div class="data-item">
<div class="data-label">几何复杂度</div>
<div class="data-value">${metrics.geometric_complexity}</div>
</div>
`;
}
// 可成型性评分
if (metrics.moldability_score) {
metricsHTML += `
<div class="data-item">
<div class="data-label">可成型性评分</div>
<div class="data-value">${metrics.moldability_score}</div>
</div>
`;
}
}
// 如果没有质量指标数据,从几何数据中计算一些基础指标
if (task.geometry_data && metricsHTML === '') {
const geo = task.geometry_data;
// 体积表面积比作为质量指标
if (geo.volume && geo.surface_area) {
const volumeSurfaceRatio = geo.volume / geo.surface_area;
metricsHTML += `
<div class="data-item">
<div class="data-label">体积表面积比</div>
<div class="data-value">${volumeSurfaceRatio.toFixed(4)}</div>
</div>
`;
}
// 如果有边界框数据,计算紧凑度
if (geo.bounding_box && geo.bounding_box.dimensions) {
const dims = geo.bounding_box.dimensions;
const compactness = geo.volume ? geo.volume / (dims[0] * dims[1] * dims[2]) : 0;
if (compactness > 0) {
metricsHTML += `
<div class="data-item">
<div class="data-label">几何紧凑度</div>
<div class="data-value">${(compactness * 100).toFixed(2)}%</div>
</div>
`;
}
}
// 拓扑复杂度
if (geo.topology) {
const faces = geo.topology.faces || 0;
const edges = geo.topology.edges || 0;
const vertices = geo.topology.vertices || 0;
metricsHTML += `
<div class="data-item">
<div class="data-label">拓扑复杂度</div>
<div class="data-value">面:${faces} 边:${edges} 顶点:${vertices}</div>
</div>
`;
}
}
return metricsHTML || '<div class="no-data">无质量指标数据</div>';
}
function displayAnalysisInfo(task) {
let infoHTML = '';
if (task.geometry_data) {
const geo = task.geometry_data;
infoHTML += `
<div class="data-item">
<div class="data-label">分析时间</div>
<div class="data-value">${task.upload_time || 'N/A'}</div>
</div>
<div class="data-item">
<div class="data-label">分析方法</div>
<div class="data-value">${geo.analysis_method || 'N/A'}</div>
</div>
`;
}
if (task.analysis_result) {
infoHTML += `
<div class="data-item">
<div class="data-label">分析状态</div>
<div class="data-value">${task.status || 'N/A'}</div>
</div>
`;
}
return infoHTML || '<div class="no-data">无分析信息</div>';
}
// 工具函数
function getStatusText(status) {
const statusMap = {