瀏覽代碼

feat: 课程选择调整

zhangjie 1 年之前
父節點
當前提交
e925e1935c

+ 1 - 11
src/components/base/BaseCourseSelect.vue

@@ -29,8 +29,6 @@ export default {
     placeholder: { type: String, default: "请选择" },
     value: { type: [Number, String], default: "" },
     clearable: { type: Boolean, default: true },
-    printPlanId: { type: [String, Array], default: "" },
-    teachingRoomId: { type: [String, Array], default: "" },
   },
   data() {
     return {
@@ -45,13 +43,6 @@ export default {
         this.selected = val;
       },
     },
-    printPlanId(val, oldval) {
-      if (val !== oldval) {
-        this.search("");
-        this.$emit("input", "");
-        this.$emit("change", {});
-      }
-    },
     teachingRoomId(val, oldval) {
       if (val !== oldval) {
         this.search("");
@@ -67,10 +58,9 @@ export default {
     async search(query) {
       const res = await courseQuery({
         param: query,
-        printPlanId: this.printPlanId,
         teachingRoomId: this.teachingRoomId,
       });
-      this.optionList = res;
+      this.optionList = res.basicCourseList;
     },
     select() {
       this.$emit("input", this.selected);

+ 3 - 0
src/components/base/CourseSelect.vue

@@ -75,6 +75,9 @@ export default {
   },
   methods: {
     async search() {
+      this.optionList = [];
+      if (!this.examId) return;
+
       let data = {
         semesterId: this.semesterId,
         examId: this.examId,

+ 3 - 0
src/components/base/PaperNumberSelect.vue

@@ -77,6 +77,9 @@ export default {
   },
   methods: {
     async search() {
+      this.optionList = [];
+      if (!this.examId) return;
+
       let data = {
         semesterId: this.semesterId,
         examId: this.examId,

+ 26 - 7
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -46,13 +46,19 @@
                 :disabled="!examTask.examId"
                 @change="courseChange"
               >
-                <el-option
+                <el-option-group
                   v-for="item in courses"
-                  :key="item.id"
-                  :value="item.id"
-                  :label="`${item.name}(${item.code})`"
+                  :key="item.label"
+                  :label="item.label"
                 >
-                </el-option>
+                  <el-option
+                    v-for="course in item.options"
+                    :key="course.id"
+                    :value="course.id"
+                    :label="`${course.name}(${course.code})`"
+                  >
+                  </el-option>
+                </el-option-group>
               </el-select>
             </el-form-item>
           </el-col>
@@ -577,7 +583,19 @@ export default {
       const res = await courseQuery({
         teachingRoomId: this.examTask.teachingRoomId,
       });
-      this.courses = res || [];
+      const teachingCourseIds = res.teachCourseList.map((item) => item.id);
+      this.courses = [
+        {
+          label: "课程管理",
+          options: res.teachCourseList,
+        },
+        {
+          label: "开课学院",
+          options: res.basicCourseList.filter(
+            (item) => !teachingCourseIds.includes(item.id)
+          ),
+        },
+      ];
     },
     semesterChange(val) {
       this.examTask.paperName = val.name;
@@ -590,7 +608,8 @@ export default {
     },
     courseChange(val) {
       if (val) {
-        const course = this.courses.find((item) => item.id === val);
+        const courseList = this.courses.map((item) => item.options).flat();
+        const course = courseList.find((item) => item.id === val);
         this.examTask.courseName = course.name;
       } else {
         this.examTask.courseName = "";

+ 3 - 1
src/modules/exam/components/createExamAndPrintTask/InfoPrintTask.vue

@@ -562,7 +562,9 @@ export default {
       }
 
       this.disabledStudentIds = this.getTabelStudentIds();
-      this.showStudent = this.checkPrivilege("button", "SelectStudent");
+      this.showStudent =
+        this.checkPrivilege("button", "SelectStudent") &&
+        this.infoExamTask.examModel !== "MODEL1";
       this.$refs.ModifyExamTaskStudent.open();
     },
     getTabelStudentIds() {

+ 24 - 6
src/modules/exam/components/createExamAndPrintTask/ModifyExamTaskStudent.vue

@@ -14,13 +14,19 @@
       <el-form inline>
         <el-form-item>
           <el-select v-model="filter.courseId" placeholder="请选择" filterable>
-            <el-option
+            <el-option-group
               v-for="item in courses"
-              :key="item.id"
-              :value="item.id"
-              :label="`${item.name}(${item.code})`"
+              :key="item.label"
+              :label="item.label"
             >
-            </el-option>
+              <el-option
+                v-for="course in item.options"
+                :key="course.id"
+                :value="course.id"
+                :label="`${course.name}(${course.code})`"
+              >
+              </el-option>
+            </el-option-group>
           </el-select>
         </el-form-item>
         <el-form-item>
@@ -186,7 +192,19 @@ export default {
       const res = await courseQuery({
         teachingRoomId: this.filterParams.teachingRoomId,
       });
-      this.courses = res || [];
+      const teachingCourseIds = res.teachCourseList.map((item) => item.id);
+      this.courses = [
+        {
+          label: "课程管理",
+          options: res.teachCourseList,
+        },
+        {
+          label: "开课学院",
+          options: res.basicCourseList.filter(
+            (item) => !teachingCourseIds.includes(item.id)
+          ),
+        },
+      ];
     },
     async getStudents() {
       const data = await uploadOrFindExamTaskStudent(this.filter);