Просмотр исходного кода

Merge branch 'beta' of https://git.cocorobo.cn/CocoRoboLabs/pbl-teacher-table into beta

lsc 1 год назад
Родитель
Сommit
b8c72305c4
1 измененных файлов с 91 добавлено и 77 удалено
  1. 91 77
      src/components/pages/kindStudentEva/test/diary.vue

+ 91 - 77
src/components/pages/kindStudentEva/test/diary.vue

@@ -84,7 +84,7 @@
         header-align="center"
         :header-cell-style="{
           background: '#E0EAFB',
-          color: 'rgba(0, 0, 0, 0.90)',
+          color: 'rgba(0, 0, 0, 0.90)'
         }"
         @selection-change="handleSelectionChange"
       >
@@ -178,7 +178,7 @@
     <!-- v-if="isPop" -->
 
     <el-dialog
-      :title="judgeNum==1 ? '修改' :judgeNum==2?'添加': '查看'"
+      :title="judgeNum == 1 ? '修改' : judgeNum == 2 ? '添加' : '查看'"
       :visible.sync="isPop"
       :append-to-body="true"
       width="700px"
@@ -221,21 +221,21 @@
 import popbox from "./component/popbox";
 export default {
   components: {
-    popbox,
+    popbox
   },
   props: {
     userid: {
-      type: String,
+      type: String
     },
     oid: {
-      type: String,
+      type: String
     },
     org: {
-      type: String,
+      type: String
     },
     cid: {
-      type: String,
-    },
+      type: String
+    }
   },
   data() {
     return {
@@ -247,9 +247,9 @@ export default {
       classid: "",
 
       // 当前时间
-      visitTime:'',
+      visitTime: "",
       // 学生详情信息
-      info:{},
+      info: {},
       // 默认选择项
       // VeidooValue:{},
       // 默认选择项
@@ -272,7 +272,7 @@ export default {
       // 组件信息数据
       isPop: false,
       // 添加记录弹窗
-      AddIsPop:false,
+      AddIsPop: false,
       // 查看,修改弹窗数据
       recordData: {},
       // recordDataCopy: {},
@@ -284,7 +284,7 @@ export default {
       judgeNum: 0,
 
       ftypeId: "",
-      stypeId: "",
+      stypeId: ""
     };
   },
   // watch: {
@@ -312,7 +312,7 @@ export default {
     },
     closePop() {
       this.isPop = false;
-      this.AddIsPop=false;
+      this.AddIsPop = false;
     },
 
     // 切换页
@@ -326,11 +326,11 @@ export default {
     getVeidooType() {
       let params = {
         org: this.org,
-        oid: this.oid,
+        oid: this.oid
       };
       this.ajax
         .get(this.$store.state.api + "selectSTEType", params)
-        .then((res) => {
+        .then(res => {
           var ftype = res.data[0]; //公共父级分类
           var stype = res.data[1]; //公共子级分类
           var sctype = res.data[2]; //该学校子级分类
@@ -385,7 +385,7 @@ export default {
 
           // console.log("小分类", this.VeidooJson, "大分类", this.VeidooList);
         })
-        .catch((err) => {
+        .catch(err => {
           this.isLoading = false;
           console.error(err);
         });
@@ -400,18 +400,18 @@ export default {
         cu: this.ftypeId,
         cn: this.stypeId,
         cm: this.termId,
-        page: this.page,
+        page: this.page
       };
       // console.log(params);
       this.ajax
         .get(this.$store.state.api + "selectVeidooType", params)
-        .then((res) => {
+        .then(res => {
           this.isLoading = false;
           this.tableData = res.data[0];
           this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
           // console.log(" 获取筛选数据", res.data[0]);
         })
-        .catch((err) => {
+        .catch(err => {
           this.isLoading = false;
           console.error(err);
         });
@@ -438,45 +438,45 @@ export default {
     //     });
     // },
     // 添加新纪录
-    addRecord(){
-      this.getPresentDate()
-      this.judgeNum=2
-      this.recordData={
-        classId:this.info.classid,
-        className:this.info.cname,
-        contact:[],
-        place:'',
-        recordContent:'',
-        recordDate:this.visitTime,
-        recordImg:[],
-        recordTit:'',
-        semName:'',
-        studentName:this.info.username,
-        term:this.termValue,
-        tname:'',
-        type:''
-      }
+    addRecord() {
+      this.getPresentDate();
+      this.judgeNum = 2;
+      this.recordData = {
+        classId: this.info.classid,
+        className: this.info.cname,
+        contact: [],
+        place: "",
+        recordContent: "",
+        recordDate: this.visitTime,
+        recordImg: [],
+        recordTit: "",
+        semName: "",
+        studentName: this.info.username,
+        term: this.termValue,
+        tname: "",
+        type: ""
+      };
 
       // this.AddIsPop = true;
       this.isPop = true;
     },
     // 获取当前时间
     getPresentDate() {
-      const currentTime = new Date()
-      const year = currentTime.getFullYear()
-      let month = currentTime.getMonth() + 1 // 月份从0开始,因此需要加1
-      month = (month < 10 ? '0' : '') + month
-      let day = currentTime.getDate()
-      day = (day < 10 ? '0' : '') + day
+      const currentTime = new Date();
+      const year = currentTime.getFullYear();
+      let month = currentTime.getMonth() + 1; // 月份从0开始,因此需要加1
+      month = (month < 10 ? "0" : "") + month;
+      let day = currentTime.getDate();
+      day = (day < 10 ? "0" : "") + day;
 
-      let hours = currentTime.getHours()
-      hours = (hours < 10 ? '0' : '') + hours
+      let hours = currentTime.getHours();
+      hours = (hours < 10 ? "0" : "") + hours;
 
-      let minutes = currentTime.getMinutes()
-      minutes = (minutes < 10 ? '0' : '') + minutes
+      let minutes = currentTime.getMinutes();
+      minutes = (minutes < 10 ? "0" : "") + minutes;
 
-      console.log(year, month, day, hours, minutes)
-      this.visitTime = `${year}-${month}-${day} ${hours}:${minutes}`
+      console.log(year, month, day, hours, minutes);
+      this.visitTime = `${year}-${month}-${day} ${hours}:${minutes}`;
       // console.log(this.visitTime)
     },
     // 修改与查看记录
@@ -514,28 +514,26 @@ export default {
       // 获取纬度筛选框
       const data = {
         oid: this.org,
-        cla: 0,
+        cla: 0
       };
 
-      this.ajax
-        .get(this.$store.state.api + "selectVeiDoo", data)
-        .then((res) => {
-          // console.log(res);
-          this.weiList = res.data[0];
-          // console.log("this.weiList", res);
-        });
+      this.ajax.get(this.$store.state.api + "selectVeiDoo", data).then(res => {
+        // console.log(res);
+        this.weiList = res.data[0];
+        // console.log("this.weiList", res);
+      });
     },
     // 获取学生详情,主要获取他的班级id,然后查询他的关联列表同学
     getStudentDetail() {
       const data2 = {
-        uid: this.userid,
+        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.info = res.data[0][0];
           this.classid = res.data[0][0].classid;
           this.getClassStudent();
 
@@ -546,12 +544,12 @@ export default {
     getClassStudent() {
       const data2 = {
         cid: this.classid,
-        uid: this.userid,
+        uid: this.userid
       };
       // console.log("获取班学生列表", data2);
       this.ajax
         .get(this.$store.state.api + "selectManyClassStudent", data2)
-        .then((res) => {
+        .then(res => {
           // console.log(res);
           this.studentList = res.data[0];
           // console.log("this.studentList", res);
@@ -561,7 +559,7 @@ export default {
       this.isLoading = true;
       this.ajax
         .get(this.$store.state.api + "selectTerm")
-        .then((res) => {
+        .then(res => {
           this.isLoading = false;
           var yearJuri = res.data[0];
           for (var i = 0; i < yearJuri.length; i++) {
@@ -571,13 +569,13 @@ export default {
           }
           this.termList = yearJuri;
           this.termList.forEach(i => {
-            if (i.defaultC===1) {
-              this.termValue=i.id
+            if (i.defaultC === 1) {
+              this.termValue = i.id;
             }
           });
           // console.log('termList',this.termList);
         })
-        .catch((err) => {
+        .catch(err => {
           this.isLoading = false;
           console.error(err);
         });
@@ -587,8 +585,14 @@ export default {
       // return console.log('导出数据',this.multipleSelection);
 
       if (this.multipleSelection.length) {
-        this.exportExcel();
-
+        this.$confirm("是否导出Excel?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消"
+        })
+          .then(() => {
+            this.exportExcel();
+          })
+          .catch(() => {});
       } else {
         this.$message({ message: "请先选择要导出的数据", type: "warning" });
         return;
@@ -598,6 +602,13 @@ export default {
     exportExcel() {
       // var res = res.data[0];
       var res = this.multipleSelection;
+      console.log("this.termList", this.termList);
+      let termName = "";
+      this.termList.forEach(e => {
+        if (e.id == this.termId) {
+          termName = e.name;
+        }
+      });
 
       // console.log('导出数据',res);
       //如果value的json字段的key值和想要的headers值不一致时,可做如下更改
@@ -605,7 +616,7 @@ export default {
       var array = [];
       for (var i = 0; i < res.length; i++) {
         var _json = {};
-        _json["姓名"] = res[i].studentName
+        _json["姓名"] = res[i].studentName;
         _json["班级"] = res[i].className;
         _json["记录时间"] = res[i].recordDate;
         _json["学期"] = res[i].semName;
@@ -634,17 +645,20 @@ export default {
         { wch: 30 },
         { wch: 30 }
       ];
+      if (!termName) {
+        termName = "所有学期";
+      }
       XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
-      XLSX.writeFile(workbook, "观察日记.xlsx");
+      XLSX.writeFile(workbook, this.info.name + 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`);//保存文件
       this.$message({
         message: "导出成功",
-        type: "success",
+        type: "success"
       });
     },
-    updatePanelB(e){
+    updatePanelB(e) {
       // console.log('出嘎',e);
       this.$emit("updatePanelA", e);
     },
@@ -652,12 +666,12 @@ export default {
     delRecord(e) {
       this.$confirm("是否删除?", "提示", {
         confirmButtonText: "确定",
-        cancelButtonText: "取消",
+        cancelButtonText: "取消"
       })
         .then(() => {
           this.ajax
             .post(this.$store.state.api + "updateRecord", [{ rid: e.rid }])
-            .then((res) => {
+            .then(res => {
               // console.log(res);
               // this.selectData();
               this.getData();
@@ -665,7 +679,7 @@ export default {
 
               this.$message({
                 type: "success",
-                message: "已删除",
+                message: "已删除"
               });
               // this.isLoading = false; updateRecord
             });
@@ -673,11 +687,11 @@ export default {
         .catch(() => {
           this.$message({
             type: "info",
-            message: "已取消删除",
+            message: "已取消删除"
           });
         });
       // return console.log(e);
-    },
+    }
   },
   created() {
     this.getWeiList();
@@ -692,7 +706,7 @@ export default {
     // this.$nextTick(() => {
     //   this.selectData();
     // });
-  },
+  }
 };
 </script>