Procházet zdrojové kódy

修改下载数据

yuanyiming před 1 rokem
rodič
revize
bc0e45d570

+ 21 - 18
src/components/pages/kindStudentEva/info/index.vue

@@ -26,24 +26,28 @@
         <!-- <span>{{ info.username }}</span> -->
       </div>
       <div
-        style="position: absolute;top: 50%;left: 0;"
+        style="position: absolute;top: 35%;left: 0;"
         @click="upStu"
         v-if="num"
       >
-        <i
-          class="el-icon-arrow-left"
-          style="font-size: 25px;cursor: pointer;"
-        ></i>
+        <el-tooltip content="上一个" placement="top" effect="dark">
+          <i
+            class="el-icon-arrow-left"
+            style="font-size: 25px;cursor: pointer;"
+          ></i>
+        </el-tooltip>
       </div>
       <div
-        style="position: absolute;top: 50%;right: 0;"
+        style="position: absolute;top: 35%;right: 0;"
         @click="nextStu"
         v-if="num != stuList.length - 1"
       >
-        <i
-          class="el-icon-arrow-right"
-          style="font-size: 25px;cursor: pointer;"
-        ></i>
+        <el-tooltip content="下一个" placement="top" effect="dark">
+          <i
+            class="el-icon-arrow-right"
+            style="font-size: 25px;cursor: pointer;"
+          ></i>
+        </el-tooltip>
       </div>
     </div>
     <div class="i_bottom">
