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)