|
|
|
@ -11,7 +11,7 @@ |
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
name="file" |
|
|
|
|
:on-remove="handleRemove" |
|
|
|
|
:show-file-list="true" |
|
|
|
|
:show-file-list="false" |
|
|
|
|
:headers="headers" |
|
|
|
|
:file-list="fileList" |
|
|
|
|
:on-preview="handlePictureCardPreview" |
|
|
|
@ -19,7 +19,24 @@ |
|
|
|
|
> |
|
|
|
|
<i class="el-icon-plus"></i> |
|
|
|
|
</el-upload> |
|
|
|
|
|
|
|
|
|
<ul class="el-upload-list el-upload-list--picture-card"> |
|
|
|
|
<draggable v-model="fileList" @end="end" @start="start"> |
|
|
|
|
<li v-for="(item, index) in fileList" :key="item.uid" class="el-upload-list__item is-success animated"> |
|
|
|
|
<img :src="item.url" alt="" class="el-upload-list__item-thumbnail "> |
|
|
|
|
<i class="el-icon-close"></i> |
|
|
|
|
<span class="el-upload-list__item-actions"> |
|
|
|
|
<!-- 预览 --> |
|
|
|
|
<span class="el-upload-list__item-preview" @click="handlePictureCardPreviewFileDetail(item)"> |
|
|
|
|
<i class="el-icon-zoom-in"></i> |
|
|
|
|
</span> |
|
|
|
|
<!-- 删除 --> |
|
|
|
|
<span class="el-upload-list__item-delete" @click="handleRemoveFileDetail(index)"> |
|
|
|
|
<i class="el-icon-delete"></i> |
|
|
|
|
</span> |
|
|
|
|
</span> |
|
|
|
|
</li> |
|
|
|
|
</draggable> |
|
|
|
|
</ul> |
|
|
|
|
<!-- 上传提示 --> |
|
|
|
|
<div class="el-upload__tip" slot="tip" v-if="showTip"> |
|
|
|
|
请上传 |
|
|
|
@ -68,8 +85,11 @@ |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { getAccessToken } from "@/utils/auth"; |
|
|
|
|
|
|
|
|
|
import draggable from 'vuedraggable' |
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
|
draggable, |
|
|
|
|
}, |
|
|
|
|
props: { |
|
|
|
|
value: [String, Object, Array], |
|
|
|
|
// 图片数量限制 |
|
|
|
@ -151,7 +171,21 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 删除图片 |
|
|
|
|
start(e) { |
|
|
|
|
console.log(this.fileList,e); // 可选:打印当前 fileList 顺序 |
|
|
|
|
}, |
|
|
|
|
end(e) { |
|
|
|
|
this.$emit("input", this.listToString(this.fileList)); |
|
|
|
|
}, |
|
|
|
|
// 放大 |
|
|
|
|
handlePictureCardPreviewFileDetail(file) { |
|
|
|
|
this.dialogImageUrl = file.url; |
|
|
|
|
this.previewDialogVisible = true; |
|
|
|
|
}, |
|
|
|
|
// 删除 |
|
|
|
|
handleRemoveFileDetail(index) { |
|
|
|
|
this.fileList.splice(index, 1); |
|
|
|
|
}, // 删除图片 |
|
|
|
|
handleRemove(file, fileList) { |
|
|
|
|
const findex = this.fileList.map(f => f.name).indexOf(file.name); |
|
|
|
|
if (findex > -1) { |
|
|
|
|