wangrong
2026-08-30 761e5c5fa871959f60e15c971c8d83f2b53d0af5
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
<script lang="ts" setup>
import { inject, computed } from 'vue'
import { getCSSVariable } from '@/utils/color'
 
const props = defineProps({
  options: {
    type: Array,
    default: () => []
  },
  disabled: {
    type: Boolean,
    default: false
  },
  activeItems: {
    type: Array,
    default: () => []
  },
  selectStyle: {
    type: Object,
    default: () => ({})
  }
})
const customStyle: any = inject('$custom-style-filter')
 
const customSelectStyle = computed(() => {
  return customStyle
    ? { ...props.selectStyle, background: customStyle.background }
    : props.selectStyle
})
 
const customColor = computed(() => {
  return customStyle
    ? { color: customStyle.text, fontSize: customStyle.placeholderSize + 'px' }
    : {}
})
 
const boxHeight = computed(() => {
  return `${customStyle?.queryConditionHeight || 32}px`
})
 
const btnColor = computed(() => {
  return customStyle ? customStyle.btnColor : getCSSVariable()
})
 
const emits = defineEmits(['handleItemClick'])
const handleItemClick = (item: any) => {
  if (props.disabled) return
  emits('handleItemClick', item.value)
}
</script>
 
<template>
  <div :style="customSelectStyle" class="flat-select" :class="disabled && 'disabled-flat'">
    <el-scrollbar>
      <div class="scrollbar-flex-content">
        <p
          @click="handleItemClick(item)"
          v-for="item in options"
          :key="item"
          :style="customColor"
          class="select-item"
          :class="activeItems.includes(item.value) && 'active-select'"
        >
          {{ item.label }}
        </p>
      </div>
    </el-scrollbar>
  </div>
</template>
 
<style lang="less" scoped>
.flat-select {
  .ed-scrollbar.ed-scrollbar.ed-scrollbar {
    padding: 0;
  }
  .scrollbar-flex-content {
    display: flex;
    width: fit-content;
    .select-item {
      height: v-bind(boxHeight);
      padding: 0 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      cursor: pointer;
      white-space: nowrap;
      &.active-select::after {
        content: '';
        width: 80%;
        height: 2px;
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        background-color: v-bind(btnColor) !important;
      }
    }
  }
 
  &.disabled-flat {
    .select-item {
      cursor: not-allowed;
      &.active-select::after {
        background-color: #eff0f1 !important;
      }
    }
  }
}
</style>