[Core] [Dashboard] Compatible with old version of report display

This commit is contained in:
qianmoQ 2024-05-19 20:04:36 +08:00
parent 0bf24cf7fc
commit c9ec5f6cc5
6 changed files with 60 additions and 26 deletions

View File

@ -1,5 +1,6 @@
import { BaseModel } from '@/model/base'
import { DatasetModel } from '@/model/dataset'
import { SourceModel } from '@/model/source.ts'
export interface ReportModel
extends BaseModel
@ -9,4 +10,5 @@ export interface ReportModel
type?: string
query?: string
dataset?: DatasetModel
source?: SourceModel
}

View File

@ -44,6 +44,8 @@ import VisualFunnel from '@/views/components/visual/components/VisualFunnel.vue'
import VisualGauge from '@/views/components/visual/components/VisualGauge.vue'
import VisualRose from '@/views/components/visual/components/VisualRose.vue'
import Alert from '@/views/ui/alert'
import ExecuteService from '@/services/execute.ts'
import { ExecuteModel } from '@/model/execute.ts'
export default defineComponent({
name: 'VisualView',
@ -83,6 +85,9 @@ export default defineComponent({
height: {
type: String,
default: () => '400px'
},
original: {
type: Number
}
},
data()
@ -102,28 +107,47 @@ export default defineComponent({
this.localConfiguration = cloneDeep(this.configuration) as Configuration
setTimeout(() => {
this.loading = true
DatasetService.adhoc(this.code!, this.query)
.then(response => {
if (response.status) {
if (this.localConfiguration) {
if (response.data.isSuccessful) {
this.localConfiguration.headers = response.data.headers
this.localConfiguration.columns = response.data.columns
this.localConfiguration.message = null
}
else {
this.localConfiguration.headers = []
this.localConfiguration.columns = []
this.localConfiguration.message = response.data.message
}
if (this.type === 'QUERY') {
const configure: ExecuteModel = { name: this.original as any, content: this.query as any, mode: 'REPORT', format: 'JSON' }
ExecuteService.execute(configure, null)
.then(response => {
if (response.data.isSuccessful) {
this.formatRaw(response)
}
}
else {
ToastUtils.error(response.message)
}
})
.finally(() => this.loading = false)
else {
ToastUtils.error(response.data.message)
}
})
.finally(() => this.loading = false)
}
else {
DatasetService.adhoc(this.code!, this.query)
.then(response => {
if (response.status) {
this.formatRaw(response)
}
else {
ToastUtils.error(response.message)
}
})
.finally(() => this.loading = false)
}
})
},
formatRaw(response: any)
{
if (this.localConfiguration) {
if (response.data.isSuccessful) {
this.localConfiguration.headers = response.data.headers
this.localConfiguration.columns = response.data.columns
this.localConfiguration.message = null
}
else {
this.localConfiguration.headers = []
this.localConfiguration.columns = []
this.localConfiguration.message = response.data.message
}
}
}
}
})

View File

@ -13,7 +13,7 @@
</FormControl>
<div class="items-center rounded-md border-4 border-muted p-1 hover:border-accent cursor-pointer text-center">
<VisualView width="200px" height="100px" :code="item.dataset?.code as string" :configuration="JSON.parse(item.configure as string)"
:query="JSON.parse(item.query as string)"/>
:type="item.type" :query="item.type === 'DATASET' ? JSON.parse(item.query as string) : item.query" :original="item?.source?.id"/>
</div>
<span class="block w-full p-2 text-center font-normal">{{ item.name }}</span>
</FormLabel>

View File

@ -24,7 +24,10 @@
<Trash :size="15"/>
</Button>
</template>
<VisualView class="-ml-3" :width="item.width.replace('px', '') - 20 + 'px'" :height="item.height.replace('px', '') - 48 + 'px'"
<VisualView v-if="item.original" class="-ml-3" :width="item.width.replace('px', '') - 20 + 'px'" :height="item.height.replace('px', '') - 48 + 'px'"
:code="item.node.code" :configuration="JSON.parse(item.node.configure)" :type="item.original?.type"
:query="item.original.type === 'DATASET' ? JSON.parse(item.original.query as string) : item.original.query" :original="item?.original?.source?.id"/>
<VisualView v-else class="-ml-3" :width="item.width.replace('px', '') - 20 + 'px'" :height="item.height.replace('px', '') - 48 + 'px'"
:code="item.node.code" :configuration="JSON.parse(item.node.configure)" :query="JSON.parse(item.node.query)"/>
</Card>
</GridItem>
@ -192,7 +195,8 @@ export default defineComponent({
configure: node.configure,
code: node.dataset?.code,
query: node?.query
}
},
original: node
}
this.layouts.push(newItem)
},

View File

@ -10,8 +10,11 @@
<Info class="cursor-pointer"/>
</Tooltip>
</template>
<VisualView :width="item.width.replace('px', '') - 3 + 'px'" :height="item.height.replace('px', '') - 55 + 'px'" :code="item.node.code"
:configuration="JSON.parse(item.node.configure)" :query="JSON.parse(item.node.query)"/>
<VisualView v-if="item.original" :width="item.width.replace('px', '') - 20 + 'px'" :height="item.height.replace('px', '') - 55 + 'px'"
:code="item.node.code" :configuration="JSON.parse(item.node.configure)" :type="item.original?.type"
:query="item.original.type === 'DATASET' ? JSON.parse(item.original.query as string) : item.original.query" :original="item?.original?.source?.id"/>
<VisualView v-else class="-ml-3" :width="item.width.replace('px', '') - 20 + 'px'" :height="item.height.replace('px', '') - 48 + 'px'"
:code="item.node.code" :configuration="JSON.parse(item.node.configure)" :query="JSON.parse(item.node.query)"/>
</Card>
</GridItem>
</GridLayout>

View File

@ -3,7 +3,8 @@
<template #title>{{ title }}</template>
<CircularLoading v-if="loading" :show="loading"/>
<div v-else-if="info">
<VisualView :code="info.dataset?.code" :type="info.type" :configuration="JSON.parse(info.configure as string)" :query="JSON.parse(info.query as string)"/>
<VisualView :code="info.dataset?.code" :type="info.type" :configuration="JSON.parse(info.configure as string)"
:query="info.type === 'DATASET' ? JSON.parse(info.query as string) : info.query" :original="info?.source?.id"/>
</div>
<template #footer>
<Button variant="outline" size="sm" @click="handlerCancel">