Commit a8392967 authored by 王's avatar

期数老师限制

parent b2567ce8
......@@ -4,7 +4,7 @@
:visible.sync="dialogObj.show"
>
<el-form ref="form" :model="form" label-width="120px">
<el-form-item label="期数" v-if="this.dialogObj.type !==1">
<el-form-item label="期数" v-if="!this.dialogObj.periodsId">
<el-cascader
:options="goodsList"
:props="{value:'id',label:'name'}"
......@@ -35,7 +35,7 @@
</template>
<script>
import {getTeacherListApi,getClassDetailApi,editClassApi,addClassApi,getPeriodsApi,getGoodsListApi} from "../../service/api";
import {getTeacherListApi,getClassDetailApi,editClassApi,addClassApi,getPeriodsApi,getGoodsListApi,getPeriodsTeacherApi} from "../../service/api";
export default {
props:[
'dialogObj'
......@@ -47,18 +47,55 @@
max_join_num:''
},
teacherList:[],
exitTeacherList: [],
goodsList: [],
periods: {}
}
},
methods:{
initPage(){
findDifferentArray(array1, array2){
let newArray = []
array1.forEach((val)=>{
let index = array2.findIndex((item)=>{
return item.teacher_id == val.id
})
if (index === -1) {
newArray.push(val)
}
})
return newArray
},
getTeacher(){
this.exitTeacherList = this.dialogObj.teacherList.length > 0 ? this.dialogObj.teacherList : [];
getTeacherListApi().then(res=>{
this.teacherList = res.list
if (this.exitTeacherList.length > 0) {
this.teacherList = this.findDifferentArray(res.list, this.exitTeacherList)
} else {
this.teacherList = res.list
}
});
},
getTeacherByPeriods(){
getPeriodsTeacherApi(this.periods.id).then(res1=>{
this.exitTeacherList = res1
getTeacherListApi().then(res=>{
if (this.exitTeacherList.length > 0) {
this.teacherList = this.findDifferentArray(res.list, this.exitTeacherList)
} else {
this.teacherList = res.list
}
});
})
},
initPage(){
this.periods = this.dialogObj.periods
this.getTeacher();
switch (this.dialogObj.type) {
case 0:
this.getPeriodList();
if(!this.dialogObj.periodsId){
this.getPeriodList();
}
this.form = {
teacher_id:'',
max_join_num:''
......@@ -91,12 +128,13 @@
onSave(){
switch (this.dialogObj.type) {
case 0:
addClassApi(this.periods.id,this.form).then(res=>{
let id = this.dialogObj.periodsId ? this.dialogObj.periodsId : this.periods.id;
addClassApi(id,this.form).then(res=>{
this.$message({
type: 'success',
message: '添加成功!'
});
this.$emit("reflash");
this.$emit("reflash", this.periods);
this.dialogObj.show = false;
});
break;
......@@ -106,7 +144,7 @@
type: 'success',
message: '修改成功!'
});
this.$emit("reflash");
this.$emit("reflash",this.periods);
this.dialogObj.show = false;
})
}
......@@ -121,7 +159,7 @@
if(data.length>1){
let nowGoods = this.goodsList.find(i=>{return i.id === data[0]});
this.periods = nowGoods.children.find(i=>{return i.id === data[1]});
this.getTeacher()
this.getTeacherByPeriods()
}
}
},
......
......@@ -103,7 +103,7 @@
</el-table>
</div>
<page :nowPage="nowPage" :total="total" :limit="limit" @pageChange="onPageChange"/>
<class-dialog :dialogObj="dialogObj" @reflash="getClassList"></class-dialog>
<class-dialog :dialogObj="dialogObj" @reflash="onReflash"></class-dialog>
<user-list :userObj="userObj" @reflash="getClassList"/>
</div>
</template>
......@@ -198,6 +198,7 @@
}
},
getTeacher(){
if (!this.periods) return;
getPeriodsTeacherApi(this.periods.id).then(res=>{
this.teacherList = res
})
......@@ -214,7 +215,13 @@
this.nowPage = val;
this.getClassList();
},
onReflash(periods){
this.periods = periods;
this.selectedGoods = [periods.goods_id, periods.id];
this.getClassList();
},
getClassList(){
if (!this.periods) return;
this.getTeacher();
let json = {
limit: this.limit,
......@@ -247,25 +254,33 @@
type: 'success',
message: '删除成功!'
});
this.getClassList()
});
this.getClassList()
});
},
onAdd(){
this.dialogObj = {
show:true,
title:'添加班级',
periodsId:this.periods ? this.periods.id : '',
type:0,
teacherList: this.teacherList ? this.teacherList: []
}
if (this.periods) {
this.dialogObj.periods = this.periods
this.dialogObj.periodsId = this.periods.id
}
},
editClass(data){
this.dialogObj = {
show:true,
title:'编辑班级',
periodsId:this.periods.id,
type:1,
id:data.id
id:data.id,
teacherList: this.teacherList ? this.teacherList: []
}
if (this.periods) {
this.dialogObj.periods = this.periods
this.dialogObj.periodsId = this.periods.id
}
}
}
......
......@@ -118,7 +118,7 @@
searchFrom: {},
userList: [],
nowPage: 1,
limit: 1,
limit: 5,
total:0,
searchFrom: {
userId:'',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment