From 9ea5ff67655241271bdf04bb50ca3a8d60c4e22a Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 11 八月 2026 15:07:02 +0800
Subject: [PATCH] fix: 用河南鹤壁代码覆盖山西长治

---
 src/views/collaborativeApproval/knowledgeBase/index.vue |  728 +------------------------------------------------------
 1 files changed, 19 insertions(+), 709 deletions(-)

diff --git a/src/views/collaborativeApproval/knowledgeBase/index.vue b/src/views/collaborativeApproval/knowledgeBase/index.vue
index 0c31e24..43fee33 100644
--- a/src/views/collaborativeApproval/knowledgeBase/index.vue
+++ b/src/views/collaborativeApproval/knowledgeBase/index.vue
@@ -225,167 +225,18 @@
         </div>
       </div>
     </FormDialog>
-
-    <!-- 鏂囦欢绠$悊寮圭獥 -->
-    <FormDialog
-      v-model="filesDialogVisible"
-      title="鏂囦欢绠$悊"
-      :width="'900px'"
-      @close="closeFilesDialog"
-      @confirm="closeFilesDialog"
-      @cancel="closeFilesDialog"
-    >
-      <div class="file-manager">
-        <!-- 鏂囦欢涓婁紶 -->
-        <div class="upload-section">
-          <el-upload
-            :action="uploadUrl"
-            :headers="uploadHeaders"
-            :on-success="handleUploadSuccess"
-            :on-error="handleUploadError"
-            :before-upload="beforeUpload"
-            name="files"
-            multiple
-            :show-file-list="false"
-            accept=".txt,.md,.docx,.xlsx,.xls,.pdf"
-          >
-            <el-button type="primary">涓婁紶鏂囦欢</el-button>
-          </el-upload>
-          <el-button
-            type="success"
-            @click="saveFiles"
-            :disabled="uploadedBlobIds.length === 0"
-            :loading="savingFiles"
-            style="margin-left: 10px"
-          >
-            淇濆瓨鏂囦欢鍏宠仈
-          </el-button>
-          <el-button
-            v-if="uploadedBlobIds.length > 0"
-            type="text"
-            @click="clearUploadedFiles"
-            style="margin-left: 10px"
-          >
-            娓呯┖寰呬繚瀛樺垪琛�
-          </el-button>
-        </div>
-
-        <!-- 寰呬繚瀛樼殑鏂囦欢鍒楄〃 -->
-        <div v-if="uploadedBlobIds.length > 0" class="uploaded-list">
-          <div class="uploaded-tip">
-            <el-icon style="color: #409eff"><InfoFilled /></el-icon>
-            <span>宸蹭笂浼� {{ uploadedBlobIds.length }} 涓枃浠�,璇风偣鍑�"淇濆瓨鏂囦欢鍏宠仈"鎸夐挳瑙﹀彂鍚戦噺鍖栧鐞�</span>
-          </div>
-        </div>
-
-        <!-- 鏂囦欢鍒楄〃涓庡悜閲忓寲鐘舵�� -->
-        <el-table :data="fileList" style="margin-top: 20px" border>
-          <el-table-column prop="fileName" label="鏂囦欢鍚�" show-overflow-tooltip />
-          <el-table-column prop="fileType" label="鏂囦欢绫诲瀷" width="100" />
-          <el-table-column label="鍚戦噺鍖栫姸鎬�" width="120">
-            <template #default="{ row }">
-              <el-tag :type="getStatusType(row.vectorStatus)">
-                {{ getStatusText(row.vectorStatus) }}
-              </el-tag>
-            </template>
-          </el-table-column>
-          <el-table-column prop="chunkCount" label="鍒囩墖鏁�" width="100" align="center" />
-          <el-table-column label="閿欒淇℃伅" width="200" show-overflow-tooltip>
-            <template #default="{ row }">
-              <span v-if="row.vectorError" style="color: #f56c6c">{{ row.vectorError }}</span>
-              <span v-else style="color: #909399">-</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="createTime" label="涓婁紶鏃堕棿" width="180" />
-          <el-table-column label="鎿嶄綔" width="150" align="center">
-            <template #default="{ row }">
-              <el-button
-                v-if="row.vectorStatus === 3"
-                type="text"
-                @click="reprocessFile(row)"
-              >
-                閲嶆柊澶勭悊
-              </el-button>
-              <el-button type="text" @click="deleteFile(row)" style="color: #f56c6c">
-                鍒犻櫎
-              </el-button>
-            </template>
-          </el-table-column>
-        </el-table>
-      </div>
-    </FormDialog>
-
-    <!-- 鐭ヨ瘑搴撻棶绛斿脊绐� -->
-    <FormDialog
-      v-model="chatDialogVisible"
-      title="鐭ヨ瘑搴撻棶绛�"
-      :width="'800px'"
-      @close="closeChatDialog"
-      @confirm="closeChatDialog"
-      @cancel="closeChatDialog"
-    >
-      <div class="knowledge-chat">
-        <div class="chat-header">
-          <el-tag type="success">褰撳墠鐭ヨ瘑搴�: {{ currentKnowledgeBase?.title }}</el-tag>
-        </div>
-
-        <!-- 瀵硅瘽鍖哄煙 -->
-        <div class="chat-messages" ref="chatMessagesRef">
-          <div
-            v-for="(msg, index) in messages"
-            :key="index"
-            :class="['message', msg.role]"
-          >
-            <div class="message-role">{{ msg.role === 'user' ? '鎴�' : 'AI鍔╂墜' }}</div>
-            <div class="message-content">{{ msg.content }}</div>
-          </div>
-          <div v-if="chatLoading" class="message assistant">
-            <div class="message-role">AI鍔╂墜</div>
-            <div class="message-content typing">姝e湪鎬濊�冧腑...</div>
-          </div>
-        </div>
-
-        <!-- 杈撳叆妗� -->
-        <div class="chat-input">
-          <el-input
-            v-model="inputQuestion"
-            placeholder="璇疯緭鍏ラ棶棰�,鎸夊洖杞﹀彂閫�(Ctrl+Enter蹇嵎鍙戦��)"
-            @keyup.enter="sendMessage"
-            :disabled="chatLoading"
-          >
-            <template #append>
-              <el-button @click="sendMessage" :loading="chatLoading">鍙戦��</el-button>
-            </template>
-          </el-input>
-          <div class="chat-actions">
-            <el-button type="text" size="small" @click="clearMessages">娓呯┖瀵硅瘽</el-button>
-          </div>
-        </div>
-      </div>
-    </FormDialog>
   </div>
 </template>
 
 <script setup>
