学生信息管理系统项目代码全集_第1页
学生信息管理系统项目代码全集_第2页
学生信息管理系统项目代码全集_第3页
学生信息管理系统项目代码全集_第4页
学生信息管理系统项目代码全集_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

学生信息管理系统项目代码全集<head><metacharset="UTF-8"><title>学生信息管理系统</title><style>.container{width:90%;margin:20pxauto;font-family:"MicrosoftYahei";}h1{text-align:center;}table{width:100%;border-collapse:collapse;margin:20px0;}th,td{border:1pxsolid#ddd;padding:10px;text-align:center;}th{background-color:#f5f5f5;}.btn-group{margin:10px0;text-align:right;}.btn{padding:6px12px;margin-left:10px;cursor:pointer;border:1pxsolid#ccc;border-radius:4px;background:#fff;}.btn-primary{background-color:#409eff;color:#fff;border-color:#409eff;}.modal{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);}.modal-content{width:400px;margin:100pxauto;background:#fff;padding:20px;border-radius:6px;}.form-group{margin:10px0;}label{display:inline-block;width:80px;text-align:right;margin-right:10px;}input{padding:6px;width:200px;border:1pxsolid#ddd;border-radius:4px;}.modal-footer{text-align:right;margin-top:20px;}</style></head><body><divclass="container"><h1>学生信息管理系统</h1><divclass="btn-group"><buttonclass="btnbtn-primary"id="add-btn">添加学生</button></div><tableid="student-table"><thead><tr><th>学号</th><th>姓名</th><th>性别</th><th>年龄</th><th>班级</th><th>操作</th></tr></thead><tbodyid="table-body"><!--数据将通过JS动态渲染--></tbody></table></div><!--添加/编辑学生模态框--><divclass="modal"id="student-modal"><divclass="modal-content"><h3id="modal-title">添加学生</h3><formid="student-form"><inputtype="hidden"id="student-id"><divclass="form-group"><labelfor="student-name">姓名:</label><inputtype="text"id="student-name"required></div><divclass="form-group"><labelfor="student-id-input">学号:</label><inputtype="text"id="student-id-input"required></div><divclass="form-group"><labelfor="student-gender">性别:</label><inputtype="text"id="student-gender"placeholder="男/女/未知"></div><divclass="form-group"><labelfor="student-age">年龄:</label><inputtype="number"id="student-age"></div><divclass="form-group"><labelfor="student-class">班级:</label><inputtype="text"id="student-class"></div><divclass="modal-footer"><buttontype="button"class="btn"id="cancel-btn">取消</button><buttontype="submit"class="btnbtn-primary"id="save-btn">保存</button></div></form></div></div><script>//全局变量constmodal=document.getElementById('student-modal');constform=document.getElementById('student-form');letisEdit=false;//是否为编辑状态//页面加载时获取学生列表window.onload=()=>{loadStudents();//绑定按钮事件document.getElementById('add-btn').addEventListener('click',()=>{isEdit=false;document.getElementById('modal-title').innerText='添加学生';form.reset();//重置表单modal.style.display='block';});document.getElementById('cancel-btn').addEventListener('click',()=>{modal.style.display='none';});form.addEventListener('submit',(e)=>{e.preventDefault();saveStudent();});};//加载学生列表functionloadStudents(){axios.get(`${baseUrl}/students`).then(res=>{consttbody=document.getElementById('table-body');res.data.forEach(student=>{consttr=document.createElement('tr');<td>${student.id}</td><td>${}</td><td>${student.gender}</td><td>${student.age||'未填写'}</td><td>${student.class_name||'未填写'}</td><td><buttonclass="btn"onclick="editStudent('${student.id}')">编辑</button><buttonclass="btn"onclick="deleteStudent('${student.id}')">删除</button></td>`;tbody.appendChild(tr);});}).catch(err=>{console.error('加载学生列表失败:',err);alert('数据加载失败,请刷新页面');});}//编辑学生functioneditStudent(studentId){isEdit=true;document.getElementById('modal-title').innerText='编辑学生';//获取学生信息axios.get(`${baseUrl}/students/${studentId}`).then(res=>{conststudent=res.data;document.getElementById('student-id').value=student.id;document.getElementById('student-id-input').value=student.id;document.getElementById('student-name').value=;document.getElementById('student-gender').value=student.gender;document.getElementById('student-age').value=student.age;document.getElementById('student-class').value=student.class_name;modal.style.display='block';}).catch(err=>{console.error('获取学生信息失败:',err);alert('获取数据失败');});}//删除学生functiondeleteStudent(studentId){if(confirm('确定要删除该学生吗?删除后其成绩也将被删除!')){axios.delete(`${baseUrl}/students/${studentId}`).then(res=>{alert(res.data.message);loadStudents();//重新加载列表}).catch(err=>{console.error('删除失败:',err);alert('删除失败,请重试');});}}//保存学生(添加/编辑)functionsaveStudent(){constdata={id:document.getElementById('student-id-input'

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论