You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.7 KiB

2 years ago
<template>
<div>
<xy-dialog ref="dialog" :width="30" :is-show.sync="isShow" :type="'form'" title="设定班主任"
:form="form" :rules='rules' @submit="submit">
2 years ago
<template v-slot:teacher_id>
2 years ago
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>班主任
</div>
<div class="xy-table-item-content">
2 years ago
<el-select @change="changeTeachers" v-model="teachers" multiple style="width:100%" placeholder="请选择班主任" clearable>
2 years ago
<el-option v-for="item in teacher_options" :key="item.id" :label="item.name" :value="item.id">
2 years ago
</el-option>
</el-select>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
2 years ago
<script>
import {show,save} from "@/api/course/index.js"
2 years ago
export default {
components: {
},
data() {
return {
isShow: false,
id: '',
2 years ago
teacher_options: [],
2 years ago
form: {
2 years ago
teacher_id: '',
2 years ago
},
2 years ago
teachers:[],
2 years ago
rules: {
2 years ago
teacher_id: [{
2 years ago
required: true,
message: '请选择班主任'
}]
}
}
},
2 years ago
created() {
},
methods: {
setTeachers(e){
this.teacher_options = e
2 years ago
},
changeTeachers(e){
this.teachers = e
this.form.teacher_id = this.teachers.join(",")
2 years ago
},
2 years ago
submit() {
if(this.teachers.length>0){
this.form.teacher_id = this.teachers.join(",")
}
2 years ago
save({
...this.form
}).then(res => {
2 years ago
this.$message({
2 years ago
type: 'success',
2 years ago
message: '设置班主任成功'
2 years ago
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
2 years ago
id: this.id
2 years ago
}).then(res => {
2 years ago
this.form = this.base.deepCopy(res, this.form)
res.teacher_detail.map(item=>{
this.teachers.push(item.id)
})
// this.teachers = this.form.teacher_id?this.form.teacher_id.split(","):[],
// this.$nextTick(function(){
// this.teachers = this.form.teacher_id?this.form.teacher_id.split(","):[]
// })
2 years ago
})
2 years ago
},
2 years ago
},
watch: {
isShow(newVal) {
if (newVal) {
2 years ago
this.getDetail()
2 years ago
} else {
2 years ago
this.id = ''
this.teachers = []
2 years ago
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
2 years ago
::v-deep .teacher_id{
2 years ago
flex-basis: 100%;
}
</style>