From 360e7dcc2d6cd71b513a3a7066577197dbdd08a2 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 28 Jul 2025 17:13:24 +0800 Subject: [PATCH] refactor: dashboard select view type change --- .../dashboard/components/sq-view/index.vue | 141 +++++++++++++++++- .../views/dashboard/editor/ChartSelection.vue | 2 +- 2 files changed, 138 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/dashboard/components/sq-view/index.vue b/frontend/src/views/dashboard/components/sq-view/index.vue index f9c089c9..86708611 100644 --- a/frontend/src/views/dashboard/components/sq-view/index.vue +++ b/frontend/src/views/dashboard/components/sq-view/index.vue @@ -2,7 +2,7 @@ import ChartComponent from '@/views/chat/component/ChartComponent.vue' import icon_window_mini_outlined from '@/assets/svg/icon_window-mini_outlined.svg' import SqViewDisplay from '@/views/dashboard/components/sq-view/index.vue' -defineProps({ +const props = defineProps({ viewInfo: { type: Object, required: true, @@ -14,20 +14,80 @@ defineProps({ }, }) -import { ref } from 'vue' +import { computed, nextTick, ref } from 'vue' import { useI18n } from 'vue-i18n' +import ChartPopover from '@/views/chat/chat-block/ChartPopover.vue' +import ICON_TABLE from '@/assets/svg/chart/icon_form_outlined.svg' +import ICON_COLUMN from '@/assets/svg/chart/icon_dashboard_outlined.svg' +import ICON_BAR from '@/assets/svg/chart/icon_bar_outlined.svg' +import ICON_LINE from '@/assets/svg/chart/icon_chart-line.svg' +import ICON_PIE from '@/assets/svg/chart/icon_pie_outlined.svg' +import type { ChartTypes } from '@/views/chat/component/BaseChart.ts' const { t } = useI18n() const chartRef = ref(null) +const currentChartType = ref(undefined) + const renderChart = () => { //@ts-expect-error eslint-disable-next-line @typescript-eslint/no-unused-expressions // eslint-disable-next-line @typescript-eslint/no-unused-expressions chartRef.value?.renderChart } + const enlargeDialogVisible = ref(false) const enlargeView = () => { enlargeDialogVisible.value = true } + +const chartTypeList = computed(() => { + const _list = [] + if (props.viewInfo.chart) { + switch (props.viewInfo.chart.type) { + case 'table': + break + case 'column': + case 'bar': + case 'line': + _list.push({ + value: 'column', + name: t('chat.chart_type.column'), + icon: ICON_COLUMN, + }) + _list.push({ + value: 'bar', + name: t('chat.chart_type.bar'), + icon: ICON_BAR, + }) + _list.push({ + value: 'line', + name: t('chat.chart_type.line'), + icon: ICON_LINE, + }) + break + case 'pie': + _list.push({ + value: 'pie', + name: t('chat.chart_type.pie'), + icon: ICON_PIE, + }) + } + } + + return _list +}) + +function changeTable() { + onTypeChange('table') +} + +function onTypeChange(val: any) { + // eslint-disable-next-line vue/no-mutating-props + props.viewInfo.chart.type = val + nextTick(() => { + //@ts-expect-error eslint-disable-next-line @typescript-eslint/no-unused-expressions + chartRef.value?.renderChart() + }) +} defineExpose({ renderChart, enlargeView, @@ -40,6 +100,32 @@ defineExpose({
{{ viewInfo.chart.title }}
+
+
+ + + + + + + + + + +
+
+
diff --git a/frontend/src/views/dashboard/editor/ChartSelection.vue b/frontend/src/views/dashboard/editor/ChartSelection.vue index 07e152ad..2704c511 100644 --- a/frontend/src/views/dashboard/editor/ChartSelection.vue +++ b/frontend/src/views/dashboard/editor/ChartSelection.vue @@ -39,7 +39,7 @@ const curSelectChange = (value: boolean) => { overflow: hidden; .select-area { position: absolute; - top: 20px; + top: 26px; right: 20px; } }