| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- var list =[]
- function QueryPermission(id) {
- if(uni.getStorageSync("jurisdiction")){
- list = JSON.parse(uni.getStorageSync("jurisdiction"))
- }
- for (var i = 0; i < list.length; i++) {
- if (list[i].children) {
- var data = list[i].children
- for (var j = 0; j < data.length; j++) {
- var item = data[j]
- if (item.pur_id == id) {
- return true
- }
- }
- }
- }
- return false
- }
- function getUserPermission(){
- let list = []
- if(uni.getStorageSync("jurisdiction")){
- list = JSON.parse(uni.getStorageSync("jurisdiction"))
- }
- return list
- }
- function getPermissionById(node = getUserPermission(),id) {
- for (const child of node) {
- if(id == child.pur_id){
- return child.children || []
- }
- if(child.children){
- let result = getPermissionById(child.children,id)
- if(result){
- return result
- }
- }
- }
- return null
- }
- export {
- QueryPermission,getPermissionById,getUserPermission
- }
|