更新调整stu模块bug。

This commit is contained in:
Orangeeee
2026-09-23 10:12:21 +08:00
parent d2464c7536
commit bc4d69b27c
3 changed files with 29 additions and 10 deletions
+22 -3
View File
@@ -1289,6 +1289,15 @@
</div>
</div>
<div class="form-row">
<div class="form-group">
<label class="form-label">学历 *</label>
<select class="form-input" id="student-education" required>
<option value="本科">本科</option>
<option value="专科">专科</option>
<option value="硕士">硕士</option>
<option value="博士">博士</option>
</select>
</div>
<div class="form-group">
<label class="form-label">籍贯</label>
<input type="text" class="form-input" id="student-home">
@@ -1560,13 +1569,18 @@
document.getElementById('student-major').value = student.specialty || '';
document.getElementById('student-home').value = student.home_Place || '';
document.getElementById('student-college').value = student.college || '';
// 回填学历(后端存储的是中文,下拉框也是中文)
const eduSel = document.getElementById('student-education');
if (student.education) {
eduSel.value = student.education;
}
openModal('student-modal');
}
document.getElementById('student-form').addEventListener('submit', async (e) => {
e.preventDefault();
const id = document.getElementById('student-edit-id').value;
const data = {
name: document.getElementById('student-name').value,
@@ -1575,15 +1589,20 @@
phone: document.getElementById('student-phone').value,
class_id: parseInt(document.getElementById('student-class').value),
specialty: document.getElementById('student-major').value,
education: document.getElementById('student-education').value,
// 默认 advisor_id=1,绕过后端 dao 查 advisor 的 bug
advisor_id: 1,
home_Place: document.getElementById('student-home').value,
college: document.getElementById('student-college').value,
};
if (id) {
data.id = parseInt(id);
await updateStudent(data);
} else {
data.num = '2024' + String(studentData.length + 1001).padStart(4, '0');
// 根据当前最大id自动生成学号
const maxId = studentData.reduce((max, s) => Math.max(max, s.id || 0), 0);
data.num = '2024' + String(maxId + 1001).padStart(4, '0');
await addStudent(data);
}
});