From acc02f587852de9472c13dd116db8846ade353b5 Mon Sep 17 00:00:00 2001 From: ZJQX1607 <1791254914@qq.com> Date: Wed, 15 May 2024 20:52:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=96=87=E4=BB=B6id=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/Image.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Upload/Image.vue b/src/components/Upload/Image.vue index ef65a251..81e50571 100644 --- a/src/components/Upload/Image.vue +++ b/src/components/Upload/Image.vue @@ -71,7 +71,8 @@ interface UploadFileProps { width?: string; // 组件宽度 ==> 非必传(默认为 150px) borderRadius?: string; // 组件边框圆角 ==> 非必传(默认为 8px) iconSize?: number; - dir?: string; // 文件目录 + dir?: string; // 文件目录 + fileId?: string; //文件id } // 接受父组件参数 @@ -85,7 +86,8 @@ const props = withDefaults(defineProps(), { height: '150px', width: '150px', borderRadius: '8px', - dir: '' + dir: '', + fileId: '', }); // 生成组件唯一id @@ -108,6 +110,7 @@ const self_disabled = computed(() => { * */ interface UploadEmits { (e: 'update:imageUrl', value: string): void; + (e: 'update:fileId', value: string): void; } const emit = defineEmits(); const handleHttpUpload = async (options: UploadRequestOptions) => { @@ -124,6 +127,7 @@ const handleHttpUpload = async (options: UploadRequestOptions) => { data: formData, }); emit('update:imageUrl', data.url); + emit('update:fileId', data.fileId); // 调用 el-form 内部的校验方法(可自动校验) formItemContext?.prop && formContext?.validateField([formItemContext.prop as string]); } catch (error) { @@ -136,6 +140,7 @@ const handleHttpUpload = async (options: UploadRequestOptions) => { * */ const deleteImg = () => { emit('update:imageUrl', ''); + emit('update:fileId', ''); }; /** -- Gitee