|
@@ -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);
|
|
|
}
|