Pārlūkot izejas kodu

添加学生端管理功能

lideyin 6 gadi atpakaļ
vecāks
revīzija
b71762b685

+ 13 - 0
src/constants/constants.js

@@ -69,3 +69,16 @@ export const NOTICE_RECEIVER_RULE_TYPE = [
   { code: "TEACHER_OF_MARK_WORK", name: "老师-按评卷老师选择" },
   { code: "COMMON_USERS_OF_ROLE", name: "老师-学习中心老师" }
 ];
+//登录方式
+export const LOGIN_TYPE = [
+  { code: "STUDENT_CODE", name: "学号登录" },
+  { code: "IDENTITY_NUMBER", name: "身份证号登录" }
+];
+//防作弊配置
+export const PREVENT_CHEATING_CONFIG = [
+  { code: "DISABLE_REMOTE_ASSISTANCE", name: "禁用远程协助" },
+  { code: "DISABLE_VIRTUAL_CAMERA", name: "禁用虚拟摄像头" },
+  { code: "DISABLE_VIRTUAL_MACHINE", name: "禁用虚拟机" },
+  { code: "DISABLE_FULL_SCREEN_TOP", name: "强制全屏置顶" },
+  { code: "DISABLE_MULTISCREEN", name: "禁用双屏" }
+];

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

@@ -13,6 +13,7 @@ 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";
+import client_config from "../view/clientConfig";
 
 export default [
   {
@@ -87,6 +88,11 @@ export default [
         path: "sys_prop_list", //参数配置列表
         meta: { privilegeCodes: "sys_pop_list" },
         component: sys_prop_list
+      },
+      {
+        path: "client_config",
+        meta: { privilegeCodes: "client_config" },
+        component: client_config
       }
     ]
   }

+ 378 - 0
src/modules/basic/view/clientConfig.vue

