<template>
  <div id="myapp">
    <!-- 头部 -->
    <div id="myapp-header" class="clearfix">
      <!-- 头部左边 左上角logo与切换组织列表 -->
      <div class="domain-box fl">
        <span class="domainlogo"><img :src="RtLogoImg" id="domainlogo" /></span>
        <span class="domainlogo_title">集团公司信息化管理系统</span>
        <!-- <el-dropdown trigger="click">
          <span class="el-dropdown-link">{{ domainName }}<i class="el-icon-caret-bottom el-icon--right"></i></span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item v-for="item in domainlistArr" :key="item.id">
              <div @click="changeDomainDown(item)">{{ item.name }}</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown> -->
      </div>

      <!-- 头部右边 -->
      <div class="center-nav fr">
        <!-- 平台通知滚动信息与信息管理图标 自定义-->
        <span class="center-messinfo">
          <span class="platAdspan" @click="platAdPop" v-if="remindInfoArr.length">
            <el-carousel height="20px" direction="vertical">
              <el-carousel-item v-for="(item, index) in remindInfoArr" :key="index" :title="item">{{ item }}
              </el-carousel-item>
            </el-carousel>
          </span>
          <!-- <span class="messagespan" @click="messagespanClick" title="消息中心"><i class="el-icon-message-solid"/></span> -->
        </span>

        <ul class="center-navul">
          <!-- 锁屏图标 -->
          <li class="center-navli layui-nav-item lockcms" pc>
            <a href="javascript:;" title="消息中心" @click="messagespanClick">
              <i class="el-icon-message-solid" style="color: #0f71ff"></i>
            </a>
          </li>
          <!-- <li class="center-navli layui-nav-item lockcms" pc >
              <a href="javascript:;" @click="lockScreen" title="锁屏">
                <i class="lockScreenicon" ></i>
              </a>
            </li> -->

          <!-- 用户头像与名称 下拉个人设置与退出系统 -->
          <li class="center-navli center-navli-last">
            <div class="mysetup">
              <a href="javascript:;">
                <!-- <img src="../assets/images/face.jpg" class="centericon" /> -->
                <img src="@/assets/images/avator.png" class="centericon" />
                <span class="personal-name">{{ $root.user.name }}</span>
                <i class="fa fa-angle-down pull-down"></i>
              </a>
              <div class="personal-settings">
                <span class="triangle"></span>
                <ul>
                  <li @click="editpwd">
                    <a>
                      <i class="fa fa-user-o"></i>
                      <cite>修改密码</cite>
                    </a>
                  </li>

                  <li @click="signOut">
                    <a href="javascript:;">
                      <i class="fa fa-power-off"></i>
                      <cite>退出系统</cite>
                    </a>
                  </li>
                </ul>
              </div>
            </div>
          </li>
        </ul>
      </div>

      <!-- 消息中心 -->
      <!-- v-if="notice && showMessagePopup" -->
      <div class="prompt-popup" v-if="otherNotice.length > 0 && showMessagePopup">
        <div class="message">
          <div class="close-icon">
            <div class="message-popup-close" @click.stop="closeMessagePopup">
              <i class="fa fa-times"></i>
            </div>
          </div>
          <div class="tip" v-for="(item, index) in otherNotice" :key="index">
            <span class="tip-first">{{ item.value }}&nbsp;&nbsp;</span>
            <span v-if="item.type == '0'">新消息提醒&nbsp;</span>
            <span v-if="item.type == '1'">新公告提醒&nbsp;</span>
            <span v-else-if="item.type == '2'">新回复提醒&nbsp;</span>
            <span v-else-if="item.type == '3'">新事项提醒&nbsp;</span>
            <span class="tip-tree" @click="
                jumpToInfo({
                  id: '03',
                  name: '消息中心',
                  linkType: '03',
                  remind: 'true',
                })
              ">点击查看</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 头部菜单 -->
    <div class="top_HeaderMenu">
      <ul class="headerMenuUl">
        <li class="headerMenuLi" @click="navtopmenuclick(0)" style="margin-left: 24px" v-if="roleshow">
          <em>工作台</em>
        </li>
        <li class="headerMenuLi" @click="navtopmenuclick(6)"><em>新闻</em></li>
        <li class="headerMenuLi" v-for="(item, index) in appcateArrList" :key="index"
          @mouseover="mouseoverMenuLI(item, index)" @mouseout="mouseoutMenuLI(item, index)">
          <em>{{ item.title }}</em>
          <ul class="secondUl" v-show="item.isSubshow">
            <li class="secondli" v-for="(its, i) in item.children" :key="i" @click="loadAppMenu(its.appid, its.name)">
              <em>{{ its.name }}</em>
            </li>
          </ul>
        </li>
      </ul>
    </div>
    <!-- 中间 左边菜单与右边内容区域 -->
    <div class="myapp-content">
      <!-- 左边菜单区域 -->
      <div class="nav-bar" ref="navbar">
        <!-- 顶部菜单 -->
        <div class="nav-MenuAll" style="display: none">
          <div class="nav-topMenu">
            <!-- <a href="javascript:;" key="homemenu" data-url="" :class="activeTopmenuindex==0?'activeTop':''" @click="navtopmenuclick(0)">
                  <i><img src="~@/assets/images/home/home-link.png" /></i>
                  <cite id="homemenu">首页</cite>
                </a> -->

            <a href="javascript:;" key="workmenu" data-url="" :class="activeTopmenuindex == 0 ? 'activeTop' : ''"
              @click="navtopmenuclick(0)">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="workmenu">工作台</cite>
            </a>

            <a href="javascript:;" key="project" data-url="" :class="activeTopmenuindex == 1 ? 'activeTop' : ''"
              @click="navtopmenuclick(1)" v-if="homeTemplateBoradType == 'rtpayTemplate'">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="project">项目</cite>
            </a>

            <a href="javascript:;" key="waitmenu" data-url="" :class="activeTopmenuindex == 2 ? 'activeTop' : ''"
              @click="navtopmenuclick(2, 'menu')">
              <i><img src="~@/assets/images/home/wait-link.png" /></i>
              <cite id="waitmenu">待办</cite>
            </a>

            <a href="javascript:;" key="admenu" data-url="" :class="activeTopmenuindex == 5 ? 'activeTop' : ''"
              @click="navtopmenuclick(5)">
              <i><img src="~@/assets/images/home/message-link.png" /></i>
              <cite id="admenu">公告</cite>
            </a>

            <a href="javascript:;" key="news" data-url="" :class="activeTopmenuindex == 6 ? 'activeTop' : ''"
              @click="navtopmenuclick(6)" v-if="homeTemplateBoradType == 'rtpayTemplate'">
              <i><img src="~@/assets/images/home/news-link.png" /></i>
              <cite id="news">新闻</cite>
            </a>

            <a href="javascript:;" key="projectCenter" data-url="" :class="activeTopmenuindex == 7 ? 'activeTop' : ''"
              @click="navtopmenuclick(7)" style="display: none">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="projectCenter">项目中心</cite>
            </a>

            <a href="javascript:;" key="projectJt" data-url="" :class="activeTopmenuindex == 8 ? 'activeTop' : ''"
              @click="navtopmenuclick(8)" style="display: none">
              <i><img src="~@/assets/images/home/work-link.png" /></i>
              <cite id="projectJt">集团项目</cite>
            </a>
          </div>
          <div class="nav-bottomMenu">
            <a href="javascript:;" data-url="" @click="Im()" title="聊天" v-if="network">
              <i><img src="~@/assets/images/home/IM-link.png" /></i>
              <cite id="feedmenu"></cite>
            </a>

            <a href="javascript:;" data-url="" @click="websiteClick()" :title="website.name"
              v-if="Object.keys(website).length">
              <i><img src="~@/assets/images/home/website-link.png" /></i>
              <cite id="feedmenu"></cite>
            </a>

            <a href="javascript:;" key="domainmanager" data-url="" @click="domainmanager()" title="管理后台"
              v-if="domainAdmin">
              <i><img src="~@/assets/images/home/domain-link.png" /></i>
              <cite id="domainmanager"></cite>
            </a>

            <!-- <a href="javascript:;" data-url="" @click="feedback()" title="意见反馈" v-if="network">
                      <i><img src="~@/assets/images/home/feed-link.png" /></i>
                      <cite id="feedmenu"></cite>
                  </a> -->

            <a href="javascript:;" data-url="" @click="help()" title="办事指南" v-if="network">
              <i><img src="~@/assets/images/home/helpcenter-link.png" /></i>
              <cite id="feedmenu"></cite>
            </a>
          </div>
        </div>

        <!-- 待办菜单 -->
        <div class="nav-waitMenu" v-if="showWait">
          <a :class="activewaitmenuindex == 0 ? 'activeTop' : ''" @click="
              waitclick(0, { id: '105', name: '我的待办', linkType: '105' })
            ">
            <i><img src="~@/assets/images/home/wait2.png" /></i>
            <cite class="main-menu_title">我的待办</cite>
          </a>
          <a :class="activewaitmenuindex == 1 ? 'activeTop' : ''" @click="
              waitclick(1, { id: '104', name: '发起新建', linkType: '104' })
            ">
            <i><img src="~@/assets/images/home/wait1.png" /></i>
            <cite class="main-menu_title">发起新建</cite>
          </a>
          <!-- <a :class="activewaitmenuindex==2?'activeTop':''" @click="waitclick(2,{id:'106',name:'经办跟踪',linkType:'106'})">
                  <i><img src="~@/assets/images/home/wait3.png" /></i>
                  <cite class="main-menu_title">经办跟踪</cite>
                </a> -->
          <a :class="activewaitmenuindex == 3 ? 'activeTop' : ''" @click="
              waitclick(3, { id: '10', name: '我的待阅', linkType: '10' })
            ">
            <i><img src="~@/assets/images/home/wait4.png" /></i>
            <cite class="main-menu_title">我的待阅</cite>
          </a>
          <a :class="activewaitmenuindex == 4 ? 'activeTop' : ''" @click="
              waitclick(4, { id: '11', name: '我的已阅', linkType: '11' })
            ">
            <i><img src="~@/assets/images/home/wait5.png" /></i>
            <cite class="main-menu_title">我的已阅</cite>
          </a>
          <a :class="activewaitmenuindex == 5 ? 'activeTop' : ''" @click="
              waitclick(5, { id: '08', name: '仪表分析', linkType: '08' })
            ">
            <i><img src="~@/assets/images/home/wait6.png" /></i>
            <cite class="main-menu_title">仪表分析</cite>
          </a>
        </div>

        <!-- 左边应用菜单 v-if="showApp"-->
        <div class="nav-appMenus" v-if="showApp || showAppMENUS">
          <div class="appnametitle">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">{{ applicationName
                }}<i class="el-icon-caret-bottom el-icon--right"></i></span>
              <el-dropdown-menu class="dropdownApp" slot="dropdown">
                <el-dropdown-item v-for="item in applistArr" :key="item.id">
                  <div @click="loadAppMenu_RT(item.appid, item.name)">
                    {{ item.name }}
                  </div>
                  <!-- <div @click="loadAppMenu(item.id,item.name)">{{item.name}}</div> -->
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!-- 左 应用菜单区域 -->
          <el-scrollbar>
            <main_navbar :appid="appid" :key="appid" :updateMenu="updateMenu" :updateMenuData="updateMenuData"
              @add-tab="addTab" ref="mainNavBar" />
          </el-scrollbar>
          <!-- 中间切换伸缩按钮 -->
          <div class="openExpand" title="开关菜单" ref="opencloseExpandRef" :class="opencloseExpandBtnFlag?'':'closeExpand'"><img src="~@/assets/images/icon_arrow.png" @click="opencloseExpandBtn(1)" :class="opencloseExpandBtnFlag?'openFlag':'closeFlag'"/></div>  
        </div>
      </div>

      <!-- 右边内容区域，包括选项卡 -->
      <main_content 
        ref="mychild" 
        :tabs="tabs" 
        :opencloseExpandBtnFlag="opencloseExpandBtnFlag"      
        @add-tab="addTab" 
        @close-tab="closeTab" 
        @close-all="closeAllTab"
        @active-tab="activeTab"
        @active-home="activeHome" 
        @updateViewNumber="updateViewNumber" 
        v-bind="$attrs"
        v-on="$listeners"
      />
    </div>

    <!--一键锁屏弹窗区域-->
    <div class="lockWraper" v-if="isLock == 'true'">
      <div class="lock-content">
        <div class="img">
          <img src="../assets/images/avator.png" alt="" />
        </div>
        <div class="admin-header-lock-name">
          {{ $root.user.name }}
        </div>
        <div class="input_btn">
          <span class="input-box">
            <div class="error-tip" v-if="isPasswordError == 'true'">
              密码错误，请重新输入!
            </div>
            <el-input
                @input="changePassword($event)"
                @keyup.enter.native="unlockScreen"
                v-model="password" 
                type="password" 
                class="admin-header-lock-input layui-input" 
                placeholder="请输入密码解锁.." 
                name="lockPwd" 
                id="lockPwd"></el-input> 
          </span>
          <span class="un-lock" @click="unlockScreen"> 解锁 </span>
        </div>
        <div class="tip">{{errorTip ? errorTip : '请输入登录密码，否则不会解锁成功哦！！！'}}</div>
      </div>
    </div>
    <!-- 超时登录界面弹窗区域 -->
    <div>
      <el-dialog title="超时登录" :visible.sync="dialogVisible" width="30%" :modal="true" :close-on-click-modal="false"
        :close-on-press-escape="false" :show-close="false">
        <el-form size="mini" label-width="80px">
          <el-form-item label="登录账户">
            <el-input v-model="$store.state.myProfile.loginNo" autocomplete="off" disabled style="width: 220px">
            </el-input>
          </el-form-item>
          <el-form-item label="登录密码">
            <el-input v-model="pwd" autocomplete="off" show-password style="width: 220px"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="hanleClickLogin" size="mini">回到登录界面</el-button>
          <el-button type="primary" @click="hanleClick" size="mini">登录</el-button>
        </div>
      </el-dialog>
    </div>

    <!-- 组织域弹窗列表区域 -->
    <div>
      <el-dialog :close-on-click-modal="false" :visible.sync="domainDialogVisible" width="50%" append-to-body>
        <main_domain :domainList="domainList"></main_domain>
      </el-dialog>
    </div>

    <!-- Im聊天弹窗区域 -->
    <IMPop :showdialog.sync="showdialog" ref="PopChildren"></IMPop>

    <!-- 右上角平台通知  弹窗区域 -->
    <platAdPop :showdialogPlatAd.sync="showdialogPlatAd" ref="PopChildrenPlatAd"></platAdPop>
    <el-dialog
        title="修改密码通知"
        :visible.sync="updatePwdDialogVisible"
        width="30%"
        center
        append-to-body
        :modal="true"
        :show-close="updatePasswordType!='1'"
        :close-on-click-modal="false"
        custom-class="custom-dialog"
        style="margin-top: 20vh;"
        >
        <span style="color: red; text-align: center; font-size: 16px">{{updatePasswordMsg}}</span>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="upadtePwdConfirm">已了解，前往修改密码</el-button>
        </span>
      </el-dialog>
      
      <!-- 修改密码弹窗 -->
      <update-password-dialog 
        :visible.sync="showPasswordDialog" 
        :can-close="updatePasswordType!='1'"
        @success="onPasswordUpdateSuccess"
         @close="showPasswordDialog = false"
      />
  </div>
