zhangjie 1 rok temu
rodzic
commit
3e897a5b33

+ 53 - 1
src/modules/mark/components/markParam/ModifyMarkGroup.vue

@@ -14,7 +14,10 @@
     <!-- <div slot="title"></div> -->
     <el-form ref="rowInfoFormRef" :model="rowInfo" :rules="rowInfoRules" inline>
       <el-form-item label="评卷方式:" label-width="80px">
-        <el-radio-group v-model="rowInfo.doubleEnable">
+        <el-radio-group
+          v-model="rowInfo.doubleEnable"
+          @change="doubleEnableChange"
+        >
           <el-radio :label="false">单评</el-radio>
           <el-radio :label="true">双评</el-radio>
         </el-radio-group>
@@ -289,6 +292,7 @@ export default {
           },
         ],
       },
+      instRow: {},
       rowInfo: {},
       rowInfoRules: {
         doubleRate: [
@@ -342,6 +346,7 @@ export default {
       this.rowInfo.doubleRate = this.rowInfo.doubleRate || undefined;
       this.rowInfo.arbitrateThreshold =
         this.rowInfo.arbitrateThreshold || undefined;
+      this.instRow = { ...this.rowInfo };
     },
     cancel() {
       this.modalIsShow = false;
@@ -350,6 +355,10 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    doubleEnableChange() {
+      this.rowInfo.arbitrateThreshold = undefined;
+      this.rowInfo.doubleRate = undefined;
+    },
     // user
     switchUserType(type) {
       this.filterLabel = "";
@@ -584,12 +593,55 @@ export default {
         .map((item) => `${item.mainNumber}_${item.subNumber}`)
         .join();
     },
+    equalArr(arr1, arr2) {
+      arr1.sort((a, b) => {
+        return a > b ? -1 : 1;
+      });
+      arr2.sort((a, b) => {
+        return a > b ? -1 : 1;
+      });
+      // console.log(arr1, arr2);
+      return JSON.stringify(arr1) === JSON.stringify(arr2);
+    },
+    checkDataChange() {
+      const fields = ["doubleEnable", "arbitrateThreshold", "doubleRate"];
+      let changed = fields.some(
+        (field) => this.rowInfo[field] !== this.instRow[field]
+      );
+      if (changed) return true;
+
+      const prevUserIds = this.instance.markers.map((item) => item.userId);
+      const curUserIds = this.selectedUsers.map((item) => item.id);
+      changed = !this.equalArr(prevUserIds, curUserIds);
+      if (changed) return true;
+
+      const prevQnos = this.instance.questions.map(
+        (item) => `${item.mainNumber}-${item.subNumber}`
+      );
+      const curQnos = this.selectedQuestions.map(
+        (item) => `${item.mainNumber}-${item.subNumber}`
+      );
+      changed = !this.equalArr(prevQnos, curQnos);
+      return changed;
+    },
     // confirm
     async confirm() {
       const valid1 = await this.$refs.rowInfoFormRef.validate().catch(() => {});
       const valid2 = await this.$refs.modalFormRef.validate().catch(() => {});
       if (!valid1 || !valid2) return;
 
+      const changed = this.checkDataChange();
+      if (changed) {
+        const confirm = await this.$confirm(
+          `保存后分组关联所有评卷任务都将删除,并生成新的分组任务!`,
+          "提示",
+          {
+            type: "warning",
+          }
+        ).catch(() => {});
+        if (confirm !== "confirm") return;
+      }
+
       let datas = Object.assign({}, this.instance, this.rowInfo);
       datas.markers = this.selectedUsers.map((item) => {
         return {