添加菜单处理
This commit is contained in:
@@ -53,13 +53,176 @@ import userApi from "@/api/userApi";
|
|||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
userApi.GetMenuByHttpUser().then((resp) => {
|
//这里动态获取菜单,暂时写死
|
||||||
this.items = resp.data.children;
|
// userApi.GetMenuByHttpUser().then((resp) => {
|
||||||
});
|
// this.items = resp.data.children;
|
||||||
|
// });
|
||||||
|
this.items =
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
icon: "mdi-view-dashboard",
|
||||||
|
router: "/",
|
||||||
|
menu_name: "首页",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 1,
|
||||||
|
children: null,
|
||||||
|
id: 2,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-account-box-multiple",
|
||||||
|
router: null,
|
||||||
|
menu_name: "用户角色管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 1,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
icon: "mdi-account-box",
|
||||||
|
router: "/AdmUser/",
|
||||||
|
menu_name: "用户管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 3,
|
||||||
|
children: null,
|
||||||
|
id: 4,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-account-circle",
|
||||||
|
router: "/admrole/",
|
||||||
|
menu_name: "角色管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 3,
|
||||||
|
children: null,
|
||||||
|
id: 9,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
id: 3,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-account-cash",
|
||||||
|
router: null,
|
||||||
|
menu_name: "角色接口管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 1,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
icon: "mdi-clipboard-check-multiple",
|
||||||
|
router: "/AdmMenu/",
|
||||||
|
menu_name: "菜单管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 14,
|
||||||
|
children: null,
|
||||||
|
id: 15,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-circle-slice-8",
|
||||||
|
router: "/admMould/",
|
||||||
|
menu_name: "接口管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 14,
|
||||||
|
children: null,
|
||||||
|
id: 20,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-clipboard-account",
|
||||||
|
router: "/admRoleMenu/",
|
||||||
|
menu_name: "角色菜单分配管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 14,
|
||||||
|
children: null,
|
||||||
|
id: 25,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
id: 14,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-clipboard-flow-outline",
|
||||||
|
router: null,
|
||||||
|
menu_name: "路由管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 1,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
icon: "mdi-account-eye",
|
||||||
|
router: "/userinfo/",
|
||||||
|
menu_name: "用户信息",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 26,
|
||||||
|
children: null,
|
||||||
|
id: 27,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "mdi-account-eye",
|
||||||
|
router: "/pan",
|
||||||
|
menu_name: "云盘管理",
|
||||||
|
roles: null,
|
||||||
|
mould: null,
|
||||||
|
is_top: 0,
|
||||||
|
sort: 0,
|
||||||
|
is_show: 1,
|
||||||
|
parentId: 26,
|
||||||
|
children: null,
|
||||||
|
id: 28,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
id: 26,
|
||||||
|
is_delete: 0,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
this.$store.dispatch("Logout");
|
this.$store.dispatch("Logout");
|
||||||
this.$router.push({ path: "/login" });
|
this.$router.push({ path: "/login" });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -69,21 +232,18 @@ export default {
|
|||||||
image() {
|
image() {
|
||||||
return this.$store.getters.image;
|
return this.$store.getters.image;
|
||||||
},
|
},
|
||||||
gradient() {
|
gradient() {
|
||||||
return this.$store.getters.gradient;
|
return this.$store.getters.gradient;
|
||||||
},
|
},
|
||||||
drawerImage()
|
drawerImage() {
|
||||||
{
|
return this.$store.state.home.drawerImage;
|
||||||
return this.$store.state.home.drawerImage;
|
},
|
||||||
|
dark() {
|
||||||
|
return this.$store.state.user.dark;
|
||||||
},
|
},
|
||||||
dark()
|
|
||||||
{
|
|
||||||
return this.$store.state.user.dark;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
|
||||||
items: [],
|
items: [],
|
||||||
}),
|
}),
|
||||||
name: "DefaultDrawer",
|
name: "DefaultDrawer",
|
||||||
|
|||||||
@@ -1,12 +1,29 @@
|
|||||||
export function setMenu(menuList) {
|
export function setTreeMenu(menuList) {
|
||||||
if(menuList!=null && menuList.Count()>0)
|
if (menuList != null && menuList.length > 0) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
//结果
|
||||||
|
var res;
|
||||||
|
//获取最小的parentId
|
||||||
|
var minParentId = 0;
|
||||||
|
//获取id=最小的parentId的菜单列表
|
||||||
|
var menuList1=menuList.filter((item)=>{item.parentId==minParentId}) ;
|
||||||
|
|
||||||
|
menuList1.forEach(element=>{
|
||||||
|
res.push(element)
|
||||||
|
var children=menuList.filter((item)=>{item.parentId==element.id}) ;
|
||||||
|
if (children.length > 0) {
|
||||||
|
setTreeChildren(menuList, children,element)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTreeChildren(menuList)
|
function setTreeChildren(menuList, childrenList,model) {
|
||||||
{
|
childrenList.forEach(element => {
|
||||||
|
model.Childs.push(element);
|
||||||
|
var childrenList2=menuList.filter((item)=>{item.parentId==element.id}) ;
|
||||||
|
if (childrenList2.length > 0) {
|
||||||
|
setTreeChildren(menuList, childrenList2,element)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
71
Yi.Vue2.x/src/util/objctHandle,js
Normal file
71
Yi.Vue2.x/src/util/objctHandle,js
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
//深拷贝
|
||||||
|
export function deepCopy(obj) {
|
||||||
|
var a = JSON.stringify(obj);
|
||||||
|
var newobj = JSON.parse(a);
|
||||||
|
return newobj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//转换数据,0是相等,1是模糊查询
|
||||||
|
export function objctToDic(object, isByPage) {
|
||||||
|
if (isByPage) {
|
||||||
|
var paramPage = {
|
||||||
|
"index": object.pageIndex,
|
||||||
|
"size": object.pageSize,
|
||||||
|
"parameters": [],
|
||||||
|
"orderBys": []
|
||||||
|
}
|
||||||
|
|
||||||
|
var newData = deepCopy(object);
|
||||||
|
delete newData.pageIndex;
|
||||||
|
delete newData.pageSize;
|
||||||
|
|
||||||
|
var newList = [Object.keys(newData).map(val => {
|
||||||
|
return {
|
||||||
|
key: val,
|
||||||
|
value: object[val],
|
||||||
|
type: 1
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
|
||||||
|
//过滤封装
|
||||||
|
newList[0].forEach((item, index) => {
|
||||||
|
if(item.value.length>0)
|
||||||
|
{
|
||||||
|
if(item.key=='isDeleted')
|
||||||
|
{
|
||||||
|
item.type=0;
|
||||||
|
}
|
||||||
|
paramPage.parameters.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return paramPage;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var params = {
|
||||||
|
"parameters": [],
|
||||||
|
"orderBys": []
|
||||||
|
}
|
||||||
|
var thisList = [Object.keys(object).map(val => {
|
||||||
|
return {
|
||||||
|
key: val,
|
||||||
|
value: object[val],
|
||||||
|
type: 1
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
thisList[0].forEach((item, index) => {
|
||||||
|
if(item.value.length>0)
|
||||||
|
{
|
||||||
|
if(item.key=='isDeleted')
|
||||||
|
{
|
||||||
|
item.type=0;
|
||||||
|
}
|
||||||
|
params.parameters.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user