xiatian il y a 4 ans
Parent
commit
b3b1c65726

+ 16 - 4
src/modules/questions/views/InsertBluePaperStructure.vue

@@ -285,9 +285,6 @@ export default {
       coursePropertyList: [],
       rules: {
         name: [{ required: true, message: "请输入名称", trigger: "blur" }],
-        remark: [
-          { required: true, message: "请输入题型描述", trigger: "blur" },
-        ],
       },
     };
   },
@@ -295,7 +292,7 @@ export default {
     totalScore() {
       var sum = 0.0;
       for (let paperDetailStruct of this.paperDetailStructs) {
-        sum += paperDetailStruct.score;
+        sum = this.accAdd(sum, paperDetailStruct.score);
       }
       return sum;
     },
@@ -324,6 +321,21 @@ export default {
     this.searchForm();
   },
   methods: {
+    accAdd(num1, num2) {
+      let sq1, sq2, m;
+      try {
+        sq1 = num1.toString().split(".")[1].length;
+      } catch (e) {
+        sq1 = 0;
+      }
+      try {
+        sq2 = num2.toString().split(".")[1].length;
+      } catch (e) {
+        sq2 = 0;
+      }
+      m = Math.pow(10, Math.max(sq1, sq2));
+      return (num1 * m + num2 * m) / m;
+    },
     //查询大题结合
     searchForm() {
       this.loading = true;

+ 24 - 12
src/modules/questions/views/InsertPaperStructure.vue

@@ -278,7 +278,7 @@ export default {
     totalScore() {
       var sum = 0.0;
       for (let paperDetailStruct of this.paperDetailStructs) {
-        sum += paperDetailStruct.totalScore;
+        sum = this.accAdd(sum, paperDetailStruct.totalScore);
       }
       return sum;
     },
@@ -298,6 +298,21 @@ export default {
   },
 
   methods: {
+    accAdd(num1, num2) {
+      let sq1, sq2, m;
+      try {
+        sq1 = num1.toString().split(".")[1].length;
+      } catch (e) {
+        sq1 = 0;
+      }
+      try {
+        sq2 = num2.toString().split(".")[1].length;
+      } catch (e) {
+        sq2 = 0;
+      }
+      m = Math.pow(10, Math.max(sq1, sq2));
+      return (num1 * m + num2 * m) / m;
+    },
     //查询列表集合
     searchForm() {
       this.loading = true;
@@ -414,20 +429,17 @@ export default {
     submitForm(formData) {
       this.$refs[formData].validate((valid) => {
         if (valid) {
-          var ids = [];
-          for (let paperDetailStruct of this.paperDetailStructs) {
-            ids.push(paperDetailStruct.id);
-          }
-          ids.sort();
-          var maxId;
-          if (ids.length == 0) {
-            maxId = 1;
+          var nextId;
+          if (!this.paperDetailStructs || this.paperDetailStructs.length == 0) {
+            nextId = 1;
           } else {
-            maxId = ids[ids.length - 1];
+            nextId =
+              this.paperDetailStructs[this.paperDetailStructs.length - 1].id +
+              1;
           }
           var paperDetailStruct = Object.assign({}, this.paperDetailStructForm);
-          paperDetailStruct.id = maxId + 1;
-          paperDetailStruct.number = this.paperDetailStructs.length + 1;
+          paperDetailStruct.id = nextId;
+          paperDetailStruct.number = paperDetailStruct.id;
           this.paperDetailStructs.push(paperDetailStruct);
           this.paperDetailStructDialog = false;
           this.paperDetailStructForm = { name: "", remark: "" };

+ 8 - 4
src/modules/questions/views/InsertPaperStructureInfo.vue

@@ -229,12 +229,14 @@
               </el-col>
               <el-col :span="12">
                 <el-form-item label="每题分值" prop="score" label-width="78px">
-                  <el-input
+                  <el-input-number
                     v-model.number="paperUnitForm2.score"
                     class="form_width"
                     placeholder="请输入"
+                    :precision="1"
+                    :min="0.1"
                     @change="muli2"
-                  ></el-input>
+                  ></el-input-number>
                 </el-form-item>
               </el-col>
             </el-row>
@@ -992,10 +994,12 @@ export default {
               unitStruct.quesNames = this.paperUnitForm2.quesNames;
               unitStruct.publicSimple = this.paperUnitForm2.publicSimple;
               unitStruct.publicMedium = this.paperUnitForm2.publicMedium;
-              unitStruct.publicDifficulty = this.paperUnitForm2.publicDifficulty;
+              unitStruct.publicDifficulty =
+                this.paperUnitForm2.publicDifficulty;
               unitStruct.noPublicSimple = this.paperUnitForm2.noPublicSimple;
               unitStruct.noPublicMedium = this.paperUnitForm2.noPublicMedium;
-              unitStruct.noPublicDifficulty = this.paperUnitForm2.noPublicDifficulty;
+              unitStruct.noPublicDifficulty =
+                this.paperUnitForm2.noPublicDifficulty;
               unitStruct.publicSum = this.paperUnitForm2.publicSum;
               unitStruct.noPublicSum = this.paperUnitForm2.noPublicSum;
               unitStruct.simpleSum = this.paperUnitForm2.simpleSum;