-import { Search, InfoFilled } from "@element-plus/icons-vue";
-import { onMounted, ref, reactive, toRefs, getCurrentInstance, computed, watch, nextTick } from "vue";
+import { Search } from "@element-plus/icons-vue";
+import { onMounted, ref, reactive, toRefs, getCurrentInstance, computed, watch } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
 import PIMTable from "@/components/PIMTable/PIMTable.vue";
 import FormDialog from '@/components/Dialog/FormDialog.vue';
-import {
-  listKnowledgeBase,
-  delKnowledgeBase,
-  addKnowledgeBase,
-  updateKnowledgeBase,
-  getVectorStatus,
-  reprocessVector,
-  saveKnowledgeBaseFiles,
-  deleteKnowledgeBaseFile,
-  knowledgeChat
-} from "@/api/collaborativeApproval/knowledgeBase.js";
+import { listKnowledgeBase, delKnowledgeBase,addKnowledgeBase,updateKnowledgeBase } from "@/api/collaborativeApproval/knowledgeBase.js";
 import useUserStore from '@/store/modules/user';
 import { userListNoPageByTenantId } from '@/api/system/user.js';
-import { getToken } from "@/utils/auth";
 
 // 琛ㄥ崟楠岃瘉瑙勫垯
 const rules = {
@@ -432,18 +283,7 @@
   dialogTitle: "",
   dialogType: "add",
   viewDialogVisible: false,
-  currentKnowledge: {},
-  filesDialogVisible: false,
-  currentKnowledgeBase: null,
-  fileList: [],
-  uploadedBlobIds: [],
-  savingFiles: false,
-  vectorStatusTimer: null, // 鍚戦噺鍖栫姸鎬佽疆璇㈠畾鏃跺櫒
-  chatDialogVisible: false,
-  messages: [],
-  inputQuestion: "",
-  chatLoading: false,
-  memoryId: ""
+  currentKnowledge: {}
 });
 
 const {
@@ -457,18 +297,7 @@
   dialogTitle,
   dialogType,
   viewDialogVisible,
-  currentKnowledge,
-  filesDialogVisible,
-  currentKnowledgeBase,
-  fileList,
-  uploadedBlobIds,
-  savingFiles,
-  vectorStatusTimer,
-  chatDialogVisible,
-  messages,
-  inputQuestion,
-  chatLoading,
-  memoryId
+  currentKnowledge
 } = toRefs(data);
 
 // 琛ㄥ崟寮曠敤
