Commit a8392967 authored by 王's avatar

期数老师限制

parent b2567ce8
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
:visible.sync="dialogObj.show" :visible.sync="dialogObj.show"
> >
<el-form ref="form" :model="form" label-width="120px"> <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 <el-cascader
:options="goodsList" :options="goodsList"
:props="{value:'id',label:'name'}" :props="{value:'id',label:'name'}"
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</template> </template>
<script> <script>
import {getTeacherListApi,getClassDetailApi,editClassApi,addClassApi,getPeriodsApi,getGoodsListApi} from "../../service/api"; import {getTeacherListApi,getClassDetailApi,editClassApi,addClassApi,getPeriodsApi,getGoodsListApi,getPeriodsTeacherApi} from "../../service/api";
export default { export default {
props:[ props:[
'dialogObj' 'dialogObj'
...@@ -47,18 +47,55 @@ ...@@ -47,18 +47,55 @@
max_join_num:'' max_join_num:''
}, },
teacherList:[], teacherList:[],
exitTeacherList: [],
goodsList: [], goodsList: [],
periods: {} periods: {}
} }
}, },
methods:{ 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=>{
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=>{ getTeacherListApi().then(res=>{
if (this.exitTeacherList.length > 0) {
this.teacherList = this.findDifferentArray(res.list, this.exitTeacherList)
} else {
this.teacherList = res.list this.teacherList = res.list
}
}); });
})
},
initPage(){
this.periods = this.dialogObj.periods
this.getTeacher();
switch (this.dialogObj.type) { switch (this.dialogObj.type) {
case 0: case 0:
if(!this.dialogObj.periodsId){
this.getPeriodList(); this.getPeriodList();
}
this.form = { this.form = {
teacher_id:'', teacher_id:'',
max_join_num:'' max_join_num:''
...@@ -91,12 +128,13 @@ ...@@ -91,12 +128,13 @@
onSave(){ onSave(){
switch (this.dialogObj.type) { switch (this.dialogObj.type) {
case 0: 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({ this.$message({
type: 'success', type: 'success',
message: '添加成功!' message: '添加成功!'
}); });
this.$emit("reflash"); this.$emit("reflash", this.periods);
this.dialogObj.show = false; this.dialogObj.show = false;
}); });
break; break;
...@@ -106,7 +144,7 @@ ...@@ -106,7 +144,7 @@
type: 'success', type: 'success',
message: '修改成功!' message: '修改成功!'
}); });
this.$emit("reflash"); this.$emit("reflash",this.periods);
this.dialogObj.show = false; this.dialogObj.show = false;
}) })
} }
...@@ -121,7 +159,7 @@ ...@@ -121,7 +159,7 @@
if(data.length>1){ if(data.length>1){
let nowGoods = this.goodsList.find(i=>{return i.id === data[0]}); let nowGoods = this.goodsList.find(i=>{return i.id === data[0]});
this.periods = nowGoods.children.find(i=>{return i.id === data[1]}); this.periods = nowGoods.children.find(i=>{return i.id === data[1]});
this.getTeacher() this.getTeacherByPeriods()
} }
} }
}, },
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
</el-table> </el-table>
</div> </div>
<page :nowPage="nowPage" :total="total" :limit="limit" @pageChange="onPageChange"/> <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"/> <user-list :userObj="userObj" @reflash="getClassList"/>
</div> </div>
</template> </template>
...@@ -198,6 +198,7 @@ ...@@ -198,6 +198,7 @@
} }
}, },
getTeacher(){ getTeacher(){
if (!this.periods) return;
getPeriodsTeacherApi(this.periods.id).then(res=>{ getPeriodsTeacherApi(this.periods.id).then(res=>{
this.teacherList = res this.teacherList = res
}) })
...@@ -214,7 +215,13 @@ ...@@ -214,7 +215,13 @@
this.nowPage = val; this.nowPage = val;
this.getClassList(); this.getClassList();
}, },
onReflash(periods){
this.periods = periods;
this.selectedGoods = [periods.goods_id, periods.id];
this.getClassList();
},
getClassList(){ getClassList(){
if (!this.periods) return;
this.getTeacher(); this.getTeacher();
let json = { let json = {
limit: this.limit, limit: this.limit,
...@@ -247,25 +254,33 @@ ...@@ -247,25 +254,33 @@
type: 'success', type: 'success',
message: '删除成功!' message: '删除成功!'
}); });
});
this.getClassList() this.getClassList()
}); });
});
}, },
onAdd(){ onAdd(){
this.dialogObj = { this.dialogObj = {
show:true, show:true,
title:'添加班级', title:'添加班级',
periodsId:this.periods ? this.periods.id : '',
type:0, type:0,
teacherList: this.teacherList ? this.teacherList: []
}
if (this.periods) {
this.dialogObj.periods = this.periods
this.dialogObj.periodsId = this.periods.id
} }
}, },
editClass(data){ editClass(data){
this.dialogObj = { this.dialogObj = {
show:true, show:true,
title:'编辑班级', title:'编辑班级',
periodsId:this.periods.id,
type:1, 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 @@ ...@@ -118,7 +118,7 @@
searchFrom: {}, searchFrom: {},
userList: [], userList: [],
nowPage: 1, nowPage: 1,
limit: 1, limit: 5,
total:0, total:0,
searchFrom: { searchFrom: {
userId:'', 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