init
This commit is contained in:
+47
-1
@@ -1260,8 +1260,40 @@ const ResultView = {
|
||||
const isFoamMaterial = (material) => {
|
||||
return material === 'aluminum_foam';
|
||||
};
|
||||
|
||||
const exportCAD = async (format) => {
|
||||
try {
|
||||
const taskId = route.params.taskId;
|
||||
const result = await apiRequest('/api/export-mold', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
task_id: taskId,
|
||||
formats: [format],
|
||||
components: ['cavity', 'core', 'parting_surface']
|
||||
})
|
||||
});
|
||||
|
||||
if (result.status === 'success' && result.data.files) {
|
||||
for (const file of result.data.files) {
|
||||
const downloadUrl = `/api/export-download/${file.filepath.replace(/\\/g, '/').split('/').slice(-2).join('/')}`;
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
link.download = file.filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
addNotification(`已导出 ${result.data.files.length} 个 ${format.toUpperCase()} 文件`, 'success');
|
||||
} else if (result.data.errors && result.data.errors.length > 0) {
|
||||
addNotification(`导出失败: ${result.data.errors[0]}`, 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
addNotification(`导出失败: ${e.message}`, 'error');
|
||||
}
|
||||
};
|
||||
|
||||
return { state, formatFileSize, formatDateTime, formatNumber, getPriorityText, isFoamMaterial };
|
||||
return { state, formatFileSize, formatDateTime, formatNumber, getPriorityText, isFoamMaterial, exportCAD };
|
||||
},
|
||||
template: `
|
||||
<div class="page-container">
|
||||
@@ -1284,6 +1316,20 @@ const ResultView = {
|
||||
<span :class="['badge', state.task.status === 'completed' ? 'badge-success' : 'badge-error']">
|
||||
{{ state.task.status }}
|
||||
</span>
|
||||
<div v-if="state.task.status === 'completed'" class="export-buttons">
|
||||
<button class="btn-sm btn-primary" @click="exportCAD('step')" title="导出STEP格式(UG/FreeCAD/SolidWorks通用)">
|
||||
导出 STEP
|
||||
</button>
|
||||
<button class="btn-sm btn-secondary" @click="exportCAD('stl')" title="导出STL网格格式(3D打印预览)">
|
||||
导出 STL
|
||||
</button>
|
||||
<button class="btn-sm btn-secondary" @click="exportCAD('iges')" title="导出IGES格式(兼容旧系统)">
|
||||
导出 IGES
|
||||
</button>
|
||||
<button class="btn-sm btn-secondary" @click="exportCAD('brep')" title="导出BRep格式(FreeCAD原生)">
|
||||
导出 BRep
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="result-grid">
|
||||
|
||||
Reference in New Issue
Block a user