@@ -476,12 +305,6 @@
 // 鐢ㄦ埛鐩稿叧
 const userStore = useUserStore();
 const userList = ref([]);
-// 鑱婂ぉ娑堟伅瀹瑰櫒寮曠敤
-const chatMessagesRef = ref();
-
-// 鏂囦欢涓婁紶鐩稿叧
-const uploadUrl = import.meta.env.VITE_APP_BASE_API + "/common/upload";
-const uploadHeaders = { Authorization: "Bearer " + getToken() };
 
 // 琛ㄦ牸鍒楅厤缃�
 const tableColumn = ref([
@@ -529,18 +352,6 @@
     }
   },
   {
-    label: "鏂囦欢鏁伴噺",
-    prop: "fileCount",
-    width: 100,
-    align: "center"
-  },
-  {
-    label: "鍒囩墖鏁伴噺",
-    prop: "totalChunkCount",
-    width: 100,
-    align: "center"
-  },
-  {
     label: "浣跨敤娆℃暟",
     prop: "usageCount",
     width: 100,
@@ -568,20 +379,6 @@
         type: "text",
         clickFun: (row) => {
           openForm("edit", row);
-        }
-      },
-      {
-        name: "鏂囦欢",
-        type: "text",
-        clickFun: (row) => {
-          openFilesDialog(row);
-        }
-      },
-      {
-        name: "闂瓟",
-        type: "text",
-        clickFun: (row) => {
-          openChatDialog(row);
         }
       },
       {
@@ -625,31 +422,21 @@
 
 const getList = () => {
   tableLoading.value = true;
-
-  // 鉁� GET璇锋眰浣跨敤params浼犲弬
-  listKnowledgeBase({
-    current: page.value.current,
-    size: page.value.size,
-    title: searchForm.value.title,
-    type: searchForm.value.type
-  })
+  listKnowledgeBase({...page.value, ...searchForm.value})
   .then(res => {
     tableLoading.value = false;
     page.value.total = res.data.total;
-
-    // 濡傛灉褰撳墠椤垫暟瓒呰繃鎬婚〉鏁�,閲嶇疆鍒扮1椤靛苟閲嶆柊鏌ヨ
+    // 濡傛灉褰撳墠椤垫暟瓒呰繃鎬婚〉鏁帮紝閲嶇疆鍒扮1椤靛苟閲嶆柊鏌ヨ
     const maxPage = Math.ceil(res.data.total / page.value.size) || 1;
     if (page.value.current > maxPage && maxPage > 0) {
       page.value.current = 1;
+      // 閲嶆柊鏌ヨ绗�1椤垫暟鎹�
       return getList();
     }
-
     tableData.value = res.data.records;
-  })
-  .catch(err => {
+  }).catch(err => {
     tableLoading.value = false;
-    console.error("鏌ヨ鐭ヨ瘑搴撳垪琛ㄥけ璐�:", err);
-  });
+  })
 };
 
 // 鍒嗛〉澶勭悊
