This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/views/charts/Panel.vue

74 lines
1.8 KiB
Vue
Raw Normal View History

2021-06-11 23:00:33 +08:00
<template>
<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-11 23:00:33 +08:00
</template>
<script>
import { useRoute } from 'vue-router'
import { ref } from 'vue'
2021-06-11 23:00:33 +08:00
import { panelTypeAndRouteMapping } from '@/utils/constants'
import { api, getPanelList, getChartList } from '@/utils/api'
import Chart from './Chart'
2021-06-11 23:00:33 +08:00
export default {
name: 'Panel',
components: {
Chart
},
2021-06-11 23:00:33 +08:00
data () {
return {
2021-06-11 23:00:33 +08:00
}
},
methods: {
},
2021-06-11 23:00:33 +08:00
async mounted () {
const panels = await getPanelList({ type: this.panelType })
if (panels && panels.length > 0) {
this.panel = panels[0]
}
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 () {
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,
chartList,
panel,
2021-06-11 23:00:33 +08:00
api
}
}
}
</script>
<style lang="scss">
@import '~@/components/charts/panel.scss';
2021-06-11 23:00:33 +08:00
</style>