This commit is contained in:
guochunsi
2026-01-27 15:59:17 +08:00
parent 74790f7ae9
commit c07d9a3350

View File

@@ -252,64 +252,79 @@ const dataRule = {
/**
* 判断市平台招生专业是否占用,占用不可选
*/
const isCityDisable = (id: string) => {
if (!dataForm.cityPlanIds || !Array.isArray(dataForm.cityPlanIds)) {
return false
}
return dataForm.cityPlanIds.some(e => e == id)
}
// const isCityDisable = (id: string) => {
// if (!dataForm.cityPlanIds || !Array.isArray(dataForm.cityPlanIds)) {
// return false
// }
// return dataForm.cityPlanIds.some(e => e == id)
// }
// 设置费用默认值
const setFeeDefaults = () => {
if (tuitionFeeList.value.length > 0) {
// 初中费用:字典值 1
const czFeeItem = tuitionFeeList.value.find((item: any) => item.value === '1')
const czFeeItem = tuitionFeeList.value.find((item: any) => item.label === '1')
if (czFeeItem) {
dataForm.czFee = Number(czFeeItem.label) || 0
dataForm.czFee = Number(czFeeItem.value) || 0
}
// 高中费用:字典值 2
const gzFeeItem = tuitionFeeList.value.find((item: any) => item.value === '2')
const gzFeeItem = tuitionFeeList.value.find((item: any) => item.label === '2')
if (gzFeeItem) {
dataForm.gzFee = Number(gzFeeItem.label) || 0
dataForm.gzFee = Number(gzFeeItem.value) || 0
}
// 技职校费用:字典值 3
const jzxFeeItem = tuitionFeeList.value.find((item: any) => item.value === '3')
const jzxFeeItem = tuitionFeeList.value.find((item: any) => item.label === '3')
if (jzxFeeItem) {
dataForm.jzxFee = Number(jzxFeeItem.label) || 0
dataForm.jzxFee = Number(jzxFeeItem.value) || 0
}
}
}
// 初始化数据
const initData = () => {
const initData = (id: string | null) => {
// 查询二级学院信息
getDeptList().then((data: any) => {
deptList.value = data.data
})
// 获取招生计划列表
getList().then((data: any) => {
planList.value = data.data
// 新增时,默认选中第一个招生计划
if (!id && data.data && data.data.length > 0) {
dataForm.groupId = data.data[0]?.id || ''
}
})
// 获取正式专业代码列表
getMajorNameList().then((data: any) => {
offcialZydmList.value = data.data
})
// 获取数据字典(一次获取多个)
getDictsByTypes(['basic_major_years', 'basic_major_level', 'tuition_fee']).then((res: any) => {
majorYears.value = res.data?.basic_major_years || []
ccList.value = res.data?.basic_major_level || []
tuitionFeeList.value = res.data?.tuition_fee || []
// 新增时,根据学费字典设置费用默认值
if (!id) {
setFeeDefaults()
}
})
}
// 表单提交
const dataFormSubmit = () => {
if (dataForm.cityPlanId != null) {
cityPlanIdList.value.forEach(e => {
if (e.id == dataForm.cityPlanId) {
dataForm.cityPlanName = e.schoolMajorName
dataForm.cityPlanYear = e.educational
}
})
}
// if (dataForm.cityPlanId != null) {
// cityPlanIdList.value.forEach(e => {
// if (e.id == dataForm.cityPlanId) {
// dataForm.cityPlanName = e.schoolMajorName
// dataForm.cityPlanYear = e.educational
// }
// })
// }
dataFormRef.value?.validate((valid: boolean) => {
if (valid) {
canSubmit.value = false
@@ -351,7 +366,7 @@ const init = (id: string | null) => {
dataFormRef.value?.resetFields()
})
initData()
initData(id)
// 获取详情数据
if (id) {
@@ -368,17 +383,7 @@ const init = (id: string | null) => {
// 错误处理
})
} else {
// 新增模式:设置默认招生计划和费用默认值
getList().then((data: any) => {
if (data.data && data.data.length > 0) {
dataForm.groupId = data.data[0]?.id || ""
}
})
// 等待字典数据加载完成后设置费用默认值
getDictsByTypes(['tuition_fee']).then((res: any) => {
tuitionFeeList.value = res.data?.tuition_fee || []
setFeeDefaults()
})
// 新增模式:initData 中已处理默认招生计划和费用默认值
}
}