Selaa lähdekoodia

批量设置给分间隔

xiatian 1 kuukausi sitten
vanhempi
commit
8be6dee372
1 muutettua tiedostoa jossa 61 lisäystä ja 23 poistoa
  1. 61 23
      src/modules/marking/views/MarkSettingMain.vue

+ 61 - 23
src/modules/marking/views/MarkSettingMain.vue

@@ -72,6 +72,14 @@
                   </el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
+              <el-button
+                style="margin-left: 10px"
+                type="primary"
+                size="small"
+                :disabled="noBatchSelected"
+                @click="openStepModelBatch()"
+                >给分间隔设置</el-button
+              >
             </el-form-item>
           </el-form>
           <!-- 导入弹窗 -->
@@ -148,7 +156,9 @@
             :data="tableData"
             border
             style="width: 100%"
+            @selection-change="handleSelectionChange"
           >
+            <el-table-column type="selection" width="40"></el-table-column>
             <el-table-column
               label="课程名称"
               width="200"
@@ -221,12 +231,13 @@
             :inline="true"
             :model="stepForm"
             :rules="stepRules"
+            :inline-message="true"
             label-width="90px"
           >
             <el-row>
-              <el-form-item label="给分间隔" prop="step">
+              <el-form-item label="给分间隔" prop="scoreStep">
                 <el-input-number
-                  v-model="stepForm.step"
+                  v-model="stepForm.scoreStep"
                   size="mini"
                   :precision="1"
                   :step="0.1"
@@ -238,7 +249,7 @@
             <el-row class="pull-center">
               <el-button
                 type="primary"
-                :loading="stepForm.loading"
+                :loading="stepFormLoading"
                 @click="subStep"
                 >确定</el-button
               >
@@ -261,6 +272,7 @@ export default {
   },
   data() {
     return {
+      selectedIds: [],
       formSearch: {
         courseCode: "",
         courseName: "",
@@ -285,10 +297,10 @@ export default {
       stepModelKey: Math.random(),
       stepForm: {
         workId: null,
-        courseCode: null,
-        step: null,
-        loading: false,
+        courseCodes: [],
+        scoreStep: null,
       },
+      stepFormLoading: false,
       paperId: "",
       impDialog: false,
       uploadAction: MARKING_LOGIC_API + "/markTasks/import",
@@ -299,7 +311,7 @@ export default {
       fileLoading: false,
       fileList: [],
       stepRules: {
-        step: [
+        scoreStep: [
           { required: true, message: "请输入给分间隔", trigger: "change" },
         ],
       },
@@ -315,6 +327,13 @@ export default {
       }
       return courseSelect;
     },
+    noBatchSelected() {
+      if (this.selectedIds.length === 0) {
+        return true;
+      } else {
+        return false;
+      }
+    },
   },
   created() {
     this.workId = this.$route.params.workId;
@@ -327,10 +346,23 @@ export default {
     this.getCourses();
   },
   methods: {
+    handleSelectionChange(val) {
+      this.selectedIds = [];
+      val.forEach((element) => {
+        this.selectedIds.push(element.code);
+      });
+    },
+    openStepModelBatch() {
+      this.stepForm.scoreStep = 0.5;
+      this.stepForm.workId = this.workId;
+      this.stepForm.courseCodes = this.selectedIds;
+      this.stepModel = true;
+    },
     openStepModel(row) {
-      this.stepForm.step = row.scoreStep || 0.5;
-      this.stepForm.workId = row.workId;
-      this.stepForm.courseCode = row.code;
+      this.stepForm.scoreStep = row.scoreStep || 0.5;
+      this.stepForm.workId = this.workId;
+      this.stepForm.courseCodes = [];
+      this.stepForm.courseCodes.push(row.code);
       this.stepModel = true;
     },
     closeStepModel() {
@@ -342,26 +374,32 @@ export default {
       if (!res) {
         return;
       }
-      this.stepForm.loading = true;
-      var url =
-        MARKING_API +
-        "/markCourses/score-step?workId=" +
-        this.stepForm.workId +
-        "&courseCode=" +
-        this.stepForm.courseCode +
-        "&scoreStep=" +
-        this.stepForm.step;
-      this.$httpWithMsg
-        .put(url)
+      this.stepFormLoading = true;
+      var url = MARKING_API + "/markCourses/score-step";
+
+      this.$http
+        .post(url, this.stepForm)
         .then(() => {
           this.$notify({
+            title: "成功",
+            message: "操作成功",
             type: "success",
-            message: "设置成功!",
           });
           this.closeStepModel();
           this.initSetting();
         })
-        .finally(() => (this.stepForm.loading = false));
+        .catch((res) => {
+          var errorMsg = "操作失败";
+          if (res.response && res.response.data) {
+            errorMsg = res.response.data.desc;
+          }
+          this.$notify({
+            title: "提示",
+            message: errorMsg,
+            type: "error",
+          });
+        })
+        .finally(() => (this.stepFormLoading = false));
     },
     //查询课程
     getCourses() {