Fixiaobai
2023-10-08 d6781631162d56fcd59e2f6df0c3eb41e151e4b2
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
 
 
 
<style scoped>
  ::-webkit-scrollbar {
    width: 8px;
    background-color: #fff;
  }
 
  ::-webkit-scrollbar-thumb:vertical {
    background-color: rgba(0, 0, 0, 0.1);
    -webkit-border-radius: 6px;
  }
 
  .icon {
    width: 488px;
    height: 350px;
    padding: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background-color: #fff;
  }
 
  .template_label {
    cursor: pointer;
    user-select: none;
    padding: 8px 10px;
    line-height: 12px;
  }
 
  .template_label i,
  span {
    font-size: 0.7rem;
    font-weight: bold;
  }
 
  .template_label i {
    float: right;
  }
 
  .template_icon {
    height: calc(350px - 20px - 63px);
    padding: 0 9px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    transition: .3s;
  }
 
  .template_icon div {
    width: 40px;
    height: 40px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
  }
 
  .template_icon div:hover {
    background-color: rgba(0, 0, 0, 0.03);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
 
  .template_icon div:active {
    opacity: .7;
  }
 
  .template_icon i {
    font-size: 22px;
    color: #666;
  }
</style>
 
<template>
  <div class="icon">
    <el-col>
      <el-input placeholder="输入关键字查询" size="small" prefix-icon="el-icon-search" v-model="search"
        style="font-size: 12px;"></el-input>
    </el-col>
    <el-col @click.native="shows.mainShow = !shows.mainShow" class="template_label">
      <span>系统图标</span>
      <i :class="shows.mainShow?'el-icon-caret-bottom':'el-icon-caret-right'"></i>
    </el-col>
    <el-collapse-transition>
      <el-col class="template_icon" v-show="shows.mainShow">
        <div v-for="(a, ai) in icons" :key="ai" :title="a.name" v-show="a.name.indexOf(search)>-1"
          @click="$emit('selectIcon', a)">
          <i :class="a.class"></i>
        </div>
      </el-col>
    </el-collapse-transition>
  </div>
</template>
 
<script>
  import iconfont from '../../../static/img/alifont/iconfont.json'
  import elicon from '../../../static/json/icon.json'
  export default {
    data() {
      return {
        search: '',
        shows: {
          mainShow: true
        },
        icons: []
      }
    },
    mounted() {
      if (this.icons.length == 0) {
        iconfont.glyphs.forEach(a => {
          this.icons.push({
            class: 'iconfont ' + iconfont['css_prefix_text'] + a['font_class'],
            name: a['name']
          })
        })
        elicon.forEach(a =>{
          this.icons.push({
            class: a,
            name: a
          })
        })
      }
    },
  }
</script>