mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 20:17:45 +08:00
[Core] [Dashboard] Optimize the way to obtain the dashboard
This commit is contained in:
parent
c73fffe9d1
commit
3864ad7f21
@ -12,5 +12,6 @@ export default {
|
||||
deleteTip2: 'Warning: This cannot be undone. ',
|
||||
deleteTip3: 'To confirm, type [ $NAME ] in the box below',
|
||||
publishSuccess: 'Dashboard [ $VALUE ] published successfully',
|
||||
notFound: 'Dashboard [ $VALUE ] not found',
|
||||
}
|
||||
}
|
@ -12,5 +12,6 @@ export default {
|
||||
deleteTip2: '警告:此操作无法撤消。 ',
|
||||
deleteTip3: '要确认,请在下面的框中键入 [ $NAME ]',
|
||||
publishSuccess: '仪表板 [ $VALUE ] 发布成功',
|
||||
notFound: '仪表板 [ $VALUE ] 不存在',
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ export interface DashboardModel
|
||||
updateTime?: string
|
||||
user?: UserModel
|
||||
reports?: ReportModel[]
|
||||
code?: string
|
||||
}
|
||||
|
||||
export class DashboardRequest
|
||||
|
@ -129,7 +129,7 @@ const createAdminRouter = (router: any) => {
|
||||
component: () => import('@/views/pages/admin/dashboard/DashboardHome.vue')
|
||||
},
|
||||
{
|
||||
path: 'dashboard/info/:id/preview',
|
||||
path: 'dashboard/preview/:code',
|
||||
meta: {
|
||||
title: 'common.dashboard',
|
||||
isRoot: false
|
||||
@ -137,7 +137,7 @@ const createAdminRouter = (router: any) => {
|
||||
component: () => import('@/views/pages/admin/dashboard/DashboardPreview.vue')
|
||||
},
|
||||
{
|
||||
path: 'dashboard/info/:id?',
|
||||
path: 'dashboard/info/:code?',
|
||||
meta: {
|
||||
title: 'common.dashboard',
|
||||
isRoot: false
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div class="grid gap-4 md:grid-cols-2 lg:grid-cols-6">
|
||||
<Card title-class="p-2 pl-4 pr-4" v-for="item in data">
|
||||
<template #title>
|
||||
<RouterLink :to="`/admin/dashboard/info/${item.id}/preview`" target="_blank">{{ item.name }}</RouterLink>
|
||||
<RouterLink :to="`/admin/dashboard/preview/${item.code}`" target="_blank">{{ item.name }}</RouterLink>
|
||||
</template>
|
||||
<template #extra>
|
||||
<DropdownMenu class="justify-items-end">
|
||||
@ -22,7 +22,7 @@
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<DropdownMenuItem class="cursor-pointer">
|
||||
<RouterLink :to="`/admin/dashboard/info/${item.id}`" target="_blank" class="flex items-center">
|
||||
<RouterLink :to="`/admin/dashboard/info/${item.code}`" target="_blank" class="flex items-center">
|
||||
<Pencil :size="15" class="mr-1"/>
|
||||
{{ $t('dashboard.common.modify') }}
|
||||
</RouterLink>
|
||||
|
@ -15,7 +15,6 @@ import { ToastUtils } from '@/utils/toast'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { DashboardModel } from '@/model/dashboard'
|
||||
import DashboardEditor from '@/views/pages/admin/dashboard/components/DashboardEditor.vue'
|
||||
import { toNumber } from 'lodash'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DashboardInfo',
|
||||
@ -37,10 +36,10 @@ export default defineComponent({
|
||||
{
|
||||
const router = useRouter()
|
||||
const params = router.currentRoute.value.params
|
||||
const id = params['id']
|
||||
if (id) {
|
||||
const code = params['code'] as string
|
||||
if (code) {
|
||||
this.loading = true
|
||||
DashboardService.getById(toNumber(id))
|
||||
DashboardService.getByCode(code)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
this.dataInfo = response.data
|
||||
|
@ -2,6 +2,7 @@
|
||||
<div class="w-full">
|
||||
<Loader2 v-if="loading" class="w-full justify-center animate-spin mt-10"/>
|
||||
<DashboardView v-else-if="data" :layouts="JSON.parse(data.configure as string)"/>
|
||||
<Alert v-else type="error" :title="$t('dashboard.tip.notFound').replace('$VALUE', $router.currentRoute?.value?.params['code'])"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -12,10 +13,12 @@ import DashboardService from '@/services/dashboard'
|
||||
import { useRouter } from 'vue-router'
|
||||
import DashboardView from '@/views/pages/admin/dashboard/components/DashboardView.vue'
|
||||
import { DashboardModel } from '@/model/dashboard'
|
||||
import Alert from '@/views/ui/alert'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DashboardPreview',
|
||||
components: {
|
||||
Alert,
|
||||
DashboardView,
|
||||
Loader2
|
||||
},
|
||||
@ -36,7 +39,7 @@ export default defineComponent({
|
||||
this.loading = true
|
||||
const router = useRouter()
|
||||
const params = router.currentRoute.value.params
|
||||
DashboardService.getById(params['id'] as unknown as number)
|
||||
DashboardService.getByCode(params['code'] as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
this.data = response.data
|
||||
|
Loading…
Reference in New Issue
Block a user