From 231334ac73df257d0f2a2d59f3697273b769070d Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期三, 08 四月 2026 09:36:03 +0800
Subject: [PATCH] feat(知识库): 添加文件删除功能和文件下载删除 联调等功能
---
src/api/collaborativeApproval/knowledgeBase.js | 8 ++--
src/views/collaborativeApproval/knowledgeBase/index.vue | 65 +++++++++++++++++++++++---------
2 files changed, 51 insertions(+), 22 deletions(-)
diff --git a/src/api/collaborativeApproval/knowledgeBase.js b/src/api/collaborativeApproval/knowledgeBase.js
index b195525..7a4b5a9 100644
--- a/src/api/collaborativeApproval/knowledgeBase.js
+++ b/src/api/collaborativeApproval/knowledgeBase.js
@@ -44,12 +44,12 @@
});
}
-// 鎵归噺鍒犻櫎鐭ヨ瘑搴�
-export function delKnowledgeBaseBatch(knowledgeBaseIds) {
+// 鍒犻櫎鐭ヨ瘑搴撴枃浠�
+export function delKnowledgeBaseFile(fileIds) {
return request({
- url: "/knowledgeBase/batch",
+ url: "/knowledgeBaseFile/del",
method: "delete",
- data: knowledgeBaseIds,
+ data: fileIds,
});
}
diff --git a/src/views/collaborativeApproval/knowledgeBase/index.vue b/src/views/collaborativeApproval/knowledgeBase/index.vue
index 236962c..7f970d6 100644
--- a/src/views/collaborativeApproval/knowledgeBase/index.vue
+++ b/src/views/collaborativeApproval/knowledgeBase/index.vue
@@ -145,6 +145,8 @@
:on-error="handleUploadError"
:on-success="handleUploadSuccess"
:on-remove="handleRemove"
+ :on-preview="handlePreview"
+ :show-file-list="true"
>
<el-button type="primary">涓婁紶</el-button>
<template #tip>
@@ -222,9 +224,10 @@
<div class="detail-section" v-if="currentKnowledge.commonFileList && currentKnowledge.commonFileList.length > 0">
<h4>闄勪欢鏉愭枡</h4>
<div class="file-list">
- <div v-for="file in currentKnowledge.commonFileList" :key="file.id" class="file-item" style="margin-bottom: 8px;">
- <el-icon><Document /></el-icon>
- <el-link type="primary" :href="file.url" target="_blank" style="margin-left: 8px;">{{ file.name }}</el-link>
+ <div v-for="file in currentKnowledge.commonFileList" :key="file.id" class="file-item">
+ <div class="file-info">
+ <el-link :href="file.url" target="_blank" :download="file.name">{{ file.name }}</el-link>
+ </div>
</div>
</div>
</div>
@@ -260,13 +263,12 @@
</template>
<script setup>
-import { Search, Document } from "@element-plus/icons-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 } from "@/api/collaborativeApproval/knowledgeBase.js";
-import { delLedgerFile } from "@/api/salesManagement/salesLedger.js";
+import { listKnowledgeBase, delKnowledgeBase,addKnowledgeBase,updateKnowledgeBase, delKnowledgeBaseFile } from "@/api/collaborativeApproval/knowledgeBase.js";
import useUserStore from '@/store/modules/user';
import { userListNoPageByTenantId } from '@/api/system/user.js';
import { getToken } from "@/utils/auth";
@@ -520,7 +522,7 @@
});
} else if (type === "edit" && row) {
dialogTitle.value = "缂栬緫鐭ヨ瘑";
- fileList.value = row.commonFileList || [];
+ fileList.value = row.files || [];
Object.assign(form.value, {
id: row.id,
title: row.title,
@@ -532,7 +534,8 @@
keyPoints: row.keyPoints,
creator: row.creator,
usageCount: row.usageCount,
- files: row.commonFileList || []
+ files: row.files || [],
+
});
}
dialogVisible.value = true;
@@ -681,14 +684,40 @@
}
}
// 绉婚櫎鏂囦欢
-function handleRemove(file) {
- if (dialogType.value === "edit") {
- let ids = [];
- ids.push(file.id);
- delLedgerFile(ids).then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+function handleRemove(file, fileList) {
+ // 濡傛灉鏄紪杈戞ā寮忎笖鏂囦欢鏈塱d锛岃皟鐢ˋPI鍒犻櫎
+ if (dialogType.value === "edit" && file.id) {
+ delKnowledgeBaseFile([file.id]).then((res) => {
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ // 浠巉orm.value.files涓Щ闄�
+ const index = form.value.files.findIndex(f => f.id === file.id);
+ if (index > -1) {
+ form.value.files.splice(index, 1);
+ }
+ } else {
+ proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触");
+ // 濡傛灉鍒犻櫎澶辫触锛岄噸鏂版坊鍔犲洖鏂囦欢鍒楄〃
+ fileList.push(file);
+ }
+ }).catch((error) => {
+ proxy.$modal.msgError("鍒犻櫎澶辫触");
+ // 濡傛灉鍒犻櫎澶辫触锛岄噸鏂版坊鍔犲洖鏂囦欢鍒楄〃
+ fileList.push(file);
});
+ } else {
+ // 鏂颁笂浼犵殑鏂囦欢锛岀洿鎺ヤ粠form.value.files涓Щ闄�
+ const index = form.value.files.findIndex(f => f.name === file.name && f.url === file.url);
+ if (index > -1) {
+ form.value.files.splice(index, 1);
+ }
}
+}
+
+// 鏂囦欢棰勮/涓嬭浇
+function handlePreview(file) {
+ // 鍒涘缓涓�涓殣钘忕殑a鏍囩鏉ヨЕ鍙戜笅杞�
+ proxy.$download.name(file.url);
}
// 鎻愪氦鐭ヨ瘑琛ㄥ崟
@@ -803,12 +832,12 @@
}
.detail-content {
- background: #f8f9fa;
- padding: 16px;
- border-radius: 6px;
line-height: 1.6;
color: #606266;
- white-space: pre-wrap;
+}
+
+.detail-section {
+ margin-top: 24px;
}
.key-points {
--
Gitblit v1.9.3