소스 검색

课程管理接口调整

zhangjie 1 년 전
부모
커밋
7f65b38fb5

+ 12 - 9
src/modules/base/api.js

@@ -579,10 +579,15 @@ export const updateTeacherSimple = (datas) => {
 export const batchAddTeacherSimple = (datas) => {
   return $postParam("/api/admin/teach/course/select_create_teacher", datas);
 };
-
+export const teacherSimpleCourseQuery = (datas) => {
+  return $postParam("/api/admin/teach/course/find_teacher_by_org", datas);
+};
+export const teacherSimpleAssignCourse = (datas) => {
+  return $post("/api/admin/teach/course/assign_clazz", datas);
+};
 // course-target-manage
-export const courseTargetList = (courseCode) => {
-  return $postParam("/api/admin/teach/course_target/list", { courseCode });
+export const courseTargetList = (datas) => {
+  return $postParam("/api/admin/teach/course_target/list", datas);
 };
 export const updateCourseTarget = (datas) => {
   return $post("/api/admin/teach/course_target/save", datas);
@@ -590,14 +595,12 @@ export const updateCourseTarget = (datas) => {
 export const deleteCourseTarget = (id) => {
   return $postParam("/api/admin/teach/course_target/delete", { id });
 };
-export const courseDimensionTree = (courseCode) => {
-  return $postParam("/api/admin/teach/course_target/dimension_tree", {
-    courseCode,
-  });
+export const courseDimensionTree = (datas) => {
+  return $postParam("/api/admin/teach/course_target/dimension_tree", datas);
 };
 // comment-evaluation-manage
-export const courseEvaluationList = (courseCode) => {
-  return $postParam("/api/admin/teach/course_evaluation/list", { courseCode });
+export const courseEvaluationList = (datas) => {
+  return $postParam("/api/admin/teach/course_evaluation/list", datas);
 };
 export const updateCourseEvaluation = (datas) => {
   return $post("/api/admin/teach/course_evaluation/save", datas);

+ 18 - 6
src/modules/base/components/course-simple/CourseEvaluationManage.vue

@@ -68,11 +68,17 @@ export default {
   },
   methods: {
     async getList() {
-      const res = await courseEvaluationList(this.course.courseCode);
+      const res = await courseEvaluationList({
+        courseCode: this.course.courseCode,
+        examId: this.course.examId,
+      });
       this.dataList = res || [];
     },
     toAdd() {
-      this.curRow = { courseCode: this.course.courseCode };
+      this.curRow = {
+        courseCode: this.course.courseCode,
+        examId: this.course.examId,
+      };
       this.$refs.ModifyCourseEvaluation.open();
     },
     async toDelete(row) {
@@ -85,11 +91,17 @@ export default {
       ).catch(() => {});
       if (confirm !== "confirm") return;
 
-      await deleteCourseEvaluation(row.evaluationId);
+      const res = await deleteCourseEvaluation(row.evaluationId);
+      if (res.warning) {
+        this.$notify({
+          title: "警告",
+          message: "评价方式有变化,请重新设置权重设置!",
+          type: "warning",
+          duration: 5000,
+        });
+      }
       this.$message.success("删除成功!");
-      this.dataList = this.dataList.filter(
-        (item) => item.evaluationId !== row.evaluationId
-      );
+      this.getList();
     },
   },
 };

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

@@ -63,7 +63,7 @@ export default {
       curTab: "ClazzSimpleManage",
       tabs: [
         {
-          name: "班级管理",
+          name: "教学班",
           val: "ClazzSimpleManage",
         },
         {

+ 25 - 6
src/modules/base/components/course-simple/CourseTargetManage.vue

@@ -11,10 +11,10 @@
       <el-table :data="dataList">
         <el-table-column type="index" label="序号" width="70"></el-table-column>
         <el-table-column prop="targetName" label="课程目标"></el-table-column>
-        <el-table-column prop="targetValue" label="毕业要求指标">
+        <el-table-column prop="dimensionList" label="毕业要求指标">
           <template slot-scope="scope">
-            <p v-for="item in scope.row.targetValue" :key="item.dimensionId">
-              {{ item.dimensionName }}({{ item.dimensionCode }})
+            <p v-for="item in scope.row.dimensionList" :key="item.id">
+              {{ item.name }}({{ item.code }})
             </p>
           </template>
         </el-table-column>
@@ -52,6 +52,10 @@
       ref="ImportFile"
       title="导入课程知识点"
       :upload-url="uploadUrl"
+      :upload-data="{
+        courseCode: course.courseCode,
+        examId: course.examId,
+      }"
       :format="['xls', 'xlsx']"
       :download-handle="() => downloadTemplate('courseProperty')"
       :download-filename="dfilename"
@@ -98,11 +102,18 @@ export default {
       this.$refs.ImportFile.open();
     },
     toAdd() {
-      this.curRow = { courseCode: this.course.courseCode };
+      this.curRow = {
+        courseCode: this.course.courseCode,
+        examId: this.course.examId,
+      };
       this.$refs.ModifyCourseTarget.open();
     },
     toEdit(row) {
-      this.curRow = { ...row, courseCode: this.course.courseCode };
+      this.curRow = {
+        ...row,
+        courseCode: this.course.courseCode,
+        examId: this.course.examId,
+      };
       this.$refs.ModifyCourseTarget.open();
     },
     async toDelete(row) {
@@ -115,8 +126,16 @@ export default {
       ).catch(() => {});
       if (confirm !== "confirm") return;
 
-      await deleteCourseTarget(row.id);
+      const res = await deleteCourseTarget(row.id);
       this.$message.success("删除成功!");
+      if (res.warning) {
+        this.$notify({
+          title: "警告",
+          message: "课程目标有变化,请重新设置权重设置!",
+          type: "warning",
+          duration: 5000,
+        });
+      }
       this.dataList = this.dataList.filter((item) => item.id !== row.id);
     },
   },

+ 74 - 9
src/modules/base/components/course-simple/CourseWeightManage.vue

@@ -51,14 +51,14 @@
               <el-row type="flex" align="middle">
                 <el-col :span="2">
                   <el-checkbox
-                    v-model="scope.row.targets[tindex].used"
+                    v-model="scope.row.targets[tindex].enable"
                     @change="usedChange(scope.$index, tindex)"
                   ></el-checkbox>
                 </el-col>
                 <el-col :span="10">
                   <el-input-number
                     v-model="scope.row.targets[tindex].weight"
-                    :disabled="!scope.row.targets[tindex].used"
+                    :disabled="!scope.row.targets[tindex].enable"
                     class="width-80"
                     size="small"
                     :min="0"
@@ -73,7 +73,7 @@
                 <el-col :span="12">
                   <el-input-number
                     v-model="scope.row.targets[tindex].targetScore"
-                    :disabled="!scope.row.targets[tindex].used"
+                    :disabled="!scope.row.targets[tindex].enable"
                     class="width-80"
                     size="small"
                     :min="0"
@@ -98,6 +98,7 @@
         :data="dataList"
         :header-cell-style="{ textAlign: 'center' }"
         :cell-style="{ textAlign: 'center' }"
+        :span-method="spanMethod"
       >
         <el-table-column
           prop="courseTargetName"
@@ -120,7 +121,7 @@
           >
             <template slot-scope="scope">
               {{
-                scope.row.evaluation[eindex].used
+                scope.row.evaluation[eindex].enable
                   ? scope.row.evaluation[eindex].targetScore
                   : ""
               }}
@@ -204,7 +205,7 @@ export default {
           }
           evaluationList[index].targets.push({
             ...targetData,
-            used: item.used,
+            enable: item.enable,
             weight: item.weight || undefined,
             targetScore: item.targetScore || undefined,
           });
@@ -216,25 +217,40 @@ export default {
     },
     usedChange(rowIndex, tindex) {
       const target = this.tableSetData[rowIndex].targets[tindex];
-      if (!target.used) {
+      if (!target.enable) {
         target.weight = undefined;
         target.targetScore = undefined;
       }
     },
     getEvaluationSumScore(evaluation) {
       return calcSum(
-        evaluation.map((item) => (item.used ? item.targetScore : 0))
+        evaluation.map((item) => (item.enable ? item.targetScore : 0))
       );
     },
+    spanMethod({ rowIndex, columnIndex }) {
+      const lineCount = this.dataList.length - 1;
+      if (rowIndex === lineCount) {
+        if (columnIndex === 0) {
+          return [1, 2];
+        } else if (columnIndex === 1) {
+          return [0, 0];
+        }
+      }
+    },
     updateDataList() {
       const evaluationData = {};
       this.tableSetData.forEach((item) => {
         item.targets.forEach((elem) => {
           const key = `${item.evaluationName}_${elem.courseTargetId}`;
-          evaluationData[key] = pick(elem, ["used", "weight", "targetScore"]);
+          evaluationData[key] = pick(elem, ["enable", "weight", "targetScore"]);
         });
       });
 
+      const lastData = this.dataList.slice(-1)[0];
+      if (lastData && lastData.courseTargetId === "total") {
+        this.dataList.pop();
+      }
+
       this.dataList.forEach((target) => {
         target.totalWeight = this.targetTotalWeight[target.courseTargetId];
         target.evaluation.forEach((item) => {
@@ -242,10 +258,58 @@ export default {
           Object.assign(item, evaluationData[key]);
         });
       });
+
+      // 更新合计
+      const tatolEvaluation = this.evaluationData.map(
+        (evaluationName, eindex) => {
+          const targetScore = calcSum(
+            this.dataList.map(
+              (item) => item.evaluation[eindex].targetScore || 0
+            )
+          );
+          return {
+            evaluationName,
+            enable: true,
+            weight: null,
+            targetScore,
+          };
+        }
+      );
+      this.dataList.push({
+        courseTargetId: "total",
+        courseTargetName: "合计",
+        degreeRequirement: "",
+        totalWeight: calcSum(
+          this.dataList.map((item) => item.totalWeight || 0)
+        ),
+        evaluation: tatolEvaluation,
+      });
     },
     checkDataList() {
       if (!this.dataList.length) return;
-      //  TODO:
+
+      // 目标整体权重
+      const totalWeight = calcSum(
+        this.dataList.map((item) => item.totalWeight || 0)
+      );
+      if (totalWeight !== 100) {
+        this.$message.error("目标整体权重合计不等于100%");
+        return;
+      }
+
+      // 目标分值统计
+      const weightList = [];
+      this.dataList.forEach((item) => {
+        item.evaluation.forEach((ev) => {
+          if (ev.enable) {
+            weightList.push(ev.weight);
+          }
+        });
+      });
+      if (calcSum(weightList) !== 100) {
+        this.$message.error("目标分值统计不等于100");
+        return;
+      }
 
       return true;
     },
@@ -257,6 +321,7 @@ export default {
 
       this.loading = true;
       const res = await courseWeightSave({
+        examId: this.course.examId,
         courseCode: this.course.courseCode,
         submitForm: this.dataList,
       }).catch(() => {});

+ 11 - 2
src/modules/base/components/course-simple/ModifyCourseEvaluation.vue

@@ -49,6 +49,7 @@ import { updateCourseEvaluation } from "../../api";
 
 const initModalForm = {
   evaluationId: null,
+  examId: "",
   courseCode: "",
   evaluation: "",
   evaluationDesc: "",
@@ -121,12 +122,20 @@ export default {
       if (this.isSubmit) return;
       this.isSubmit = true;
       let datas = { ...this.modalForm };
-      const data = await updateCourseEvaluation(datas).catch(() => {});
+      const res = await updateCourseEvaluation(datas).catch(() => {});
       this.isSubmit = false;
 
-      if (!data) return;
+      if (!res) return;
 
       this.$message.success(this.title + "成功!");
+      if (res.warning) {
+        this.$notify({
+          title: "警告",
+          message: "评价方式有变化,请重新设置权重设置!",
+          type: "warning",
+          duration: 5000,
+        });
+      }
       this.$emit("modified");
       this.cancel();
     },

+ 25 - 14
src/modules/base/components/course-simple/ModifyCourseTarget.vue

@@ -33,14 +33,15 @@
             >选择知识点</el-button
           >
           <el-table
-            v-if="targetValue.length"
-            :data="targetValue"
+            v-if="dimensionList.length"
+            :data="dimensionList"
             :show-header="false"
           >
-            <el-table-column
-              prop="dimensionName"
-              label="知识点"
-            ></el-table-column>
+            <el-table-column prop="name" label="知识点">
+              <template slot-scope="scope">
+                {{ scope.row.name }}({{ scope.row.code }})
+              </template>
+            </el-table-column>
             <el-table-column class-name="action-column" label="操作" width="60">
               <template slot-scope="scope">
                 <i
@@ -74,7 +75,7 @@
     <!-- SelectDimensionDialog -->
     <select-dimension-dialog
       ref="SelectDimensionDialog"
-      :course-code="instance.courseCode"
+      :course="{ courseCode: instance.courseCode, examId: instance.examId }"
       :selected-data="modalForm.dimensionIdList"
       @confirm="dimensionSelected"
     ></select-dimension-dialog>
@@ -87,6 +88,7 @@ import SelectDimensionDialog from "./SelectDimensionDialog.vue";
 
 const initModalForm = {
   id: null,
+  examId: "",
   courseCode: "",
   targetName: "",
   degreeRequirement: "",
@@ -117,7 +119,7 @@ export default {
       modalIsShow: false,
       isSubmit: false,
       modalForm: { ...initModalForm },
-      targetValue: [],
+      dimensionList: [],
       rules: {
         targetName: [
           {
@@ -155,8 +157,8 @@ export default {
   methods: {
     initData(val) {
       this.modalForm = this.$objAssign(initModalForm, val);
-      if (val.targetValue) {
-        this.targetValue = [...val.targetValue];
+      if (val.dimensionList) {
+        this.dimensionList = [...val.dimensionList];
         this.updateDimensionIds();
       } else {
         this.modalForm.dimensionIdList = [];
@@ -175,17 +177,17 @@ export default {
       this.$refs.SelectDimensionDialog.open();
     },
     updateDimensionIds() {
-      this.modalForm.dimensionIdList = this.targetValue.map(
-        (item) => item.dimensionId
+      this.modalForm.dimensionIdList = this.dimensionList.map(
+        (item) => item.id
       );
     },
     dimensionSelected(dimensions) {
-      this.targetValue = [...dimensions];
+      this.dimensionList = [...dimensions];
       this.updateDimensionIds();
       this.$refs.modalFormComp.validateField("dimensionIdList").catch(() => {});
     },
     toDeleteDimension(index) {
-      this.targetValue.splice(index, 1);
+      this.dimensionList.splice(index, 1);
       this.updateDimensionIds();
       this.$refs.modalFormComp.validateField("dimensionIdList").catch(() => {});
     },
@@ -200,6 +202,15 @@ export default {
 
       if (!res) return;
 
+      if (res.warning) {
+        this.$notify({
+          title: "警告",
+          message: "课程目标有变化,请重新设置权重设置!",
+          type: "warning",
+          duration: 5000,
+        });
+      }
+
       this.$message.success(this.title + "成功!");
       this.$emit("modified");
       this.cancel();

+ 18 - 10
src/modules/base/components/course-simple/SelectDimensionDialog.vue

@@ -15,7 +15,7 @@
       :data="treeData"
       show-checkbox
       check-on-click-node
-      node-key="dimensionId"
+      node-key="id"
       :props="defaultProps"
     >
     </el-tree>
@@ -39,9 +39,14 @@ export default {
         return [];
       },
     },
-    courseCode: {
-      type: String,
-      default: "",
+    course: {
+      type: Object,
+      default() {
+        return {
+          examId: "",
+          courseCode: "",
+        };
+      },
     },
   },
   data() {
@@ -50,12 +55,12 @@ export default {
       treeData: [],
       defaultProps: {
         children: "children",
-        label: "dimensionName",
+        label: "name",
       },
     };
   },
   watch: {
-    courseCode: {
+    course: {
       immediate: true,
       handler(val, oldVal) {
         if (!val) return;
@@ -65,7 +70,10 @@ export default {
   },
   methods: {
     async getTree() {
-      const data = await courseDimensionTree(this.courseCode);
+      const data = await courseDimensionTree({
+        examId: this.course.examId,
+        courseCode: this.course.courseCode,
+      });
       this.treeData = data || [];
     },
     visibleChange() {
@@ -89,9 +97,9 @@ export default {
         "confirm",
         selectedNodes.map((item) => {
           return {
-            dimensionId: item.dimensionId,
-            dimensionCode: item.dimensionCode,
-            dimensionName: item.dimensionName,
+            id: item.id,
+            name: item.name,
+            code: item.code,
           };
         })
       );

+ 146 - 0
src/modules/base/components/course-simple/TeacherSimpleAssignCourseDialog.vue

@@ -0,0 +1,146 @@
+<template>
+  <el-dialog
+    class="page-dialog"
+    :visible.sync="modalIsShow"
+    title="分配班级"
+    top="10vh"
+    width="800px"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @opened="visibleChange"
+  >
+    <div class="part-box part-box-pad">
+      <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
+        <el-form-item>
+          <el-input
+            v-model.trim="filterLabel"
+            placeholder="请输入班级名称"
+            clearable
+            @change="labelChange"
+          ></el-input>
+        </el-form-item>
+        <!-- <el-form-item>
+          <el-button type="primary" @click="toPage(1)">查询</el-button>
+        </el-form-item> -->
+      </el-form>
+      <el-table
+        ref="TableList"
+        :data="dataList"
+        @selection-change="handleSelectionChange"
+      >
+        <el-table-column width="55" align="center">
+          <template slot="header">
+            <el-checkbox
+              v-model="checkAll"
+              @change="checkAllChagne"
+            ></el-checkbox>
+          </template>
+          <template slot-scope="scope">
+            <el-checkbox v-model="scope.row.checked"></el-checkbox>
+          </template>
+        </el-table-column>
+        <el-table-column prop="clazzName" label="教学班"></el-table-column>
+        <el-table-column prop="teachers" label="当前分配人"></el-table-column>
+      </el-table>
+    </div>
+    <div slot="footer">
+      <el-button type="primary" :loading="loading" @click="submit"
+        >确认</el-button
+      >
+      <el-button @click="cancel">取消</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { teacherSimpleCourseQuery, teacherSimpleAssignCourse } from "../../api";
+
+export default {
+  name: "select-dimension-dialog",
+  props: {
+    teacher: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      orignDataList: [],
+      dataList: [],
+      filterLabel: "",
+      loading: false,
+    };
+  },
+  methods: {
+    async getList() {
+      const data = await teacherSimpleCourseQuery({
+        examId: this.teacher.examId,
+        courseCode: this.teacher.courseCode,
+      });
+      this.orignDataList = (data || []).map((item) => {
+        if (item.teacherList && item.teacherList.length) {
+          item.teachers = item.teacherList.map((t) => t.name).join(",");
+          item.checked = item.teacherList.some((t) => t.id === this.teacher.id);
+        } else {
+          item.teachers = "公共班级";
+          item.checked = false;
+        }
+        return item;
+      });
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val.map((item) => item.clazzId);
+    },
+    checkAllChagne(checked) {
+      this.dataList.forEach((item) => {
+        item.checked = checked;
+      });
+    },
+    labelChange() {
+      const escapeRegexpString = (value = "") =>
+        String(value).replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
+      const reg = new RegExp(escapeRegexpString(this.filterLabel), "i");
+
+      this.dataList = this.orignDataList.filter((item) =>
+        reg.test(item.clazzName)
+      );
+    },
+    visibleChange() {
+      this.getList();
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    async submit() {
+      const clazzIdList = this.orignDataList
+        .filter((item) => item.checked)
+        .map((item) => item.clazzId);
+
+      if (!clazzIdList.length) {
+        this.$message.error("请选择班级");
+        return;
+      }
+
+      if (this.loading) return;
+      this.loading = true;
+      const res = await teacherSimpleAssignCourse({
+        examId: this.teacher.examId,
+        courseCode: this.teacher.courseCode,
+        teacherId: this.teacher.id,
+        clazzIdList,
+      });
+      this.loading = false;
+      if (!res) return;
+      this.$message.success("保存成功!");
+      this.cancel();
+    },
+  },
+};
+</script>

+ 23 - 3
src/modules/base/components/course-simple/TeacherSimpleManage.vue

@@ -44,8 +44,14 @@
         <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="100px">
+        <el-table-column class-name="action-column" label="操作" width="140px">
           <template slot-scope="scope">
+            <el-button
+              class="btn-primary"
+              type="text"
+              @click="toAssignClazz(scope.row)"
+              >分配班级</el-button
+            >
             <el-button
               class="btn-danger"
               type="text"
@@ -76,16 +82,22 @@
       :course="course"
       @modified="getList"
     ></modify-teacher-simple>
+    <!-- TeacherSimpleAssignCourseDialog -->
+    <teacher-simple-assign-course-dialog
+      ref="TeacherSimpleAssignCourseDialog"
+      :teacher="curRow"
+    ></teacher-simple-assign-course-dialog>
   </div>
 </template>
 
 <script>
 import { teacherSimpleListQuery, deleteTeacherSimple } from "../../api";
-import ModifyTeacherSimple from "./ModifyTeacherSimple";
+import ModifyTeacherSimple from "./ModifyTeacherSimple.vue";
+import TeacherSimpleAssignCourseDialog from "./TeacherSimpleAssignCourseDialog.vue";
 
 export default {
   name: "teacher-simple-manage",
-  components: { ModifyTeacherSimple },
+  components: { ModifyTeacherSimple, TeacherSimpleAssignCourseDialog },
   props: {
     course: {
       type: Object,
@@ -136,6 +148,14 @@ export default {
     toAdd() {
       this.$refs.ModifyTeacherSimple.open();
     },
+    toAssignClazz(row) {
+      this.curRow = {
+        ...row,
+        examId: this.course.examId,
+        courseCode: this.course.courseCode,
+      };
+      this.$refs.TeacherSimpleAssignCourseDialog.open();
+    },
     async toDelete(row) {
       const confirm = await this.$confirm(
         `确定要删除教师【${row.userName}】吗?`,

+ 9 - 9
src/modules/base/components/course-simple/targetData.js

@@ -7,19 +7,19 @@ export const weightList = [
     evaluation: [
       {
         evaluationName: "评价方式名称1",
-        used: true,
+        enable: true,
         weight: 30,
         targetScore: 20,
       },
       {
         evaluationName: "评价方式名称2",
-        used: false,
+        enable: false,
         weight: null,
         targetScore: null,
       },
       {
         evaluationName: "评价方式名称3",
-        used: false,
+        enable: false,
         weight: null,
         targetScore: null,
       },
@@ -33,19 +33,19 @@ export const weightList = [
     evaluation: [
       {
         evaluationName: "评价方式名称1",
-        used: false,
+        enable: false,
         weight: null,
         targetScore: null,
       },
       {
         evaluationName: "评价方式名称2",
-        used: true,
+        enable: true,
         weight: 40,
         targetScore: 30,
       },
       {
         evaluationName: "评价方式名称3",
-        used: true,
+        enable: true,
         weight: 20,
         targetScore: 24,
       },
@@ -59,19 +59,19 @@ export const weightList = [
     evaluation: [
       {
         evaluationName: "评价方式名称1",
-        used: false,
+        enable: false,
         weight: null,
         targetScore: null,
       },
       {
         evaluationName: "评价方式名称2",
-        used: true,
+        enable: true,
         weight: 20,
         targetScore: 30,
       },
       {
         evaluationName: "评价方式名称3",
-        used: false,
+        enable: false,
         weight: null,
         targetScore: null,
       },