|
@@ -10,7 +10,7 @@
|
|
|
</Upload>
|
|
|
<div class="tip-wrap">
|
|
|
<div class="download-wrap">
|
|
|
- <span style="color: #41cdec;cursor: pointer;" @click="onDownloadFiles">{{ $t('newCusMgt.downloadFiles') }}</span>
|
|
|
+ <span style="color: #41cdec; cursor: pointer" @click="onDownloadFiles">{{ $t("newCusMgt.downloadFiles") }}</span>
|
|
|
<Dropdown @on-click="onDownloadTemp">
|
|
|
<a href="javascript:void(0)" style="font-size: 14px; margin-left: 20px; color: #41cdec">
|
|
|
{{ $t("evaluation.importFile.templateDownload") }}
|
|
@@ -37,29 +37,31 @@
|
|
|
<template slot-scope="{ row, index }" slot="grade">
|
|
|
<span>{{ curPeriod.grades[row.grade] }}</span>
|
|
|
</template>
|
|
|
- <!-- <template slot-scope="{ row, index }" slot="assistants">
|
|
|
- <span>{{ row.assistants ? getTchName(row.assistants[0]) : "-" }}</span>
|
|
|
- </template> -->
|
|
|
- <template slot-scope="{ row, index }" slot="invalidCode">
|
|
|
- <span :style="{ color: row.invalidCode === 0 ? '#19be6d' : '#ff0000' }">{{ errorArr.find(i => i.code === row.invalidCode).msg }}</span>
|
|
|
+ <template slot-scope="{ row, index }" slot="assistants">
|
|
|
+ <span>{{ row.assistants ? row.assistants.split(',').length + $t('teachermgmt.peopleUnit') : "-" }}</span>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row, index }" slot="invalidCode">
|
|
|
+ <span :style="{ color: row.invalidCode === 0 ? '#19be6d' : '#ff0000' }">{{ errorArr.find((i) => i.code === row.invalidCode).msg }}</span>
|
|
|
</template>
|
|
|
</Table>
|
|
|
- <p style="margin: 20px 0;color:red;">* {{ $t('newCusMgt.tip4') }}<span style="color:#19be6b">{{ $t('newCusMgt.tip5') }}</span></p>
|
|
|
- <div class="btn-wrap">
|
|
|
- <Button @click="reImport"> {{$t('cusMgt.cusImp11')}}</Button>
|
|
|
- <Button type="success" :loading="btnLoading" @click="confirmImport" :disabled="!canImportList.length"> {{$t('cusMgt.cusImp10')}}</Button>
|
|
|
- </div>
|
|
|
+ <p style="margin: 20px 0; color: red">
|
|
|
+ * {{ $t("newCusMgt.tip4") }}<span style="color: #19be6b">{{ $t("newCusMgt.tip5") }}</span>
|
|
|
+ </p>
|
|
|
+ <div class="btn-wrap">
|
|
|
+ <Button @click="reImport"> {{ $t("cusMgt.cusImp11") }}</Button>
|
|
|
+ <Button type="success" :loading="btnLoading" @click="confirmImport" :disabled="!canImportList.length"> {{ $t("cusMgt.cusImp10") }}</Button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-</template>
|
|
|
+</template>
|
|
|
|
|
|
<script>
|
|
|
import excel from "@/utils/excel.js";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- canImportList:[],
|
|
|
- checkToken:null,
|
|
|
+ canImportList: [],
|
|
|
+ checkToken: null,
|
|
|
btnLoading: false,
|
|
|
isPreview: false,
|
|
|
isImporting: false,
|
|
@@ -67,22 +69,22 @@
|
|
|
columns: [
|
|
|
{
|
|
|
key: "name",
|
|
|
- title: this.$t('cusMgt.cusName'),
|
|
|
+ title: this.$t("cusMgt.cusName"),
|
|
|
align: "center"
|
|
|
},
|
|
|
{
|
|
|
key: "courseNo",
|
|
|
- title: this.$t('newCusMgt.no'),
|
|
|
+ title: this.$t("newCusMgt.no"),
|
|
|
align: "center"
|
|
|
},
|
|
|
{
|
|
|
slot: "grade",
|
|
|
- title: this.$t('newCusMgt.grade'),
|
|
|
+ title: this.$t("newCusMgt.grade"),
|
|
|
align: "center"
|
|
|
},
|
|
|
{
|
|
|
key: "list",
|
|
|
- title: this.$t('newCusMgt.list'),
|
|
|
+ title: this.$t("newCusMgt.list"),
|
|
|
align: "center",
|
|
|
width: 140
|
|
|
},
|
|
@@ -94,18 +96,18 @@
|
|
|
// },
|
|
|
{
|
|
|
slot: "tmdid",
|
|
|
- title: this.$t('newCusMgt.tmdid'),
|
|
|
+ title: this.$t("newCusMgt.tmdid"),
|
|
|
align: "center",
|
|
|
width: 100
|
|
|
},
|
|
|
{
|
|
|
slot: "assistants",
|
|
|
- title: this.$t('newCusMgt.assistantsId'),
|
|
|
+ title: this.$t("newCusMgt.assistantsId"),
|
|
|
align: "center"
|
|
|
},
|
|
|
{
|
|
|
slot: "invalidCode",
|
|
|
- title: this.$t('newCusMgt.invalidCode'),
|
|
|
+ title: this.$t("newCusMgt.invalidCode"),
|
|
|
align: "center",
|
|
|
width: 100
|
|
|
}
|
|
@@ -138,29 +140,62 @@
|
|
|
};
|
|
|
reader.readAsBinaryString(file);
|
|
|
},
|
|
|
+ mergeObjects(array) {
|
|
|
+ let mergedArray = [];
|
|
|
+
|
|
|
+ // 遍历数组中的每个对象
|
|
|
+ for (let i = 0; i < array.length; i++) {
|
|
|
+ let currentObject = array[i];
|
|
|
+ let isDuplicate = false;
|
|
|
+
|
|
|
+ // 检查是否有与当前对象相同的对象存在
|
|
|
+ for (let j = 0; j < mergedArray.length; j++) {
|
|
|
+ let mergedObject = mergedArray[j];
|
|
|
+ if (currentObject.courseNo === mergedObject.courseNo && currentObject.list === mergedObject.list && currentObject.tmdid === mergedObject.tmdid) {
|
|
|
+ // 如果找到相同的对象,则将当前对象的d字段合并到已存在的对象的d字段中
|
|
|
+ mergedObject.assistants = mergedObject.assistants + ',' + currentObject.assistants;
|
|
|
+ isDuplicate = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果未找到相同的对象,则将当前对象添加到合并后的数组中
|
|
|
+ if (!isDuplicate) {
|
|
|
+ mergedArray.push(currentObject);
|
|
|
+ } else {
|
|
|
+ // 如果找到相同的对象,将当前对象从原始数组中删除,避免后续循环中再次遇到它
|
|
|
+ array.splice(i, 1);
|
|
|
+ i--; // 调整索引以继续检查下一个对象
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return mergedArray;
|
|
|
+ },
|
|
|
/* 导入操作 */
|
|
|
onBeforeImportUpload(file) {
|
|
|
let maxSize = 10 * 1024 * 1024;
|
|
|
let nameType = file.name.split(".")[file.name.split(".").length - 1];
|
|
|
if (!["xls", "xlsx"].includes(nameType.toLowerCase())) {
|
|
|
- this.$Message.warning(this.$t('newCusMgt.tip6'));
|
|
|
+ this.$Message.warning(this.$t("newCusMgt.tip6"));
|
|
|
return false;
|
|
|
}
|
|
|
if (file.size > maxSize) {
|
|
|
- this.$Message.warning(this.$t('newCusMgt.tip7'));
|
|
|
+ this.$Message.warning(this.$t("newCusMgt.tip7"));
|
|
|
return false;
|
|
|
}
|
|
|
this.isImporting = true;
|
|
|
this.readExcel(file, (data) => {
|
|
|
this.importPercent = 20;
|
|
|
console.log(data.results);
|
|
|
- data.results.forEach(i => {
|
|
|
- i.grade = i.grade - 1
|
|
|
- i.tmdid = i.tmdid + ''
|
|
|
- i.courseNo = i.courseNo + ''
|
|
|
- i.assistants = isNaN(i.assistants) ? i.assistants : i.assistants + ''
|
|
|
- })
|
|
|
- let { year,id } = this.$store.state.user.curSemester
|
|
|
+ data.results.forEach((i) => {
|
|
|
+ i.grade = i.grade - 1;
|
|
|
+ i.tmdid = i.tmdid + "";
|
|
|
+ i.courseNo = i.courseNo + "";
|
|
|
+ i.assistants = isNaN(i.assistants) ? i.assistants : i.assistants + "";
|
|
|
+ });
|
|
|
+ // data.results = this.mergeObjects(data.results)
|
|
|
+
|
|
|
+ let { year, id } = this.$store.state.user.curSemester;
|
|
|
this.$api.newCourse
|
|
|
.courseManage({
|
|
|
scope: "school",
|
|
@@ -168,12 +203,12 @@
|
|
|
periodId: this.$store.state.user.curPeriod.id,
|
|
|
semesterId: id,
|
|
|
studyYear: year,
|
|
|
- courseCheckImports: data.results
|
|
|
+ courseCheckImports: this.mergeObjects(data.results)
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- this.checkToken = res.checkToken
|
|
|
- this.importResult = res.courseInvalidImports.concat(res.courseVerifiedImports)
|
|
|
- this.canImportList = res.courseVerifiedImports
|
|
|
+ this.checkToken = res.checkToken;
|
|
|
+ this.importResult = res.courseInvalidImports.concat(res.courseVerifiedImports);
|
|
|
+ this.canImportList = res.courseVerifiedImports;
|
|
|
this.isPreview = true;
|
|
|
this.isImporting = false;
|
|
|
this.importPercent = 100;
|
|
@@ -182,7 +217,7 @@
|
|
|
return;
|
|
|
});
|
|
|
},
|
|
|
- /* 确认导入 */
|
|
|
+ /* 确认导入 */
|
|
|
confirmImport() {
|
|
|
this.btnLoading = true;
|
|
|
this.$api.newCourse
|
|
@@ -225,82 +260,84 @@
|
|
|
downloadRes();
|
|
|
},
|
|
|
/* 导出备用资料 */
|
|
|
- onDownloadFiles(){
|
|
|
- let parentPage = this.$parent.$parent
|
|
|
+ onDownloadFiles() {
|
|
|
+ let parentPage = this.$parent.$parent;
|
|
|
console.log(parentPage.allClassList);
|
|
|
console.log(parentPage.teacherList);
|
|
|
console.log(parentPage.originCourseList);
|
|
|
- let curSemesterYear = this.$store.state.user.curSemester.year
|
|
|
- let sheets = []
|
|
|
+ let curSemesterYear = this.$store.state.user.curSemester.year;
|
|
|
+ let sheets = [];
|
|
|
// 班级名单
|
|
|
- let class_Headers = [`${this.$t('cusMgt.listName')}(name)`, `${this.$t('cusMgt.nameListType')}(type)`, `${this.$t('newCusMgt.no')}(list)`,`${this.$t('newCusMgt.year')}(year)`, `${this.$t('cusMgt.stuCount')}`]
|
|
|
- let class_Keys = ['name', 'type', 'no', 'year', 'scount']
|
|
|
- let class_datas = []
|
|
|
- parentPage.allClassList.filter(i => i.type !== 'research' && i.type !== 'yxtrain').forEach(classItem => {
|
|
|
- class_datas.push({
|
|
|
- name:classItem.name,
|
|
|
- year:classItem.year,
|
|
|
- no:classItem.year + '-' + classItem.no,
|
|
|
- type:classItem.type,
|
|
|
- scount:classItem.scount,
|
|
|
- })
|
|
|
- })
|
|
|
+ let class_Headers = [`${this.$t("cusMgt.listName")}(name)`, `${this.$t("cusMgt.nameListType")}(type)`, `${this.$t("newCusMgt.no")}(list)`, `${this.$t("newCusMgt.year")}(year)`, `${this.$t("cusMgt.stuCount")}`];
|
|
|
+ let class_Keys = ["name", "type", "no", "year", "scount"];
|
|
|
+ let class_datas = [];
|
|
|
+ parentPage.allClassList
|
|
|
+ .filter((i) => i.type !== "research" && i.type !== "yxtrain")
|
|
|
+ .forEach((classItem) => {
|
|
|
+ class_datas.push({
|
|
|
+ name: classItem.name,
|
|
|
+ year: classItem.year,
|
|
|
+ no: classItem.year + "-" + classItem.no,
|
|
|
+ type: classItem.type,
|
|
|
+ scount: classItem.scount
|
|
|
+ });
|
|
|
+ });
|
|
|
const classSheet = {
|
|
|
title: class_Headers,
|
|
|
key: class_Keys,
|
|
|
data: class_datas,
|
|
|
- filename: this.$t('cusMgt.classList'),
|
|
|
+ filename: this.$t("cusMgt.classList"),
|
|
|
autoWidth: true
|
|
|
- }
|
|
|
- sheets.push(classSheet)
|
|
|
+ };
|
|
|
+ sheets.push(classSheet);
|
|
|
// 教师名单
|
|
|
- let teacher_Headers = [this.$t('cusMgt.teaName') + '(tmdName)', this.$t('teachermgmt.table.th1') + '(tmdid)', this.$t('teachermgmt.tcUpd8'), this.$t('cusMgt.job'), this.$t('user.mobile'), this.$t('teachermgmt.page.text3'),this.$t('teachermgmt.tcUpd5')]
|
|
|
- let teacher_Keys = ['name', 'id', 'iname', 'job', 'phone', 'group', 'subject']
|
|
|
- let teacher_datas = []
|
|
|
- parentPage.teacherList.forEach(teacher => {
|
|
|
+ let teacher_Headers = [this.$t("cusMgt.teaName") + "(tmdName)", this.$t("teachermgmt.table.th1") + "(tmdid)", this.$t("teachermgmt.tcUpd8"), this.$t("cusMgt.job"), this.$t("user.mobile"), this.$t("teachermgmt.page.text3"), this.$t("teachermgmt.tcUpd5")];
|
|
|
+ let teacher_Keys = ["name", "id", "iname", "job", "phone", "group", "subject"];
|
|
|
+ let teacher_datas = [];
|
|
|
+ parentPage.teacherList.forEach((teacher) => {
|
|
|
teacher_datas.push({
|
|
|
- name:teacher.name,
|
|
|
+ name: teacher.name,
|
|
|
id: teacher.id,
|
|
|
- iname:teacher.iname || '-',
|
|
|
- job:teacher.job || '-',
|
|
|
- phone:teacher.phone || '-',
|
|
|
- group:teacher.groups.map(i => i.name).join(','),
|
|
|
- subject:teacher.subjectIds.map(i => parentPage.curPeriod.subjects.find(k => k.id === i)?.name || '-').join(','),
|
|
|
- })
|
|
|
- })
|
|
|
+ iname: teacher.iname || "-",
|
|
|
+ job: teacher.job || "-",
|
|
|
+ phone: teacher.phone || "-",
|
|
|
+ group: teacher.groups.map((i) => i.name).join(","),
|
|
|
+ subject: teacher.subjectIds.map((i) => parentPage.curPeriod.subjects.find((k) => k.id === i)?.name || "-").join(",")
|
|
|
+ });
|
|
|
+ });
|
|
|
const teacherSheet = {
|
|
|
title: teacher_Headers,
|
|
|
key: teacher_Keys,
|
|
|
data: teacher_datas,
|
|
|
- filename: this.$t('teachermgmt.teacherList'),
|
|
|
+ filename: this.$t("teachermgmt.teacherList"),
|
|
|
autoWidth: true
|
|
|
- }
|
|
|
- sheets.push(teacherSheet)
|
|
|
+ };
|
|
|
+ sheets.push(teacherSheet);
|
|
|
// 课程名单
|
|
|
- let course_Headers = [`${this.$t('cusMgt.listName')}(name)`, `${this.$t('newCusMgt.no')}(courseNo)`, `${this.$t('newCusMgt.grade')}(grade)`, `${this.$t('newCusMgt.subject')}(subject)`, `${this.$t('newCusMgt.desc')}(desc)`, this.$t('jyzx.offline.creator')]
|
|
|
- let course_Keys = ['name', 'no', 'grade', 'subject', 'desc', 'creator']
|
|
|
- let course_datas = []
|
|
|
- parentPage.originCourseList.forEach(course => {
|
|
|
+ let course_Headers = [`${this.$t("cusMgt.listName")}(name)`, `${this.$t("newCusMgt.no")}(courseNo)`, `${this.$t("newCusMgt.grade")}(grade)`, `${this.$t("newCusMgt.subject")}(subject)`, `${this.$t("newCusMgt.desc")}(desc)`, this.$t("jyzx.offline.creator")];
|
|
|
+ let course_Keys = ["name", "no", "grade", "subject", "desc", "creator"];
|
|
|
+ let course_datas = [];
|
|
|
+ parentPage.originCourseList.forEach((course) => {
|
|
|
course_datas.push({
|
|
|
- name:course.name,
|
|
|
- no: course.no || '-',
|
|
|
+ name: course.name,
|
|
|
+ no: course.no || "-",
|
|
|
grade: course.grade + 1,
|
|
|
- subject:course.subject.name,
|
|
|
- desc:course.desc || '-',
|
|
|
- creator:course.creatorName + '(' + course.creatorId +')',
|
|
|
- })
|
|
|
- })
|
|
|
+ subject: course.subject.name,
|
|
|
+ desc: course.desc || "-",
|
|
|
+ creator: course.creatorName + "(" + course.creatorId + ")"
|
|
|
+ });
|
|
|
+ });
|
|
|
const courseSheet = {
|
|
|
title: course_Headers,
|
|
|
key: course_Keys,
|
|
|
data: course_datas,
|
|
|
- filename: this.$t('courseManage.courseList'),
|
|
|
+ filename: this.$t("courseManage.courseList"),
|
|
|
autoWidth: true
|
|
|
- }
|
|
|
- sheets.push(courseSheet)
|
|
|
+ };
|
|
|
+ sheets.push(courseSheet);
|
|
|
let schoolName = this.$store.state.user.schoolProfile.school_base.name;
|
|
|
let periodName = parentPage.curPeriod.name;
|
|
|
- excel.export_array_to_sheet(sheets, `${schoolName}-${periodName} ${this.$t('newCusMgt.recommendFiles')}`)
|
|
|
+ excel.export_array_to_sheet(sheets, `${schoolName}-${periodName} ${this.$t("newCusMgt.recommendFiles")}`);
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -311,52 +348,52 @@
|
|
|
curYear() {
|
|
|
return new Date().getFullYear();
|
|
|
},
|
|
|
- /* 获取教师姓名 */
|
|
|
+ /* 获取教师姓名 */
|
|
|
getTchName() {
|
|
|
return (tchId) => {
|
|
|
return this.$parent.$parent.teacherList.find((i) => i.id === tchId)?.name;
|
|
|
};
|
|
|
},
|
|
|
- errorArr(){
|
|
|
- return [
|
|
|
- {
|
|
|
- code:0,
|
|
|
- msg:this.$t('newCusMgt.normal')
|
|
|
- },
|
|
|
- {
|
|
|
- code:1,
|
|
|
- msg:this.$t('newCusMgt.errorTip1')
|
|
|
- },
|
|
|
- {
|
|
|
- code:2,
|
|
|
- msg:this.$t('newCusMgt.errorTip2')
|
|
|
- },
|
|
|
- {
|
|
|
- code:3,
|
|
|
- msg:this.$t('newCusMgt.errorTip3')
|
|
|
- },
|
|
|
- {
|
|
|
- code:4,
|
|
|
- msg:this.$t('newCusMgt.errorTip4')
|
|
|
- },
|
|
|
- {
|
|
|
- code:5,
|
|
|
- msg:this.$t('newCusMgt.errorTip5')
|
|
|
- },
|
|
|
+ errorArr() {
|
|
|
+ return [
|
|
|
{
|
|
|
- code:12,
|
|
|
- msg:this.$t('newCusMgt.errorTip7')
|
|
|
- },
|
|
|
- {
|
|
|
- code:21,
|
|
|
- msg:this.$t('newCusMgt.errorTip6')
|
|
|
- },
|
|
|
+ code: 0,
|
|
|
+ msg: this.$t("newCusMgt.normal")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 1,
|
|
|
+ msg: this.$t("newCusMgt.errorTip1")
|
|
|
+ },
|
|
|
{
|
|
|
- code:22,
|
|
|
- msg:this.$t('newCusMgt.tip3')
|
|
|
- },
|
|
|
- ]
|
|
|
- }
|
|
|
+ code: 2,
|
|
|
+ msg: this.$t("newCusMgt.errorTip2")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 3,
|
|
|
+ msg: this.$t("newCusMgt.errorTip3")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 4,
|
|
|
+ msg: this.$t("newCusMgt.errorTip4")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 5,
|
|
|
+ msg: this.$t("newCusMgt.errorTip5")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 12,
|
|
|
+ msg: this.$t("newCusMgt.errorTip7")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 21,
|
|
|
+ msg: this.$t("newCusMgt.errorTip6")
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 22,
|
|
|
+ msg: this.$t("newCusMgt.tip3")
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|