Commit aa916a7c authored by 刘殿昕's avatar 刘殿昕

+拖拽上传功能

parent 7a738e81
<template> <template>
<div> <div>
<div v-if="type != 'cropper'"> <div class="img_crop" v-if="type == 'cropper'">
<div v-for="(item, index) in fileArray" :key="'img' + index" class="list_img">
<div v-if="!readOnly" @click="deleteImg(item, index)" class="list_img_back">
<i class="el-icon-delete img_del"></i>
</div>
<el-image class="list_img_item" :src="item.url" :fit="fit"></el-image>
</div>
<cropper v-if="fileArray.length <= max" @getNewUrl="getNewUrl"></cropper>
</div>
<div v-else>
<el-upload <el-upload
action="ssurl" action="ssurl"
:file-list="fileArray" :file-list="fileArray"
...@@ -13,20 +22,19 @@ ...@@ -13,20 +22,19 @@
:class="{hide:hideUpload || readOnly}" :class="{hide:hideUpload || readOnly}"
:readOnly="readOnly" :readOnly="readOnly"
:data="anotherData" :data="anotherData"
:drag="drag"
> >
<el-button size="small" type="primary" v-if="type=='mp3'">上传文件</el-button> <div v-if="drag">
<div slot="tip" class="el-upload__tip" v-if="type=='mp3'">支持文件格式:.mp3,单个文件不能超过20M。</div> <i class="el-icon-upload"></i>
<i class="el-icon-plus" v-if="type=='picture'"></i> <div class="el-upload__text">
</el-upload> 将文件拖到此处,或
</div> <em>点击上传</em>
<div class="img_crop" v-else> </div>
<div v-for="(item, index) in fileArray" :key="'img' + index" class="list_img">
<div v-if="!readOnly" @click="deleteImg(item, index)" class="list_img_back">
<i class="el-icon-delete img_del"></i>
</div> </div>
<el-image class="list_img_item" :src="item.url" :fit="fit"></el-image> <el-button size="small" type="primary" v-if="!drag && type=='default'">上传文件</el-button>
</div> <div slot="tip" class="el-upload__tip" v-if="!drag && type=='mp3'">支持文件格式:.mp3,单个文件不能超过20M。</div>
<cropper v-if="fileArray.length <= max" @getNewUrl="getNewUrl"></cropper> <i class="el-icon-plus" v-if="!drag && type=='picture'"></i>
</el-upload>
</div> </div>
</div> </div>
</template> </template>
...@@ -55,7 +63,7 @@ export default { ...@@ -55,7 +63,7 @@ export default {
}, },
list: { list: {
type: Array, type: Array,
default: [] default: () => []
}, },
type: { type: {
type: String, type: String,
...@@ -68,6 +76,10 @@ export default { ...@@ -68,6 +76,10 @@ export default {
fit: { fit: {
type: String, type: String,
default: "" default: ""
},
drag: {
type: Boolean,
default: false
} }
}, },
watch: { watch: {
...@@ -131,8 +143,8 @@ export default { ...@@ -131,8 +143,8 @@ export default {
this.hideUpload = fileList.length >= this.max; this.hideUpload = fileList.length >= this.max;
}, },
handleRemove(file, fileList) { handleRemove(file, fileList) {
if(!(fileList&&fileList.length>0)){ if (!(fileList && fileList.length > 0)) {
return return;
} }
let url = file.url; let url = file.url;
let detection = true; let detection = true;
......
<template> <template>
<div class="up_ex_container"> <div class="up_ex_container">
<h3>压缩包上传</h3>
<upload-file
:multiple="false"
:max="1"
type="zip"
:readOnly="false"
:drag="true"
@getNewList="getNewList"
></upload-file>
<h3>带有裁剪功能的图片上传</h3> <h3>带有裁剪功能的图片上传</h3>
<upload-file <upload-file
:multiple="false" :multiple="false"
...@@ -23,7 +32,7 @@ ...@@ -23,7 +32,7 @@
<upload-file <upload-file
:multiple="false" :multiple="false"
:max="4" :max="4"
type="mp3" type="default"
:readOnly="false" :readOnly="false"
fit="fill" fit="fill"
:list="imgList" :list="imgList"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment