學(xué)生信息管理系統(tǒng)項目代碼全集_第1頁
學(xué)生信息管理系統(tǒng)項目代碼全集_第2頁
學(xué)生信息管理系統(tǒng)項目代碼全集_第3頁
學(xué)生信息管理系統(tǒng)項目代碼全集_第4頁
學(xué)生信息管理系統(tǒng)項目代碼全集_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

學(xué)生信息管理系統(tǒng)項目代碼全集<head><metacharset="UTF-8"><title>學(xué)生信息管理系統(tǒng)</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>學(xué)生信息管理系統(tǒng)</h1><divclass="btn-group"><buttonclass="btnbtn-primary"id="add-btn">添加學(xué)生</button></div><tableid="student-table"><thead><tr><th>學(xué)號</th><th>姓名</th><th>性別</th><th>年齡</th><th>班級</th><th>操作</th></tr></thead><tbodyid="table-body"><!--數(shù)據(jù)將通過JS動態(tài)渲染--></tbody></table></div><!--添加/編輯學(xué)生模態(tài)框--><divclass="modal"id="student-modal"><divclass="modal-content"><h3id="modal-title">添加學(xué)生</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">學(xué)號:</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;//是否為編輯狀態(tài)//頁面加載時獲取學(xué)生列表window.onload=()=>{loadStudents();//綁定按鈕事件document.getElementById('add-btn').addEventListener('click',()=>{isEdit=false;document.getElementById('modal-title').innerText='添加學(xué)生';form.reset();//重置表單modal.style.display='block';});document.getElementById('cancel-btn').addEventListener('click',()=>{modal.style.display='none';});form.addEventListener('submit',(e)=>{e.preventDefault();saveStudent();});};//加載學(xué)生列表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('加載學(xué)生列表失?。?,err);alert('數(shù)據(jù)加載失敗,請刷新頁面');});}//編輯學(xué)生functioneditStudent(studentId){isEdit=true;document.getElementById('modal-title').innerText='編輯學(xué)生';//獲取學(xué)生信息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('獲取學(xué)生信息失敗:',err);alert('獲取數(shù)據(jù)失敗');});}//刪除學(xué)生functiondeleteStudent(studentId){if(confirm('確定要刪除該學(xué)生嗎?刪除后其成績也將被刪除!')){axios.delete(`${baseUrl}/students/${studentId}`).then(res=>{alert(res.data.message);loadStudents();//重新加載列表}).catch(err=>{console.error('刪除失?。?,err);alert('刪除失敗,請重試');});}}//保存學(xué)生(添加/編輯)functionsaveStudent(){constdata={id:document.getElementById('student-id-input'

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論