dataease/frontend/src/views/panel/index.vue

98 lines
2.6 KiB
Vue
Raw Normal View History

2021-03-08 14:31:09 +08:00
<template>
2021-05-05 23:48:05 +08:00
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]" style="background-color: #f7f8fa">
<de-main-container :class="{'full-height':fullHeightFlag}">
2021-07-02 19:19:38 +08:00
<panel-main v-show="componentName==='PanelMain'" ref="panel_main" />
<panel-edit v-if="componentName==='PanelEdit'" />
</de-main-container>
</de-container>
2021-03-08 14:31:09 +08:00
</template>
<script>
2021-04-01 17:40:12 +08:00
import bus from '@/utils/bus'
import DeMainContainer from '@/components/dataease/DeMainContainer'
import DeContainer from '@/components/dataease/DeContainer'
2021-04-01 17:40:12 +08:00
import PanelMain from '@/views/panel/list/PanelMain'
import PanelEdit from '@/views/panel/edit'
2021-03-08 14:31:09 +08:00
2021-03-08 21:10:16 +08:00
export default {
name: 'Panel',
2022-04-20 10:52:00 +08:00
components: { DeMainContainer, DeContainer, PanelMain, PanelEdit },
2021-03-08 21:10:16 +08:00
data() {
return {
2021-04-01 17:40:12 +08:00
component: PanelMain,
componentName: 'PanelMain',
param: {},
contentHasSave: false
2021-03-08 21:10:16 +08:00
}
},
computed: {
fullHeightFlag() {
return this.$route.path.indexOf('panel') > -1 && (this.componentName === 'PanelEdit' || this.componentName === 'ChartEdit')
}
},
beforeRouteLeave(to, from, next) {
if (this.componentName === 'PanelEdit') {
next(false)
if (confirm(this.$t('panel.edit_leave_tips'))) {
next()
}
} else {
next()
2021-07-06 15:24:34 +08:00
}
},
watch: {
// $route(to, from) {
// }
},
2021-04-01 17:40:12 +08:00
mounted() {
2021-07-06 15:24:34 +08:00
bus.$on('to-msg-share', params => {
this.toMsgShare(params)
})
2021-04-01 17:40:12 +08:00
bus.$on('PanelSwitchComponent', (c) => {
this.param = c.param
this.componentName = c.name
this.$store.dispatch('panel/setMainActiveName', c.name)
2021-04-01 17:40:12 +08:00
})
},
2021-07-02 19:19:38 +08:00
created() {
bus.$emit('PanelSwitchComponent', { name: 'PanelMain' })
2021-07-02 19:19:38 +08:00
this.$store.dispatch('app/toggleSideBarHide', true)
2021-07-06 15:24:34 +08:00
const routerParam = this.$router.currentRoute.params
this.toMsgShare(routerParam)
},
methods: {
toMsgShare(routerParam) {
if (routerParam !== null && routerParam.msgNotification) {
2021-07-12 11:30:57 +08:00
const panelShareTypeIds = [1, 2, 3]
// 说明是从消息通知跳转过来的
if (panelShareTypeIds.includes(routerParam.msgType)) { // 是仪表板分享
2021-07-06 15:24:34 +08:00
this.componentName = 'PanelMain'
this.$nextTick(() => {
2021-07-12 11:30:57 +08:00
this.$refs.panel_main && this.$refs.panel_main.msg2Current && this.$refs.panel_main.msg2Current(routerParam.sourceParam)
2021-07-06 15:24:34 +08:00
})
}
2021-07-02 19:19:38 +08:00
}
}
2021-04-01 17:40:12 +08:00
2021-03-08 14:31:09 +08:00
}
2021-03-08 21:10:16 +08:00
}
2021-03-08 14:31:09 +08:00
</script>
<style scoped>
.ms-aside-container {
height: calc(100vh - 56px);
2021-04-08 16:54:37 +08:00
padding: 0px;
2021-03-08 14:31:09 +08:00
min-width: 260px;
max-width: 460px;
}
.ms-main-container {
height: calc(100vh - 56px);
2021-04-01 17:40:12 +08:00
padding: 0;
2021-03-08 14:31:09 +08:00
}
.full-height {
height: 100vh !important;
}
2021-03-08 14:31:09 +08:00
</style>