<template>
  <div style="height:100%">
    <!--通讯,1-->
    <div id="getMenu">
    </div>
    <!--通讯,1-->
    <!--通讯,2-->
    <div id="changeRole">
    </div>
    <!--通讯,2-->
    <!--通讯,3-->
    <div id="changeOrg">
    </div>
    <!--通讯,3-->
    <!--通讯,4-->
    <div id="logout">
    </div>
    <!--通讯,4-->
    <!--通讯,5-->
    <div id="connWS">
    </div>
    <!--通讯,5-->
    <!--通讯,6-->
    <div id="showUserDetail">
    </div>
    <!--通讯,6-->
    <!--通讯,7-->
    <div id="saveUserDetail">
    </div>
    <!--通讯,7-->
    <!--通讯,8-->
    <div id="allMenuListMsg">
    </div>
    <!--通讯,8-->
    <el-container class="index-total">
      <div class="t"></div>
      <m-header ref="header" @SignIn="SignIn" @SignOut="SignOut" @changeRoles="changeRoles" @changeOrgs="changeOrgs" :header="header" :user="user"></m-header>
      <el-container style="height:calc(100vh - 60px)">
        <side-bar ref="sidebar" :data="menuData" @select="initOpenMenu" @calc="calcTabsWidth"></side-bar>
        <!-- 右边主内容块 -->
        <el-main class="poin-el-main" :class="{'main-home':'/home' === $route.path, 'main--fullscreen': mainFullscreen}">
          <!-- 标签 -->
          <active-menu-tabs ref="menuTabs" :data="menuData" :activeIndex="activeIndex" @initMenu="initOpenMenu"></active-menu-tabs>
          <bread-crumbs v-show="$route.path != '/home'" :data="breadcrumb" ref="breadcrumb"></bread-crumbs>
          <div class="c-main-content">
            <router-view></router-view>
          </div>
          <!-- <el-scrollbar style="height: 100%;" ref="mainWrap" wrapClass="main-view">
						<router-view>
						</router-view>
					</el-scrollbar> -->
				</el-main>
				<toolbars></toolbars>
				<!-- <dustbin></dustbin> -->
			</el-container>
		</el-container>
		
	</div>
</template>
<script type="text/javascript">
import * as iscMessage from "@/util/isc-common/messageManage.js";
const publicPath = require("@/config/isc-publicPath.js");
import baseData from "@/config/isc-baseData.js";
import ad from "./Toolbars/components/Ad";

import {
  Form,
  FormItem,
  Tooltip,
  Dropdown,
  MenuItem,
  DropdownMenu,
  Aside,
  Input,
  Container,
  Header,
  ButtonGroup,
  Button,
  Dialog,
  MenuItemGroup,
  Tag,
  Menu,
  Submenu,
  Main,
  Scrollbar,
  DropdownItem
} from "element-ui";

import { mapMutations, mapActions } from "vuex";

import BreadCrumbs from "./Home/aside/BreadCrumbs.vue";
import IscNavMenu from "./Home/aside/SideMenu.js";
import ActiveMenuTabs from "./Home/aside/MenuTabs.vue";
import SideBar from "./Home/aside/SideBar.vue";
import Api from '~/service/Api';

// Test
import menuData from "./menuData.js";
// 工具条
import toolbars from "./Toolbars";

//垃圾桶
import dustbin from "./Dustbin";

import header from "./Home/Header/header.vue"
import trancode from "./tranCode.js"

