2026-02-04 15:19:29 +08:00
|
|
|
|
<template>
|
2026-02-04 17:19:29 +08:00
|
|
|
|
<el-drawer
|
2026-02-04 15:19:29 +08:00
|
|
|
|
v-model="visible"
|
|
|
|
|
|
:title="documentInfo.name || '文档详情'"
|
2026-02-04 17:19:29 +08:00
|
|
|
|
size="80%"
|
|
|
|
|
|
direction="rtl"
|
2026-02-05 11:12:08 +08:00
|
|
|
|
:close-on-click-modal="true"
|
2026-02-04 15:19:29 +08:00
|
|
|
|
destroy-on-close
|
2026-02-04 17:19:29 +08:00
|
|
|
|
class="document-detail-drawer"
|
2026-02-04 15:19:29 +08:00
|
|
|
|
>
|
2026-02-04 17:19:29 +08:00
|
|
|
|
<div class="drawer-content">
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<!-- 左侧:文档原文 -->
|
|
|
|
|
|
<div class="document-content">
|
|
|
|
|
|
<div class="content-header">
|
|
|
|
|
|
<h2>{{ documentInfo.name }}</h2>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
<div class="content-meta">Size:{{ formatFileSize(documentInfo.fileSize) }} Uploaded Time:{{ documentInfo.createdAt }}</div>
|
2026-02-04 15:19:29 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="content-body" v-loading="contentLoading">
|
|
|
|
|
|
<pre class="document-text">{{ documentContent }}</pre>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<!-- 右侧:切片结果 -->
|
|
|
|
|
|
<div class="chunk-panel">
|
|
|
|
|
|
<div class="panel-header">
|
|
|
|
|
|
<h3>切片结果</h3>
|
|
|
|
|
|
<div class="panel-subtitle">查看用于嵌入和召回的切片段落。</div>
|
|
|
|
|
|
</div>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<div class="panel-toolbar">
|
|
|
|
|
|
<div class="toolbar-tabs">
|
|
|
|
|
|
<el-radio-group v-model="viewMode" size="small">
|
|
|
|
|
|
<el-radio-button label="full">全文</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="chunk">省略</el-radio-button>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="toolbar-actions">
|
2026-03-30 17:35:05 +08:00
|
|
|
|
<el-input v-model="chunkSearch" placeholder="搜索" clearable size="small" style="width: 120px">
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<template #prefix>
|
|
|
|
|
|
<el-icon><ele-Search /></el-icon>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
<el-button size="small" @click="onAddChunk">
|
|
|
|
|
|
<el-icon><ele-Plus /></el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<div class="chunk-list" v-loading="chunkLoading">
|
|
|
|
|
|
<div class="select-all">
|
|
|
|
|
|
<el-checkbox v-model="selectAll" @change="onSelectAllChange">选择所有</el-checkbox>
|
|
|
|
|
|
</div>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="chunk-item" v-for="chunk in filteredChunks" :key="chunk.id">
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<div class="chunk-checkbox">
|
|
|
|
|
|
<el-checkbox v-model="chunk.selected" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="chunk-content">
|
|
|
|
|
|
<span class="chunk-text">{{ viewMode === 'full' ? chunk.content : truncateText(chunk.content, 100) }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="chunk-actions">
|
|
|
|
|
|
<el-switch v-model="chunk.enabled" size="small" @change="onChunkStatusChange(chunk)" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<el-empty v-if="filteredChunks.length === 0 && !chunkLoading" description="暂无切片" :image-size="60" />
|
|
|
|
|
|
</div>
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
|
<div class="panel-footer">
|
|
|
|
|
|
<span class="total-info">总共 {{ chunkTotal }} 条</span>
|
|
|
|
|
|
<el-pagination
|
|
|
|
|
|
v-model:current-page="chunkPage"
|
|
|
|
|
|
:page-size="chunkPageSize"
|
|
|
|
|
|
:total="chunkTotal"
|
|
|
|
|
|
layout="prev, pager, next"
|
|
|
|
|
|
small
|
|
|
|
|
|
@current-change="getChunkList"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-select v-model="chunkPageSize" size="small" style="width: 80px" @change="getChunkList">
|
|
|
|
|
|
<el-option :value="10" label="10条/页" />
|
|
|
|
|
|
<el-option :value="20" label="20条/页" />
|
|
|
|
|
|
<el-option :value="50" label="50条/页" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-02-04 17:19:29 +08:00
|
|
|
|
</el-drawer>
|
2026-02-04 15:19:29 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'documentDetailDialog',
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { ref, reactive, computed, watch } from 'vue';
|
|
|
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
modelValue: boolean;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
knowledgeId: string;
|
|
|
|
|
|
knowledgeName: string;
|
2026-02-04 15:19:29 +08:00
|
|
|
|
document: any;
|
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue']);
|
|
|
|
|
|
|
|
|
|
|
|
const visible = computed({
|
|
|
|
|
|
get: () => props.modelValue,
|
|
|
|
|
|
set: (val) => emit('update:modelValue', val),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 文档信息
|
|
|
|
|
|
const documentInfo = reactive({
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
fileType: '',
|
|
|
|
|
|
fileSize: 0,
|
|
|
|
|
|
createdAt: '',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 文档内容
|
|
|
|
|
|
const documentContent = ref('');
|
|
|
|
|
|
const contentLoading = ref(false);
|
|
|
|
|
|
|
|
|
|
|
|
// 切片相关
|
|
|
|
|
|
const chunkLoading = ref(false);
|
|
|
|
|
|
const chunkList = ref<any[]>([]);
|
|
|
|
|
|
const chunkTotal = ref(0);
|
|
|
|
|
|
const chunkPage = ref(1);
|
|
|
|
|
|
const chunkPageSize = ref(50);
|
|
|
|
|
|
const chunkSearch = ref('');
|
|
|
|
|
|
const viewMode = ref('full');
|
|
|
|
|
|
const selectAll = ref(false);
|
|
|
|
|
|
|
|
|
|
|
|
// 过滤后的切片列表
|
|
|
|
|
|
const filteredChunks = computed(() => {
|
|
|
|
|
|
if (!chunkSearch.value) return chunkList.value;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
return chunkList.value.filter((chunk) => (chunk.content || '').toLowerCase().includes(chunkSearch.value.toLowerCase()));
|
2026-02-04 15:19:29 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 格式化文件大小
|
|
|
|
|
|
const formatFileSize = (size: number) => {
|
|
|
|
|
|
if (!size) return '0 Bytes';
|
|
|
|
|
|
if (size < 1024) return size + ' Bytes';
|
|
|
|
|
|
if (size < 1024 * 1024) return (size / 1024).toFixed(0) + ' KB';
|
|
|
|
|
|
return (size / 1024 / 1024).toFixed(1) + ' MB';
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 截断文本
|
|
|
|
|
|
const truncateText = (text: string, maxLength: number) => {
|
|
|
|
|
|
if (!text || text.length <= maxLength) return text;
|
|
|
|
|
|
return text.substring(0, maxLength) + '...';
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文档详情
|
|
|
|
|
|
const getDocumentDetail = async () => {
|
|
|
|
|
|
contentLoading.value = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 模拟数据
|
|
|
|
|
|
documentInfo.id = props.document?.id || '';
|
|
|
|
|
|
documentInfo.name = props.document?.name || '456_product(1).txt';
|
|
|
|
|
|
documentInfo.fileType = props.document?.fileType || 'txt';
|
|
|
|
|
|
documentInfo.fileSize = props.document?.fileSize || 10;
|
|
|
|
|
|
documentInfo.createdAt = props.document?.createdAt || '22/01/2026 00:53:32';
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
// 模拟文档内容
|
|
|
|
|
|
documentContent.value = '<p>123</p>';
|
2026-03-24 18:00:17 +08:00
|
|
|
|
} catch (_error) {
|
|
|
|
|
|
ElMessage.error('获取文档详情失败');
|
|
|
|
|
|
documentContent.value = '';
|
2026-02-04 15:19:29 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
contentLoading.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 获取切片列表
|
|
|
|
|
|
const getChunkList = async () => {
|
|
|
|
|
|
chunkLoading.value = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 模拟数据
|
|
|
|
|
|
chunkList.value = [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: '1',
|
|
|
|
|
|
content: '123',
|
|
|
|
|
|
enabled: true,
|
|
|
|
|
|
selected: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
chunkTotal.value = 1;
|
2026-03-24 18:00:17 +08:00
|
|
|
|
} catch (_error) {
|
|
|
|
|
|
ElMessage.error('获取切片列表失败');
|
|
|
|
|
|
chunkList.value = [];
|
|
|
|
|
|
chunkTotal.value = 0;
|
2026-02-04 15:19:29 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
chunkLoading.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 全选变化
|
|
|
|
|
|
const onSelectAllChange = (val: boolean) => {
|
2026-03-30 17:35:05 +08:00
|
|
|
|
chunkList.value.forEach((chunk) => {
|
2026-02-04 15:19:29 +08:00
|
|
|
|
chunk.selected = val;
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 切片状态变化
|
|
|
|
|
|
const onChunkStatusChange = (chunk: any) => {
|
|
|
|
|
|
ElMessage.success(chunk.enabled ? '已启用' : '已禁用');
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 添加切片
|
|
|
|
|
|
const onAddChunk = () => {
|
|
|
|
|
|
ElMessage.info('添加切片功能开发中');
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 监听弹窗打开
|
2026-03-30 17:35:05 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => props.modelValue,
|
|
|
|
|
|
(val) => {
|
|
|
|
|
|
if (val && props.document) {
|
|
|
|
|
|
getDocumentDetail();
|
|
|
|
|
|
getChunkList();
|
|
|
|
|
|
}
|
2026-02-04 15:19:29 +08:00
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
);
|
2026-02-04 15:19:29 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2026-02-04 17:19:29 +08:00
|
|
|
|
.document-detail-drawer {
|
|
|
|
|
|
:deep(.el-drawer__body) {
|
2026-02-04 15:19:29 +08:00
|
|
|
|
padding: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-04 17:19:29 +08:00
|
|
|
|
.drawer-content {
|
2026-02-04 15:19:29 +08:00
|
|
|
|
display: flex;
|
2026-02-04 17:19:29 +08:00
|
|
|
|
height: 100%;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
// 左侧文档内容
|
|
|
|
|
|
.document-content {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
border-right: 1px solid #ebeef5;
|
|
|
|
|
|
overflow: hidden;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.content-header {
|
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
h2 {
|
|
|
|
|
|
margin: 0 0 8px 0;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #303133;
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.content-meta {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #909399;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.content-body {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
background: #fafafa;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.document-text {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
|
color: #303133;
|
|
|
|
|
|
white-space: pre-wrap;
|
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
// 右侧切片面板
|
|
|
|
|
|
.chunk-panel {
|
|
|
|
|
|
width: 420px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
background: #fff;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.panel-header {
|
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
h3 {
|
|
|
|
|
|
margin: 0 0 4px 0;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #303133;
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.panel-subtitle {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #909399;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.panel-toolbar {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 12px 20px;
|
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.toolbar-actions {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.chunk-list {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
padding: 12px 20px;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.select-all {
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.chunk-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
background: #f5f7fa;
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
border: 1px solid #ebeef5;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.chunk-checkbox {
|
|
|
|
|
|
margin-right: 12px;
|
|
|
|
|
|
padding-top: 2px;
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.chunk-content {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.chunk-text {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #303133;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.chunk-actions {
|
|
|
|
|
|
margin-left: 12px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.panel-footer {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
padding: 12px 20px;
|
|
|
|
|
|
border-top: 1px solid #ebeef5;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
|
2026-02-04 15:19:29 +08:00
|
|
|
|
.total-info {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #909399;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|