update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import XImage from "../XImage/Index.vue";
|
||||
import Api from "../../api/index.js";
|
||||
|
||||
const {size, api} = defineProps({
|
||||
const {size, api, multiple} = defineProps({
|
||||
size: {
|
||||
type: String,
|
||||
default: '60px'
|
||||
@@ -10,14 +10,23 @@ const {size, api} = defineProps({
|
||||
api: {
|
||||
type: Function,
|
||||
default: Api.system.uploadFile,
|
||||
},
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
}
|
||||
});
|
||||
const files = defineModel('files');
|
||||
const emits = defineEmits(['success']);
|
||||
|
||||
const beforeUpload = (file) => {
|
||||
api(file).then(({data}) => {
|
||||
files.value.push(data);
|
||||
api && api(file).then(({data}) => {
|
||||
console.log(files.value);
|
||||
if (!multiple) {
|
||||
files.value = [data];
|
||||
} else {
|
||||
files.value.push(data);
|
||||
}
|
||||
emits('success', data);
|
||||
});
|
||||
return false;
|
||||
@@ -26,7 +35,8 @@ const beforeUpload = (file) => {
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-[15px]">
|
||||
<a-upload :style="{width: size,height: size}" @before-upload="beforeUpload" multiple>
|
||||
<a-upload v-if="!(!multiple && files.length >= 1)" :style="{width: size,height: size}"
|
||||
@before-upload="beforeUpload" :multiple="multiple">
|
||||
<template #upload-button>
|
||||
<div class="upload-button test">
|
||||
<IconPlus/>
|
||||
|
||||
Reference in New Issue
Block a user