This commit is contained in:
2026-03-07 03:04:15 +08:00
parent bfe6da3376
commit 557fcd578a
10 changed files with 1469 additions and 201 deletions
+86 -13
View File
@@ -760,7 +760,10 @@ const MoldInsightView = {
polling: false,
dragOver: false,
progress: 0,
history: null
history: null,
showFileHistory: false,
selectedFileHistory: null,
fileHistoryRecords: []
});
const loadHistory = async () => {
@@ -771,6 +774,21 @@ const MoldInsightView = {
}
};
const viewFileHistory = async (filename) => {
try {
state.selectedFileHistory = filename;
state.fileHistoryRecords = await apiRequest(`/api/history/${encodeURIComponent(filename)}`);
state.showFileHistory = true;
} catch (e) {
handleApiError(e, '加载文件历史');
}
};
const viewResult = (record) => {
state.showFileHistory = false;
router.push(`/moldinsight/result/${record.id}`);
};
const handleFileChange = (event) => {
const file = event.target.files[0];
if (!file) return;
@@ -844,6 +862,7 @@ const MoldInsightView = {
state.polling = false;
state.progress = 100;
addNotification('分析完成', 'success');
loadHistory();
router.push(`/moldinsight/result/${taskId}`);
return;
}
@@ -879,7 +898,9 @@ const MoldInsightView = {
handleDrop,
uploadFile,
formatFileSize,
formatDateTime
formatDateTime,
viewFileHistory,
viewResult
};
},
template: `
@@ -933,38 +954,90 @@ const MoldInsightView = {
</div>
<div v-if="state.history?.files?.length" class="section">
<h2 class="section-title">最近分析</h2>
<h2 class="section-title">分析历史</h2>
<div class="table-container">
<table class="data-table">
<thead>
<tr>
<th>文件名</th>
<th>大小</th>
<th>状态</th>
<th>分析时间</th>
<th>上传次数</th>
<th>文件大小</th>
<th>最新状态</th>
<th>最新分析时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="file in state.history.files.slice(0, 5)" :key="file.task_id">
<tr v-for="file in state.history.files" :key="file.filename">
<td>{{ file.filename }}</td>
<td>
<span class="badge badge-info">{{ file.upload_count }} 次</span>
</td>
<td>{{ formatFileSize(file.file_size) }}</td>
<td>
<span :class="['badge', file.status === 'completed' ? 'badge-success' : file.status === 'failed' ? 'badge-error' : 'badge-warning']">
{{ file.status }}
<span :class="['badge', file.latest_status === 'completed' ? 'badge-success' : file.latest_status === 'failed' ? 'badge-error' : 'badge-warning']">
{{ file.latest_status }}
</span>
</td>
<td>{{ formatDateTime(file.created_at) }}</td>
<td>{{ formatDateTime(file.latest_upload_time) }}</td>
<td>
<button v-if="file.status === 'completed'" class="btn-sm btn-primary" @click="$router.push('/moldinsight/result/' + file.task_id)">
查看
</button>
<div class="action-buttons">
<button v-if="file.latest_status === 'completed'" class="btn-sm btn-primary" @click="router.push('/moldinsight/result/' + file.latest_id)">
查看最新
</button>
<button class="btn-sm btn-secondary" @click="viewFileHistory(file.filename)">
历史记录
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div v-if="state.showFileHistory" class="modal-overlay" @click.self="state.showFileHistory = false">
<div class="modal-content" style="max-width: 800px;">
<div class="modal-header">
<h2>{{ state.selectedFileHistory }} - 历史记录</h2>
<button class="modal-close" @click="state.showFileHistory = false">×</button>
</div>
<div class="modal-body">
<table class="data-table">
<thead>
<tr>
<th>上传时间</th>
<th>文件大小</th>
<th>状态</th>
<th>体积 (mm³)</th>
<th>表面积 (mm²)</th>
<th>重量 (g)</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="record in state.fileHistoryRecords" :key="record.id">
<td>{{ formatDateTime(record.upload_time) }}</td>
<td>{{ formatFileSize(record.file_size) }}</td>
<td>
<span :class="['badge', record.status === 'completed' ? 'badge-success' : record.status === 'failed' ? 'badge-error' : 'badge-warning']">
{{ record.status }}
</span>
</td>
<td>{{ record.volume ? formatNumber(record.volume) : '-' }}</td>
<td>{{ record.surface_area ? formatNumber(record.surface_area) : '-' }}</td>
<td>{{ record.product_weight ? record.product_weight.toFixed(2) : '-' }}</td>
<td>
<button v-if="record.has_analysis" class="btn-sm btn-primary" @click="viewResult(record)">
查看详情
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
`
};