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 @@
"name": "@gic-test/vue-office-header",
"description": "vue-office-header Plugin",
"author": "fairyly <498745097@qq.com>",
"version": "1.0.5",
"version": "1.0.8",
"license": "MIT",
"private": false,
"main": "dist/vue-office-header.js",
......
......@@ -11,8 +11,13 @@
<div :class="['itemlink-gic', 'bottom', pathName=='gic-web'? 'current-module':'']">GIC商户后台</div> -->
<!-- menu -->
<template v-for="menuitem in menuHead">
<a :class="['itemlink', 'bottom','menu-mall',pathName==menuitem.menuUrl? 'current-module':'']" :href="'#'+menuitem.menuUrl" :target="menuitem.target == 1?'_blank':''">{{menuitem.menuName}}</a>
<template v-for="(menuitem,index) in menuHead">
<a
:key="index"
:class="['itemlink', 'bottom','menu-mall',pathName == menuitem.url? 'current-module':'']"
:href="'#'+menuitem.url" >
{{menuitem.rightName}}
</a>
</template>
<!-- 最右侧用户信息 -->
<div class="navuserinfo fr">
......@@ -31,7 +36,7 @@
props: ['menuRouter','collapseFlag','projectName'],
data () {
return {
repProjectName: 'gic-web', // 项目名
repProjectName: 'haoban-manage-web', // 项目名
// 当前路由
pathName: '',
......@@ -40,48 +45,48 @@
// 菜单数据
menuHead: [
{
menuCode: null,
menuName: "首页",
menuUrl: "/index",
parentCode: null,
project: "office"
},
{
menuCode: null,
menuName: "通讯录",
menuUrl: "/administrativeFrame",
parentCode: null,
project: "office"
},
{
menuCode: null,
menuName: "企业应用",
menuUrl: "/enterpriseApp",
parentCode: null,
project: "office"
},
{
menuCode: null,
menuName: "审核中心",
menuUrl: "/unreview",
parentCode: null,
project: "office"
},
{
menuCode: null,
menuName: "我的企业",
menuUrl: "/myCompany",
parentCode: null,
project: "office"
},
{
menuCode: null,
menuName: "设置",
menuUrl: "/companyAddress",
parentCode: null,
project: "office"
},
// {
// menuCode: null,
// rightName: "首页",
// url: "/index",
// parentCode: null,
// project: "office"
// },
// {
// menuCode: null,
// rightName: "通讯录",
// url: "/administrativeFrame",
// parentCode: null,
// project: "office"
// },
// {
// menuCode: null,
// rightName: "企业应用",
// url: "/enterpriseApp",
// parentCode: null,
// project: "office"
// },
// {
// menuCode: null,
// rightName: "审核中心",
// url: "/unreview",
// parentCode: null,
// project: "office"
// },
// {
// menuCode: null,
// rightName: "我的企业",
// url: "/myCompany",
// parentCode: null,
// project: "office"
// },
// {
// menuCode: null,
// rightName: "设置",
// url: "/companyAddress",
// parentCode: null,
// project: "office"
// },
],
// 获取 location origin
......@@ -91,11 +96,11 @@
}
},
beforeMount() {
var that = this
var host = window.location.origin;
const that = this
let host = window.location.origin;
console.log("当前host:",host)
if (host.indexOf('localhost') != '-1') {
that.baseUrl = 'http://gicdev.demogic.com';
that.baseUrl = 'http://www.gicdev.com';
}else {
that.baseUrl = host
}
......@@ -104,7 +109,7 @@
// 处理折叠
handleCollapse() {
var that = this;
const that = this;
that.isCollapse = (that.isCollapse==true? false: true);
that.$emit('collapseTag', that.isCollapse)
},
......@@ -116,7 +121,7 @@
//退出登录
toLoginOut() {
var that = this;
const that = this;
// var para = {
// requestProject: that.repProjectName
// }
......@@ -127,14 +132,14 @@
that.axios.post(that.baseUrl+'/api-auth/do-logout',{})
.then((res) => {
// console.log(res,res.data,res.data.errorCode)
var resData = res.data
let resData = res.data
if (resData.errorCode == 0) {
that.$message({
message: '退出成功',
type: 'success'
});
// 跳转登录页
window.location.href = window.location.origin + '/gic-web/#/';
window.location.href = window.location.origin + '/haoban-web/#/login';
return;
}
......@@ -165,7 +170,7 @@
// 触发父组件路由
toRouter(path,name,code) {
var that = this;
const that = this;
var obj ={
path: '/'+ path,
......@@ -174,25 +179,79 @@
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,
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) => {
// console.log(res,res.data,res.data.errorCode)
var resData = res.data
if (resData.errorCode == 0) {
let resData = res.data
if (resData.errorCode == 1) {
that.menuHeadRouter = resData.result;
that.pathName = '/' + resData.result.top.url;
console.log(that.menuHeadRouter)
// that.setNewData(resData.result)
// 获取左侧菜单
that.getLeftMenu()
return;
}
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;
}
that.$message.error({
......@@ -213,32 +272,29 @@
},
watch: {
$route: {
handler: function(val, oldVal){
console.log("获取当前路由:",val);
var that = this
const that = this
that.getMenuDetail();
},
// 深度观察监听
deep: true
},
collapseFlag: function(newData,oldData){
var that = this;
const that = this;
that.isCollapse = newData
},
projectName: function(newData,oldData){
var that = this;
that.repProjectName = newData || 'gic-web';
const that = this;
that.repProjectName = newData || 'haoban-manage-web';
},
},
/* 接收数据 */
mounted(){
console.log("传递的参数对象:",this.collapseFlag)
var that = this;
const that = this;
that.pathName = that.$route.path
//获取项目名 pathname (路由的hash)
......@@ -252,13 +308,13 @@
console.log("routePathname:",that.routePathName)
// 项目名
that.repProjectName = that.projectName || 'gic-web';
that.repProjectName = that.projectName || 'haoban-manage-web';
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