Commit fd7a86f4 authored by 王's avatar

期数老师观摩带班老师不重复

parent 4d88aba8
......@@ -46,9 +46,9 @@
</el-date-picker>
</el-form-item>
<el-form-item label="带班老师" prop="teacherList" v-if = "!form.id">
<el-select v-model="form.teacherList" multiple placeholder="请选择">
<el-select v-model="form.teacherList" multiple placeholder="请选择" @change="onTeacher1Change">
<el-option
v-for="item in teacherOptions"
v-for="item in teacher1Options"
:key="item.id"
:label="item.name"
:value="item.id">
......@@ -56,9 +56,9 @@
</el-select>
</el-form-item>
<el-form-item label="观摩老师" prop="viewTeacher" v-if = "!form.id">
<el-select v-model="form.viewTeacher" placeholder="请选择">
<el-select v-model="form.viewTeacher" placeholder="请选择" @change="onTeacher2Change">
<el-option
v-for="item in teacherOptions"
v-for="item in teacher2Options"
:key="item.id"
:label="item.name"
:value="item.id">
......@@ -135,6 +135,8 @@
}
],
teacherOptions: [],
teacher1Options: [],
teacher2Options: [],
goodList: [],
itemOptions: [],
rules:{
......@@ -187,14 +189,6 @@
},
methods:{
sub(){
// if (!this.teacherList) {
// this.$message.error('请选择老师ID');
// return;
// }
// if (!this.viewTeacher) {
// this.$message.error('请选择观摩老师');
// return;
// }
this.$refs['form'].validate((valid) => {
if(valid){
let _id = this.form.goods_id;
......@@ -229,8 +223,36 @@
getTeachers(){
getTeacherListApi().then((res)=>{
this.teacherOptions = res.list;
this.teacher1Options = res.list;
this.teacher2Options = res.list;
})
},
findDifferentArray(array1, array2){
let newArray = []
array1.forEach((val)=>{
let index = array2.findIndex((item)=>{
return val.id == item
})
if (index === -1) {
newArray.push(val)
}
})
return newArray
},
onTeacher1Change(ids){
if(ids){
this.teacher2Options = this.findDifferentArray(this.teacherOptions, ids)
} else {
this.teacher2Options = this.teacherOptions
}
},
onTeacher2Change(id){
if(id){
this.teacher1Options = this.findDifferentArray(this.teacherOptions, [id])
} else {
this.teacher1Options = this.teacherOptions
}
},
onOptionChange(id){
let index = this.goodList.findIndex((val)=>{ return val.id = id});
if(index >-1){
......@@ -238,7 +260,6 @@
}
},
getLessonDetail(id){
console.log('getLessonDetail', id);
this.form.start_num=''
getLessonDetailApi(id,{}).then((res) => {
this.itemOptions = res.detail[res.type]
......
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