فهرست منبع

Merge branch 'develop3.0' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0

CrazyIter 4 سال پیش
والد
کامیت
9f7b037fb0

+ 1 - 2
TEAMModelOS/ClientApp/src/common/ImportExcel.vue

@@ -54,7 +54,6 @@
                         key: this.headerKeys[index]
                     }
                 })
-                console.log(this.tableColumn)
             },
             //获取上传的文件
             handleBeforeUpload(file) {
@@ -101,7 +100,7 @@
                     if (flag) {
                         // 处理表格导入数据类型
                         this.tableData = [...results]
-                        this.$Message.info('导入成功')
+                        //this.$Message.info('文件读取成功')
                         this.tableLoading = false
                         this.$emit('getTableData', this.tableData)
                     } else {

+ 12 - 130
TEAMModelOS/ClientApp/src/components/app-root.vue

@@ -11,143 +11,25 @@
         components: {
             'nav-menu': NavMenu,
         },
+        provide () {    //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。                                             
+            return {
+                reload: this.reload                                              
+            }
+        },
         methods: {
-            
-            /**设置用户角色权限 */
-            // setUser(roleCode) {
-            //     console.log(typeof roleCode)
-            //     this.$access.reset()
-            //     switch (roleCode) {
-            //         case '0':
-            //             this.$access.setLoginUserInfo(this.adminRole)
-            //             this.$router.push({
-            //                 name:'totalIndex'
-            //             })
-            //             break
-            //         case '1':
-            //             this.$access.setLoginUserInfo(this.teacherRole)
-            //             this.$router.push({
-            //                 name:'courseManage'
-            //             })
-            //             break
-            //         case '2':
-            //             this.$access.setLoginUserInfo(this.teacherAnalysis)
-            //             this.$router.push({
-            //                 name:'totalIndex'
-            //             })
-            //             break
-            //         case '3':
-            //             this.$access.setLoginUserInfo(this.teacherContent)
-            //             this.$router.push({
-            //                 name:'courseManage'
-            //             })
-            //             break
-            //         case '4':
-            //             this.$access.setLoginUserInfo(this.teacherSyllabus)
-            //             this.$router.push({
-            //                 name:'courseManage'
-            //             })
-            //             break
-            //         case '5':
-            //             this.$access.setLoginUserInfo(this.teacherSchoolSettingRead)
-            //             this.$router.push({
-            //                 name:'system'
-            //             })
-            //             break
-            //         case '6':
-            //             this.$access.setLoginUserInfo(this.teacherSchoolSettingUpd)
-            //             this.$router.push({
-            //                 name:'system'
-            //             })
-            //             break
-            //         case '7':
-            //             this.$access.setLoginUserInfo(this.teacherStudentRead)
-            //             this.$router.push({
-            //                 name:'studentAccount'
-            //             })
-            //             break
-            //         case '8':
-            //             this.$access.setLoginUserInfo(this.teacherStudentUpd)
-            //             this.$router.push({
-            //                 name:'studentAccount'
-            //             })
-            //             break
-            //         default:
-            //             this.$access.setLoginUserInfo(this.adminRole)
-            //             localStorage.setItem('roleCode',0)
-            //             break
-            //     }
-            // },
+            reload() {
+                this.isRouterAlive = false
+                this.$nextTick(function () {
+                    this.isRouterAlive = true
+                })
+            }
         },
         data() {
             return {
-                // //管理员
-                // adminRole: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["admin"],
-                //     "permissions": [],
-                //     "isLogin": true
-                // },
-                // //教师
-                // teacherRole: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": [],
-                //     "isLogin": true
-                // },
-                // //可以编辑校本资源的老师
-                // teacherContent: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['content-school-upd'],
-                //     "isLogin": true
-                // },
-                // //可以查看学情的教师
-                // teacherAnalysis: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['analysis'],
-                //     "isLogin": true
-                // },
-                // //可以编辑校本课纲的老师
-                // teacherSyllabus: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['school_syllabus'],
-                //     "isLogin": true
-                // },
-                // //可以查看区班校的老师
-                // teacherSchoolSettingRead: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['schoolSetting-read'],
-                //     "isLogin": true
-                // },
-                // //可以编辑区班校的老师
-                // teacherSchoolSettingUpd: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['schoolSetting-upd'],
-                //     "isLogin": true
-                // },
-                // //可以编辑学生账号的老师
-                // teacherStudentRead: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['student-read'],
-                //     "isLogin": true
-                // },
-                // //可以编辑学生账号的老师
-                // teacherStudentUpd: {
-                //     "userId": "boDH1#1856",
-                //     "roles": ["teacher"],
-                //     "permissions": ['student-upd'],
-                //     "isLogin": true
-                // }
+                isRouterAlive:true
             }
         },
         created() {
-            // this.setUser(localStorage.getItem('roleCode'))
         }
     }
 </script>

+ 6 - 0
TEAMModelOS/ClientApp/src/view/newcourse/CoursePlan.less

@@ -141,4 +141,10 @@
     .label{
         margin-right:5px; 
     }
+}
+.error-tips-wrap{
+    width:100%;
+    height:50px;
+    line-height:50px;
+
 }

+ 132 - 14
TEAMModelOS/ClientApp/src/view/newcourse/CoursePlan.vue

@@ -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
                 }
             }
         },