|
| 1 | +<script lang="ts" setup> |
| 2 | +import icon_done_outlined from '@/assets/svg/icon_done_outlined.svg' |
| 3 | +import { computed } from 'vue' |
| 4 | +import icon_expand_down_filled from '@/assets/svg/icon_down_outlined.svg' |
| 5 | +const props = defineProps({ |
| 6 | + chartTypeList: { |
| 7 | + type: Array<any>, |
| 8 | + default: () => [], |
| 9 | + }, |
| 10 | + chartType: { |
| 11 | + type: String, |
| 12 | + default: 'table', |
| 13 | + }, |
| 14 | + title: { |
| 15 | + type: String, |
| 16 | + default: '', |
| 17 | + }, |
| 18 | +}) |
| 19 | +const currentIcon = computed(() => { |
| 20 | + return props.chartTypeList.find((ele) => ele.value === props.chartType || ele.value === 'table') |
| 21 | + .icon |
| 22 | +}) |
| 23 | +const emits = defineEmits(['typeChange']) |
| 24 | +const handleDefaultChatChange = (val: any) => { |
| 25 | + emits('typeChange', val.value) |
| 26 | +} |
| 27 | +</script> |
| 28 | + |
| 29 | +<template> |
| 30 | + <el-popover trigger="click" popper-class="chat-type_select" placement="bottom"> |
| 31 | + <template #reference> |
| 32 | + <div class="chat-select_type" :class="chartType && chartType !== 'table' && 'active'"> |
| 33 | + <component :is="currentIcon" /> |
| 34 | + <el-icon style="transform: scale(0.75)" class="expand" size="16"> |
| 35 | + <icon_expand_down_filled></icon_expand_down_filled> |
| 36 | + </el-icon> |
| 37 | + </div> |
| 38 | + </template> |
| 39 | + <div class="popover"> |
| 40 | + <div class="popover-content"> |
| 41 | + <div v-if="!!title" class="title">{{ title }}</div> |
| 42 | + <div |
| 43 | + v-for="ele in chartTypeList" |
| 44 | + :key="ele.name" |
| 45 | + class="popover-item" |
| 46 | + :class="chartType === ele.value && 'isActive'" |
| 47 | + @click="handleDefaultChatChange(ele)" |
| 48 | + > |
| 49 | + <el-icon size="16"> |
| 50 | + <component :is="ele.icon" /> |
| 51 | + </el-icon> |
| 52 | + <div class="model-name">{{ ele.name }}</div> |
| 53 | + <el-icon size="16" class="done"> |
| 54 | + <icon_done_outlined></icon_done_outlined> |
| 55 | + </el-icon> |
| 56 | + </div> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + </el-popover> |
| 60 | +</template> |
| 61 | + |
| 62 | +<style lang="less"> |
| 63 | +.chat-type_select.chat-type_select { |
| 64 | + padding: 4px 0; |
| 65 | + width: 120px !important; |
| 66 | + min-width: 120px !important; |
| 67 | + box-shadow: 0px 4px 8px 0px #1f23291a; |
| 68 | + border: 1px solid #dee0e3; |
| 69 | +
|
| 70 | + .popover { |
| 71 | + .popover-content { |
| 72 | + padding: 0 4px; |
| 73 | + max-height: 300px; |
| 74 | + overflow-y: auto; |
| 75 | +
|
| 76 | + .title { |
| 77 | + width: 100%; |
| 78 | + height: 32px; |
| 79 | + margin-bottom: 2px; |
| 80 | + display: flex; |
| 81 | + align-items: center; |
| 82 | + padding-left: 8px; |
| 83 | + color: #8f959e; |
| 84 | + } |
| 85 | + } |
| 86 | + .popover-item { |
| 87 | + height: 32px; |
| 88 | + display: flex; |
| 89 | + align-items: center; |
| 90 | + padding-left: 12px; |
| 91 | + padding-right: 8px; |
| 92 | + margin-bottom: 2px; |
| 93 | + position: relative; |
| 94 | + border-radius: 4px; |
| 95 | + cursor: pointer; |
| 96 | + &:last-child { |
| 97 | + margin-bottom: 0; |
| 98 | + } |
| 99 | + &:hover { |
| 100 | + background: #1f23291a; |
| 101 | + } |
| 102 | +
|
| 103 | + .model-name { |
| 104 | + margin-left: 8px; |
| 105 | + font-weight: 400; |
| 106 | + font-size: 14px; |
| 107 | + line-height: 22px; |
| 108 | + max-width: 220px; |
| 109 | + } |
| 110 | +
|
| 111 | + .done { |
| 112 | + margin-left: auto; |
| 113 | + display: none; |
| 114 | + } |
| 115 | +
|
| 116 | + &.isActive { |
| 117 | + color: var(--ed-color-primary); |
| 118 | +
|
| 119 | + .done { |
| 120 | + display: block; |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | +} |
| 126 | +</style> |
| 127 | + |
| 128 | +<style lang="less" scoped> |
| 129 | +.chat-select_type { |
| 130 | + width: 40px; |
| 131 | + height: 24px; |
| 132 | + border-radius: 4px; |
| 133 | + padding-left: 4px; |
| 134 | + display: flex; |
| 135 | + align-items: center; |
| 136 | + cursor: pointer; |
| 137 | +
|
| 138 | + .expand { |
| 139 | + margin-left: 4px; |
| 140 | + } |
| 141 | +
|
| 142 | + &:hover { |
| 143 | + background: #1f23291a; |
| 144 | + } |
| 145 | +
|
| 146 | + &.active { |
| 147 | + background: rgba(28, 186, 144, 0.1); |
| 148 | + color: rgba(28, 186, 144, 1); |
| 149 | + } |
| 150 | +} |
| 151 | +</style> |
0 commit comments