|
|
@@ -169,7 +169,7 @@
|
|
|
>{{ lang.ssDownloadTemp }}</span
|
|
|
>
|
|
|
</div>
|
|
|
- <div v-if="boxType == 0" style="margin-top: 10px">
|
|
|
+ <div v-if="boxType == 0" style="margin-top: 10px;font-weight: 600;">
|
|
|
{{ lang.ssUploadNote }}
|
|
|
</div>
|
|
|
<div v-else style="margin-top: 10px">
|
|
|
@@ -401,10 +401,10 @@ export default {
|
|
|
export_json_to_excel,
|
|
|
} = require("../../../../common/Export2Excel");
|
|
|
// 增加 colWidths 参数以调整列宽,例如调整为 [20, 35, 20]
|
|
|
- let tHeader = [this.lang.StudentName];
|
|
|
+ let tHeader = [this.lang.StudentName,'账户'];
|
|
|
|
|
|
if (this.boxType == 2) {
|
|
|
- tHeader = [this.lang.StudentName,this.lang.Class];
|
|
|
+ tHeader = [this.lang.StudentName,this.lang.Class,'账户'];
|
|
|
}
|
|
|
const data = [];
|
|
|
const colWidths = [35]; // 设置每一列的宽度
|
|
|
@@ -455,7 +455,7 @@ export default {
|
|
|
}
|
|
|
outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]); //outdata就是你想要的东西
|
|
|
let da = [...outdata];
|
|
|
- // console.log(da, "da");
|
|
|
+ console.log(da, "da");
|
|
|
let arr = [];
|
|
|
da.map((v) => {
|
|
|
let obj = {};
|
|
|
@@ -471,9 +471,20 @@ export default {
|
|
|
_this.org &&
|
|
|
_this.schoolChar
|
|
|
) {
|
|
|
+ if (Number(v['账户'])) {
|
|
|
+ obj.account = v['账户'] + '@' + _this.schoolChar + '.' + _this.userSuffix;
|
|
|
+ } else {
|
|
|
+ obj.account = '';
|
|
|
+ }
|
|
|
+
|
|
|
obj.mail =
|
|
|
uuidv4() + "@" + _this.schoolChar + "." + _this.userSuffix;
|
|
|
} else {
|
|
|
+ if (Number(v['账户'])) {
|
|
|
+ obj.account = v['账户'] + + _this.userSuffix;
|
|
|
+ } else {
|
|
|
+ obj.account = '';
|
|
|
+ }
|
|
|
obj.mail = uuidv4() + "@" + _this.userSuffix;
|
|
|
}
|
|
|
obj.class = _this.boxType == 2 ? v[_this.lang.Class] : _this.classInfo.id;
|
|
|
@@ -611,19 +622,45 @@ export default {
|
|
|
console.log(box, "box");
|
|
|
this.uploadfileLoading = true;
|
|
|
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;
|
|
|
- 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({
|
|
|
message: this.lang.ssAddOk,
|
|
|
type: "success",
|
|
|
@@ -671,21 +708,49 @@ export default {
|
|
|
}
|
|
|
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);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ 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) => {
|
|
|
console.error(err);
|