From 6d8e930f8a93d1d15b9e9a6e30536902f1aeeb86 Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期四, 04 九月 2025 10:06:41 +0800
Subject: [PATCH] 行政管理的通知、会议、文件共享

---
 src/views/collaborativeApproval/knowledgeBase/index.vue |  170 ++++++++++++++++++++++++--------------------------------
 1 files changed, 72 insertions(+), 98 deletions(-)

diff --git a/src/views/collaborativeApproval/knowledgeBase/index.vue b/src/views/collaborativeApproval/knowledgeBase/index.vue
index f944859..f199321 100644
--- a/src/views/collaborativeApproval/knowledgeBase/index.vue
+++ b/src/views/collaborativeApproval/knowledgeBase/index.vue
@@ -233,6 +233,7 @@
 import { onMounted, ref, reactive, toRefs } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
 import PIMTable from "@/components/PIMTable/PIMTable.vue";
+import { listKnowledgeBase, delKnowledgeBaseBatch,addKnowledgeBase,updateKnowledgeBase } from "@/api/collaborativeApproval/knowledgeBase.js";
 
 // 琛ㄥ崟楠岃瘉瑙勫垯
 const rules = {
@@ -259,7 +260,7 @@
   tableLoading: false,
   page: {
     current: 1,
-    size: 100,
+    size: 20,
     total: 0,
   },
   tableData: [],
@@ -268,7 +269,7 @@
     title: "",
     type: "",
     scenario: "",
-    efficiency: "medium",
+    efficiency: "",
     problem: "",
     solution: "",
     keyPoints: "",
@@ -400,47 +401,47 @@
 ]);
 
 // 妯℃嫙鏁版嵁
