This commit is contained in:
2026-08-06 11:04:14 +08:00
parent 46f034d628
commit 57e662b414
6 changed files with 130 additions and 2 deletions
+9
View File
@@ -15,3 +15,12 @@ export function getContractDetail(id) {
export function deleteContract(id) {
return request.post('/contract/delete', { id })
}
// 导出标注版 HTML:走原生 fetch(拦截器会误判 blob 响应),token 手动带上
export async function exportAnnotatedContract(id) {
const resp = await fetch(`/contract/annotated?id=${id}`, {
headers: { Authorization: 'Bearer ' + (localStorage.getItem('token') || '') }
})
if (!resp.ok) throw new Error('导出失败')
return resp.blob()
}
+26 -2
View File
@@ -53,6 +53,9 @@
<!-- 详情抽屉条款 + 标注 -->
<el-drawer v-model="detailVisible" :title="detailTitle" size="80%" destroy-on-close>
<div v-if="detail" class="detail-toolbar">
<el-button type="primary" size="small" @click="exportAnnotated">导出标注版HTML</el-button>
</div>
<div v-if="detail" class="detail-body">
<div class="clause-panel">
<div class="panel-title">合同条款{{ detail.clauses.length }}</div>
@@ -92,7 +95,7 @@ import { onMounted, onUnmounted, computed, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { UploadFilled } from '@element-plus/icons-vue'
import { listDatasets } from '../api/dataset.js'
import { uploadContract, listContracts, getContractDetail, deleteContract } from '../api/contract.js'
import { uploadContract, listContracts, getContractDetail, deleteContract, exportAnnotatedContract } from '../api/contract.js'
const datasets = ref([])
const dsIds = ref([])
@@ -183,6 +186,22 @@ async function openDetail(row) {
}
}
async function exportAnnotated() {
if (!detail.value) return
try {
const blob = await exportAnnotatedContract(detail.value.task.id)
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = '标注版-' + detail.value.task.filename.replace(/\.[^.]+$/, '') + '.html'
a.click()
URL.revokeObjectURL(url)
ElMessage.success('已导出标注版')
} catch (e) {
ElMessage.error(e.message || '导出失败')
}
}
async function removeTask(row) {
try {
await ElMessageBox.confirm('删除任务将同时删除条款与标注结果,确认?', '删除任务', { type: 'warning' })
@@ -231,10 +250,15 @@ const detailTitle = computed(() => detail.value ? detail.value.task.filename : '
font-size: 40px;
color: #c0c4cc;
}
.detail-toolbar {
display: flex;
justify-content: flex-end;
margin-bottom: 12px;
}
.detail-body {
display: flex;
gap: 12px;
height: 100%;
height: calc(100% - 44px);
}
.clause-panel {
width: 280px;