2021-06-11 23:00:33 +08:00
|
|
|
<template>
|
2021-06-21 11:29:26 +08:00
|
|
|
<div>
|
|
|
|
|
<DateTimeRange />
|
|
|
|
|
<div class="cn-panel">
|
|
|
|
|
<chart v-for="(chart, index) in chartList" :key="index" :chart="chart"></chart>
|
|
|
|
|
<!-- <grid-layout v-model:layout="chartList"
|
|
|
|
|
:col-num="12"
|
|
|
|
|
:row-height="30"
|
|
|
|
|
:is-draggable="draggable"
|
|
|
|
|
:is-resizable="resizable"
|
|
|
|
|
:vertical-compact="compact"
|
|
|
|
|
:use-css-transforms="true"
|
|
|
|
|
>
|
|
|
|
|
<grid-item v-for="item in chartList" :key="item.i"
|
|
|
|
|
:x="item.x"
|
|
|
|
|
:y="item.y"
|
|
|
|
|
:w="item.w"
|
|
|
|
|
:h="item.h"
|
|
|
|
|
:i="item.i"
|
|
|
|
|
>
|
|
|
|
|
<span class="text">{{ item.i }}</span>
|
|
|
|
|
</grid-item>
|
|
|
|
|
</grid-layout>-->
|
|
|
|
|
</div>
|
2021-06-20 13:31:55 +08:00
|
|
|
</div>
|
2021-06-11 23:00:33 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { useRoute } from 'vue-router'
|
2021-06-20 13:31:55 +08:00
|
|
|
import { ref } from 'vue'
|
2021-06-11 23:00:33 +08:00
|
|
|
import { panelTypeAndRouteMapping } from '@/utils/constants'
|
2021-06-20 13:31:55 +08:00
|
|
|
import { api, getPanelList, getChartList } from '@/utils/api'
|
|
|
|
|
import Chart from './Chart'
|
2021-06-21 11:29:26 +08:00
|
|
|
import DateTimeRange from '@/components/common/TimeRange/DateTimeRange'
|
2021-06-11 23:00:33 +08:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Panel',
|
2021-06-20 13:31:55 +08:00
|
|
|
components: {
|
2021-06-21 11:29:26 +08:00
|
|
|
Chart,
|
|
|
|
|
DateTimeRange
|
2021-06-20 13:31:55 +08:00
|
|
|
},
|
2021-06-11 23:00:33 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
2021-06-20 13:31:55 +08:00
|
|
|
|
2021-06-11 23:00:33 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-06-20 13:31:55 +08:00
|
|
|
methods: {
|
|
|
|
|
},
|
2021-06-11 23:00:33 +08:00
|
|
|
async mounted () {
|
2021-06-15 15:24:36 +08:00
|
|
|
const panels = await getPanelList({ type: this.panelType })
|
|
|
|
|
if (panels && panels.length > 0) {
|
|
|
|
|
this.panel = panels[0]
|
|
|
|
|
}
|
2021-06-20 13:31:55 +08:00
|
|
|
if (this.panel.id) {
|
|
|
|
|
this.chartList = (await getChartList({ panelId: this.panel.id })).map(chart => {
|
|
|
|
|
chart.i = chart.id
|
|
|
|
|
return chart
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-06-11 23:00:33 +08:00
|
|
|
},
|
|
|
|
|
setup () {
|
2021-06-20 13:31:55 +08:00
|
|
|
const chartList = ref([])
|
|
|
|
|
const panel = ref({})
|
|
|
|
|
let panelType = 1 // 取得panel的type
|
2021-06-11 23:00:33 +08:00
|
|
|
const { params } = useRoute()
|
|
|
|
|
panelTypeAndRouteMapping[params.typeName] && (panelType = panelTypeAndRouteMapping[params.typeName])
|
|
|
|
|
return {
|
|
|
|
|
panelType,
|
2021-06-20 13:31:55 +08:00
|
|
|
chartList,
|
|
|
|
|
panel,
|
2021-06-11 23:00:33 +08:00
|
|
|
api
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2021-06-20 13:31:55 +08:00
|
|
|
<style lang="scss">
|
|
|
|
|
@import '~@/components/charts/panel.scss';
|
2021-06-11 23:00:33 +08:00
|
|
|
</style>
|