transferPage.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div></div>
  3. </template>
  4. <script>
  5. import { departInterence } from '@/api/api.js';
  6. export default {
  7. data() {
  8. return {
  9. }
  10. },
  11. created() {
  12. this.init()
  13. },
  14. methods: {
  15. async init() {
  16. if (Object.keys(this.$route.query).length <= 0) {
  17. this.$router.replace('/login')
  18. return
  19. }
  20. // debugger;
  21. const res = await departInterence.useCodeLogin(this.$route.query)
  22. // console.log(res);
  23. // debugger;
  24. if (res.Ret !== 200) {
  25. this.$router.replace('/login?HZ=1')
  26. return
  27. }
  28. localStorage.setItem('auth', res.Data.Authorization)
  29. localStorage.setItem('userName', res.Data.RealName)
  30. localStorage.setItem('Role', res.Data.RoleTypeCode)
  31. localStorage.setItem('RoleIdentity', res.Data.SysRoleTypeCode)
  32. localStorage.setItem('RoleType', res.Data.ProductName)
  33. localStorage.setItem('ManageType', res.Data.Authority)
  34. localStorage.setItem('AdminId', res.Data.AdminId)
  35. localStorage.setItem('AdminName', res.Data.AdminName)
  36. // 如果路由参数有redirect_uri则跳转到redirect_uri,redirect_uri通过encode
  37. if (this.$route.query.redirect_uri) {
  38. const path = decodeURIComponent(this.$route.query.redirect_uri)
  39. this.$router.push(path)
  40. return
  41. }
  42. let path = "";
  43. switch (res.Data.RoleTypeCode) {
  44. case "rai_researcher":
  45. case "ficc_researcher":
  46. case "researcher":
  47. path = "/reportlist";
  48. break;
  49. // case "compliance": //合规
  50. // path = "/contractapprovallist";
  51. // break;
  52. case "special_researcher": //特邀研究员
  53. path = "/dataList";
  54. break;
  55. // case "special_ficc_seller":
  56. // path = "/meetingCalendar";
  57. // break;
  58. default:
  59. path = await this.getOtherRolePath("myCalendar");
  60. }
  61. this.$router.push({ path });
  62. },
  63. getOtherRolePath(pathVal) {
  64. return departInterence.getMenu().then(res => {
  65. let resolvePath = ''
  66. if (res.Ret === 200) {
  67. let menuList = res.Data.List || [];
  68. if (!menuList.length) {
  69. this.$message.error('该账号没有任何菜单权限,请联系管理员')
  70. return
  71. }
  72. // 是否已经拿到菜单信息
  73. sessionStorage.setItem('hasGetMenu', 'true')
  74. sessionStorage.setItem('MenuList', JSON.stringify(menuList));
  75. /* 是否有数据报表权限 */
  76. this.$store.commit('SET_DATA_AUTH', menuList.some(item => item.name === '报表统计'))
  77. for (let i = 0; i < menuList.length; i++) {
  78. const element = menuList[i];
  79. const arr = menuList[i].children || []
  80. if (arr.some(it => it.path == pathVal)) {
  81. resolvePath = '/' + pathVal
  82. break
  83. }
  84. }
  85. return resolvePath || '/' + menuList[0].children[0].path
  86. }
  87. return '/' + pathVal
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style></style>