最近在做项目过程中,自己写了个首页,要用到树形导航与标签页结合展示页面,使用的而且是iframe页面嵌套的方式,不使用组件。以下是代码,仅供参考,关注关键代码就行了
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>中方科技客户关系管理系统</title>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="/static/plugins/vuejs/vue.js" type="text/javascript"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="/static/plugins/elementui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="/static/plugins/elementui/lib/index.js"></script>
<%--路由--%>
<script src="/static/plugins/vuejs/vue-router.js" type="text/javascript"></script>
<%--axios--%>
<script src="/static/plugins/vuejs/axios.js" type="text/javascript"></script>
</head>
<body>
<div id="app">
<el-container>
<el-header>
<el-row style="line-height: 70px">
<el-col :span="10" :offset="2" style="font-family: 华文楷体;font-size: 50px;">中方科技CRM管理系统</el-col>
<el-col :span="12" style="text-align: right">
<span>${user.userName}</span>
<el-dropdown>
<i class="el-icon-setting" style="margin-right: 15px"></i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="editPwd">修改密码</el-dropdown-item>
<el-dropdown-item @click.native="open">注销登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-col>
</el-row>
</el-header>
<el-container>
<el-aside width="180px" style="height: 595px;">
<el-row class="tac">
<el-col :span="12">
<el-menu
class="el-menu-vertical-demo"
background-color="#F6F6F6">
<el-submenu index="1">
<template slot="title">
<i class="el-icon-menu"></i>
<span>菜单</span>
</template>
<el-tree style="margin-left: 12px; background-color: #F6F6F6" :data="treeData"
node-key="id" :props="defaultProps" @node-click="handleNodeClick">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>
<i :class="node.icon"></i>{{ node.label }}
</span>
</span>
</el-tree>
</el-submenu>
</el-menu>
</el-col>
</el-row>
</el-aside>
<el-container>
<el-main>
<el-tabs v-model="editableTabsValue" type="border-card" closable @tab-remove="removeTab">
<el-tab-pane
v-for="(item, index) in editableTabs"
:key="item.name"
:label="item.title"
:name="item.name"
>
<iframe :src="item.content" style="width: 100%;height: 450px" frameborder="0"></iframe>
</el-tab-pane>
</el-tabs>
</el-main>
<el-footer style="height: 30px;">
®2006-2018重庆大智若愚网络科技有限公司 版权所有 渝ICP备14030149号-1 渝公网安备510114990541
</el-footer>
</el-container>
</el-container>
</el-container>
</div>
<script>
new Vue({
el: "#app",
data: {
currentUser:'',
treeData: [
{
label: '客户管理',
icon: 'el-icon-location',
children: [{
label: '潜在客户',
url: '/potentialCustomer/index',
icon: 'el-icon-location-outline'
},{
label: '开发计划',
url: '/customerDevPlan/index',
icon: 'el-icon-location-outline'
},{
label: '正式客户',
url: '/customer/index',
icon: 'el-icon-location-outline'
},{
label: '跟进历史',
url: '/customerTraceHistory/index',
icon: 'el-icon-location-outline'
},{
label: '移交记录',
url: '/customerTransfer/index',
icon: 'el-icon-location-outline'
},{
label: '资源池',
url: '/customerResourcePool/index',
icon: 'el-icon-location-outline'
}]
},{
label: '订单管理',
icon: 'el-icon-location',
children: [{
label: '订单明细',
url: '/order/index',
icon: 'el-icon-location-outline'
}]
},{
label: '合同管理',
icon: 'el-icon-location',
children: [{
label: '合同明细',
url: '/Contract/index',
icon: 'el-icon-location-outline'
}, {
label: '付款详情',
url: '/ContractDetails/index',
icon: 'el-icon-location-outline'
}]
},{
label: '保修单管理',
icon: 'el-icon-location',
children: [{
label: '保修单明细',
url: '/Guarantee/index',
icon: 'el-icon-location-outline'
}, {
label: '保修单详情',
url: '/guaranteeDetail/index',
icon: 'el-icon-location-outline'
}]
},{
label: '员工管理',
icon: 'el-icon-location',
children: [{
label: '员工明细',
url: '/employee/index',
icon: 'el-icon-location-outline'
}]
},{
label: '部门管理',
icon: 'el-icon-location',
children: [{
label: '部门明细',
url: '/department/index',
icon: 'el-icon-location-outline'
}]
}, {
label: '基础数据管理',
icon: 'el-icon-location',
children: [{
label: '数据字典',
url: '/systemDictionary/index',
icon: 'el-icon-location-outline'
},{
label: '租户管理',
url: '/tenant/index',
icon: 'el-icon-location-outline'
},{
label: '套餐管理',
url: '/setMeal/index',
icon: 'el-icon-location-outline'
}]
}
],
defaultProps: {
children: 'children',
label: 'label'
},
editableTabsValue: '1',
editableTabs: [{
title: '首页',
name: '1',
content: '/login/hello'
}],
tabIndex: 1
},
methods: {
//修改密码
editPwd(){
alert("赶紧写!!")
},
//跳转到登录
open(){
//发送注销登录请求
location.href = "/login/loginOut";
},
//标签页处理
handleNodeClick(data) {
if (!data.children) {
//取得当前已打开的tab页
let tabs = this.editableTabs;
let flag = true;//表示可以新打开
tabs.forEach((tab, index) => {
if (tab.title === data.label) {
//如果打开则选中
this.editableTabsValue = tab.name;
flag = false;
return;
}
});
if (flag) {//如果没有打开则添加
let newTabName = ++this.tabIndex + '';
this.editableTabs.push({
title: data.label,
name: newTabName,
content: data.url
});
this.editableTabsValue = newTabName;
}
}
},
//标签页移除
removeTab(targetName) {
let tabs = this.editableTabs;
let activeName = this.editableTabsValue;
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);
},
/*loaduser(){
this.currentUser = JSON.parse('${user}')
}*/
}
/*mounted(){
this.loaduser();
}*/
})
</script>
<style>
.el-header {
background-color: #6699CC;
color: #FFFFFF;
height: 80px;
line-height: 70px;
background-repeat: no-repeat;
background-position: 28px;
background-image: url("/static/images/kehu.png");
}
.el-footer {
background-color: #E6E6E6;
color: #333;
text-align: center;
line-height: 30px;
}
body > .el-container {
margin-bottom: 40px;
}
.el-menu {
border: none;
width: 180px;
}
.el-aside {
background-color: #E2E2E2;
color: #333;
}
.el-main {
background-color: #FFFFFF;
color: #333;
text-align: left;
}
</style>
</body>
</html>