From efde01cee841611bf6f5cc9538fc39f6313e1533 Mon Sep 17 00:00:00 2001 From: DYL0109 <1332079466@qq.com> Date: 星期二, 21 一月 2025 10:20:08 +0800 Subject: [PATCH] !35 开发了知识库相关的功能 Merge pull request !35 from liulingling1993/lll0118 --- zhitan-vue/src/components/FileUpload/index.vue | 7 ++++--- zhitan-vue/src/api/policy/knowledgeBase.js | 5 ++--- zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue | 31 ++++++++++++++++++++++++++++--- zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue | 11 +++++++++-- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/zhitan-vue/src/api/policy/knowledgeBase.js b/zhitan-vue/src/api/policy/knowledgeBase.js index 573e1ad..22b8698 100644 --- a/zhitan-vue/src/api/policy/knowledgeBase.js +++ b/zhitan-vue/src/api/policy/knowledgeBase.js @@ -24,9 +24,8 @@ // 鏌ヨ鎯� export function knowledgeBaseInfo(params) { return request({ - url: `/knowledgeBase/detail/${params.id}`, - method: 'get', - params + url: "/knowledgeBase/detail?id="+params, + method: 'get' }) } diff --git a/zhitan-vue/src/components/FileUpload/index.vue b/zhitan-vue/src/components/FileUpload/index.vue index 4b76324..488d3ee 100644 --- a/zhitan-vue/src/components/FileUpload/index.vue +++ b/zhitan-vue/src/components/FileUpload/index.vue @@ -55,7 +55,7 @@ // 鏂囦欢绫诲瀷, 渚嬪['png', 'jpg', 'jpeg'] fileType: { type: Array, - default: () => ["doc", "xls", "ppt", "txt", "pdf"], + default: () => ["doc", "xls", "ppt", "txt", "pdf","docx"], }, // 鏄惁鏄剧ず鎻愮ず isShowTip: { @@ -147,7 +147,7 @@ // 鍒犻櫎鏂囦欢 function handleDelete(index) { fileList.value.splice(index, 1); - emit("update:modelValue", listToString(fileList.value)); + emit("update:modelValue", fileList.value); } // 涓婁紶缁撴潫澶勭悊 @@ -156,7 +156,8 @@ fileList.value = fileList.value.filter(f => f.url !== undefined).concat(uploadList.value); uploadList.value = []; number.value = 0; - emit("update:modelValue", listToString(fileList.value)); + console.log(fileList.value) + emit("update:modelValue", fileList.value); proxy.$modal.closeLoading(); } } diff --git a/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue b/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue index 9aaf0d0..a644d2d 100644 --- a/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue +++ b/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue @@ -14,9 +14,12 @@ <el-form-item label="鍐呭" prop="content"> <el-input v-model="form.content" placeholder="璇疯緭鍏ュ唴瀹�" /> </el-form-item> - <!-- <el-form-item label="闄勪欢" prop="url"> - <FileUpload></FileUpload> - </el-form-item> --> + <el-form-item label="闄勪欢" prop="url"> + <FileUpload + :modelValue="fileList" + @update:modelValue="val => fileList = val" + ></FileUpload> + </el-form-item> </el-form> <div slot="footer" class="text-right"> <el-button type="primary" @click="submitForm" :loading="loading">纭� 瀹�</el-button> @@ -40,6 +43,7 @@ type: null, url:[] }) +let fileList=ref([]) let emit = defineEmits(['getList']) const formRules = { title: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ爣棰�" }], @@ -51,6 +55,10 @@ proxy.$refs.queryRef.validate(valid => { if (valid) { loading.value = true; + form.value.url=[] + for(let i=0;i<fileList.value.length;i++){ + form.value.url.push(fileList.value[i].url) + } let obj = form.value.id ? knowledgeBaseEdit(form.value) : knowledgeBaseAdd(form.value) obj.then((res) => { if (res.code == 200) { @@ -74,9 +82,26 @@ function handleOpen(row) { + debugger + fileList.value=[] if (row && row.id) { title.value = "缂栬緫鐭ヨ瘑搴�" form.value = JSON.parse(JSON.stringify(row)) + let fileItem={ + name:'', + url:'' + } + let files=[] + if(row.url && row.url.length){ + for(let i=0;i<row.url.length;i++){ + fileItem.url=row.url[i] + fileItem.name=row.url[i] + console.log(fileItem) + files.push(JSON.parse(JSON.stringify(fileItem)) ) + } + fileList.value=files + console.log(fileList.value) + } } else { title.value = "娣诲姞鐭ヨ瘑搴�" } diff --git a/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue b/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue index e8f32a2..ac9cc39 100644 --- a/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue +++ b/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue @@ -52,7 +52,7 @@ <script setup> import EditModal from "./components/EditModal.vue" -import { knowledgeBaseList, knowledgeBaseDel } from "@/api/policy/knowledgeBase" +import { knowledgeBaseList, knowledgeBaseDel,knowledgeBaseInfo } from "@/api/policy/knowledgeBase" let { proxy } = getCurrentInstance() const types = ref([ { label: "鐢�", value: 0 }, @@ -85,7 +85,14 @@ let EditModalRef = ref("") function handleAdd(row) { if (EditModalRef.value) { - EditModalRef.value.handleOpen(row) + if(row.id){ + knowledgeBaseInfo(row.id).then((res) => { + EditModalRef.value.handleOpen(res.data) + }) + }else{ + EditModalRef.value.handleOpen(row) + } + } } -- Gitblit v1.9.3