From 2512276152c1d070f00d9fc140d3f19f8eedc6b2 Mon Sep 17 00:00:00 2001 From: ulleo Date: Wed, 11 Jun 2025 17:13:00 +0800 Subject: [PATCH 1/6] feat: chart type select --- frontend/src/assets/svg/chart/bar.svg | 7 + frontend/src/assets/svg/chart/column.svg | 7 + frontend/src/assets/svg/chart/line.svg | 5 + frontend/src/assets/svg/chart/pie.svg | 4 + frontend/src/assets/svg/chart/table.svg | 12 ++ frontend/src/views/chat/ChatAnswer.vue | 198 +++++++++++++++--- .../{Component.vue => ChartComponent.vue} | 0 7 files changed, 209 insertions(+), 24 deletions(-) create mode 100644 frontend/src/assets/svg/chart/bar.svg create mode 100644 frontend/src/assets/svg/chart/column.svg create mode 100644 frontend/src/assets/svg/chart/line.svg create mode 100644 frontend/src/assets/svg/chart/pie.svg create mode 100644 frontend/src/assets/svg/chart/table.svg rename frontend/src/views/chat/component/{Component.vue => ChartComponent.vue} (100%) diff --git a/frontend/src/assets/svg/chart/bar.svg b/frontend/src/assets/svg/chart/bar.svg new file mode 100644 index 00000000..ade22f57 --- /dev/null +++ b/frontend/src/assets/svg/chart/bar.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/frontend/src/assets/svg/chart/column.svg b/frontend/src/assets/svg/chart/column.svg new file mode 100644 index 00000000..2eb3504a --- /dev/null +++ b/frontend/src/assets/svg/chart/column.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/frontend/src/assets/svg/chart/line.svg b/frontend/src/assets/svg/chart/line.svg new file mode 100644 index 00000000..b8ecfcc7 --- /dev/null +++ b/frontend/src/assets/svg/chart/line.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/src/assets/svg/chart/pie.svg b/frontend/src/assets/svg/chart/pie.svg new file mode 100644 index 00000000..096513bf --- /dev/null +++ b/frontend/src/assets/svg/chart/pie.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/src/assets/svg/chart/table.svg b/frontend/src/assets/svg/chart/table.svg new file mode 100644 index 00000000..4fbddcc2 --- /dev/null +++ b/frontend/src/assets/svg/chart/table.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/frontend/src/views/chat/ChatAnswer.vue b/frontend/src/views/chat/ChatAnswer.vue index 2f6c9d33..3184d7ae 100644 --- a/frontend/src/views/chat/ChatAnswer.vue +++ b/frontend/src/views/chat/ChatAnswer.vue @@ -2,10 +2,16 @@ import type {ChatMessage} from "@/api/chat.ts"; import {computed, nextTick, ref} from "vue"; -import type {TabsPaneContext} from 'element-plus-secondary' import {Loading} from "@element-plus/icons-vue"; -import Component from "./component/Component.vue" +import ChartComponent from "./component/ChartComponent.vue" import type {ChartTypes} from "@/views/chat/component/BaseChart.ts"; +import {ArrowDown} from "@element-plus/icons-vue"; +import ICON_BAR from "@/assets/svg/chart/bar.svg" +import ICON_COLUMN from "@/assets/svg/chart/column.svg" +import ICON_LINE from "@/assets/svg/chart/line.svg" +import ICON_PIE from "@/assets/svg/chart/pie.svg" +import ICON_TABLE from "@/assets/svg/chart/table.svg" +import {find} from "lodash-es"; const props = defineProps<{ message?: ChatMessage @@ -29,10 +35,6 @@ const renderChartThinking = computed(() => { return props.message?.record?.chart_answer }) -const handleClick = (tab: TabsPaneContext, event: Event) => { - console.log(tab, event) -} - const dataObject = computed<{ fields: Array, data: Array<{ [key: string]: any }>, @@ -92,10 +94,59 @@ const chartType = computed({ } }) +function clickTab(type: "chart" | "sql") { + settings.value.type = type +} + +const chartSelectRef = ref() + +function openChartSelect() { + chartSelectRef.value.toggleMenu() +} + +const chartTypeList = computed(() => { + const _list = [{ + value: "table", + icon: ICON_TABLE + }] + if (chartObject.value) { + switch (chartObject.value.type) { + case "table": + break + case "column": + case "bar": + case "line": + _list.push({ + value: "column", + icon: ICON_COLUMN + }) + _list.push({ + value: "bar", + icon: ICON_BAR + }) + _list.push({ + value: "line", + icon: ICON_LINE + }) + break + case "pie": + _list.push({ + value: "pie", + icon: ICON_PIE + }) + } + } + + return _list; +}) + +const currentChartTypeIcon = computed(() => { + return find(chartTypeList.value, c => c.value === chartType.value)?.icon ?? ICON_TABLE +}) + const chartRef = ref() -function onTypeChange(type: string) { - console.log(type) +function onTypeChange() { nextTick(() => { chartRef.value?.destroyChart() chartRef.value?.renderChart() @@ -112,21 +163,36 @@ function onTypeChange(type: string) {
Thinking ...
{{ chartObject.title }}
- - - - - - +
+
+
+ + + + + + +
+ + +
+ + + + {{ t.value }} +
+
+
+ +
+
+ SQL +
+
+ + + + +
+ +
+
+ +
+ @@ -126,6 +167,7 @@ onMounted(() => { .ds-card-selected { box-shadow: 0 1px 3px var(--ed-color-primary-light-5); + border: 1px solid var(--ed-color-primary-light-5); } From 2fdda922b8c3741bb68d863dd2d1c4d1934959af Mon Sep 17 00:00:00 2001 From: ulleo Date: Wed, 11 Jun 2025 18:07:42 +0800 Subject: [PATCH 4/6] feat: chat select datasource --- frontend/src/views/chat/WelcomeBlock.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/chat/WelcomeBlock.vue b/frontend/src/views/chat/WelcomeBlock.vue index 6be01603..d9afc507 100644 --- a/frontend/src/views/chat/WelcomeBlock.vue +++ b/frontend/src/views/chat/WelcomeBlock.vue @@ -8,10 +8,10 @@ import {useI18n} from 'vue-i18n' const {t} = useI18n() const props = withDefaults(defineProps<{ - modelValue?: number - currentChat: ChatInfo - }>(), - {} + modelValue?: number + currentChat: ChatInfo + }>(), + {} ) const dsList = ref>([]) @@ -67,7 +67,7 @@ function selectDsInDialog(ds: any) { innerDs.value = ds.id } -function comfirmSelectDs() { +function confirmSelectDs() { if (innerDs.value) { emits("update:modelValue", innerDs.value) dialogVisible.value = false @@ -114,7 +114,7 @@ onMounted(() => { -
@@ -127,7 +127,7 @@ onMounted(() => { - \ No newline at end of file + From d2db2fc3d4b20bc275f3c3cfa0d4befbe326667b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 11 Jun 2025 18:18:07 +0800 Subject: [PATCH 6/6] fix: Format Ts Error --- .../views/dashboard/preview/SQPreviewShow.vue | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/frontend/src/views/dashboard/preview/SQPreviewShow.vue b/frontend/src/views/dashboard/preview/SQPreviewShow.vue index 31e6f83e..94b99b89 100644 --- a/frontend/src/views/dashboard/preview/SQPreviewShow.vue +++ b/frontend/src/views/dashboard/preview/SQPreviewShow.vue @@ -1,13 +1,13 @@