StudentDistributeEdit.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. })
  6. //添加学生
  7. function Student_Add() {
  8. var studentDistributeID = $("#studentDistributeID").val();
  9. var GrademajorID = $("#GrademajorID").val();
  10. $.popupTopWindow('添加学生', CMS_SystemConfig.VirtualDirectoryPath + '/Common/StudentSelect?FromMNU=' +
  11. mnu + '&studentDistributeID=' + studentDistributeID + '&GrademajorID=' + GrademajorID, 650, 480, AddStudent_Confirm);
  12. }
  13. //确定
  14. function AddStudent_Confirm(studentList) {
  15. //var studentViewList = $("#dgStudentList").cmsXDataTable("getRows"); //studentViewList 原列表数据
  16. //$.each(studentList, function () {
  17. // studentViewList.push(this);
  18. //});
  19. //$("#dgStudentList").cmsXDataTable("loadData", { rows: studentViewList, total: studentViewList.length });
  20. if (studentList == undefined)
  21. return;
  22. var dataList = [{ "Text": "请选择", "Value": -1 }];
  23. var studentViewList = $("#dgStudentList").cmsXDataTable("getRows"); //studentViewList 原列表数据
  24. $.each(studentList, function (index, value) {
  25. if ($.grep(studentViewList, function (row, index) { return value.UserID == studentViewList[index].UserID; }).length == 0) {
  26. studentViewList.push({
  27. UserID: value.UserID,
  28. LoginID: value.LoginID,
  29. Name: value.Name,
  30. CourseCode: value.CourseCode,
  31. TeachingMaterialCode: value.TeachingMaterialCode,
  32. CreateUserName: value.CreateUserName,
  33. CreateTime: value.CreateTime,
  34. Remark: value.Remark
  35. });
  36. }
  37. });
  38. $("#dgStudentList").cmsXDataTable("loadData", { rows: studentViewList, total: studentViewList.length });
  39. }
  40. function validChoose() {
  41. var d = [];
  42. $.each($("#dgStudentList").cmsXDataTable("getSelections"), function (index) {
  43. d.push(this);
  44. });
  45. return d;
  46. }
  47. //删除
  48. function Student_Delete() {
  49. var d = validChoose();
  50. if (d == "") {
  51. $.messager.alert("系统提示", "请选择您要删除的信息。");
  52. return;
  53. }
  54. var studentViewList = $("#dgStudentList").cmsXDataTable("getRows");
  55. var i, j;
  56. var len = studentViewList.length;
  57. for (i = len - 1; i >= 0; i--) {
  58. for (j = 0; j < d.length; j++) {
  59. if (studentViewList[i].UserID == d[j].UserID) {
  60. studentViewList.splice(i, 1);
  61. break;
  62. }
  63. }
  64. }
  65. $("#dgStudentList").cmsXDataTable("loadData", { rows: studentViewList, total: studentViewList.length });
  66. }
  67. function success(data) {
  68. $.messager.alert('系统信息', data.Message);
  69. if (data.IsSuccess) {
  70. top.$('#sysWindow').window('close');
  71. var tab = top.$('#index_center_tabs').tabs('getSelected');
  72. tab.panel('refresh');
  73. }
  74. }