Explorar o código

学校权限设置

xiatian %!s(int64=6) %!d(string=hai) anos
pai
achega
7105eaf380

+ 6 - 0
src/modules/basic/routes/routes.js

@@ -10,6 +10,7 @@ import app_list from "../view/app_list.vue";
 import privilege_group_list from "../view/privilege_group_list.vue";
 import privilege_tree from "../view/privilege_tree.vue";
 import role_privilege_settings from "../view/role_privilege_settings.vue";
+import school_privilege_settings from "../view/school_privilege_settings.vue";
 import resource_list from "../view/resource_list.vue";
 import sys_prop_list from "../view/sys_prop_list";
 
@@ -72,6 +73,11 @@ export default [
         meta: { privilegeCodes: "index_role_privilege_settings" },
         component: role_privilege_settings
       },
+      {
+        path: "school_privilege_settings", //学校权限设置
+        meta: { privilegeCodes: "index_school_privilege_settings" },
+        component: school_privilege_settings
+      },
       {
         path: "resource_list", //资源列表
         meta: { privilegeCodes: "index_resource_list" },

+ 6 - 1
src/modules/basic/view/privilege_tree.vue

@@ -24,6 +24,7 @@
           <el-dialog
             title="新增权限"
             width="450px"
+            :close-on-click-modal="false"
             :visible.sync="addingDialog.show"
           >
             <el-form
@@ -182,7 +183,11 @@
           </el-dialog>
 
           <!-- 查看权限 -->
-          <el-dialog title="查看权限" :visible.sync="showDialog.show">
+          <el-dialog
+            title="查看权限"
+            :visible.sync="showDialog.show"
+            :close-on-click-modal="false"
+          >
             <el-form :model="showDialog.privilege" label-width="100px">
               <el-form-item label="权限名称">
                 <el-col>

+ 248 - 0
src/modules/basic/view/school_privilege_settings.vue

@@ -0,0 +1,248 @@
+<template>
+  <section class="content">
+    <div class="box box-info">
+      <div class="box-body">
+        <!-- 选择 -->
+        <el-form :inline="true" :model="form" label-position="right">
+          <el-row>
+            <el-form-item label="学校" class="pull-left">
+              <el-select
+                class="input_width_lg"
+                v-model="form.orgId"
+                placeholder="请选择"
+                @change="rootOrgChanged"
+                :disabled="!isSuperAdmin"
+              >
+                <el-option
+                  v-for="item in orgList"
+                  :label="item.name"
+                  :value="item.id"
+                  :key="item.id"
+                />
+              </el-select>
+            </el-form-item>
+            <el-form-item label="权限组" class="pull-left">
+              <el-select
+                class="input_width_lg"
+                v-model="form.privilegeGroupId"
+                placeholder="请选择"
+                @change="change"
+              >
+                <el-option
+                  v-for="item in privilegeGroupList"
+                  :label="item.name"
+                  :value="item.id"
+                  :key="item.id"
+                />
+              </el-select>
+            </el-form-item>
+          </el-row>
+        </el-form>
+
+        <div style="margin-bottom:10px;">
+          <el-button type="primary" :disabled="!treeChanged" @click="save">
+            保 存
+          </el-button>
+        </div>
+
+        <!-- 权限树 -->
+        <div style="width: 50%;">
+          <el-tree
+            class="el-tree"
+            :data="treeData"
+            :props="defaultProps"
+            show-checkbox
+            node-key="id"
+            ref="tree"
+            highlight-current
+            :check-strictly="true"
+            :default-expanded-keys="checkedKeys"
+            :default-checked-keys="checkedKeys"
+            @check="nodeCheck"
+            :expand-on-click-node="true"
+          />
+        </div>
+      </div>
+    </div>
+  </section>
+</template>
+
+<script>
+import { mapState } from "vuex";
+import { CORE_API } from "@/constants/constants.js";
+
+export default {
+  name: "RolePrivilegeSettings",
+  data() {
+    return {
+      form: {
+        orgId: null,
+        privilegeGroupId: null
+      },
+      orgList: [],
+      privilegeGroupList: [],
+      treeChanged: false,
+      treeData: [],
+      checkedKeys: [],
+      uncheckChildren_nodeId: null,
+      defaultProps: {
+        children: "children",
+        label: "label"
+      }
+    };
+  },
+  computed: {
+    ...mapState({ user: state => state.user }),
+    isSuperAdmin() {
+      return this.user.roleList.some(role => role.roleCode == "SUPER_ADMIN");
+    }
+  },
+  methods: {
+    /*初始化*/
+    init() {
+      var url1 = CORE_API + "/org/getRootOrgList";
+      var url2 =
+        CORE_API + "/rolePrivilege/getRoles?includeSuperAdmin=" + false;
+      var url3 = CORE_API + "/rolePrivilege/getPrivilegeGroupList";
+
+      Promise.all([
+        this.$httpWithMsg.get(url1),
+        this.$httpWithMsg.post(url2),
+        this.$httpWithMsg.get(url3)
+      ]).then(([resp1, resp2, resp3]) => {
+        this.orgList = resp1.data;
+
+        this.form.orgId = this.user.rootOrgId;
+        this.roleList = resp2.data;
+        if (0 < this.roleList.length) {
+          this.form.roleId = this.roleList[0].roleId;
+        }
+        this.privilegeGroupList = resp3.data;
+        if (0 < this.privilegeGroupList.length) {
+          this.form.privilegeGroupId = this.privilegeGroupList[0].id;
+        }
+
+        this.initTree(this.form.orgId, this.form.privilegeGroupId);
+      });
+    },
+    /*初始化权限树*/
+    initTree(orgId, privilegeGroupId) {
+      var url1 =
+        CORE_API + "/rolePrivilege/getPrivilegeTree/" + privilegeGroupId;
+      var url2 =
+        CORE_API +
+        "/rolePrivilege/getRootOrgPrivilegeIdList/" +
+        orgId +
+        "/" +
+        privilegeGroupId;
+
+      Promise.all([
+        this.$httpWithMsg.get(url1),
+        this.$httpWithMsg.get(url2)
+      ]).then(([resp1, resp2]) => {
+        console.log("initTree(). treeData:", resp1.data.children);
+        console.log("initTree(). checkedKeys:", resp2.data);
+        this.treeData = resp1.data.children;
+        this.checkedKeys = resp2.data;
+      });
+    },
+    /*change事件*/
+    change() {
+      this.initTree(this.form.orgId, this.form.privilegeGroupId);
+    },
+    rootOrgChanged() {
+      var url =
+        CORE_API +
+        "/rolePrivilege/getRoles?includeSuperAdmin=false&rootOrgId=" +
+        this.form.orgId;
+      this.$httpWithMsg.post(url).then(response => {
+        this.roleList = response.data;
+        if (0 < this.roleList.length) {
+          this.form.roleId = this.roleList[0].roleId;
+        }
+
+        this.initTree(this.form.orgId, this.form.privilegeGroupId);
+      });
+    },
+    nodeCheck({ id, parentId, children }, { checkedKeys }) {
+      // console.log("[tree change] node:", node);
+
+      const checked = checkedKeys.includes(id);
+      // 当前node的状态
+      if (checked) {
+        this.checkedKeys = [...this.checkedKeys, id];
+      } else {
+        this.checkedKeys = this.checkedKeys.filter(id0 => id0 !== id);
+      }
+      // 选中状态下对子节点的影响:递归选中所有子孙节点
+      if (checked && children) {
+        this.checkedKeys = [...this.checkedKeys, ...children.map(v => v.id)];
+        for (const child of children) {
+          this.checkedKeys = [...this.checkedKeys, child.id];
+          for (const child of child.children || []) {
+            // 树最多只有三个层级,这里就不写递归了
+            this.checkedKeys = [...this.checkedKeys, child.id];
+          }
+        }
+      }
+
+      // 选中状态下对父节点的影响:递归选中所有父辈节点
+      if (checked && parentId) {
+        this.checkedKeys = [...this.checkedKeys, parentId];
+        const parent1 = this.$refs.tree.getNode(parentId).data;
+        // this.$refs.tree.setChecked(parentId, true, false);
+        if (parent1.parentId) {
+          // 第二个父节点
+          this.checkedKeys = [...this.checkedKeys, parent1.parentId];
+          // this.$refs.tree.setChecked(parent1.parentId, true, false);
+        }
+      }
+
+      // 取消选中状态下对子节点的影响:递归取消选中所有子孙节点
+      if (!checked && children) {
+        this.checkedKeys = this.checkedKeys.filter(id0 => id0 !== id);
+        // console.log(this.checkedKeys);
+        for (const child of children) {
+          this.checkedKeys = this.checkedKeys.filter(id => id !== child.id);
+          // console.log(this.checkedKeys);
+          for (const child of child.children || []) {
+            // 树最多只有三个层级,这里就不写递归了
+            this.checkedKeys = this.checkedKeys.filter(id => id !== child.id);
+          }
+        }
+      }
+
+      this.checkedKeys = [...new Set(this.checkedKeys)];
+      this.$refs.tree.setCheckedKeys(this.checkedKeys);
+
+      this.treeChanged = true;
+    },
+    save() {
+      console.log("save(). checkedKeys:", this.checkedKeys);
+      var url = CORE_API + "/rolePrivilege/updateRootOrgPrivilegeRelations";
+      this.$httpWithMsg
+        .post(url, {
+          rootOrgId: this.form.orgId,
+          privilegeGroupId: this.form.privilegeGroupId,
+          privilegeIdSet: this.checkedKeys
+        })
+        .then(() => {
+          this.$notify({
+            message: "更新成功",
+            type: "success"
+          });
+          this.treeChanged = false;
+        });
+    }
+  },
+  created() {
+    this.init();
+  }
+};
+</script>
+
+<style scoped>
+.el-tree >>> label {
+  margin-bottom: 0;
+}
+</style>

+ 28 - 10
src/modules/examwork/view/onlineExam.vue

@@ -407,7 +407,7 @@
                   >
                     <el-radio-group
                       v-model="form.properties.IS_FACE_ENABLE"
-                      @change="faceChange"
+                      :disabled="this.is_face_enable_diabled"
                       class="input"
                     >
                       <el-radio label="true">是</el-radio>
@@ -487,6 +487,7 @@
                   >
                     <el-radio-group
                       v-model="form.properties.IS_FACE_VERIFY"
+                      :disabled="this.is_face_verify_diabled"
                       class="input"
                     >
                       <el-radio label="true">是</el-radio>
@@ -600,11 +601,10 @@
 </template>
 
 <script>
-import { EXAM_TYPE, EXAM_WORK_API } from "@/constants/constants.js";
+import { EXAM_TYPE, EXAM_WORK_API, CORE_API } from "@/constants/constants.js";
 import moment from "moment";
 import ckeditor from "@/components/ckeditor.vue";
 import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
-
 let _this = null;
 
 let validateCode = (rule, value, callback) => {
@@ -916,6 +916,8 @@ export default {
       toActiveName: null,
       examDatetimeRange: [],
       show_ckeditor: false,
+      is_face_verify_diabled: true,
+      is_face_enable_diabled: true,
       form: {
         started: false,
         name: "",
@@ -1030,13 +1032,6 @@ export default {
   },
 
   methods: {
-    faceChange() {
-      if (this.form.properties.IS_FACE_ENABLE == "false") {
-        this.form.properties.IS_FACE_VERIFY = "false";
-      } else if (this.form.properties.IS_FACE_ENABLE == "true") {
-        this.form.properties.IS_FACE_VERIFY = "true";
-      }
-    },
     init() {
       if (this.examId != "add") {
         let url = EXAM_WORK_API + "/exam/" + this.examId;
@@ -1066,14 +1061,37 @@ export default {
               this.form.properties.FILL_BLANK_EDIT === "true";
 
             this.show_ckeditor = true;
+
+            this.checkRootOrgPrivileges();
           });
         });
       } else {
         let now = moment().format("YYYY-MM-DD HH:mm:ss");
         this.examDatetimeRange = [now, now];
         this.show_ckeditor = true;
+        this.checkRootOrgPrivileges();
       }
     },
+    checkRootOrgPrivileges: function() {
+      let url =
+        CORE_API +
+        "/rolePrivilege/checkRootOrgPrivileges?privilegeCodes=FACE_CHECK,IDENTIFICATION_OF_LIVING_BODY";
+      this.$httpWithMsg.post(url).then(response => {
+        let res = response.data;
+        if (!res.FACE_CHECK) {
+          this.form.properties.IS_FACE_ENABLE = "false";
+          this.is_face_enable_diabled = true;
+        } else {
+          this.is_face_enable_diabled = false;
+        }
+        if (!res.IDENTIFICATION_OF_LIVING_BODY) {
+          this.is_face_verify_diabled = true;
+          this.form.properties.IS_FACE_VERIFY = "false";
+        } else {
+          this.is_face_verify_diabled = false;
+        }
+      });
+    },
     saveExam: function() {
       this.toActiveName = null;
       this.form.beginTime = this.examDatetimeRange[0];