QueryPermission.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var list =[]
  2. function QueryPermission(id) {
  3. if(uni.getStorageSync("jurisdiction")){
  4. list = JSON.parse(uni.getStorageSync("jurisdiction"))
  5. }
  6. for (var i = 0; i < list.length; i++) {
  7. if (list[i].children) {
  8. var data = list[i].children
  9. for (var j = 0; j < data.length; j++) {
  10. if (data[j].children) {
  11. var item = data[j].children
  12. for (var k = 0; k < item.length; k++) {
  13. if (item[k].pur_id == id) {
  14. return true
  15. }
  16. }
  17. }
  18. }
  19. }
  20. }
  21. return false
  22. }
  23. function getUserPermission(){
  24. let list = []
  25. if(uni.getStorageSync("jurisdiction")){
  26. list = JSON.parse(uni.getStorageSync("jurisdiction"))
  27. }
  28. return list
  29. }
  30. function getPermissionById(node = getUserPermission(),id) {
  31. for (const child of node) {
  32. if(id == child.pur_id){
  33. return child.children || []
  34. }
  35. if(child.children){
  36. let result = getPermissionById(child.children,id)
  37. if(result){
  38. return result
  39. }
  40. }
  41. }
  42. return null
  43. }
  44. export {
  45. QueryPermission,getPermissionById,getUserPermission
  46. }