index.vue
4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
<div class="fullheight appcontent-div__content">
<app-portal
v-if="type === 1"
ref="htPortal"
:key="id"
:column-layout-alias="alias"
></app-portal>
<div v-if="type === 4" class="chart-wrapper">
<ht-chart :id="id" :key="id" :chart-key="id" />
</div>
<!-- 数据报表-->
<template-preview
v-else-if="type === 2"
ref="templatePreview"
:key="id"
:template-key="alias"
/>
<!-- 自定义视图-->
<query-sql-preview
v-else-if="type === 3"
:key="id"
:sql-view-id="id"
:single="true"
/>
<!-- 表单预览-->
<form-preview
v-else-if="type === 6"
:key="alias"
:form-id="id"
:single="true"
:form-key="alias"
/>
<iframe
v-else-if="type === 5 || type === 7 || type === 8 || type === 11"
style="width: 100%"
frameborder="0"
class="fullheight"
allowtransparency="0"
:src="path"
:height="tableHeight"
></iframe>
<DatavDesignPreview
v-else-if="type === 9"
ref="datavDesign"
:key="id"
:layout="null"
:alias="alias"
/>
<mail-box v-else-if="type === 163" />
<message-center v-else-if="type === 164" />
<div v-else style="height: 100%; margin-top: 160px">
<el-empty
:image-size="380"
:image="noDataImg"
description="无菜单权限或菜单可预览"
></el-empty>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { getMainByDefKey } from '@/api/appCenter.js'
const templatePreview = () =>
import('@/components/dataTemplate/TemplatePreview.vue')
const QuerySqlPreview = () =>
import('@/components/querySql/QuerySqlPreview.vue')
const FormPreview = () => import('@/components/form/FormPreview.vue')
const DatavDesignPreview = () =>
import('@/components/datav/DatavDesignPreview.vue')
const MailBox = () => import('@/views/personal/mail/index')
const MessageCenter = () => import('@/views/personal/message/index')
const AppPortal = () => import('@/views/app/portal/AppPortal')
const EMPTY_IMAGE = require('@/assets/nodata_images/no-data.png')
export default {
name: 'Index',
components: {
templatePreview,
QuerySqlPreview,
FormPreview,
DatavDesignPreview,
MailBox,
MessageCenter,
AppPortal,
},
data() {
return {
id: '',
type: '',
path: '',
alias: '',
noDataImg: EMPTY_IMAGE,
}
},
computed: {
tableHeight() {
return this.$baseTableHeight() + 100
},
...mapGetters({
activeMenu: 'app/activeMenu',
tileMenus: 'app/tileMenus',
accessToken: 'user/accessToken',
}),
},
watch: {
activeMenu() {
this.initMain()
},
},
mounted() {
this.initMain()
},
methods: {
async initMain() {
if (this.activeMenu) {
let val = this.activeMenu
this.type = val.type
if (val.type === 5) {
this.path = val.content
return
}
if (val.type === 11) {
if (!val.content) return
if (val.content.includes('?')) {
this.path = `${window.context.front}${val.content}&application=true&__isFull__=true`
} else {
this.path = `${window.context.front}${val.content}?&application=true&__isFull__=true`
}
return
}
if (val.type === 7) {
let content = JSON.parse(val.content)
this.path = `${window.context.front}/sysModulePreview/${content.id}/${val.name}?token=${this.accessToken}`
return
}
if (val.type === 8) {
let content = JSON.parse(val.content)
let resp = {}
let url
if (content.key) {
resp = await getMainByDefKey(content.key)
url = `/matter/startProcess?defId=${resp.id}&name=${content.name}&__isFull__=true`
} else {
url = `/matter/startProcess?defId=${content.id}&name=${content.name}&__isFull__=true`
}
this.path = `${window.context.front}${url}`
}
if (val.type === 6) {
let content = JSON.parse(val.content)
this.alias = content.key
this.id = content.id
return
}
if (val.content) {
let content = JSON.parse(val.content)
this.id = content.id
this.alias = content.alias
}
}
},
},
}
</script>
<style lang="scss" scoped>
.fullheight {
overflow: hidden;
}
.chart-wrapper {
height: 100%;
background: white;
padding: 16px;
}
</style>