소스 검색

超管功能添加

zhangjie 4 년 전
부모
커밋
bc8462edd3

+ 7 - 3
src/components/UploadButton.vue

@@ -78,6 +78,12 @@ export default {
       uploadDataDict: {}
     };
   },
+  created() {
+    this.headers = {
+      ...this.headers,
+      ...this.getHeadIds()
+    };
+  },
   methods: {
     checkFileFormat(fileType) {
       const _file_format = fileType
@@ -90,9 +96,7 @@ export default {
     },
     async handleBeforeUpload(file) {
       this.uploadDataDict = {
-        ...this.uploadData,
-        schoolId: this.$ls.get("schoolId"),
-        userId: this.$ls.get("user", { id: "" }).id
+        ...this.uploadData
       };
       this.uploadDataDict[this.addFilenameParam] = file.name;
 

+ 7 - 3
src/components/UploadFileView.vue

@@ -95,6 +95,12 @@ export default {
       res: {}
     };
   },
+  created() {
+    this.headers = {
+      ...this.headers,
+      ...this.getHeadIds()
+    };
+  },
   methods: {
     startUpload() {
       this.loading = true;
@@ -115,9 +121,7 @@ export default {
     },
     async handleBeforeUpload(file) {
       this.uploadDataDict = {
-        ...this.uploadData,
-        schoolId: this.$ls.get("schoolId"),
-        userId: this.$ls.get("user", { id: "" }).id
+        ...this.uploadData
       };
       this.uploadDataDict[this.addFilenameParam] = file.name;
 

+ 1 - 1
src/constants/navs.js

@@ -43,7 +43,7 @@ const navs = [
       },
       {
         title: "印刷管理",
-        name: "paper",
+        name: "print",
         icon: "el-icon-s-check",
         children: [
           {

+ 10 - 0
src/main.js

@@ -70,6 +70,16 @@ axios.interceptors.request.use(
     // 为请求头添加鉴权信息
     let token = Vue.ls.get("token");
     if (token) {
+      const ids = {
+        orgId: Vue.ls.get("orgId"),
+        schoolId: Vue.ls.get("schoolId"),
+        userId: Vue.ls.get("user", { id: "" }).id
+      };
+      Object.entries(ids).forEach(([key, val]) => {
+        if (val === null || val === "null" || val === "") return;
+        config.headers[key] = val;
+      });
+
       // 新版鉴权 to open
       // const userId = Vue.ls.get("user").id;
       // const { Authorization, timestamp } = getAuthorisation(

+ 1 - 1
src/modules/base/components/ModifyMenu.vue

@@ -81,7 +81,7 @@ const initModalForm = {
   url: "",
   parentId: null,
   parentName: "",
-  sortNumber: 1,
+  sequence: 1,
   type: "M",
   remark: ""
 };

+ 18 - 16
src/modules/base/components/ModifyRole.vue

@@ -150,23 +150,25 @@ export default {
   },
   methods: {
     async visibleChange() {
-      if (this.instance.id && this.instance.type === "CUSTOM") {
+      if (this.instance.id) {
         this.modalForm = this.$objAssign(initModalForm, this.instance);
-        let privilegeIds = await roleBoundPrivileges(this.instance.id);
-        let checkedIds = [];
-        const getCheckedIds = list => {
-          list.forEach(item => {
-            if (item["children"] && item["children"].length) {
-              getCheckedIds(item.children);
-            } else {
-              const isChecked = privilegeIds.includes(item.id);
-              if (isChecked) checkedIds.push(item.id);
-            }
-          });
-        };
-        getCheckedIds(this.menus);
-        this.$refs.MenuTree.setCheckedKeys(checkedIds);
-        this.modalForm.privilegeIds = checkedIds;
+        if (this.instance.type === "CUSTOM") {
+          let privilegeIds = await roleBoundPrivileges(this.instance.id);
+          let checkedIds = [];
+          const getCheckedIds = list => {
+            list.forEach(item => {
+              if (item["children"] && item["children"].length) {
+                getCheckedIds(item.children);
+              } else {
+                const isChecked = privilegeIds.includes(item.id);
+                if (isChecked) checkedIds.push(item.id);
+              }
+            });
+          };
+          getCheckedIds(this.menus);
+          this.$refs.MenuTree.setCheckedKeys(checkedIds);
+          this.modalForm.privilegeIds = checkedIds;
+        }
       } else {
         this.modalForm = { ...initModalForm };
         this.$refs.MenuTree.setCheckedKeys([]);

+ 4 - 1
src/modules/base/views/MenuManage.vue

@@ -111,10 +111,13 @@ export default {
         .catch(() => {});
     },
     append(node, data) {
+      const sequences = node.parent.childNodes.map(item => item.sequence);
+      const maxSequence = Math.max.apply(null, sequences);
+
       this.curMenu = {
         parentId: data.id,
         parentName: data.name,
-        sortNumber: node.parent.childNodes.length + 1
+        sequence: maxSequence + 1
       };
       this.$refs.ModifyMenu.open();
     }

+ 1 - 6
src/modules/base/views/UserManage.vue

@@ -55,7 +55,6 @@
           btn-content="导入"
           :upload-url="uploadUrl"
           :format="['xls', 'xlsx']"
-          :upload-data="uploadData"
           @upload-error="uplaodError"
           @upload-success="uploadSuccess"
         >
@@ -188,11 +187,7 @@ export default {
       curUser: {},
       downloadUrl: "/temps/用户导入模板.xlsx",
       // import
-      uploadUrl: "/api/admin/sys/user/import",
-      uploadData: {
-        schoolId: this.$ls.get("schoolId"),
-        userId: this.$ls.get("user", { id: "" }).id
-      }
+      uploadUrl: "/api/admin/sys/user/import"
     };
   },
   created() {

+ 1 - 1
src/modules/exam/api.js

@@ -3,7 +3,7 @@ import { $postParam, $post } from "@/plugins/axios";
 // other
 // 试卷编号模糊查询
 export const pageNumberQuery = param => {
-  return $postParam("/api/admin/exam/task/page_number_query", { param });
+  return $postParam("/api/admin/exam/task/paper_number_query", { param });
 };
 // 命题老师模糊查询
 export const questionTeatherQuery = ({ param, courseCode }) => {

+ 0 - 5
src/modules/exam/components/CardOptionDialog.vue

@@ -78,7 +78,6 @@
                 :upload-url="uploadUrl"
                 :format="format"
                 :max-size="maxSize"
-                :upload-data="uploadData"
                 @upload-error="uplaodError"
                 @upload-success="uploadSuccess"
                 style="margin: 0;"
@@ -163,10 +162,6 @@ export default {
       },
       // upload
       format: ["pdf"],
-      uploadData: {
-        schoolId: this.$ls.get("schoolId"),
-        userId: this.$ls.get("user", { id: "" }).id
-      },
       maxSize: 20 * 1024 * 1024,
       uploadUrl: "/api/admin/common/file/upload"
     };

+ 1 - 4
src/modules/exam/views/TaskReviewManage.vue

@@ -381,10 +381,7 @@ export default {
           examTaskIds: this.multipleSelection
         },
         fileName: `${Date.now()}${randomCode()}.zip`,
-        header: {
-          schoolId: this.$ls.get("schoolId"),
-          userId: this.$ls.get("user", { id: "" }).id
-        }
+        header: this.getHeadIds()
       }).catch(error => {
         this.$message.error(error + "文件下载失败,请重新尝试!");
       });

+ 3 - 0
src/modules/login/api.js

@@ -18,3 +18,6 @@ export const attachmentPreview = id => {
 export const getEnums = type => {
   return $postParam("/api/admin/common/get_enums", { type });
 };
+export const schoolList = () => {
+  return $postParam("/api/admin/common/school/list", {});
+};

+ 10 - 0
src/modules/login/router.js

@@ -1,5 +1,6 @@
 import LoginHome from "./views/LoginHome";
 import Login from "./views/Login";
+import SelectSchool from "./views/SelectSchool";
 
 export default {
   path: "/login-home",
@@ -13,6 +14,15 @@ export default {
         title: "登录",
         noRequire: true
       }
+    },
+    {
+      path: "/select-school",
+      name: "SelectSchool",
+      component: SelectSchool,
+      meta: {
+        title: "选择学校",
+        noRequire: true
+      }
     }
   ]
 };

+ 16 - 8
src/modules/login/views/Login.vue

@@ -140,22 +140,30 @@ export default {
       this.isSubmit = false;
       if (!data) return;
 
-      this.$ls.set("schoolId", data.user.schoolId, this.GLOBAL.authTimeout);
+      if (data.user.orgId)
+        this.$ls.set("orgId", data.user.orgId, this.GLOBAL.authTimeout);
+      if (data.user.schoolId)
+        this.$ls.set("schoolId", data.user.schoolId, this.GLOBAL.authTimeout);
       this.$ls.set("user", data.user, this.GLOBAL.authTimeout);
 
-      // if (
-      //   data.user.roleCode.includes("QUESTION_TEACHER") &&
-      //   !data.account.pwChangedCount
-      // ) {
+      // 强制修改密码
+      // if (!data.user.pwdUpdateTime) {
       //   this.$refs.ResetPwd.open();
       //   return;
       // }
 
       this.$ls.set("token", data.token, this.GLOBAL.authTimeout);
       this.$store.commit("setUser", data.user);
-      this.$router.push({
-        name: "Home"
-      });
+
+      if (data.user.roles.includes("ADMIN")) {
+        this.$router.push({
+          name: "SelectSchool"
+        });
+      } else {
+        this.$router.push({
+          name: "Home"
+        });
+      }
     },
     // code valid
     setWaitingTime() {

+ 79 - 0
src/modules/login/views/SelectSchool.vue

@@ -0,0 +1,79 @@
+<template>
+  <div class="select-school login login-box">
+    <div class="login-body">
+      <div class="login-title">
+        <h1>选择学校</h1>
+      </div>
+      <div class="login-form">
+        <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
+          <el-form-item prop="schoolId">
+            <el-select
+              v-model="modalForm.schoolId"
+              style="width:100%;"
+              placeholder="请选择"
+              filterable
+              clearable
+            >
+              <el-option
+                v-for="item in schools"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button style="width:100%;" type="primary" @click="confirm"
+              >确定</el-button
+            >
+          </el-form-item>
+        </el-form>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import { schoolList } from "../api";
+
+export default {
+  name: "select-school",
+  data() {
+    return {
+      schools: [],
+      modalForm: { schoolId: "" },
+      rules: {
+        schoolId: [{ required: true, message: "请选择学校", trigger: "change" }]
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    async getList() {
+      this.schools = await schoolList();
+    },
+    async confirm() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      const curSchool = this.schools.find(
+        item => item.id === this.modalForm.schoolId
+      );
+
+      this.$ls.set(
+        "schoolId",
+        this.modalForm.schoolId,
+        this.GLOBAL.authTimeout
+      );
+      this.$ls.set("schoolName", curSchool.name, this.GLOBAL.authTimeout);
+
+      this.$router.push({
+        name: "Home"
+      });
+    }
+  }
+};
+</script>

+ 1 - 6
src/modules/print/views/BusinessDataExport.vue

@@ -67,7 +67,6 @@
           btn-content="导入"
           :upload-url="uploadUrl"
           :format="['xls', 'xlsx']"
-          :upload-data="uploadData"
           @upload-error="uplaodError"
           @upload-success="uploadSuccess"
           :disabled="!canImport"
@@ -177,11 +176,7 @@ export default {
       curPrintPlan: {},
       // import
       downloadUrl: "/temps/考务数据模板.xlsx",
-      uploadUrl: "/api/admin/sys/user/import",
-      uploadData: {
-        schoolId: this.$ls.get("schoolId"),
-        userId: this.$ls.get("user", { id: "" }).id
-      }
+      uploadUrl: "/api/admin/sys/user/import"
     };
   },
   computed: {

+ 1 - 4
src/modules/print/views/PrintTaskManage.vue

@@ -391,10 +391,7 @@ export default {
           examTaskIds: this.multipleSelection
         },
         fileName: `${Date.now()}${randomCode()}.zip`,
-        header: {
-          schoolId: this.$ls.get("schoolId"),
-          userId: this.$ls.get("user", { id: "" }).id
-        }
+        header: this.getHeadIds()
       }).catch(error => {
         this.$message.error(error + "文件下载失败,请重新尝试!");
       });

+ 7 - 5
src/plugins/axios.js

@@ -8,11 +8,13 @@ import Vue from "vue";
 let unauthMsgBoxIsShow = false;
 
 const mdData = datas => {
-  return {
-    ...datas,
-    schoolId: Vue.ls.get("schoolId"),
-    userId: Vue.ls.get("user", { id: "" }).id
-  };
+  let nData = {};
+  if (!datas) return nData;
+  Object.entries(datas).forEach(([key, val]) => {
+    if (val === null || val === "null" || val === "") return;
+    nData[key] = val;
+  });
+  return nData;
 };
 
 /**

+ 9 - 0
src/plugins/mixins.js

@@ -1,3 +1,5 @@
+import { pickByNotNull } from "@/plugins/utils";
+
 export default {
   methods: {
     deletePageLastItem() {
@@ -18,6 +20,13 @@ export default {
       const current = this.current || 1;
       const size = this.size || 10;
       return (current - 1) * size + index + 1;
+    },
+    getHeadIds() {
+      return pickByNotNull({
+        orgId: this.$ls.get("orgId"),
+        schoolId: this.$ls.get("schoolId"),
+        userId: this.$ls.get("user", { id: "" }).id
+      });
     }
   }
 };

+ 11 - 1
src/plugins/utils.js

@@ -246,6 +246,15 @@ function humpToLowLine(a) {
     .slice(1);
 }
 
+function pickByNotNull(params) {
+  let nData = {};
+  Object.entries(params).forEach(([key, val]) => {
+    if (val === null || val === "null" || val === "") return;
+    nData[key] = val;
+  });
+  return nData;
+}
+
 export {
   objTypeOf,
   deepCopy,
@@ -261,5 +270,6 @@ export {
   calcSum,
   isEmptyObject,
   jsonBigNumberToString,
-  humpToLowLine
+  humpToLowLine,
+  pickByNotNull
 };

+ 8 - 0
src/views/Home.vue

@@ -22,6 +22,10 @@
       </div>
       <div class="head-user menu-list">
         <ul>
+          <li v-if="schoolName" @click="toSelectSchool" title="切换学校">
+            <i class="icon icon-home"></i>
+            <span>{{ schoolName }}</span>
+          </li>
           <li
             class="menu-item menu-item-account"
             @click="$refs.ResetPwd.open()"
@@ -133,6 +137,7 @@ export default {
       breadcrumbs: [],
       validRoutes: [],
       username: this.$ls.get("user", { realName: "" }).realName,
+      schoolName: this.$ls.get("schoolName"),
       menuDailogIsShow: false,
       waitTaskCount: 0
     };
@@ -287,6 +292,9 @@ export default {
       this.$ls.clear();
       this.$router.push({ name: "Login" });
     },
+    toSelectSchool() {
+      this.$router.push({ name: "SelectSchool" });
+    },
     // popover menu
     showMenu() {
       this.menuDailogIsShow = !this.menuDailogIsShow;