|
@@ -142,6 +142,7 @@
|
|
|
</template>
|
|
|
</Table>
|
|
|
</div>
|
|
|
+ <Loading v-if="isLoading" bgColor="rgba(103, 103, 103, 0.27)"></Loading>
|
|
|
</vuescroll>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -152,6 +153,17 @@
|
|
|
@on-ok="importCus"
|
|
|
@on-cancel="cancelImport">
|
|
|
<ImportExcel ref="impXls" :headerKeys="headerKeys" :headerTitles="headerTitles" @getTableData="getTableData"></ImportExcel>
|
|
|
+ <div class="error-tips-wrap">
|
|
|
+ <span style="color:#ed4014;" v-if="errorCourse.length > 0">
|
|
|
+ <span>错误课程:</span><span>{{errorCourse.join(',')}}</span>
|
|
|
+ </span>
|
|
|
+ <span style="margin-left:30px;color:#ff9900" v-if="errorClass.length > 0">
|
|
|
+ <span>错误班级:</span><span>{{errorClass.join(',')}}</span>
|
|
|
+ </span>
|
|
|
+ <span style="margin-left:30px;color:#2db7f5" v-if="errorTeacher.length > 0">
|
|
|
+ <span>错误授课老师:</span><span>{{errorTeacher.join(',')}}</span>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</Modal>
|
|
|
<Modal v-model="setCusStatus"
|
|
|
title="设置课程"
|
|
@@ -180,8 +192,10 @@
|
|
|
components: {
|
|
|
NoData,Loading,ImportExcel
|
|
|
},
|
|
|
+ inject:['reload'],
|
|
|
data() {
|
|
|
return {
|
|
|
+ isLoading: false,
|
|
|
coursePlan: {},
|
|
|
courseList:[],
|
|
|
cusItem: {
|
|
@@ -190,9 +204,12 @@
|
|
|
row: {},
|
|
|
day:''
|
|
|
},
|
|
|
+ errorClass: [],
|
|
|
+ errorCourse: [],
|
|
|
+ errorTeacher: [],
|
|
|
excelData:[],
|
|
|
- headerKeys:['classroomCode','courseName','courseCode','MON','TUE','WED','THU','FRI','SAT','SUN'],
|
|
|
- headerTitles:['班级','课程名称','课程编码','星期一','星期二','星期三','星期四','星期五','星期六','星期日'],
|
|
|
+ headerKeys:['classroomCode','courseName','courseCode','teacher','MON','TUE','WED','THU','FRI','SAT','SUN'],
|
|
|
+ headerTitles:['班级','课程名称','课程编码','授课老师','星期一','星期二','星期三','星期四','星期五','星期六','星期日'],
|
|
|
importCusStatus: false,
|
|
|
setCusStatus: false,
|
|
|
semesterTree:[],
|
|
@@ -203,7 +220,8 @@
|
|
|
classList: [],
|
|
|
classListShow: [],
|
|
|
curClassIndex: 0,
|
|
|
- tableData:[],
|
|
|
+ tableData: [],
|
|
|
+ importData:[],
|
|
|
timeColumns: [
|
|
|
{
|
|
|
title: ' ',
|
|
@@ -275,6 +293,7 @@
|
|
|
},
|
|
|
//确认设置课程
|
|
|
confirmSetCus() {
|
|
|
+ this.isLoading = true
|
|
|
let requestData = {
|
|
|
courseId: this.cusItem.courseId,
|
|
|
classroomCode: this.classListShow[this.curClassIndex].classroomCode,
|
|
@@ -288,18 +307,20 @@
|
|
|
}
|
|
|
this.$api.courseMgmt.upsertAllPlan([requestData]).then(
|
|
|
(res) => {
|
|
|
- this.$set(this.tableData[this.cusItem.row._index].weeklies[this.cusItem.day], 'courseName',this.courseList.filter((item) => {
|
|
|
+ this.$set(this.classListShow[this.curClassIndex].classPlan[this.cusItem.row._index].weeklies[this.cusItem.day], 'courseName',this.courseList.filter((item) => {
|
|
|
return item.id == this.cusItem.courseId
|
|
|
})[0].courseName)
|
|
|
|
|
|
- this.$set(this.tableData[this.cusItem.row._index].weeklies[this.cusItem.day], 'teacher', this.cusTeaList.filter((item) => {
|
|
|
+ this.$set(this.classListShow[this.curClassIndex].classPlan[this.cusItem.row._index].weeklies[this.cusItem.day], 'teacher', this.cusTeaList.filter((item) => {
|
|
|
return item.id == this.cusItem.teacher
|
|
|
})[0].name)
|
|
|
|
|
|
this.$Message.success('设置成功!')
|
|
|
+ this.isLoading = false
|
|
|
},
|
|
|
(err) => {
|
|
|
console.log('error')
|
|
|
+ this.isLoading = false
|
|
|
}
|
|
|
)
|
|
|
},
|
|
@@ -312,6 +333,69 @@
|
|
|
//处理表格导入的数据
|
|
|
getTableData(data) {
|
|
|
this.excelData = data
|
|
|
+ console.log('-----')
|
|
|
+ console.log(data)
|
|
|
+ let keys = ['MON','TUE','WED','THU','FRI','SAT','SUN']
|
|
|
+ for (let itemData of data) {
|
|
|
+ //验证教室code
|
|
|
+ let classroom = this.classList.filter((item) => {
|
|
|
+ return item.classroomCode == itemData.classroomCode
|
|
|
+ })
|
|
|
+ if (classroom.length == 0) {
|
|
|
+ this.errorClass.push(itemData.classroomCode)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //验证教师id
|
|
|
+ let teacher = this.$store.state.teachers.teacherList.filter((item) => {
|
|
|
+ return item.id == itemData.teacher
|
|
|
+ })
|
|
|
+ if (teacher.length == 0) {
|
|
|
+ this.errorTeacher.push(itemData.teacher)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //验证课程编码
|
|
|
+ let courseId = ''
|
|
|
+ let course = this.courseList.filter((item) => {
|
|
|
+ return item.courseCode == itemData.courseCode
|
|
|
+ })
|
|
|
+ if (course.length > 0) {
|
|
|
+ courseId = course[0].id
|
|
|
+ } else {
|
|
|
+ this.errorCourse.push(itemData.courseCode)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (let key of keys) {
|
|
|
+ if (itemData[key]) {
|
|
|
+ console.log(itemData[key])
|
|
|
+ let indexes = itemData[key].toString().split(',')
|
|
|
+ console.log(indexes)
|
|
|
+ for (let index of indexes) {
|
|
|
+ let reqItem = {
|
|
|
+ classroomCode: itemData.classroomCode,
|
|
|
+ courseId: courseId,
|
|
|
+ code: teacher[0].id,
|
|
|
+ courseTime: {}
|
|
|
+ }
|
|
|
+ reqItem.courseTime.label = this.tableData[parseInt(index) - 1].label
|
|
|
+ reqItem.courseTime.time = this.tableData[parseInt(index) - 1].time
|
|
|
+ reqItem.courseTime.day = key
|
|
|
+ this.importData.push(reqItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //this.importData.push(reqItem)
|
|
|
+ }
|
|
|
+ if (this.errorClass.length > 0 || this.errorCourse.length > 0 || this.errorTeacher.length > 0) {
|
|
|
+ this.$Message.error({
|
|
|
+ content: '错误数据不能导入,请检查数据是否正确',
|
|
|
+ duration: 5,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$Message.info('文件读取成功')
|
|
|
+ }
|
|
|
+ console.log(this.importData)
|
|
|
},
|
|
|
//显示导入课程
|
|
|
showImportCus() {
|
|
@@ -320,14 +404,43 @@
|
|
|
//确认导入课程
|
|
|
importCus() {
|
|
|
this.$refs['impXls'].file = undefined
|
|
|
+ this.errorClass.length = 0
|
|
|
+ this.errorCourse.length = 0
|
|
|
+ this.errorTeacher.length = 0
|
|
|
+ this.isLoading = true
|
|
|
+ this.$api.courseMgmt.upsertAllPlan(this.importData).then(
|
|
|
+ (res) => {
|
|
|
+ if (res.error == null) {
|
|
|
+ this.$Message.success('导入成功!')
|
|
|
+ this.reload()
|
|
|
+ } else {
|
|
|
+ this.$Message.error('API ERROR!')
|
|
|
+ }
|
|
|
+
|
|
|
+ this.isLoading = false
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ this.$Message.error('API ERROR!')
|
|
|
+ this.isLoading = false
|
|
|
+ }
|
|
|
+ )
|
|
|
},
|
|
|
cancelImport() {
|
|
|
this.$refs['impXls'].file = undefined
|
|
|
+ this.errorClass.length = 0
|
|
|
+ this.errorCourse.length = 0
|
|
|
+ this.errorTeacher.length = 0
|
|
|
+ this.importData.length = 0
|
|
|
},
|
|
|
selectClass(index) {
|
|
|
this.curClassIndex = index
|
|
|
- if (!this.classListShow.isFull) {
|
|
|
+ this.isLoading = true
|
|
|
+ if (!this.classListShow[this.curClassIndex].isFull) {
|
|
|
this.findClassPlan()
|
|
|
+ } else {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isLoading = false
|
|
|
+ },500)
|
|
|
}
|
|
|
},
|
|
|
//根据上下午合并单元格
|
|
@@ -355,6 +468,7 @@
|
|
|
},
|
|
|
//根据班级查询课程安排
|
|
|
findClassPlan() {
|
|
|
+
|
|
|
if (this.classListShow.length > 0) {
|
|
|
let requestData = {
|
|
|
classroomCode: this.classListShow[this.curClassIndex].classroomCode
|
|
@@ -362,7 +476,9 @@
|
|
|
this.$api.courseMgmt.findPlan(requestData).then(
|
|
|
(res) => {
|
|
|
if (res.error == null) {
|
|
|
- this.$set(this.classListShow[this.curClassIndex], 'classPlan', [...this.tableData])
|
|
|
+ let jStr = JSON.stringify(this.tableData)
|
|
|
+ console.log(jStr)
|
|
|
+ this.$set(this.classListShow[this.curClassIndex], 'classPlan', JSON.parse(jStr))
|
|
|
for (let planItem of res.result.data) {
|
|
|
let course = this.courseList.filter((item) => {
|
|
|
return item.id == planItem.courseId
|
|
@@ -375,27 +491,29 @@
|
|
|
for (let timeItem of planItem.courseTimes) {
|
|
|
//可优化
|
|
|
for (let i = 0; i < this.classListShow[this.curClassIndex].classPlan.length; i++) {
|
|
|
- if (this.tableData[i].time == timeItem.time) {
|
|
|
- this.$set(this.classListShow[this.curClassIndex].classPlan[i].weeklies[timeItem.day], 'courseName', courseName)
|
|
|
- this.$set(this.classListShow[this.curClassIndex].classPlan[i].weeklies[timeItem.day], 'teacher', teacherName)
|
|
|
+ if (this.classListShow[this.curClassIndex].classPlan[i].time == timeItem.time) {
|
|
|
+ //this.$set(this.classListShow[this.curClassIndex].classPlan[i].weeklies[timeItem.day], 'courseName', courseName)
|
|
|
+ //this.$set(this.classListShow[this.curClassIndex].classPlan[i].weeklies[timeItem.day], 'teacher', teacherName)
|
|
|
+ this.classListShow[this.curClassIndex].classPlan[i].weeklies[timeItem.day].teacher = teacherName
|
|
|
+ this.classListShow[this.curClassIndex].classPlan[i].weeklies[timeItem.day].courseName = courseName
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- console.log('0.0.0.0')
|
|
|
- console.log(this.tableData)
|
|
|
this.classListShow[this.curClassIndex].isFull = true
|
|
|
+ this.isLoading = false
|
|
|
} else {
|
|
|
this.$Message.error('API error!')
|
|
|
+ this.isLoading = false
|
|
|
}
|
|
|
},
|
|
|
(err) => {
|
|
|
-
|
|
|
+ this.isLoading = false
|
|
|
}
|
|
|
)
|
|
|
} else {
|
|
|
-
|
|
|
+ this.isLoading = false
|
|
|
}
|
|
|
}
|
|
|
},
|