<style>
@import "../assets/css/Details.css";
</style>
<template>
	<div class="flexDiv">
			<div class="secondMenu">
				<div class="secondMenu_l">
          <div class="menuItem" >
            <el-menu
            default-active=""
            background-color="#38425D"
            text-color="#8899AA"
            active-text-color="#FFFFFF"
            class="el-menu-vertical-demo"  :collapse="isCollapse">
              <el-submenu v-for="(item,index) in items" :index="String(index+1)" :key='index'>
                <template slot="title" class="left-nav">
                  <i :class="[fontPub,item.MenuStyleIcon]" class="big-icon"></i>
                  <!-- <span>{{item.MenuName}}</span> -->
                </template>
                <el-menu-item-group class="my_maxheight">
                  <span slot="title">{{item.MenuName}}</span>
                  <el-menu-item  v-for="(subItem,sindex) in item.childerns" :index="String(index+1)+'-'+String(sindex+1)"  @click="goUrl(subItem.MenuUrl)" :key='sindex'>
                    <i :class="[fontPub,subItem.MenuStyleIcon]" ></i>
                    {{subItem.MenuName}}</el-menu-item>
                </el-menu-item-group>
              </el-submenu>
            </el-menu>
            <!-- <ul>
              <li v-for="(item,index) in items" class="menuItem_level1">
                <p @click="showToggle(item.MenuId)" class="parentBox">
                  <i :class="[fontPub,item.MenuStyleIcon]"></i>
                  {{item.MenuName}}
                  <i class="iconfont icon-arrow-right small"></i>
                </p>
                <ul class="liDiv" >
                  <li v-for="subItem in item.childerns" class="childBox" @click="goUrl(subItem.MenuUrl)"><i :class="[fontPub,subItem.MenuStyleIcon]" :style="{background:subItem.MenuStyleColor}"></i><br/>{{subItem.MenuName}}</li>
                </ul>
              </li>
            </ul>   -->
          </div>
        </div>
			</div>
			<div class="flexParent" v-if="openMode==1">
				<!-- <div class="resource-ttop" style="font-family:PingFangSC-Semibold" v-if="rootName!=''">
					{{rootName}}<i class="iconfont icon-weibiaoti102"></i>{{parentName}}<i class="iconfont icon-weibiaoti102"></i><span class="active">{{currentName}}</span>
        </div>  -->
        
        <div class="nav-tabs-box" @contextmenu.prevent="showRightMenu">
          <el-tabs v-if='tabs && tabs.length>0' v-model="currentTabName" :closable="tabs.length>1" type="card" @edit="handleTabsEdit">
            <el-tab-pane :key="i" v-for="(item,i) in tabs" :label="item.title" :name="item.name+'_'+i">
            </el-tab-pane>
          </el-tabs>
          <div class="browner-opera-box" v-if="currentTag.history&&currentTag.history.length>0">
            <i class="iconfont icon-houtui" @click="goback(0)" :class="{'active':this.currentTag && this.currentTag.hisIndex>0}" title="后退"></i>
            <i class="iconfont icon-qianjin" @click="goback(1)" :class="{'active':this.currentTag && this.currentTag.hisIndex<this.currentTag.history.length-1}" title="前进"></i>
            <i class="iconfont icon-shuaxin1 active" @click="reloadpage" title="刷新"></i>
          </div>
        </div>
        <analogIFrame :key="i" :type='item.type' v-model="item.history" :curIndex='i' :refer='item.refer' v-show="tabs.indexOf(currentTag)==i" :componentTemp='item.comp' v-for="(item,i) in tabs" v-if='item.comp' :path='item.path' :name='item.name'></analogIFrame>
			</div>
      <div class="flexParent" v-if="openMode==0">
        <a :href='blankUrl' id='blankLink' target="_blank" style="display:none">1</a>
				<div class="resource-ttop" style="font-family:PingFangSC-Semibold" v-if="rootName!=''">
					{{rootName}}<i class="iconfont icon-weibiaoti102"></i>{{parentName}}<i class="iconfont icon-weibiaoti102"></i><span class="active">{{currentName}}</span>
        </div> 
        <div class="frame-box">
          <router-view></router-view>
        </div>
      </div>
      <ul class="right-menu" @contextmenu.prevent="nullMethod" v-if='currentRightIndex>-1' :style="{top:mouserY+'px',left:mouseX+'px'}">
        <li @click="referPage">重新加载当前页</li>
        <li class="split"></li>
        <li @click="closeCurrent" :class="{'disable':tabs.length==1}">关闭标签</li>
        <li @click="closeOther" :class="{'disable':tabs.length<2}">关闭其它标签</li>
        <li @click="closeRight" :class="{'disable':currentRightIndex==tabs.length-1}">关闭右侧标签</li>
      </ul>
		</div>
