Bläddra i källkod

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

lsc 1 år sedan
förälder
incheckning
9d910f08cf

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 18691
package-lock.json


+ 2 - 1
package.json

@@ -51,7 +51,8 @@
     "vuex": "^3.6.2",
     "wangeditor": "^4.6.14",
     "wav-encoder": "^1.3.0",
-    "xlsx": "^0.16.9"
+    "xlsx": "^0.16.9",
+    "xlsx-js-style": "^1.2.0"
   },
   "devDependencies": {
     "autoprefixer": "^7.1.2",

+ 28 - 29
src/components/pages/kindStudentEva/test/score.vue

@@ -6,7 +6,6 @@
           v-model="year"
           placeholder="请选择学期"
           class="student_input"
-          @change="searchStudentScore"
         >
           <!-- <el-option label="所有学期" value=""></el-option> -->
           <el-option
@@ -180,10 +179,19 @@ export default {
       };
     }
   },
+  watch: {
+    year(newVal, oldVal){
+      this.saveSRJson2(oldVal)
+    }
+  },
   methods: {
     closePop() {
       this.dialogVisibleReport = false;
     },
+    switchTerm() {
+      // this.searchStudentScore();
+      console.log('变化了');
+    },
     searchStudentScore() {
       this.isLoading = true;
       this.scoreType = [];
@@ -283,7 +291,6 @@ export default {
     },
     updateStar(id, iid, i, j, v) {
       this.scoreJson[id][i][iid][j] = v;
-      this.saveSRJson();
       this.$forceUpdate();
     },
     lookSRecordByType(fid, tid) {
@@ -294,6 +301,22 @@ export default {
         this.$refs.dialogRef.getData();
       });
     },
+    saveSRJson2(val) {
+      let params = {
+        uid: this.userid,
+        j: JSON.stringify(this.scoreJson),
+        t: val
+      };
+      this.ajax
+        .get(this.$store.state.api + "addSRScore", params)
+        .then(res => {
+          // this.$message.success("保存成功!");
+          this.searchStudentScore();
+        })
+        .catch(err => {
+          console.error(err);
+        });
+    },
     saveSRJson() {
       let params = {
         uid: this.userid,
@@ -309,35 +332,11 @@ export default {
         .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: ""
-      //       // });
-      //     });
     }
   },
+  beforeDestroy() {
+    this.saveSRJson();
+  },
   mounted() {
     // this.$nextTick(()=>{
     //   console.log(this.$refs.dialogRef);

+ 42 - 7
src/components/pages/record/class.vue

@@ -27,6 +27,7 @@
                   placeholder="请输入班级名称"
                   v-model="sClassName"
                   clearable
+                  @change="getClassAverageScore"
                   class="student_input"
                 >
                 </el-input>
@@ -48,9 +49,9 @@
               </span>
               <el-button
                 type="primary"
-                @click="getClassAverageScore"
+                @click="resetting"
                 class="student_button"
-                >查询</el-button
+                >重置</el-button
               >
             </div>
             <el-button
@@ -613,8 +614,7 @@
 </template>
 
 <script>
-import TaskListHeader from "gantt-elastic/src/components/TaskList/TaskListHeader.vue";
-
+import XLSX from "xlsx-js-style";
 export default {
   data() {
     return {
@@ -723,11 +723,11 @@ export default {
         _json["学期前"] = res[i].avaScore[0];
         _json["学期中"] = res[i].avaScore[1];
         _json["学期末"] = res[i].avaScore[2];
-        _json["人数"] = res[i].num;
+        _json["人数"] = res[i].pnum;
         array.push(_json);
       }
 
-      var XLSX = require("xlsx");
+      // var XLSX = require("xlsx");
       const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
       let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
       ws["!cols"] = [
@@ -739,8 +739,33 @@ export default {
         { wch: 30 },
         { wch: 30 }
       ];
-      
+      const styleObj = { alignment: { horizontal: "center" } }; // 设置居中对齐和加粗样式
+
+      for (let cell in ws) {
+        if (!cell[0].startsWith("!")) {
+          ws[cell]["s"] = styleObj;
+        }
+      }
+      // 添加样式
+      // for (let i = 0; i < array.length + 1; i++) {
+      //   const cellStyle = { alignment: { horizontal: "center" } };
+
+      //   if (i === 0) {
+      //     // 第一行标题居中
+      //     cellStyle["font"] = { bold: true };
+      //   } else {
+      //     // 内容居中
+      //     cellStyle["alignment"] = { vertical: "middle", wrapText: true };
+      //   }
+
+      //   XLSX.utils.cell_set_style(
+      //     ws[XLSX.utils.encode_row(i)][0],
+      //     cellStyle
+      //   );
+      // }
+
       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
@@ -767,6 +792,7 @@ export default {
           // console.log("下载数据", res);
           this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
           this.allAvaScore = res.data[0];
+          console.log("res.data[0]", res.data[0]);
           // console.log("res.data[0]", res.data[0]);
           // 将分数添加到对应的班级
           this.allAvaScore.forEach(j => {
@@ -818,6 +844,15 @@ export default {
           console.error(err);
         });
     },
+    resetting() {
+      this.sClassName = "";
+      for (var i = 0; i < this.yearJuri.length; i++) {
+        if (this.yearJuri[i].defaultC == 1) {
+          this.year = this.yearJuri[i].id;
+        }
+      }
+      this.getClassAverageScore();
+    },
     getClassAverageScore() {
       this.isLoading = true;
       let params = {

+ 15 - 7
src/components/pages/studentEva.vue

@@ -25,6 +25,7 @@
           <el-input
             v-model="sName"
             class="student_input"
+            @change="searchStudent"
             placeholder="请输入用户名"
           ></el-input>
           <el-select
@@ -54,11 +55,8 @@
               :value="y.id"
             ></el-option>
           </el-select>
-          <el-button
-            type="primary"
-            class="student_button"
-            @click="searchStudent"
-            >查询</el-button
+          <el-button type="primary" class="student_button" @click="resetting"
+            >重置</el-button
           >
         </div>
         <div>
@@ -116,7 +114,7 @@
                         '&suid=' +
                         scope.row.userid +
                         '&role=' +
-                        role+
+                        role +
                         '&fathType=' +
                         fathType
                     )
@@ -192,7 +190,7 @@ export default {
             "&role=" +
             this.role
         );
-      }else{
+      } else {
         this.$router.push(
           "/class" +
             "?userid=" +
@@ -377,6 +375,15 @@ export default {
 
       return result;
     },
+    resetting() {
+      this.sName = "";
+      for (var i = 0; i < this.yearJuri.length; i++) {
+        if (this.yearJuri[i].defaultC == 1) {
+          this.year = this.yearJuri[i].id;
+        }
+      }
+      this.searchStudent()
+    },
     searchStudent() {
       this.isLoading = true;
       let params = {
@@ -582,6 +589,7 @@ export default {
 
 .student_page {
   margin-top: 10px;
+  float: right;
 }
 
 .el-table >>> .even_row {

Vissa filer visades inte eftersom för många filer har ändrats