@@ -824,47 +611,27 @@
 const submitForm = async () => {
   try {
     await formRef.value.validate();
-
-    // 鉁� POST璇锋眰浣跨敤data浼犲弬,鏄庣‘鍙傛暟缁撴瀯
-    const formData = {
-      title: form.value.title,
-      type: form.value.type,
-      scenario: form.value.scenario || "",
-      efficiency: form.value.efficiency || "",
-      problem: form.value.problem,
-      solution: form.value.solution,
-      keyPoints: form.value.keyPoints || "",
-      creator: form.value.creator || "",
-      usageCount: form.value.usageCount || 0
-    };
-
     if (dialogType.value === "add") {
       // 鏂板鐭ヨ瘑
-      addKnowledgeBase(formData).then(res => {
+      addKnowledgeBase({...form.value}).then(res => {
         if(res.code == 200){
           ElMessage.success("娣诲姞鎴愬姛");
           closeKnowledgeDialog();
           getList();
         }
       }).catch(err => {
-        console.error("娣诲姞鐭ヨ瘑搴撳け璐�:", err);
-        ElMessage.error(err.msg || "娣诲姞澶辫触");
-      });
+        ElMessage.error(err.msg);
+      })
     } else {
-      // 鏇存柊鐭ヨ瘑 - 娣诲姞id鍙傛暟
-      updateKnowledgeBase({
-        id: form.value.id,
-        ...formData
-      }).then(res => {
+      updateKnowledgeBase({...form.value}).then(res => {
         if(res.code == 200){
           ElMessage.success("鏇存柊鎴愬姛");
           closeKnowledgeDialog();
           getList();
         }
       }).catch(err => {
-        console.error("鏇存柊鐭ヨ瘑搴撳け璐�:", err);
-        ElMessage.error(err.msg || "鏇存柊澶辫触");
-      });
+        ElMessage.error(err.msg);
+      })
     }
   } catch (error) {
     console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
@@ -878,22 +645,19 @@
     return;
   }
 
-  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄�,鏄惁纭鍒犻櫎?", "鍒犻櫎", {
+  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
     confirmButtonText: "纭",
     cancelButtonText: "鍙栨秷",
     type: "warning",
   }).then(() => {
-    // 鉁� DELETE璇锋眰浣跨敤data浼犻�扞D鏁扮粍
+    // console.log(selectedIds.value);
     delKnowledgeBase(selectedIds.value).then(res => {
       if(res.code == 200){
         ElMessage.success("鍒犻櫎鎴愬姛");
         selectedIds.value = [];
         getList();
       }
-    }).catch(err => {
-      console.error("鍒犻櫎鐭ヨ瘑搴撳け璐�:", err);
-      ElMessage.error(err.msg || "鍒犻櫎澶辫触");
-    });
+    })
   }).catch(() => {
     // 鐢ㄦ埛鍙栨秷
   });
@@ -916,351 +680,6 @@
 const handleExport = () => {
   proxy.download('/knowledgeBase/export', { ...searchForm.value }, '鐭ヨ瘑搴�.xlsx')
 }
