Files
banben/frontend/src/views/governance/GovernanceView.vue
T

230 lines
8.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import {
listDataset,
listGovernanceJobs,
previewHints,
runHint,
runMerge,
runOptimize,
runPurify,
type DatasetItem,
type DefectItem,
type DuplicateItem,
type GovernanceHint,
type GovernanceJob
} from '@/api/governance'
import { governStatusLabel, governStatusTagType } from '@/constants/dict'
const loading = ref(false)
const running = ref('')
const jobs = ref<GovernanceJob[]>([])
const hintReport = ref<GovernanceHint>({
duplicateGroupCount: 0,
defectCount: 0,
duplicateGroups: [],
defects: []
})
const dataset = ref<DatasetItem[]>([])
const actions = [
{ type: 'MERGE', title: '聚同', desc: '将不同来源、不同媒体类型的同一文献元数据聚合为一条,并标注来源。' },
{ type: 'OPTIMIZE', title: '优化', desc: '整合聚同文献的不同描述元数据,生成质量更高、要素更完整的元数据。' },
{ type: 'HINT', title: '提示', desc: '生成疑似同一文献提示清单、疑似元数据错漏提示清单。' },
{ type: 'PURIFY', title: '提纯', desc: '将相关纸电图书数据从全部图书数据中提取出来,形成版本资源数据集。' }
]
const duplicateRows = computed(() => {
const rows: Array<DuplicateItem & { reason: string }> = []
for (const group of hintReport.value.duplicateGroups || []) {
for (const record of group.records || []) {
rows.push({ ...record, reason: group.reason })
}
}
return rows
})
async function fetchJobs() {
loading.value = true
try {
jobs.value = await listGovernanceJobs()
} finally {
loading.value = false
}
}
async function loadHints() {
hintReport.value = await previewHints()
}
async function loadDataset() {
dataset.value = await listDataset()
}
async function handleRun(action: (typeof actions)[number]) {
running.value = action.type
try {
if (action.type === 'HINT') {
hintReport.value = await runHint()
ElMessage.success(hintReport.value.job?.resultSummary || '提示完成')
} else if (action.type === 'MERGE') {
const job = await runMerge()
ElMessage.success(`${action.title}完成:${job.resultSummary || ''}`)
await loadHints()
} else if (action.type === 'OPTIMIZE') {
const job = await runOptimize()
ElMessage.success(`${action.title}完成:${job.resultSummary || ''}`)
await loadHints()
} else {
const job = await runPurify()
ElMessage.success(`${action.title}完成:${job.resultSummary || ''}`)
await loadDataset()
}
fetchJobs()
} finally {
running.value = ''
}
}
function statusTag(status?: string) {
if (status === 'SUCCESS') return 'success'
if (status === 'RUNNING') return 'warning'
if (status === 'FAILED') return 'danger'
return 'info'
}
function issueText(row: DefectItem) {
return (row.issues || []).join(';')
}
onMounted(async () => {
await fetchJobs()
try {
await loadHints()
} catch {
// 错误已由响应拦截器提示
}
try {
await loadDataset()
} catch {
// 错误已由响应拦截器提示
}
})
</script>
<template>
<div class="page-card">
<h3 class="page-title">数据治理</h3>
<el-alert
title="建议顺序:先看提示清单,再对完全一致的重复文献执行聚同、优化,最后提纯。疑似同一文献只出清单,不自动合并。"
type="info"
:closable="false"
class="mb-16"
/>
<el-row :gutter="16">
<el-col v-for="a in actions" :key="a.type" :xs="24" :sm="12">
<el-card shadow="hover" class="gov-card" :class="'tone-' + a.type">
<h4>{{ a.title }}</h4>
<p>{{ a.desc }}</p>
<el-button type="primary" :loading="running === a.type" @click="handleRun(a)">
执行{{ a.title }}
</el-button>
</el-card>
</el-col>
</el-row>
<h3 class="page-title" style="margin-top: 8px">
疑似同一文献提示清单({{ hintReport.duplicateGroupCount }} 组)
</h3>
<el-table :data="duplicateRows" border stripe empty-text="暂无疑似同一文献">
<el-table-column prop="reason" label="提示原因" min-width="280" show-overflow-tooltip />
<el-table-column prop="processNo" label="加工编号" width="140" />
<el-table-column prop="title" label="正题名" min-width="180" show-overflow-tooltip />
<el-table-column prop="author" label="责任者" width="100" />
<el-table-column prop="isbn" label="ISBN" width="170" show-overflow-tooltip />
<el-table-column prop="mediaType" label="媒体" width="80" />
<el-table-column prop="sourceLibrary" label="来源馆" min-width="160" show-overflow-tooltip />
<el-table-column label="治理状态" width="100">
<template #default="{ row }">
<el-tag :type="governStatusTagType(row.governStatus)" size="small">
{{ governStatusLabel(row.governStatus) }}
</el-tag>
</template>
</el-table-column>
</el-table>
<h3 class="page-title" style="margin-top: 20px">
疑似元数据错漏提示清单({{ hintReport.defectCount }} 条)
</h3>
<el-table :data="hintReport.defects" border stripe empty-text="暂无疑似错漏">
<el-table-column prop="processNo" label="加工编号" width="140" />
<el-table-column prop="title" label="正题名" min-width="180" show-overflow-tooltip />
<el-table-column prop="author" label="责任者" width="100" />
<el-table-column prop="sourceLibrary" label="来源馆" min-width="160" show-overflow-tooltip />
<el-table-column prop="mediaType" label="媒体" width="80" />
<el-table-column label="错漏说明" min-width="280" show-overflow-tooltip>
<template #default="{ row }">{{ issueText(row) }}</template>
</el-table-column>
</el-table>
<h3 class="page-title" style="margin-top: 20px">版本资源数据集({{ dataset.length }} 条)</h3>
<el-table :data="dataset" border stripe empty-text="尚未提纯">
<el-table-column prop="processNo" label="加工编号" width="140" />
<el-table-column prop="title" label="正题名" min-width="200" show-overflow-tooltip />
<el-table-column prop="author" label="责任者" width="100" />
<el-table-column prop="mediaType" label="媒体" width="80" />
<el-table-column prop="contentForm" label="内容形式" width="100" />
<el-table-column prop="sourceLibrary" label="来源馆" min-width="160" show-overflow-tooltip />
<el-table-column prop="publishYear" label="出版年份" width="100" />
<el-table-column label="治理状态" width="100">
<template #default="{ row }">
<el-tag :type="governStatusTagType(row.governStatus)" size="small">
{{ governStatusLabel(row.governStatus) }}
</el-tag>
</template>
</el-table-column>
</el-table>
<h3 class="page-title" style="margin-top: 20px">治理任务历史</h3>
<el-table v-loading="loading" :data="jobs" border stripe>
<el-table-column type="index" label="#" width="50" />
<el-table-column prop="jobType" label="治理类型" width="120" />
<el-table-column label="状态" width="110">
<template #default="{ row }">
<el-tag :type="statusTag(row.status)" size="small">{{ row.status }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="affectedCount" label="影响记录数" width="120" />
<el-table-column prop="resultSummary" label="结果摘要" min-width="260" show-overflow-tooltip />
<el-table-column prop="createTime" label="执行时间" width="170" />
</el-table>
</div>
</template>
<style scoped lang="scss">
.gov-card {
margin-bottom: 16px;
border-top: 3px solid var(--brand-primary);
h4 {
margin: 0 0 8px;
font-family: var(--font-serif);
letter-spacing: 1px;
}
p {
font-size: 13px;
color: var(--text-muted);
min-height: 38px;
margin: 0 0 12px;
}
}
.tone-MERGE { border-top-color: var(--brand-primary-deep); }
.tone-OPTIMIZE { border-top-color: var(--brand-gold); }
.tone-HINT { border-top-color: var(--brand-primary); }
.tone-PURIFY { border-top-color: var(--brand-gold-deep); }
</style>