image-purview.vue
2.29 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
<div class="image-purview">
<template v-if="status === 'finished' || url">
<img :src="url">
<div class="image-purview-cover">
<Icon type="ios-eye-outline" size="30" @click.native="purviewImage"></Icon>
<Icon type="ios-trash-outline" v-if="remove" size="30" @click.native="removeImage"></Icon>
</div>
</template>
<template v-else>
<Progress v-if="progress" :percent="percentage" hide-info></Progress>
</template>
<modal-purview v-model="showModal" :url="url"></modal-purview>
</div>
</template>
<script>
import modalPurview from './modal-purview'
export default {
name: 'image-purview',
props: {
status: {
type: String,
default: 'finished'
},
url: {
type: String,
},
progress: {
type: Boolean,
default: false,
},
percentage: {
type: Number,
},
remove: {
type: Boolean,
default: false
}
},
data() {
return {
showModal: false
};
},
methods: {
purviewImage() {
this.showModal = true;
this.$emit('purview', this.url);
},
removeImage() {
this.$emit('remove-image', this.url);
}
},
components: {
modalPurview
}
};
</script>
<style lang="scss">
.image-purview {
margin: 0 auto;
width: 100px;
height: 100px;
text-align: center;
border-radius: 4px;
overflow: hidden;
background: #fff;
position: relative;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
border: 1px solid #e8e8e8;
align-items: center;
justify-content: center;
display: flex;
.ivu-progress {
width: 90%;
}
}
.image-purview img {
width: 100px;
height: 100px;
}
.image-purview-cover {
display: none;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
align-items: center;
justify-content: center;
}
.image-purview:hover .image-purview-cover {
display: flex;
}
.image-purview-cover i {
color: #fff;
font-size: 20px;
cursor: pointer;
margin: 0 2px;
}
</style>