Commit 4a4068fe by 无尘

add: 添加菜单接口

parent fca0d3da
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "@gic-test/vue-office-header", "name": "@gic-test/vue-office-header",
"description": "vue-office-header Plugin", "description": "vue-office-header Plugin",
"author": "fairyly <498745097@qq.com>", "author": "fairyly <498745097@qq.com>",
"version": "1.0.5", "version": "1.0.8",
"license": "MIT", "license": "MIT",
"private": false, "private": false,
"main": "dist/vue-office-header.js", "main": "dist/vue-office-header.js",
......
...@@ -11,8 +11,13 @@ ...@@ -11,8 +11,13 @@
<div :class="['itemlink-gic', 'bottom', pathName=='gic-web'? 'current-module':'']">GIC商户后台</div> --> <div :class="['itemlink-gic', 'bottom', pathName=='gic-web'? 'current-module':'']">GIC商户后台</div> -->
<!-- menu --> <!-- menu -->
<template v-for="menuitem in menuHead"> <template v-for="(menuitem,index) in menuHead">
<a :class="['itemlink', 'bottom','menu-mall',pathName==menuitem.menuUrl? 'current-module':'']" :href="'#'+menuitem.menuUrl" :target="menuitem.target == 1?'_blank':''">{{menuitem.menuName}}</a> <a
:key="index"
:class="['itemlink', 'bottom','menu-mall',pathName == menuitem.url? 'current-module':'']"
:href="'#'+menuitem.url" >
{{menuitem.rightName}}
</a>
</template> </template>
<!-- 最右侧用户信息 --> <!-- 最右侧用户信息 -->
<div class="navuserinfo fr"> <div class="navuserinfo fr">
...@@ -31,7 +36,7 @@ ...@@ -31,7 +36,7 @@
props: ['menuRouter','collapseFlag','projectName'], props: ['menuRouter','collapseFlag','projectName'],
data () { data () {
return { return {
repProjectName: 'gic-web', // 项目名 repProjectName: 'haoban-manage-web', // 项目名
// 当前路由 // 当前路由
pathName: '', pathName: '',
...@@ -40,48 +45,48 @@ ...@@ -40,48 +45,48 @@
// 菜单数据 // 菜单数据
menuHead: [ menuHead: [
{ // {
menuCode: null, // menuCode: null,
menuName: "首页", // rightName: "首页",
menuUrl: "/index", // url: "/index",
parentCode: null, // parentCode: null,
project: "office" // project: "office"
}, // },
{ // {
menuCode: null, // menuCode: null,
menuName: "通讯录", // rightName: "通讯录",
menuUrl: "/administrativeFrame", // url: "/administrativeFrame",
parentCode: null, // parentCode: null,
project: "office" // project: "office"
}, // },
{ // {
menuCode: null, // menuCode: null,
menuName: "企业应用", // rightName: "企业应用",
menuUrl: "/enterpriseApp", // url: "/enterpriseApp",
parentCode: null, // parentCode: null,
project: "office" // project: "office"
}, // },
{ // {
menuCode: null, // menuCode: null,
menuName: "审核中心", // rightName: "审核中心",
menuUrl: "/unreview", // url: "/unreview",
parentCode: null, // parentCode: null,
project: "office" // project: "office"
}, // },
{ // {
menuCode: null, // menuCode: null,
menuName: "我的企业", // rightName: "我的企业",
menuUrl: "/myCompany", // url: "/myCompany",
parentCode: null, // parentCode: null,
project: "office" // project: "office"
}, // },
{ // {
menuCode: null, // menuCode: null,
menuName: "设置", // rightName: "设置",
menuUrl: "/companyAddress", // url: "/companyAddress",
parentCode: null, // parentCode: null,
project: "office" // project: "office"
}, // },
], ],
// 获取 location origin // 获取 location origin
...@@ -91,11 +96,11 @@ ...@@ -91,11 +96,11 @@
} }
}, },
beforeMount() { beforeMount() {
var that = this const that = this
var host = window.location.origin; let host = window.location.origin;
console.log("当前host:",host) console.log("当前host:",host)
if (host.indexOf('localhost') != '-1') { if (host.indexOf('localhost') != '-1') {
that.baseUrl = 'http://gicdev.demogic.com'; that.baseUrl = 'http://www.gicdev.com';
}else { }else {
that.baseUrl = host that.baseUrl = host
} }
...@@ -104,7 +109,7 @@ ...@@ -104,7 +109,7 @@
// 处理折叠 // 处理折叠
handleCollapse() { handleCollapse() {
var that = this; const that = this;
that.isCollapse = (that.isCollapse==true? false: true); that.isCollapse = (that.isCollapse==true? false: true);
that.$emit('collapseTag', that.isCollapse) that.$emit('collapseTag', that.isCollapse)
}, },
...@@ -116,7 +121,7 @@ ...@@ -116,7 +121,7 @@
//退出登录 //退出登录
toLoginOut() { toLoginOut() {
var that = this; const that = this;
// var para = { // var para = {
// requestProject: that.repProjectName // requestProject: that.repProjectName
// } // }
...@@ -127,14 +132,14 @@ ...@@ -127,14 +132,14 @@
that.axios.post(that.baseUrl+'/api-auth/do-logout',{}) that.axios.post(that.baseUrl+'/api-auth/do-logout',{})
.then((res) => { .then((res) => {
// console.log(res,res.data,res.data.errorCode) // console.log(res,res.data,res.data.errorCode)
var resData = res.data let resData = res.data
if (resData.errorCode == 0) { if (resData.errorCode == 0) {
that.$message({ that.$message({
message: '退出成功', message: '退出成功',
type: 'success' type: 'success'
}); });
// 跳转登录页 // 跳转登录页
window.location.href = window.location.origin + '/gic-web/#/'; window.location.href = window.location.origin + '/haoban-web/#/login';
return; return;
} }
...@@ -165,7 +170,7 @@ ...@@ -165,7 +170,7 @@
// 触发父组件路由 // 触发父组件路由
toRouter(path,name,code) { toRouter(path,name,code) {
var that = this; const that = this;
var obj ={ var obj ={
path: '/'+ path, path: '/'+ path,
...@@ -174,25 +179,79 @@ ...@@ -174,25 +179,79 @@
that.$emit('toRouterView', obj) that.$emit('toRouterView', obj)
}, },
// 获取菜单 /**
getHeaderMenu() { * 简单数组-->父子数组对象
var that = this */
var para = { treeData(data){
let tree = data.filter((father)=>{ //循环所有项
let branchArr = data.filter((child)=>{
return father.haobanMenuRightId == child.parentRightId; //返回每一项的子级数组
});
if(branchArr.length>0){
father.children = branchArr; //如果存在子级,则给父级添加一个children属性,并赋值
}
return father.parentRightId == -1; //返回第一层
});
return tree;
},
/**
* 获取菜单详情
*/
getMenuDetail() {
const that = this
let para = {
router: that.routePathName,
project: that.repProjectName, project: that.repProjectName,
requestProject: that.repProjectName requestProject: that.repProjectName
} }
that.axios.post(that.baseUrl + '/api-auth/login-clerk-menu',qs.stringify(para)) that.axios.post(that.baseUrl + '/haoban-manage-web/menu-detail',qs.stringify(para))
.then((res) => { .then((res) => {
// console.log(res,res.data,res.data.errorCode) // console.log(res,res.data,res.data.errorCode)
var resData = res.data let resData = res.data
if (resData.errorCode == 0) { if (resData.errorCode == 1) {
that.menuHeadRouter = resData.result; that.pathName = '/' + resData.result.top.url;
console.log(that.menuHeadRouter) console.log(that.menuHeadRouter)
// that.setNewData(resData.result) return;
// 获取左侧菜单 }
that.getLeftMenu() that.$message.error({
duration: 1000,
message: resData.message
})
})
.catch(function (error) {
console.log(error);
// that.toLogin()
that.$message.error({
duration: 1000,
message: error.message
})
});
},
/**
* 获取菜单
*/
getHeaderMenu() {
const that = this
let para = {
project: that.repProjectName,
requestProject: that.repProjectName
}
that.axios.post(that.baseUrl + '/haoban-manage-web/menu-list',qs.stringify(para))
.then((res) => {
// console.log(res,res.data,res.data.errorCode)
let resData = res.data
if (resData.errorCode == 1) {
resData.result.forEach(function(ele,index){
ele.url = '/'+ele.url;
})
that.menuHead = that.treeData(resData.result);
console.log(that.menuHead)
return; return;
} }
that.$message.error({ that.$message.error({
...@@ -213,32 +272,29 @@ ...@@ -213,32 +272,29 @@
}, },
watch: { watch: {
$route: { $route: {
handler: function(val, oldVal){ handler: function(val, oldVal){
console.log("获取当前路由:",val); console.log("获取当前路由:",val);
var that = this const that = this
that.getMenuDetail();
}, },
// 深度观察监听 // 深度观察监听
deep: true deep: true
}, },
collapseFlag: function(newData,oldData){ collapseFlag: function(newData,oldData){
var that = this; const that = this;
that.isCollapse = newData that.isCollapse = newData
}, },
projectName: function(newData,oldData){ projectName: function(newData,oldData){
var that = this; const that = this;
that.repProjectName = newData || 'gic-web'; that.repProjectName = newData || 'haoban-manage-web';
}, },
}, },
/* 接收数据 */
mounted(){ mounted(){
console.log("传递的参数对象:",this.collapseFlag) console.log("传递的参数对象:",this.collapseFlag)
var that = this; const that = this;
that.pathName = that.$route.path that.pathName = that.$route.path
//获取项目名 pathname (路由的hash) //获取项目名 pathname (路由的hash)
...@@ -252,13 +308,13 @@ ...@@ -252,13 +308,13 @@
console.log("routePathname:",that.routePathName) console.log("routePathname:",that.routePathName)
// 项目名 // 项目名
that.repProjectName = that.projectName || 'gic-web'; that.repProjectName = that.projectName || 'haoban-manage-web';
that.isCollapse = that.collapseFlag that.isCollapse = that.collapseFlag
// 获取菜单 // 获取菜单
that.getHeaderMenu(); Promise.all([that.getHeaderMenu(),that.getMenuDetail()]);
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment