浏览代码

新增导出全部数据和导出个人数据

zengyicheng 1 年之前
父节点
当前提交
50c3dc6e27

+ 1 - 1
dist/index.html

@@ -24,4 +24,4 @@
             height: 100%;
             width: 100%;
             background: #e6eaf0;
-        }</style><link href=./static/css/app.dfd444ea16f8dce3a6f40f24fdea05b5.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.ecc36c9873dca1dee44b.js></script><script type=text/javascript src=./static/js/app.6a0d6d45263e87a36208.js></script></body></html><script>document.domain = document.domain.split(".").slice(-2).join(".");</script>
+        }</style><link href=./static/css/app.babfb6e172688ab521f58acca296f0af.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.3ad1d5771e9b13dbdad2.js></script><script type=text/javascript src=./static/js/vendor.dca404bd3711c644c2ae.js></script><script type=text/javascript src=./static/js/app.d333d368e4236b3eb9c4.js></script></body></html><script>document.domain = document.domain.split(".").slice(-2).join(".");</script>

文件差异内容过多而无法显示
+ 0 - 0
dist/static/css/app.babfb6e172688ab521f58acca296f0af.css


文件差异内容过多而无法显示
+ 0 - 0
dist/static/css/app.babfb6e172688ab521f58acca296f0af.css.map


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/app.6a0d6d45263e87a36208.js


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/app.6a0d6d45263e87a36208.js.map


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/app.d333d368e4236b3eb9c4.js


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/app.d333d368e4236b3eb9c4.js.map


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/manifest.3ad1d5771e9b13dbdad2.js.map


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/vendor.dca404bd3711c644c2ae.js


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/vendor.dca404bd3711c644c2ae.js.map


文件差异内容过多而无法显示
+ 0 - 0
dist/static/js/vendor.ecc36c9873dca1dee44b.js


+ 152 - 0
src/components/pages/disAdmin/score.vue

@@ -54,6 +54,24 @@
           ></el-input>
         </div>
       </div>
+      <!-- 导出所有评分数据 -->
+      <!-- <el-button
+        v-show="false"
+        type="primary"
+        size="small"
+        @click="exportAllScore"
+        style="margin-right: 10px"
+        >导出Excel</el-button
+      > -->
+      <!-- 导出个人评分数据 -->
+      <!-- <el-button
+        v-show="false"
+        type="primary"
+        size="small"
+        @click="exportScoreByUid"
+        style="margin-right: 10px"
+        >导出Excel</el-button
+      > -->
     </div>
     <div v-if="isNoTableData" class="isNoMessage">
       <img src="../../../assets/icon/isNoMessage.png" alt />