export default {
  data() {
    return {
      showUpArrow: false,
      showDownArrow: false,
      openPassWord: false,
      showModifyPass: true,
      publicPath: publicPath,
      mainFullscreen: false,
      isCollapse: false,
      tagsDefaultArr: [{ name: 'home', path: '/home', text: '平台首页', menuIndex: '30582', isHome: true }],
      tagsArry: [],
      activeIndex: '30582',
      activePath: '/home',
      homeQuery: '',
      menuTimeout: null,
      showMenuTimeout: 310,
      currOpenedIndex: '30582',
      homeIndex: '',
      homeTagWidth: 91,
      tagsLeft: 76,
      tagsWidth: 10,
      curViewWidth: 0,
      flexHeight: 'calc(100vh - 60px)',
      flexMainHeight: 'calc(100vh - 60px)',
      mainScrollHeight: 'calc(100vh - 128px)',
      devicePixelRatio: 1,
      menuData: [],
      username: '',
      oneExecute:true,
      roleList: [],
      orgList: [],
      date: '',
      curRole: { id: -110, name: '' },
      curOrg: { id: -110, name: '' },
      breadcrumb: [{ name: '平台首页', uri: '/home', replace: true }],
      connWS: { "fileName": "workflow.json", "basePath": "{{basePath}}", "method": "get", "scheme": "{{schemes}}", "host": "{{host}}", "consume": "0", "produce": "0", "uri": "/poinwfsocket" },
      allMenuListMsg: { "fileName": "menuManager.json", "basePath": "{{basePath}}", "method": "get", "scheme": "{{schemes}}", "host": "{{host}}", "consume": "0", "produce": "0", "uri": "/menu/treeOrBtnOrSubpage" },
      user: {
        fixedPhone: '',
        province: '',
        nationality: '',
        sex: '1',
        extfield1: '',
        extfield2: '',
        extfield3: '',
        extfield4: '',
        extfield5: '',
        mobilePhone: '',
        postalcode: '',
        email: '',
        street: '',
        city: '',
        state: '1',
        workDept: '',
        workDeptName: '',
        birthday: '',
        workorg: '',
        workorgName: '',
        faxaPhone: '',
        confirmPass: '',
        logPass: '',
        logName: '',
        name: '',
        id: '',
      },
      // dragShow: false,
      //header增加字段
      header: {
        date: '',
        roleTypeList:[],
        allRoleList:[],
        roleList: [],
        orgList: [],
        curRole: { id: '', name: '' },
        curOrg: { id: '', name: '' },
        accbch:{id:'',name:''},
        usr:{},
        username: ''
      }
    }
  },
  mixins: [trancode],
  components: {
    'el-header': Header,
    'el-button-group': ButtonGroup,
    'el-dropdown-menu': DropdownMenu,
    'el-form': Form,
    'el-container': Container,
    'el-submenu': Submenu,
    'el-scrollbar': Scrollbar,
    'el-dropdown-item': DropdownItem,
    'el-menu': Menu,
    'el-menu-item': MenuItem,
    'el-dropdown': Dropdown,
    'el-input': Input,
    'el-button': Button,
    'el-form-item': FormItem,
    'el-menu-item-group': MenuItemGroup,
    'el-dialog': Dialog,
    'isc-nav-menu': IscNavMenu,
    'el-aside': Aside,
    'el-tag': Tag,
    'el-tooltip': Tooltip,
    'el-main': Main,
    toolbars,
    dustbin,
    'm-header': header,
    "active-menu-tabs": ActiveMenuTabs,
    "side-bar": SideBar,
    "bread-crumbs": BreadCrumbs
  },
  mounted() {
    this.getMenuList()
    let $this = this;
    this.devicePixelRatio = window.devicePixelRatio;
    this.calcHeight();
    this.$el.querySelectorAll('*[data-init]').forEach(function (el, index) {
      var init = el.getAttribute('data-init');
      var message = iscMessage.initMessageKey(init);
      // 避免加载router-view里的页面的初始化通讯(如果其他页面嵌套有router-view,也需这样处理)
      if (!message[0] || !message[0].id || !$this[message[0].id]) return;
      $this.poin_initManage(message[0], message[1], message[2]);
    });

    // 添加 resize 绑定事件
    // window.addEventListener( "resize",this.resizeFun());
    // 监听菜单滚动事件


    // this.handleScroll()
    //iam登录不显示修改密码框 2021-8-9
    if (this.$store.state.common.isIamLogin) {
      this.showModifyPass = false;
    }
    // 获取节假日
		this.queryHoliday()
  },
  methods: {
    // handleChooseTool() {
    // 	this.dragShow = true
    // },
    poin_initManage(messageKey, callback, execBefore) {
      messageKey.vue = this;
      iscMessage.messageManage(messageKey, callback, execBefore);
    },
    // 刷新router-view
    refreshPage() {
      this.goRefreshRoute(this);
    },
    resizeFun() {
      var $this = this;
      if (
        navigator.userAgent.toLowerCase().indexOf("chrome") > -1 &&
        window.devicePixelRatio !== $this.devicePixelRatio
      ) {
        $this.$refs.menuTabs.resize();
      }
      $this.resizeFlexHeight();
    },
    // 窗口大小变化时,计算poin-el-main和main-view高度
    resizeFlexHeight() {
      const body = document.querySelector("body");
      if (body.offsetHeight < body.scrollHeight) {
        this.flexHeight = this.flexMainHeight = body.scrollHeight - 60 + "px";
        if ("/home" === this.$route.path) {
          this.mainScrollHeight = body.scrollHeight - 94 + "px";
        } else {
          this.mainScrollHeight = body.scrollHeight - 128 + "px";
        }
      } else {
        if (this.mainFullscreen) {
          this.flexMainHeight = "100%";
          this.mainScrollHeight = "calc(100vh - 19px)";
        } else {
          this.flexMainHeight = "calc(100vh - 60px)";
          if ("/home" === this.$route.path) {
            this.mainScrollHeight = "calc(100vh - 94px)";
          } else {
            this.mainScrollHeight = "calc(100vh - 113px)";
          }
        }
      }
      // 高度变化后,更新scroller
      this.$nextTick(() => {
        if (this.$refs.mainWrap) {
          this.$refs.mainWrap.update();
        }
      });
    },
    // 全屏的触发与取消
    toggleScreen() {
      this.mainFullscreen = !this.mainFullscreen;
      this.calcHeight();
    },
    // 全屏切换的情况下,重新 计算poin-el-main和main-view高度
    calcHeight() {
      if (this.mainFullscreen) {
        this.flexMainHeight = "100%";
        this.mainScrollHeight = "calc(100vh - 19px)";
      } else {
        this.flexMainHeight = "calc(100vh - 60px)";
        if ("/home" === this.$route.path) {
          this.mainScrollHeight = "calc(100vh - 94px)";
        } else {
          this.mainScrollHeight = "calc(100vh - 113px)";
        }
      }
      this.$nextTick(() => {
        if (this.$refs.mainWrap) {
          this.$refs.mainWrap.update();
        }
      });
    },
    // 路由切换时,根据是否是首页,计算main-view高度
    calcHeight2() {
      if (
        "/home" === this.$route.path &&
        "calc(100vh - 113px)" === this.mainScrollHeight
      ) {
        this.mainScrollHeight = "calc(100vh - 94px)";
        return;
      }
      if (
        "/home" !== this.$route.path &&
        "calc(100vh - 94px)" === this.mainScrollHeight
      ) {
        this.mainScrollHeight = "calc(100vh - 113px)";
        return;
      }
    },
    initOpenMenu(index, indexPath, routePath) {
      // 当路由变化时,菜单状态也随之改变,包括activeIndex和openedMenus
      let activeIndex = "";
      let activePath = "";
      activePath = this.$route.fullPath;
      // activePath = activePath.indexOf('?') > -1 ? activePath.split('?')[0] : activePath;
      this.activePath = activePath;
      if (index) {
        activeIndex = index;
      } else {
        const activeRoute = this.menuData.filter(
          (el, i) => el.routePath == activePath
        );
        if (activeRoute && activeRoute.length != 0) {
          activeIndex = activeRoute[0].idIndex;
        } else {
          activeIndex = this.homeIndex;
        }
      }
      this.activeIndex = activeIndex;
      if (
        !this.$refs.sidebar.$refs.menu ||
        !this.$refs.sidebar.$refs.menu.$children
      ) {
        return;
      }

      let $ElMenu = this.$refs.sidebar.$refs.menu.$children[0];
      if (activeIndex) {
        if ($ElMenu.activeIndex != activeIndex) {
          $ElMenu.activeIndex = activeIndex;
        }
        if (activeIndex.indexOf("-") == -1) {
          if (
            activePath == "/home" || activePath.indexOf("?") > -1
              ? activePath.split("?")[0]
              : activePath == "/home"
          ) {
            this.currOpenedIndex = this.homeIndex;
          } else {
            this.currOpenedIndex = activeIndex;
          }
        } else {
          let indexArr = activeIndex.split("-");
          const indexArrLength = indexArr.length;
          if (indexArrLength == 2) {
            this.currOpenedIndex = indexArr[0];
          } else {
            this.currOpenedIndex = indexArr[0]; // + '-' + indexArr[1]
          }
        }
      } else {
        this.currOpenedIndex = this.homeIndex;
      }
      if (this.isCollapse) {
        return;
      }
      //$ElMenu.openedMenus = [this.currOpenedIndex];
    },
    hideSubMenu() {
      if (
        !this.$refs.sidebar.$refs.menu ||
        !this.$refs.sidebar.$refs.menu.$children
      ) {
        return;
      }
      // 隐藏展开的菜单,只留2级
      if ("/home" == this.activePath) {
        this.currOpenedIndex = this.homeIndex;
        this.activeIndex = this.homeIndex;
      } else {
        const activeIndex = this.$refs.sidebar.$refs.menu.$children[0]
          .activeIndex;
        this.activeIndex = activeIndex;
        if (activeIndex) {
          this.currOpenedIndex =
            activeIndex.indexOf("-") > -1
              ? activeIndex.split("-")[0]
              : activeIndex;
        } else {
          this.currOpenedIndex = this.homeIndex;
          this.activeIndex = this.homeIndex;
        }
      }
      if (this.$refs.sidebar.isCollapse) {
        return;
      }
      this.$refs.sidebar.$refs.menu.$children[0].openedMenus = [
        this.currOpenedIndex
      ];
    },
    showMenu(key, keyPath, routePath) {
      // 点击1级菜单时,菜单伸缩状态改变
      if (key.indexOf("-") == -1) {
        this.$refs.sidebar.toggleCollapse();
      }
    },
    collapseMenu(key, keyPath, routePath) {
      // 点击1级菜单时,菜单伸缩状态改变
      if (key.indexOf("-") == -1) {
        this.$refs.sidebar.toggleCollapse();
      }
    },
    toggleCollapse() {
      this.isCollapse = !this.isCollapse;
      this.setMenuCollapse(this.isCollapse);
    },
    addMenuEvent() {
      if (
        !this.$refs.sidebar.$refs.menu ||
        !this.$refs.sidebar.$refs.menu.$children
      ) {
        return;
      }
      const $this = this;
      let $ElMenu = this.$refs.sidebar.$refs.menu.$children[0];
      // 由于菜单是动态创建的,所以省去解绑
    },
    async getMenuList() {
      // this.menudatamock = JSON.parse(sessionStorage.getItem("menudatamock"));
      await this.getDbCode("ROLTYP","CN");
      let logininfo = sessionStorage.getItem('logininfo');
      let logininfoObj = JSON.parse(logininfo);
      if (logininfoObj) {
        this.menuData = logininfoObj.menu;
      }
      let data = logininfoObj;
      //获取用户和系统信息后通讯成功回调事件,在这里对菜单、角色、机构赋值
      //if (response && response.ok && data) {
      if (data) {
        this.header.roleList = data.roleList;
        this.header.allRoleList = data.roleList;
        this.header.orgList = data.orgList;
        this.header.date = data.curDate;
        this.header.curOrg = data.currentOrg;
        this.header.curRole = data.curRole;
        this.header.username = data.username;
        this.autoChageRoles(this.header.curOrg.id);
        // 记账机构
        this.header.accbchList = data.accbchList;
        this.header.accbch = data.accbch;
        this.header.usr = data.usr;
        //增加用户id=>data.userId  查询当前用户信息 可修改密码
        var $this = this;
        if (data.userId) {
          // 处理缓存问题
          this.setLoginInfo({
            ...data
          });
          // 缓存机构
          this.updateCurrentOrg(data.currentOrg);
          //缓存角色
          this.updateCurRole(data.curRole);
          sessionStorage.setItem('departmentNumber', data.currentOrg.departmentNumber)
          this.updateAccbch(data.accbch);
          // 缓存国结usr表用户信息
          this.updateUsr(data.usr);
        }
        // 由于菜单数据变化,触发菜单DOM的重新渲染,需在其渲染完后才能给菜单li绑定事件
        this.$nextTick(() => {
          this.resizeFlexHeight();
          if (
            this.$refs.sidebar.$refs.menu &&
            this.$refs.sidebar.menuData
          ) {
            const menuData = this.$refs.sidebar.menuData;
            if (menuData instanceof Array && menuData.length > 0) {
              this.activeIndex = this.currOpenedIndex = this.homeIndex =
                menuData[0].idIndex;
              this.tagsDefaultArr[0].menuIndex = menuData[0].idIndex;
            }
					}
          this.$refs.menuTabs.addMenuTab(this.$route,null);
          if (this.$route.path != "/home")
            this.breadcrumb = this.$refs.breadcrumb.getBreadcrumb(
              this.menuData
            );
          this.addMenuEvent();
        });

        //创建websocket,接收后台推送的待办提示
        //this.connWebSocket(this.username,'8018');
        //存储username到状态管理器
        this.setUserName(this.header.username);
        //存储菜单数据到状态管理器
        if (baseData.isOpenDisabledCopy == "menuConfig") {
          this.poin_initManage({ id: "allMenuListMsg" }, (res, resData) => {
            if (res && res.ok) {
              sessionStorage.setItem("menu_data", JSON.stringify(resData.menu));
            }
          });
        }
      }
    },
    async changeOrgs(param) {
      if (param == this.header.curOrg.id) {
        return;
      }
      let isColseTags = this.$store.state.rulebpmn.tagsArry.some((item) => {
        return this.getTransactionCode().includes(item.name)
      })
      //判断是否有未关闭的页签
      if (this.$store.state.rulebpmn.tagsArry.length > 1 && isColseTags) {
        this.$alert('当前机构有未关闭的页签,请先关闭', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      //切换机构
      const params = {
        j_username: sessionStorage.getItem('j_username'),
        curOrgId: param,
      };
      //const res = await Api.post('/manager/login/changeOrg', params);
      const res = await Api.post('/admin/login/changeOrg', params);
      if (res.respCode === SUCCESS) {
        if (res.data) {
          let curOrg = res.data
          this.header.curOrg = curOrg;
          sessionStorage.setItem('currentOrg', JSON.stringify(curOrg))
          this.updateCurrentOrg(curOrg)
        }
      }else{
        this.$notify.error(res.respMsg);
      }
      // 切换机构
      // this.poin_initManage({ "id": "changeOrg" }, (response, data, messageObj, error) => {
      //   //改变当前显示机构
      //   let curOrg = this.header.orgList.filter((item, index) => { return item.id == param })[0]
      //   this.header.curOrg = curOrg;
      //   sessionStorage.setItem('currentOrg', JSON.stringify(curOrg))
      //   this.updateCurrentOrg(curOrg)
      //   if (this.$store.state.rulebpmn.tagsArry.length > 1) {
      //     this.$refs.menuTabs.dropdownTabClick('all', true);
      //   }
      // }, messageObj => { messageObj.setUriParam({ "orgId": param }) });
    },
    autoChageRoles(param){
      //如果机构为总行,角色为分行,会自动切换机构的第一个默认总行角色
      if(this.header.roleTypeList && this.header.roleTypeList.length===0){
        return;
      }
      let orgObj = this.header.orgList.find(item => item.id === param)
      let roleObj = this.header.roleTypeList.find(item => item.key === this.header.curRole.id+"")
      this.initRoleList(orgObj);
      if(this.header.roleList &&
        this.header.roleList.length>0 &&
        ((orgObj.departmentNumber==="1000" && roleObj && roleObj.value!=="HEAD") || (orgObj.departmentNumber!=="1000" && (roleObj && roleObj.value==="HEAD")))
      ){
        this.changeRoles(this.header.roleList[0].id);
        sessionStorage.setItem('curRole', JSON.stringify(this.header.roleList[0]));
      }
      if(this.header.roleList && this.header.roleList.length===0  ) {
        if (orgObj.departmentNumber === "1000") {
          this.$notify({title: "失败", message: "请先维护总行机构角色!", type: "error",});
        } else {
          this.$notify({title: "失败", message: "请先维护分行机构角色!", type: "error",});
        }
      }
    },

    initRoleList(orgObj){
      let newRoleList=[];
      for(let i=0;i<this.header.roleTypeList.length;i++){
        let item=this.header.roleTypeList[i];
        for(let j=0;j<this.header.allRoleList.length;j++){
          if(item.key===this.header.allRoleList[j].id+"" ){
            if(orgObj.departmentNumber==="1000" && (item.value==="HEAD" || item.value==='PUBLIC')){
              newRoleList.push(this.header.allRoleList[j]);
            }
            if(orgObj.departmentNumber!=="1000" && item.value!=="HEAD"){
              newRoleList.push(this.header.allRoleList[j]);
            }
          }
        }
      }
      this.header.roleList=newRoleList;
    },
    async changeRoles(param) {
      if (param == this.header.curRole.id) {
        return;
      }
      let isColseTags = this.$store.state.rulebpmn.tagsArry.some((item) => {
        return this.getTransactionCode().includes(item.name)
      })
      //判断是否有未关闭的页签
      if (this.$store.state.rulebpmn.tagsArry.length > 1 && isColseTags) {
        this.$alert('当前角色有未关闭的页签,请先关闭', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      //切换角色
      const params = {
        j_username: sessionStorage.getItem('j_username'),
        roleId: param,
      };
      const res = await Api.post('/admin/login/changeRole', params);
      if (res.respCode === SUCCESS) {
        if (res.data) {
          let curRole = res.data
          this.header.curRole = curRole;
          sessionStorage.setItem('curRole', JSON.stringify(curRole))
          this.updateCurRole(curRole)
        }
      }else{
        this.$notify.error(res.respMsg);
      }
    },
    getDbCode(codeType, uil) {
      return new Promise(async (resolve) => {
        if(this.oneExecute){
            this.oneExecute=false;
            let params = {codeType: codeType, uil: uil ? uil : 'EN'};
            let rtnmsg = await Api.post("/manager/dic/listDicInfo", params);
            if (rtnmsg.respCode === SUCCESS) {
              let curList = rtnmsg.data.map(item => ({
                key: item.codeValue,
                value: item.codeName
              }));
              this.header.roleTypeList = curList || [];
              resolve(this.header.roleTypeList);
          }
        }
      })
    },
    //签到
    async SignIn(param) {
      let res = await Api.post('/public/taskdist/user/signin', param);
      console.log('res:', res)
      if (res.respCode == SUCCESS) {
        if (param.isLogin == 'Y') {
          if (res.data.rtnCod == 'AAAAAA') {
            this.$notify({
              title: '提示',
              message: res.data.rtnMsg,
              type: 'warning',
            });
          } else if ("E00002|E00003|E00004".indexOf(res.data.rtnCod) < 0) {
            // this.$notify({
            //   title: '提示',
            //   message: res.data.rtnMsg,
            //   type: 'warning',
            // });
          }

        } else {
          if (res.data.rtnCod == 'AAAAAA') {
            this.$notify({
              title: '成功',
              message: res.data.rtnMsg,
              type: 'success',
            });
          } else {
            this.$notify({
              title: '提示',
              message: res.data.rtnMsg,
              type: 'warning',
            });
          }
        }

      }
    },
    //签退
    async SignOut(param) {
      let res = await Api.post('/public/taskdist/user/logout', param);
      if (res.respCode == SUCCESS) {
        if (res.data.rtnCod == 'AAAAAA') {
          this.$notify({
            title: '成功',
            message: res.data.rtnMsg,
            type: 'success',
          });
        } else {
          this.$notify({
            title: '提示',
            message: res.data.rtnMsg,
            type: 'warning',
          });
        }

      } else {
        this.$notify({
          title: "失败",
          message: res.respMsg,
          type: "error",
        });
      }
    },
    connWebSocket(poin_user_name, hostNum) {
      //创建websocket,接收后台推送的待办提醒
      const _this = this;
      if ("WebSocket" in window && this.connWS) {
        let websocket = null;
        const wsHost = this.connWS.host;
        let ipString = "";
        if (wsHost) {
          if (wsHost.startsWith("{{") && wsHost.endsWith("}}")) {
            ipString = baseData[wsHost.substring(2, wsHost.length - 2)];
          } else {
            ipString = wsHost;
          }
          ipString = ipString.substring(0, ipString.indexOf(":"));
        }
        websocket = new WebSocket(
          "ws://" +
          ipString +
          ":" +
          hostNum +
          "/poinwfsocket?userId=" +
          poin_user_name
        );
        websocket.onmessage = function (event) {
          const h = _this.$createElement;
          _this.$notify({
            title: "您有一个新的待办任务",
            message: h(
              "a",
              {
                class: "el-link is-underline",
                on: { click: _this.goToWFList }
              },
              event.data
            )
          });
        };
      }
    },
    goToWFList() {
      this.$router.push("/iscWorkflow/wfassignmentUndo");
    },
    calcTabsWidth(data) {
      this.$refs.menuTabs.calcTagsWidthAfterCollapse(data)
    },
    ...mapMutations(["setLoginInfo", "updateCurrentOrg", "updateCurRole","updateAccbch","updateUsr"]),
    ...mapActions([
      "changeSkin",
      "goRefreshRoute",
      "setMenuCollapse",
      "setUserName"
    ]),
    // 获取节假日
    async queryHoliday () {
      let res = await Api.post('/manager/tdh/queryHoliday')
      if(res.respCode == SUCCESS){
        if (res.data) {
          let localHolidays = JSON.stringify(res.data)
          localStorage.setItem('localHolidays', localHolidays)
        }
      }
    }
  },
  beforeDestroy() {
    localStorage.removeItem("localCodes");
  },
  destroyed() {
    //解绑
    //this.$el.querySelector("header.poin-el-header").removeEventListener("click", this.hideSubMenu);
    this.$el.querySelector("main.poin-el-main").removeEventListener("click", this.hideSubMenu);
    // this.$el.querySelector('.aside-menu').removeEventListener('mouseleave', () => {
    // 	if (this.isCollapse) {
    // 		return
    // 	}
    // 	if (!this.$refs.sidebar.$refs.menu || !this.$refs.sidebar.$refs.menu.$children) {
    // 		return
    // 	}
    // 	this.$refs.sidebar.$refs.menu.$children[0].openedMenus = [this.currOpenedIndex];
    // });
    window.removeEventListener("resize", this.resizeFun());
  },
  watch: {
    menuData() { },
    $route() {
      let lstpath=this.activePath
      // 当前被激活菜单的path
			let activePath = this.$route.path;
      // activePath = activePath.indexOf('?') > -1 ? activePath.split('?')[0] : activePath;
      if (this.activePath != activePath) {
        this.activePath = activePath;
      }
      this.$refs.menuTabs.addMenuTab(this.$route,lstpath);
      this.calcHeight2();
      if (this.$route.path != "/home") {
        this.breadcrumb = this.$refs.breadcrumb.getBreadcrumb(this.menuData);
      }
    },
  }
};
</script>
<style type="text/css" lang="less">
@header-height: 60px;
@tags-height: 34px;
@baseMenu-width: 58px;
@menu-height: 42px;
.noBorderBg() {
  border-width: 0;
  border-radius: 0;
  background: transparent;
}
.el-date-table td:not([align]),
.el-date-table th:not([align]) {
  text-align: center;
}
body,
html,
#app,
.el-container {
  height: 100%;
}
body > .el-container {
  margin-bottom: 40px;
}
.t{
		height: 61px;
		width: 100%;
		background: rgb(63,48,154);
		background-position: center;
		background-size: 100% 100%;
		border-radius: 0px 0px 12px 12px;
		z-index: -1;
		flex-shrink: 0;
		position: absolute;
	}
	.index-total{
		flex-direction: column;
	}
.el-menu {
  border: none;
}

.el-menu--vertical {
  width: 230px;
  .el-menu {
    margin-right: 0;
  }
  .el-menu-item,
  .el-submenu,
  .el-submenu__title {
    height: 36px;
    line-height: 36px;
    border-bottom: none;
  }
  .el-scrollbar__view {
    .el-submenu {
      border-bottom: none;
    }
  }
  .el-menu-item.is-active {
    // background: #f6f1f8;
    color: #000000;
    .before-icon {
      background: var(--error-color) !important;
    }
  }
  .el-menu-item:hover {
    // background: #f6f1f8;
    color: #222222;
  }
}

.el-breadcrumb {
  display: inline-block;
}
.el-scrollbar__bar {
  z-index: 10000;
}


.skin-dropitem {
  position: relative;

  &:hover {
    .skin-btns {
      display: block;
    }
  }
}
.skin-btns {
  display: none;
  position: absolute;
  left: 0;
  top: -1px;
  transform: translateX(-99%);

  & > div {
    margin-right: 6px;
    padding: 5px 10px;
    line-height: 0;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  }

  &:after {
    content: "";
    position: absolute;
    right: 1px;
    top: 50%;
    margin-top: -5px;
    display: block;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-color: transparent;
    border-right-width: 0;
    border-left-color: #fff;
  }

  .el-button {
    background-color: #a04dc0;
    border-color: #a04dc0;

    & + .el-button {
      background-color: #409eff;
      border-color: #409eff;
    }
  }
}

.poin-el-main {
  margin-right: 8px;

  .main-view {
    height: 100%;
    padding: 10px;
  }
}

.el-scrollbar__wrap {
  overflow-x: hidden;
  overflow-y: scroll;
  .el-scrollbar__view {
    height: 100%;
    overflow: hidden auto;
    #business_container {
      height: 100%;
      .el-form {
				margin-bottom:15px;
        height: calc(100% - 75px);
      }
      .m-Btn-eContainer {
        background: #fff;
        width: 100%;
        position: absolute;
        left: 0;
        bottom: 10px;
      }
    }
    .eibs {
      padding-bottom: 50px;
    }
  }
}
.aside-menu {
  .menu-wrap {
    width: 100%;
    height: calc(100% - 34px);
    overflow: hidden auto;
  }
}
.poin-el-main {
  height: 100%;
  box-sizing: border-box;
  padding: 0;
  overflow: hidden;
  .c-main-content {
    width: 100%;
    height: calc(100% - 56px);
  }
  .breadcrumb-container + .c-main-content {
    height: calc(100% - 52px);
	}
	.menuTabs{
		position: absolute;
	}
}
</style>