From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/ai/knowledge/document/form/index.vue | 193 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 193 insertions(+), 0 deletions(-)
diff --git a/src/views/ai/knowledge/document/form/index.vue b/src/views/ai/knowledge/document/form/index.vue
new file mode 100644
index 0000000..722f57c
--- /dev/null
+++ b/src/views/ai/knowledge/document/form/index.vue
@@ -0,0 +1,193 @@
+<template>
+ <ContentWrap>
+ <div class="mx-auto">
+ <!-- 澶撮儴瀵艰埅鏍� -->
+ <div
+ class="absolute top-0 left-0 right-0 h-50px bg-white border-bottom z-10 flex items-center px-20px"
+ >
+ <!-- 宸︿晶鏍囬 -->
+ <div class="w-200px flex items-center overflow-hidden">
+ <Icon icon="ep:arrow-left" class="cursor-pointer flex-shrink-0" @click="handleBack" />
+ <span class="ml-10px text-16px truncate">
+ {{ formData.id ? '缂栬緫鐭ヨ瘑搴撴枃妗�' : '鍒涘缓鐭ヨ瘑搴撴枃妗�' }}
+ </span>
+ </div>
+
+ <!-- 姝ラ鏉� -->
+ <div class="flex-1 flex items-center justify-center h-full">
+ <div class="w-400px flex items-center justify-between h-full">
+ <div
+ v-for="(step, index) in steps"
+ :key="index"
+ class="flex items-center mx-15px relative h-full"
+ :class="[
+ currentStep === index
+ ? 'text-[#3473ff] border-[#3473ff] border-b-2 border-b-solid'
+ : 'text-gray-500'
+ ]"
+ >
+ <div
+ class="w-28px h-28px rounded-full flex items-center justify-center mr-8px border-2 border-solid text-15px"
+ :class="[
+ currentStep === index
+ ? 'bg-[#3473ff] text-white border-[#3473ff]'
+ : 'border-gray-300 bg-white text-gray-500'
+ ]"
+ >
+ {{ index + 1 }}
+ </div>
+ <span class="text-16px font-bold whitespace-nowrap">{{ step.title }}</span>
+ </div>
+ </div>
+ </div>
+
+ <!-- 鍙充晶鎸夐挳 - 宸茬Щ闄� -->
+ <div class="w-200px flex items-center justify-end gap-2"> </div>
+ </div>
+
+ <!-- 涓讳綋鍐呭 -->
+ <div class="mt-50px">
+ <!-- 绗竴姝ワ細涓婁紶鏂囨。 -->
+ <div v-if="currentStep === 0" class="mx-auto w-560px">
+ <UploadStep v-model="formData" ref="uploadDocumentRef" />
+ </div>
+
+ <!-- 绗簩姝ワ細鏂囨。鍒嗘 -->
+ <div v-if="currentStep === 1" class="mx-auto w-560px">
+ <SplitStep v-model="formData" ref="documentSegmentRef" />
+ </div>
+
+ <!-- 绗笁姝ワ細澶勭悊骞跺畬鎴� -->
+ <div v-if="currentStep === 2" class="mx-auto w-560px">
+ <ProcessStep v-model="formData" ref="processCompleteRef" />
+ </div>
+ </div>
+ </div>
+ </ContentWrap>
+</template>
+
+<script lang="ts" setup>
+import { useRoute, useRouter } from 'vue-router'
+import { useTagsViewStore } from '@/store/modules/tagsView'
+import UploadStep from './UploadStep.vue'
+import SplitStep from './SplitStep.vue'
+import ProcessStep from './ProcessStep.vue'
+import { KnowledgeDocumentApi } from '@/api/ai/knowledge/document'
+
+const { delView } = useTagsViewStore() // 瑙嗗浘鎿嶄綔
+const route = useRoute() // 璺敱
+const router = useRouter() // 璺敱
+
+// 缁勪欢寮曠敤
+const uploadDocumentRef = ref()
+const documentSegmentRef = ref()
+const processCompleteRef = ref()
+const currentStep = ref(0) // 姝ラ鎺у埗
+const steps = [{ title: '涓婁紶鏂囨。' }, { title: '鏂囨。鍒嗘' }, { title: '澶勭悊骞跺畬鎴�' }]
+const formData = ref({
+ knowledgeId: undefined, // 鐭ヨ瘑搴撶紪鍙�
+ id: undefined, // 缂栬緫鐨勬枃妗g紪鍙�(documentId)
+ segmentMaxTokens: 500, // 鍒嗘鏈�澶� token 鏁�
+ list: [] as Array<{
+ id: number // 鏂囨。缂栧彿
+ name: string // 鏂囨。鍚嶇О
+ url: string // 鏂囨。 URL
+ segments: Array<{
+ content?: string
+ contentLength?: number
+ tokens?: number
+ }>
+ count?: number // 娈佃惤鏁伴噺
+ process?: number // 澶勭悊杩涘害
+ }> // 鐢ㄤ簬瀛樺偍涓婁紶鐨勬枃浠跺垪琛�
+}) // 琛ㄥ崟鏁版嵁
+
+provide('parent', getCurrentInstance()) // 鎻愪緵 parent 缁欏瓙缁勪欢浣跨敤
+
+/** 鍒濆鍖栨暟鎹� */
+const initData = async () => {
+ // 銆愭柊澧炲満鏅�戜粠璺敱鍙傛暟涓幏鍙栫煡璇嗗簱 ID
+ if (route.query.knowledgeId) {
+ formData.value.knowledgeId = route.query.knowledgeId as any
+ }
+
+ // 銆愪慨鏀瑰満鏅�戜粠璺敱鍙傛暟涓幏鍙栨枃妗� ID
+ const documentId = route.query.id
+ if (documentId) {
+ // 鑾峰彇鏂囨。淇℃伅
+ formData.value.id = documentId as any
+ const document = await KnowledgeDocumentApi.getKnowledgeDocument(documentId as any)
+ formData.value.segmentMaxTokens = document.segmentMaxTokens
+ formData.value.list = [
+ {
+ id: document.id,
+ name: document.name,
+ url: document.url,
+ segments: []
+ }
+ ]
+ // 杩涘叆涓嬩竴姝�
+ goToNextStep()
+ }
+}
+
+/** 鍒囨崲鍒颁笅涓�姝� */
+const goToNextStep = () => {
+ if (currentStep.value < steps.length - 1) {
+ currentStep.value++
+ }
+}
+
+/** 鍒囨崲鍒颁笂涓�姝� */
+const goToPrevStep = () => {
+ if (currentStep.value > 0) {
+ currentStep.value--
+ }
+}
+
+/** 杩斿洖鍒楄〃椤� */
+const handleBack = () => {
+ // 鍏堝垹闄ゅ綋鍓嶉〉绛�
+ delView(unref(router.currentRoute))
+ // 璺宠浆鍒板垪琛ㄩ〉
+ router.push({ name: 'AiKnowledgeDocument', query: { knowledgeId: formData.value.knowledgeId } })
+}
+
+/** 鍒濆鍖� */
+onMounted(async () => {
+ await initData()
+})
+
+/** 娣诲姞缁勪欢鍗歌浇鍓嶇殑娓呯悊浠g爜 */
+onBeforeUnmount(() => {
+ // 娓呯悊鎵�鏈夌殑寮曠敤
+ uploadDocumentRef.value = null
+ documentSegmentRef.value = null
+ processCompleteRef.value = null
+})
+
+/** 鏆撮湶鏂规硶缁欏瓙缁勪欢浣跨敤 */
+defineExpose({
+ goToNextStep,
+ goToPrevStep,
+ handleBack
+})
+</script>
+
+<style lang="scss" scoped>
+.border-bottom {
+ border-bottom: 1px solid #dcdfe6;
+}
+
+.text-primary {
+ color: #3473ff;
+}
+
+.bg-primary {
+ background-color: #3473ff;
+}
+
+.border-primary {
+ border-color: #3473ff;
+}
+</style>
--
Gitblit v1.8.0