lsc 8 hónapja
szülő
commit
0a1d7b1b1b
1 módosított fájl, 8 hozzáadás és 16 törlés
  1. 8 16
      src/components/pages/disAdmin/score.vue

+ 8 - 16
src/components/pages/disAdmin/score.vue

@@ -844,25 +844,16 @@ export default {
             }
             acc[cur.rid].push(cur.score);
             return acc;
-          }, {});suo
+          }, {});
 
           // 计算每组的first、second和third的平均值,并将结果存储在新的数组b中
           var b = Object.keys(grouped).map(function (key) {
             var scores = grouped[key];
-            var firstPw = Math.round(
-              (parseInt(scores[0].first) +
-                parseInt(scores[0].second) +
-                parseInt(scores[0].third)) /
-                3
-            );
-            var secondPw = Math.round(
-              (parseInt(scores[1].first) +
-                parseInt(scores[1].second) +
-                parseInt(scores[1].third)) /
-                3
-            );
-            var sum = ((firstPw + secondPw) / 2).toFixed(2);
-            return { rid: key, firstPw: firstPw, secondPw: secondPw, sum: sum };
+            var firstPw = scores[0] ? Math.round(parseInt(scores[0].first)) : 0;
+            var secondPw = scores[1] ? Math.round(parseInt(scores[1].first)) : 0;
+            var thirdPw = scores[2] ? Math.round(parseInt(scores[2].first)) : 0;
+            var sum = ((firstPw + secondPw + thirdPw) / 3).toFixed(2);
+            return { rid: key, firstPw: firstPw, secondPw: secondPw,thirdPw: thirdPw, sum: sum };
           });
 
           for (var i = 0; i < b.length; i++) {
@@ -940,6 +931,7 @@ export default {
         _json["案例名称"] = res[i].title;
         _json["评审1"] = res[i].firstPw;
         _json["评审2"] = res[i].secondPw;
+        _json["评审3"] = res[i].thirdPw;
         _json["平均分"] = res[i].sum;
         array.push(_json);
       }
@@ -953,7 +945,7 @@ export default {
       //   { wch: 50 },
       // ];
       XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
-      XLSX.writeFile(workbook, "项目数据导出.xlsx");
+      XLSX.writeFile(workbook, "案例评分导出.xlsx");
       // const wopts = { bookType: "xlsx", bookSST: false, type: "array" };//写入的样式bookType:输出的文件类型,type:输出的数据类型,bookSST: 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
       // const wbout = XLSX.write(workbook, wopts);// 浏览器端和node共有的API,实际上node可以直接使用xlsx.writeFile来写入文件,但是浏览器没有该API
       // FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }), `${title} demo.xlsx`);//保存文件