permission.js 706 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * long description for the file
  3. *
  4. * @summary 权限判断函数
  5. * @author wu <308822989@qq.com>
  6. *
  7. * Created at : 2018-08-12 14:52:51
  8. * Last modified : 2018-08-18 18:11:42
  9. */
  10. import store from '@/store/index.js';
  11. import { dgTree } from '@/utils/util.js';
  12. /**
  13. * 菜单树上功能权限判断函数
  14. * @param {String} menuCode 功能编码
  15. * @returns {Boolean} 菜单树上是否有这个菜单 有:true, 没有:false
  16. */
  17. const checkPermission = function (menuCode) {
  18. let bol = false;
  19. let menu = store.state.routes;
  20. dgTree(menu, 'children', item => {
  21. if (item.menuCode === menuCode) {
  22. bol = true;
  23. }
  24. });
  25. return bol;
  26. }
  27. // 默认
  28. export default checkPermission;