xiatian 4 lat temu
rodzic
commit
0980476338

+ 17 - 2
src/modules/questions/views/InsertBluePaperStructure.vue

@@ -295,7 +295,7 @@ export default {
     totalScore() {
       var sum = 0.0;
       for (let paperDetailStruct of this.paperDetailStructs) {
-        sum += paperDetailStruct.score;
+        sum = this.accAdd(paperDetailStruct.score, sum);
       }
       return sum;
     },
@@ -324,6 +324,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;
@@ -421,7 +436,7 @@ export default {
     checkTotalScore() {
       var totalScore = 0;
       for (let paperDetailStruct of this.blueStruct.paperDetailStructs) {
-        totalScore = parseFloat(paperDetailStruct.totalScore) + totalScore;
+        totalScore = this.accAdd(paperDetailStruct.totalScore, totalScore);
       }
       if (totalScore != this.blueStruct.totalScore) {
         return false;

+ 16 - 1
src/modules/questions/views/InsertPaperStructure.vue

@@ -279,7 +279,7 @@ export default {
     totalScore() {
       var sum = 0.0;
       for (let paperDetailStruct of this.paperDetailStructs) {
-        sum += paperDetailStruct.totalScore;
+        sum = this.accAdd(paperDetailStruct.totalScore, sum);
       }
       return sum;
     },
@@ -299,6 +299,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;

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

@@ -229,12 +229,13 @@
               </el-col>
               <el-col :span="12">
                 <el-form-item label="每题分值" prop="score" label-width="78px">
-                  <el-input
-                    v-model.number="paperUnitForm2.score"
-                    class="form_width"
-                    placeholder="请输入"
+                  <el-input-number
+                    v-model="paperUnitForm2.score"
+                    size="small"
+                    :precision="1"
+                    :min="0"
                     @change="muli2"
-                  ></el-input>
+                  ></el-input-number>
                 </el-form-item>
               </el-col>
             </el-row>
@@ -832,7 +833,7 @@ export default {
     totalScore() {
       var sum = 0.0;
       for (let unitStruct of this.unitStructs) {
-        sum += unitStruct.totalScore;
+        sum = this.accAdd(unitStruct.totalScore, sum);
       }
       return sum;
     },
@@ -860,6 +861,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;
+    },
     //查询来源大题名称
     getQuesNameList(quesType) {
       if (quesType && quesType.length > 0) {
@@ -978,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;