11wqe1 před 17 hodinami
rodič
revize
f5cd14abb6

+ 92 - 27
src/components/pages/studentManageNew/component/addstu.vue

@@ -169,7 +169,7 @@
                 >{{ lang.ssDownloadTemp }}</span
                 >{{ lang.ssDownloadTemp }}</span
               >
               >
             </div>
             </div>
-            <div v-if="boxType == 0" style="margin-top: 10px">
+            <div v-if="boxType == 0" style="margin-top: 10px;font-weight: 600;">
               {{ lang.ssUploadNote }}
               {{ lang.ssUploadNote }}
             </div>
             </div>
             <div v-else style="margin-top: 10px">
             <div v-else style="margin-top: 10px">
@@ -401,10 +401,10 @@ export default {
           export_json_to_excel,
           export_json_to_excel,
         } = require("../../../../common/Export2Excel");
         } = require("../../../../common/Export2Excel");
         // 增加 colWidths 参数以调整列宽,例如调整为 [20, 35, 20]
         // 增加 colWidths 参数以调整列宽,例如调整为 [20, 35, 20]
-        let tHeader = [this.lang.StudentName];
+        let tHeader = [this.lang.StudentName,'账户'];
             
             
         if (this.boxType == 2) {
         if (this.boxType == 2) {
-           tHeader = [this.lang.StudentName,this.lang.Class];
+           tHeader = [this.lang.StudentName,this.lang.Class,'账户'];
         }
         }
         const data = [];
         const data = [];
         const colWidths = [35]; // 设置每一列的宽度
         const colWidths = [35]; // 设置每一列的宽度
@@ -455,7 +455,7 @@ export default {
           }
           }
           outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]); //outdata就是你想要的东西
           outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]); //outdata就是你想要的东西
           let da = [...outdata];
           let da = [...outdata];
