From dfd9d165ca88013c0557fcc01c19a6e183d0aed5 Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Sat, 18 Jan 2025 19:55:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor(notification):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=BC=96=E8=BE=91=E7=BB=84=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=99=84=E4=BB=B6=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -将 formData 中的 attachments 属性改为 attachmentIds,以更准确地表示附件 ID 列表 - 在编辑公告时,将附件列表转换为附件 ID 列表 - 更新附件上传和删除逻辑,以适应新的附件 ID 列表结构 - 移除 BulletinRecord接口中的 closeTime 属性,简化数据结构 --- src/api/bulletin-mgmt.ts | 1 - .../bulletin/components/bulletin-edit.vue | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/api/bulletin-mgmt.ts b/src/api/bulletin-mgmt.ts index aa054b9..580121c 100644 --- a/src/api/bulletin-mgmt.ts +++ b/src/api/bulletin-mgmt.ts @@ -26,7 +26,6 @@ export interface BulletinRecord extends BulletinCreateRecord { publishUserId: number; publishTime: string; closeUserId: number; - closeTime: string; attachments?: AttachmentRecord[]; } diff --git a/src/views/notification/bulletin/components/bulletin-edit.vue b/src/views/notification/bulletin/components/bulletin-edit.vue index 12fff9e..256c99f 100644 --- a/src/views/notification/bulletin/components/bulletin-edit.vue +++ b/src/views/notification/bulletin/components/bulletin-edit.vue @@ -64,7 +64,7 @@ > import useVisible from '@/hooks/visible'; import { computed, defineEmits, ref, shallowRef,onBeforeUnmount } from 'vue'; -import { BulletinRecord } from '@/api/bulletin-mgmt'; +import { BulletinRecord } from '@/api/bulletin-mgmt'; import { FormInstance } from '@arco-design/web-vue/es/form'; import { Message } from '@arco-design/web-vue'; import { useBulletinStore } from '@/store'; @@ -130,6 +130,7 @@ const formData = ref({ id: -1, title: '', top: false, + attachmentIds: [], content: '', remark: '', createTime: '', @@ -140,7 +141,6 @@ const formData = ref({ publishUserId: 0, publishTime: '', closeUserId: 0, - closeTime: '', attachments: [], }); @@ -188,6 +188,9 @@ const handleClick = () => { if(!props.isCreate){ bulletinStore.queryBulletinDetail(props.id).then((res: any) => { formData.value = res.data; + formData.value.attachmentIds = res.data.attachments?.map((item: any) => { + return item.id; + }); }) } }; @@ -243,7 +246,9 @@ const customRequest = async (option: any) => { const res = await bulletinStore.addAttachments(formDataFile); if (res.status === 200) { onSuccess(res.data); - formData.value.attachments?.push(res.data); + formData.value.attachmentIds?.push(res.data.id); + console.log(res.data.id); + console.log(formData.value); } else { onError(res.data); } @@ -251,7 +256,11 @@ const customRequest = async (option: any) => { // 删除附件 const beforeRemove = async (file: any) => { - const res = await bulletinStore.deleteAttachment(file.response.id); + if(!file.uid){ + const res = await bulletinStore.deleteAttachment(file.response.id); + return res.status === 200; + } + const res = await bulletinStore.deleteAttachment(file.uid); return res.status === 200; }