Bladeren bron

完成课程时段设置

liqk 4 jaren geleden
bovenliggende
commit
e05cc8d3c2

+ 3 - 2
TEAMModelOS.SDK/Models/Cosmos/School/Course.cs

@@ -73,9 +73,10 @@ namespace TEAMModelOS.SDK.Models
     }
     public class timeInfo
     {
+        public string id { get; set; }
         public string week { get; set; }
-        public string start { get; set; }
-        public string end { get; set; }
+        //public string start { get; set; }
+        //public string end { get; set; }
     }
     public class PeriodSimple
     {

+ 68 - 8
TEAMModelOS/ClientApp/src/view/newcourse/NewCusMgt.vue

@@ -12,7 +12,6 @@
                     <DropdownItem :name="item.id">{{ item.name }}</DropdownItem>
                 </DropdownMenu>
             </Dropdown>
-
             <div class="action-btn-wrap">
                 <span v-if="$access.can('admin.*|course-upd')" @click="toggleView()" class="action-btn" style="margin-right:40px">
                     <Icon custom="iconfont icon-schedule" size="16" />
@@ -144,7 +143,7 @@
                             <span @click="curTab = 0" :class="curTab == 0 ? 'tab-label line-bottom line-bottom-active':'tab-label line-bottom'">
                                 课程名单
                             </span>
-                            <span @click="curTab = 1" :class="curTab == 1 ? 'tab-label line-bottom line-bottom-active':'tab-label line-bottom'">
+                            <span @click="selectTab(1)" :class="curTab == 1 ? 'tab-label line-bottom line-bottom-active':'tab-label line-bottom'">
                                 课程时段
                             </span>
                             <div class="action-btn-wrap">
@@ -152,20 +151,23 @@
                                     <Icon type="ios-albums-outline" size="16" />
                                     <span>保存变更</span>
                                 </span>
-                                <span class="action-btn" :style="{marginRight:isUpd ? '20px':'30px'}" @click="setDefaultTea">
+                                <span class="action-btn" v-show="curTab == 0" :style="{marginRight:isUpd ? '20px':'30px'}" @click="setDefaultTea">
                                     <Icon type="md-add" size="16" />
                                     <span>添加名单</span>
                                 </span>
-                                <span class="action-btn" @click="removeStuList">
+                                <span class="action-btn" v-show="curTab == 0" @click="removeStuList">
                                     <Icon type="md-trash" size="16" />
                                     <span>移除名单</span>
                                 </span>
-
+                                <span v-show="curTab == 1">授课教室:</span>
+                                <Select v-show="curTab == 1" v-model="setCurClass" style="width:200px;margin-right:30px" size="small">
+                                    <Option v-for="(item,index) in schdClassList" :value="item.classId" :key="index">{{ item.classInfo.name }}</Option>
+                                </Select>
                             </div>
                         </div>
                         <!-- 教师上课时段设置 -->
                         <div class="cus-time-setting">
-                            <!-- 设置授课教室名单 -->
+                            <!-- 设置授课教室/名单 -->
                             <div class="set-cus-class" v-show="curTab == 0">
                                 <Split v-model="split3" v-show="schdList.length > 0">
                                     <!-- 教室列表 -->
@@ -230,7 +232,7 @@
                             </div>
                             <!-- 教师课表 -->
                             <vuescroll v-show="curTab == 1">
-                                <TeaTable v-if="hasTimeTable" :periodId="filterPeriod"></TeaTable>
+                                <TeaTable v-if="hasTimeTable" :teacher="teaList[curTeaIndex] ? teaList[curTeaIndex].id : ''" :periodId="filterPeriod" :schedData="[courseListShow[this.curCusIndex]]" @selectCell="selectCell" @cancelCell="cancelCell"></TeaTable>
                                 <div v-else>
                                     <p class="no-time-table-tips">
                                         {{filterPeriodName}}暂未设置时段,请先
@@ -323,6 +325,7 @@ export default {
                 label: 'name',
                 emitPath: false
             },
+            setCurClass: '',
             addTeaStatus: false,
             preDefault: true,
             isAddStuList: false,
@@ -466,6 +469,57 @@ export default {
         }
     },
     methods: {
+        selectTab(index) {
+            this.curTab = index
+            this.setDefClass()
+        },
+        //设置默认授课教室
+        setDefClass() {
+            if (this.schdList[this.curClassIndex]) {
+                this.setCurClass = this.schdList[this.curClassIndex].classId || ''
+                if (!this.setCurClass && this.schdClassList[0]) {
+                    this.setCurClass = this.schdClassList[0].classId
+                }
+            }else{
+                this.setCurClass = ''
+            }
+        },
+        //设置课程时段
+        selectCell(data) {
+            console.log('data', data)
+            let teacher = this.teaList[this.curTeaIndex] ? this.teaList[this.curTeaIndex].id : ''
+            if (!this.setCurClass || !teacher) {
+                this.$Message.warning("暂无教师或授课教室信息,无法完成课程时段设置")
+                return
+            }
+            let schedule = this.courseListShow[this.curCusIndex].schedule.find(item => {
+                return item.classId == this.setCurClass && item.teacher.id == this.teaList[this.curTeaIndex].id
+            })
+            if (schedule) {
+                schedule.time.push({
+                    week: data.col,
+                    id: data.row.id
+                })
+                this.isUpd = true
+                console.log('ss', schedule)
+            }
+        },
+        //取消课程时段设置
+        cancelCell(data) {
+            console.log('data', data)
+            let schedule = this.courseListShow[this.curCusIndex].schedule.find(item => {
+                return item.classId == this.setCurClass && item.teacher.id == this.teaList[this.curTeaIndex].id
+            })
+            if (schedule) {
+                for (let index in schedule.time) {
+                    if (schedule.time[index].week == data.col && schedule.time[index].id == data.row.id) {
+                        schedule.time.splice(index, 1)
+                        this.isUpd = true
+                        break
+                    }
+                }
+            }
+        },
         //修改上课名单
         updateStuList(listName) {
             this.isUpd = true
@@ -507,6 +561,7 @@ export default {
             this.curClassIndex = 0
             this.curTeaIndex = index
             this.setIsDefault()
+            this.setDefClass()
         },
         /**
          * 添加名单的时候获取名单对应的学生信息
@@ -532,7 +587,6 @@ export default {
                                     item.className = classInfo.name
                                 }
                             })
-                            console.log('ssss', res.stus)
                             curList.students = res.stus
                             curList.full = true
                             this.preStus = res.stus
@@ -1165,6 +1219,12 @@ export default {
                 return []
             }
         },
+        //当前老师课程安排,有设置教室的
+        schdClassList() {
+            return this.schdList.filter(item => {
+                return item.classId
+            })
+        },
         //当前课程的授课老师列表
         teaList() {
             if (this.courseListShow && this.courseListShow[this.curCusIndex] && this.courseListShow[this.curCusIndex].schedule) {

+ 4 - 1
TEAMModelOS/ClientApp/src/view/newcourse/TeaTable.less

@@ -45,9 +45,12 @@
 }
 
 .course-name {
-    padding-top: 12px;
+    padding: 12px 4px 0px 4px;
     font-size: 18px;
     font-weight: 800;
+    text-overflow:ellipsis; 
+    overflow:hidden; 
+    white-space:nowrap; 
 }
 
 .classroom-name {

+ 56 - 18
TEAMModelOS/ClientApp/src/view/newcourse/TeaTable.vue

@@ -8,14 +8,14 @@
                         <Option v-for="(item,index) in teachClassList" :key="index" :value="item.classroomCode">{{item.classroomName}}</Option>
                         <Option value="all">所有课程</Option>
                     </Select> -->
-                    <span class="label">班级: </span>
+                    <!-- <span class="label">班级: </span>
                     <Select v-model="curClass" size="small" style="width: 150px;display:inline-block;">
                         <Option v-for="(item,index) in teachClassList" :key="index" :value="item.classroomCode">{{item.classroomName}}</Option>
                         <Option value="all">所有班级</Option>
-                    </Select>
+                    </Select> -->
                 </div>
             </div>
-            <Table :columns="timeColumns" disabled-hover :data="timetable" border :span-method="handleSpan" style="width:calc(100% - 15px);margin-top:10px;">
+            <Table :columns="timeColumns" disabled-hover :data="timetable" border :span-method="handleSpan" style="width:calc(100% - 15px);margin-top:00px;">
                 <!--上午/下午-->
                 <template slot-scope="{ row, index }" slot="sub">
                     <p style="padding:10px 0px 4px 0px;font-size: 20px;">
@@ -35,8 +35,8 @@
                 <template slot-scope="{ row, index }" slot="MON">
                     <div :class="row.weeklies.MON.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
                         <div class="toggle-status-btn-wrap">
-                            <Icon class="cell-action-icon" type="ios-settings" title="设置课程" @click="showSetCus(row,'MON')" />
-                            <Icon v-if="row.weeklies.MON.courseName" class="cell-action-icon" type="md-trash" title="取消课程" @click="showCancelCus(row,'MON')" />
+                            <Icon class="cell-action-icon" custom="iconfont icon-choose" title="设置课程" @click="selectCell(row,'MON')" />
+                            <Icon v-if="row.weeklies.MON.courseName" class="cell-action-icon" type="md-close" title="取消课程" @click="cancelCell(row,'MON')" />
                         </div>
                         <p class="course-name" v-show="curClass == 'all' || curClass == row.weeklies.MON.classroomCode">{{row.weeklies.MON.courseName}}</p>
                         <p class="classroom-name" v-show="curClass == 'all' || curClass == row.weeklies.MON.classroomCode">{{row.weeklies.MON.classroomName}}</p>
@@ -46,8 +46,8 @@
                 <template slot-scope="{ row, index }" slot="TUE">
                     <div :class="row.weeklies.TUE.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
                         <div class="toggle-status-btn-wrap">
-                            <Icon class="cell-action-icon" type="ios-settings" title="设置课程" @click="showSetCus(row,'TUE')" />
-                            <Icon v-if="row.weeklies.TUE.courseName" class="cell-action-icon" type="md-trash" title="取消课程" @click="showCancelCus(row,'TUE')" />
+                            <Icon class="cell-action-icon" custom="iconfont icon-choose" title="设置课程" @click="selectCell(row,'TUE')" />
+                            <Icon v-if="row.weeklies.TUE.courseName" class="cell-action-icon" type="md-close" title="取消课程" @click="cancelCell(row,'TUE')" />
                         </div>
                         <p class="course-name" v-show="curClass == 'all' || curClass == row.weeklies.TUE.classroomCode">{{row.weeklies.TUE.courseName}}</p>
                         <p class="classroom-name" v-show="curClass == 'all' || curClass == row.weeklies.TUE.classroomCode">{{row.weeklies.TUE.classroomName}}</p>
@@ -57,8 +57,8 @@
                 <template slot-scope="{ row, index }" slot="WED">
                     <div :class="row.weeklies.WED.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
                         <div class="toggle-status-btn-wrap">
-                            <Icon class="cell-action-icon" type="ios-settings" title="设置课程" @click="showSetCus(row,'WED')" />
-                            <Icon v-if="row.weeklies.WED.courseName" class="cell-action-icon" type="md-trash" title="取消课程" @click="showCancelCus(row,'WED')" />
+                            <Icon class="cell-action-icon" custom="iconfont icon-choose" title="设置课程" @click="selectCell(row,'WED')" />
+                            <Icon v-if="row.weeklies.WED.courseName" class="cell-action-icon" type="md-close" title="取消课程" @click="cancelCell(row,'WED')" />
                         </div>
                         <p class="course-name" v-show="curClass == 'all' || curClass == row.weeklies.WED.classroomCode">{{row.weeklies.WED.courseName}}</p>
                         <p class="classroom-name" v-show="curClass == 'all' || curClass == row.weeklies.WED.classroomCode">{{row.weeklies.WED.classroomName}}</p>
@@ -68,8 +68,8 @@
                 <template slot-scope="{ row, index }" slot="THU">
                     <div :class="row.weeklies.THU.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
                         <div class="toggle-status-btn-wrap">
-                            <Icon class="cell-action-icon" type="ios-settings" title="设置课程" @click="showSetCus(row,'THU')" />
-                            <Icon v-if="row.weeklies.THU.courseName" class="cell-action-icon" type="md-trash" title="取消课程" @click="showCancelCus(row,'THU')" />
+                            <Icon class="cell-action-icon" custom="iconfont icon-choose" title="设置课程" @click="selectCell(row,'THU')" />
+                            <Icon v-if="row.weeklies.THU.courseName" class="cell-action-icon" type="md-close" title="取消课程" @click="cancelCell(row,'THU')" />
                         </div>
                         <p class="course-name" v-show="curClass == 'all' || curClass == row.weeklies.THU.classroomCode">{{row.weeklies.THU.courseName}}</p>
                         <p class="classroom-name" v-show="curClass == 'all' || curClass == row.weeklies.THU.classroomCode">{{row.weeklies.THU.classroomName}}</p>
@@ -79,8 +79,8 @@
                 <template slot-scope="{ row, index }" slot="FRI">
                     <div :class="row.weeklies.FRI.status == 1 ? 'week-day-cell':'week-day-cell vact-status'">
                         <div class="toggle-status-btn-wrap">
-                            <Icon class="cell-action-icon" type="ios-settings" title="设置课程" @click="showSetCus(row,'FRI')" />
-                            <Icon v-if="row.weeklies.FRI.courseName" class="cell-action-icon" type="md-trash" title="取消课程" @click="showCancelCus(row,'FRI')" />
+                            <Icon class="cell-action-icon" custom="iconfont icon-choose" title="设置课程" @click="selectCell(row,'FRI')" />
+                            <Icon v-if="row.weeklies.FRI.courseName" class="cell-action-icon" type="md-close" title="取消课程" @click="cancelCell(row,'FRI')" />
                         </div>
                         <p class="course-name" v-show="curClass == 'all' || curClass == row.weeklies.FRI.classroomCode">{{row.weeklies.FRI.courseName}}</p>
                         <p class="classroom-name" v-show="curClass == 'all' || curClass == row.weeklies.FRI.classroomCode">{{row.weeklies.FRI.classroomName}}</p>
@@ -110,6 +110,17 @@ export default {
         periodId: {
             type: String,
             default: ''
+        },
+        //课程对象数据
+        schedData: {
+            type: Array,
+            default: () => {
+                return []
+            }
+        },
+        teacher:{
+            type: String,
+            default:''
         }
     },
     data() {
@@ -120,7 +131,7 @@ export default {
             schoolBase: {
                 period: []
             },
-            tableData: [],
+            classList: [],
             timeColumns: [
                 {
                     title: ' ',
@@ -174,11 +185,13 @@ export default {
         }
     },
     methods: {
-        showSetCus(){
-            
+        selectCell(row, col) {
+            console.log(row, col)
+            this.$emit('selectCell', { row, col })
         },
-        showCancelCus(){
-
+        cancelCell(row, col) {
+            console.log(row, col) 
+            this.$emit('cancelCell', { row, col })
         },
         //根据上下午合并单元格
         handleSpan({ row, column, rowIndex, columnIndex }) {
@@ -208,6 +221,7 @@ export default {
         this.$store.dispatch('user/getSchoolProfile').then(
             res => {
                 this.schoolBase = res.school_base
+                this.classList = res.school_classes
             },
             err => {
                 this.$Message.warning(this.$t('cusMgt.noSchool'))
@@ -243,7 +257,31 @@ export default {
                         SAT: {},
                         SUN: {},
                     }
+                    this.schedData.forEach(cusItem => {
+                        if (cusItem && cusItem.schedule) {
+                            cusItem.schedule.forEach((schedItem, sIndex) => {
+                                let classInfo = this.classList.find(classItem => {
+                                    return classItem.id == schedItem.classId
+                                })
+                                if(this.teacher){
+                                    if(this.teacher != schedItem.teacher.id){
+                                        return false
+                                    }
+                                }
+                                schedItem.time.forEach(timeItem => {
+                                    if (timeItem.id == item.id) {
+                                        console.log('1212', timeItem)
+                                        item.weeklies[timeItem.week].courseName = cusItem.name
+
+                                        item.weeklies[timeItem.week].classroomName = classInfo ? classInfo.name : '暂无数据'
+                                    }
+                                })
+                            })
+
+                        }
+                    })
                 })
+                console.log('timetable', timetable)
                 return timetable
             } else {
                 return []