|
|
@@ -283,7 +283,11 @@ export default {
|
|
|
export_json_to_excel,
|
|
|
} = require("../../../../common/Export2Excel");
|
|
|
// 增加 colWidths 参数以调整列宽,例如调整为 [20, 35, 20]
|
|
|
- const tHeader = [this.lang.StudentName];
|
|
|
+ let tHeader = [this.lang.StudentName];
|
|
|
+
|
|
|
+ if (this.boxType == 2) {
|
|
|
+ tHeader = [this.lang.StudentName,this.lang.Class];
|
|
|
+ }
|
|
|
const data = [];
|
|
|
const colWidths = [35]; // 设置每一列的宽度
|
|
|
export_json_to_excel(
|
|
|
@@ -333,7 +337,7 @@ export default {
|
|
|
let obj = {};
|
|
|
if (
|
|
|
v[_this.lang.StudentName] !== undefined &&
|
|
|
- v[_this.lang.StudentName] !== ""
|
|
|
+ v[_this.lang.StudentName] !== ""
|
|
|
) {
|
|
|
obj.name = v[_this.lang.StudentName];
|
|
|
if (
|
|
|
@@ -348,8 +352,11 @@ export default {
|
|
|
} else {
|
|
|
obj.mail = uuidv4() + "@" + _this.userSuffix;
|
|
|
}
|
|
|
- obj.class = _this.classInfo.name;
|
|
|
+ obj.class = _this.boxType == 2 ? v[_this.lang.Class] : _this.classInfo.name;
|
|
|
arr.push(obj);
|
|
|
+ }else{
|
|
|
+ _this.$message.error('请检查上传文件学生姓名列是否填写正确');
|
|
|
+ return;
|
|
|
}
|
|
|
});
|
|
|
console.log(arr);
|
|
|
@@ -357,13 +364,27 @@ export default {
|
|
|
_this.$message.error(_this.lang.Limitmore);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ if (this.boxType == 2 && arr.filter(e => e.class) != arr.length) {
|
|
|
+ _this.$message.error('请检查上传文件班级列是否填写正确');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (!arr.length) {
|
|
|
_this.$message.error(
|
|
|
"未能提取上传学生信息,请检查数据格式,使用模板文件格式上传"
|
|
|
);
|
|
|
return;
|
|
|
}
|
|
|
- _this.accUpdate(arr);
|
|
|
+ _this.$confirm('是否确认上传?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ _this.accUpdate(arr);
|
|
|
+ }).catch(() => {
|
|
|
+ _this.$message.info('已取消');
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
reader.readAsArrayBuffer(f);
|
|
|
@@ -387,7 +408,7 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (this.cascaderDataPath.length == 0 || this.classInfo.name == "") {
|
|
|
+ if ((this.boxType == 2 && this.cascaderDataPath.length == 0) || this.classInfo.name == "") {
|
|
|
this.$message.error("请选择所属班级");
|
|
|
return;
|
|
|
}
|
|
|
@@ -403,11 +424,16 @@ export default {
|
|
|
} else {
|
|
|
mail = "@" + this.userSuffix;
|
|
|
}
|
|
|
+ let classInfo = this.classInfo;
|
|
|
+ if (this.boxType == 2) {
|
|
|
+ classInfo = this.cascaderData.flatMap((item) => item.children).filter((item) => this.cascaderDataPath[1]==item.id)[0];
|
|
|
+ }
|
|
|
+ // console.log(classInfo, "classInfo");
|
|
|
let box = this.selectedStuData.map((item) => {
|
|
|
return {
|
|
|
name: item,
|
|
|
mail: uuidv4() + mail,
|
|
|
- class: this.classInfo.name,
|
|
|
+ class: classInfo.name,
|
|
|
};
|
|
|
});
|
|
|
// console.log(box, "box");
|
|
|
@@ -450,8 +476,9 @@ export default {
|
|
|
message: "添加成功",
|
|
|
type: "success",
|
|
|
});
|
|
|
+ this.addStuVisible = false;
|
|
|
this.selectedStuData = [];
|
|
|
- this.$emit("getStudent");
|
|
|
+ this.$emit("getCascaderData");
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|