Commit c1826656 by 冒粤蓉

fix

1 parent 1f877a14
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</template> </template>
<script> <script>
import { reactive, toRefs, onBeforeMount, computed } from 'vue'; import { reactive, toRefs, onBeforeMount, onMounted, computed } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import MenuService from 'services/Menu'; import MenuService from 'services/Menu';
...@@ -161,17 +161,37 @@ export default { ...@@ -161,17 +161,37 @@ export default {
if(path === '/noData') { if(path === '/noData') {
showEmpty = true; showEmpty = true;
} }
store.dispatch('menu/setBreadCrumb', [{ getMenuAuth(cItem.id, cOrigin.menuName);
name: pOrigin.menuName,
path: pOrigin.frontRoute
}]);
store.dispatch('app/setCommonData', { showEmpty }); store.dispatch('app/setCommonData', { showEmpty });
history.pushState(null, path, path); history.pushState({
breadcrumb: [
{
name: pOrigin.menuName,
path: pOrigin.frontRoute
},
{
name: cOrigin.menuName,
path: cOrigin.frontRoute
}
]
}, path, path);
} }
// 获取权限菜单(假数据) // 获取权限菜单(假数据)
// const res = {"code":200,"data":[{"children":[{"children":[],"id":20101,"origin":{"menuNo":20101,"menuName":"ODB管理","parentId":201,"type":2,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":201,"label":"ODB管理"}],"id":201,"origin":{"menuNo":201,"menuName":"设备管理","parentId":0,"type":1,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":0,"label":"设备管理"},{"children":[{"children":[],"id":30101,"origin":{"menuNo":30101,"menuName":"测试菜单","parentId":301,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":301,"label":"测试菜单"}],"id":301,"origin":{"menuNo":301,"menuName":"测试菜单","parentId":0,"type":1,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":0,"label":"测试菜单"},{"children":[{"children":[],"id":10101,"origin":{"menuNo":10101,"menuName":"用户管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":101,"label":"用户管理"},{"children":[],"id":10102,"origin":{"menuNo":10102,"menuName":"用户组管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":2,"checked":false},"order":2,"depth":null,"parentId":101,"label":"用户组管理"},{"children":[],"id":10103,"origin":{"menuNo":10103,"menuName":"角色管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":3,"checked":false},"order":3,"depth":null,"parentId":101,"label":"角色管理"},{"children":[],"id":10104,"origin":{"menuNo":10104,"menuName":"菜单管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":4,"checked":false},"order":4,"depth":null,"parentId":101,"label":"菜单管理"},{"children":[],"id":10105,"origin":{"menuNo":10105,"menuName":"组织管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":5,"checked":false},"order":5,"depth":null,"parentId":101,"label":"组织管理"},{"children":[{"children":[],"id":1010607,"origin":{"menuNo":1010607,"menuName":"数据字典3","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典3"},{"children":[],"id":1010608,"origin":{"menuNo":1010608,"menuName":"数据字典4","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典4"},{"children":[],"id":1010609,"origin":{"menuNo":1010609,"menuName":"数据字典5","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典5"},{"children":[],"id":1010610,"origin":{"menuNo":1010610,"menuName":"数据字典6","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典6"}],"id":10106,"origin":{"menuNo":10106,"menuName":"字典管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":6,"checked":false},"order":6,"depth":null,"parentId":101,"label":"字典管理"},{"children":[],"id":10107,"origin":{"menuNo":10107,"menuName":"操作日志","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":7,"checked":false},"order":7,"depth":null,"parentId":101,"label":"操作日志"}],"id":101,"origin":{"menuNo":101,"menuName":"系统管理","parentId":0,"type":1,"icon":null,"frontRoute":null,"orderNum":2,"checked":false},"order":2,"depth":null,"parentId":0,"label":"系统管理"}],"message":"success"}; // const res = {"code":200,"data":[{"children":[{"children":[],"id":20101,"origin":{"menuNo":20101,"menuName":"ODB管理","parentId":201,"type":2,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":201,"label":"ODB管理"}],"id":201,"origin":{"menuNo":201,"menuName":"设备管理","parentId":0,"type":1,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":0,"label":"设备管理"},{"children":[{"children":[],"id":30101,"origin":{"menuNo":30101,"menuName":"测试菜单","parentId":301,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":301,"label":"测试菜单"}],"id":301,"origin":{"menuNo":301,"menuName":"测试菜单","parentId":0,"type":1,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":0,"label":"测试菜单"},{"children":[{"children":[],"id":10101,"origin":{"menuNo":10101,"menuName":"用户管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":1,"checked":false},"order":1,"depth":null,"parentId":101,"label":"用户管理"},{"children":[],"id":10102,"origin":{"menuNo":10102,"menuName":"用户组管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":2,"checked":false},"order":2,"depth":null,"parentId":101,"label":"用户组管理"},{"children":[],"id":10103,"origin":{"menuNo":10103,"menuName":"角色管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":3,"checked":false},"order":3,"depth":null,"parentId":101,"label":"角色管理"},{"children":[],"id":10104,"origin":{"menuNo":10104,"menuName":"菜单管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":4,"checked":false},"order":4,"depth":null,"parentId":101,"label":"菜单管理"},{"children":[],"id":10105,"origin":{"menuNo":10105,"menuName":"组织管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":5,"checked":false},"order":5,"depth":null,"parentId":101,"label":"组织管理"},{"children":[{"children":[],"id":1010607,"origin":{"menuNo":1010607,"menuName":"数据字典3","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典3"},{"children":[],"id":1010608,"origin":{"menuNo":1010608,"menuName":"数据字典4","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典4"},{"children":[],"id":1010609,"origin":{"menuNo":1010609,"menuName":"数据字典5","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典5"},{"children":[],"id":1010610,"origin":{"menuNo":1010610,"menuName":"数据字典6","parentId":10106,"type":2,"icon":null,"frontRoute":"bbb","orderNum":1,"checked":false},"order":1,"depth":null,"parentId":10106,"label":"数据字典6"}],"id":10106,"origin":{"menuNo":10106,"menuName":"字典管理","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":6,"checked":false},"order":6,"depth":null,"parentId":101,"label":"字典管理"},{"children":[],"id":10107,"origin":{"menuNo":10107,"menuName":"操作日志","parentId":101,"type":2,"icon":null,"frontRoute":null,"orderNum":7,"checked":false},"order":7,"depth":null,"parentId":101,"label":"操作日志"}],"id":101,"origin":{"menuNo":101,"menuName":"系统管理","parentId":0,"type":1,"icon":null,"frontRoute":null,"orderNum":2,"checked":false},"order":2,"depth":null,"parentId":0,"label":"系统管理"}],"message":"success"};
// const getNewTree = getMenuTree(res.data, menuTreeLocalList); // const getNewTree = getMenuTree(res.data, menuTreeLocalList);
const getMenuAuth = (parentId, menuName) => {
const menuService = new MenuService();
menuService.getMenuAuth({parentId}).then( res => {
const { code, data } = res;
if(code == 200) {
store.dispatch('menu/setMenuAuth', {menuName, data});
}
}, err => {
})
}
// 获取菜单树接口 // 获取菜单树接口
const getServerTree = async (isInit) => { const getServerTree = async (isInit) => {
...@@ -213,6 +233,18 @@ export default { ...@@ -213,6 +233,18 @@ export default {
getServerTree(true); getServerTree(true);
}) })
onMounted(()=> {
window.addEventListener("popstate", function(e) {
const { state } = e;
if(state) {
const { breadcrumb } = state;
if(breadcrumb) {
store.dispatch('menu/setBreadCrumb', breadcrumb);
}
}
}, false);
})
const updateMenu = computed(() => { const updateMenu = computed(() => {
const updateNow = !!store.getters.updateMenu; const updateNow = !!store.getters.updateMenu;
if(updateNow) { if(updateNow) {
......
...@@ -52,58 +52,9 @@ export default { ...@@ -52,58 +52,9 @@ export default {
}) })
const breadCrumbList = computed(() => { const breadCrumbList = computed(() => {
const curBreadCrumb = store.getters.curBreadCrumb, return store.getters.curBreadCrumb;
curParent = curBreadCrumb['parent'],
curChildren = curBreadCrumb['children'];
let breadCrumbList = [];
if (curParent) {
breadCrumbList.push({
name: curChildren.menuName ? curParent.menuName : curParent.menuName
});
}
if (curChildren) {
const nextChildren = curChildren.children;
breadCrumbList.push({
name: nextChildren ? curChildren.menuName : curChildren.menuName,
path: curChildren.path,
active: nextChildren ? false : true
});
const store = useStore();
onMounted(() => {
state.el_sub_innerH = elmSubMicro._value.innerHTML;
// 监听子系统挂载的元素内容变化
const subMircroEle = document.getElementById('sub-system-frame');
subMircroEle.addEventListener('DOMNodeInserted', function(e) {
const target = e.currentTarget,
tarInner = target.innerHTML;
if(!state.el_sub_innerH !== !tarInner) {
state.el_sub_innerH = target.innerHTML;
}
})
})
const showEmpty = computed(() => {
return store.getters.commonData.showEmpty || !state.el_sub_innerH;
})
const breadCrumbList = computed(() => {
return store.getters.curBreadCrumb;
})
const routerGo = (item, path) => {
// store.dispatch('menu/setBreadCrumb', saveBreadCrumb);
// history.pushState(null, path, path);
}
}
return breadCrumbList;
}) })
const routerGo = (item, path) => { const routerGo = (item, path) => {
let saveBreadCrumb = {}; let saveBreadCrumb = {};
const thisName = item.name.replace(' / ', ''); const thisName = item.name.replace(' / ', '');
......
...@@ -10,6 +10,7 @@ const API = { ...@@ -10,6 +10,7 @@ const API = {
LOGIN_CAPTCHA: '/usercenter/captcha', // 非接口,直接url可展示验证码 LOGIN_CAPTCHA: '/usercenter/captcha', // 非接口,直接url可展示验证码
LOGIN_ACTION: '/usercenter/login', // 登录接口 LOGIN_ACTION: '/usercenter/login', // 登录接口
MENU_TREE_ACTION: '/usercenter/menu/permtree', // 用户登录成功后拉取权限菜单 MENU_TREE_ACTION: '/usercenter/menu/permtree', // 用户登录成功后拉取权限菜单
MENU_AUTH: '/usercenter/menu/subtree'
} }
export { export {
......
...@@ -11,7 +11,20 @@ export default class MenuService extends HTTP { ...@@ -11,7 +11,20 @@ export default class MenuService extends HTTP {
resolve(data); resolve(data);
}, },
error (error) { error (error) {
console.log('menu/permtree接口请求失败'); }
})
});
}
getMenuAuth(data) {
return new Promise((resolve, reject) => {
this.axiosGet({
url: API.MENU_AUTH,
data,
success (data) {
resolve(data);
},
error (error) {
} }
}) })
}); });
......
...@@ -10,7 +10,8 @@ const getters = { ...@@ -10,7 +10,8 @@ const getters = {
fullscreen: state => state.app.fullscreen, fullscreen: state => state.app.fullscreen,
menu: state => state.menu.menu, menu: state => state.menu.menu,
curBreadCrumb: state => state.menu.curBreadCrumb, curBreadCrumb: state => state.menu.curBreadCrumb,
updateMenu: state => state.menu.updateMenu updateMenu: state => state.menu.updateMenu,
curMenuAuth: state => state.menu.curMenuAuth,
} }
export default getters; export default getters;
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,8 @@ let state = { ...@@ -2,7 +2,8 @@ let state = {
is_collapse: false, // 折叠状态 is_collapse: false, // 折叠状态
menu: [], // 菜单数据 menu: [], // 菜单数据
curBreadCrumb: [], curBreadCrumb: [],
updateMenu: false updateMenu: false,
curMenuAuth: []
}; };
let init = false; let init = false;
try { try {
...@@ -29,8 +30,11 @@ export default { ...@@ -29,8 +30,11 @@ export default {
}, },
// 设置面包屑 // 设置面包屑
SET_BREAD_CRUMB(state, data) { SET_BREAD_CRUMB(state, data) {
state.curBreadCrumb = data; if(!init) {
localStorage.setItem('breadcrumb', JSON.stringify(data)); state.curBreadCrumb = data;
localStorage.setItem('breadcrumb', JSON.stringify(data));
}
init = false;
}, },
ADD_BREAD_CRUMB(state, data) { ADD_BREAD_CRUMB(state, data) {
if(!init) { if(!init) {
...@@ -44,6 +48,10 @@ export default { ...@@ -44,6 +48,10 @@ export default {
UPDATE_MENU(state, data) { UPDATE_MENU(state, data) {
state.updateMenu = data; state.updateMenu = data;
}, },
// 菜单权限
SET_MENU_AUTH(state, data) {
state.curMenuAuth = data;
},
}, },
actions: { actions: {
// 推入用户菜单 // 推入用户菜单
...@@ -64,6 +72,9 @@ export default { ...@@ -64,6 +72,9 @@ export default {
// 子系统操作更新菜单 // 子系统操作更新菜单
updateMenu({commit}, data) { updateMenu({commit}, data) {
commit('UPDATE_MENU', data) commit('UPDATE_MENU', data)
} },
setMenuAuth({commit}, data) {
commit('SET_MENU_AUTH', data)
},
} }
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!