PreviewDialog.vue
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<template>
<!-- 详情预览 -->
<div class="view_picture">
<el-dialog
:visible="previewVisible"
@update:visible="$emit('update:previewVisible',false)"
width="70%"
:before-close="handleClose"
:close-on-click-modal="false"
title="详情预览"
append-to-body
center
>
<div class="demo_image_lazy">
<div v-if="firstImg<1">暂无数据...</div>
<el-image v-for="url in urls" :key="url" :src="url" v-else lazy></el-image>
</div>
</el-dialog>
</div>
</template>
<script>
import { post } from "@/api/http";
export default {
props: ["previewVisible","reportId","type"],
data() {
return {
// 院校
urls: [],
id:"",
// 学习资源
source:[],
// 首张图片长度
firstImg:""
};
},
methods: {
handleClose: function() {
this.$emit("update:previewVisible", false);
},
// 大学院校详情
getSchoolDetail() {
let url = "/api/school/getSchoolDetail/";
let params = {
school_id: this.id
};
post(url, params).then(res => {
this.urls = res.report_img;
this.firstImg = this.urls[0].length
});
},
// 学习资源详情
getBooksDetail() {
let url = "/api/resource/getBooksDetail/";
let params = {
id: this.id
};
post(url, params).then(res => {
this.urls = res.file_images;
this.firstImg = this.urls[0].length
});
},
},
mounted() {
this.id = this.reportId;
if(this.type == 1){
// 院校
this.getSchoolDetail();
}else if(this.type == 2){
// 学习资源
this.getBooksDetail();
}
}
};
</script>
<style scoped>
.demo_image_lazy{
overflow-y: scroll;
height: 600px;
}
.el-image{
display:block!important;
width: 400px;
margin:0 auto;
margin-top:20px;
}
.el-image img{
height:100%;
}
</style>