From 5cf2e4d20881c69b62fa3c9d26e668ec543d1c84 Mon Sep 17 00:00:00 2001 From: dj <1042039504@qq.com> Date: Fri, 11 Apr 2025 18:21:43 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(article-management):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=96=87=E7=AB=A0=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在文章管理页面添加公告附件列表 - 实现附件上传和展示功能- 优化 Tinymce 组件,支持附件上传事件 --- src/components/Tinymce.vue | 6 +++++- src/views/article-management/add.vue | 24 ++++++++++++++++++++++-- src/views/article-management/detail.vue | 4 ++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/components/Tinymce.vue b/src/components/Tinymce.vue index c38dcd4..ebe3971 100644 --- a/src/components/Tinymce.vue +++ b/src/components/Tinymce.vue @@ -38,7 +38,7 @@ import 'tinymce/plugins/wordcount' import 'tinymce/plugins/autosave' import '@/assets/axupimgs/plugin.js'//多图上传插件 -const emit = defineEmits(['update:value']) +const emit = defineEmits(['update:value','getFiles']) const props = defineProps({ //默认值 value: { @@ -78,6 +78,7 @@ const props = defineProps({ default: 500 } }) +const fileLists=ref([]) const content = ref(props.value); const imgUrl = ref(); // const apiKey = reactive("v4zo4n22oanvco29ws5drh0pecuf3gh53clx53cccj3grjwg"); @@ -168,6 +169,9 @@ const init = reactive({ type: res.code === 1000 ? 'success' : 'error' }) loading.close() + console.log("🚀 ~ file:res.data ", res.data) + fileLists.value.push(res.data) + emit('getFiles',fileLists.value) const fileUrl = res.data.url; // '?fileId='+res.data.id+ callback(fileUrl + '?fileName=' + res.data.originalFilename, {text: file.name, title: file.name}); diff --git a/src/views/article-management/add.vue b/src/views/article-management/add.vue index e74a49f..d6cec6e 100644 --- a/src/views/article-management/add.vue +++ b/src/views/article-management/add.vue @@ -27,10 +27,26 @@ - + + + + + +
+
+ {{index+1}}{{item.originalFilename}} +
+
+
+
+
@@ -54,6 +70,7 @@ const loading = ref(false) const showTinymce = ref(true) const fundForm = ref() const formData = ref({}) +const articleFile = ref({}) const routerName = ref(router.currentRoute.value.name) const rules = reactive({ articleTitle: [{required: true, message: '请输入文章标题', trigger: ['blur', 'change']}], @@ -64,7 +81,10 @@ const rules = reactive({ const handleBack = () => { history.back() } - +const getFiles=(filelist)=>{ + console.log("🚀 ~ file:filelist ", filelist) + articleFile.value=filelist +} const submitParam = (item) => { return { articleContent: item.articleContent, diff --git a/src/views/article-management/detail.vue b/src/views/article-management/detail.vue index 993d97c..03152a9 100644 --- a/src/views/article-management/detail.vue +++ b/src/views/article-management/detail.vue @@ -10,7 +10,7 @@ -
+
@@ -43,7 +43,7 @@ const clickHandle = (e) => { fileName } // handleDownload(fileId,fileName) - download(item) + // download(item) // }else { // e.preventDefault() // } From e20f8cad7f514933003578e6b128f106408cf344 Mon Sep 17 00:00:00 2001 From: dj <1042039504@qq.com> Date: Sun, 13 Apr 2025 21:22:22 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=92=8C=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Tinymce.vue | 4 +++- src/views/article-management/add.vue | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/Tinymce.vue b/src/components/Tinymce.vue index ebe3971..6fe222c 100644 --- a/src/components/Tinymce.vue +++ b/src/components/Tinymce.vue @@ -171,7 +171,9 @@ const init = reactive({ loading.close() console.log("🚀 ~ file:res.data ", res.data) fileLists.value.push(res.data) - emit('getFiles',fileLists.value) + if(meta.filetype !== "image"){ + emit('getFiles',fileLists.value) + } const fileUrl = res.data.url; // '?fileId='+res.data.id+ callback(fileUrl + '?fileName=' + res.data.originalFilename, {text: file.name, title: file.name}); diff --git a/src/views/article-management/add.vue b/src/views/article-management/add.vue index d6cec6e..7af6fbe 100644 --- a/src/views/article-management/add.vue +++ b/src/views/article-management/add.vue @@ -85,14 +85,33 @@ const getFiles=(filelist)=>{ console.log("🚀 ~ file:filelist ", filelist) articleFile.value=filelist } + const submitParam = (item) => { return { articleContent: item.articleContent, articleTitle: item.articleTitle, articleType: item.articleType, remarks: item.remarks, + articleId: item.articleId, + fileList:compositeParam(articleFile.value,item.articleId) } } +const compositeParam = (list,id) => { + const array= list?.map(item => { + return { + articleId:id?id:null, + fileId: item.id, + size: item.size, + originalFileName: item.originalFilename, + fileType: item.fileType, + url: item.url, + newFile: true, + tag: 'article' + } + }) + console.log('array',array) + return array +} const handleSubmit = async (instance) => { if (!instance) return instance.validate(async (valid) => { @@ -124,6 +143,7 @@ const handleResubmit = () => { articleId: route.query.id, ...submitParam(formData.value) } + console.log('params',params) editArticle(params).then(res => { ElNotification({ title: '提示', From c6390a81170be8c3233992ffaeda9dd2afec2bd0 Mon Sep 17 00:00:00 2001 From: dj <1042039504@qq.com> Date: Mon, 14 Apr 2025 15:07:58 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E6=96=87=E7=AB=A0=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A2=9E=E5=8A=A0=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?/=E5=88=A0=E9=99=A4/=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Tinymce.vue | 8 +- src/views/article-management/add.vue | 150 ++++++++++++++++-------- src/views/article-management/detail.vue | 23 +++- 3 files changed, 128 insertions(+), 53 deletions(-) diff --git a/src/components/Tinymce.vue b/src/components/Tinymce.vue index 6fe222c..43588cd 100644 --- a/src/components/Tinymce.vue +++ b/src/components/Tinymce.vue @@ -170,8 +170,12 @@ const init = reactive({ }) loading.close() console.log("🚀 ~ file:res.data ", res.data) - fileLists.value.push(res.data) - if(meta.filetype !== "image"){ + res.data.originalFileName=res.data.originalFilename + console.log("🚀 ~ file:'meta.filetype ",meta.filetype ) + + if (res && res.data && res.data.fileType && + !["png", "jpg", "jpeg","gif", "svg","ico"].includes(res.data.fileType.toLowerCase())){ + fileLists.value.push(res.data) emit('getFiles',fileLists.value) } const fileUrl = res.data.url; diff --git a/src/views/article-management/add.vue b/src/views/article-management/add.vue index 7af6fbe..fea8059 100644 --- a/src/views/article-management/add.vue +++ b/src/views/article-management/add.vue @@ -1,49 +1,65 @@ diff --git a/src/fvcomponents/fvTable/index.vue b/src/fvcomponents/fvTable/index.vue index 41baf4e..b9f05b3 100644 --- a/src/fvcomponents/fvTable/index.vue +++ b/src/fvcomponents/fvTable/index.vue @@ -1,5 +1,8 @@