PersonalScore.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. var url = CMS_SystemConfig.VirtualDirectoryPath + "/PersonalScore/Edit";
  2. var mnu = "";
  3. //加载
  4. $(function () {
  5. mnu = $.SystemGeneral.getUrlParam("MNU");
  6. })
  7. //获取选中的数据
  8. function validChoose() {
  9. var d = [];
  10. $.each($("#dgCourseScheduleSettingList").cmsXDataTable("getSelections"), function (index) {
  11. d.push(this.SubmitedScoreID);
  12. });
  13. return d;
  14. }
  15. function reload() {
  16. $("#display_search_list").css('display', 'none');
  17. var userID = $("#StudentsComboGrid").combogridX("getValue");
  18. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/PersonalScore/CoursematerialList', { userID: userID }, function (data) {
  19. if (data.length > 0) {
  20. var count = data[0].ListStarttermID.length;
  21. var width = " 20%";
  22. var a = "100%";
  23. if (count > 5) {
  24. var height = 0;
  25. a = 100 + (count - 5) * 20;
  26. width = 100 / count + "%";
  27. }
  28. $("#search_list").html("");
  29. StudentCoursematerialtable(data[0]);
  30. var html = "<div id='divScroll' style='width: " + a + "%'>";
  31. for (var i = 0; i < data[0].ListStarttermID.length; i++) {
  32. //PS:同一课程、可能开课学期不同~
  33. var listCourseGradeView = $.grep(data[0].ListCourseGradeView, function (x) { return (x.StarttermID == data[0].ListStarttermID[i]); });
  34. html += "<table cellpadding='0' cellspacing='0' style='width: " + width + "; margin-bottom: 5px; float:left;' class='Coursematerialtable'>";
  35. html += "<tr>";
  36. html += "<td align='center' colspan='3' style='background-color: #F0F0F0'>" + listCourseGradeView[0].StarttermName + "</td>";
  37. html += "</tr>";
  38. html += "<tr>";
  39. html += "<td align='center' style='background-color: #F0F0F0'>课程名称</td>";
  40. html += "<td align='center' style='background-color: #F0F0F0'>总成绩</td>";
  41. html += "<td align='center' style='background-color: #F0F0F0'>学分</td>";
  42. html += "</tr>";
  43. for (var j = 0; j < listCourseGradeView.length; j++) {
  44. var color = "'" + listCourseGradeView[j].CourseTypeColour + "'"
  45. html += "<tr>";
  46. if (listCourseGradeView[j].Club == null)
  47. {
  48. html += "<td style='background-color:" + listCourseGradeView[j].CourseTypeColour + "'" + " align=\"center\"><a href=\"#this\" onclick=\"return LoadScore('" + listCourseGradeView[j].CoursematerialID + "','" + listCourseGradeView[j].SchoolyearID + "','" + listCourseGradeView[j].UserID + "','" + data[0].ListStarttermID[i] + "');\"><font color=blue>" + listCourseGradeView[j].CourseName + "</font></a></td>";
  49. } else
  50. {
  51. html += "<td style='background-color:#32CD32' align=\"center\"><a href=\"#this\" onclick=\"return LoadScore('" + listCourseGradeView[j].CoursematerialID + "','" + listCourseGradeView[j].SchoolyearID + "','" + listCourseGradeView[j].UserID + "','" + data[0].ListStarttermID[i] + "');\"><font color=blue>" + listCourseGradeView[j].CourseName + "</font></a></td>";
  52. }
  53. if (listCourseGradeView[j].TotalScore < 60 || listCourseGradeView[j].TotalScore == "")
  54. html += "<td align='center' style='color:Red'>" + listCourseGradeView[j].TotalScoreStr + "</td>";
  55. else
  56. html += "<td align='center' >" + listCourseGradeView[j].TotalScoreStr + "</td>";
  57. html += "<td align='center'>" + isEmpty(listCourseGradeView[j].ScoreCredit) + "</td>";
  58. html += "</tr>";
  59. }
  60. html += "</table>";
  61. }
  62. html += "</div>";
  63. $("#search_list").html(html);
  64. }
  65. else {
  66. StudentCoursematerialtable(data[0]);
  67. var html = " <p style='color:Red;'>选择的学生成绩库中无成绩,请检查。</p>"
  68. $("#search_list").html(html);
  69. }
  70. });
  71. }
  72. function reloadBack() {
  73. $("#display_search_list").css('display', 'none');
  74. var userID = $("#StudentsComboGrid").combogridX("getValue");
  75. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/PersonalScore/CoursematerialList', { userID: userID }, function (data) {
  76. if (data.length > 0) {
  77. var count = data[0].ListStarttermID.length;
  78. var width = " 20%";
  79. var a = "100%";
  80. if (count > 5) {
  81. var height = 0;
  82. a = 100 + (count - 5) * 20;
  83. width = 100 / count + "%";
  84. }
  85. $("#search_list").html("");
  86. StudentCoursematerialtable(data[0]);
  87. var html = "<div id='divScroll' style='width: " + a + "%'>";
  88. for (var i = 0; i < data[0].ListStarttermID.length; i++) {
  89. //PS:同一课程、可能开课学期不同~
  90. var listCourseGradeView = $.grep(data[0].ListCourseGradeView, function (x) { return (x.StarttermID == data[0].ListStarttermID[i]); });
  91. html += "<table cellpadding='0' cellspacing='0' style='width: " + width + "; margin-bottom: 5px; float:left;' class='Coursematerialtable'>";
  92. html += "<tr>";
  93. html += "<td align='center' colspan='3' style='background-color: #F0F0F0'>" + listCourseGradeView[0].StarttermName + "</td>";
  94. html += "</tr>";
  95. html += "<tr>";
  96. html += "<td align='center' style='background-color: #F0F0F0'>课程名称</td>";
  97. html += "<td align='center' style='background-color: #F0F0F0'>总成绩</td>";
  98. html += "<td align='center' style='background-color: #F0F0F0'>学分</td>";
  99. html += "</tr>";
  100. for (var j = 0; j < listCourseGradeView.length; j++) {
  101. var color = "'" + listCourseGradeView[j].CourseTypeColour + "'"
  102. html += "<tr>";
  103. if (listCourseGradeView[j].Club == null) {
  104. html += "<td style='background-color:" + listCourseGradeView[j].CourseTypeColour + "'" + " align=\"center\"><a href=\"#this\" onclick=\"return LoadScore('" + listCourseGradeView[j].CoursematerialID + "','" + listCourseGradeView[j].SchoolyearID + "','" + listCourseGradeView[j].UserID + "','" + data[0].ListStarttermID[i] + "');\"><font color=blue>" + listCourseGradeView[j].CourseName + "</font></a></td>";
  105. } else {
  106. html += "<td style='background-color:#32CD32' align=\"center\"><a href=\"#this\" onclick=\"return LoadScore('" + listCourseGradeView[j].CoursematerialID + "','" + listCourseGradeView[j].SchoolyearID + "','" + listCourseGradeView[j].UserID + "','" + data[0].ListStarttermID[i] + "');\"><font color=blue>" + listCourseGradeView[j].CourseName + "</font></a></td>";
  107. }
  108. if (listCourseGradeView[j].TotalScore < 60 || listCourseGradeView[j].TotalScore == "")
  109. html += "<td align='center' style='color:Red'>" + listCourseGradeView[j].TotalScoreStr + "</td>";
  110. else
  111. html += "<td align='center' >" + listCourseGradeView[j].TotalScoreStr + "</td>";
  112. html += "<td align='center'>" + isEmpty(listCourseGradeView[j].ScoreCredit) + "</td>";
  113. html += "</tr>";
  114. }
  115. html += "</table>";
  116. }
  117. html += "</div>";
  118. $("#search_list").html(html);
  119. }
  120. else {
  121. StudentCoursematerialtable(data[0]);
  122. var html = " <p style='color:Red;'>请选择您要查看成绩的学生学号。</p>"
  123. $("#search_list").html(html);
  124. }
  125. });
  126. }
  127. //验证是否为空。
  128. function isEmpty(val) {
  129. switch (typeof (val)) {
  130. case 'string':
  131. return trim(val).length == 0 ? 0 : val;
  132. break;
  133. case 'number':
  134. return val == 0 ? 0 : val;
  135. break;
  136. case 'object':
  137. return val == null ? 0 : val;
  138. break;
  139. case 'array':
  140. return val.length == 0 ? 0 : val;
  141. break;
  142. default:
  143. return true;
  144. }
  145. };
  146. function StudentCoursematerialtable(data) {
  147. if (data!=null) {
  148. //$("#StudentCoursematerialtable").find("tr.row").remove();
  149. var html = "";
  150. html += "<label><b>姓名:</b></label>";
  151. html += "&nbsp<label><b>" + data.UserName + "</b></label>";
  152. html += "&nbsp&nbsp<label><b>院系所:</b></label>";
  153. html += "&nbsp<label><b>" + data.CollegeName + "</b></label>";
  154. html += "&nbsp&nbsp<label><b>班级名称:</b></label>";
  155. html += "&nbsp<label><b>" + data.ClassName + "</b></label>";
  156. html += "&nbsp&nbsp<label><b>毕业时间:</b></label>";
  157. html += "<label><b>" + (data.PlanningGraduateDate == null ? "" : ChangeDateFormat(data.PlanningGraduateDate)) + "</b></label>";
  158. var html1 = "";
  159. html1 += "<label><b>门数:</b></label>";
  160. html1 += "&nbsp<label><b>" + data.CoursematerialCount + "</b></label>";
  161. html1 += "&nbsp&nbsp<label'><b>平均成绩:</b></label>";
  162. html1 += "&nbsp<label><b>" + (data.AVGScore == null ? 0 : data.AVGScore.toFixed(1)) + "</b></label>";
  163. html1 += "&nbsp&nbsp<label><b>总学分:</b></label>";
  164. html1 += "&nbsp<label><b>" + (data.TotalCredit == null ? 0 : data.TotalCredit.toFixed(1)) + "</b></label>";
  165. // html += "<tr>";
  166. // html += "<td style='background-color: #F0F0F0; '>姓&nbsp&nbsp&nbsp名</td>";
  167. // html += "<td>" + data.UserName + "</td>";
  168. // html += "<td style='background-color: #F0F0F0'>院系</td>";
  169. // html += "<td>" + data.CollegeName + "</td>";
  170. // html += "<td style='background-color: #F0F0F0'>班&nbsp&nbsp&nbsp级</td>";
  171. // html += "<td>" + data.ClassName + "</td>";
  172. // html += "</tr>";
  173. // html += "<tr>";
  174. // html += "<td style='background-color: #F0F0F0'>毕业时间</td>";
  175. // html += "<td>" + (data.PlanningGraduateDate == null ? "" : ChangeDateFormat(data.PlanningGraduateDate)) + "</td>";
  176. // html += "<td style='background-color: #F0F0F0'>门数</td>";
  177. // html += "<td>" + data.CoursematerialCount + "</td>";
  178. // html += "<td style='background-color: #F0F0F0'>平均成绩</td>";
  179. // html += "<td>" + (data.AVGScore == null ? 0 : data.AVGScore.toFixed(1)) + "</td>";
  180. // html += "</tr>";
  181. // html += "<tr>";
  182. // html += "<td style='background-color: #F0F0F0'>总 学 分</td>";
  183. // html += "<td>" + (data.TotalCredit == null ? 0 : data.TotalCredit.toFixed(1)) + "</td>";
  184. // html += "<td style='background-color: #F0F0F0'></td>";
  185. // html += "<td></td>";
  186. // html += "<td style='background-color: #F0F0F0'></td>";
  187. // html += "<td></td>";
  188. // html += "</tr>";
  189. $("#Studenttable").html(html);
  190. $("#StudentCoursematerialtable").html(html1);
  191. }
  192. else {
  193. $("#Studenttable").html("");
  194. $("#StudentCoursematerialtable").html("");
  195. }
  196. }
  197. function LoadScore(CoursematerialID, SchoolyearID, UserID, StarttermID) {
  198. $("#display_search_list").css('display', 'block');
  199. $("#hid_SchoolyearID").val(SchoolyearID);
  200. $("#hid_CoursematerialID").val(CoursematerialID);
  201. $("#hid_UserID").val(UserID);
  202. $("#hid_StarttermID").val(StarttermID)
  203. $("#dgCourseScheduleSettingList").cmsXDataTable("load", { CoursematerialID: CoursematerialID, StarttermID: StarttermID, UserID: UserID });
  204. }
  205. //转化json数据的日期
  206. function ChangeDateFormat(jsondate) {
  207. jsondate = jsondate.replace("/Date(", "").replace(")/", "");
  208. if (jsondate.indexOf("+") > 0) {
  209. jsondate = jsondate.substring(0, jsondate.indexOf("+"));
  210. } else if (jsondate.indexOf("-") > 0) {
  211. jsondate = jsondate.substring(0, jsondate.indexOf("-"));
  212. }
  213. //alert(jsondate);
  214. var date = new Date(parseInt(jsondate, 10));
  215. //alert(date.getHours());
  216. var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  217. var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  218. //+ " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); 时分秒就不需要了~~
  219. return date.getFullYear() + "-" + month + "-" + currentDate;
  220. }
  221. function PersonScore_Add() {
  222. var d = validChoose();
  223. var SchoolyearID = $("#hid_SchoolyearID").val();
  224. var CoursematerialID = $("#hid_CoursematerialID").val();
  225. var UserID = $("#hid_UserID").val();
  226. var StarttermID = $("#hid_StarttermID").val();
  227. if (d.length > 0) {
  228. if (d.length > 1) {
  229. $.messager.alert("系统提示", "只能选择单个记录进行复制。");
  230. return;
  231. }
  232. var redirectTo = url + "?SubmitedScoreID=" + d + "&SchoolyearID=" + SchoolyearID + "&CoursematerialID=" + CoursematerialID + "&UserID=" + UserID + "&StarttermID=" + StarttermID + "&atype=1&MNU=" + mnu + "&SaveType=Add";
  233. $.popupTopWindow('学生成绩复制新增', redirectTo, 800, 480, null, null);
  234. } else {
  235. var redirectTo = url + "?SubmitedScoreID=" + d + "&SchoolyearID=" + SchoolyearID + "&CoursematerialID=" + CoursematerialID + "&UserID=" + UserID + "&StarttermID=" + StarttermID + "&atype=1&MNU=" + mnu;
  236. $.popupTopWindow('学生成绩新增', redirectTo, 800, 480, null, null);
  237. }
  238. }
  239. function PersonScore_Update() {
  240. var d = validChoose();
  241. var SchoolyearID = $("#hid_SchoolyearID").val();
  242. var CoursematerialID = $("#hid_CoursematerialID").val();
  243. var UserID = $("#hid_UserID").val();
  244. var StarttermID = $("#hid_StarttermID").val();
  245. if (d == "") {
  246. $.messager.alert("系统提示", "请选择您要修改的成绩基本信息。");
  247. return;
  248. }
  249. if (d.length > 1) {
  250. $.messager.alert("系统提示", "只能选择单个记录进行修改。");
  251. return;
  252. }
  253. var redirectTo = url + "?SubmitedScoreID=" + d + "&SchoolyearID=" + SchoolyearID + "&CoursematerialID=" + CoursematerialID + "&UserID=" + UserID + "&StarttermID=" + StarttermID + "&atype=2&MNU=" + mnu;
  254. $.popupTopWindow('学生成绩修改', redirectTo, 800, 480, null, null);
  255. }
  256. function PersonScore_Delete() {
  257. // var d = validChoose().join(',');
  258. // if (d == "") {
  259. // $.messager.alert("系统提示", "请选择您要删除的成绩基本信息!");
  260. // return;
  261. // }
  262. // var schoolyearID = $("#hid_SchoolyearID").val();
  263. // var coursematerialID = $("#hid_CoursematerialID").val();
  264. // var userID = $("#hid_UserID").val();
  265. // var starttermID = $("#hid_StarttermID").val();
  266. // $.messager.confirm("系统提示", "您确定要删除该成绩基本信息?", function (r) {
  267. // if (r) {
  268. // $.post(CMS_SystemConfig.VirtualDirectoryPath + '/PersonalScore/Delete', { submitedScoreIDs: d, schoolyearID: schoolyearID, coursematerialID: coursematerialID, starttermID: starttermID, userID: userID }, function (data) {
  269. // if (data == "删除成功") {
  270. // $.messager.alert("系统提示", "删除成功!");
  271. // $("#dgCourseScheduleSettingList").cmsXDataTable("load", { CoursematerialID: coursematerialID, SchoolyearID: schoolyearID, UserID: userID });
  272. // reload(); //load页面
  273. // } else {
  274. // $.messager.alert("系统提示", data);
  275. // }
  276. // });
  277. // }
  278. // });
  279. var d = validChoose().join(',');
  280. if (d == "") {
  281. $.messager.alert("系统提示", "请选择您要删除的学生成绩信息!");
  282. return;
  283. }
  284. var schoolyearID = $("#hid_SchoolyearID").val();
  285. var coursematerialID = $("#hid_CoursematerialID").val();
  286. var userID = $("#hid_UserID").val();
  287. var starttermID = $("#hid_StarttermID").val();
  288. $.messager.confirm("系统提示", "您确定要删除该学生成绩信息?", function (r) {
  289. if (r) {
  290. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/StudentScore/Delete', { submitedScoreIDs: d }, function (data) {
  291. if (data == "删除成功") {
  292. $.messager.alert("系统提示", "删除成功!");
  293. $("#dgCourseScheduleSettingList").cmsXDataTable("load", { CoursematerialID: coursematerialID, SchoolyearID: schoolyearID, UserID: userID });
  294. reload(); //load页面
  295. } else {
  296. $.messager.alert("系统提示", data);
  297. }
  298. });
  299. }
  300. });
  301. }
  302. function StudentScore_Report() {
  303. if ($("#StudentsComboGrid").combogridX("getValue") == null || $("#StudentsComboGrid").combogridX("getValue") == "" || $("#StudentsComboGrid").combogridX("getText") == "") {
  304. $.messager.alert("系统提示", "请选择要查看成绩报表的学生学号。");
  305. return;
  306. }
  307. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/PersonalScore/StudentScoreReport?LoginID=" + $("#StudentsComboGrid").combogridX("getText")+"&UserID="; //兼容广体版成绩多个姓名下拉框,这里传空值
  308. //$.System.addTab('学生个人成绩报表', redirectTo, 'StudentScore', false);
  309. //addTab('学生个人成绩报表', redirectTo);
  310. $.popupTopWindow('学生个人成绩报表', redirectTo, 850, 550, null, null);
  311. //var redirectTo = '/StudentScore/StudentScoreReport?MNU=' + "" + "&CollegeID="
  312. // + "&Years=&GrademajorID=&ClassmajorID=&Attribute=LoginID&Condition==&Value=" + $("#LoginID").val();
  313. //$.popupTopWindow('学生个人成绩报表', redirectTo, 1100, 550, null, null);
  314. }
  315. function addTab(title, url) {
  316. if ($('#index_center').tabs('exists', title)) {
  317. $('#index_center').tabs('select', title);
  318. } else {
  319. var content = '<iframe scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>';
  320. $('#index_center').tabs('add', {
  321. title: title,
  322. content: content,
  323. closable: true
  324. });
  325. }
  326. }
  327. //列表字体颜色设置为红色
  328. function SetRedColumn(index, row, value) {
  329. return " <span style=\"color: red;\">" + value + "</span>";
  330. }