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 +
+