|
|
@@ -26,6 +26,16 @@
|
|
|
v-if="file.status === 'success' && isImage(file)"
|
|
|
@click="preview(file)"
|
|
|
></i>
|
|
|
+ <i
|
|
|
+ class="opt-icon el-icon-search"
|
|
|
+ v-if="file.status === 'success' && isPdf(file)"
|
|
|
+ @click="previewPdf(file)"
|
|
|
+ ></i>
|
|
|
+ <i
|
|
|
+ class="opt-icon el-icon-search"
|
|
|
+ v-if="file.status === 'success' && isDoc(file)"
|
|
|
+ @click="previewDoc(file)"
|
|
|
+ ></i>
|
|
|
<i class="opt-icon el-icon-download" v-if="file.status === 'success'" @click="download(file)"></i>
|
|
|
<i class="opt-icon el-icon-delete" @click="removeFile(file)" v-if="!readonly"></i>
|
|
|
</i>
|
|
|
@@ -38,8 +48,7 @@
|
|
|
class="upload-progress"
|
|
|
></el-progress>
|
|
|
</div>
|
|
|
- <el-image style="width:0;height:0;" :src="previewUrl" :preview-src-list="[previewUrl]" ref="preview">
|
|
|
- </el-image>
|
|
|
+ <el-image style="width:0;height:0;" :src="previewUrl" :preview-src-list="previewList" ref="preview"> </el-image>
|
|
|
</el-upload>
|
|
|
</template>
|
|
|
|
|
|
@@ -95,6 +104,15 @@ export default {
|
|
|
},
|
|
|
disabled() {
|
|
|
return this.fileList.length >= this.limit;
|
|
|
+ },
|
|
|
+ previewList() {
|
|
|
+ return [...this.fileList]
|
|
|
+ .filter(item => {
|
|
|
+ return this.isImage(item);
|
|
|
+ })
|
|
|
+ .map(item => {
|
|
|
+ return item.url;
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -156,9 +174,21 @@ export default {
|
|
|
this.$refs.preview.clickHandler();
|
|
|
});
|
|
|
},
|
|
|
+ previewDoc(file) {
|
|
|
+ window.open('https://view.officeapps.live.com/op/view.aspx?src=' + file.url, '_blank');
|
|
|
+ },
|
|
|
+ previewPdf(file) {
|
|
|
+ window.open(this.$baseUrl + '/pdf/web/viewer.html?file=' + file.url, '_blank');
|
|
|
+ },
|
|
|
isImage(file) {
|
|
|
return /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(file.url);
|
|
|
},
|
|
|
+ isPdf(file) {
|
|
|
+ return /\.(pdf)$/i.test(file.url);
|
|
|
+ },
|
|
|
+ isDoc(file) {
|
|
|
+ return /\.(docx|doc)$/i.test(file.url);
|
|
|
+ },
|
|
|
emit() {
|
|
|
this.emitting = true;
|
|
|
if (this.filesLimit === 1) {
|