|
1
|
<!-- @author zhengjie -->
|
1
|
<!-- @author zhengjie -->
|
|
2
|
<template>
|
2
|
<template>
|
|
3
|
<div class="icon-body">
|
3
|
<div class="icon-body">
|
|
4
|
- <el-input v-model="name" style="position: relative;" clearable placeholder="请输入图标名称" @clear="filterIcons" @input="filterIcons">
|
4
|
+ <el-input v-model="name" class="icon-search" clearable placeholder="请输入图标名称" @clear="filterIcons" @input="filterIcons">
|
|
5
|
<i slot="suffix" class="el-icon-search el-input__icon" />
|
5
|
<i slot="suffix" class="el-icon-search el-input__icon" />
|
|
6
|
</el-input>
|
6
|
</el-input>
|
|
7
|
<div class="icon-list">
|
7
|
<div class="icon-list">
|
|
8
|
- <div v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)">
|
|
|
|
9
|
- <svg-icon :icon-class="item" style="height: 30px;width: 16px;" />
|
|
|
|
10
|
- <span>{{ item }}</span>
|
|
|
|
11
|
- </div>
|
8
|
+ <el-scrollbar>
|
|
|
|
9
|
+ <div class="list-container">
|
|
|
|
10
|
+ <div v-for="(item, index) in iconList" class="icon-item-wrapper" :key="index" @click="selectedIcon(item)">
|
|
|
|
11
|
+ <div :class="['icon-item', { active: activeIcon === item }]">
|
|
|
|
12
|
+ <svg-icon :icon-class="item" class-name="icon" style="height: 30px;width: 16px;" />
|
|
|
|
13
|
+ <span :title="item">{{ item }}</span>
|
|
|
|
14
|
+ </div>
|
|
|
|
15
|
+ </div>
|
|
|
|
16
|
+ </div>
|
|
|
|
17
|
+ </el-scrollbar>
|
|
12
|
</div>
|
18
|
</div>
|
|
13
|
</div>
|
19
|
</div>
|
|
14
|
</template>
|
20
|
</template>
|
|
@@ -17,6 +23,11 @@ |
|
@@ -17,6 +23,11 @@ |
|
17
|
import icons from './requireIcons'
|
23
|
import icons from './requireIcons'
|
|
18
|
export default {
|
24
|
export default {
|
|
19
|
name: 'IconSelect',
|
25
|
name: 'IconSelect',
|
|
|
|
26
|
+ props: {
|
|
|
|
27
|
+ activeIcon: {
|
|
|
|
28
|
+ type: String
|
|
|
|
29
|
+ }
|
|
|
|
30
|
+ },
|
|
20
|
data() {
|
31
|
data() {
|
|
21
|
return {
|
32
|
return {
|
|
22
|
name: '',
|
33
|
name: '',
|
|
@@ -46,22 +57,55 @@ export default { |
|
@@ -46,22 +57,55 @@ export default { |
|
46
|
.icon-body {
|
57
|
.icon-body {
|
|
47
|
width: 100%;
|
58
|
width: 100%;
|
|
48
|
padding: 10px;
|
59
|
padding: 10px;
|
|
|
|
60
|
+ .icon-search {
|
|
|
|
61
|
+ position: relative;
|
|
|
|
62
|
+ margin-bottom: 5px;
|
|
|
|
63
|
+ }
|
|
49
|
.icon-list {
|
64
|
.icon-list {
|
|
50
|
height: 200px;
|
65
|
height: 200px;
|
|
51
|
- overflow-y: scroll;
|
|
|
|
52
|
- div {
|
|
|
|
53
|
- height: 30px;
|
|
|
|
54
|
- line-height: 30px;
|
|
|
|
55
|
- margin-bottom: -5px;
|
|
|
|
56
|
- cursor: pointer;
|
|
|
|
57
|
- width: 33%;
|
|
|
|
58
|
- float: left;
|
66
|
+ ::v-deep .el-scrollbar {
|
|
|
|
67
|
+ height: 100%;
|
|
|
|
68
|
+ .el-scrollbar__wrap {
|
|
|
|
69
|
+ overflow-x: hidden;
|
|
|
|
70
|
+ }
|
|
59
|
}
|
71
|
}
|
|
60
|
- span {
|
|
|
|
61
|
- display: inline-block;
|
|
|
|
62
|
- vertical-align: -0.15em;
|
|
|
|
63
|
- fill: currentColor;
|
|
|
|
64
|
- overflow: hidden;
|
72
|
+ .list-container {
|
|
|
|
73
|
+ display: flex;
|
|
|
|
74
|
+ flex-wrap: wrap;
|
|
|
|
75
|
+ .icon-item-wrapper {
|
|
|
|
76
|
+ width: calc(100% / 3);
|
|
|
|
77
|
+ height: 30px;
|
|
|
|
78
|
+ line-height: 30px;
|
|
|
|
79
|
+ margin-bottom: -5px;
|
|
|
|
80
|
+ cursor: pointer;
|
|
|
|
81
|
+ display: flex;
|
|
|
|
82
|
+ .icon-item {
|
|
|
|
83
|
+ display: flex;
|
|
|
|
84
|
+ max-width: 100%;
|
|
|
|
85
|
+ height: 100%;
|
|
|
|
86
|
+ padding: 0 2px;
|
|
|
|
87
|
+ &:hover {
|
|
|
|
88
|
+ background: #ececec;
|
|
|
|
89
|
+ border-radius: 5px;
|
|
|
|
90
|
+ }
|
|
|
|
91
|
+ .icon {
|
|
|
|
92
|
+ flex-shrink: 0;
|
|
|
|
93
|
+ }
|
|
|
|
94
|
+ span {
|
|
|
|
95
|
+ display: inline-block;
|
|
|
|
96
|
+ vertical-align: -0.15em;
|
|
|
|
97
|
+ fill: currentColor;
|
|
|
|
98
|
+ padding-left: 2px;
|
|
|
|
99
|
+ overflow: hidden;
|
|
|
|
100
|
+ text-overflow: ellipsis;
|
|
|
|
101
|
+ white-space: nowrap;
|
|
|
|
102
|
+ }
|
|
|
|
103
|
+ }
|
|
|
|
104
|
+ .icon-item.active {
|
|
|
|
105
|
+ background: #ececec;
|
|
|
|
106
|
+ border-radius: 5px;
|
|
|
|
107
|
+ }
|
|
|
|
108
|
+ }
|
|
65
|
}
|
109
|
}
|
|
66
|
}
|
110
|
}
|
|
67
|
}
|
111
|
}
|