index.vue 4.36 KB
Newer Older
fukai committed
1
<template>
2 3 4 5 6 7
  <section id="business_container">
    <transition name="fade-transform" mode="out-in">
      <keep-alive :include="cachedViews">
        <router-view :key="key" />
      </keep-alive>
    </transition>
8 9 10 11 12 13 14

    <component
      v-for="item in hasOpenComponentsArr"
      :key="item.name"
      :is="item.name"
      v-show="$route.path === item.path"
    ></component>
15
  </section>
fukai committed
16 17 18
</template>

<script>
19 20 21 22 23
import Vue from "vue";

import DzSys from "~/views/Layout/dz/DzSys.vue";
import { getDzSysMenu } from "~/views/Layout/dz/menus.js";

fukai committed
24
export default {
潘际乾 committed
25
  name: "Business",
潘际乾 committed
26 27 28 29 30 31 32
  watch: {
    $route() {
      if (this.$route.path.startsWith("/review")) {
        this.$store.commit("setMode", "display");
      } else {
        this.$store.commit("setMode", "normal");
      }
33 34 35 36 37 38 39 40

      this.componentsArr.forEach(comp => {
        if (!this.visitedViews.find(view => view.path === comp.path)) {
          comp.hasOpen = false
        }
      })
      // 判断当前路由是否iframe页
      this.isOpenIframePage();
潘际乾 committed
41 42
    },
  },
43
  created() {
44
    console.log("进入业务交易界面");
45 46 47 48 49 50 51 52 53 54 55

    // 设置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();
56 57 58 59 60
  },
  computed: {
    cachedViews() {
      return this.$store.state.TagsView.cachedViews;
    },
61 62 63
    visitedViews() {
      return this.$store.state.TagsView.visitedViews;
    },
64 65 66
    key() {
      return this.$route.path;
    },
67 68 69 70 71 72 73 74 75
    // 实现懒加载,只渲染已经打开过(hasOpen:true)的iframe页
    hasOpenComponentsArr() {
      return this.componentsArr.filter(item => item.hasOpen);
    }
  },
  data() {
    return {
      componentsArr: []
    }
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
  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
            })
          }
        }
    }
  }
105
};
fukai committed
106 107 108
</script>

<style>
109
#business_container {
潘际乾 committed
110
  flex: 1;
Wuyuqiu committed
111
  box-shadow: 0 1px 15px 0 rgb(0 0 0 / 12%), 0 0 3px 0 rgb(0 0 0 / 4%);
潘际乾 committed
112 113 114 115
}
#business_container .eContainer, #business_container .eContainer-search{
  box-sizing: border-box;
  height: 100%;
Wuyuqiu committed
116
  width: 85%;
潘际乾 committed
117 118
  margin: 0 auto;
  padding-top: 40px;
潘际乾 committed
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



@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%;
    }
}



潘际乾 committed
160
#business_container .eContainer {
潘际乾 committed
161
  background-color: #ffffff;
Wuyuqiu committed
162
  box-shadow: 0 1px 15px 0 rgb(0 0 0 / 12%), 0 0 3px 0 rgb(0 0 0 / 4%);
163
}
潘际乾 committed
164 165 166 167 168 169 170 171 172 173
#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;
}
jianglong committed
174
/*
潘际乾 committed
175
#business_container .eibs-tab {
潘际乾 committed
176
  padding: 40px;
潘际乾 committed
177
}
jianglong committed
178
*/
潘际乾 committed
179
#business_container .eibs::before, #business_container .eibs-tab::before,
潘际乾 committed
180
#business_container .eibs::after, #business_container .eibs-tab::after {
潘际乾 committed
181 182 183 184
  content: "";
  display: block;
  clear: both;
}
185 186 187 188 189 190

.eibs{
  margin-top: 20px;

}

fukai committed
191
</style>