Browse Source

修改学生上传

11wqe1 9 hours ago
parent
commit
c2ce47a902
1 changed files with 36 additions and 15 deletions
  1. 36 15
      src/components/pages/studentManageNew/component/addstu.vue

+ 36 - 15
src/components/pages/studentManageNew/component/addstu.vue

@@ -211,11 +211,11 @@
         :show-close="false"
       >
         <div class="msgCon">
-            <img v-if="deltypy == 0" style="width: 20px;" src="../../../../assets/stuImg/duil.svg" alt="">
+            <img v-if="deltypy == 0 || deltypy == 2" style="width: 20px;" src="../../../../assets/stuImg/duil.svg" alt="">
             <img v-if="deltypy == 1" style="width: 20px;" src="../../../../assets/stuImg/tishi.svg" alt="">
 
             <div class="msgContxt">
-              <div v-if="deltypy == 0">
+              <div v-if="deltypy == 0 || deltypy == 2">
                 {{ (impbox.length ? impbox[0].name : '') + lang.ssAddStuSucc.replace(/\*/g, impbox.length) }}
               </div>
               <div v-if="deltypy == 1">{{ lang.ssConfirmUpload }}?</div>
@@ -420,6 +420,10 @@ export default {
 
     // 上传Excel添加学生
     handleChange(file) {
+      if (this.uploadfileLoading) {
+        this.$message.warning(this.lang.ssUploading);
+        return;
+      }
       if (this.userSuffix == "") {
         this.$message.error(this.lang.ssGetSuffixReUp);
         this.getUser();
@@ -525,7 +529,7 @@ export default {
             return;
           }
 
-          
+          // 打开确认上传弹窗
           _this.deltypy = 1;
           _this.popBoxdia= true;
           _this.stuexcel = arr;
@@ -621,10 +625,10 @@ export default {
           class: classInfo.id,
         };
       });
-
-      this.accUpdate(box);
+      // 手动输入添加学生,打开弹框
+      this.accUpdate(box,0);
     },
-    async accUpdate(box) {
+    async accUpdate(box,index) {
       console.log(box, "box");
       this.uploadfileLoading = true;
       this.impbox = box;
@@ -672,8 +676,8 @@ export default {
           message: this.lang.ssAddOk,
           type: "success",
         });
-
-        this.deltypy = 0;
+        // excel与手动上传,上传完毕,打开弹框
+        this.deltypy = index;
         this.popBoxdia= true;
         // this.addStuVisible = false;
         console.log('this.selectedStuData',this.selectedStuData);
@@ -681,6 +685,12 @@ export default {
         // this.selectedStuData = [];
         this.$emit("getCascaderData");
         this.addOp3('1', "", { type: "student_add" }, "success")
+      } catch (err) {
+        console.error(err);
+        // 业务错误已在 uploadBatch / uploadBatchAccount 中提示
+        if (!err || !err.business) {
+          this.$message.error(this.lang.Additionfailed);
+        }
       } finally {
         this.uploadfileLoading = false;
       }
@@ -717,8 +727,10 @@ export default {
             }
             if (z == 2) {
               console.log("添加成功");
+              resolve(res);
+            } else {
+              reject({ business: true, res });
             }
-            resolve(res);
           })
           .catch((err) => {
             console.error(err);
@@ -758,8 +770,10 @@ export default {
             }
             if (z == 2) {
               console.log("添加成功");
+              resolve(res);
+            } else {
+              reject({ business: true, res });
             }
-            resolve(res);
           })
           .catch((err) => {
             console.error(err);
@@ -770,20 +784,27 @@ export default {
     },
     confirmDelStu(){
           // this.addStuVisible = false;
-          if (this.deltypy == 0) {
+          if (this.deltypy == 0 || this.deltypy == 2) {    //上传完毕,关闭弹窗
             this.impbox = []
             this.selectedStuData = [];
             // 关闭弹窗
-            this.addStuVisible = false;
-          }else if (this.deltypy == 1) {
-            this.uploadfileLoading = true;
-            this.accUpdate(this.stuexcel);
+            if(this.deltypy == 2){    //excel上传,关闭弹窗
+              this.stuexcel = [];
+              this.addStuVisible = false;
+            }
+          }else if (this.deltypy == 1) {     //excel上传,提示是否继续上传
+            if (this.uploadfileLoading) {
+              this.$message.warning(this.lang.ssUploading);
+              return;
+            }
+            this.accUpdate(this.stuexcel,2);
           }
           this.popBoxdia= false;
     },
     closePop(){
       this.popBoxdia= false;
       if (this.deltypy == 1) {
+        // excel上传,清空数据
         this.stuexcel = []
       }
     },