ReportUnknownCluster.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="report-unknown admin-page">
  3. <el-card>
  4. <PageHeader slot="header" title="未知报告审核">
  5. <el-select v-model="statusFilter" size="small" class="filter-select-140" @change="fetchClusters">
  6. <el-option label="全部" value="" />
  7. <el-option label="收集" value="collecting" />
  8. <el-option label="可生成" value="ready" />
  9. <el-option label="已生成" value="generated" />
  10. </el-select>
  11. </PageHeader>
  12. <div class="adm-table-wrap">
  13. <el-table :data="clusters" v-loading="loading" border stripe height="100%">
  14. <el-table-column prop="id" label="ID" width="60">
  15. <template slot="header">
  16. <span class="sort-header" @click.stop="onSortClick('id', $event)">ID{{ sortIcon('id') }}</span>
  17. </template>
  18. </el-table-column>
  19. <el-table-column prop="clusterKey" label="聚类键" width="140">
  20. <template slot="header">
  21. <span class="sort-header" @click.stop="onSortClick('clusterKey', $event)">聚类键{{ sortIcon('clusterKey') }}</span>
  22. </template>
  23. </el-table-column>
  24. <el-table-column prop="reportCount" label="报告数" width="80">
  25. <template slot="header">
  26. <span class="sort-header" @click.stop="onSortClick('reportCount', $event)">报告数{{ sortIcon('reportCount') }}</span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="状态" width="100">
  30. <template slot-scope="{ row }">
  31. <StatusTag :type="statusType(row.status)" :text="statusText(row.status)" />
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="generatedTypeId" label="生成类型" width="140">
  35. <template slot="header">
  36. <span class="sort-header" @click.stop="onSortClick('generatedTypeId', $event)">生成类型{{ sortIcon('generatedTypeId') }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="updatedAt" label="更新时间" width="180">
  40. <template slot="header">
  41. <span class="sort-header" @click.stop="onSortClick('updatedAt', $event)">更新时间{{ sortIcon('updatedAt') }}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="操作" width="160" fixed="right">
  45. <template slot-scope="{ row }">
  46. <el-button size="mini" type="primary" @click="handleDetail(row)">详情</el-button>
  47. <el-button v-if="row.status === 'ready'" size="mini" type="success" @click="handleGenerate(row)">生成类型</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </div>
  52. </el-card>
  53. <!-- 详情对话框 -->
  54. <el-dialog :visible.sync="detailVisible" title="聚类详情" width="750px" :close-on-click-modal="false">
  55. <template v-if="currentCluster">
  56. <el-descriptions :column="2" border size="small">
  57. <el-descriptions-item label="聚类键">{{ currentCluster.clusterKey }}</el-descriptions-item>
  58. <el-descriptions-item label="报告数">{{ currentCluster.reportCount }}</el-descriptions-item>
  59. <el-descriptions-item label="状态">{{ statusText(currentCluster.status) }}</el-descriptions-item>
  60. <el-descriptions-item label="生成类型">{{ currentCluster.generatedTypeId || '—' }}</el-descriptions-item>
  61. </el-descriptions>
  62. <h4>公共文本特征</h4>
  63. <pre class="detail-pre">{{ currentCluster.commonSignatures }}</pre>
  64. <h4>LLM 解析模板</h4>
  65. <pre class="detail-pre">{{ formatJson(currentCluster.llmTemplate) }}</pre>
  66. <h4>聚类内报告</h4>
  67. <el-table :data="uploads" v-loading="uploadLoading" border size="small">
  68. <el-table-column prop="id" label="ID" width="60" />
  69. <el-table-column prop="fileUrl" label="文件" min-width="200" />
  70. <el-table-column prop="uploadedAt" label="上传时间" width="180" />
  71. </template>
  72. </el-dialog>
  73. </el-table>
  74. </div>
  75. </template>
  76. <script>
  77. import { getUnknownClusters, getClusterUploads, generateTypeFromCluster } from '@/api/reportParser'
  78. import SortMixin from '@/mixins/SortMixin'
  79. export default {
  80. name: 'ReportUnknownCluster',
  81. mixins: [SortMixin],
  82. data() {
  83. return {
  84. loading: false, uploadLoading: false,
  85. clusters: [], statusFilter: '',
  86. sortableColumns: { id: 'ID', clusterKey: '聚类键', reportCount: '报告数', generatedTypeId: '生成类型', updatedAt: '更新时间' },
  87. detailVisible: false, currentCluster: null,
  88. uploads: [],
  89. }
  90. },
  91. mounted() { this.fetchClusters() },
  92. methods: {
  93. loadList() {
  94. this.fetchClusters()
  95. },
  96. async fetchClusters() {
  97. this.loading = true
  98. try {
  99. var params = { page: 1, size: 50, status: this.statusFilter }
  100. if (this.sortState.length > 0) params.sort = this.sortState
  101. const res = await getUnknownClusters(params)
  102. this.clusters = res.data?.records || res.data || []
  103. } catch (e) { this.$message.error('加载失败') }
  104. this.loading = false
  105. },
  106. statusType(status) {
  107. return { collecting: 'info', ready: 'warning', generated: 'success', imported: 'success' }[status] || 'info'
  108. },
  109. statusText(status) {
  110. return { collecting: '收集', ready: '可生成', generated: '已生成', imported: '已导入' }[status] || status
  111. },
  112. formatJson(str) {
  113. if (!str) return ''
  114. try { return JSON.stringify(JSON.parse(str), null, 2) } catch (e) { return str }
  115. },
  116. async handleDetail(row) {
  117. this.currentCluster = row
  118. this.detailVisible = true
  119. this.uploads = []
  120. this.uploadLoading = true
  121. try {
  122. const res = await getClusterUploads({ clusterId: row.id })
  123. this.uploads = res.data || []
  124. } catch (e) { this.$message.error('加载报告失败') }
  125. this.uploadLoading = false
  126. },
  127. handleGenerate(row) {
  128. this.$confirm('确认为此聚类生成报告类型?将创建待审核的报告类型和指纹规则。', '提示', { type: 'warning' })
  129. .then(async () => {
  130. try {
  131. const res = await generateTypeFromCluster({ clusterId: row.id })
  132. this.$message.success('已生成类型: ' + (res.data?.typeId || ''))
  133. this.fetchClusters()
  134. } catch (e) { this.$message.error('生成失败') }
  135. }).catch(() => {})
  136. },
  137. }
  138. }
  139. </script>
  140. <style scoped>
  141. .detail-pre {
  142. background: var(--adm-bg-header);
  143. border: 1px solid var(--adm-border-split);
  144. border-radius: 4px;
  145. padding: 10px;
  146. max-height: 300px;
  147. overflow: auto;
  148. font-size: 12px;
  149. white-space: pre-wrap;
  150. word-break: break-all;
  151. }
  152. /* == C 批内联清理工具类 == */
  153. .filter-select-140 { width: 140px; }
  154. </style>