index.vue
2.99 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
<div class="icon-List">
<el-dialog
:visible.sync="visible"
:append-to-body="true"
:show-close="isClose"
>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="内置图标" name="first">
<ul v-if="iconList" class="clearfix">
<li
v-for="(item, index) in iconList"
:key="index"
@click="changeData(item)"
>
<i :class="item" />
</li>
</ul>
</el-tab-pane>
<el-tab-pane label="自定义图标" name="second">
<el-upload
class="avatar-uploader"
action="https://jsonplaceholder.typicode.com/posts/"
>
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon">
<p>点击上传</p>
</i>
</el-upload>
<div>
<el-input v-model="iconName" class="icon-name" placeholder="请输入图标代码"></el-input>
</div>
<el-button class="confirm" type="primary" @click="changeIconName">确定</el-button>
</el-tab-pane>
</el-tabs>
</el-dialog>
</div>
</template>
<script>
import icoNameList from '@/utils/elementUI'
export default {
name: 'IconList',
components: {},
props: {},
data() {
return {
visible: false,
isClose: false,
iconList: [],
activeName: 'first',
iconName: '',
imageUrl: ''
}
},
computed: {},
watch: {},
created() {},
mounted() {
this.iconList = icoNameList
},
methods: {
show(show) {
this.visible = show
},
handleClick(tab, event) {
console.log(tab, event)
},
changeData(iconName) {
this.visible = false
// 传递图标名称给父级
this.$emit('iconName', iconName)
},
changeIconName() {
this.visible = false
// 传递图标名称给父级
this.$emit('iconName', this.iconName)
}
}
}
</script>
<style scoped lang="scss">
::v-deep .el-dialog {
box-shadow: 0px 4px 10px 0px #666666;
border-radius: 4px;
width: 573px;
height: 300px;
position: relative;
top: 4vh;
left: 0vw;
.el-dialog__header {
display: none;
}
.el-dialog__body {
padding: 10px;
}
.el-tabs {
.el-tabs__content {
height: 200px;
overflow-y: scroll;
ul {
li {
float: left;
padding: 1%;
margin: 2px;
border: 1px solid #e8eaec;
cursor: pointer;
width: 30px;
height: 30px;
}
}
.avatar-uploader-icon {
font-size: 12px;
color: #8c939d;
text-align: center;
width: 62px;
height: 62px;
background: #f6f7f9;
border-radius: 4px;
border: 1px solid #e5e5e5;
padding-top: 32%;
}
}
}
.confirm {
float: right;
margin-top: 30px;
}
.icon-name {
width: 70%;
margin-top: 10px;
}
}
</style>