1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
<el-dialog
:title="dialogObj.title"
:visible.sync="dialogObj.show"
>
<el-form ref="form" :model="form" label-width="120px">
<el-form-item label="老师">
<el-select v-model="form.teacher_id" placeholder="请选择">
<el-option
v-for="(data,index) in teacherList"
:key="index"
:label="data.name"
:value="data.id">
</el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogObj.show = false">取 消</el-button>
<el-button type="primary" @click="onSave">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import {getTeacherListApi,addRelatedTeacherApi} from "../../service/api";
export default {
props:[
'dialogObj'
],
data(){
return{
form:{
id: '',
teacher_id:'',
},
teacherList:[],
}
},
methods:{
initPage(){
let json ={
page:1,
limit:200
}
getTeacherListApi(json).then(res=>{
this.teacherList = res.list;
});
this.form = {
id: this.dialogObj.id,
teacher_id: this.dialogObj.teacher_id ? this.dialogObj.teacher_id : ''
};
},
onSave(){
let json = {
teacher_id: this.form.teacher_id ? this.form.teacher_id : 0
};
addRelatedTeacherApi(this.form.id, json).then(res => {
this.$message({
type: 'success',
message: '绑定成功!'
});
this.$emit("reflash");
this.dialogObj.show = false;
})
}
},
watch:{
'dialogObj'(value){
this.initPage()
}
}
}
</script>
<style scoped>
</style>