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.

171 lines
4.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<xy-dialog ref="dialog" :width="40" :is-show.sync="isShow" :type="'form'"
:title="type === 'add' ? '新增授课老师信息' : '编辑授课老师信息'" :form="form" :rules='rules' @submit="submit">
<template v-slot:name>
<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">
<el-input v-model="form.name" placeholder="请输入授课老师" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:introduce>
<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">
<el-input v-model="form.introduce" type="textarea" placeholder="请输入老师简介" clearable
style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:sex>
<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">
<el-select v-model="form.sex" placeholder="请选择" clearable style="width: 100%;">
<el-option v-for="item in sex_options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:mobile>
<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">
<el-input v-model="form.mobile" placeholder="请输入联系方式" clearable style="width: 100%;"></el-input>
</div>
</div>
</template>
<template v-slot:remark>
<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">
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" clearable
style="width: 100%;"></el-input>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
show,
save
} from "@/api/info/teachers.js"
export default {
components: {
},
data() {
return {
isShow: false,
type: 'add',
action: '',
id: '',
form: {
name: '',
introduce: '',
sex: '',
mobile: '',
remark: ''
},
sex_options: [{
label: '男',
value: '男'
}, {
label: '女',
value: '女'
}],
rules: {
name: [{
required: true,
message: '请输入姓名'
}],
sex: [{
required: true,
message: '请选择性别'
}],
// mobile: [{
// required: true,
// message: '请输入联系方式'
// }]
}
}
},
created() {},
methods: {
submit() {
if (this.id) {
this.form.id = this.id
}
if (this.type == 'add') {
this.form.id = ''
}
save(this.form).then(res => {
this.$message({
type: 'success',
message: this.type === 'add' ? '新增授课老师成功' : '编辑授课老师成功'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
}
} else {
this.id = ''
this.form = {
name: '',
introduce: '',
sex: '',
mobile: '',
remark: ''
}
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .name,
::v-deep .sex,
::v-deep .introduce,
::v-deep .mobile {
flex-basis: 100%;
}
</style>