zhengyiming
2025-02-10 958b79ed89b9e742540f714a80261d222c0fc09b
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
<template>
  <div class="tag-group-item-wrapper">
    <div :class="['tag-group-item', { active: props.active, canSelect: props.canSelect }]">
      <slot />
      <div v-if="showCloseBtn" class="close-btn-wrapper" @click.stop="emit('close')">
        <el-icon class="close-btn" :size="12"> <close /> </el-icon>
      </div>
    </div>
  </div>
</template>
 
<script setup lang="ts">
defineOptions({
  name: 'TagGroupItem',
});
 
type Props = {
  active?: boolean;
  canSelect?: boolean;
  showCloseBtn?: boolean;
};
 
const props = withDefaults(defineProps<Props>(), {
  active: false,
  canSelect: false,
  showCloseBtn: false,
});
 
const emit = defineEmits<{
  (e: 'close'): void;
}>();
</script>
 
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
 
.tag-group-item-wrapper {
  padding: 10px;
 
  .tag-group-item {
    position: relative;
    padding: 0 10px;
    height: 30px;
    font-size: 14px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    text-align: center;
    color: getCssVar('text-color', 'regular');
    background: #f3f3f3;
    transition: all 0.1s;
    line-height: 28px;
 
    &.canSelect {
      cursor: pointer;
    }
 
    &.active {
      border-color: getCssVar('color', 'primary', 'light-9');
      color: getCssVar('color', 'primary');
      background: getCssVar('color', 'primary', 'light-9');
    }
 
    .close-btn-wrapper {
      position: absolute;
      top: -6px;
      right: -6px;
      padding: 2px;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background-color: getCssVar('color', 'danger');
      cursor: pointer;
      box-sizing: border-box;
      line-height: 14px;
    }
 
    .close-btn {
      border-radius: 50%;
      color: #ffffff;
    }
  }
}
</style>