优化多图上传
This commit is contained in:
parent
044ae4ccd9
commit
c986fdc505
@ -53,11 +53,11 @@
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import OSS from 'ali-oss';
|
||||
import { generateUUID } from '@/utils/auth';
|
||||
|
||||
const uploadRef = ref<UploadInstance>();
|
||||
import { upload, getOssConfig } from '@/api/common';
|
||||
|
||||
// 接受父组件参数
|
||||
/**
|
||||
* 接受父组件参数
|
||||
*/
|
||||
const props = defineProps({
|
||||
zIndex: {
|
||||
default: -1,
|
||||
@ -104,6 +104,11 @@
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 定义参数
|
||||
*/
|
||||
const uploadRef = ref<UploadInstance>();
|
||||
// 生成组件唯一id
|
||||
const uuid = ref('id-' + generateUUID());
|
||||
|
||||
@ -266,15 +271,28 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行预览
|
||||
* @param index 参数
|
||||
*/
|
||||
const onPreview = (index: any) => {
|
||||
window.open(props.fileList[index].filePath);
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行编辑
|
||||
* @param index 参数
|
||||
*/
|
||||
const handleEdit = (index: any) => {
|
||||
editIndex = index;
|
||||
const dom = document.querySelector(`#${uuid.value} .el-upload__input`);
|
||||
dom && dom.dispatchEvent(new MouseEvent('click'));
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行删除
|
||||
* @param index 参数
|
||||
*/
|
||||
const handleRemove = (index: any) => {
|
||||
editIndex = index;
|
||||
if (props.multiple) {
|
||||
@ -289,6 +307,9 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 设置最大上传张数
|
||||
*/
|
||||
const onExceed = () => {
|
||||
if (props.limit) {
|
||||
ElNotification({
|
||||
|
@ -50,7 +50,7 @@
|
||||
@changeFileName="(name) => (formData.coverImgName = name)"
|
||||
:fileType="['image/jpeg', 'image/png', 'image/jpg', 'image/gif']"
|
||||
name="article"
|
||||
:fileSize="20"
|
||||
:fileSize="5"
|
||||
v-model:image-url="formData.cover"
|
||||
>
|
||||
<template #tip>支持扩展名: jpg png jpeg;文件大小不超过20M</template>
|
||||
|
Loading…
Reference in New Issue
Block a user