退伍复学-材料上传

This commit is contained in:
2026-03-10 15:58:12 +08:00
parent 9224b75cfe
commit 8652ddf7b3
2 changed files with 112 additions and 270 deletions

View File

@@ -1170,118 +1170,53 @@ export default {
}
},
methods: {
// 班级选择事件仅更新ID不处理名称
// handleChange1(value) {
// if (value && value.length === 3) {
// const [gradeId, majorId, classId] = value;
// // 仅更新子表的ID字段名称仅前端展示不提交给后端
// this.$set(this.form.maList[0], 'finaldata1', gradeId); // 年级ID
// this.$set(this.form.maList[0], 'finaldata2', majorId); // 专业ID
// this.$set(this.form.maList[0], 'newmajor', classId); // 班级ID
// // finalClassName 仅用于前端展示,不提交
// const gradeItem = this.ClassNameList.find(item => item.value === gradeId);
// if (gradeItem) {
// const majorItem = gradeItem.children.find(item => item.value === majorId);
// if (majorItem) {
// const classItem = majorItem.children.find(item => item.value === classId);
// if (classItem) {
// this.finalClassName = classItem.label; // 仅前端展示
// }
// }
// }
// }
// },
handleChange1(value) {
if (value && value.length === 3) {
const [gradeId, majorId, classId] = value;
// 1. 更新存储用的ID字段
this.$set(this.form.maList[0], 'finaldata1', gradeId);
this.$set(this.form.maList[0], 'finaldata2', majorId);
this.$set(this.form.maList[0], 'newmajor', classId);
this.$set(this.form.maList[0], 'finalmajor', classId);
handleChange1(value) {
if (value && value.length === 3) {
const [gradeId, majorId, classId] = value;
// 1. 更新存储用的ID字段
this.$set(this.form.maList[0], 'finaldata1', gradeId);
this.$set(this.form.maList[0], 'finaldata2', majorId);
this.$set(this.form.maList[0], 'newmajor', classId);
this.$set(this.form.maList[0], 'finalmajor', classId);
// 2. 查找班级名称
const gradeItem = this.ClassNameList.find(item => item.value === gradeId);
if (gradeItem) {
const majorItem = gradeItem.children.find(item => item.value === majorId);
if (majorItem) {
const classItem = majorItem.children.find(item => item.value === classId);
if (classItem) {
this.finalClassName = classItem.label;
// 2. 查找班级名称
const gradeItem = this.ClassNameList.find(item => item.value === gradeId);
if (gradeItem) {
const majorItem = gradeItem.children.find(item => item.value === majorId);
if (majorItem) {
const classItem = majorItem.children.find(item => item.value === classId);
if (classItem) {
this.finalClassName = classItem.label;
}
}
}
// 关键修复:从年级列表中查找年级名称,而不是直接使用 gradeItem.label
const selectedGrade = this.grade_list.find(item => item.gradeId === gradeId);
if (selectedGrade) {
this.finalGradeName = selectedGrade.gradeName; // 正确的年级名称
this.$set(this.form.maList[0], 'finallabel', selectedGrade.gradeId); // 正确的年级ID
}
}
}
// 关键修复:从年级列表中查找年级名称,而不是直接使用 gradeItem.label
const selectedGrade = this.grade_list.find(item => item.gradeId === gradeId);
if (selectedGrade) {
this.finalGradeName = selectedGrade.gradeName; // 正确的年级名称
this.$set(this.form.maList[0], 'finallabel', selectedGrade.gradeId); // 正确的年级ID
}
}
},
// 年级选择事件仅更新ID不处理名称
// handleGradeChange(value) {
// const selectedGrade = this.grade_list.find(item => item.gradeId === value);
// if (selectedGrade) {
// // 仅更新子表的ID字段名称仅前端展示
// this.$set(this.form.maList[0], 'finallabel', value); // 年级ID存储用
// this.$set(this.form.maList[0], 'finalmajor', value); // 年级ID选择框绑定
// this.finalGradeName = selectedGrade.gradeName; // 仅前端展示
// }
// },
handleGradeChange(value) {
const selectedGrade = this.grade_list.find(item => item.gradeId === value);
if (selectedGrade) {
// 1. 更新存储用的年级ID
this.$set(this.form.maList[0], 'finallabel', value);
// 2. 同步更新显示用的年级名称(这里必须是 selectedGrade.gradeName
this.finalGradeName = selectedGrade.gradeName;
// 3. 清空班级选择,避免年级和班级不匹配
this.classVlue1 = [];
this.finalClassName = null;
this.$set(this.form.maList[0], 'finaldata1', '');
this.$set(this.form.maList[0], 'finaldata2', '');
this.$set(this.form.maList[0], 'newmajor', '');
this.$set(this.form.maList[0], 'finalmajor', '');
}
},
// handleChange1(value) {
// if (value && value.length === 3) {
// const [gradeId, majorId, classId] = value;
// // 从ClassNameList中找到对应班级名称
// const gradeItem = this.ClassNameList.find(item => item.value === gradeId);
// if (gradeItem) {
// const majorItem = gradeItem.children.find(item => item.value === majorId);
// if (majorItem) {
// const classItem = majorItem.children.find(item => item.value === classId);
// if (classItem) {
// this.finalClassName = classItem.label;
// // 【关键修改】实时更新form.maList[0]的字段,确保提交时能拿到最新值
// this.$set(this.form.maList[0], 'finaldata1', gradeId); // 年级ID
// this.$set(this.form.maList[0], 'finaldata2', majorId); // 专业ID
// this.$set(this.form.maList[0], 'newmajor', classId); // 班级ID
// this.$set(this.form.maList[0], 'finalClassName', classItem.label); // 班级名称
// }
// }
// }
// }
// },
// handleGradeChange(value) {
// // 3. 选择框值变更时,同步更新显示名称和存储字段
// const selectedGrade = this.grade_list.find(item => item.gradeId === value);
// if (selectedGrade) {
// this.finalGradeName = selectedGrade.gradeName; // 更新显示名称
// // 【关键修改】实时更新form.maList[0]的字段
// this.$set(this.form.maList[0], 'finallabel', value); // 年级ID存储用
// this.$set(this.form.maList[0], 'finalmajor', value); // 年级ID选择框绑定
// this.$set(this.form.maList[0], 'finalGradeName', selectedGrade.gradeName); // 年级名称
// }
// },
},
handleGradeChange(value) {
const selectedGrade = this.grade_list.find(item => item.gradeId === value);
if (selectedGrade) {
// 1. 更新存储用的年级ID
this.$set(this.form.maList[0], 'finallabel', value);
// 2. 同步更新显示用的年级名称(这里必须是 selectedGrade.gradeName
this.finalGradeName = selectedGrade.gradeName;
// 3. 清空班级选择,避免年级和班级不匹配
this.classVlue1 = [];
this.finalClassName = null;
this.$set(this.form.maList[0], 'finaldata1', '');
this.$set(this.form.maList[0], 'finaldata2', '');
this.$set(this.form.maList[0], 'newmajor', '');
this.$set(this.form.maList[0], 'finalmajor', '');
}
},
penaltyTypeMethodFormat(row, column) {
return this.selectDictLabel(this.dict.type.rt_penalty_type, row.penaltyType)
},
@@ -1357,57 +1292,38 @@ handleGradeChange(value) {
// 退伍复学申请表单数据
getBasicApplication(startUser) {
// // let newName = this.startUser.replace(/-/g, "");
// let newName = this.startUser.split('-')[0].trim();
// getStname(newName).then((res) => {
// // console.log("后端返回原始数据:",res.data);
// this.form = res.data
let newName = this.startUser.split('-')[0].trim();
getStname(newName).then((res) => {
console.log("后端返回原始数据:", res.data);
// 深拷贝确保数据不被污染
this.form = JSON.parse(JSON.stringify(res.data));
// // 1. 初始化选择框绑定的核心字段finalmajor
// if (this.form.maList && this.form.maList.length > 0) {
// // 从maList中读取已保存的年级ID赋值给finalmajor选择框绑定字段
// this.$set(this.form.maList[0], 'finalmajor', this.form.maList[0].finallabel || '');
// } else {
// // 若无数据初始化空值避免undefined
// this.form.maList = [{ finalmajor: '', finallabel: '' }];
// }
// 初始化maList防止空指针
if (!this.form.maList || this.form.maList.length === 0) {
this.form.maList = [{
finalmajor: '',
finallabel: '',
finaldata1: '',
finaldata2: '',
newmajor: '',
finalClassName: '',
finalGradeName: ''
}];
}
// this.getClassNameList()
// this.listGrade()
// this.getXWClassNameList()
// });
let newName = this.startUser.split('-')[0].trim();
getStname(newName).then((res) => {
console.log("后端返回原始数据:", res.data);
// 深拷贝确保数据不被污染
this.form = JSON.parse(JSON.stringify(res.data));
// 1. 初始化选择框绑定的核心字段finalmajor
this.$set(this.form.maList[0], 'finalmajor', this.form.maList[0].finallabel || '');
// 初始化maList防止空指针
if (!this.form.maList || this.form.maList.length === 0) {
this.form.maList = [{
finalmajor: '',
finallabel: '',
finaldata1: '',
finaldata2: '',
newmajor: '',
finalClassName: '',
finalGradeName: ''
}];
}
// 1. 初始化选择框绑定的核心字段finalmajor
this.$set(this.form.maList[0], 'finalmajor', this.form.maList[0].finallabel || '');
// 确保数据加载完成后再渲染下拉列表
this.$nextTick(() => {
this.getClassNameList();
this.listGrade();
this.getXWClassNameList();
});
}).catch(error => {
console.error("获取退伍复学数据失败:", error);
this.$modal.msgError("获取学生信息失败,请刷新页面重试");
});
// 确保数据加载完成后再渲染下拉列表
this.$nextTick(() => {
this.getClassNameList();
this.listGrade();
this.getXWClassNameList();
});
}).catch(error => {
console.error("获取退伍复学数据失败:", error);
this.$modal.msgError("获取学生信息失败,请刷新页面重试");
});
},
/** 获取班级名称列表 */
getClassNameList() {
@@ -1434,126 +1350,37 @@ handleGradeChange(value) {
})
},
// 获取学务班级名称列表
// getXWClassNameList() {
// getClassName().then(res => {
// this.ClassNameList = res.data
// // console.log(this.ClassNameList)
// if (this.ClassNameList != null) {
// this.ClassNameList.forEach(element => {
// if (element.value == this.form.maList[0].finaldata1) {
// // console.log(element.label)
// element.children.forEach(elementTwo => {
// if (elementTwo.value == this.form.maList[0].finaldata2) {
// // console.log(elementTwo.label)
// // this.saveClassName =elementTwo.label
// elementTwo.children.forEach(elementFree => {
// this.finalClassName = elementFree.label
// this.classVlue1 = [element.value, elementTwo.value, elementFree.value];
// // console.log(elementFree.label)
// });
// }
// });
// }
// });
// }
// })
// },
// getXWClassNameList() {
// getClassName().then(res => {
// this.ClassNameList = res.data;
// if (this.ClassNameList != null) {
// this.ClassNameList.forEach(element => {
// if (element.value == this.form.maList[0].finaldata1) {
// element.children.forEach(elementTwo => {
// if (elementTwo.value == this.form.maList[0].finaldata2) {
// elementTwo.children.forEach(elementFree => {
// if (elementFree.value == this.form.maList[0].newmajor) {
// this.finalClassName = elementFree.label;
// this.classVlue1 = [element.value, elementTwo.value, elementFree.value];
// // 同步更新年级名称
// this.finalGradeName = element.label;
// this.$set(this.form.maList[0], 'finallabel', element.value);
// }
// });
// }
// });
// }
// });
// }
// })
// },
getXWClassNameList() {
getClassName().then(res => {
this.ClassNameList = res.data;
if (this.ClassNameList != null) {
this.ClassNameList.forEach(element => {
if (element.value == this.form.maList[0].finaldata1) {
element.children.forEach(elementTwo => {
if (elementTwo.value == this.form.maList[0].finaldata2) {
elementTwo.children.forEach(elementFree => {
if (elementFree.value == this.form.maList[0].newmajor) {
this.finalClassName = elementFree.label;
this.classVlue1 = [element.value, elementTwo.value, elementFree.value];
// 关键修复:从年级列表中查找年级名称,而不是直接使用 element.label
const gradeId = element.value;
const gradeItem = this.grade_list.find(item => item.gradeId === gradeId);
if (gradeItem) {
this.finalGradeName = gradeItem.gradeName; // 正确的年级名称
this.$set(this.form.maList[0], 'finallabel', gradeItem.gradeId); // 正确的年级ID
}
getClassName().then(res => {
this.ClassNameList = res.data;
if (this.ClassNameList != null) {
this.ClassNameList.forEach(element => {
if (element.value == this.form.maList[0].finaldata1) {
element.children.forEach(elementTwo => {
if (elementTwo.value == this.form.maList[0].finaldata2) {
elementTwo.children.forEach(elementFree => {
if (elementFree.value == this.form.maList[0].newmajor) {
this.finalClassName = elementFree.label;
this.classVlue1 = [element.value, elementTwo.value, elementFree.value];
// 关键修复:从年级列表中查找年级名称,而不是直接使用 element.label
const gradeId = element.value;
const gradeItem = this.grade_list.find(item => item.gradeId === gradeId);
if (gradeItem) {
this.finalGradeName = gradeItem.gradeName; // 正确的年级名称
this.$set(this.form.maList[0], 'finallabel', gradeItem.gradeId); // 正确的年级ID
}
}
});
}
});
}
});
}
});
}
})
},
})
},
/** 获取年级列表 */
// async listGrade() {
// try {
// let res = await listGrade()
// if (res.code == 200) {
// this.grade_list = [...res.rows]
// console.log(this.grade_list)
// this.grade_list.forEach(element => {
// // console.log("newgrade",this.form.maList[0].newgrade)
// if (element.gradeId == this.form.maList[0].newgrade) {
// this.saveGradeName = element.gradeName
// }
// if (element.gradeId == this.form.maList[0].finallabel) {
// this.finalGradeName = element.gradeName
// // this.$set(this.form.maList[0], 'finalmajor', element.gradeId);
// }
// });
// }
// } catch (error) {
// console.error('获取年级列表失败:', error)
// }
// },
// async listGrade() {
// try {
// let res = await listGrade();
// if (res.code == 200) {
// this.grade_list = [...res.rows];
// this.grade_list.forEach(element => {
// if (element.gradeId == this.form.maList[0].newgrade) {
// this.saveGradeName = element.gradeName;
// }
// if (element.gradeId == this.form.maList[0].finallabel) {
// this.finalGradeName = element.gradeName;
// }
// });
// }
// } catch (error) {
// console.error('获取年级列表失败:', error);
// }
// },
async listGrade() {
try {
let res = await listGrade(); // 调用后端接口获取年级列表

View File

@@ -87,6 +87,21 @@
</div> -->
</el-card>
<!-- 材料上传 -->
<el-card class="box-card1" v-if="form.conversion === 'N'">
<el-form ref="form2" :model="form" :rules="rules2" label-width="80px">
<el-form-item label="退役证明" prop="proof">
<image-upload v-model="form.proof" />
</el-form-item>
<el-form-item label="身份证" prop="idcard">
<image-upload v-model="form.idcard" />
</el-form-item>
<el-form-item label="材料" prop="material">
<image-upload v-model="form.material" />
</el-form-item>
</el-form>
</el-card>
<!-- 转专业材料上传 -->
<el-card class="box-card1" v-if="form.conversion === 'Y'">
<el-form ref="form2" :model="form" :rules="rules2" label-width="80px">
@@ -109,8 +124,8 @@
<span>{{ data.label }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item> -->
</el-cascader>
</el-form-item> -->
<el-form-item label="新专业" prop="newmajor" :rules="rules2.reason6">
<!-- 1. 必须绑定 form.classVlue12. key 强制刷新3. 明确 props 匹配字段 -->
<el-cascader v-model="form.classVlue1" placeholder="请选择班级" :show-all-levels="false" :options="ClassNameList"