-          // console.log(da, "da");
+          console.log(da, "da");
           let arr = [];
           let arr = [];
           da.map((v) => {
           da.map((v) => {
             let obj = {};
             let obj = {};
@@ -471,9 +471,20 @@ export default {
                 _this.org &&
                 _this.org &&
                 _this.schoolChar
                 _this.schoolChar
               ) {
               ) {
+                if (Number(v['账户'])) {
+                  obj.account = v['账户'] + '@' + _this.schoolChar + '.' + _this.userSuffix;
+                } else {
+                  obj.account = '';
+                }
+
                 obj.mail =
                 obj.mail =
                   uuidv4() + "@" + _this.schoolChar + "." + _this.userSuffix;
                   uuidv4() + "@" + _this.schoolChar + "." + _this.userSuffix;
               } else {
               } else {
+                if (Number(v['账户'])) {
+                  obj.account = v['账户'] + + _this.userSuffix;
+                } else {
+                  obj.account = '';
+                }
                 obj.mail = uuidv4() + "@" + _this.userSuffix;
                 obj.mail = uuidv4() + "@" + _this.userSuffix;
               }
               }
               obj.class = _this.boxType == 2 ? v[_this.lang.Class] : _this.classInfo.id;
               obj.class = _this.boxType == 2 ? v[_this.lang.Class] : _this.classInfo.id;
@@ -611,19 +622,45 @@ export default {
       console.log(box, "box");
       console.log(box, "box");
       this.uploadfileLoading = true;
       this.uploadfileLoading = true;
       this.impbox = box;
       this.impbox = box;
+      let data1 = box.filter(e => !e.account);
+      let data2 = box.filter(e => e.account);
+
+      data2.forEach((e) => {
+        e.mail = e.account;
+      });
+
       const batchSize = 50;
       const batchSize = 50;
-      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);
+      if (data1.length > 0) {
+        if (data1.length > batchSize) {
+          // 计算总批次数
+          const totalBatches = Math.ceil(data1.length / batchSize);
+          for (let i = 0; i < totalBatches; i++) {
+            const batch = data1.slice(i * batchSize, (i + 1) * batchSize);
+            await this.uploadBatch(batch); // 假设 uploadBatch 返回 Promise
+            console.log(`普通上传第 ${i + 1} 批上传完成`, batch);
+          }
+        } else {
+          // 长度不超过 10,直接上传整个数组
+          await this.uploadBatch(data1);
         }
         }
-      } else {
-        // 长度不超过 10,直接上传整个数组
-        await this.uploadBatch(box);
       }
       }
+
+      if (data2.length > 0) {
+        if (data2.length > batchSize) {
+          // 计算总批次数
+          const totalBatches = Math.ceil(data2.length / batchSize);
+          for (let i = 0; i < totalBatches; i++) {
+            const batch = data2.slice(i * batchSize, (i + 1) * batchSize);
+            await this.uploadBatchAccount (batch); // 假设 uploadBatch 返回 Promise
+            console.log(`自定义账号上传第 ${i + 1} 批上传完成`, batch);
+          }
+        } else {
+          // 长度不超过 10,直接上传整个数组
+          await this.uploadBatchAccount (data2);
+        }
+      }
+
+
       this.$message({
       this.$message({
         message: this.lang.ssAddOk,
         message: this.lang.ssAddOk,
         type: "success",
         type: "success",
@@ -671,21 +708,49 @@ export default {
             }
             }
             if (z == 2) {
             if (z == 2) {
               console.log("添加成功");
               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);
             resolve(res);
-            // this.uploadfileLoading = false;
+          })
+          .catch((err) => {
+            console.error(err);
+            this.addOp3('1', "", { type: "student_add" }, err)
+            reject(err);
+          });
+        });
+    },
+    async uploadBatchAccount(box){
+      return new Promise((resolve, reject) => {
+        let z = 2;
+        let newArr = JSON.stringify(box);
+        let params = [
+          {
+            arr: newArr,
+            userpassword: "Coco1234",
+            oid: this.oid,
+          },
+        ];
+      console.log(params, "batchRegistrationMoreAcc");
+      // batchRegistrationMoreCopy
+        this.ajax
+          .post(this.$store.state.api + "batchRegistrationMoreAcc", 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("添加成功");
+            }
+            resolve(res);
           })
           })
           .catch((err) => {
           .catch((err) => {
             console.error(err);
             console.error(err);

+ 1 - 1
src/lang/cn.json

@@ -2015,7 +2015,7 @@
   "ssUploadTip":"支持格式:.xlsx,.xls,大小不超过10MB",
   "ssUploadTip":"支持格式:.xlsx,.xls,大小不超过10MB",
   "ssUploadTempLbl":"上传模板:",
   "ssUploadTempLbl":"上传模板:",
   "ssDownloadTemp":"下载模板",
   "ssDownloadTemp":"下载模板",
-  "ssUploadNote":"提示:请按照模板格式填写学生信息并导入。",
+  "ssUploadNote":"提示:请按照模板填写学生信息。账户列非必填:手动输入则以输入为准,未输入则由系统自动生成。",
   "ssGetSuffixReUp":"正在获取后缀,请重新上传",
   "ssGetSuffixReUp":"正在获取后缀,请重新上传",
   "ssGetSuffixReAdd":"正在获取后缀,请重新添加",
   "ssGetSuffixReAdd":"正在获取后缀,请重新添加",
   "ssCheckStuNameCol":"请检查上传文件学生姓名列是否填写正确",
   "ssCheckStuNameCol":"请检查上传文件学生姓名列是否填写正确",

+ 1 - 1
src/lang/en.json

@@ -2014,7 +2014,7 @@
   "ssUploadTip":"Supported: xlsx, xls , up to 10MB",
   "ssUploadTip":"Supported: xlsx, xls , up to 10MB",
   "ssUploadTempLbl":"Upload template:",
   "ssUploadTempLbl":"Upload template:",
   "ssDownloadTemp":"Download template",
   "ssDownloadTemp":"Download template",
-  "ssUploadNote":"Tip: Please fill in student information according to the template format to avoid import failure",
+  "ssUploadNote":"Tip: Please fill in student information according to the template format. The account column is optional: if manually entered, the input will be used; if not entered, it will be generated automatically by the system.",
   "ssGetSuffixReUp":"Getting suffix, please re-upload",
   "ssGetSuffixReUp":"Getting suffix, please re-upload",
   "ssGetSuffixReAdd":"Getting suffix, please re-add",
   "ssGetSuffixReAdd":"Getting suffix, please re-add",
   "ssCheckStuNameCol":"Please check whether the student name column in the uploaded file is correct",
   "ssCheckStuNameCol":"Please check whether the student name column in the uploaded file is correct",

+ 1 - 1
src/lang/hk.json

@@ -2014,7 +2014,7 @@
   "ssUploadTip":"支持格式:.xlsx,.xls,大小不超過10MB",
   "ssUploadTip":"支持格式:.xlsx,.xls,大小不超過10MB",
   "ssUploadTempLbl":"上傳模板:",
   "ssUploadTempLbl":"上傳模板:",
   "ssDownloadTemp":"下載模板",
   "ssDownloadTemp":"下載模板",
-  "ssUploadNote":"提示:請按照模板格式填寫學生信息,避免導入失敗",
+  "ssUploadNote":"提示:請按照模板格式填寫學生信息。賬戶列非必填:手動輸入則以輸入為準,未輸入則由系統自動生成。",
   "ssGetSuffixReUp":"正在獲取後綴,請重新上傳",
   "ssGetSuffixReUp":"正在獲取後綴,請重新上傳",
   "ssGetSuffixReAdd":"正在獲取後綴,請重新添加",
   "ssGetSuffixReAdd":"正在獲取後綴,請重新添加",
   "ssCheckStuNameCol":"請檢查上傳文件學生姓名列是否填寫正確",
   "ssCheckStuNameCol":"請檢查上傳文件學生姓名列是否填寫正確",