沈丘营商办后台前端项目
346149741
2024-06-18 9fb6a0ff49c2af567be2e3adaf93c4c301b3f102
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
<template>
  <div class="icon-body">
    <el-input v-model="iconName" style="position: relative" clearable placeholder="请输入图标名称" @clear="filterIcons" @input="filterIcons">
      <template #suffix><i class="el-icon-search el-input__icon" /></template>
    </el-input>
    <el-scrollbar height="200px">
      <div class="icon-list">
        <div class="icon-item hovers" :style="{ '--color': thcolor }" v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)">
          <svg-icon :icon-class="item" style="height: 30px; width: 16px" />
          <span class="txt">{{ item }}</span>
        </div>
      </div>
    </el-scrollbar>
  </div>
</template>
 
<script setup>
import icons from "./requireIcons";
import useSettingsStore from "@/store/modules/settings";
const thcolor = computed(() => useSettingsStore().theme);
const iconName = ref("");
const iconList = ref(icons);
const emit = defineEmits(["selected"]);
 
function filterIcons() {
  iconList.value = icons;
  if (iconName.value) {
    iconList.value = icons.filter((item) => item.indexOf(iconName.value) !== -1);
  }
}
 
function selectedIcon(name) {
  emit("selected", name);
  document.body.click();
}
 
function reset() {
  iconName.value = "";
  iconList.value = icons;
}
 
defineExpose({
  reset,
});
</script>
 
<style lang="scss" scoped>
.hovers {
  cursor: pointer;
  transition: transform 0.5s;
}
 
.hovers:hover {
  color: var(--color);
  transform: scale(1.3);
}
.icon-body {
  width: 100%;
  padding: 10px;
  .icon-list {
    height: 200px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
 
    .icon-item {
      // height: 30px;
      // line-height: 30px;
      // margin-bottom: -5px;
      // cursor: pointer;
      // width: 33%;
      // float: left;
      width: 65px;
      // height: 60px;
      text-align: center;
      // line-height: 50px;
      margin-left: 5px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      // overflow-x: hidden;
      .txt {
        width: 100%;
        font-size: 14px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    span {
      display: inline-block;
      vertical-align: -0.15em;
      fill: currentColor;
      overflow: hidden;
    }
  }
}
</style>