Эх сурвалжийг харах

课程目标权限以及修改提示

zhangjie 1 жил өмнө
parent
commit
ebf0988bec

+ 7 - 0
src/modules/base/api.js

@@ -598,6 +598,13 @@ export const deleteCourseTarget = (id) => {
 export const courseDimensionTree = (datas) => {
   return $postParam("/api/admin/teach/course_target/dimension_tree", datas);
 };
+export const courseWeightSettingStatus = (datas) => {
+  return $postParam(
+    "/api/admin/teach/course/find_course_weight_setting_status",
+    datas
+  );
+};
+
 // comment-evaluation-manage
 export const courseEvaluationList = (datas) => {
   return $postParam("/api/admin/teach/course_evaluation/list", datas);

+ 16 - 3
src/modules/base/components/course-simple/ClazzSimpleManage.vue

@@ -18,9 +18,8 @@
           >
         </el-form-item>
       </el-form>
-      <div class="part-box-action">
+      <div v-if="editable" class="part-box-action">
         <el-button type="danger" @click="toBatchDelete">批量删除</el-button>
-        <!-- <el-button type="primary" @click="toAdd">新增班级</el-button> -->
       </div>
     </div>
     <div class="part-box part-box-pad">
@@ -30,6 +29,7 @@
         @selection-change="handleSelectionChange"
       >
         <el-table-column
+          v-if="editable"
           type="selection"
           width="55"
           align="center"
@@ -53,7 +53,12 @@
             scope.row.createTime | timestampFilter
           }}</span>
         </el-table-column>
-        <el-table-column class-name="action-column" label="操作" width="170px">
+        <el-table-column
+          v-if="editable"
+          class-name="action-column"
+          label="操作"
+          width="170px"
+        >
           <template slot-scope="scope">
             <el-button
               class="btn-primary"
@@ -93,12 +98,14 @@
 
     <!-- ModifyClazzSimple -->
     <modify-clazz-simple
+      v-if="editable"
       :instance="curRow"
       @modified="getList"
       ref="ModifyClazzSimple"
     ></modify-clazz-simple>
     <!-- StudentSimpleManage -->
     <student-simple-manage
+      v-if="editable"
       ref="StudentSimpleManage"
       :clazz="curRow"
       @modified="getList"
@@ -134,8 +141,14 @@ export default {
       multipleSelection: [],
       dataList: [],
       curRow: {},
+      userId: this.$ls.get("user", { id: "" }).id,
     };
   },
+  computed: {
+    editable() {
+      return this.userId === this.course.courseCreateId;
+    },
+  },
   mounted() {
     this.initData();
   },

+ 17 - 2
src/modules/base/components/course-simple/CourseEvaluationManage.vue

@@ -45,6 +45,7 @@
 <script>
 import { courseEvaluationList, deleteCourseEvaluation } from "../../api";
 import ModifyCourseEvaluation from "./ModifyCourseEvaluation.vue";
+import { mapState } from "vuex";
 
 export default {
   name: "CourseEvaluationManage",
@@ -63,6 +64,9 @@ export default {
       curRow: {},
     };
   },
+  computed: {
+    ...mapState("base", ["cwStatus"]),
+  },
   mounted() {
     this.getList();
   },
@@ -74,7 +78,18 @@ export default {
       });
       this.dataList = res || [];
     },
