index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="select-container">
  3. <div class="select-box" @click="handleShow">
  4. <div class="text1" :style="{ height: modelValue + 'px' }"></div>
  5. <div class="icon"></div>
  6. </div>
  7. <div v-show="show" class="select-content">
  8. <div v-for="(item, index) in options" :key="index" :class="modelValue === item.value ? 'item item-active' : 'item'" @click="handleClick(item.value)">
  9. <div class="text1" :style="{ height: item.value + 'px' }"></div>
  10. </div>
  11. </div>
  12. </div>
  13. </template>
  14. <script lang="ts" setup name="LineWidthSelect">
  15. interface Props {
  16. modelValue: boolean;
  17. options: object[];
  18. }
  19. const props = withDefaults(defineProps<Props>(), {});
  20. const emits = defineEmits(['update:modelValue']);
  21. let show = ref();
  22. const handleShow = () => {
  23. show.value = true;
  24. };
  25. const handleClick = (value: string) => {
  26. emits('update:modelValue', value);
  27. show.value = false;
  28. };
  29. </script>
  30. <style lang="scss" scoped>
  31. .select-container {
  32. position: relative;
  33. }
  34. .select-box {
  35. width: 118px;
  36. height: 22px;
  37. line-height: 22px;
  38. background-color: rgba(26, 144, 255, 0.15) !important;
  39. border: 1px solid rgba(26, 144, 255, 0.15) !important;
  40. padding: 4px 8px !important;
  41. cursor: pointer;
  42. position: relative;
  43. display: flex;
  44. align-items: center;
  45. &::before {
  46. content: '';
  47. position: absolute;
  48. top: 0;
  49. left: 0;
  50. width: 6px;
  51. height: 6px;
  52. background: url('@/assets/images/inputIcon1.png') no-repeat;
  53. background-size: 100% 100%;
  54. }
  55. &::after {
  56. content: '';
  57. position: absolute;
  58. right: 0;
  59. bottom: 0;
  60. width: 6px;
  61. height: 6px;
  62. background: url('@/assets/images/inputIcon2.png') no-repeat;
  63. background-size: 100% 100%;
  64. }
  65. .text1 {
  66. flex: 1;
  67. height: 1px;
  68. background-color: #9dc2da;
  69. margin-right: 15px;
  70. }
  71. .icon {
  72. width: 7px;
  73. height: 13px;
  74. background: url('@/assets/images/select.png') no-repeat;
  75. background-size: 100% 100%;
  76. }
  77. }
  78. .select-content {
  79. position: absolute;
  80. left: 0;
  81. bottom: -65px;
  82. width: 100%;
  83. background-color: #113a84;
  84. border: 1px solid #124b9d;
  85. box-shadow: inset 0 0 20px #1a90ff80 !important;
  86. z-index: 9;
  87. padding: 6px 0;
  88. .item {
  89. height: 25px;
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. padding: 4px 10px !important;
  94. cursor: pointer;
  95. &:hover {
  96. background-color: #1c335f;
  97. }
  98. }
  99. .item-active {
  100. background-color: #1c335f;
  101. }
  102. .text1 {
  103. flex: 1;
  104. height: 1px;
  105. background-color: #9dc2da;
  106. }
  107. }
  108. </style>