@@ -0,0 +1,378 @@
+<template>
+  <el-container>
+    <el-main class="el-main-padding">
+      <el-form
+        :model="ruleForm"
+        :rules="rules"
+        ref="ruleForm"
+        label-width="120px"
+        class="demo-ruleForm"
+        :inline-message="true"
+      >
+        <el-form-item label="系统名称" prop="OE_STUDENT_SYS_NAME">
+          <el-input
+            v-model="ruleForm.OE_STUDENT_SYS_NAME"
+            placeholder="请输入系统名称"
+            class="input-width"
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="学校logo" prop="LOGO_FILE_URL">
+          <el-upload
+            class="upload-width"
+            ref="upload"
+            accept="image/*"
+            :action="uploadAction"
+            :headers="uploadHeaders"
+            :data="uploadData"
+            :before-upload="beforeUpload"
+            :on-progress="uploadProgress"
+            :on-success="uploadSuccess"
+            :on-error="uploadError"
+            :file-list="fileList"
+            :auto-upload="false"
+            :multiple="false"
+            list-type="picture"
+          >
+            <el-button size="small" slot="trigger" type="primary"
+              >选择文件</el-button
+            >&nbsp;
+            <el-button size="small" type="success" @click="submitUpload"
+              >确认上传</el-button
+            >
+            <el-button size="small" type="danger" @click="removeFile"
+              >清空文件</el-button
+            >
+            <div slot="tip" class="el-upload__tip">
+              图片大小为400*100的png文件
+            </div>
+          </el-upload>
+          <el-input v-show="false" v-model="ruleForm.LOGO_FILE_URL"></el-input>
+        </el-form-item>
+
+        <el-form-item label="登录方式选择" prop="loginType">
+          <el-checkbox-group v-model="ruleForm.loginType">
+            <el-checkbox
+              v-for="lt in loginTypes"
+              name="loginType"
+              :label="lt.code"
+              v-model="lt.code"
+              :key="lt.code"
+              >{{ lt.name }}</el-checkbox
+            >
+          </el-checkbox-group>
+        </el-form-item>
+        <el-form-item label="防作弊配置" prop="preventCheatingConfig">
+          <el-checkbox-group v-model="ruleForm.preventCheatingConfig">
+            <el-checkbox
+              v-for="pcc in preventCheatingConfigs"
+              name="preventCheatingConfig"
+              :label="pcc.code"
+              v-model="pcc.code"
+              :key="pcc.code"
+              >{{ pcc.name }}</el-checkbox
+            >
+          </el-checkbox-group>
+        </el-form-item>
+        <el-form-item label="客户端默认大小" prop="STUDENT_CLIENT_DEFAULT_SIZE">
+          <el-input
+            v-model="ruleForm.STUDENT_CLIENT_DEFAULT_SIZE"
+            placeholder="客户端大小格式为:宽度*高度"
+            class="input-width"
+          ></el-input>
+        </el-form-item>
+
+        <el-form-item>
+          <el-button
+            class="btn-margin-left"
+            type="primary"
+            @click="submitForm('ruleForm')"
+            >保 存</el-button
+          >
+          <el-button class="btn-margin-left" @click="resetForm('ruleForm')"
+            >取 消</el-button
+          >
+        </el-form-item>
+      </el-form>
+    </el-main>
+  </el-container>
+</template>
+<script>
+import { mapState } from "vuex";
+import {
+  LOGIN_TYPE,
+  PREVENT_CHEATING_CONFIG,
+  CORE_API
+} from "@/constants/constants.js";
+export default {
+  data() {
+    return {
+      rootOrgId: null,
+      loginTypes: LOGIN_TYPE,
+      propertyGroupId: "student.client.config",
+      preventCheatingConfigs: PREVENT_CHEATING_CONFIG,
+      ruleForm: {
+        orgId: null,
+        OE_STUDENT_SYS_NAME: "",
+        LOGO_FILE_URL: "",
+        LOGIN_TYPE: "",
+        PREVENT_CHEATING_CONFIG: "",
+        STUDENT_CLIENT_DEFAULT_SIZE: "",
+        properties: {
+          OE_STUDENT_SYS_NAME: "",
+          LOGO_FILE_URL: "",
+          LOGIN_TYPE: "",
+          PREVENT_CHEATING_CONFIG: "",
+          STUDENT_CLIENT_DEFAULT_SIZE: ""
+        },
+        loginType: [],
+        preventCheatingConfig: []
+      },
+      logoDialog: false,
+      uploadAction: "",
+      uploadHeaders: {},
+      uploadData: {},
+      fileList: [],
+      rules: {
+        OE_STUDENT_SYS_NAME: [
+          { required: true, message: "请输入系统名称", trigger: "blur" },
+          { min: 1, max: 50, message: "长度在 1 到 50 个字符", trigger: "blur" }
+        ],
+        LOGO_FILE_URL: [
+          { required: true, message: "请选择学校logo", trigger: "blur" }
+        ],
+        loginType: [
+          {
+            type: "array",
+            required: true,
+            message: "请至少选择一个登录方式",
+            trigger: "change"
+          }
+        ],
+        STUDENT_CLIENT_DEFAULT_SIZE: [
+          { required: true, message: "请输入客户端默认大小", trigger: "blur" }
+        ]
+      }
+    };
+  },
+  methods: {
+    submitForm(formName) {
+      this.$refs[formName].validate(valid => {
+        if (valid) {
+          this.ruleForm.properties.OE_STUDENT_SYS_NAME = this.ruleForm.OE_STUDENT_SYS_NAME;
+          this.ruleForm.properties.LOGO_FILE_URL = this.ruleForm.LOGO_FILE_URL;
+          this.ruleForm.properties.STUDENT_CLIENT_DEFAULT_SIZE = this.ruleForm.STUDENT_CLIENT_DEFAULT_SIZE;
+          this.ruleForm.properties.LOGIN_TYPE = this.ruleForm.LOGIN_TYPE = this.ruleForm.loginType.join(
+            ","
+          );
+          if (
+            this.ruleForm.preventCheatingConfig == null ||
+            this.ruleForm.preventCheatingConfig.length == 0
+          ) {
+            this.ruleForm.properties.PREVENT_CHEATING_CONFIG = this.ruleForm.PREVENT_CHEATING_CONFIG =
+              "NONE";
+          } else {
+            this.ruleForm.properties.PREVENT_CHEATING_CONFIG = this.ruleForm.PREVENT_CHEATING_CONFIG = this.ruleForm.preventCheatingConfig.join(
+              ","
+            );
+          }
+
+          this.$httpWithMsg
+            .put(CORE_API + "/org/saveOrgProperties", this.ruleForm)
+            .then(
+              () => {
+                this.$notify({
+                  message: "保存成功",
+                  type: "success"
+                });
+              },
+              () => {}
+            );
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    initForm() {
+      var url =
+        CORE_API +
+        "/org/orgPropertiesByGroup/" +
+        this.rootOrgId +
+        "/" +
+        this.propertyGroupId;
+      this.$httpWithMsg.get(url).then(response => {
+        console.log(response);
+
+        if (response) {
+          this.ruleForm.properties = response.data;
+          // if (this.ruleForm.properties.OE_STUDENT_SYS_NAME) {
+          this.ruleForm.OE_STUDENT_SYS_NAME =
+            this.ruleForm.properties.OE_STUDENT_SYS_NAME ||
+            this.ruleForm.OE_STUDENT_SYS_NAME;
+          // }
+
+          this.ruleForm.LOGO_FILE_URL =
+            this.ruleForm.properties.LOGO_FILE_URL ||
+            this.ruleForm.LOGO_FILE_URL;
+          this.ruleForm.LOGIN_TYPE =
+            this.ruleForm.properties.LOGIN_TYPE || this.ruleForm.LOGIN_TYPE;
+          this.ruleForm.PREVENT_CHEATING_CONFIG =
+            this.ruleForm.properties.PREVENT_CHEATING_CONFIG ||
+            this.ruleForm.PREVENT_CHEATING_CONFIG;
+          this.ruleForm.STUDENT_CLIENT_DEFAULT_SIZE =
+            this.ruleForm.properties.STUDENT_CLIENT_DEFAULT_SIZE ||
+            this.ruleForm.STUDENT_CLIENT_DEFAULT_SIZE;
+          if (this.ruleForm.properties.LOGIN_TYPE) {
+            this.ruleForm.loginType = this.ruleForm.properties.LOGIN_TYPE.split(
+              ","
+            );
+          }
+          if (this.ruleForm.properties.PREVENT_CHEATING_CONFIG) {
+            this.ruleForm.preventCheatingConfig = this.ruleForm.properties.PREVENT_CHEATING_CONFIG.split(
+              ","
+            );
+          }
+          console.log("1111111111");
+          console.log(this.ruleForm.properties.PREVENT_CHEATING_CONFIG);
+          console.log(this.ruleForm.preventCheatingConfig);
+          console.log("21111111111");
+          let fileUrl = response.data.LOGO_FILE_URL;
+          let fname = "";
+          if (fileUrl) {
+            let lastIndex = fileUrl.lastIndexOf("/");
+            let len = fileUrl.length;
+            fname = fileUrl.substr(lastIndex + 1, len - lastIndex);
+          }
+
+          this.fileList = [{ name: fname, url: this.ruleForm.LOGO_FILE_URL }];
+        }
+      });
+    },
+    resetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+    initUpload() {
+      this.fileList = [];
+    },
+    beforeUpload(file) {
+      if (!this.checkUpload()) {
+        return false;
+      }
+      console.log(file);
+    },
+    uploadProgress() {
+      console.log("uploadProgress");
+    },
+    uploadSuccess(response) {
+      console.log("uploadSuccess");
+      console.log(response);
+      if (response && response.length > 0) {
+        this.$notify({
+          message: "上传成功",
+          type: "success"
+        });
+        let fileUrl = response;
+
+        this.ruleForm.LOGO_FILE_URL = this.ruleForm.properties.LOGO_FILE_URL = fileUrl;
+      } else {
+        this.errDialog = true;
+      }
+      this.fileLoading = false;
+      this.logoDialog = false;
+      // this.removeFile();
+    },
+    uploadError(response) {
+      let json = JSON.parse(response.message);
+      if (response.status == 500) {
+        this.$notify({
+          message: json.desc,
+          type: "error"
+        });
+      }
+      this.fileLoading = false;
+    },
+    //确定上传
+    submitUpload() {
+      if (!this.checkUpload()) {
+        return false;
+      }
+      this.$refs.upload.submit();
+      this.fileLoading = true;
+    },
+    checkUpload() {
+      var fileList = this.$refs.upload.uploadFiles;
+      if (fileList.length == 0) {
+        this.$notify({
+          message: "上传文件不能为空",
+          type: "error"
+        });
+        return false;
+      }
+      if (fileList.length > 1) {
+        this.$notify({
+          message: "每次只能上传一个文件",
+          type: "error"
+        });
+        return false;
+      }
+      for (let file of fileList) {
+        var fileName = file.name;
+        if (
+          !fileName.endsWith(".jpg") &&
+          !fileName.endsWith(".gif") &&
+          !fileName.endsWith(".png")
+        ) {
+          this.$notify({
+            message: "上传文件必须为[jpg,gif,png]",
+            type: "error"
+          });
+          this.initUpload();
+          return false;
+        }
+      }
+      return true;
+    },
+    //清空文件
+    removeFile() {
+      this.fileList = [];
+      this.ruleForm.LOGO_FILE_URL = this.ruleForm.properties.LOGO_FILE_URL = "";
+      if (this.$refs.upload) {
+        this.$refs.upload.clearFiles();
+      }
+    },
+    handleRemove(file, fileList) {
+      console.log(file, fileList);
+    },
+    handlePreview(file) {
+      console.log(file);
+    }
+  },
+  created() {
+    this.rootOrgId = this.user.rootOrgId;
+    this.ruleForm.orgId = this.user.rootOrgId;
+    this.ruleForm.STUDENT_CLIENT_DEFAULT_SIZE = "1400*900";
+    this.propertyGroupId = "student.client.config";
+    this.uploadAction = CORE_API + "/org/importLogo/" + this.rootOrgId;
+    this.uploadHeaders = {
+      key: this.user.key,
+      token: this.user.token
+    };
+    console.log(this.propertyGroupId);
+    this.initForm();
+  },
+  computed: {
+    ...mapState({ user: state => state.user })
+  }
+};
+</script>
+<style scoped>
+.input-width {
+  width: 600px;
+}
+.upload-width {
+  width: 600px;
+}
+.btn-margin-left {
+  margin-left: 200px;
+}
+</style>