-    toAdd() {
+    async toAdd() {
+      if (this.cwStatus.everSettingStatus) {
+        const confirm = await this.$confirm(
+          `新增评价方式会影响权重设置,确定要新增吗?`,
+          "提示",
+          {
+            type: "warning",
+          }
+        ).catch(() => {});
+        if (confirm !== "confirm") return;
+      }
+
       this.curRow = {
         courseCode: this.course.courseCode,
         examId: this.course.examId,
@@ -83,7 +98,7 @@ export default {
     },
     async toDelete(row) {
       const confirm = await this.$confirm(
-        `确定要删除评价方式【${row.evaluation}】吗?`,
+        `删除评价方式会影响权重设置,确定要删除评价方式【${row.evaluation}】吗?`,
         "提示",
         {
           type: "warning",

+ 12 - 0
src/modules/base/components/course-simple/CourseSimpleDetail.vue

@@ -39,6 +39,7 @@ import TeacherSimpleManage from "./TeacherSimpleManage.vue";
 import CourseTargetManage from "./CourseTargetManage.vue";
 import CourseEvaluationManage from "./CourseEvaluationManage.vue";
 import CourseWeightManage from "./CourseWeightManage.vue";
+import { mapActions } from "vuex";
 
 export default {
   name: "course-simple-detail",
@@ -57,6 +58,9 @@ export default {
       },
     },
   },
+  computed: {
+    ...mapActions("base", ["updateCwStatus"]),
+  },
   data() {
     return {
       modalIsShow: false,
@@ -94,6 +98,14 @@ export default {
     },
     selectMenu(tab) {
       this.curTab = tab;
+
+      const statusTabs = ["CourseTargetManage", "CourseEvaluationManage"];
+      if (statusTabs.includes(tab)) {
+        this.updateCwStatus({
+          examId: this.course.examId,
+          courseCode: this.course.courseCode,
+        });
+      }
     },
   },
 };

+ 28 - 3
src/modules/base/components/course-simple/CourseTargetManage.vue

@@ -53,6 +53,7 @@
 <script>
 import { courseTargetList, deleteCourseTarget } from "../../api";
 import ModifyCourseTarget from "./ModifyCourseTarget.vue";
+import { mapState } from "vuex";
 
 export default {
   name: "CourseTargetManage",
@@ -71,6 +72,9 @@ export default {
       curRow: {},
     };
   },
+  computed: {
+    ...mapState("base", ["cwStatus"]),
+  },
   mounted() {
     this.getList();
   },
@@ -82,7 +86,17 @@ export default {
       });
       this.dataList = res || [];
     },
-    toAdd() {
+    async toAdd() {
+      if (this.cwStatus.everSettingStatus) {
+        const confirm = await this.$confirm(
+          `新增课程目标会影响权重设置,确定要新增吗?`,
+          "提示",
+          {
+            type: "warning",
+          }
+        ).catch(() => {});
+        if (confirm !== "confirm") return;
+      }
       this.curRow = {
         courseCode: this.course.courseCode,
         examId: this.course.examId,
@@ -100,7 +114,18 @@ export default {
       });
       return ids;
     },
-    toEdit(row) {
+    async toEdit(row) {
+      if (this.cwStatus.everSettingStatus) {
+        const confirm = await this.$confirm(
+          `修改课程目标会影响权重设置,确定要修改吗?`,
+          "提示",
+          {
+            type: "warning",
+          }
+        ).catch(() => {});
+        if (confirm !== "confirm") return;
+      }
+
       this.curRow = {
         ...row,
         courseCode: this.course.courseCode,
@@ -111,7 +136,7 @@ export default {
     },
     async toDelete(row) {
       const confirm = await this.$confirm(
-        `确定要删除课程目标【${row.targetName}】吗?`,
+        `修改课程目标会影响权重设置,确定要删除课程目标【${row.targetName}】吗?`,
         "提示",
         {
           type: "warning",

+ 15 - 5
src/modules/base/components/course-simple/CourseWeightManage.vue

@@ -141,9 +141,9 @@
 
 <script>
 import { courseWeightDetail, courseWeightSave } from "../../api";
-// import { weightList } from "./targetData";
 import { omit, pick } from "lodash";
 import { calcSum } from "@/plugins/utils";
+import { mapState, mapActions } from "vuex";
 
 export default {
   name: "course-weight-manage",
@@ -165,12 +165,21 @@ export default {
       loading: false,
     };
   },
+  computed: {
+    ...mapState("base", ["cwStatus"]),
+  },
   mounted() {
-    this.getList();
-    // this.dataList = weightList;
-    // this.transformData(this.dataList);
+    this.initData();
   },
   methods: {
+    ...mapActions("base", ["updateCwStatus"]),
+    async initData() {
+      await this.updateCwStatus();
+      await this.getList();
+      if (this.cwStatus.currentSettingStatus) {
+        this.updateDataList();
+      }
+    },
     async getList() {
       const res = await courseWeightDetail({
         examId: this.course.examId,
@@ -323,7 +332,6 @@ export default {
     },
     async submit() {
       if (this.loading) return;
-      this.updateDataList();
 
       if (!this.checkDataList()) return;
 
@@ -335,6 +343,8 @@ export default {
       }).catch(() => {});
       this.loading = false;
       if (!res) return;
+
+      this.initData();
       this.$message.success("保存成功!");
     },
   },

+ 16 - 2
src/modules/base/components/course-simple/TeacherSimpleManage.vue

@@ -18,7 +18,7 @@
           >
         </el-form-item>
       </el-form>
-      <div class="part-box-action">
+      <div v-if="editable" class="part-box-action">
         <el-button type="danger" @click="toBatchDelete">批量删除</el-button>
         <el-button type="primary" @click="toAdd">新增教师</el-button>
       </div>
@@ -30,6 +30,7 @@
         @selection-change="handleSelectionChange"
       >
         <el-table-column
+          v-if="editable"
           type="selection"
           width="55"
           align="center"
@@ -44,7 +45,12 @@
         <el-table-column prop="userCode" label="用户名/工号"></el-table-column>
         <el-table-column prop="roleName" label="角色"></el-table-column>
         <el-table-column prop="orgName" label="所在机构"></el-table-column>
-        <el-table-column class-name="action-column" label="操作" width="140px">
+        <el-table-column
+          v-if="editable"
+          class-name="action-column"
+          label="操作"
+          width="140px"
+        >
           <template slot-scope="scope">
             <el-button
               class="btn-primary"
@@ -78,12 +84,14 @@
 
     <!-- ModifyTeacherSimple -->
     <modify-teacher-simple
+      v-if="editable"
       ref="ModifyTeacherSimple"
       :course="course"
       @modified="getList"
     ></modify-teacher-simple>
     <!-- TeacherSimpleAssignCourseDialog -->
     <teacher-simple-assign-course-dialog
+      v-if="editable"
       ref="TeacherSimpleAssignCourseDialog"
       :teacher="curRow"
     ></teacher-simple-assign-course-dialog>
@@ -118,8 +126,14 @@ export default {
       multipleSelection: [],
       dataList: [],
       curRow: {},
+      userId: this.$ls.get("user", { id: "" }).id,
     };
   },
+  computed: {
+    editable() {
+      return this.userId === this.course.courseCreateId;
+    },
+  },
   mounted() {
     this.initData();
   },

+ 35 - 0
src/modules/base/store.js

@@ -0,0 +1,35 @@
+import { courseWeightSettingStatus } from "./api";
+
+const state = {
+  cwStatus: {
+    // 曾经设置过情况,true:曾经设置过(编辑课程设置时警告提示),false:从未设置过(不需要提示)
+    everSettingStatus: false,
+    // 当前设置情况,true:当前课程设置过权重,权重设置界面需要展示两个表单,false:当前未设置权重,权重设置界面只展示1个表单
+    currentSettingStatus: false,
+    // 教学课程管理者(创建人)id 当前登录人和课程创建人一致时“教学班”“教师团队”两个页签才能编辑,否则只能查看
+    courseCreateId: "",
+  },
+};
+
+const mutations = {
+  setCwStatus(state, data) {
+    state.cwStatus = Object.assign({}, state.cwStatus, data);
+  },
+  resetState(state) {
+    state.cwStatus = {};
+  },
+};
+
+const actions = {
+  async updateCwStatus({ commit }, data) {
+    const res = await courseWeightSettingStatus(data);
+    commit("setCwStatus", res || {});
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 2 - 0
src/store.js

@@ -10,6 +10,7 @@ const privilegeMap = privilegeMapData ? JSON.parse(privilegeMapData).value : {};
 // modules
 import { card, free } from "./modules/card/store";
 import exam from "./modules/exam/store";
+import base from "./modules/base/store";
 import baseConfigs from "./modules/analysis/components/baseConfig/baseConfigsStore";
 import markParam from "./modules/mark/components/markParam/store";
 import report from "./modules/mark/components/report/store";
@@ -33,6 +34,7 @@ export default new Vuex.Store({
     card,
     free,
     exam,
+    base,
     baseConfigs,
     markParam,
     report,