-let mockData = [
-  {
-    id: "1",
-    title: "鐗规畩鍚堝悓瀹℃壒娴佺▼浼樺寲鏂规",
-    type: "contract",
-    scenario: "澶ч鍚堝悓蹇�熷鎵�",
-    efficiency: "high",
-    problem: "澶ч鍚堝悓瀹℃壒娴佺▼澶嶆潅锛屽鎵规椂闂撮暱锛屽奖鍝嶄笟鍔¤繘灞�",
-    solution: "寤虹珛缁胯壊閫氶亾锛屽绗﹀悎鏉′欢鐨勫悎鍚岄噰鐢ㄧ畝鍖栧鎵规祦绋嬶紝鐢遍儴闂ㄨ礋璐d汉鐩存帴瀹℃壒锛屽钩鍧囧鎵规椂闂翠粠3澶╃缉鐭嚦1澶�",
-    keyPoints: "缁胯壊閫氶亾鏉′欢,绠�鍖栨祦绋�,瀹℃壒鏉冮檺,鏃堕棿鎺у埗",
-    creator: "寮犵粡鐞�",
-    usageCount: 15,
-    createTime: "2024-01-15 10:30:00"
-  },
-  {
-    id: "2",
-    title: "璺ㄩ儴闂ㄥ崗浣滃鎵圭粡楠屾�荤粨",
-    type: "experience",
-    scenario: "澶氶儴闂ㄥ崗浣滈」鐩�",
-    efficiency: "medium",
-    problem: "璺ㄩ儴闂ㄩ」鐩鎵规椂锛屽悇閮ㄩ棬鎰忚涓嶇粺涓�锛屽鎵硅繘搴︾紦鎱�",
-    solution: "寤虹珛椤圭洰鍗忚皟鏈哄埗锛屾寚瀹氶」鐩礋璐d汉锛屽畾鏈熷彫寮�鍗忚皟浼氳锛岀粺涓�鍚勬柟鎰忚鍚庡啀杩涜瀹℃壒",
-    keyPoints: "椤圭洰鍗忚皟,瀹氭湡浼氳,缁熶竴鎰忚,璐熻矗浜哄埗搴�",
-    creator: "鏉庝富绠�",
-    usageCount: 8,
-    createTime: "2024-01-14 15:20:00"
-  },
-  {
-    id: "3",
-    title: "绱ф�ラ噰璐鎵规搷浣滄寚鍗�",
-    type: "guide",
-    scenario: "绱ф�ラ噰璐渶姹�",
-    efficiency: "high",
-    problem: "绱ф�ラ噰璐椂瀹℃壒娴佺▼澶嶆潅锛屾棤娉曟弧瓒崇揣鎬ラ渶姹�",
-    solution: "鍒跺畾绱ф�ラ噰璐鎵规爣鍑嗭紝鏄庣‘绱ф�ョ▼搴﹀垎绾э紝涓嶅悓绾у埆閲囩敤涓嶅悓瀹℃壒娴佺▼锛岀‘淇濈揣鎬ラ渶姹傚緱鍒板強鏃跺鐞�",
-    keyPoints: "绱ф�ュ垎绾�,鏍囧噯鍒跺畾,娴佺▼绠�鍖�,鍙婃椂澶勭悊",
-    creator: "鐜嬩笓鍛�",
-    usageCount: 12,
-    createTime: "2024-01-13 09:15:00"
-  }
-];
+// let mockData = [
+//   {
+//     id: "1",
+//     title: "鐗规畩鍚堝悓瀹℃壒娴佺▼浼樺寲鏂规",
+//     type: "contract",
+//     scenario: "澶ч鍚堝悓蹇�熷鎵�",
+//     efficiency: "high",
+//     problem: "澶ч鍚堝悓瀹℃壒娴佺▼澶嶆潅锛屽鎵规椂闂撮暱锛屽奖鍝嶄笟鍔¤繘灞�",
+//     solution: "寤虹珛缁胯壊閫氶亾锛屽绗﹀悎鏉′欢鐨勫悎鍚岄噰鐢ㄧ畝鍖栧鎵规祦绋嬶紝鐢遍儴闂ㄨ礋璐d汉鐩存帴瀹℃壒锛屽钩鍧囧鎵规椂闂翠粠3澶╃缉鐭嚦1澶�",
+//     keyPoints: "缁胯壊閫氶亾鏉′欢,绠�鍖栨祦绋�,瀹℃壒鏉冮檺,鏃堕棿鎺у埗",
+//     creator: "寮犵粡鐞�",
+//     usageCount: 15,
+//     createTime: "2024-01-15 10:30:00"
+//   },
+//   {
+//     id: "2",
+//     title: "璺ㄩ儴闂ㄥ崗浣滃鎵圭粡楠屾�荤粨",
+//     type: "experience",
+//     scenario: "澶氶儴闂ㄥ崗浣滈」鐩�",
+//     efficiency: "medium",
+//     problem: "璺ㄩ儴闂ㄩ」鐩鎵规椂锛屽悇閮ㄩ棬鎰忚涓嶇粺涓�锛屽鎵硅繘搴︾紦鎱�",
+//     solution: "寤虹珛椤圭洰鍗忚皟鏈哄埗锛屾寚瀹氶」鐩礋璐d汉锛屽畾鏈熷彫寮�鍗忚皟浼氳锛岀粺涓�鍚勬柟鎰忚鍚庡啀杩涜瀹℃壒",
+//     keyPoints: "椤圭洰鍗忚皟,瀹氭湡浼氳,缁熶竴鎰忚,璐熻矗浜哄埗搴�",
+//     creator: "鏉庝富绠�",
+//     usageCount: 8,
+//     createTime: "2024-01-14 15:20:00"
+//   },
+//   {
+//     id: "3",
+//     title: "绱ф�ラ噰璐鎵规搷浣滄寚鍗�",
+//     type: "guide",
+//     scenario: "绱ф�ラ噰璐渶姹�",
+//     efficiency: "high",
+//     problem: "绱ф�ラ噰璐椂瀹℃壒娴佺▼澶嶆潅锛屾棤娉曟弧瓒崇揣鎬ラ渶姹�",
+//     solution: "鍒跺畾绱ф�ラ噰璐鎵规爣鍑嗭紝鏄庣‘绱ф�ョ▼搴﹀垎绾э紝涓嶅悓绾у埆閲囩敤涓嶅悓瀹℃壒娴佺▼锛岀‘淇濈揣鎬ラ渶姹傚緱鍒板強鏃跺鐞�",
+//     keyPoints: "绱ф�ュ垎绾�,鏍囧噯鍒跺畾,娴佺▼绠�鍖�,鍙婃椂澶勭悊",
+//     creator: "鐜嬩笓鍛�",
+//     usageCount: 12,
+//     createTime: "2024-01-13 09:15:00"
+//   }
+// ];
 
 // 鐭ヨ瘑鏍囬妯℃澘
 const titleTemplates = [
@@ -526,24 +527,14 @@
 
 const getList = () => {
   tableLoading.value = true;
-  
-  setTimeout(() => {
-    let filteredData = [...mockData];
-    
-    if (searchForm.value.title) {
-      filteredData = filteredData.filter(item => 
-        item.title.toLowerCase().includes(searchForm.value.title.toLowerCase())
-      );
-    }
-    
-    if (searchForm.value.type) {
-      filteredData = filteredData.filter(item => item.type === searchForm.value.type);
-    }
-    
-    tableData.value = filteredData;
-    page.value.total = filteredData.length;
+  listKnowledgeBase({...page.value, ...searchForm.value})
+  .then(res => {
     tableLoading.value = false;
-  }, 500);
+    tableData.value = res.data.records
+    page.total = res.data.total;
+  }).catch(err => {
+    tableLoading.value = false;
+  })
 };
 
 // 鍒嗛〉澶勭悊
@@ -568,7 +559,7 @@
       title: "",
       type: "",
       scenario: "",
-      efficiency: "medium",
+      efficiency: "",
       problem: "",
       solution: "",
       keyPoints: "",
@@ -578,6 +569,7 @@
   } else if (type === "edit" && row) {
     dialogTitle.value = "缂栬緫鐭ヨ瘑";
     Object.assign(form.value, {
+      id: row.id,
       title: row.title,
       type: row.type,
       scenario: row.scenario,
@@ -697,47 +689,29 @@
 // 鎻愪氦鐭ヨ瘑琛ㄥ崟
 const submitForm = async () => {
   try {
-    await formRef.value.validate();
-    
+    await formRef.value.validate();   
     if (dialogType.value === "add") {
       // 鏂板鐭ヨ瘑
-      const newKnowledge = {
-        id: (mockData.length + 1).toString(),
-        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,
-        createTime: new Date().toLocaleString()
-      };
-      
-      mockData.unshift(newKnowledge);
-      ElMessage.success("鐭ヨ瘑鍒涘缓鎴愬姛");
+      addKnowledgeBase({...form.value}).then(res => {
+        if(res.code == 200){
+          ElMessage.success("娣诲姞鎴愬姛");
+          dialogVisible.value = false;
+          getList();
+        }
+      }).catch(err => {
+        ElMessage.error(err.msg);
+      })
     } else {
-      // 缂栬緫鐭ヨ瘑
-      const index = mockData.findIndex(item => item.id === selectedIds.value[0]);
-      if (index !== -1) {
-        Object.assign(mockData[index], {
-          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
-        });
-        ElMessage.success("鐭ヨ瘑鏇存柊鎴愬姛");
-      }
+      updateKnowledgeBase({...form.value}).then(res => {
+        if(res.code == 200){
+          ElMessage.success("鏇存柊鎴愬姛");
+          dialogVisible.value = false;
+          getList();
+        }
+      }).catch(err => {
+        ElMessage.error(err.msg);
+      })
     }
-    
-    dialogVisible.value = false;
-    getList();
   } catch (error) {
     console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
   }

--
Gitblit v1.9.3