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