@@ -788,6 +806,140 @@ export default {
     lookDetail(aid) {
       window.open(window.origin + "/#/anliDetail?aid=" + aid);
     },
+    exportAllScore() {
+      this.ajax
+        .get(this.$store.state.api + "selectAllScore")
+        .then((res) => {
+          var scoreList = res.data[0];
+          // 将score值转换为对象
+          for (var i = 0; i < scoreList.length; i++) {
+            scoreList[i].score = JSON.parse(scoreList[i].score);
+          }
+          // 根据rid进行分组
+          var grouped = scoreList.reduce(function (acc, cur) {
+            if (!acc[cur.rid]) {
+              acc[cur.rid] = [];
+            }
+            acc[cur.rid].push(cur.score);
+            return acc;
+          }, {});
+
+          // 计算每组的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 };
+          });
+
+          for (var i = 0; i < b.length; i++) {
+            for (var j = 0; j < scoreList.length; j++) {
+              if (scoreList[j].rid == b[i].rid) {
+                if (!b[i].title) {
+                  b[i].title = JSON.parse(scoreList[j].info).title;
+                }
+              }
+            }
+          }
+          this.exportExcel(b);
+        })
+        .catch((err) => {
+          this.isLoading = false;
+          console.error(err);
+        });
+    },
+    exportScoreByUid() {
+      this.ajax
+        .get(this.$store.state.api + "selectAllScore")
+        .then((res) => {
+          var scoreList = res.data[0];
+          let params = {
+            uid: this.$store.state.userInfo.userid,
+          };
+          this.ajax
+            .get(this.$store.state.api + "selectScoreByUid", params)
+            .then((res) => {
+              var scoreListByuid = res.data[0];
+              for(var i = 0;i<scoreList.length;i++){
+                for(var j = 0;j<scoreListByuid.length;j++){
+                  if(scoreList[i].rid == scoreListByuid[j].rid){
+                    if(scoreList[i].scorer == scoreListByuid[j].scorer){
+                      var point = JSON.parse(scoreListByuid[j].score);
+                      var a = parseInt(point.first);
+                      var b = parseInt(point.second);
+                      var c = parseInt(point.third);
+                      var sumScore = Math.round((a + b + c) / 3);
+                      scoreListByuid[j].firstPw = sumScore;
+                    }else{
+                      var point = JSON.parse(scoreList[i].score);
+                      var a = parseInt(point.first);
+                      var b = parseInt(point.second);
+                      var c = parseInt(point.third);
+                      var sumScore = Math.round((a + b + c) / 3);
+                      scoreListByuid[j].secondPw = sumScore;
+                    }
+                  }
+                  if(scoreListByuid[j].firstPw && scoreListByuid[j].secondPw){
+                    scoreListByuid[j].sum = ((scoreListByuid[j].firstPw + scoreListByuid[j].secondPw) / 2).toFixed(2)
+                    scoreListByuid[j].title = JSON.parse(scoreListByuid[j].info).title;
+                  }
+                }
+              }
+              this.exportExcel(scoreListByuid);
+            })
+            .catch((err) => {
+              console.error(err);
+            });
+        })
+        .catch((err) => {
+          this.isLoading = false;
+          console.error(err);
+        });
+    },
+
+    exportExcel(t) {
+      var res = t;
+      //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
+      //将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
+      var array = [];
+      for (var i = 0; i < res.length; i++) {
+        var _json = {};
+        _json["案例名称"] = res[i].title;
+        _json["评审1"] = res[i].firstPw;
+        _json["评审2"] = res[i].secondPw;
+        _json["平均分"] = res[i].sum;
+        array.push(_json);
+      }
+      var XLSX = require("xlsx");
+      const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
+      let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
+      // ws["!cols"] = [
+      //   //设置每一列的宽度
+      //   { wch: 50 },
+      //   { wch: 50 },
+      //   { wch: 50 },
+      // ];
+      XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
+      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`);//保存文件
+      this.$message({
+        message: "导出成功",
+        type: "success",
+      });
+    },
   },
   created() {
     // this.getAnliList();

+ 152 - 0
src/components/pages/munAdmin/score.vue

@@ -54,6 +54,24 @@
           ></el-input>
         </div>
       </div>
+      <!-- 导出所有评分数据 -->
+      <!-- <el-button
+        v-show="false"
+        type="primary"
+        size="small"
+        @click="exportAllScore"
+        style="margin-right: 10px"
+        >导出Excel</el-button
+      > -->
+      <!-- 导出个人评分数据 -->
+      <!-- <el-button
+        v-show="false"
+        type="primary"
+        size="small"
+        @click="exportScoreByUid"
+        style="margin-right: 10px"
+        >导出Excel</el-button
+      > -->
     </div>
     <div v-if="isNoTableData" class="isNoMessage">
       <img src="../../../assets/icon/isNoMessage.png" alt />
@@ -787,6 +805,140 @@ export default {
     lookDetail(aid) {
       window.open(window.origin + "/#/anliDetail?aid=" + aid);
     },
+    exportAllScore() {
+      this.ajax
+        .get(this.$store.state.api + "selectAllScore")
+        .then((res) => {
+          var scoreList = res.data[0];
+          // 将score值转换为对象
+          for (var i = 0; i < scoreList.length; i++) {
+            scoreList[i].score = JSON.parse(scoreList[i].score);
+          }
+          // 根据rid进行分组
+          var grouped = scoreList.reduce(function (acc, cur) {
+            if (!acc[cur.rid]) {
+              acc[cur.rid] = [];
+            }
+            acc[cur.rid].push(cur.score);
+            return acc;
+          }, {});
+
+          // 计算每组的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 };
+          });
+
+          for (var i = 0; i < b.length; i++) {
+            for (var j = 0; j < scoreList.length; j++) {
+              if (scoreList[j].rid == b[i].rid) {
+                if (!b[i].title) {
+                  b[i].title = JSON.parse(scoreList[j].info).title;
+                }
+              }
+            }
+          }
+          this.exportExcel(b);
+        })
+        .catch((err) => {
+          this.isLoading = false;
+          console.error(err);
+        });
+    },
+    exportScoreByUid() {
+      this.ajax
+        .get(this.$store.state.api + "selectAllScore")
+        .then((res) => {
+          var scoreList = res.data[0];
+          let params = {
+            uid: this.$store.state.userInfo.userid,
+          };
+          this.ajax
+            .get(this.$store.state.api + "selectScoreByUid", params)
+            .then((res) => {
+              var scoreListByuid = res.data[0];
+              for(var i = 0;i<scoreList.length;i++){
+                for(var j = 0;j<scoreListByuid.length;j++){
+                  if(scoreList[i].rid == scoreListByuid[j].rid){
+                    if(scoreList[i].scorer == scoreListByuid[j].scorer){
+                      var point = JSON.parse(scoreListByuid[j].score);
+                      var a = parseInt(point.first);
+                      var b = parseInt(point.second);
+                      var c = parseInt(point.third);
+                      var sumScore = Math.round((a + b + c) / 3);
+                      scoreListByuid[j].firstPw = sumScore;
+                    }else{
+                      var point = JSON.parse(scoreList[i].score);
+                      var a = parseInt(point.first);
+                      var b = parseInt(point.second);
+                      var c = parseInt(point.third);
+                      var sumScore = Math.round((a + b + c) / 3);
+                      scoreListByuid[j].secondPw = sumScore;
+                    }
+                  }
+                  if(scoreListByuid[j].firstPw && scoreListByuid[j].secondPw){
+                    scoreListByuid[j].sum = ((scoreListByuid[j].firstPw + scoreListByuid[j].secondPw) / 2).toFixed(2)
+                    scoreListByuid[j].title = JSON.parse(scoreListByuid[j].info).title;
+                  }
+                }
+              }
+              this.exportExcel(scoreListByuid);
+            })
+            .catch((err) => {
+              console.error(err);
+            });
+        })
+        .catch((err) => {
+          this.isLoading = false;
+          console.error(err);
+        });
+    },
+
+    exportExcel(t) {
+      var res = t;
+      //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
+      //将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
+      var array = [];
+      for (var i = 0; i < res.length; i++) {
+        var _json = {};
+        _json["案例名称"] = res[i].title;
+        _json["评审1"] = res[i].firstPw;
+        _json["评审2"] = res[i].secondPw;
+        _json["平均分"] = res[i].sum;
+        array.push(_json);
+      }
+      var XLSX = require("xlsx");
+      const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
+      let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
+      // ws["!cols"] = [
+      //   //设置每一列的宽度
+      //   { wch: 50 },
+      //   { wch: 50 },
+      //   { wch: 50 },
+      // ];
+      XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
+      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`);//保存文件
+      this.$message({
+        message: "导出成功",
+        type: "success",
+      });
+    },
   },
   created() {
     // this.getAnliList();

部分文件因为文件数量过多而无法显示