新增教员页面,下拉框乱码修复,保存报错修复

This commit is contained in:
2026-09-15 15:54:06 +08:00
parent 3905e5cb54
commit 9312327112
2 changed files with 192 additions and 12 deletions
@@ -98,6 +98,32 @@
>
<el-form ref="addFormRef" :model="addForm" :rules="addRules" label-width="160px" class="add-form">
<el-divider content-position="left">教员基本信息</el-divider>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="教员工号" prop="teacher.jybh">
<el-input v-model="addForm.teacher.jybh" placeholder="选填,留空由系统自动生成" maxlength="50" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="教研室" prop="teacher.jysdh">
<el-select
v-model="addForm.teacher.jysdh"
filterable
clearable
placeholder="请选择所属教研室"
:loading="officeLoading"
style="width:100%"
>
<el-option
v-for="item in officeOptions"
:key="item.jysdh"
:label="item.jysmc"
:value="item.jysdh"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="教员姓名" prop="teacher.jyxm"><el-input v-model="addForm.teacher.jyxm" placeholder="请输入" /></el-form-item>
@@ -608,6 +634,7 @@ import {
getTeacherAttribute,
updateTeacherAttribute
} from '@/api/teachOffice/teacher'
import { listOffice } from '@/api/teachOffice/office'
import { getDicts } from '@/api/system/dict/data'
export default {
@@ -629,6 +656,8 @@ export default {
addForm: this.createEmptyAddForm(),
addRules: {
'teacher.jyxm': [{ required: true, message: '请输入教员姓名', trigger: 'blur' }],
'teacher.jysdh': [{ required: true, message: '请选择所属教研室', trigger: 'change' }],
'teacher.jybh': [{ max: 50, message: '教员工号不能超过 50 个字符', trigger: 'blur' }],
'teacher.xh': [{ required: true, message: '请输入序号', trigger: 'blur' }],
'teacher.zyjszwdj': [{ required: true, message: '请输入专业技术职务等级', trigger: 'blur' }],
@@ -679,12 +708,16 @@ export default {
zyjszwdjOptions: [],
jylbOptions: [],
zzlbOptions: [],
dslbOptions: []
dslbOptions: [],
// 教研室下拉(新增教员时选择所属教研室)
officeOptions: [],
officeLoading: false
}
},
mounted() {
this.fetchList()
this.loadDicts()
this.loadOfficeOptions()
},
methods: {
/** 统一格式化后端 LocalDateTime(去除 T、截断到秒) */
@@ -726,6 +759,29 @@ export default {
getDicts('teacher_dslb').then(res => { this.dslbOptions = res.data || [] }).catch(() => {})
},
/** 加载教研室下拉:教员表 [教研室代号] 为非空外键,新增时必须选择 */
loadOfficeOptions() {
this.officeLoading = true
listOffice({ pageNum: 1, pageSize: 500 }).then(response => {
const data = response.data || {}
const rows = data.records || []
const seen = {}
const options = []
rows.forEach(row => {
const jysdh = row.jysdh
// 已停用(ty=1)的教研室不再参与新建教员
if (!jysdh || seen[jysdh] || Number(row.ty) === 1) return
seen[jysdh] = true
options.push({ jysdh, jysmc: row.jysmc || jysdh })
})
this.officeOptions = options
}).catch(() => {
this.officeOptions = []
}).finally(() => {
this.officeLoading = false
})
},
cleanPayload(obj) {
const payload = {}
Object.keys(obj).forEach(key => {