@@ -175,7 +179,6 @@ export default {
     handleCommand(e) {
       // this.$message("click on item " + command);
       this.$emit("updateUid", e);
-
     },
 
     // 下拉框切换学生
@@ -312,23 +315,23 @@ export default {
   height: 180px;
   overflow: auto;
 }
-.el-icon--right{
+.el-icon--right {
   font-size: 20px;
 }
 .el-dropdown-menu::-webkit-scrollbar {
   width: 6px;
 }
 .el-dropdown-menu::-webkit-scrollbar-thumb {
-    border-radius: 8px;
-    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
-    background: #B9B9B9;
+  border-radius: 8px;
+  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
+  background: #b9b9b9;
 }
 .el-dropdown-menu::-webkit-scrollbar-track {
-    border-radius: 8px;
-    background: #E4E4E4;
+  border-radius: 8px;
+  background: #e4e4e4;
 }
 .el-dropdown-menu::-webkit-scrollbar-button {
-    display: none;
+  display: none;
 }
 /* .i_top > .name >>> .el-dropdown-menu__item {
   text-align: center;

+ 5 - 5
src/components/pages/kindStudentEva/test/index.vue

@@ -28,7 +28,7 @@
         </div>
       </div>
       <div style="display: flex;">
-        <div class="backClassCss" @click="saveScore" v-if="type == 2">保存评分</div>
+        <!-- <div class="backClassCss" @click="saveScore" v-if="type == 2">保存评分</div> -->
         <div class="backClassCss" @click="backClaBtn">返回</div>
       </div>
     </div>
@@ -49,7 +49,7 @@
         :org="org"
         :cid="cid"
       ></Score>
-      <Report v-if="type == 3" :oid="oid" :userid="userid" :org="org"></Report>
+      <Report v-if="type == 3" :oid="oid" :userid="userid" :org="org" :cid="cid"></Report>
     </div>
   </div>
 </template>
@@ -85,9 +85,9 @@ export default {
     };
   },
   methods: {
-    saveScore(){
-      this.$refs.score.saveSRJson();
-    },
+    // saveScore(){
+    //   this.$refs.score.saveSRJson();
+    // },
     checkType(type) {
       this.type = type;
     },

+ 95 - 41
src/components/pages/kindStudentEva/test/report.vue

@@ -114,6 +114,9 @@ export default {
     },
     org: {
       type: String
+    },
+    cid: {
+      type: String
     }
   },
   data() {
@@ -121,6 +124,11 @@ export default {
       year: "",
       // 学期数组
       termList: [],
+
+      info: {},
+      classJuri: [],
+      termName: "",
+      className: "",
       // dialogVisible: false,
       // 平均分柱状图数据
       croColumnarData: [],
@@ -450,55 +458,62 @@ export default {
 
     // 下载pdf弹框
     savePop() {
-      this.$confirm("是否下载?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消"
-      })
-        .then(() => {
-          // 下载pdf
-          this.isPdf = true;
-          this.fullscreenLoading = true;
-          setTimeout(() => {
-            this.savePdf();
-          }, 1000);
-        })
-        .catch(() => {
-          this.$message({
-            type: "info",
-            message: "已取消"
-          });
-        });
+      this.isPdf = true;
+      this.fullscreenLoading = true;
+      setTimeout(() => {
+        this.savePdf();
+      }, 1000);
+      // this.$confirm("是否下载?", "提示", {
+      //   confirmButtonText: "确定",
+      //   cancelButtonText: "取消"
+      // })
+      //   .then(() => {
+      //     // 下载pdf
+      //     this.isPdf = true;
+      //     this.fullscreenLoading = true;
+      //     setTimeout(() => {
+      //       this.savePdf();
+      //     }, 1000);
+      //   })
+      //   .catch(() => {
+      //     this.$message({
+      //       type: "info",
+      //       message: "已取消"
+      //     });
+      //   });
     },
 
     // 下载pdf
     savePdf() {
+      this.termList.forEach(i => {
+        if (i.id == this.year) {
+          this.termName = i.name;
+        }
+      });
       let _this = this;
+      const scale = 2;
       html2Canvas(this.$refs.reportPdf, {
         //导出的html元素
-        allowTaint: true
+        allowTaint: true,
+        scale
       }).then(function(canvas) {
-        let contentWidth = canvas.width;
-        let contentHeight = canvas.height;
-        let pageHeight = (contentWidth / 592.28) * 841.89;
-        let leftHeight = contentHeight;
-        let position = 0;
-        let imgWidth = 595.28;
-        let imgHeight = (592.28 / contentWidth) * contentHeight;
+        let contentWidth = canvas.width / scale;
+        let contentHeight = canvas.height / scale;
+
+        let PDF = new JsPDF("", "pt", [contentWidth, contentHeight]);
         let pageData = canvas.toDataURL("image/jpeg", 1.0);
-        let PDF = new JsPDF("", "pt", "a4");
-        if (leftHeight < pageHeight) {
-          PDF.addImage(pageData, "JPEG", 0, 0, imgWidth, imgHeight);
-        } else {
-          while (leftHeight > 0) {
-            PDF.addImage(pageData, "JPEG", 0, position, imgWidth, imgHeight);
-            leftHeight -= pageHeight;
-            position -= 841.89;
-            if (leftHeight > 0) {
-              PDF.addPage();
-            }
-          }
-        }
-        PDF.save("学情报告" + ".pdf");
+
+        PDF.addImage(pageData, "JPEG", 0, 0, contentWidth, contentHeight);
+
+        PDF.save(
+          _this.info.username +
+            "-" +
+            _this.className +
+            "-" +
+            _this.termName +
+            "学情报告" +
+            ".pdf"
+        );
 
         _this.$message.success("保存成功!");
 
@@ -507,12 +522,51 @@ export default {
           _this.fullscreenLoading = false;
         }, 500);
       });
+    },
+    //获取班级列表
+    getClass() {
+      let params = {
+        oid: this.oid
+      };
+      this.ajax
+        .get(this.$store.state.api + "selectClassBySchool", params)
+        .then(res => {
+          this.classJuri = res.data[0];
+          // console.log(this.classJuri);
+          this.classJuri.forEach(i => {
+            if (i.id == this.cid) {
+              this.className = i.name;
+            }
+          });
+        })
+        .catch(err => {
+          console.error(err);
+        });
+    },
+    // 获取学生详情
+    getStudentDetail() {
+      const data2 = {
+        uid: this.userid
+      };
+      // console.log("获取班学生列表", data2);
+      this.ajax
+        .get(this.$store.state.api + "selectStudentDetail", data2)
+        .then(res => {
+          // console.log('学生详情',res.data[0][0]);
+          this.info = res.data[0][0];
+
+          // this.classid = res.data[0][0].classid;
+          // this.getClassStudent();
+
+          console.log("this.info", this.info);
+        });
     }
   },
   mounted() {},
   created() {
     this.fullscreenLoading = true;
-
+    this.getStudentDetail();
+    this.getClass();
     this.getYear();
     // console.log('数据',this.$route.query);
   }

+ 40 - 25
src/components/pages/kindStudentEva/test/score.vue

@@ -283,6 +283,7 @@ export default {
     },
     updateStar(id, iid, i, j, v) {
       this.scoreJson[id][i][iid][j] = v;
+      this.saveSRJson();
       this.$forceUpdate();
     },
     lookSRecordByType(fid, tid) {
@@ -294,33 +295,47 @@ export default {
       });
     },
     saveSRJson() {
-      this.$confirm("是否保存?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消"
-      })
-        .then(() => {
-          console.log("保存了");
-          let params = {
-            uid: this.userid,
-            j: JSON.stringify(this.scoreJson),
-            t: this.year
-          };
-          this.ajax
-            .get(this.$store.state.api + "addSRScore", params)
-            .then(res => {
-              this.$message.success("保存成功!");
-              this.searchStudentScore();
-            })
-            .catch(err => {
-              console.error(err);
-            });
+      let params = {
+        uid: this.userid,
+        j: JSON.stringify(this.scoreJson),
+        t: this.year
+      };
+      this.ajax
+        .get(this.$store.state.api + "addSRScore", params)
+        .then(res => {
+          // this.$message.success("保存成功!");
+          this.searchStudentScore();
         })
-        .catch(() => {
-          // this.$message({
-          //   type: "info",
-          //   message: ""
-          // });
+        .catch(err => {
+          console.error(err);
         });
+      //   this.$confirm("是否保存?", "提示", {
+      //     confirmButtonText: "确定",
+      //     cancelButtonText: "取消"
+      //   })
+      //     .then(() => {
+      //       console.log("保存了");
+      //       let params = {
+      //         uid: this.userid,
+      //         j: JSON.stringify(this.scoreJson),
+      //         t: this.year
+      //       };
+      //       this.ajax
+      //         .get(this.$store.state.api + "addSRScore", params)
+      //         .then(res => {
+      //           this.$message.success("保存成功!");
+      //           this.searchStudentScore();
+      //         })
+      //         .catch(err => {
+      //           console.error(err);
+      //         });
+      //     })
+      //     .catch(() => {
+      //       // this.$message({
+      //       //   type: "info",
+      //       //   message: ""
+      //       // });
+      //     });
     }
   },
   mounted() {

+ 2 - 2
src/components/pages/studentEva.vue

@@ -303,7 +303,7 @@ export default {
         { wch: 30 }
       ];
       XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
-      XLSX.writeFile(workbook, className + termName + "观察记录.xlsx");
+      XLSX.writeFile(workbook, className+'-'+ termName + "观察记录.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`);//保存文件
@@ -450,7 +450,7 @@ export default {
              
               // let aaa = this.combineArrays(allScore);
 
-              console.log("tableData", tableData[i]);
+              // console.log("tableData", tableData[i]);
 
               // console.log("allfType", allfType);