From c523068c312960854fea2acdb61e27a6691a6371 Mon Sep 17 00:00:00 2001
From: ZN <zhang_12370@163.com>
Date: 星期三, 01 四月 2026 14:57:33 +0800
Subject: [PATCH] feat(知识库): 新增附件上传功能并更新侧边栏折叠logo
---
src/views/collaborativeApproval/knowledgeBase/index.vue | 94 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/src/views/collaborativeApproval/knowledgeBase/index.vue b/src/views/collaborativeApproval/knowledgeBase/index.vue
index bdaf0b4..0c1e44d 100644
--- a/src/views/collaborativeApproval/knowledgeBase/index.vue
+++ b/src/views/collaborativeApproval/knowledgeBase/index.vue
@@ -133,6 +133,27 @@
</el-form-item>
</el-col>
</el-row>
+ <el-form-item label="闄勪欢鏉愭枡" prop="tempFileIds">
+ <el-upload
+ v-model:file-list="fileList"
+ :action="upload.url"
+ multiple
+ ref="fileUpload"
+ auto-upload
+ :headers="upload.headers"
+ :before-upload="handleBeforeUpload"
+ :on-error="handleUploadError"
+ :on-success="handleUploadSuccess"
+ :on-remove="handleRemove"
+ >
+ <el-button type="primary">涓婁紶</el-button>
+ <template #tip>
+ <div class="el-upload__tip">
+ 鏀寔鏂囨。锛坉oc, docx, xls, xlsx, pdf, txt锛夊拰鍥剧墖锛坖pg, jpeg, png, gif锛夋牸寮�
+ </div>
+ </template>
+ </el-upload>
+ </el-form-item>
</el-form>
</FormDialog>
@@ -198,6 +219,16 @@
</div>
</div>
+ <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>
+ </div>
+ </div>
+
<div class="detail-section">
<h4>浣跨敤缁熻</h4>
<div class="usage-stats">
@@ -229,14 +260,16 @@
</template>
<script setup>
-import { Search } from "@element-plus/icons-vue";
+import { Search, Document } 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 useUserStore from '@/store/modules/user';
import { userListNoPageByTenantId } from '@/api/system/user.js';
+import { getToken } from "@/utils/auth";
// 琛ㄥ崟楠岃瘉瑙勫垯
const rules = {
@@ -268,6 +301,13 @@
},
tableData: [],
selectedIds: [],
+ fileList: [],
+ upload: {
+ // 涓婁紶鐨勫湴鍧�
+ url: import.meta.env.VITE_APP_BASE_API + "/file/upload",
+ // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+ headers: { Authorization: "Bearer " + getToken() },
+ },
form: {
title: "",
type: "",
@@ -277,7 +317,8 @@
solution: "",
keyPoints: "",
creator: "",
- usageCount: 0
+ usageCount: 0,
+ tempFileIds: []
},
dialogVisible: false,
dialogTitle: "",
@@ -292,6 +333,8 @@
page,
tableData,
selectedIds,
+ fileList,
+ upload,
form,
dialogVisible,
dialogTitle,
@@ -462,6 +505,7 @@
if (type === "add") {
dialogTitle.value = "鏂板鐭ヨ瘑";
// 閲嶇疆琛ㄥ崟锛岄粯璁ゅ垱寤轰汉涓哄綋鍓嶇敤鎴�
+ fileList.value = [];
Object.assign(form.value, {
title: "",
type: "",
@@ -471,10 +515,12 @@
solution: "",
keyPoints: "",
creator: userStore.nickName || "",
- usageCount: 0
+ usageCount: 0,
+ tempFileIds: []
});
} else if (type === "edit" && row) {
dialogTitle.value = "缂栬緫鐭ヨ瘑";
+ fileList.value = row.commonFileList || [];
Object.assign(form.value, {
id: row.id,
title: row.title,
@@ -485,7 +531,8 @@
solution: row.solution,
keyPoints: row.keyPoints,
creator: row.creator,
- usageCount: row.usageCount
+ usageCount: row.usageCount,
+ tempFileIds: (row.commonFileList || []).map(file => file.id)
});
}
dialogVisible.value = true;
@@ -577,6 +624,7 @@
// 鍏抽棴鐭ヨ瘑琛ㄥ崟瀵硅瘽妗�
const closeKnowledgeDialog = () => {
// 娓呯┖琛ㄥ崟鏁版嵁锛岄粯璁ゅ垱寤轰汉涓哄綋鍓嶇敤鎴�
+ fileList.value = [];
Object.assign(form.value, {
id: undefined,
title: "",
@@ -587,7 +635,8 @@
solution: "",
keyPoints: "",
creator: userStore.nickName || "",
- usageCount: 0
+ usageCount: 0,
+ tempFileIds: []
});
// 娓呴櫎琛ㄥ崟楠岃瘉鐘舵��
if (formRef.value) {
@@ -607,6 +656,41 @@
closeViewDialog();
};
+// 涓婁紶鍓嶆牎妫�
+function handleBeforeUpload(file) {
+ proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...");
+ return true;
+}
+// 涓婁紶澶辫触
+function handleUploadError(err) {
+ proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触");
+ proxy.$modal.closeLoading();
+}
+// 涓婁紶鎴愬姛鍥炶皟
+function handleUploadSuccess(res, file, uploadFiles) {
+ proxy.$modal.closeLoading();
+ if (res.code === 200) {
+ if (!form.value.tempFileIds) {
+ form.value.tempFileIds = [];
+ }
+ form.value.tempFileIds.push(res.data.tempId);
+ proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+ } else {
+ proxy.$modal.msgError(res.msg);
+ proxy.$refs.fileUpload.handleRemove(file);
+ }
+}
+// 绉婚櫎鏂囦欢
+function handleRemove(file) {
+ if (dialogType.value === "edit") {
+ let ids = [];
+ ids.push(file.id);
+ delLedgerFile(ids).then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ });
+ }
+}
+
// 鎻愪氦鐭ヨ瘑琛ㄥ崟
const submitForm = async () => {
try {
--
Gitblit v1.9.3