fix: 真正合并两个卡片为单一表格

This commit is contained in:
yilv committed 2026-04-12 18:32:39 +08:00
1 parent e097255a65
commit 68f398396f
1 file changed
+109 -238
+109 -238
View File
@@ -48,242 +48,67 @@
</div>
</div>
<!-- 原始数据(滤波处理) -->
<el-card class="data-section" style="margin-bottom: 20px">
<template #header>
<span>原始数据(滤波处理)</span>
</template>
<div class="tab-toolbar">
<el-button v-if="userStore.isAdmin" @click="syncRawFolders">{{ $t('common.sync') }}</el-button>
<el-select v-model="rawFilterStatus" placeholder="筛选状态" clearable style="width: 120px" @change="fetchRawFolders">
<el-option label="未处理" value="unprocessed" />
<el-option label="处理中" value="processing" />
<el-option label="已完成" value="completed" />
<el-option label="失败" value="failed" />
</el-select>
<el-button v-if="userStore.isAdmin" type="danger" :disabled="!selectedRawIds.length" @click="batchDeleteRaw">批量删除</el-button>
<el-button v-if="userStore.isAdmin" :disabled="!selectedRawIds.length" @click="openRawBatchAssign">分配研究员</el-button>
</div>
<el-table :data="rawFolders" style="width: 100%" v-loading="rawFoldersLoading" @selection-change="onRawSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="folder_name" :label="$t('common.folder')" min-width="150" />
<el-table-column prop="status" :label="$t('common.status')" width="120">
<template #default="scope">
<el-tag :type="scope.row.status === 'completed' ? 'success' : scope.row.status === 'processing' ? 'warning' : scope.row.status === 'failed' ? 'danger' : 'info'">
{{ getRawStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="inference_status" :label="$t('admin.inference')" width="120">
<template #default="scope">
<el-tag :type="scope.row.inference_status === 'inferred' ? 'success' : scope.row.inference_status === 'inferencing' ? 'warning' : 'info'">
{{ getRawInferenceStatusText(scope.row.inference_status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="researcher_id" :label="$t('common.researcherId')" width="100" />
<el-table-column :label="$t('dataEntries.dataType')" width="100">
<template #default="scope">
<el-tag type="info">{{ $t('dataEntries.raw') }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('common.actions')" width="280" fixed="right">
<template #default="scope">
<el-button size="small" @click="runRawJob(scope.row)">{{ $t('common.run') }}</el-button>
<el-button size="small" @click="showRawSummary(scope.row)">{{ $t('common.summary') }}</el-button>
<el-button v-if="userStore.isAdmin" size="small" @click="openRawAssign(scope.row)">{{ $t('common.assign') }}</el-button>
<el-button v-if="userStore.isAdmin" size="small" type="danger" @click="deleteRawFolder(scope.row)">{{ $t('common.delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination
v-model:current-page="rawPage"
v-model:page-size="rawPerPage"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="rawTotal"
@size-change="fetchRawFolders"
@current-change="fetchRawFolders"
/>
</div>
<!-- 处理任务列表 -->
<el-card style="margin-top: 12px">
<template #header>
<div class="card-header">
<span>处理任务</span>
<div class="header-actions">
<el-select v-model="rawJobFilter.status" placeholder="筛选状态" clearable size="small" style="width: 120px" @change="fetchRawJobs">
<el-option label="排队中" value="queued" />
<el-option label="运行中" value="running" />
<el-option label="已完成" value="completed" />
<el-option label="失败" value="failed" />
</el-select>
<el-button size="small" @click="fetchRawJobs">刷新</el-button>
</div>
</div>
<!-- 单一数据表格 -->
<el-card class="data-table-card">
<el-table
:data="filteredData"
style="width: 100%"
v-loading="loading"
@selection-change="onSelectionChange"
>
<!-- 选择列 -->
<el-table-column type="selection" width="55" />
<!-- 数据类型列 -->
<el-table-column label="数据类型" width="100">
<template #default="scope">
<el-tag :type="scope.row.data_status === 'raw' ? 'info' : scope.row.data_status === 'filtered' ? 'warning' : 'success'">
{{ scope.row.data_status === 'raw' ? '原始' : scope.row.data_status === 'filtered' ? '已滤波' : '已完成' }}
</el-tag>
</template>
<el-table :data="rawJobs" style="width: 100%" v-loading="rawJobsLoading" @expand-change="handleRawExpand">
<el-table-column type="expand">
<template #default="props">
<div class="expand-content">
<h4>ZIP 文件处理详情</h4>
<el-table :data="props.row.zip_tasks || []" size="small" style="font-size: 12px">
<el-table-column prop="zip_filename" label="ZIP 文件" min-width="200" />
<el-table-column prop="status" label="状态" width="80">
<template #default="scope">
<el-tag :type="getZipTaskStatusType(scope.row.status)" size="small">
{{ getZipTaskStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="files_processed" label="已处理文件" width="80" />
<el-table-column prop="segments_created" label="片段数" width="70" />
<el-table-column label="操作" width="80">
<template #default="scope">
<el-button
size="small"
type="danger"
:disabled="scope.row.status !== 'queued' && scope.row.status !== 'running'"
@click="cancelZipTask(scope.row)"
>
取消
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
</el-table-column>
<el-table-column prop="id" label="ID" width="70" />
<el-table-column prop="folder_name" :label="$t('common.folder')" min-width="150" />
<el-table-column prop="status" :label="$t('common.status')" width="120">
<template #default="scope">
<el-tag :type="getJobStatusType(scope.row.status)">
{{ getJobStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="zip_task_count" label="ZIP 任务数" width="90" />
<el-table-column prop="start_time" :label="$t('common.start')" width="180" />
<el-table-column prop="end_time" :label="$t('common.end')" width="180" />
</el-table>
<div class="pagination-container">
<el-pagination
v-model:current-page="rawJobPage"
v-model:page-size="rawJobPerPage"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="rawJobTotal"
@size-change="fetchRawJobs"
@current-change="fetchRawJobs"
/>
</div>
</el-card>
</el-card>
<!-- 已处理数据(推理) -->
<el-card class="data-section" style="margin-bottom: 20px">
<template #header>
<span>已处理数据(推理)</span>
</template>
<div class="tab-toolbar">
<el-select v-model="filterStatus" placeholder="处理状态" clearable style="width: 120px" @change="fetchItems">
<el-option label="未处理" value="unprocessed" />
<el-option label="处理中" value="processing" />
<el-option label="已完成" value="completed" />
<el-option label="失败" value="failed" />
</el-select>
<el-select v-model="filterInferenceStatus" placeholder="推理状态" clearable style="width: 120px" @change="fetchItems">
<el-option label="未推理" value="none" />
<el-option label="推理中" value="inferencing" />
<el-option label="已推理" value="inferred" />
</el-select>
<el-button type="primary" :disabled="!selectedIds.length" @click="openPipelineDialog">{{ $t('common.run') }}</el-button>
<el-button v-if="userStore.isAdmin" :disabled="!selectedIds.length" @click="openBatchAssign">{{ $t('admin.assignResearcher') }}</el-button>
<el-button type="danger" :disabled="!selectedIds.length" @click="batchDelete">批量删除</el-button>
</div>
<div class="table-responsive">
<el-table :data="items" style="width: 100%" @selection-change="onSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="patient_id" :label="$t('common.patientId')" min-width="150" />
<el-table-column prop="status" :label="$t('common.status')" width="120">
<template #default="scope">
<el-tag :type="scope.row.status === 'completed' ? 'success' : scope.row.status === 'processing' ? 'warning' : scope.row.status === 'failed' ? 'danger' : 'info'">
{{ scope.row.status === 'completed' ? '已完成' : scope.row.status === 'processing' ? '处理中' : scope.row.status === 'failed' ? '失败' : '未处理' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="inference_status" :label="$t('admin.inference')" width="120">
<template #default="scope">
<el-tag :type="scope.row.inference_status === 'inferred' ? 'success' : scope.row.inference_status === 'inferencing' ? 'warning' : 'info'">
{{ scope.row.inference_status === 'inferred' ? '已推理' : scope.row.inference_status === 'inferencing' ? '推理中' : '未推理' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="researcher_name" label="研究员" width="120">
<template #default="scope">
<span v-if="scope.row.researcher_name">{{ scope.row.researcher_name }}</span>
<el-tag v-else size="small" type="info">未分配</el-tag>
</template>
</el-table-column>
<el-table-column prop="file_count" :label="$t('admin.fileCount')" width="120">
<template #default="scope">
<span>{{ scope.row.file_count || 0 }}</span>
<el-tag v-if="scope.row.has_filtered && !scope.row.has_inference" size="small" type="success" style="margin-left: 5px">已滤波</el-tag>
<el-tag v-else-if="scope.row.has_inference" size="small" type="primary" style="margin-left: 5px">已推理</el-tag>
</template>
</el-table-column>
<el-table-column prop="last_processed" :label="$t('common.lastProcessed')" width="180" />
<el-table-column :label="$t('dataEntries.dataType')" width="100">
<template #default="scope">
<el-tag type="success">{{ $t('dataEntries.processed') }}</el-tag>
</template>
</el-table-column>
<el-table-column label="进度" width="200">
<template #default="scope">
<div v-if="getRunningTask(scope.row.patient_id)">
<el-progress
:percentage="getPatientProgress(scope.row.patient_id).toFixed(2)"
:status="getRunningTask(scope.row.patient_id).status === 'completed' ? 'success' : getRunningTask(scope.row.patient_id).status === 'failed' ? 'exception' : ''"
:stroke-width="15"
/>
<div style="font-size: 12px; color: #909399; margin-top: 4px">
{{ getPatientStatusText(scope.row.patient_id) }}
</div>
</div>
<el-tag v-else size="small" type="info">无进行中任务</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('common.actions')" width="350" fixed="right">
<template #default="scope">
<div class="action-buttons">
<el-button size="small" @click="viewDetail(scope.row)">{{ $t('common.view') }}</el-button>
<el-button size="small" v-if="hasRunInference" @click="runInferenceSingle(scope.row)">{{ $t('admin.runInference') }}</el-button>
<el-button size="small" @click="showHistoryResults(scope.row)">{{ $t('admin.inferenceResults') }}</el-button>
<el-button size="small" type="danger" @click="deleteSingle(scope.row)">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-container">
<el-pagination
v-model:current-page="page"
v-model:page-size="perPage"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="onPageChange"
@current-change="onPageChange"
/>
</div>
</el-table-column>
<!-- 名称列 -->
<el-table-column label="名称" min-width="180">
<template #default="scope">
{{ scope.row.display_name }}
</template>
</el-table-column>
<!-- 处理状态 -->
<el-table-column label="处理状态" width="120">
<template #default="scope">
<el-tag :type="scope.row.status === 'completed' ? 'success' : scope.row.status === 'processing' ? 'warning' : scope.row.status === 'failed' ? 'danger' : 'info'">
{{ scope.row.status === 'completed' ? '已完成' : scope.row.status === 'processing' ? '处理中' : scope.row.status === 'failed' ? '失败' : '未处理' }}
</el-tag>
</template>
</el-table-column>
<!-- 推理状态 -->
<el-table-column label="推理状态" width="120">
<template #default="scope">
<el-tag v-if="scope.row.data_status !== 'raw'" :type="scope.row.inference_status === 'inferred' ? 'success' : scope.row.inference_status === 'inferencing' ? 'warning' : 'info'">
{{ scope.row.inference_status === 'inferred' ? '已推理' : scope.row.inference_status === 'inferencing' ? '推理中' : '未推理' }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" width="220" fixed="right">
<template #default="scope">
<el-button v-if="scope.row.can_run" size="small" type="primary" @click="handleRun(scope.row)">
{{ scope.row.data_status === 'raw' ? '全流程' : '推理' }}
</el-button>
<el-button v-if="scope.row.can_view_results" size="small" @click="viewResults(scope.row)">
查看结果
</el-button>
<el-button size="small" type="danger" @click="deleteItem(scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- Pipeline 任务列表对话框 -->
@@ -678,6 +503,7 @@ const selectedIds = ref([])
// 统一列表
const unifiedData = ref([])
const filteredData = ref([])
const loading = ref(false)
// 筛选条件
const filterStatus = ref('')
@@ -778,6 +604,7 @@ const isTaskTimeout = computed(() => {
// 加载统一列表数据
const loadUnifiedData = async () => {
loading.value = true
try {
// 并行请求两个 API
const rawParams = { page: rawPage.value, per_page: rawPerPage.value }
@@ -795,22 +622,36 @@ const loadUnifiedData = async () => {
// 处理原始数据
const rawItems = (rawRes.items || rawRes.data?.items || rawRes || []).map(item => ({
...item,
data_type: 'raw'
data_type: 'raw',
data_status: 'raw',
display_name: item.folder_name || item.name || '',
status: item.status || 'unprocessed',
inference_status: 'none',
can_run: true,
can_view_results: false
}))
// 处理已处理数据
const processedItems = (processedRes.items || processedRes.data?.items || processedRes || []).map(item => ({
...item,
data_type: 'processed'
data_type: 'processed',
data_status: item.has_inference ? 'completed' : item.has_filtered ? 'filtered' : 'raw',
display_name: item.patient_id || item.folder_name || item.name || '',
status: item.status || 'unprocessed',
inference_status: item.inference_status || 'none',
can_run: true,
can_view_results: item.has_inference || item.inference_status === 'inferred'
}))
// 合并数据
unifiedData.value = [...rawItems, ...processedItems]
// 初始化筛选数据
filteredData.value = unifiedData.value
applyFilters()
} catch (error) {
console.error('加载数据失败:', error)
ElMessage.error('加载数据失败')
} finally {
loading.value = false
}
}
@@ -827,6 +668,36 @@ const applyFilters = () => {
})
}
// 查看结果(统一表格中的按钮回调)
const viewResults = (row) => {
if (row.data_type === 'processed') {
showHistoryResults(row)
} else {
ElMessage.info('原始数据暂无结果')
}
}
// 删除单条数据(统一表格中的按钮回调)
const deleteItem = async (row) => {
try {
await ElMessageBox.confirm(
`确定要删除 "${row.display_name}" 吗?此操作不可恢复。`,
'警告',
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
)
} catch {
return
}
try {
const id = row.folder_id || row.id || row.patient_id
await api.delete(`/admin/integration/folders/${id}`)
ElMessage.success('删除成功')
await loadUnifiedData()
} catch (error) {
ElMessage.error(error.response?.data?.msg || '删除失败')
}
}
// 获取选中项
const getSelectedItems = () => {
return selectedItems.value || []