From be125538c6e9c17a923c9dbe1e4cca9962b0ed39 Mon Sep 17 00:00:00 2001 From: yaowanxin <3588231647@qq.com> Date: 星期一, 08 九月 2025 10:17:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into ywx --- src/views/collaborativeApproval/knowledgeBase/index.vue | 200 +++++++++++++++++++++---------------------------- 1 files changed, 87 insertions(+), 113 deletions(-) diff --git a/src/views/collaborativeApproval/knowledgeBase/index.vue b/src/views/collaborativeApproval/knowledgeBase/index.vue index 279738e..ba572f5 100644 --- a/src/views/collaborativeApproval/knowledgeBase/index.vue +++ b/src/views/collaborativeApproval/knowledgeBase/index.vue @@ -28,7 +28,7 @@ <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button> </div> </div> - + <div class="table_list"> <PIMTable rowKey="id" @@ -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: "", @@ -282,11 +283,11 @@ currentKnowledge: {} }); -const { - searchForm, - tableLoading, - page, - tableData, +const { + searchForm, + tableLoading, + page, + tableData, selectedIds, form, dialogVisible, @@ -400,47 +401,47 @@ ]); // 妯℃嫙鏁版嵁 -let mockData = [ - { - id: "1", - title: "鐗规畩鍚堝悓瀹℃壒娴佺▼浼樺寲鏂规", - type: "contract", - scenario: "澶ч鍚堝悓蹇�熷鎵�", - efficiency: "high", - problem: "澶ч鍚堝悓瀹℃壒娴佺▼澶嶆潅锛屽鎵规椂闂撮暱锛屽奖鍝嶄笟鍔¤繘灞�", - solution: "寤虹珛缁胯壊閫氶亾锛屽绗﹀悎鏉′欢鐨勫悎鍚岄噰鐢ㄧ畝鍖栧鎵规祦绋嬶紝鐢遍儴闂ㄨ礋璐d汉鐩存帴瀹℃壒锛屽钩鍧囧鎵规椂闂翠粠3澶╃缉鐭嚦1澶�", - keyPoints: "缁胯壊閫氶亾鏉′欢,绠�鍖栨祦绋�,瀹℃壒鏉冮檺,鏃堕棿鎺у埗", - creator: "闄堝織寮�", - usageCount: 15, - createTime: "2025-01-15 10:30:00" - }, - { - id: "2", - title: "璺ㄩ儴闂ㄥ崗浣滃鎵圭粡楠屾�荤粨", - type: "experience", - scenario: "澶氶儴闂ㄥ崗浣滈」鐩�", - efficiency: "medium", - problem: "璺ㄩ儴闂ㄩ」鐩鎵规椂锛屽悇閮ㄩ棬鎰忚涓嶇粺涓�锛屽鎵硅繘搴︾紦鎱�", - solution: "寤虹珛椤圭洰鍗忚皟鏈哄埗锛屾寚瀹氶」鐩礋璐d汉锛屽畾鏈熷彫寮�鍗忚皟浼氳锛岀粺涓�鍚勬柟鎰忚鍚庡啀杩涜瀹℃壒", - keyPoints: "椤圭洰鍗忚皟,瀹氭湡浼氳,缁熶竴鎰忚,璐熻矗浜哄埗搴�", - creator: "鏉庝富绠�", - usageCount: 8, - createTime: "2025-01-14 15:20:00" - }, - { - id: "3", - title: "绱ф�ラ噰璐鎵规搷浣滄寚鍗�", - type: "guide", - scenario: "绱ф�ラ噰璐渶姹�", - efficiency: "high", - problem: "绱ф�ラ噰璐椂瀹℃壒娴佺▼澶嶆潅锛屾棤娉曟弧瓒崇揣鎬ラ渶姹�", - solution: "鍒跺畾绱ф�ラ噰璐鎵规爣鍑嗭紝鏄庣‘绱ф�ョ▼搴﹀垎绾э紝涓嶅悓绾у埆閲囩敤涓嶅悓瀹℃壒娴佺▼锛岀‘淇濈揣鎬ラ渶姹傚緱鍒板強鏃跺鐞�", - keyPoints: "绱ф�ュ垎绾�,鏍囧噯鍒跺畾,娴佺▼绠�鍖�,鍙婃椂澶勭悊", - creator: "鐜嬩笓鍛�", - usageCount: 12, - createTime: "2025-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 = [ @@ -472,13 +473,13 @@ const now = new Date(); const randomType = knowledgeTypes[Math.floor(Math.random() * knowledgeTypes.length)]; const randomScenario = scenarios[Math.floor(Math.random() * scenarios.length)]; - + // 鐢熸垚闅忔満鏍囬 let title = titleTemplates[Math.floor(Math.random() * titleTemplates.length)]; title = title .replace('{type}', randomType.label) .replace('{scenario}', randomScenario); - + const newKnowledge = { id: newId, title: title, @@ -488,19 +489,19 @@ problem: `鍦�${randomScenario}杩囩▼涓亣鍒扮殑闂鎻忚堪...`, solution: `閽堝${randomScenario}鐨勮В鍐虫柟妗堝拰鎿嶄綔姝ラ...`, keyPoints: "鍏抽敭瑕佺偣1,鍏抽敭瑕佺偣2,鍏抽敭瑕佺偣3,鍏抽敭瑕佺偣4", - creator: ["闄堝織寮�", "鍒橀泤濠�", "鐜嬪缓鍥�", "璧典附鍗�"][Math.floor(Math.random() * 4)], + creator: ["寮犵粡鐞�", "鏉庝富绠�", "鐜嬩笓鍛�", "鍒樻�荤洃"][Math.floor(Math.random() * 4)], usageCount: Math.floor(Math.random() * 20) + 1, createTime: now.toLocaleString() }; - + // 娣诲姞鍒版暟鎹紑澶� mockData.unshift(newKnowledge); - + // 淇濇寔鏁版嵁閲忓湪鍚堢悊鑼冨洿鍐咃紙鏈�澶氫繚鐣�30鏉★級 if (mockData.length > 30) { mockData = mockData.slice(0, 30); } - + console.log(`[${new Date().toLocaleString()}] 鑷姩鐢熸垚鏂扮煡璇�: ${title}`); }; @@ -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, @@ -673,7 +665,7 @@ 鍏抽敭瑕佺偣锛�${currentKnowledge.value.keyPoints} 鍒涘缓浜猴細${currentKnowledge.value.creator} `.trim(); - + // 澶嶅埗鍒板壀璐存澘 navigator.clipboard.writeText(knowledgeText).then(() => { ElMessage.success("鐭ヨ瘑鍐呭宸插鍒跺埌鍓创鏉�"); @@ -690,7 +682,7 @@ mockData[index].usageCount += 1; currentKnowledge.value.usageCount += 1; } - + ElMessage.success("宸叉敹钘忥紝浣跨敤娆℃暟+1"); }; @@ -698,46 +690,28 @@ const submitForm = async () => { try { 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); } @@ -749,7 +723,7 @@ ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鐭ヨ瘑"); return; } - + ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", { confirmButtonText: "纭", cancelButtonText: "鍙栨秷", @@ -762,7 +736,7 @@ mockData.splice(index, 1); } }); - + ElMessage.success("鍒犻櫎鎴愬姛"); selectedIds.value = []; getList(); -- Gitblit v1.9.3