| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <template>
- <div class="report-unknown admin-page">
- <el-card>
- <PageHeader slot="header" title="未知报告审核">
- <el-select v-model="statusFilter" size="small" class="filter-select-140" @change="fetchClusters">
- <el-option label="全部" value="" />
- <el-option label="收集" value="collecting" />
- <el-option label="可生成" value="ready" />
- <el-option label="已生成" value="generated" />
- </el-select>
- </PageHeader>
- <div class="adm-table-wrap">
- <el-table :data="clusters" v-loading="loading" border stripe height="100%">
- <el-table-column prop="id" label="ID" width="60">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('id', $event)">ID{{ sortIcon('id') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="clusterKey" label="聚类键" width="140">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('clusterKey', $event)">聚类键{{ sortIcon('clusterKey') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="reportCount" label="报告数" width="80">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('reportCount', $event)">报告数{{ sortIcon('reportCount') }}</span>
- </template>
- </el-table-column>
- <el-table-column label="状态" width="100">
- <template slot-scope="{ row }">
- <StatusTag :type="statusType(row.status)" :text="statusText(row.status)" />
- </template>
- </el-table-column>
- <el-table-column prop="generatedTypeId" label="生成类型" width="140">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('generatedTypeId', $event)">生成类型{{ sortIcon('generatedTypeId') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="updatedAt" label="更新时间" width="180">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('updatedAt', $event)">更新时间{{ sortIcon('updatedAt') }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="160" fixed="right">
- <template slot-scope="{ row }">
- <el-button size="mini" type="primary" @click="handleDetail(row)">详情</el-button>
- <el-button v-if="row.status === 'ready'" size="mini" type="success" @click="handleGenerate(row)">生成类型</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </el-card>
- <!-- 详情对话框 -->
- <el-dialog :visible.sync="detailVisible" title="聚类详情" width="750px" :close-on-click-modal="false">
- <template v-if="currentCluster">
- <el-descriptions :column="2" border size="small">
- <el-descriptions-item label="聚类键">{{ currentCluster.clusterKey }}</el-descriptions-item>
- <el-descriptions-item label="报告数">{{ currentCluster.reportCount }}</el-descriptions-item>
- <el-descriptions-item label="状态">{{ statusText(currentCluster.status) }}</el-descriptions-item>
- <el-descriptions-item label="生成类型">{{ currentCluster.generatedTypeId || '—' }}</el-descriptions-item>
- </el-descriptions>
- <h4>公共文本特征</h4>
- <pre class="detail-pre">{{ currentCluster.commonSignatures }}</pre>
- <h4>LLM 解析模板</h4>
- <pre class="detail-pre">{{ formatJson(currentCluster.llmTemplate) }}</pre>
- <h4>聚类内报告</h4>
- <el-table :data="uploads" v-loading="uploadLoading" border size="small">
- <el-table-column prop="id" label="ID" width="60" />
- <el-table-column prop="fileUrl" label="文件" min-width="200" />
- <el-table-column prop="uploadedAt" label="上传时间" width="180" />
- </template>
- </el-dialog>
-
- </el-table>
- </div>
- </template>
- <script>
- import { getUnknownClusters, getClusterUploads, generateTypeFromCluster } from '@/api/reportParser'
- import SortMixin from '@/mixins/SortMixin'
- export default {
- name: 'ReportUnknownCluster',
- mixins: [SortMixin],
- data() {
- return {
- loading: false, uploadLoading: false,
- clusters: [], statusFilter: '',
- sortableColumns: { id: 'ID', clusterKey: '聚类键', reportCount: '报告数', generatedTypeId: '生成类型', updatedAt: '更新时间' },
- detailVisible: false, currentCluster: null,
- uploads: [],
- }
- },
- mounted() { this.fetchClusters() },
- methods: {
- loadList() {
- this.fetchClusters()
- },
- async fetchClusters() {
- this.loading = true
- try {
- var params = { page: 1, size: 50, status: this.statusFilter }
- if (this.sortState.length > 0) params.sort = this.sortState
- const res = await getUnknownClusters(params)
- this.clusters = res.data?.records || res.data || []
- } catch (e) { this.$message.error('加载失败') }
- this.loading = false
- },
- statusType(status) {
- return { collecting: 'info', ready: 'warning', generated: 'success', imported: 'success' }[status] || 'info'
- },
- statusText(status) {
- return { collecting: '收集', ready: '可生成', generated: '已生成', imported: '已导入' }[status] || status
- },
- formatJson(str) {
- if (!str) return ''
- try { return JSON.stringify(JSON.parse(str), null, 2) } catch (e) { return str }
- },
- async handleDetail(row) {
- this.currentCluster = row
- this.detailVisible = true
- this.uploads = []
- this.uploadLoading = true
- try {
- const res = await getClusterUploads({ clusterId: row.id })
- this.uploads = res.data || []
- } catch (e) { this.$message.error('加载报告失败') }
- this.uploadLoading = false
- },
- handleGenerate(row) {
- this.$confirm('确认为此聚类生成报告类型?将创建待审核的报告类型和指纹规则。', '提示', { type: 'warning' })
- .then(async () => {
- try {
- const res = await generateTypeFromCluster({ clusterId: row.id })
- this.$message.success('已生成类型: ' + (res.data?.typeId || ''))
- this.fetchClusters()
- } catch (e) { this.$message.error('生成失败') }
- }).catch(() => {})
- },
- }
- }
- </script>
- <style scoped>
- .detail-pre {
- background: var(--adm-bg-header);
- border: 1px solid var(--adm-border-split);
- border-radius: 4px;
- padding: 10px;
- max-height: 300px;
- overflow: auto;
- font-size: 12px;
- white-space: pre-wrap;
- word-break: break-all;
- }
- /* == C 批内联清理工具类 == */
- .filter-select-140 { width: 140px; }
- </style>
|