Ver código fonte

题库单点登录

zhangjie 2 anos atrás
pai
commit
d4194d1be2

+ 1 - 1
src/main.js

@@ -16,7 +16,7 @@ import "../card/assets/styles/module.scss";
 
 Vue.use(ElementUI, { size: "small" });
 
-Vue.use(VueLocalStorage, { snamespace: "vs_", torage: "session" });
+Vue.use(VueLocalStorage, { snamespace: "vs_", storage: "session" });
 Vue.use(globalVuePlugins);
 
 Vue.prototype.GLOBAL = GLOBAL;

+ 2 - 1
src/modules/login/views/LoginOpen.vue

@@ -27,6 +27,8 @@ export default {
     async autoLogin() {
       this.$ls.clear();
       const query = this.$route.query;
+      this.$ls.set("returnUrl", decodeURIComponent(query["returnUrl"]));
+
       const data = await openLogin({
         ...query,
         path: "/#/login-open"
@@ -44,7 +46,6 @@ export default {
       this.$ls.set("user", data, this.GLOBAL.authTimeout);
 
       this.$ls.set("token", data.accessToken, this.GLOBAL.authTimeout);
-      this.$ls.set("returnUrl", query["returnUrl"]);
 
       if (data.roleList && data.roleList.includes("ADMIN")) {
         this.$router.push({

+ 4 - 0
src/modules/stmms/api.js

@@ -68,3 +68,7 @@ export const syncResultListPage = datas => {
 export const syncResync = id => {
   return $postParam("/api/admin/data/sync/resync", { id });
 };
+// question-library-manage
+export const tikuAuth = datas => {
+  return $postParam("/api/admin/exam/sso/question_library_login", datas);
+};

+ 6 - 0
src/modules/stmms/router.js

@@ -2,6 +2,7 @@ import MarkerLogin from "./views/MarkerLogin.vue";
 import ScoreArchive from "./views/ScoreArchive.vue";
 import UploadStructure from "./views/UploadStructure.vue";
 import SyncManage from "./views/SyncManage.vue";
+import QuestionLibraryManage from "./views/QuestionLibraryManage.vue";
 
 export default [
   {
@@ -23,5 +24,10 @@ export default [
     path: "/stmms/sync-manage",
     name: "SyncManage",
     component: SyncManage
+  },
+  {
+    path: "/tiku/question-library-manage",
+    name: "QuestionLibraryManage",
+    component: QuestionLibraryManage
   }
 ];

+ 74 - 0
src/modules/stmms/views/QuestionLibraryManage.vue

@@ -0,0 +1,74 @@
+<template>
+  <div class="question-library-manage marker-login">
+    <div class="part-box part-box-pad">
+      <el-button
+        v-for="item in roles"
+        :key="item.roleCode"
+        type="primary"
+        class="auth-item"
+        :disabled="loading"
+        @click="toAuth(item)"
+        >{{ item.roleName }}</el-button
+      >
+    </div>
+  </div>
+</template>
+
+<script>
+import { tikuAuth } from "../api";
+
+export default {
+  name: "question-library-manage",
+  data() {
+    return {
+      roleNames: {
+        SUBJECT_TEACHER: "学科老师",
+        ASSIGN_TEACHER: "命题老师"
+      },
+      roles: [],
+      user: {},
+      loading: false
+    };
+  },
+  mounted() {
+    this.user = this.$ls.get("user");
+    this.getRoles();
+    if (this.$route.query.trigger) {
+      this.toAuth({ roleCode: this.$route.query.trigger });
+    }
+  },
+  methods: {
+    getRoles() {
+      const userRoles = this.user.roleSource.filter(
+        item => item.roleSource === "QUESTION_LIBRARY"
+      );
+      if (!userRoles.length) {
+        this.$message.error("当前用户无对应角色!");
+        return;
+      }
+      const stRole = userRoles.find(
+        item => item.roleCode === "SUBJECT_TEACHER"
+      );
+      if (stRole) {
+        this.roles = [stRole];
+      } else {
+        this.roles = [userRoles[0]];
+      }
+    },
+    async toAuth(item) {
+      if (this.loading) return;
+      this.loading = true;
+      const data = await tikuAuth({
+        loginName: this.user.loginName,
+        realName: this.user.realName,
+        role: item.roleCode,
+        returnUrl: encodeURIComponent(window.location.href)
+      }).catch(() => {});
+      this.loading = false;
+
+      if (!data) return;
+      window.location.href = data.redirectUrl;
+    }
+  }
+};
+</script>