-
-// ============ 鏂囦欢绠$悊鐩稿叧 ============
-
-// 鎵撳紑鏂囦欢绠$悊寮圭獥
-const openFilesDialog = (row) => {
-  currentKnowledgeBase.value = row;
-  filesDialogVisible.value = true;
-  loadFileList();
-};
-
-// 鍔犺浇鏂囦欢鍒楄〃
-const loadFileList = async () => {
-  if (!currentKnowledgeBase.value?.id) return;
-
-  try {
-    const res = await getVectorStatus(currentKnowledgeBase.value.id);
-    fileList.value = res.data || [];
-
-    // 妫�鏌ユ槸鍚︽湁澶勭悊涓殑鏂囦欢,濡傛灉鏈夊垯鍚姩杞
-    const hasProcessing = res.data.some(item => item.vectorStatus === 1);
-    if (hasProcessing && !vectorStatusTimer.value) {
-      startVectorStatusPolling();
-    } else if (!hasProcessing && vectorStatusTimer.value) {
-      stopVectorStatusPolling();
-    }
-  } catch (error) {
-    console.error("鍔犺浇鏂囦欢鍒楄〃澶辫触:", error);
-    ElMessage.error("鍔犺浇鏂囦欢鍒楄〃澶辫触");
-  }
-};
-
-// 寮�濮嬭疆璇㈠悜閲忓寲鐘舵��
-const startVectorStatusPolling = () => {
-  vectorStatusTimer.value = setInterval(async () => {
-    try {
-      const res = await getVectorStatus(currentKnowledgeBase.value.id);
-      fileList.value = res.data || [];
-
-      // 妫�鏌ユ槸鍚﹁繕鏈夊鐞嗕腑鐨勬枃浠�
-      const hasProcessing = res.data.some(item => item.vectorStatus === 1);
-      if (!hasProcessing) {
-        stopVectorStatusPolling();
-        ElMessage.success("鎵�鏈夋枃浠跺悜閲忓寲澶勭悊瀹屾垚");
-      }
-    } catch (error) {
-      console.error("杞鍚戦噺鍖栫姸鎬佸け璐�:", error);
-      stopVectorStatusPolling();
-    }
-  }, 3000); // 姣�3绉掕疆璇竴娆�
-};
-
-// 鍋滄杞鍚戦噺鍖栫姸鎬�
-const stopVectorStatusPolling = () => {
-  if (vectorStatusTimer.value) {
-    clearInterval(vectorStatusTimer.value);
-    vectorStatusTimer.value = null;
-  }
-};
-
-// 涓婁紶鍓嶆牎楠�
-const beforeUpload = (file) => {
-  const allowedTypes = ['.txt', '.md', '.docx', '.xlsx', '.xls', '.pdf'];
-  const fileName = file.name.toLowerCase();
-  const isAllowed = allowedTypes.some(type => fileName.endsWith(type));
-
-  if (!isAllowed) {
-    ElMessage.error('鍙敮鎸� txt銆乵d銆乨ocx銆亁lsx銆亁ls銆乸df 鏍煎紡鐨勬枃浠�');
-    return false;
-  }
-
-  const isLt50M = file.size / 1024 / 1024 < 50;
-  if (!isLt50M) {
-    ElMessage.error('鏂囦欢澶у皬涓嶈兘瓒呰繃 50MB');
-    return false;
-  }
-
-  return true;
-};
-
-// 涓婁紶鎴愬姛
-const handleUploadSuccess = (response, file) => {
-  console.log("涓婁紶鍝嶅簲:", response);  // 璋冭瘯鏃ュ織
-
-  if (response.code === 200) {
-    // 鉁� 鍚庣杩斿洖鐨勬槸 List<StorageBlobVO>,鎵�浠ata鏄暟缁�
-    if (Array.isArray(response.data) && response.data.length > 0) {
-      // 鍙栨暟缁勭涓�涓厓绱犵殑id
-      const blobId = response.data[0].id;
-      if (blobId) {
-        uploadedBlobIds.value.push(blobId);
-        ElMessage.success(`鏂囦欢 ${file.name} 涓婁紶鎴愬姛`);
-      } else {
-        console.error("涓婁紶鍝嶅簲涓湭鎵惧埌id:", response.data[0]);
-        ElMessage.error("涓婁紶澶辫触: 鏈幏鍙栧埌鏂囦欢ID");
-      }
-    } else {
-      console.error("涓婁紶鍝嶅簲鏍煎紡閿欒:", response);
-      ElMessage.error("涓婁紶澶辫触: 鍝嶅簲鏍煎紡閿欒");
-    }
-  } else {
-    ElMessage.error(response.msg || "涓婁紶澶辫触");
-  }
-};
-
-// 涓婁紶澶辫触
-const handleUploadError = (error, file) => {
-  ElMessage.error(`鏂囦欢 ${file.name} 涓婁紶澶辫触`);
-};
-
-// 淇濆瓨鏂囦欢鍏宠仈
-const saveFiles = async () => {
-  // 鍙傛暟鏍¢獙
-  if (!currentKnowledgeBase.value?.id) {
-    ElMessage.error("鐭ヨ瘑搴撲俊鎭紓甯�");
-    return;
-  }
-
-  if (uploadedBlobIds.value.length === 0) {
-    ElMessage.warning("璇峰厛涓婁紶鏂囦欢");
-    return;
-  }
-
-  savingFiles.value = true;
-
-  try {
-    // 鉁� POST璇锋眰浣跨敤data浼犲弬,鏄庣‘鍙傛暟缁撴瀯
-    await saveKnowledgeBaseFiles({
-      knowledgeBaseId: currentKnowledgeBase.value.id,  // 鐭ヨ瘑搴揑D
-      storageBlobIds: uploadedBlobIds.value             // 鏂囦欢blob ID鏁扮粍
-    });
-
-    ElMessage.success("鏂囦欢鍏宠仈淇濆瓨鎴愬姛,姝e湪鍚庡彴澶勭悊鍚戦噺鍖�");
-    uploadedBlobIds.value = [];
-
-    // 寤惰繜鍒锋柊鏂囦欢鍒楄〃,缁欏悗鍙板鐞嗘椂闂�
-    setTimeout(() => {
-      loadFileList();
-    }, 1000);
-  } catch (error) {
-    console.error("淇濆瓨鏂囦欢鍏宠仈澶辫触:", error);
-    ElMessage.error("淇濆瓨鏂囦欢鍏宠仈澶辫触");
-  } finally {
-    savingFiles.value = false;
-  }
-};
-
-// 閲嶆柊澶勭悊鍚戦噺鍖栫殑鏂囦欢
-const reprocessFile = async (row) => {
-  try {
-    await reprocessVector(row.id);
-    ElMessage.success("宸查噸鏂版彁浜ゅ悜閲忓寲浠诲姟");
-    // 寤惰繜鍒锋柊
-    setTimeout(() => {
-      loadFileList();
-    }, 1000);
-  } catch (error) {
-    console.error("閲嶆柊澶勭悊澶辫触:", error);
-    ElMessage.error("閲嶆柊澶勭悊澶辫触");
-  }
-};
-
-// 娓呯┖寰呬繚瀛樼殑鏂囦欢鍒楄〃
-const clearUploadedFiles = () => {
-  uploadedBlobIds.value = [];
-  ElMessage.success("宸叉竻绌哄緟淇濆瓨鏂囦欢鍒楄〃");
-};
-
-// 鍒犻櫎鏂囦欢
-const deleteFile = async (row) => {
-  try {
-    await ElMessageBox.confirm(
-      "纭畾瑕佸垹闄よ鏂囦欢鍚�?鍒犻櫎鍚庡皢鏃犳硶鎭㈠鍚戦噺鏁版嵁",
-      "鍒犻櫎纭",
-      {
-        confirmButtonText: "纭畾",
-        cancelButtonText: "鍙栨秷",
-        type: "warning"
-      }
-    );
-
-    // 鉁� DELETE璇锋眰浣跨敤data浼犻�扞D鏁扮粍
-    await deleteKnowledgeBaseFile([row.id]);  // 娉ㄦ剰: row.id鏄悜閲忚褰旾D,涓嶆槸storageBlobId
-    ElMessage.success("鍒犻櫎鎴愬姛");
-    loadFileList();
-  } catch (error) {
-    if (error !== 'cancel') {
-      console.error("鍒犻櫎鏂囦欢澶辫触:", error);
-      ElMessage.error("鍒犻櫎鏂囦欢澶辫触");
-    }
-  }
-};
-
-// 鐘舵�佹枃鏈槧灏�
-const getStatusText = (status) => {
-  const map = {
-    0: '寰呭鐞�',
-    1: '澶勭悊涓�',
-    2: '宸插畬鎴�',
-    3: '澶辫触'
-  };
-  return map[status] || '鏈煡';
-};
-
-// 鐘舵�佹爣绛剧被鍨嬫槧灏�
-const getStatusType = (status) => {
-  const map = {
-    0: 'info',
-    1: 'warning',
-    2: 'success',
-    3: 'danger'
-  };
-  return map[status] || 'info';
-};
-
-// 鍏抽棴鏂囦欢绠$悊寮圭獥
-const closeFilesDialog = () => {
-  filesDialogVisible.value = false;
-  currentKnowledgeBase.value = null;
-  fileList.value = [];
-  uploadedBlobIds.value = [];
-  stopVectorStatusPolling(); // 鍋滄杞
-  getList(); // 鍒锋柊涓诲垪琛�,鏇存柊鏂囦欢鏁伴噺
-};
-
-// ============ 鐭ヨ瘑搴撻棶绛旂浉鍏� ============
-
-// 鎵撳紑闂瓟寮圭獥
-const openChatDialog = (row) => {
-  currentKnowledgeBase.value = row;
-  chatDialogVisible.value = true;
-  memoryId.value = crypto.randomUUID();
-  messages.value = [];
-  inputQuestion.value = "";
-};
-
-// 鍙戦�佹秷鎭�
-const sendMessage = async () => {
-  // 鍙傛暟鏍¢獙
-  if (!inputQuestion.value.trim()) {
-    ElMessage.warning("璇疯緭鍏ラ棶棰�");
-    return;
-  }
-
-  if (!currentKnowledgeBase.value?.id) {
-    ElMessage.error("鐭ヨ瘑搴撲俊鎭紓甯�");
-    return;
-  }
-
-  const question = inputQuestion.value.trim();
-
-  // 娣诲姞鐢ㄦ埛娑堟伅
-  messages.value.push({
-    role: 'user',
-    content: question
-  });
-
-  inputQuestion.value = "";
-  chatLoading.value = true;
-
-  // 婊氬姩鍒板簳閮�
-  await nextTick();
-  scrollToBottom();
-
-  try {
-    // 鉁� 娴佸紡璇锋眰浣跨敤Fetch API
-    const response = await knowledgeChat({
-      knowledgeBaseId: currentKnowledgeBase.value.id,  // 鐭ヨ瘑搴揑D
-      memoryId: memoryId.value,                         // 浼氳瘽ID
-      question: question                                // 鐢ㄦ埛闂
-    });
-
-    if (!response.ok) {
-      const errorText = await response.text();
-      throw new Error(errorText || '璇锋眰澶辫触');
-    }
-
-    // 鉁� 鍚庣杩斿洖 text/stream;charset=utf-8
-    const reader = response.body.getReader();
-    const decoder = new TextDecoder();
-    let aiContent = '';
-
-    messages.value.push({ role: 'assistant', content: '' });
-
-    while (true) {
-      const { done, value } = await reader.read();
-      if (done) break;
-
-      const text = decoder.decode(value, { stream: true });  // 鉁� 娣诲姞stream閫夐」
-      aiContent += text;
-      messages.value[messages.value.length - 1].content = aiContent;
-
-      // 婊氬姩鍒板簳閮�
-      await nextTick();
-      scrollToBottom();
-    }
-
-    // 濡傛灉AI杩斿洖绌哄唴瀹�,鏄剧ず鎻愮ず
-    if (!aiContent.trim()) {
-      messages.value[messages.value.length - 1].content = '鎶辨瓑,鐭ヨ瘑搴撲腑鏈壘鍒扮浉鍏冲唴瀹�,璇峰皾璇曞叾浠栭棶棰樸��';
-    }
-  } catch (error) {
-    console.error("闂瓟璇锋眰澶辫触:", error);
-    ElMessage.error("闂瓟璇锋眰澶辫触,璇风◢鍚庨噸璇�");
-    messages.value.push({
-      role: 'assistant',
-      content: '鎶辨瓑,鍙戠敓浜嗛敊璇�,璇风◢鍚庨噸璇�'
-    });
-  } finally {
-    chatLoading.value = false;
-  }
-};
-
-// 娓呯┖瀵硅瘽
-const clearMessages = () => {
-  ElMessageBox.confirm(
-    "纭畾瑕佹竻绌烘墍鏈夊璇濊褰曞悧?",
-    "娓呯┖纭",
-    {
-      confirmButtonText: "纭畾",
-      cancelButtonText: "鍙栨秷",
-      type: "warning"
-    }
-  ).then(() => {
-    messages.value = [];
-    memoryId.value = crypto.randomUUID(); // 閲嶆柊鐢熸垚浼氳瘽ID
-    ElMessage.success("瀵硅瘽宸叉竻绌�");
-  }).catch(() => {
-    // 鐢ㄦ埛鍙栨秷
-  });
-};
-
-// 婊氬姩鍒板簳閮�
-const scrollToBottom = () => {
-  if (chatMessagesRef.value) {
-    chatMessagesRef.value.scrollTop = chatMessagesRef.value.scrollHeight;
-  }
-};
-
-// 鍏抽棴闂瓟寮圭獥
-const closeChatDialog = () => {
-  chatDialogVisible.value = false;
-  currentKnowledgeBase.value = null;
-  messages.value = [];
-  inputQuestion.value = "";
-};
 </script>
 
 <style scoped>
