permissionComponent.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import modularLoading from '@views/newWorkBench/template/modularLoading.vue';
  2. import noPermission from '@views/newWorkBench/template/noPermission.vue';
  3. import { mapState } from 'vuex';
  4. export default {
  5. components: {
  6. //默认加载
  7. modularLoading,
  8. noPermission
  9. },
  10. data() {
  11. return {
  12. loadding: true,
  13. defaultModel: {
  14. permissUrl: "",
  15. titleName: ""
  16. },
  17. permisStatus: false
  18. }
  19. },
  20. computed: {
  21. //全局社区
  22. ...mapState(['homeCommunityAll']),
  23. // 定义模块显示隐藏
  24. permissionFiltering() {
  25. let arr = this.$store.getters['getMenuList'] || [];
  26. if (arr.length !== 0) {
  27. setTimeout(() => {
  28. this.loadding = false;
  29. }, 700)
  30. this.permissionStr(arr)
  31. return this.permisStatus;
  32. } else {
  33. return this.permisStatus;
  34. }
  35. }
  36. },
  37. watch: {
  38. //全局社区接口调用
  39. homeCommunityAll(val) {
  40. try {
  41. this.mixins_query.communityId = val;
  42. this.getData();
  43. } catch {
  44. }
  45. }
  46. },
  47. methods: {
  48. // 需要什么权限才能查看
  49. filterFuntion(arr, nameTitle, linkPaths) {
  50. arr.map((item) => {
  51. if (item.name == nameTitle && item.linkPath == linkPaths) {
  52. this.permisStatus = true
  53. } else if (!!item.children) {
  54. this.filterFuntion(item.children, nameTitle, linkPaths);
  55. }
  56. });
  57. },
  58. permissionStr(arr) {
  59. const { permissUrl, titleName } = this.defaultModel;
  60. if (!!permissUrl && !!titleName) {
  61. return this.filterFuntion(arr, titleName, permissUrl);
  62. }
  63. },
  64. }
  65. }