Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gavel-oa-app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李苏
gavel-oa-app
Commits
5312dc15
Commit
5312dc15
authored
Dec 12, 2024
by
李苏
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步 方法 /调整模块id
parent
c32cf053
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
26 deletions
+44
-26
power.js
common/util/power.js
+2
-3
index.vue
pages/index/index.vue
+42
-23
No files found.
common/util/power.js
View file @
5312dc15
...
...
@@ -5,12 +5,11 @@ export default [
mkmc
:
'考勤管理'
,
image
:
'null'
,
children
:
[{
mkid
:
'1804020
0
00'
,
mkid
:
'1804020
2
00'
,
mkmc
:
'工作日报'
,
image
:
'/static/icon/oa/gzrb.png'
,
page
:
'kqgl-gzrb'
},
}
]
}
]
\ No newline at end of file
pages/index/index.vue
View file @
5312dc15
...
...
@@ -85,29 +85,48 @@
key
:
'mobile'
,
data
:
res
.
data
,
});
const
menuMap
=
res
.
data
.
menu
.
reduce
((
acc
,
item
)
=>
{
acc
[
item
.
mkid
]
=
item
.
mkmc
;
// 创建一个以 mkid 为键,mkmc 为值的映射对象
return
acc
;
},
{});
// 递归函数,用于更新项及其子项的 mkmc
const
updateItemMkmc
=
(
item
)
=>
{
const
newMkmc
=
menuMap
[
item
.
mkid
];
item
.
mkmc
=
newMkmc
;
// 更新当前项的 mkmc
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
// 递归更新子项
item
.
children
=
item
.
children
.
map
(
updateItemMkmc
);
}
return
item
;
};
// 更新 powerList
this
.
powerList
=
this
.
powerList
.
map
(
updateItemMkmc
);
this
.
showList
=
this
.
powerList
.
filter
(
item
=>
item
.
children
&&
item
.
children
.
length
>
0
);
this
.
showList
=
this
.
powerList
;
/* 获取本地权限副本*/
let
powerList
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
powerList
))
/* 获取服务器权限mam*/
let
menuMap
=
new
Map
(
res
.
data
.
menu
.
map
((
item
,
index
)
=>
[
item
.
mkid
,{...
item
,
qz
:
index
}]))
/* 过滤本地权限数组 */
const
filterPower
=
(
powerList
,
menuMap
)
=>
{
let
filteredList
=
[];
powerList
.
forEach
(
item
=>
{
if
(
menuMap
.
has
(
item
.
mkid
))
{
let
menuValue
=
menuMap
.
get
(
item
.
mkid
);
let
updatedItem
=
{
...
item
};
// 创建item的浅拷贝以避免直接修改原对象
updatedItem
.
mkmc
=
menuValue
.
mkmc
;
updatedItem
.
qz
=
menuValue
.
qz
;
if
(
updatedItem
.
children
&&
updatedItem
.
children
.
length
>
0
)
{
updatedItem
.
children
=
filterPower
(
updatedItem
.
children
,
menuMap
);
}
filteredList
.
push
(
updatedItem
);
}
});
return
filteredList
;
};
/* 根据权重递归数据 */
const
sortByQz
=
(
array
)
=>
{
function
compare
(
a
,
b
)
{
return
a
.
qz
-
b
.
qz
;
}
function
recursiveSort
(
arr
)
{
// 对当前数组进行排序
arr
.
sort
(
compare
);
arr
.
forEach
(
item
=>
{
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
recursiveSort
(
item
.
children
);
}
});
}
recursiveSort
(
array
);
return
array
;
}
powerList
=
filterPower
(
powerList
,
menuMap
)
this
.
showList
=
sortByQz
(
powerList
)
console
.
log
(
this
.
showList
,
'最终展示'
)
}
else
{
this
.
$tip
.
alert
(
res
.
message
||
"请求失败"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment