| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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++) {
- if (data[j].children) {
- var item = data[j].children
- for (var k = 0; k < item.length; k++) {
- if (item[k].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
- }
|