This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2021-01-06 06:21:20 -08:00
|
|
|
<template>
|
|
|
|
<div class="form-group">
|
2021-01-07 14:18:33 -08:00
|
|
|
<draggable tag="ul" v-model="images" handle="img" ghostClass="ghost" @end="$emit('input', images)" class="list-unstyled">
|
2021-01-06 06:21:20 -08:00
|
|
|
<li v-for="image in images" class="mb-4">
|
|
|
|
<ImageThumb :id="image"/>
|
|
|
|
<a href="#" @click.prevent="removeFile(image)" class="small">
|
|
|
|
<Icon v="trash"/>
|
|
|
|
<T>crud.remove</T>
|
|
|
|
</a>
|
|
|
|
</li>
|
2021-01-07 14:18:33 -08:00
|
|
|
</draggable>
|
2021-01-08 06:14:53 -08:00
|
|
|
<ImageUploader :multiple="multiple" :name="name" form @uploaded="addFiles"/>
|
2021-01-06 06:21:20 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-01-07 14:18:33 -08:00
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
2021-01-06 06:21:20 -08:00
|
|
|
export default {
|
2021-01-07 14:18:33 -08:00
|
|
|
components: {
|
|
|
|
draggable,
|
|
|
|
},
|
2021-01-06 06:21:20 -08:00
|
|
|
props: {
|
|
|
|
value: {},
|
|
|
|
multiple: {type: Boolean},
|
|
|
|
name: {'default': 'images'},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
images: this.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value() {
|
|
|
|
this.images = this.value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
addFiles(files) {
|
|
|
|
this.$emit('input', [...this.images, ...files]);
|
|
|
|
},
|
|
|
|
async removeFile(id) {
|
|
|
|
await this.$confirm(this.$t('crud.removeConfirm'), 'danger');
|
|
|
|
this.$emit('input', this.images.filter(i => i !== id));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|