wr1207
2023-04-17 32e4bad2cff2793052effcd2d59cdd8923702b22
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
<template>
    <el-dialog title="设置字体图标" class="icon-dialog" width="800px" top="20px" :visible.sync="iconshow" :before-close="closeForm" append-to-body>
      <ul class="icon-ul">
        <li  v-for="icon in iconList" :key="icon" @click="onSelect(icon)">
          <i :class="icon" />
          <div>{{ icon }}</div>
        </li>
      </ul>
    </el-dialog>
</template>
 
<script>
import iconList from '@/utils/icon.json'
export default {
    name:'Icon',
    props: {
        iconshow: {
            type: Boolean,
            default: false
        },
        currentIconModel:{
          type:String,
        }
    },
    data() {
        return {
            iconList: '',
        }
    },
    watch:{
      iconshow(){
        const originList = iconList.map(name => `el-icon-${name}`)
        this.iconList = originList
      }
    },
    methods: {
        onSelect(icon) {
          this.$emit('update:icon', icon)
          this.$emit('update:iconshow', false)
        },
        closeForm(){
            this.$emit('update:iconshow', false)
        }
    },
}
</script>
<style lang="scss">
.icon-dialog{
  .el-dialog {
    margin-bottom: 0;
    margin-top: 4vh !important;
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    overflow: hidden;
    box-sizing: border-box;
    .el-dialog__header {
      padding-top: 14px;
    }
    .el-dialog__body {
      margin: 20px;
      padding: 0;
      overflow: auto;
    }
 
  }
}
 
.icon-ul {
  margin: 0;
  padding: 0;
  font-size: 0;
  li {
    list-style-type: none;
    text-align: center;
    font-size: 14px;
    display: inline-block;
    width: 16.66%;
    box-sizing: border-box;
    height: 108px;
    padding: 15px 6px 6px 6px;
    cursor: pointer;
    overflow: hidden;
    &:hover {
      background: #f2f2f2;
    }
    &.active-item{
      background: #e1f3fb;
      color: #7a6df0
    }
    > i {
      font-size: 30px;
      line-height: 50px;
    }
  }
}
 
</style>