index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { config } from '@/api/request/config.js'
  2. /* 操作权限验证
  3. * str 为权限字符 用于匹配操作角色的字符
  4. * str === performEvacuation 应急疏散操作权限
  5. * str === checkGentle 安全检查
  6. */
  7. export function controlsRestrictVerify(str) {
  8. if(str){
  9. let controlsRestrict = uni.getStorageSync('controlsRestrict');
  10. return controlsRestrict.indexOf(str) != -1;
  11. }else{
  12. return false
  13. }
  14. }
  15. /* 页面权限验证
  16. * str 为权限字符 用于匹配操作角色的字符
  17. */
  18. export function pageRestrictVerify(str) {
  19. if(str){
  20. let permissions = uni.getStorageSync('permissions')+'';
  21. return permissions.indexOf(str) != -1;
  22. }else{
  23. return false
  24. }
  25. }
  26. /* 硬件控制与视频监控权限验证(校级管理员/院级管理员/实验室管理员)
  27. subAdminId 传入的实验室管理员ID
  28. schoolId 校级管理员身份ID
  29. collegeId 院级管理员身份ID
  30. userInfo.position 当前用户身份ID (系统用户为NULL)
  31. userInfo.userId 当前用户userID
  32. */
  33. export function itoOrVideoLimits(subAdminId) {
  34. let userInfo = uni.getStorageSync('user');
  35. let schoolId = config.schoolId;
  36. let collegeId = config.collegeId;
  37. if(userInfo.position == null){
  38. //如果是管理员(系统用户)
  39. return true
  40. }else if(userInfo.position == schoolId || userInfo.position == collegeId){
  41. //如果是校级管理员/院级管理员
  42. return true
  43. }else if(userInfo.userId == subAdminId){
  44. //如果当前用户userId 与 管理员ID相等
  45. return true
  46. }else{
  47. return false
  48. }
  49. }