@@ -1336,113 +755,4 @@
   font-size: 14px;
   color: #909399;
 }
-
-/* 鏂囦欢绠$悊鏍峰紡 */
-.file-manager {
-  padding: 20px 0;
-}
-
-.upload-section {
-  display: flex;
-  align-items: center;
-}
-
-.uploaded-list {
-  margin-top: 16px;
-  padding: 12px;
-  background: #f0f9ff;
-  border-radius: 6px;
-  border: 1px solid #b3d8ff;
-}
-
-.uploaded-tip {
-  display: flex;
-  align-items: center;
-  gap: 8px;
-  color: #409eff;
-  font-size: 14px;
-}
-
-/* 鐭ヨ瘑搴撻棶绛旀牱寮� */
-.knowledge-chat {
-  display: flex;
-  flex-direction: column;
-  height: 500px;
-}
-
-.chat-header {
-  margin-bottom: 16px;
-}
-
-.chat-messages {
-  flex: 1;
-  overflow-y: auto;
-  padding: 16px;
-  background: #f5f7fa;
-  border-radius: 8px;
-  margin-bottom: 16px;
-}
-
-.message {
-  margin-bottom: 16px;
-  max-width: 80%;
-}
-
-.message.user {
-  margin-left: auto;
-  text-align: right;
-}
-
-.message.assistant {
-  margin-right: auto;
-}
-
-.message-role {
-  font-size: 12px;
-  color: #909399;
-  margin-bottom: 4px;
-}
-
-.message-content {
-  display: inline-block;
-  padding: 10px 14px;
-  border-radius: 8px;
-  line-height: 1.6;
-  word-wrap: break-word;
-  white-space: pre-wrap;
-}
-
-.message.user .message-content {
-  background: #409eff;
-  color: white;
-}
-
-.message.assistant .message-content {
-  background: white;
-  color: #303133;
-  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-}
-
-.typing {
-  animation: typing 1.5s infinite;
-}
-
-@keyframes typing {
-  0%, 50%, 100% {
-    opacity: 1;
-  }
-  25%, 75% {
-    opacity: 0.5;
-  }
-}
-
-.chat-input {
-  margin-top: auto;
-}
-
-.chat-actions {
-  margin-top: 8px;
-  text-align: right;
-}
-
 </style>

--
Gitblit v1.9.3