From 08f83ed0155659c7c76628b136838ea8374836a1 Mon Sep 17 00:00:00 2001 From: gxwebsoft Date: Sun, 25 Feb 2024 16:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=9A=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=BB=B4=E4=BF=9D=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security2/components/security-edit.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/views/tower/maintenance/security2/components/security-edit.vue b/src/views/tower/maintenance/security2/components/security-edit.vue index 4c686f8..ca73a83 100644 --- a/src/views/tower/maintenance/security2/components/security-edit.vue +++ b/src/views/tower/maintenance/security2/components/security-edit.vue @@ -50,6 +50,7 @@ v-model:value="files" :item-style="{ width: '90px', height: '90px' }" :limit="20" + :upload-handler="uploadHandler" @upload="onUpload" /> @@ -176,6 +177,25 @@ form.replaceAccessories = e.target.value; } + + /* 上传事件 */ + const uploadHandler = (file: File) => { + const item: ItemType = { + file, + uid: (file as any).uid, + name: file.name + }; + if (!file.type.startsWith('image')) { + message.error('只能选择图片'); + return; + } + if (file.size / 1024 / 1024 > 2) { + message.error('大小不能超过 2MB'); + return; + } + onUpload(item); + }; + // 上传文件 const onUpload = (d: ItemType) => { uploadFile(d.file)