Skip to content

Commit 85d8146

Browse files
committed
fix: bug fix
1 parent b122a47 commit 85d8146

File tree

2 files changed

+161
-17
lines changed

2 files changed

+161
-17
lines changed

frontend/src/views/chat/chat-block/ChartBlock.vue

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { ChatMessage } from '@/api/chat.ts'
33
import DisplayChartBlock from '@/views/chat/component/DisplayChartBlock.vue'
4+
import ChartPopover from '@/views/chat/chat-block/ChartPopover.vue'
45
import { computed, ref } from 'vue'
56
import { concat } from 'lodash-es'
67
import type { ChartTypes } from '@/views/chat/component/BaseChart.ts'
@@ -157,11 +158,11 @@ const chartTypeList = computed(() => {
157158
})
158159
159160
function changeTable() {
160-
chartType.value = 'table'
161-
onTypeChange()
161+
onTypeChange('table')
162162
}
163163
164-
function onTypeChange() {
164+
function onTypeChange(val: any) {
165+
chartType.value = val
165166
chartRef.value?.onTypeChange()
166167
}
167168
@@ -207,21 +208,13 @@ function addToDashboard() {
207208
<div class="buttons-bar">
208209
<div class="chart-select-container">
209210
<el-tooltip effect="dark" :content="t('chat.type')" placement="top">
210-
<el-select
211+
<ChartPopover
212+
:chartTypeList="chartTypeList"
213+
:chartType="chartType"
214+
:title="t('chat.type')"
215+
@typeChange="onTypeChange"
211216
v-if="chartTypeList.length > 0"
212-
v-model="chartType"
213-
class="chart-select"
214-
:class="{ 'chart-active': currentChartType !== 'table' }"
215-
@change="onTypeChange"
216-
>
217-
<el-option v-for="type in chartTypeList" :key="type.value" :value="type.value">
218-
<el-icon size="16">
219-
<component :is="type.icon" />
220-
</el-icon>
221-
{{ type.name }}
222-
&nbsp;
223-
</el-option>
224-
</el-select>
217+
></ChartPopover>
225218
</el-tooltip>
226219

227220
<el-tooltip effect="dark" :content="t('chat.chart_type.table')" placement="top">
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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

Comments
 (0)