'use strict'; window.onload = function () { window.vm = new Vue({ el: '#g-app-main', data: function () { return { tabsList: [], // 打开的tab页面 showPagesAction: false, // 打开tabs操作选项 selectedTabsIndex: -1, // 当前所选的tab 索引 sideBarOpen: true, inFullScreenMode: false, // 是否处于全屏模式 showThemePicker: false, // 显示主题选择器 classicalLayout: true, menuTreeData: [], // 目录数据 subMenuData: [], // 二级目录数据 selectedTopMenuIndex: 0, subMenuTitle: '', // 二级目录标题 selectedId: -1, // 当前激活的id // 是否开启刷新记忆tab功能 is_remember: false, webUser: new WebUser(), isAdmin: false, showShortCut: false, showShortOA: false, showUserActions: false, tabDropdownVisible: false, top: 0, left: 0, closeTimeout: null, SystemName: "驰骋BPM", SystemLogo: "./image/logo.png", IsShowFast: true, IsShowOA: true, IsShowRefresh: true, IsShowFullScreen: true, IsShowTheme: true, IsShowFlexible: true, IsShowTwoLevelMenu: false }; }, computed: { contextMenuStyle: function () { return { position: 'fixed', zIndex: 9999, top: (this.top || 0) + 'px', left: (this.left || 0) + 'px', background: 'white', padding: '0 10px', border: '1px solid #eee' }; }, }, methods: { openTabDropdownMenu: function (e) { this.tabDropdownVisible = true; this.top = e.pageY; this.left = e.pageX; }, selectTopMenu: function (index) { if (this.classicalLayout) return; this.selectedTopMenuIndex = index; this.selectedSubIndex = -1; if (this.menuTreeData.length > 0) { this.subMenuData = this.menuTreeData[index]; this.subMenuTitle = this.menuTreeData[index].Name; if (this.subMenuTitle.length > 4) $(".line").css("width", (70 - (this.subMenuTitle.length - 4) * 8) + "px"); this.bindDropdown(this.subMenuData.type) } this.sideBarOpen = true this.initChildContextMenu() }, fullScreenOpen: function (uri, name) { this.changeFullScreenStatus() var w = screen.width, h = screen.height layer.open({ type: 2, title: name, content: [uri, 'no'], area: [w + 'px', h + 'px'], offset: 'rb', shadeClose: true }) }, changeFullScreenStatus: function () { if (this.inFullScreenMode) { this.exitFullScreen() return } this.fullScreen() }, // 全屏事件 fullScreen: function () { var element = window.document .documentElement; //若要全屏页面中div,var element= document.getElementById("divID"); //IE 10及以下ActiveXObject if (window.ActiveXObject) { var WsShell = new ActiveXObject('WScript.Shell') WsShell.SendKeys('{F11}'); } //HTML W3C 提议 else if (element.requestFullScreen) { element.requestFullScreen(); } //IE11 else if (element.msRequestFullscreen) { element.msRequestFullscreen(); } // Webkit (works in Safari5.1 and Chrome 15) else if (element.webkitRequestFullScreen) { element.webkitRequestFullScreen(); } // Firefox (works in nightly) else if (element.mozRequestFullScreen) { element.mozRequestFullScreen(); } this.inFullScreenMode = true }, exitFullScreen: function () { var element = document .documentElement; //若要全屏页面中div,var element= document.getElementById("divID"); //IE ActiveXObject if (window.ActiveXObject) { var WsShell = new ActiveXObject('WScript.Shell') WsShell.SendKeys('{F11}'); } //HTML5 W3C 提议 else if (element.requestFullScreen) { document.exitFullscreen(); } //IE 11 else if (element.msRequestFullscreen) { document.msExitFullscreen(); } // Webkit (works in Safari5.1 and Chrome 15) else if (element.webkitRequestFullScreen) { document.webkitCancelFullScreen(); } // Firefox (works in nightly) else if (element.mozRequestFullScreen) { document.mozCancelFullScreen(); } this.inFullScreenMode = false }, // 改变侧边栏大小 resizeSideBar: function () { this.sideBarOpen = !this.sideBarOpen }, // 上一个页面 toLeftPage: function () { this.$nextTick(function () { var iframeTabs = this.$refs['iframe-tabs'] var offsetWidth = iframeTabs.offsetWidth var scrollWidth = iframeTabs.scrollWidth var offsetLeft = iframeTabs.offsetLeft if (scrollWidth <= offsetWidth) { return } if (offsetLeft < 0) { var leftDistance = offsetLeft + offsetWidth if (leftDistance > 0) { leftDistance = 0 } iframeTabs.style.left = leftDistance + 'px' } }) }, // 下一个页面 toRightPage: function () { this.$nextTick(function () { var iframeTabs = this.$refs['iframe-tabs'] var offsetWidth = iframeTabs.offsetWidth var scrollWidth = iframeTabs.scrollWidth var offsetLeft = iframeTabs.offsetLeft if (scrollWidth <= offsetWidth) { return } if (Math.abs(offsetLeft) < scrollWidth - offsetWidth) { iframeTabs.style.left = offsetLeft - offsetWidth + 'px' } }) }, // 重载当前页面 reLoadCurrentPage: function () { this.$nextTick(function () { if (this.selectedTabsIndex === -1) { this.$refs['iframe-home'].contentWindow.location.reload(); return } this.$refs['iframe-' + this.selectedTabsIndex][0].contentWindow.location .reload() }) }, // 关闭当前标签页 closeCurrentTabs: function (index) { if (index == undefined) index = this.selectedTabsIndex; this.tabsList.splice(index, 1) var _this = this setTimeout(function () { if (_this.tabsList.length > index) { _this.selectedTabsIndex = index } else { _this.selectedTabsIndex = index - 1 } }, 100) }, closeTabByName: function (name) { if (name == null || name == undefined || name == "") return; if (this.tabsList.length == 0) return; //获取当前标签所在的位置 var index = -1; $.each(this.tabsList, function (i, item) { if (item.name == name) { index = i; return false; } }) if (index == -1) return; this.tabsList.splice(index, 1) var _this = this setTimeout(function () { if (_this.tabsList.length > index) { _this.selectedTabsIndex = index } else { _this.selectedTabsIndex = index - 1 } }, 100) }, // 关闭所有 closeAllTabs: function () { this.tabsList = [] this.selectedTabsIndex = -1 this.$nextTick(function () { this.$refs['iframe-tabs'].style.left = 0 + 'px' }) }, // 关闭其他 closeOtherTabs: function () { if (this.tabsList.length === 0) return var tab = this.tabsList[this.selectedTabsIndex] this.tabsList = [tab] this.selectedTabsIndex = 0 }, // 处理tab滚动 handleTabScroll: function () { // 待实现 // this.$nextTick(function() { // var tabs = this.$refs['iframe-tabs'] // var elLeft = tabs.querySelector('.layui-this').offsetLeft // if (elLeft >= 0 && elLeft <= Math.abs(tabs.offsetLeft)) { // return // } else { // tabs.style.left = -(elLeft - elWidth) + 'px' // } // }) }, openTabByMenu: function (menu, alignRight) { //写入日志. UserLogInsert("MenuClick", menu.Name + "@" + menu.Icon + "@" + menu.Url); this.openTab(menu.Name, menu.Url, alignRight); }, openTab: function (name, src, alignRight) { //如果发起实体类的流程,是通过一个页面中专过去的. /* * /WF/CCBill/Opt/StartFlowByNewEntity.htm * 这里不解析特殊的业务逻辑, 让页面解析。 * */ if (this.tabsList.length >= 30) { layer.alert('最多可以打开30个标签页~'); return; } var obj = { name: name, src: src } var idx = this.checkExist(obj) if (idx > -1) { this.selectedTabsIndex = idx this.reLoadCurrentPage() return } if (alignRight) { this.tabsList.splice(this.selectedTabsIndex + 1, 0, obj) this.selectedTabsIndex = this.selectedTabsIndex + 1 } else { this.tabsList.push(obj) this.selectedTabsIndex = this.tabsList.length - 1 } // if (this.tabsList.length > 5) // this.handleTabScroll() }, checkExist: function (obj) { for (var i = 0; i < this.tabsList.length; i++) { var item = this.tabsList[i] if (item.name === obj.name && item.src === obj.src) { return i } } return -1 }, foldMenus: function (menus, c, ev) { for (var i = 0; i < menus.length; i++) { var item = menus[i] if (item.No === c.No) { item.open = !item.open continue } item.open = false } }, generatePickerBody: function () { var tag = "