</template>
<script type="text/javascript">
import routerConfig from '../router/config';
import analogIFrame from './analogIFrame';
import MsgBus from '../assets/utils/msgBus.js';
export default {
  data() {
    return {
      msg: {
        ParentId: "",
        MenuStatus: "0",
        MenuName: ""
      },
      fontPub: "iconfont",
      num: -1,
      items: [],
      openId: 0,
      rootName: "",
      parentName: "",
      currentName: "",
      isCollapse: true,
      tabs:[],
      currentTabName:'',
      currentTag:{},
      type:'d',
      currentRightIndex:-1,
      mouseX:0,
      mouserY:0,
      ctrlDown:false,
      openMode:0,
      blankUrl:'',
      
    };
  },
  components:{
    analogIFrame
  },
  watch: {
    $route: "getMenu",
    currentTabName:function(val,oldval){
      this.tabs.forEach((x,i)=>{
        if((x.name+"_"+i)==val){
          this.currentTag=x
          if(!x.comp){
            x.comp=this.mapObj(x.path,x.name).comp
          }
          this.$router.push({path: x.path})
        }
      })
    },
    tabs: {
      handler(newValue, oldValue) {
        window.localStorage.navTabs=JSON.stringify(newValue)
      },
      deep: true
　　}
  },
  mounted() {
    this.openMode=0
    if(localStorage.openMode && localStorage.openMode==1)
      this.openMode=1
    this.MsgBus.$on('msg', ()=> {
       this.handleTabsEdit(this.currentTabName,'remove')
    });
    this.MsgBus.$on('refresh', ()=> {
      this.reloadpage()
    });
    // this.MsgBus.$on('forEachLoc', ()=> {
    //   let obj = {}
    //   let LocNavTab = JSON.parse(window.localStorage.navTabs);
    //   let navTab = JSON.parse(window.localStorage.navTabs);
    //   let navTabSortR = [];
    //   for (let i = navTab.length-1; i>=0; i--) {
    //     navTabSortR.push(navTab[i]);
    //   }
    //   navTabSortR = navTabSortR.reduce(function(item, next) {  //根据MD5Sign数组对象去重
    //     obj[next.name] ? '' : obj[next.name] = true && item.push(next);
    //     return item;
    //   }, []);
    //   let navTabSortA = [];
    //   for (let i = navTabSortR.length-1; i>=0; i--) {
    //     navTabSortA.push(navTabSortR[i]);
    //   }
    //   if (LocNavTab.length !== navTabSortA.length) {
    //     this.tabs = navTabSortA;
    //     this.currentTabName = this.tabs[this.tabs.length-1].name + '_' + (this.tabs.length-1);
    //     this.currentTag = this.tabs[this.tabs.length-1];
    //   }
    // });
    if(this.openMode==1){
      if(localStorage['navTabs']){
        this.tabs=JSON.parse(localStorage['navTabs'])
        // this.tabs.forEach(x=>{
        //   x.comp=this.mapObj(x.path,x.name).comp
        // })
      }
    }
    this.getMenu()
    this.filterRouter()
    let hrefs=window.location.href.split('/')
    if(this.openMode==1){
      let hrefs=window.location.href.split('/')
      this.goUrl('/'+hrefs[hrefs.length-1])
      this.propF5()
    }else{
      this.goUrl('/'+hrefs[hrefs.length-1])
    }
    
  },
  methods: {
    nullMethod(){

    },
    referPage(){
      this.currentTabName=this.tabs[this.currentRightIndex].name+'_'+this.currentRightIndex
      this.tabs[this.currentRightIndex].refer+=1
    },
    closeOther(){
      if(this.tabs.length>1){
        let temp=this.tabs.filter((x,i)=>{
          return i==this.currentRightIndex
        })
        if(temp.length==1){
          this.tabs=[]
          this.tabs.push(temp[0])
          this.currentTabName=temp[0].name+'_0'
        }
      }
    },
    closeRight(){
      if(this.currentRightIndex<this.tabs.length-1){
        let temp=this.tabs.filter((x,i)=>{
          return i<=this.currentRightIndex
        })
        if(temp.length>0){
          this.tabs=[]
          this.tabs=temp
          this.currentTabName=temp[this.currentRightIndex].name+"_"+this.currentRightIndex
        }
      }
    },
    closeCurrent(){
      if(this.tabs.length>1){
        this.handleTabsEdit(this.tabs[this.currentRightIndex].name,'remove')
      }
    },
    showRightMenu(e){
      console.log(e)

      if(e.button==2){
        let id=''
        e.path.forEach(x=>{
          if(x.className && x.className.indexOf('el-tabs__item')!=-1){
            id=x.id.split('-')[1]
            return false
          }
        })
        this.tabs.forEach((x,i)=>{
          if((x.name+"_"+i)==id){
            this.mouseX=e.clientX
            this.mouserY=e.offsetY
            this.currentRightIndex=i
          }
        })
      }
    },
    goback(t){
      if(t==0 && this.currentTag.hisIndex>0) {
        this.type='b'
        this.currentTag.type='b'
        this.currentTag.hisIndex-=1
        this.$router.push({path: this.currentTag.history[this.currentTag.hisIndex]})
      } else if(t==1 && this.currentTag.hisIndex<this.currentTag.history.length-1){
        this.type='f'
        this.currentTag.type='f'
        this.currentTag.hisIndex+=1
        this.$router.push({path: this.currentTag.history[this.currentTag.hisIndex]})
      }
    },
    propF5(){
      let that=this
      //注册JS屏蔽F5事件
      document.onkeydown = function(event){
        if(event.keyCode==17){  // ctrlDown 用来判断是否按下ctrl键 ctrl + F5
          that.ctrlDown = true;
        }
        if(event.keyCode==116&&!that.ctrlDown) {  // 只有在单独使用F5 的时候 阻止刷新
          that.reloadpage();
          return false
        }
      };
      document.onkeyup = function(e) {  //ctrl放开后改变状态
        if(e.keyCode==17){
          that.ctrlDown = false;
        }
      };
      //不想写checkout方法了，直接JS原生，那位义士把这里搞成checkout一下
      document.onclick=function(e){
        if(e.button!=2){
          that.currentRightIndex=-1
        }
      }
    },
    reloadpage(){
      this.tabs.forEach((x,i)=>{
        if(x.name==this.currentTabName.split('_')[0]){
          x.refer+=1
          return false
        }
      })
    },
    handleTabsEdit(targetName, action) {
      if (action === 'remove') {
        let index=0
        this.tabs.forEach((x,i)=>{
          if(x.name==targetName.split('_')[0] && i==targetName.split('_')[1]){
            index=i
            return false
          }
        })
        if(this.currentTabName==targetName){
          if(index<this.tabs.length-1)
            this.currentTabName=this.tabs[index+1].name+"_"+index
          else if(index>0){
            this.currentTabName=this.tabs[index-1].name+"_"+(index-1)
          }
        }
        // console.log(this.currentTabName)
        this.tabs.splice(index,1)
      }
    },
    mapObj(path,name){
      //this.getMenuV2(path)
      let obj={}
      obj=this.getTitleByRouter(name)
      if(obj.title=='')
        obj.title=this.getMenuV2(path)
      obj.title==''?'未命名':obj.title
      return obj
    },
    goUrl(path) {
      if(this.openMode==1){
        let pathArray=path.split('/')
        let isExsit=false
        let newName = pathArray[1].split('?')[0];
        let temp=this.mapObj(path,newName)
        if(path==="/TravelManager3"){
          this.$router.push({
            name: 'TravelManager3',
            query: { flag: true,blank:'y'}
          });
          return
        }
        if(path==="/TravelControlList3"){
          this.$router.push({
            name: 'TravelControlList3',
            query: { flag: true,blank:'y'}
          });
          return
        }
        this.tabs.forEach((x,i)=>{
          if(pathArray[1]==x.name||path==x.path||x.history.indexOf(path)!=-1){
            this.tabs[i].hisIndex=this.tabs[i].history.length
            this.tabs[i].path=path
            isExsit=true
            this.currentTabName=x.name+"_"+i
            this.comp=temp.comp
            this.tabs[i].type='d'
            return false
          }
        })
        if(!isExsit){
          let obj={}
          obj.path=path
          obj.title=temp.title
          obj.name=newName
          obj.comp=temp.comp
          obj.refer=0
          obj.history=[]
          obj.type='d'
          obj.hisIndex=0
          // console.log(newName)
          this.currentTabName=obj.name+'_'+this.tabs.length
          this.tabs.push(obj)
        }
        this.type='d'
      } else if (this.openMode==0 && path != "") {
        this.$router.push({ path });
      }
    },
    showToggle(id) {
      if (this.openId != id) {
        this.openId = id;
      } else {
        this.openId = 0;
      }
    },
    getMenu() {
      this.menuList = this.getLocalStorage().UserMenu;
      let path = this.$route.path.split("?")[0];

      let root = 0;
      let temprootName = ""; //根节点名称
      let tempparentName = ""; //二级节点名称
      let tempcurrentName = ""; //当前名称
      let itemsTemp = [];
      let that = this;
      //三级下面的子页面
      switch (path) {
        case "/leaderChedule": //领队档期
          path = "/leaderManagement";
          break;
        case "/leaderStateDetails": //领队绩效
          path = "/leaderManagement";
          break;
        case "/HotelInfo": //酒店基本信息新增修改
          path = "/HotelManagement";
          break;
        case "/HotelProductManage": //酒店房型
          path = "/HotelManagement";
          break;
        case "/HotelPrice": //酒店报价
          path = "/HotelManagement";
          break;
        case "/HotelOrder": //酒店销量看板详情
          path = "/HotelSalesBoard";
          break;
        case "/detailsInventory": //酒店总库存看板详情
          path = "/HotelTotalStock";
          break;
        case "/HotelSinglePrice": //酒店总库存看板(报价)详情
          path = "/HotelTotalStock";
          break;
        case "/HotelAccountInfo": //酒店核算详情
          path = "/HotelAccounting";
          break;
        case "/restaurantInfoManage": //餐厅新增修改
          path = "/restaurantList";
          break;
        case "/RestaurantPackage": //餐厅套餐新增修改
          path = "/restaurantList";
          break;
        case "/RestaurantPrice": //餐厅套餐报价新增修改
          path = "/restaurantList";
          break;
        case "/RestauranAccountingDetail": //餐厅内部核算详情
          path = "/RestauranAccounting";
          break;

        case "/scenicSpotInfoManage": //票劵新增修改
          path = "/scenicSpotList";
          break;
        case "/ticketManagement": //票劵门票新增修改
          path = "/scenicSpotList";
          break;
        case "/scenicSpotPackagePrice": //票劵门票报价新增修改
          path = "/scenicSpotList";
          break;
        case "/scenicSpotDetails": //票劵内部核算详情
          path = "/scenicSpotAccounting";
          break;

        case "/TicketAccountingDetails": //机票核算详情
          path = "/TicketAccounting";
          break;
        case "/TicketPlanInfo": //机票计划详情
          path = "/TicketPlan";
          break;
        case "/BusInfo": //新增修改车辆信息
          path = "/busManage";
          break;
        case "/BusAccountInfo": //车辆内部核算详情
          path = "/busManage";
          break;
        case "/MakeQuotation": //制作报价单
          path = "/quoTation";
          break;
        case "/TravelManager": //团控详情-开团
          path = "/quoTation";
          break;
        case "/ThroughSetting": //机票联运设置
          path = "/TicketManager";
          break;
        case "/QuotationPrice": //报价单
          path = "/quoTation";
          break;
        case "/DistributionTransport": //分销联运
          path = "/TravelControlList";
          break;
        case "/RegistrationList": //报名清单
          path = "/TravelControlList";
          break;
        case "/addPassenger": //报名清单
          path = "/groupTourOrder";
          break;
        case "/passengerListSale": //报名清单
          path = "/groupTourOrder";
          break;
        case "/passengerList": //旅客名单
          path = "/TravelControlList";
          break;
        case "/salesApprovalDetail": //计划审批
          path = "/salesApproval";
          break;
        case "/MyCustomerDetail": //计划审批
          path = "/MyCustomer";
          break;
        case "/saleDepartmentMap": //销售地图区域划分
          path = "/saleDepartmet";
          break;
        case "/QuotationDetails": //报价单详情
          path = "/AuditDan";
          break;
        case "/DirectQuotation": //报价单
          path = "/MakeQuotation";
          break;
        case "/VisaProductOrder": //报价单
          path = "/VisaProduct";
          break;
        case "/CombinedOrderList": //查看联运订单
          path = "/TicketManager";
          break;
        case "/groupTourOrderByTuan": //查看联运订单
          path = "/groupTourOrder";
          break;
        case "/empBankAccount": //查看联运订单
          path = "/userManagement";
          break;
        case "/BasicOpenGroup": //基础班开团
          path = "/BasicTravelControlList";
          break;
        case "/askPriceTotal": //工作汇总 询价
          path = "/workTotal";
          break;
        case "/worksalesApproval": //工作汇总 询价
          path = "/workTotal";
          break;
        case "/TeamBalancePayment": //团队收支明细
          path = "/TravelControlList";
          break;
        case "/saleReceivablesTotal": //工作汇总 询价
          path = "/workTotal";
          break;
        case "/PassengerList": //机票名单
          path = "/TicketManager";
          break;
          case "/roomReservationsDetails": //机票名单
          path = "/roomReservations";
          break;
          case "/bookDinnerStatisticsDetails": //餐厅
          path = "/bookDinnerStatistics";
          break;
          case "/OrderDetails": //国内机票历史订单详情
          path = "/SettlementOrder";
          break;
          case "/AccountPageList": //财务 下属账号页面
          path = "/institutionsManagement";
          break;
          case "/SalesFinancialDetail": //销售
          path = "/groupTourOrder";
          break;
          case "/addCapitalAllocation": //资金调拨
          path = "/CapitalAllocation";
          break;
          case "/CapitalAllocationDetail": //资金调拨
          path = "/CapitalAllocation";
          break;
      }

      //找到Root
      this.menuList.forEach(rootItem => {
        rootItem.ChildMenu.forEach(secondItem => {
          secondItem.ChildMenu.forEach(thirdItem => {
            if (thirdItem.MenuUrl == path) {
              root = rootItem.MenuId;
              return false;
            }
          });
        });
      });

      this.menuList.forEach(rootItem => {
        if (rootItem.MenuId == root) {
          temprootName = rootItem.MenuName;
          rootItem.ChildMenu.forEach(secondItem => {
            secondItem.childerns = [];
            let style = JSON.parse(secondItem.MenuStyle);
            secondItem.MenuStyleIcon = style.icon;
            secondItem.MenuStyleColor = style.color;
            secondItem.ChildMenu.forEach(thirdItem => {
              if (thirdItem.MenuUrl == path) {
                this.openId = secondItem.MenuId;
                tempparentName = secondItem.MenuName;
                tempcurrentName = thirdItem.MenuName;
              }
              secondItem.childerns.push(thirdItem);
              let style2 = JSON.parse(thirdItem.MenuStyle);
              thirdItem.MenuStyleIcon = style2.icon;
              thirdItem.MenuStyleColor = style2.color;
            });
            itemsTemp.push(secondItem);
          });
        }
      });

      if (itemsTemp.length > 0) {
        this.items = itemsTemp;
        this.rootName = temprootName;
        this.parentName = tempparentName;
        this.currentName = tempcurrentName;
      }
    },
    getMenuV2(path) {
      this.menuList = this.getLocalStorage().UserMenu;

      let root = 0;
      let temprootName = ""; //根节点名称
      let tempparentName = ""; //二级节点名称
      let tempcurrentName = ""; //当前名称
      let itemsTemp = [];
      let that = this;
      //三级下面的子页面
      switch (path) {
        case "/leaderChedule": //领队档期
          path = "/leaderManagement";
          break;
        case "/leaderStateDetails": //领队绩效
          path = "/leaderManagement";
          break;
        case "/HotelInfo": //酒店基本信息新增修改
          path = "/HotelManagement";
          break;
        case "/HotelProductManage": //酒店房型
          path = "/HotelManagement";
          break;
        case "/HotelPrice": //酒店报价
          path = "/HotelManagement";
          break;
        case "/HotelOrder": //酒店销量看板详情
          path = "/HotelSalesBoard";
          break;
        case "/detailsInventory": //酒店总库存看板详情
          path = "/HotelTotalStock";
          break;
        case "/HotelSinglePrice": //酒店总库存看板(报价)详情
          path = "/HotelTotalStock";
          break;
        case "/HotelAccountInfo": //酒店核算详情
          path = "/HotelAccounting";
          break;
        case "/restaurantInfoManage": //餐厅新增修改
          path = "/restaurantList";
          break;
        case "/RestaurantPackage": //餐厅套餐新增修改
          path = "/restaurantList";
          break;
        case "/RestaurantPrice": //餐厅套餐报价新增修改
          path = "/restaurantList";
          break;
        case "/RestauranAccountingDetail": //餐厅内部核算详情
          path = "/RestauranAccounting";
          break;

        case "/scenicSpotInfoManage": //票劵新增修改
          path = "/scenicSpotList";
          break;
        case "/ticketManagement": //票劵门票新增修改
          path = "/scenicSpotList";
          break;
        case "/scenicSpotPackagePrice": //票劵门票报价新增修改
          path = "/scenicSpotList";
          break;
        case "/scenicSpotDetails": //票劵内部核算详情
          path = "/scenicSpotAccounting";
          break;

        case "/TicketAccountingDetails": //机票核算详情
          path = "/TicketAccounting";
          break;
        case "/TicketPlanInfo": //机票计划详情
          path = "/TicketPlan";
          break;
        case "/BusInfo": //新增修改车辆信息
          path = "/busManage";
          break;
        case "/BusAccountInfo": //车辆内部核算详情
          path = "/busManage";
          break;
        case "/MakeQuotation": //制作报价单
          path = "/quoTation";
          break;
        case "/TravelManager": //团控详情-开团
          path = "/quoTation";
          break;
        case "/ThroughSetting": //机票联运设置
          path = "/TicketManager";
          break;
        case "/QuotationPrice": //报价单
          path = "/quoTation";
          break;
        case "/DistributionTransport": //分销联运
          path = "/TravelControlList";
          break;
        case "/RegistrationList": //报名清单
          path = "/TravelControlList";
          break;
        case "/addPassenger": //报名清单
          path = "/groupTourOrder";
          break;
        case "/passengerListSale": //报名清单
          path = "/groupTourOrder";
          break;
        case "/passengerList": //旅客名单
          path = "/TravelControlList";
          break;
        case "/salesApprovalDetail": //计划审批
          path = "/salesApproval";
          break;
        case "/MyCustomerDetail": //计划审批
          path = "/MyCustomer";
          break;
        case "/saleDepartmentMap": //销售地图区域划分
          path = "/saleDepartmet";
          break;
        case "/QuotationDetails": //报价单详情
          path = "/AuditDan";
          break;
        case "/DirectQuotation": //报价单
          path = "/MakeQuotation";
          break;
        case "/VisaProductOrder": //报价单
          path = "/VisaProduct";
          break;
        case "/CombinedOrderList": //查看联运订单
          path = "/TicketManager";
          break;
        case "/groupTourOrderByTuan": //查看联运订单
          path = "/groupTourOrder";
          break;
        case "/empBankAccount": //查看联运订单
          path = "/userManagement";
          break;
        case "/BasicOpenGroup": //基础班开团
          path = "/BasicTravelControlList";
          break;
        case "/askPriceTotal": //工作汇总 询价
          path = "/workTotal";
          break;
        case "/worksalesApproval": //工作汇总 询价
          path = "/workTotal";
          break;
        case "/TeamBalancePayment": //团队收支明细
          path = "/TravelControlList";
          break;
        case "/saleReceivablesTotal": //工作汇总 询价
          path = "/workTotal";
          break;
        case "/PassengerList": //机票名单
          path = "/TicketManager";
          break;
          case "/roomReservationsDetails": //机票名单
          path = "/roomReservations";
          break;
          case "/bookDinnerStatisticsDetails": //餐厅
          path = "/bookDinnerStatistics";
          break;
          case "/OrderDetails": //国内机票历史订单详情
          path = "/SettlementOrder";
          break;
          case "/AccountPageList": //财务 下属账号页面
          path = "/institutionsManagement";
          break;
          case "/SalesFinancialDetail": //销售
          path = "/groupTourOrder";
          break;
          case "/addCapitalAllocation": //资金调拨
          path = "/CapitalAllocation";
          break;
          case "/CapitalAllocationDetail": //资金调拨
          path = "/CapitalAllocation";
          break;
      }

      //找到Root
      this.menuList.forEach(rootItem => {
        rootItem.ChildMenu.forEach(secondItem => {
          secondItem.ChildMenu.forEach(thirdItem => {
            if (thirdItem.MenuUrl == path) {
              root = rootItem.MenuId;
              return false;
            }
          });
        });
      });

      this.menuList.forEach(rootItem => {
        if (rootItem.MenuId == root) {
          temprootName = rootItem.MenuName;
          rootItem.ChildMenu.forEach(secondItem => {
            secondItem.childerns = [];
            let style = JSON.parse(secondItem.MenuStyle);
            secondItem.MenuStyleIcon = style.icon;
            secondItem.MenuStyleColor = style.color;
            secondItem.ChildMenu.forEach(thirdItem => {
              if (thirdItem.MenuUrl == path) {
                this.openId = secondItem.MenuId;
                tempparentName = secondItem.MenuName;
                tempcurrentName = thirdItem.MenuName;
              }
              secondItem.childerns.push(thirdItem);
              let style2 = JSON.parse(thirdItem.MenuStyle);
              thirdItem.MenuStyleIcon = style2.icon;
              thirdItem.MenuStyleColor = style2.color;
            });
            itemsTemp.push(secondItem);
          });
        }
      });

      if (itemsTemp.length > 0) {
        this.items = itemsTemp;
        this.rootName = temprootName;
        this.parentName = tempparentName;
        this.currentName = tempcurrentName;
      }

      return tempcurrentName
    },
    getTitleByRouter(name){
      let obj={}
      routerConfig.routes[11].children[11].children.forEach(x=>{
        if(x.name==name){
          obj.comp=x.component
          if(x.meta && x.meta.title)
            obj.title=x.meta.title
          else
            obj.title=''
          return false
        }
      })
      return obj
    },
    filterRouter(){
      let that=this
      this.$router.beforeEach((to, from, next) => {
        console.log("to.query.blank && to.query.blank=='y'",to.query)
        if(that.openMode==1){
          let isThreeNav=false
          to.matched.forEach(x=>{
            if(x.name=='Details'){
              isThreeNav=true
              return false
            }
          })

          if(isThreeNav){
            // console.log(to)
            if(!to.query.blank || to.query.blank!='y'){
              let comp=that.getTitleByRouter(to.name)
              if(that.tabs.length>0){
                // console.log('in..........')
                let tabs=that.tabs.filter(x=>{
                  let item=x
                  if(x.name==that.currentTabName.split('_')[0]&& x.path==that.currentTag.path){
                    if(that.type=='d'){
                      x.hisIndex=x.history.length
                      // console.log(x)
                    }
                    x.title=comp.title==''?x.title:comp.title
                    x.path=to.fullPath
                    x.comp=comp.comp
                  }
                  return item
                })
                that.$set(that.tabs,tabs)
                that.type='d'
              }
            }else{
              let temp=that.mapObj(to.path,to.name)
              let realPath=to.fullPath.split('?')[1]
              let newPath=to.path+'?'
              realPath.split('&').forEach((x,i)=>{
                if(x.indexOf('blank')==-1){
                  if(i>0)
                    newPath+='&'
                  newPath+=x
                }
              })
              // console.log(newPath)
              let isExsit=false
              let tabs=that.tabs.filter((x,i)=>{
                if(x.path==newPath){
                  that.currentTabName=x.name+'_'+i
                  isExsit=true
                }
                return x
              })
              // console.log(newPath)
              if(isExsit)
                that.$set(that.tabs,tabs)
              else{
                let obj={}
                obj.path=newPath
                obj.title=to.query.tab?to.query.tab:temp.title
                obj.name=to.name
                obj.comp=temp.comp
                obj.refer=0
                obj.history=[]
                obj.type='d'
                obj.hisIndex=0
                that.tabs.push(obj)
                that.currentTabName=obj.name+"_"+(that.tabs.length-1)
                // console.log(that.tabs)
              }
            }
          }

          next()
        }else if(that.openMode==0 && to.query.blank && to.query.blank=='y'){
          let dom = document.querySelector("#blankLink")
          dom.href=`http://${window.location.host}/#${to.fullPath}`
          //console.log(that.$refs.blankLink.click())
          dom.click()
        }else{
          next()
        }
      });
    }
  },
  beforeDestroy() {
    //卸载屏蔽事件
    document.onkeydown=null
    if(this.tabs.length>0)
      window.localStorage.navTabs=JSON.stringify(this.tabs)
  },
};
</script>
