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
180
181
182
183
184
185
186
187
188
189
190
191
<template>
<section id="business_container">
<transition name="fade-transform" mode="out-in">
<keep-alive :include="cachedViews">
<router-view :key="key" />
</keep-alive>
</transition>
<component
v-for="item in hasOpenComponentsArr"
:key="item.name"
:is="item.name"
v-show="$route.path === item.path"
></component>
</section>
</template>
<script>
import Vue from "vue";
import DzSys from "~/views/Layout/dz/DzSys.vue";
import { getDzSysMenu } from "~/views/Layout/dz/menus.js";
export default {
name: "Business",
watch: {
$route() {
if (this.$route.path.startsWith("/review")) {
this.$store.commit("setMode", "display");
} else {
this.$store.commit("setMode", "normal");
}
this.componentsArr.forEach(comp => {
if (!this.visitedViews.find(view => view.path === comp.path)) {
comp.hasOpen = false
}
})
// 判断当前路由是否iframe页
this.isOpenIframePage();
},
},
created() {
console.log("进入业务交易界面");
// 设置iframe页的数组对象
const componentsArr = []
const dzSysMenu = getDzSysMenu()
this.getComponentsArr(componentsArr, dzSysMenu ? dzSysMenu.children : []);
componentsArr.forEach((item) => {
Vue.component(item.name, DzSys);
});
this.componentsArr = componentsArr;
// 判断当前路由是否iframe页
this.isOpenIframePage();
},
computed: {
cachedViews() {
return this.$store.state.TagsView.cachedViews;
},
visitedViews() {
return this.$store.state.TagsView.visitedViews;
},
key() {
return this.$route.path;
},
// 实现懒加载,只渲染已经打开过(hasOpen:true)的iframe页
hasOpenComponentsArr() {
return this.componentsArr.filter(item => item.hasOpen);
}
},
data() {
return {
componentsArr: []
}
},
methods: {
// 根据当前路由设置hasOpen
isOpenIframePage() {
const target = this.componentsArr.find(item => {
return item.path === this.$route.path
});
if (target && !target.hasOpen) {
target.hasOpen = true;
}
},
// 遍历路由的所有页面,把含有iframeComponent标识的收集起来
getComponentsArr(arr, menus) {
for (let i = 0; i < menus.length; i++) {
const menu = menus[i];
if (menu.children.length) {
const tempArr = []
this.getComponentsArr(tempArr, menu.children)
arr.push(...tempArr)
} else {
arr.push({
name: menu.value,
path: menu.path,
hasOpen: false, // 是否打开过,默认false
})
}
}
}
}
};
</script>
<style>
#business_container {
flex: 1;
box-shadow: 0 1px 15px 0 rgb(0 0 0 / 12%), 0 0 3px 0 rgb(0 0 0 / 4%);
}
#business_container .eContainer, #business_container .eContainer-search{
box-sizing: border-box;
height: 100%;
width: 85%;
margin: 0 auto;
padding-top: 40px;
}
@media screen and (min-width: 2561px) {
#business_container .eContainer {
width: 85%;
}
}
@media screen and (min-width: 1921px) and (max-width: 2560px) {
#business_container .eContainer {
width: 90%;
}
}
@media screen and (min-width: 1441px) and (max-width: 1920px) {
#business_container .eContainer {
width: 93%;
}
}
@media screen and (min-width: 1200px) and (max-width: 1440px) {
#business_container .eContainer {
width: 95%;
}
}
@media screen and (max-width: 1199px) {
#business_container .eContainer {
width: 100%;
}
}
#business_container .eContainer {
background-color: #ffffff;
box-shadow: 0 1px 15px 0 rgb(0 0 0 / 12%), 0 0 3px 0 rgb(0 0 0 / 4%);
}
#business_container .eContainer .eContainer,
#business_container .eContainer .eContainer-search,
#business_container .eContainer-search .eContainer,
#business_container .eContainer-search .eContainer-search{
width: 100%;
margin: 0;
padding-top: 0;
background-color: unset;
box-shadow: unset;
}
/*
#business_container .eibs-tab {
padding: 40px;
}
*/
#business_container .eibs::before, #business_container .eibs-tab::before,
#business_container .eibs::after, #business_container .eibs-tab::after {
content: "";
display: block;
clear: both;
}
.eibs{
margin-top: 20px;
}
</style>