refactor: support sq add view to dashboard

This commit is contained in:
wangjiahao
2025-07-29 15:12:11 +08:00
parent 17fcfd4503
commit 66cbfd22ba
3 changed files with 18 additions and 2 deletions
@@ -189,8 +189,9 @@ function showSql() {
}
function addToDashboard() {
const viewInfo = chartRef.value?.getViewInfo()
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
addViewRef.value?.optInit()
addViewRef.value?.optInit(viewInfo)
}
function copy() {
@@ -54,9 +54,22 @@ function onTypeChange() {
chartRef.value?.renderChart()
})
}
function getViewInfo() {
return {
chart: {
columns: chartObject.value?.columns,
type: props.chartType,
xAxis: xAxis.value,
yAxis: yAxis.value,
series: series.value,
title: chartObject.value.title,
},
data: { data: props.data },
}
}
defineExpose({
onTypeChange,
getViewInfo,
})
</script>
@@ -86,6 +86,8 @@ const saveResourcePrepare = () => {
component['id'] = newComponentId
component['y'] = bottomPosition + 1
canvasDataResult.push(component)
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
state.viewInfo.chart['id'] = newComponentId
canvasViewInfoPreview[newComponentId] = state.viewInfo
const commonParams = {
componentData: canvasDataResult,