AnalysisReportView.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="analysis-report-view">
  3. <div class="part-box part-box-pad">
  4. <el-button
  5. v-for="item in roles"
  6. :key="item.roleId"
  7. type="primary"
  8. class="auth-item"
  9. :disabled="loading"
  10. @click="toAuth(item)"
  11. >{{ item.roleName }}</el-button
  12. >
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { autoSubmitForm } from "@/plugins/utils";
  18. import { ssoAnalysisLogin } from "../api";
  19. export default {
  20. name: "analysis-report-view",
  21. data() {
  22. return {
  23. user: {},
  24. roles: [],
  25. loading: false
  26. };
  27. },
  28. created() {
  29. this.user = this.$ls.get("user", {
  30. roleSource: [],
  31. loginName: "",
  32. role: "",
  33. orgName: ""
  34. });
  35. this.roles = this.user.roleSource.filter(
  36. item => item.roleSource === "ANALYSIS"
  37. );
  38. if (this.$route.query.trigger) {
  39. this.toAuth({ roleCode: this.$route.query.trigger });
  40. }
  41. },
  42. methods: {
  43. async toAuth(item) {
  44. if (this.loading) return;
  45. this.loading = true;
  46. const params = {
  47. loginName: this.user.loginName,
  48. role: item.roleCode,
  49. orgName: this.user.orgInfo.name,
  50. returnUrl: window.location.href
  51. };
  52. const data = await ssoAnalysisLogin(params).catch(() => {});
  53. this.loading = false;
  54. if (!data) return;
  55. console.log(data);
  56. // if (data) return;
  57. autoSubmitForm(data.redirectUrl, data);
  58. }
  59. }
  60. };
  61. </script>