</template>

<script>
import main_appbar from "@/components/main_appbar.vue";
import main_navbar from "@/components/main_navbar.vue";
import main_content from "@/components/main_content.vue";
import main_domain from "@/components/domain.vue";
import IMPop from "./IMPop.vue";
import platAd from "@/components/platAd.vue";
import platAdPop from "@/components/platAdPop.vue";
import Constant from "@/Constant.js";
import config from "../../public/js/obpm.config.js";
import API from "@/api.js";
import { currDate } from "@/utils/global.js";
import RtLogoImg from "@/assets/images/RTImgs/rtloginlogo.png";
let Base64 = require("js-base64").Base64;
const statiContextPath = config.statiContextPath;
const signonContextPath = config.signonContextPath;
import { mapState } from "vuex";
// import mixin_LockScreen from './mixin_LockScreen'//引入超时锁屏功能
import UpdatePasswordDialog from '@/components/UpdatePasswordDialog.vue'; // 修改密码弹窗

export default {
  name: "mainpage",
  // mixins:[mixin_LockScreen],//混入超时锁屏功能--rt不加入锁屏
  provide() {
    return {
      addTab: this.addTab,
    };
  },
  components: {
    "obpm-main-appbar": main_appbar,
    main_navbar,
    main_content,
    main_domain,
    IMPop,
    platAd,
    platAdPop,
    UpdatePasswordDialog
  },

  computed: {
    ...mapState({
      //这里的...不是省略号了,是对象扩展符
      // headPhoto:(state)=>state.myProfile.headPhoto,
      showAppMENUS(state) {
        if (state.appmenusShow) {
          this.$nextTick(() => {
            this.showApp = true;
            this.$refs.mychild.setMaincontent(false); // 调用子组件的方法
            this.activeHome();
            this.applist(); //查询左边下拉应用列表
            console.log(this.$refs.mainNavBar.data);
            if (state.defaultFirst == 1) {
              this.$refs.mainNavBar.defaultClickFirst(
                this.$refs.mainNavBar.data
              );
            }
          });
        }
        return state.appmenusShow;
      },
    }),
    applicationName() {
      if (this.$store.state.appmenusShow) {
        this.$nextTick(() => {
          this.showApp = true;
          this.$refs.mychild.setMaincontent(false); // 调用子组件的方法
          this.applist(); //查询左边下拉应用列表
          console.log(this.$refs.mainNavBar.data);
          if (this.$store.state.defaultFirst == 1) {
            this.$refs.mainNavBar.defaultClickFirst(this.$refs.mainNavBar.data);
          }
        });
      }
      let currentAppName = "";
      if (this.$store.getters.currentAppName.indexOf("-") > -1) {
        let currentAppNameIndex =
          this.$store.getters.currentAppName.indexOf("-");
        currentAppName = this.$store.getters.currentAppName.substr(
          0,
          currentAppNameIndex
        );
      } else {
        currentAppName = this.$store.getters.currentAppName;
      }
      console.log(currentAppName);
      return currentAppName;
    },
    showInstance() {
      return this.$store.state.isInstance;
    },
  },
  // created() {
  //     // let user = this.$root.user;//main.js获取user用户信息
  //     // let obj = {
  //     //   doId: user&&user.domainId||"",
  //     //   userId: user&&user.id,
  //     //   profile: user,
  //     // }
  //     // this.$store.commit('landingUser', obj);//查询登录用户

  //     // this.Searchdomain()//查询所有组织
  // },
  created() {
    this.checkPasswordUpdateNotice()
    this.domainlistArr = JSON.parse(localStorage.getItem("domainList")) || [];

    if (
      this.domainlistArr.length &&
      this.homeTemplateBoradType != "rtpayTemplate"
    ) {
      //rt环境不要提示
      this.organizationsID(localStorage.getItem("domainId")); //根据组织id获取注册地
    }

    if (this.homeTemplateBoradType == "rtpayTemplate") {
      //rt环境判断权限-工作台权限划分-集团领导可以看到现有设计工作台-子公司看不到工作台入口
      this.roleAuthShow();
    }

    // this.getLock()//锁屏

    window.setInterval(() => {
      setTimeout(this.getOnlineNumber, 0); //定时查询公告数量
    }, 60000);

    let radomNum = new Date().getTime();

    this.$api.getMessage(
      //消息
      radomNum,
      {
        onSucess: (res) => {
          this.notice = res.data.data.notice;
        },
      }
    );

    this.$api.getNotificationNum(
      //消息公告数字
      {
        onSucess: (res) => {
          let otherNotice = res.data.data;
          let arr = [];
          for (let key in otherNotice) {
            let obj = {};
            if (otherNotice[key] > 0 && key != "size") {
              obj.type = key.toString();
              obj.value = otherNotice[key];
              arr.push(obj);
            }
          }
          this.otherNotice = arr;
          console.log("this.otherNotice---->", this.otherNotice);
        },
      }
    );

    this.network = __network__; //获取__network__全局变量状态，判断显示隐藏
    this.applistIframe(); //查询所有分类与列表--rt顶部菜单
    this.myprofile();

    this.$api.bcxplatAdlistApi(
      {},
      {
        //右上角平台通知提示信息
        onSucess: (res) => {
          if (res.data.errcode == 0) {
            let listArr = res.data.data.data;
            if (listArr.length) {
              listArr.forEach((item) => {
                if (
                  currDate(true) >= item.items.__G3lF6FIrSTspuF06jEr.value &&
                  currDate(true) <= item.items.__eG17lW4psp4yq1aT0Pt.value
                ) {
                  //在当前时间范围内提醒
                  this.remindInfoArr.push(
                    item.items.__04C3Fur4uYFpos1vlSP.value
                  );
                }
              });
            }
          }
        },
      }
    );
  },
  data() {
    return {
      RtLogoImg,
      appid: "km1",
      tabs: [],
      password: "",
      isLock: "false",
      notice: 0,
      otherNotice: [],
      showMessagePopup: true,
      showMenu: true,
      Constant,
      updateMenu: "",
      updateMenuData: {},
      dialogVisible: false,
      domainDialogVisible: false,
      pwd: "",
      isPasswordError: "",
      isChangeDomain: false,
      domainList: [],
      nullPrompt: "",
      activeTopmenuindex: 0,
      activewaitmenuindex: -1, //待办默认不选中
      showWait: false,
      showApp: false,
      appname: "",
      applistArr: [],
      domainlistArr: [],
      logo: "",
      showdialog: false,
      showdialogPlatAd: false, //平台通知 弹窗
      remindInfoArr: [], //提醒消息数组列表
      platinfoli: "", //右上角平台消息第一条
      platStartTime: "", //提醒开始时间
      platEndTime: "", //提醒结束时间
      remindFlag: false, //在当前时间范围内提醒,默认不提醒显示
      domainAdmin: localStorage.getItem("domainAdmin") == "true" ? true : false, //是否是组织管理员
      website: {}, //官网名称与地址对象
      network: true, //获取__network__全局变量状态，判断显示隐藏
      domainName: localStorage.getItem("domainName") || "",
      headPhoto: "",
      homeTemplateBoradType:localStorage.getItem("homeTemplateBoradType") || "payTemplate",
      appcateArrList: [], //工作台应用分类
      roleshow: false,
      opencloseExpandBtnFlag:true,//开关菜单状态
      errorTip: '',
      updatePasswordType: localStorage.getItem('updatePasswordType') || '',
      updatePasswordMsg: localStorage.getItem('updatePasswordMsg') || '',
      updatePwdDialogVisible: false,
      showPasswordDialog: false,
    };
  },

  methods: {
    upadtePwdConfirm() {
      this.updatePwdDialogVisible = false
      this.showPasswordDialog = true
    },
    // 检查并显示密码修改提示
    checkPasswordUpdateNotice() {
      console.log('this.updatePasswordType', this.updatePasswordType, this.updatePasswordMsg)
      if (this.updatePasswordType && this.updatePasswordMsg) {
        this.updatePwdDialogVisible = true
        if (this.updatePasswordType === '2') {
          localStorage.removeItem('updatePasswordType');
          localStorage.removeItem('updatePasswordMsg');
        } 
      }
    },
    
    onPasswordUpdateSuccess() {
      this.showPasswordDialog = false;
      this.$message({
        message: '密码修改成功',
        type: 'success'
      });
      
      // 如果是强制修改密码，修改成功后清除状态
      if (this.updatePasswordType === '1') {
        localStorage.removeItem('updatePasswordType');
        localStorage.removeItem('updatePasswordMsg');
      }
    },
    opencloseExpandBtn(flag){//中间切换伸缩按钮点击事件
      if(flag){
        this.opencloseExpandBtnFlag=!this.opencloseExpandBtnFlag
      }
      if(this.opencloseExpandBtnFlag){//中间按钮是展开状态与菜单显示--rt项目应用左边菜单特有样式
        this.$nextTick(()=>{
          this.$refs.navbar.style.display='flex'
          this.$refs.navbar.style.width='186px'
          this.$refs.mychild.$refs.mainHomeContent.style.left='186px'
          this.$refs.opencloseExpandRef.style.left='186px'  
        })
      }else{
        this.$nextTick(()=>{
          this.$refs.navbar.style.display='block'
          this.$refs.navbar.style.width='0px'
          this.$refs.mychild.$refs.mainHomeContent.style.left='0px'
          this.$refs.opencloseExpandRef.style.left='0px'
        })
      }
    },
    roleAuthShow() {
      this.$api.RtrolePermissiondisplay(
        {},
        {
          onSucess: (response) => {
            console.log(response.data);
            this.roleshow = response.data.show || false;
            if (!this.roleshow) {
              this.navtopmenuclick(6);
            }
          },
        }
      );
    },
    applistIframe() {
      let data = {
        //只查询电脑端应用
        search_clientype: "电脑端",
      };
      this.$api.getApplicationsAll(data, {
        onSucess: (response) => {
          if (response.data && response.data.errmsg == "ok") {
            console.log(response.data);
            if (response.data.data.data.length) {
              let arr = [];
              response.data.data.data.forEach((item, index) => {
                let obj = {};
                let obj2 = {};
                obj.title = item.items["__4ReuvgLxTKieJDzGu2L"].value;
                obj.cateSort = item.items["__sJO2jdvlNEznauT5KQa"].value; //分类排序

                obj.children = [];
                obj2.img = item.items["__oTDoKOfuYRsmXS7DfDk"].value
                  ? JSON.parse(item.items["__oTDoKOfuYRsmXS7DfDk"].value)[0]
                      .path
                  : ""; //应用图标
                obj2.name = item.items["__M0NXUq24HGrzQrmjLwj"].value; //应用名称
                obj2.appid = item.items["__ZLG2HsnA374L6Ww4X6P"].value; //应用id
                obj2.appSort = item.items["__zsh5fkZEXwof08KVNMe"].value; //应用id

                obj.children.push(obj2);
                arr.push(obj);
              });
              console.log(arr);
              arr.sort((a, b) => {
                return Number(a.cateSort) - Number(b.cateSort);
              }); //分类排序cateSort

              const titleMap = {};
              const transferObj = arr.reduce((prev, next) => {
                if (titleMap[next.title]) {
                  prev[next.title].children.push(...next.children);
                } else {
                  titleMap[next.title] = true;
                  prev[next.title] = { children: next.children };
                }
                return prev;
              }, {});

              let arr2 = [];
              for (let i in transferObj) {
                let obj = {};
                obj.title = i;
                transferObj[i].children.sort((a, b) => {
                  return Number(a.appSort) - Number(b.appSort);
                }); //应用排序cateSort
                obj.children = transferObj[i].children;
                arr2.push(obj);
              }

              if (location.host.indexOf("v5qy.test.baibaodun.cn") > -1) {
                if (
                  localStorage.getItem("domainId") != "__2gH5luUlviULa7KnmqW"
                ) {
                  //临时过滤使用--后期删除--测试117环境
                  arr2.forEach((item, index) => {
                    item.children.forEach((its, ix) => {
                      if (its.name == "组织权益") {
                        if (item.children.length == 1) {
                          arr2.splice(index, 1);
                        }
                        item.children.splice(ix, 1);
                      }
                    });
                  });
                }
              } else {
                if (
                  localStorage.getItem("domainId") != "__Qqg3L4GhNXG4iRAmcTB"
                ) {
                  //临时过滤使用--后期删除--正式环境
                  arr2.forEach((item, index) => {
                    item.children.forEach((its, ix) => {
                      if (its.name == "组织权益") {
                        if (item.children.length == 1) {
                          arr2.splice(index, 1);
                        }
                        item.children.splice(ix, 1); //不在这个组织，组织权益应用隐藏删除
                      }
                    });
                  });
                }
              }
              console.log(arr2);
              arr2.forEach((its) => {
                its.isSubshow = false;
              });

              this.appcateArrList = arr2;

              //前端缓存本地代码块--切换不同组织的所有应用列表
              //  let HomeApplist_board={employeeIdStr:localStorage.getItem('employeeId'),appcateArrListStr:this.appcateArrList}
              //  localStorage.setItem('HomeApplist_board',JSON.stringify(HomeApplist_board))
            }
          }
        },
      });
    },
    loadAppMenu(appId, name) {
      //点击应用列表查询左边应用菜单
      // debugger
      if (appId == "__Hab04s0VNDPrjFZ3Xlo") {
        //RT挂图作战应用直接打开项目中心首页
        this.navtopmenuclick(1);
        return;
      }

      if (appId == "__ua9GbvpRSyUUOPzqK5y") {
        //RT项目中心应用直接打开项目中心页面
        this.navtopmenuclick(7);
        return;
      }

      if (appId == "__nvk0VeqSX1E9JCDd9fP") {
        //RT集团项目应用直接打开集团项目页面
        this.navtopmenuclick(8);
        return;
      }

      if (appId != "km" && appId != "pm" && appId != "qm") {
        this.$root.appid = appId || "";
      }

      let flag = 1;
      this.$store.dispatch("loadMenus", { appId, name, flag });
      if (appId == "__d1qEDy3wYq8VF5KvUoE") {
        //智能人事（__xkeybkGaZa1SboC9GL1）、机构用户管理（__d1qEDy3wYq8VF5KvUoE）
        let obj = { name, appId };
        localStorage.setItem("appidSupervise", JSON.stringify(obj));
      }
    },
    organizationsID(id) {
      //北京系统提醒
      this.$api.organizationsIDApi(id, {
        onSucess: (res) => {
          console.log(res);
          console.log(res.data.data.placeOfRegister);
          if (
            res.data.data.placeOfRegister &&
            res.data.data.placeOfRegister.province.name.indexOf("北京") > -1
          ) {
            this.$alert(
              "尊敬的系统管理员：<br/>4月12日-5月13日为系统升级阶段，为了确保数据准确性，升级期间，业务数据办理等工作仍在旧系统中进行操作，数据以旧系统为准！<br/>新系统现阶段仅供熟悉及了解，不可对自己的组织进行数据增减删的操作！若要试用，请通过试用组织进行操作。给您带来的不便敬请谅解。如有问题，请第一时间联系您的专属客服经理或者拨打4006629696",
              "系统通知",
              {
                confirmButtonText: "确定",
                dangerouslyUseHTMLString: true,
                callback: (action) => {},
              }
            );
          }
        },
      });
    },
    mouseoverMenuLI(item, index) {
      this.appcateArrList.forEach((its) => {
        its.isSubshow = false;
      });
      item.isSubshow = true;
    },
    mouseoutMenuLI(item, index) {
      this.appcateArrList.forEach((its) => {
        its.isSubshow = false;
      });
    },
    myprofile() {
      sessionStorage.setItem("myProfileName", this.$root.user.name); //存储iM聊天登录用户名
      sessionStorage.setItem("loginNo", this.$root.user.telephone); //存储iM聊天登录手机号--IM废弃，改为imIdentity
      sessionStorage.setItem("imIdentity", this.$root.user.imIdentity || ""); //存储iM聊天登录---存储iM标识符，根据这个标识符获取im的sig秘钥
      let headPhotoUrl = this.$root.user.headPhoto;
      if (headPhotoUrl.indexOf("http") > -1) {
        this.headPhoto = headPhotoUrl;
      } else {
        this.headPhoto = window.location.origin + "/obpm" + headPhotoUrl;
      }

      localStorage.setItem("headPhotoStr", this.headPhoto); //保存本地头像地址

      let data = { s_comId: localStorage.getItem("domainId") }; //根据组织id获取官网
      this.$api.getWebSiteApi(data, {
        onSucess: (res) => {
          if (res.data.data.data) {
            let name = res.data.data.data[0].items.__d7xhxbGk9975pvHmwrv.value;
            let url = res.data.data.data[0].items.__zHBRHJJEwYAZxLwUhyO.value;
            this.website = { name, url };
          }
        },
      });

      this.$api.getEnterpriseUserinfo(localStorage.getItem("domainId"), {
        onSucess: (res) => {
          console.log(res);
          if (res.data.status == 200) {
            document.title = res.data.data.sysName || ""; //系统名称
            //获取icon图标
            var link =
              document.querySelector("link[rel*='icon']") ||
              document.createElement("link");
            link.type = "image/x-icon";
            link.rel = "shortcut icon";
            link.href = this.RtLogoImg;
            // link.href="http://v5qy.test.baibaodun.cn/obpm/uploads/lib/icon/upload/1.jpg"
            // if (res.data.data.logoPath.indexOf("http") > -1) {
            //   link.href = `${res.data.data.logoPath}`; //浏览器图标企业logo
            // } else {
            //   link.href = `${obpmConfig.obpmFilePath}/uploads/lib/icon${res.data.data.logoPath}`; //浏览器图标企业logo
            // }
            document.getElementsByTagName("head")[0].appendChild(link);
            // console.log("查询用户信息")
            // console.log(res.data.logoUrl)
            // console.log(res.data.logoUrl)
            if (res.data.data.logoPath.indexOf("http") > -1) {
              this.logo = res.data.data.logoPath;
            } else {
              if (res.data.data.logoPath) {
                this.logo = `${obpmConfig.obpmFilePath}/uploads/lib/icon${res.data.data.logoPath}`;
              } else {
                this.logo = "";
              }
            }
          }
        },
      });
    },
    Im() {
      //点击聊天弹窗显示
      this.showdialog = true;
    },
    platAdPop() {
      //平台通知消息滚动弹窗
      this.$refs.PopChildrenPlatAd.show();
    },
    messagespanClick() {
      //右上角消息图标点击
      this.showWait = false;
      this.showApp = false;
      this.$store.state.appmenusShow = false;
      this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
      this.addTab({
        id: "03",
        name: "消息中心",
        linkType: "03",
        remind: "true",
      });
    },
    editpwd() {
      //右上角下拉修改密码
      this.showWait = false;
      this.showApp = false;
      this.$store.state.appmenusShow = false;
      this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
      this.addTab({ id: "02", name: "修改密码", linkType: "102" });
    },
    help() {
      //帮助
      this.showWait = false;
      this.showApp = false;
      this.$store.state.appmenusShow = false;
      this.$refs.mychild.setMaincontent(true); // 调用子组件的方法

      var param = {
        id: "help",
        name: "办事指南",
        linkType: "07",
        actionContent: `/static/signon/help/index.html?v=${Date.now()}#/home`,
        icon: "",
        key: "",
      };
      this.addTab(param);
    },
    feedback() {
      //意见反馈
      let loginNo = sessionStorage.getItem("loginNo");
      let myProfileName = sessionStorage.getItem("myProfileName");
      window.open(
        `https://support.qq.com/product/321476?nickname=${myProfileName}&avatar=xxx&openid=${loginNo}`
      );
    },
    websiteClick() {
      //官网
      if (this.website.url) {
        window.open(this.website.url);
      }
    },
    domainmanager() {
      //切换组织管理
      this.showWait = false;
      this.showApp = false;
      this.$store.state.appmenusShow = false;
      this.$refs.mychild.setMaincontent(true); // 调用子组件的方法

      let domainId = localStorage.getItem("domainId");
      var param = {
        id: "domainmanager",
        name: "管理后台",
        linkType: "07",
        actionContent: `/static/signon/domainCompany/index.html?v=${Date.now()}#/domain?domainId=${domainId}`,
        icon: "",
        key: "",
      };
      this.addTab(param);
    },
    changeDomainDown(item) {
      //头部左上角切换组织--新版本直接从缓存里面获取
      if (item.name) {
        localStorage.setItem("accessToken", item.accessToken); //切换组织，重新获取新的accessToken
        localStorage.setItem("domainName", item.name); //存储组织域名称--给员工管理-甲方
        localStorage.setItem("domainId", item.id); //域id
        localStorage.setItem("domainAdmin", item.domainAdmin); //是否是组织管理员
        localStorage.setItem("employeeId", item.employeeId); //保存当前公司的当前用户
        localStorage.setItem("institutionalCode", item.institutionalCode); //机构类型
        window.location.reload(); //重新刷新页面
      }
    },
    Searchdomain() {
      //查询所有组织---注释掉，从登录跳转页获取
    },
    navtopmenuclick(index, type, url, title) {
      this.showWait = false;
      this.showApp = false;
      this.activeTopmenuindex = index;
      if (index === 0) {
        //首页--工作台
        this.showApp = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        this.activeHome();
        this.applist(); //查询左边下拉应用列表
        return;
      }
      if (index === 1) {
        //项目
        this.showApp = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        var param = {
          id: "project",
          name: "项目",
          linkType: "07",
          actionContent: `/static/signon/project/index.html?v=${Date.now()}#/Project`,
          icon: "icon-1",
          key: "project",
        };
        this.addTab(param);
        return;
      }
      if (index === 2) {
        //待办
        this.showWait = true;
        this.$store.state.appmenusShow = false;
        if (type == "menu") {
          this.waitclick(0, { id: "105", name: "我的待办", linkType: "105" }); //默认点击第一个待办菜单
        }
        this.$refs.mychild.setMaincontent(false); // 调用子组件的方法
        return;
      }
      if (index === 3) {
        //工作台
        this.showApp = true;
        this.$refs.mychild.setMaincontent(false); // 调用子组件的方法
        var param = {
          id: "workmenu",
          name: "工作台",
          linkType: "application",
          actionContent: "",
          icon: "-1",
          key: "",
        };
        this.addTab(param); //新组件Tab
        this.applist(); //查询左边下拉应用列表
        return;
      }
      if (index === 4) {
        //知识库
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        return;
      }
      if (index === 5) {
        //公告
        this.showWait = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        var param = {
          id: "ad",
          name: "公告",
          linkType: "ad",
          actionContent: "",
          notice: this.notice,
          icon: "",
          key: "",
        };
        this.addTab(param);
        return;
      }
      if (index === 6) {
        //新闻
        this.showApp = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        var param = {};
        if (type == "news" && url) {
          param = {
            id: "news" + title,
            name: title,
            linkType: "07",
            actionContent: url,
            icon: "icon-1",
            key: "news" + title,
          };
        } else {
          param = {
            id: "news",
            name: "新闻",
            linkType: "07",
            actionContent: `/static/signon/news/index.html?v=${Date.now()}#/`,
            icon: "icon-1",
            key: "news",
          };
        }
        this.addTab(param);
        return;
      }
      if (index === 7) {
        //项目中心
        this.showApp = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        var param = {
          id: "projectCenter",
          name: "项目中心",
          linkType: "07",
          actionContent: `/static/signon/project/index.html?v=${Date.now()}#/projectCenter`,
          icon: "icon-1",
          key: "projectCenter",
        };
        this.addTab(param);
        return;
      }
      if (index === 8) {
        //集团项目
        this.showApp = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
        var param = {
          id: "projectJt",
          name: "集团项目",
          linkType: "07",
          actionContent: `/static/signon/project/index.html?v=${Date.now()}#/projectJt`,
          icon: "icon-1",
          key: "projectJt",
        };
        this.addTab(param);
        return;
      }
    },
    waitclick(index, obj) {
      //待办菜单点击
      this.activewaitmenuindex = index;
      this.addTab(obj);
    },
    applist() {
      //查询左边--下拉应用列表

      // if(localStorage.getItem('HomeApplist_board')&&JSON.parse(localStorage.getItem('HomeApplist_board')).employeeIdStr==localStorage.getItem('employeeId')){//前端走缓存，职员id一样，多次刷新不走接口，走缓存
      //    this.applistArr=JSON.parse(localStorage.getItem('HomeApplist_board')).appcateArrListStr
      //    return
      // }

      let data = {
        //只查询电脑端应用
        search_clientype: "电脑端",
      };
      this.$api.getApplicationsAll(data, {
        onSucess: (response) => {
          if (response.data && response.data.errmsg == "ok") {
            console.log(response.data);
            if (response.data.data.data.length) {
              let arr = [];
              response.data.data.data.forEach((item, index) => {
                let obj = {};
                let obj2 = {};
                obj.title = item.items["__4ReuvgLxTKieJDzGu2L"].value;
                obj.cateSort = item.items["__sJO2jdvlNEznauT5KQa"].value; //分类排序

                obj.children = [];
                obj2.img = item.items["__oTDoKOfuYRsmXS7DfDk"].value
                  ? JSON.parse(item.items["__oTDoKOfuYRsmXS7DfDk"].value)[0]
                      .path
                  : ""; //应用图标
                obj2.name = item.items["__M0NXUq24HGrzQrmjLwj"].value; //应用名称
                obj2.appid = item.items["__ZLG2HsnA374L6Ww4X6P"].value; //应用id
                obj2.appSort = item.items["__zsh5fkZEXwof08KVNMe"].value; //应用id

                obj.children.push(obj2);
                arr.push(obj);
              });
              console.log(arr);
              arr.sort((a, b) => {
                return Number(a.cateSort) - Number(b.cateSort);
              }); //分类排序cateSort

              const titleMap = {};
              const transferObj = arr.reduce((prev, next) => {
                if (titleMap[next.title]) {
                  prev[next.title].children.push(...next.children);
                } else {
                  titleMap[next.title] = true;
                  prev[next.title] = { children: next.children };
                }
                return prev;
              }, {});

              let arr2 = [];
              for (let i in transferObj) {
                let obj = {};
                obj.title = i;
                transferObj[i].children.sort((a, b) => {
                  return Number(a.appSort) - Number(b.appSort);
                }); //应用排序cateSort
                obj.children = transferObj[i].children;
                arr2.push(obj);
              }

              let arr3 = [];
              arr2.forEach((item) => {
                item.children.forEach((its) => {
                  let obj = {};
                  obj.appid = its.appid;
                  obj.name = its.name;
                  arr3.push(obj);
                });
              });

              if (location.host.indexOf("v5qy.test.baibaodun.cn") > -1) {
                if (
                  localStorage.getItem("domainId") != "__2gH5luUlviULa7KnmqW"
                ) {
                  //临时过滤使用--后期删除--测试117环境
                  arr3 = arr3.filter((item) => {
                    return item.appid != "__gZxrYDgj8OpfztxSuUg";
                  });
                }
              } else {
                if (
                  localStorage.getItem("domainId") != "__Qqg3L4GhNXG4iRAmcTB"
                ) {
                  //临时过滤使用--后期删除--正式环境
                  arr3 = arr3.filter((item) => {
                    return item.appid != "__gZxrYDgj8OpfztxSuUg"; //不在这个组织，组织权益应用隐藏
                  });
                }
              }
              console.log(arr3);
              this.applistArr = arr3;

              //前端缓存本地代码块--切换不同组织的所有应用列表
              //  let HomeApplist_board={employeeIdStr:localStorage.getItem('employeeId'),appcateArrListStr:this.applistArr}
              //  localStorage.setItem('HomeApplist_board',JSON.stringify(HomeApplist_board))
            }
          }
        },
      });
    },
    loadAppMenu_RT(appId, name) {
      //点击右边application.vue应用列表 查询左边应用菜单
      if (appId != "km" && appId != "pm" && appId != "qm") {
        this.$root.appid = appId;
      }
      this.$store.dispatch("loadMenus", { appId, name });
      if (appId == "__xkeybkGaZa1SboC9GL1") {
        //智能人事（__xkeybkGaZa1SboC9GL1）、机构用户管理（__d1qEDy3wYq8VF5KvUoE）
        let obj = { name, appId };
        localStorage.setItem("appidSupervise", JSON.stringify(obj));
      }
    },
    updateViewNumber(menuData) {
      this.updateMenuData = menuData;
      this.updateMenu = new Date().getTime();
    },
    hiddenMenu() {
      this.showMenu = !this.showMenu;
      this.$refs.mychild.setMaincontent(); // 调用子组件的方法
    },

    jumpToInfo(val) {
      this.showMessagePopup = false;
      this.addTab(val);
    },

    closeMessagePopup() {
      this.showMessagePopup = false;
    },

    signOut() {
      //退出系统

      let statiContextPath = obpmConfig.statiContextPath;
      let signonContextPath = obpmConfig.signonContextPath;
      let url = "";
      if (statiContextPath) {
        //5.0 trunk
        url =
          window.location.origin +
          statiContextPath +
          signonContextPath +
          "/index.html"; // http://49.4.123.194/static/signon/index.html
      }
      window.location.href = url;

      this.$api.removeOnlineUser({
        onSucess: (res) => {
          if (res.status == 200) {
            console.log("res--->", res.status);
          }
        },
      });
      this.$api.LogOut({
        onSucess: (res) => {},
      });
      let cookies = document.cookie.match(/[^=;]+(?=\=)/g);
      if (cookies) {
        for (let i = cookies.length; i--; ) {
          document.cookie =
            cookies[i] + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
        }
      }
      // localStorage.clear();
    },

    getLock() {
      //一键锁屏
      let val = sessionStorage.getItem("screenLock");
      if (val) {
        this.isLock = val;
      } else {
        this.isLock = "false";
      }
    },

    getOnlineNumber() {
      //定时查询公告数量
      this.$api.getNotification({
        onSucess: (res) => {
          if (res.data.data.data && res.data.data.data.length > 0) {
            let data = res.data.data.data[0];
            this.$notify({
              title: "",
              dangerouslyUseHTMLString: true,
              message: "你有一条新消息",
              duration: 5000,
              customClass: "fontclass",
            });
          }
        },
      });
    },

    // systemManagement(){//进入组织管理后台
    //   let domainid = localStorage.getItem("domainId");
    //   let domainName;//企业域名称
    //   for(let i = 0; i < this.domainList.length; i ++) {
    //     if(domainid === this.domainList[i].id) {
    //       domainName = this.domainList[i].name
    //     }
    //   }
    //   let statiContextPath = obpmConfig.statiContextPath;
    //   let systemUrl = '';
    //   if(statiContextPath) { //5.0 trunk
    //     systemUrl = obpmConfig.statiContextPath + "/domain/index.html#/domain?domainid=" + domainid + "&from=systemManagement" + "&name=" + domainName;//&from=systemManagement让deisgner那边可以获取到标识
    //   }else { //4.4 stable
    //     systemUrl = obpmConfig.obpmFilePath + "/domain/index.html#/domain?domainid=" + domainid + "&from=systemManagement" + "&name=" + domainName;
    //   }
    //   window.open(systemUrl);//新窗口打开组织管理后台
    // },

    changeDomain() {
      this.domainDialogVisible = true;
    },

    //退出系统
    Actionquit() {
      API.LogOut({
        onSucess: (response) => {
          if (response.status == 200) {
            window.location = "http://localhost:8080/signon/";
          }
        },
        onError: (error) => {
          console.log(error);
        },
      });
    },

    hanleClickLogin() {
      //超时登录界面弹窗--回到登录界面
      let statiContextPath = obpmConfig.statiContextPath;
      let url = "";
      if (statiContextPath) {
        //5.0 trunk
        url =
          "http://" +
          window.location.host +
          statiContextPath +
          "/signon/index.html";
      } else {
        //4.4 stable
        url = "http://" + window.location.host + "/signon/index.html";
      }
      window.location.href = url;
    },

    hanleClick() {
      //超时登录界面弹窗--登录
      let cookie = document.cookie.split(";");
      let language, url, path;
      for (let i = 0; i < cookie.length; i++) {
        if (cookie[i].indexOf("USERLANGUAGE") >= 0) {
          language = cookie[i].split("=")[1];
        }
      }
      let str = Base64.encode(this.pwd);
      let userPwd;
      if (str.length > 2) {
        let lp = str.substr(0, 2);
        let rp = str.substr(2, str.length);
        userPwd = rp + lp;
      }
      let data = {
        username: this.$store.state.myProfile.loginNo,
        password: userPwd,
        remember: "0",
        debug: false,
        domainName: this.$store.state.myProfile.domainName,
        checkcode: "",
        language: language,
        url: url,
        path: path,
      };
      this.$api.signonLogin(data, {
        onSucess: (res) => {
          if (res.data.resultCode != 0) {
            //更新accessToken
            document.cookie = res.data.accessToken;
            localStorage.setItem("accessToken", res.data.accessToken);
            this.pwd = "";
            this.dialogVisible = false;
            this.$message({
              message: "登录成功",
              type: "success",
            });
          } else {
            this.$message.error("登录失败，输入密码有误");
          }
        },
      });
    },
    //一键锁频
    lockScreen() {
      if(this.$store.state.lastTimeFlag==false) return;//iframe嵌套第三方，如员工保险应用，企业钱包关闭锁屏
      this.password = "";
      this.isLock = "true";
      sessionStorage.setItem("screenLock", "true");
    },

    changeMenu: function (appid) {
      this.appid = appid;
    },

    activeHome: function () {
      //点击首页，去掉所有tab选项卡
      this.tabs.forEach(function (value) {
        value.active = false;
      });
      this.showWait = false;
      this.showApp = false;
      this.$store.state.appmenusShow = false;
    },

    addTab(param) {
      //核心，左边菜单---应用菜单点击显示 右边iframe Tab模式
      // debugger
      param.currentAppName = this.$store.getters.currentAppName; //获取vuex应用名称--核心代码
      var flag = false;
      this.tabs.forEach(function (value) {
        if (value.id && value.id == param.id) {
          value.active = true;
          if (param.linkType == "01") {
            //视图
            value.randomNumber = param.randomNumber;
          }
          flag = flag || true;
        } else {
          value.active = false;
        }
      });

      if (flag) return;
      this.tabs.forEach(function (value) {
        value.active = false; //所有隐藏选项卡
      });
      param.active = true; //当前显示选项卡
      this.tabs.push(param);
    },

    closeAllTab() {
      //关闭所有选项卡--隐藏左边菜单
      this.tabs = [];
      this.showApp = false;
      this.$store.state.appmenusShow = false;
      this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
      this.$store.state.searchDataStore=[]
    },

    closeTab: function (tab, tabindex) {
      //关闭当前选项卡，选中前一个选项卡
      console.log(tab)
      console.log(tabindex)
      if(this.$store.state.searchDataStore.length){
        this.$store.state.searchDataStore.forEach((item,index)=>{
            if(item.appId==tab.appId&&item.viewId==tab.actionContent){
                this.$store.state.searchDataStore.splice(index,1)//关闭视图--清掉vuex单个视图的记住数据
            }
        })
      }
      if(this.$store.state.pageDataStore.length){
        this.$store.state.pageDataStore.forEach((item,index)=>{
            if(item.appId==tab.appId&&item.viewId==tab.actionContent){
                this.$store.state.pageDataStore.splice(index,1)//关闭视图--清掉vuex单个视图的记住数据
            }
        })
      }
      console.log(this.$store.state.searchDataStore)
      let tabs = this.tabs;
      if (tabindex >= 0) {
        //点击X关闭
        console.log(JSON.stringify(this.tabs));
        tabs.splice(tabindex, 1);
        if (tab.active) {
          if (tabs.length > 0 && tabs.length - 1 >= tabindex) {
            tabs[tabindex].active = true;
          } else if (tabs.length > 0 && tabs.length - 1 < tabindex) {
            if (tabindex > 0) {
              tabs[tabindex - 1].active = true; //选中前一个选项卡
            }
          }
        }
        // if(tabs[tabs.length-1]) {
        //   tabs[tabs.length-1].active = true;
        // }
      } else {
        //单击返回按钮
        let i = -1;
        this.tabs.forEach(function (value, index) {
          if (
            (value.id && value.id == tab.id) ||
            (value._select && value._select == tab._select)
          ) {
            i = index;
          }
        });
        this.tabs.splice(i, 1);
        let act = this.tabs[i];
        if (act) {
          this.activeTab({ id: act._select ? act._select : act.id });
        } else if (i >= 1) {
          let act = this.tabs[i - 1];
          this.activeTab({ id: act._select ? act._select : act.id });
        } else {
          if (this.tabs.length > 0)
            this.tabs[this.tabs.length - 1].active = true;
        }
      }

      if (this.tabs.length == 0) {
        //关闭最后一个，所有左边菜单隐藏
        this.showWait = false;
        this.showApp = false;
        this.$store.state.appmenusShow = false;
        this.$refs.mychild.setMaincontent(true); // 调用子组件的方法
      }
    },

    activeTab: function (tab, index) {
      //选中选项卡
      if (index >= 0) {
        this.tabs.forEach((value, i) => {
          if (i == index) {
            value.active = true;
          } else {
            value.active = false;
          }
        });
      } else {
        this.tabs.forEach((value) => {
          if (
            (value.id && value.id == tab.id) ||
            (value._select && value._select == tab._select) ||
            (value._select && value._select == tab.id)
          ) {
            value.active = true;
            return;
          } else {
            value.active = false;
          }
        });
      }
    },
  },
  watch: {
    showInstance(val) {
      if (val) {
        this.dialogVisible = true;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .custom-dialog {
  height: auto;
  .el-dialog__title{
    font-size: 24px;
    font-weight: bold;
  }
  .el-dialog__body{
    padding: 10px 25px 10px;
  }
  .el-dialog__header{
    padding: 30px 20px 10px;
  }
}
.lockWraper {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(24, 38, 46, 0.6);
  z-index: 999999;
  color: red;
  .lock-content {
    width: 460px;
    height: 240px;
    background: white;
    border-radius: 5px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-top: -120px;
    margin-left: -230px;
    .img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      overflow: hidden;
      position: absolute;
      left: 50%;
      top: -30px;
      margin-left: -30px;
      img {
        width: 60px;
        height: 60px;
      }
    }
    .admin-header-lock-name {
      margin-top: 43px;
      width: 100%;
      text-align: center;
      color: #333636;
      margin-bottom: 55px;
    }
    .input_btn {
      width: 100%;
      padding-left: 95px;
      padding-right: 95px;
      box-sizing: border-box;
      display: -webkit-flex;
      display: flex;
      justify-content: center;
      align-items: center;
      .input-box {
        position: relative;
        .error-tip {
          position: absolute;
          top: -35px;
          padding: 5px 5px;
          border: 1px solid red;
          border-radius: 4px;
          font-size: 12px;
          &::after {
            position: absolute;
            top: 26px;
            content: "";
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 7px solid red;
          }
          &::before {
            position: absolute;
            top: 25px;
            z-index: 10;
            content: "";
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 7px solid #fff;
          }
        }
      }
      #lockPwd {
        width: 200px;
        height: 30px;
        border-radius: 3px;
        background: #797979;
        display: inline-block;
        padding-left: 10px;
        font-size: 14px;
        color: #fff;
        border: none;
        vertical-align: middle;
        margin-right: 10px;
        outline: none;
      }
      .un-lock {
        display: inline-block;
        height: 30px;
        line-height: 30px;
        background: #0076f6;
        color: #fff;
        width: 60px;
        border-radius: 3px;
        text-align: center;
        cursor: pointer;
      }
      ::-webkit-input-placeholder {
        /* WebKit browsers */
        color: #fff;
      }
      :-moz-placeholder {
        /* Mozilla Firefox 4 to 18 */
        color: #fff;
      }
      ::-moz-placeholder {
        /* Mozilla Firefox 19+ */
        color: #fff;
      }
      :-ms-input-placeholder {
        /* Internet Explorer 10+ */
        color: #fff;
      }
    }
    .tip {
      width: 100%;
      padding: 0 15px;
      box-sizing: border-box;
      margin-top: 20px;
      text-align: center;
    }
  }
}
.fontclass {
  .el-notification__content {
    .notice_actor {
      color: #0095ff;
    }
    .notice_summary {
      color: #0095ff;
    }
  }
}

.fa-lock:before,
.lockScreenicon:before {
  display: none;
  cursor: default;
}

.nav-appMenus {
  .el-scrollbar {
    height: calc(100% - 30px) !important;
    overflow-x: scroll;
    .el-scrollbar__wrap {
      overflow: auto;
      .el-scrollbar__view {
        white-space: nowrap;
        height: calc(100%);
      }
    }
  }
}
</style>
<style lang="scss" scoped>
.domain-box {
  display: flex;
  align-items: center;
  height: 100% !important;
}
.domainlogo_title {
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}

//中间切换伸缩按钮
.openExpand{
  position: fixed;
  left: 186px;//rt特有布局
  top:50%;
  width: 11px;
  height: 32px;
  z-index: 1;
  cursor: pointer;
  overflow: hidden;
  img{
     position: absolute;
     top: 0;
     left: 0;
     &:hover{
      top:0;
      left: -12px;
     }
     &.openFlag{

     }
     &.closeFlag{
       top: -32px;
       left:0;
       &:hover{
        top:-32px;
        left:-12px;
       }
     }
  }
  
}
.openExpand.closeExpand{
  left: 0px; 
}
</style>