This commit is contained in:
guochunsi
2026-01-16 15:04:30 +08:00
parent 358b08bb79
commit 2169bfee92
5 changed files with 374 additions and 316 deletions

View File

@@ -4,7 +4,6 @@
:close-on-click-modal="false"
v-model="visible"
width="600px"
destroy-on-close
>
<el-form :model="dataForm" :rules="dataRule" ref="dataFormRef" @keyup.enter="dataFormSubmit" label-width="120px">
<el-form-item label="招生计划" prop="groupId">
@@ -103,9 +102,6 @@ const initData = () => {
})
getList().then((data: any) => {
planList.value = data.data
if (!dataForm.id) {
dataForm.groupId = planList.value[0]?.id || null
}
})
// 获取所有省
areaList({ type: "0", parentId: 112 }).then((res: any) => {
@@ -147,21 +143,42 @@ const dataFormSubmit = () => {
// 初始化方法
const init = (id: string | null) => {
dataForm.id = id || null
visible.value = true
canSubmit.value = true
initData()
dataForm.id = ""
// 重置表单数据
nextTick(() => {
dataFormRef.value?.resetFields()
if (dataForm.id) {
getObj(dataForm.id).then((response: any) => {
})
initData()
// 获取详情数据
if (id) {
dataForm.id = id
getObj(id).then((response: any) => {
if (response && response.data) {
Object.assign(dataForm, response.data)
if (dataForm.area) {
dataForm.area = String(dataForm.area)
}
})
}
})
// 确保 deptCode 正确映射(如果 API 返回的是 xy 字段)
if (response.data.xy && !response.data.deptCode) {
dataForm.deptCode = response.data.xy
}
}
}).catch(() => {
// 错误处理
})
} else {
// 新增模式:设置默认招生计划
getList().then((data: any) => {
if (data.data && data.data.length > 0) {
dataForm.groupId = data.data[0]?.id || ""
}
})
}
}
// 暴露方法给父组件