permission.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {useUserStore} from "@/pinia/user-store";
  2. const userRoles = useUserStore().userInfo.roles
  3. export function getGreatestRole() {
  4. if (userRoles) {
  5. if (userRoles.indexOf(1) > -1 || userRoles.indexOf('1') > -1) {
  6. return 1
  7. }
  8. if (userRoles.indexOf(2) > -1 || userRoles.indexOf('2') > -1) {
  9. return 2
  10. }
  11. if (userRoles.indexOf(3) > -1 || userRoles.indexOf('3') > -1) {
  12. return 3
  13. }
  14. if (userRoles.indexOf(5) > -1 || userRoles.indexOf('5') > -1) {
  15. return 5
  16. }
  17. if (userRoles.indexOf(8) > -1 || userRoles.indexOf('8') > -1) {
  18. return 8
  19. }
  20. return 99
  21. }
  22. }
  23. export function allWardsVisible() {
  24. if (userRoles) {
  25. return userRoles.indexOf(1) > -1 || userRoles.indexOf(2) > -1 || userRoles.indexOf(8) > -1
  26. }
  27. return false
  28. }
  29. export function isInpatientStaff() {
  30. if (userRoles) {
  31. return userRoles.indexOf(3) > -1 || userRoles.indexOf(4) > -1
  32. }
  33. return false
  34. }
  35. export function recoveryTradePermission() {
  36. if (userRoles) {
  37. return userRoles.indexOf(41) > -1
  38. }
  39. return false
  40. }