Browse Source

添加学生

11wqe1 3 days ago
parent
commit
7bdd701eff

+ 86 - 51
src/components/pages/studentManageNew/component/addstu.vue

@@ -193,7 +193,7 @@
           <div @click="closeAllClaAddStu" class="kbtn">{{ lang.Cancel }}</div>
 
           <div @click="addStu" class="kbtn" style="background: #3681FC; color: #E6FFFFFF;">{{ lang.Confirm }}</div>
-          
+
           <!-- <el-button size="small" type="primary" @click="addStu"
             >确认</el-button
           > -->
@@ -479,10 +479,10 @@ export default {
             }
           });
           console.log(arr);
-          if (arr.length > 70) {
-            _this.$message.error(_this.lang.Limitmore);
-            return;
-          }
+          // if (arr.length > 70) {
+          //   _this.$message.error(_this.lang.Limitmore);
+          //   return;
+          // }
 
           if (this.boxType == 2 && arr.filter(e => e.class) != arr.length) {
             _this.$message.error(_this.lang.ssCheckClassCol);
@@ -560,56 +560,91 @@ export default {
 
       this.accUpdate(box);
     },
-    accUpdate(box) {
+    async accUpdate(box) {
       console.log(box, "box");
+      this.uploadfileLoading = true;
       this.impbox = box;
-      let z = 2;
-      let newArr = JSON.stringify(box);
-      let params = [
-        {
-          arr: newArr,
-          userpassword: "Coco1234",
-          oid: this.oid,
-        },
-      ];
+      const batchSize = 3;
+      if (box.length > batchSize) {
+        // 计算总批次数
+        const totalBatches = Math.ceil(box.length / batchSize);
+        for (let i = 0; i < totalBatches; i++) {
+          const batch = box.slice(i * batchSize, (i + 1) * batchSize);
+          await this.uploadBatch(batch); // 假设 uploadBatch 返回 Promise
+          console.log(`第 ${i + 1} 批上传完成`, batch);
+        }
+      } else {
+        // 长度不超过 10,直接上传整个数组
+        await this.uploadBatch(box);
+      }
+      this.$message({
+            message: this.lang.ssAddOk,
+            type: "success",
+          });
+          this.uploadfileLoading = false;
+
+          this.deltypy = 0;
+          this.popBoxdia= true;
+          // this.addStuVisible = false;
+          console.log('this.selectedStuData',this.selectedStuData);
+          
+          // this.selectedStuData = [];
+          this.$emit("getCascaderData");
+          this.addOp3('1', "", { type: "student_add" }, "success")
+    },
+    async uploadBatch(box){
+      return new Promise((resolve, reject) => {
+        // this.impbox = box;
+        let z = 2;
+        let newArr = JSON.stringify(box);
+        let params = [
+          {
+            arr: newArr,
+            userpassword: "Coco1234",
+            oid: this.oid,
+          },
+        ];
       console.log(params, "batchRegistrationMoreCopy");
       // batchRegistrationMoreCopy
-      this.ajax
-        .post(this.$store.state.api + "batchRegistrationMoreCopy", params)
-        .then((res) => {
-          console.log(res, "res");
-          if (res.data.type == 1) {
-            this.$message.error(this.lang.stunumberregistered);
-            z = 1;
-          }
-          if (res.data.type == 2) {
-            this.$message.error(this.lang.stuaccregistered);
-            z = 1;
-          }
-          if (res.data.type == 3) {
-            this.$message.error(this.lang.studuplicateIDs);
-            z = 1;
-          }
-          if (z == 2) {
-            console.log("添加成功");
-            this.$message({
-              message: this.lang.ssAddOk,
-              type: "success",
-            });
-            this.deltypy = 0;
-            this.popBoxdia= true;
-            // this.addStuVisible = false;
-            console.log('this.selectedStuData',this.selectedStuData);
-            
-            // this.selectedStuData = [];
-            this.$emit("getCascaderData");
-            this.addOp3('1', "", { type: "student_add" }, "success")
-          }
-          this.uploadfileLoading = false;
-        })
-        .catch((err) => {
-          console.error(err);
-          this.addOp3('1', "", { type: "student_add" }, err)
+        this.ajax
+          .post(this.$store.state.api + "batchRegistrationMoreCopy", params)
+          .then((res) => {
+            console.log(res, "res");
+            if (res.data.type == 1) {
+              this.$message.error(this.lang.stunumberregistered);
+              z = 1;
+            }
+            if (res.data.type == 2) {
+              this.$message.error(this.lang.stuaccregistered);
+              z = 1;
+            }
+            if (res.data.type == 3) {
+              this.$message.error(this.lang.studuplicateIDs);
+              z = 1;
+            }
+            if (z == 2) {
+              console.log("添加成功");
+              // this.$message({
+              //   message: this.lang.ssAddOk,
+              //   type: "success",
+              // });
+              // this.deltypy = 0;
+              // this.popBoxdia= true;
+              // // this.addStuVisible = false;
+              // console.log('this.selectedStuData',this.selectedStuData);
+              
+              // // this.selectedStuData = [];
+              // this.$emit("getCascaderData");
+              // this.addOp3('1', "", { type: "student_add" }, "success")
+            }
+            resolve(res);
+            // this.uploadfileLoading = false;
+          })
+          .catch((err) => {
+            console.error(err);
+            this.addOp3('1', "", { type: "student_add" }, err)
+            reject(err);
+          });
         });
     },
     confirmDelStu(){

+ 1 - 1
src/components/pages/studentManageNew/index.vue

@@ -25,7 +25,7 @@
         >
           <el-submenu v-for="item in tableData" :index="item.id" :key="item.id">
             <template slot="title">
-              <span>{{ item.name }}</span>
+              <div class="tabcla_box">{{ item.name }}</div>
               <img
                 class="grade-submenu-arrow"
                 src="../../../assets/stuImg/zankai.svg"

+ 1 - 1
src/lang/cn.json

@@ -1989,7 +1989,7 @@
   "ssEntered":"已输入:",
   "ssStuNameDup":"您添加的学生“*”存在重复姓名。 是否继续添加?",
   "ssUploadClickDrag":"点击或拖拽文件到此处上传",
-  "ssUploadTip":"支持格式:xlsx、xls,最多添加70人",
+  "ssUploadTip":"支持格式:.xlsx,.xls,大小不超过10MB",
   "ssUploadTempLbl":"上传模板:",
   "ssDownloadTemp":"下载模板",
   "ssUploadNote":"注意:请按照模板格式填写学生信息,避免导入失败",

+ 1 - 1
src/lang/en.json

@@ -1988,7 +1988,7 @@
   "ssEntered":"Entered:",
   "ssStuNameDup":"The student you added \"*\" has duplicate names. Continue?",
   "ssUploadClickDrag":"Click or drag file here to upload",
-  "ssUploadTip":"Supported: xlsx, xls; up to 70 students",
+  "ssUploadTip":"Supported: xlsx, xls , up to 10MB",
   "ssUploadTempLbl":"Upload template:",
   "ssDownloadTemp":"Download template",
   "ssUploadNote":"Note: Please fill in student information according to the template format to avoid import failure",

+ 1 - 1
src/lang/hk.json

@@ -1988,7 +1988,7 @@
   "ssEntered":"已輸入:",
   "ssStuNameDup":"您添加的學生“*”存在重複姓名。 是否繼續添加?",
   "ssUploadClickDrag":"點擊或拖拽文件到此處上傳",
-  "ssUploadTip":"支持格式:xlsx、xls,最多添加70人",
+  "ssUploadTip":"支持格式:.xlsx,.xls,大小不超過10MB",
   "ssUploadTempLbl":"上傳模板:",
   "ssDownloadTemp":"下載模板",
   "ssUploadNote":"注意:請按照模板格式填寫學生信息,避免導入失敗",