赞
踩
提示:以下是本篇文章正文内容,下面案例可供参考
代码如下(示例):
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import warnings warnings.filterwarnings('ignore') import ssl ssl._create_default_https_context = ssl._create_unverified_context <template> <div> <el-container> <el-header> <!-- 头部区域 --> <div class="Hui-header cl"> <div class="logo-box"> <div class="logo"></div> <div class="logo-r"></div> </div> <div class="robot"></div> <div class="Hui-welcome"> <span>{{ DateTime | formDateFun(4) }}</span> <span>{{ Day[new Date().getDay()] }}</span> <span @click="customShow('修改密码', 'changPassword', 550, 395)">{{ UserName }}</span> <div class="quit"> <img src="../../assets/images/quit.png" /> <a @click="exit" class="dropDown_A" > <font color="#ffffff">退出登录</font> </a> </div> </div> </div> </el-header> <el-container> <!-- 侧边栏菜单区域 --> <el-aside :width="isCollapse ? '64px' : '200px'"> <div class="toggle-button" @click="toggleCollapse" >|||</div> <!-- :router="true" --> <el-menu :collapse-transition="false" :collapse="isCollapse" :unique-opened="true" background-color="#fff" text-color="#545c64" active-text-color="#409EFF" :default-active="activationInedx" @select="handleSelect" :router="true" > <!-- 菜单一 --> <el-submenu :index="item.id + ''" v-for="item in menu" :key="item.path" > <template slot="title"> <i :class="iconsObj[item.id]"></i> <span>{{ item.lable }}</span> </template> <el-menu-item :index="'/' + subItem.path" v-for="subItem in item.children" :key="subItem.path" > <template slot="title"> <i class="el-icon-menu" style="font-size: 15px" ></i> <span>{{ subItem.lable }}</span> </template> </el-menu-item> </el-submenu> </el-menu> </el-aside> <el-main class="main"> <div v-show="contextMenuVisible"> <ul :style="{left:left+'px',top:top+'px'}" class="contextmenu"> <li><el-button type="text" @click="curTabReload()" size="mini">重新加载</el-button></li> <li><el-button type="text" @click="closeAllTabs()" size="mini">关闭所有</el-button></li> <li><el-button type="text" @click="closeOtherTabs('other')" size="mini">关闭其他</el-button></li> </ul> </div> <el-tabs v-model="editableTabsValue" type="border-card" closable @tab-remove="removeTab" @tab-click="tab_click(editableTabsValue)" > <el-tab-pane v-for="item in editableTabs" :key="item.name" :label="item.title" :name="item.name" > <!-- 路由站位符 --> <router-view></router-view> </el-tab-pane> </el-tabs> </el-main> </el-container> </el-container> </div> </template> <style lang="less" scoped> .contextmenu { width: 100px; margin: 0; border: 1px solid #ccc; background: #fff; z-index: 3000; position: absolute; list-style-type: none; padding: 5px 0; border-radius: 4px; font-size: 14px; color: #333; box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.2); } .contextmenu li { margin: 0; padding: 0px 22px; } .contextmenu li:hover { background: #f2f2f2; cursor: pointer; } .contextmenu li button{ color: #2c3e50; } .el-tabs__nav .el-tabs__item:nth-child(1) span { display: none; } // .el-menu-item:nth-child(1) span { // display: none; // } .el-aside { margin-top: 25px; height: 100%; .el-menu { .el-menu-item { font-family: "微软雅黑"; font-size: 13px; font-weight: normal; } border-right: none; } } .main { margin-top: 5px; } .toggle-button { background-color: #409eff; font-size: 10px; line-height: 24px; color: #fff; text-align: center; letter-spacing: 0.2em; cursor: pointer; } </style> <script> import "../../assets/css/skin.css"; import "../../assets/css/H-ui.min.css"; import { bus } from "../../bus.js"; export default { mounted: function () { // 获取dom let tab_top_dom = document.body.getElementsByClassName("el-tabs__header is-top") // 使用原生js 为单个dom绑定鼠标右击事件 tab_top_dom[0].oncontextmenu = this.openContextMenu // 设置定时器 const chatTimer = setInterval(() => { this.DateTime = Date.parse(new Date()); }, 1000); }, created() { bus.$on("goto", (url) => { if (url === "/login") { localStorage.clear(); } this.$router.push(url); }); bus.$on("msg", (msg) => { if (msg === "504") { this.$notify({ title: "提示", message: "连接超时!", }); } }); }, data() { return { left:'', top:'', //右键菜单的显示 contextMenuVisible:false, //右键选中的tabs页签属性 currentContextTab:'', flag: true, isCollapse: false, editableTabsValue: "welcome", editableTabs: [ { title: "首页", name: "welcome", closable: false, content: "首页", }, ], tabIndex: 2, //父菜单数组对象 menu: [ { id: "101", lable: "数据建模", children: [ { id: 1, path: "WarehouseTree", lable: "隶属关系管理" }, { id: 2, lable: "仓库建模管理", path: "Warehouse" }, { id: 3, path: "ReservoirManagement", lable: "库区建模管理" }, { id: 4, path: "ShelfManagement", lable: "货架建模管理" }, { id: 5, path: "WarehouseLoc", lable: "货位建模管理" }, { id: 5, path: "storeManagement", lable: "网关建模管理" }, { id: 5, path: "MaterialCategory", lable: "货物类别管理" }, { id: 5, path: "MaterialInfo", lable: "货物管理" }, { id: 5, path: "Supplier", lable: "供应商管理" }, { id: 5, path: "Customer", lable: "收物单位管理" }, { id: 5, path: "Company", lable: "计量单位管理" }, { id: 5, path: "UnitConversion", lable: "单位换算" }, { id: 5, path: "StandardDescription", lable: "标准说明" }, ], }, { id: "102", lable: "仓库管理", children: [ { id: 6, path: "StockManagement", lable: "库存管理" }, { id: 7, path: "EnterWarehouse", lable: "入库管理" }, { id: 8, path: "OutboundOrder", lable: "出库管理" }, { id: 9, path: "countingTaskList", lable: "盘点管理" }, { id: 10, path: "ScrapManagementList", lable: "报废管理" }, { id: 10, path: "TransferTaskList", lable: "移库单管理" }, { id: 10, path: "GeneratePurchaseList", lable: "采购单生成" }, ], }, { id: "103", lable: "查询管理", children: [ { id: 1, path: "InformationService", lable: "货物查询" }, { id: 1, path: "ShelfQuery", lable: "货架查询" }, { id: 1, path: "IssueorReceiptQuery", lable: "出入库查询" }, { id: 1, path: "InventoryQuery", lable: "盘点查询" }, { id: 1, path: "InventoryAnalysis", lable: "库存分析" }, { id: 1, path: "InventoryCheck", lable: "盘点分析" }, { id: 1, path: "StockInAnalysis", lable: "出入库分析" }, { id: 1, path: "OperationLog", lable: "操作日志" }, { id: 1, path: "PrintManagement", lable: "打印管理" }, ], }, { id: "104", lable: "系统管理", children: [ { id: 1, path: "UserManagement", lable: "用户管理" }, { id: 1, path: "PrivilegeManagement", lable: "角色管理" }, { id: 1, path: "SetTime", lable: "设置超时时间" }, ], }, ], iconsObj: { '101': "el-icon-coin", '102': "el-icon-house", '103': "el-icon-search", '104': "el-icon-setting", }, //激活菜单项的index activationInedx: 0, HomeShow: window, UserName: window.localStorage.getItem("UserName"), DateTime: Date.parse(new Date()), Day: [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", ], }; }, methods: { // 关闭其它标签页 closeOtherTabs(par) { if (par == "other") { //TODO 关闭其他所有标签 for (let i = 0; i < this.editableTabs.length; i++) { if(i!=0){ if (this.editableTabs[i].name!=this.currentContextTab) { console.log(this.editableTabs[i].name); console.log(i); this.editableTabs.splice(i,1) console.log(this.editableTabs.length); i-=1 } } } this.editableTabsValue=this.currentContextTab this.$router.push("/" + this.currentContextTab); } //关闭菜单栏 this.closeContextMenu() }, //刷新当前页 curTabReload(){ this.$router.push("/" + this.currentContextTab); //TODO 重新载入当前标签页 //关闭菜单栏 this.closeContextMenu() }, // 关闭所有标签页 closeAllTabs() { //TODO 关闭所有标签 // this.editableTabs console.log(this.editableTabs.length); this.editableTabs.splice(1,this.editableTabs.length-1) this.editableTabsValue='welcome' this.$router.push("/" + "welcome"); //关闭菜单栏 this.closeContextMenu() }, // 关闭contextMenu closeContextMenu() { this.contextMenuVisible = false; }, /* 右击事件 */ openContextMenu(e) { e.preventDefault(); //防止默认菜单弹出 let obj = e.srcElement ? e.srcElement : e.target; console.log('右击'); console.log(obj); if (obj.id) { let currentContextTabId = obj.id.split("-")[1]; this.currentContextTab=currentContextTabId let curIndex = 0; for(;curIndex<this.editableTabs.length;++curIndex){ if(this.editableTabs[curIndex].title == currentContextTabId){ break; } } if(curIndex<=0){ this.isDisabledCloseLeftBtnFlag = true this.isDisabledCloseRightBtnFlag = false }else if(curIndex >= this.editableTabs.length-1){ this.isDisabledCloseLeftBtnFlag = false this.isDisabledCloseRightBtnFlag = true }else{ this.isDisabledCloseLeftBtnFlag = false this.isDisabledCloseRightBtnFlag = false } this.contextMenuVisible = true; this.$store.commit("saveCurContextTabId", currentContextTabId); this.left = e.clientX; this.top = e.clientY + 10; } }, //折叠菜单栏 toggleCollapse() { this.isCollapse = !this.isCollapse; }, customShow(title, url, w, h, id) { layer_show(title, url + "?res=" + id, w, h); }, //退出 exit() { let that = this; let params = new FormData(); localStorage.clear(); that.$notify({ title: "提示", message: "退出成功!", }); console.log("======================456"); that.$router.push("/login"); }, //选中tab菜单触发事件 tab_click(index) { this.$router.push("/" + index); // 对子菜单的联动 this.activationInedx = "/" + index; }, //点击菜单项触发事件 handleSelect(key, keyPath) { const keys = key.split("/")[1]; for (let s = 0; s < this.editableTabs.length; s++) { this.editableTabs.map((tabs) => { if (tabs.name == keys) { this.editableTabsValue = keys; this.activationInedx = "/" + keys; this.flag = false; } }); } if (this.flag) { this.menu.map((item) => { const itemList = item.children; itemList.map((res) => { if (res.path == keys) { console.log(res.lable); // key 代表访问路径 // 实现tab菜单生成 this.editableTabs.push({ title: res.lable, name: keys, content: res.lable, }); this.editableTabsValue = keys; this.activationInedx = "/" + keys; } }); }); } this.flag = true; }, removeTab(targetName) { let tabs = this.editableTabs; let activeName = this.editableTabsValue; if (targetName === "welcome") { return; } if (activeName === targetName) { tabs.forEach((tab, index) => { if (tab.name === targetName) { let nextTab = tabs[index + 1] || tabs[index - 1]; if (nextTab) { activeName = nextTab.name; } } }); } this.editableTabsValue = activeName; this.editableTabs = tabs.filter((tab) => tab.name !== targetName); this.$router.push("/" + activeName); }, }, }; </script>
该处使用的url网络请求的数据。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。