SOCEdit.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. })
  6. var selectDetailID;
  7. function SOC_Save() {
  8. var TotalWeight = 0;
  9. var TotalCredit = 0;
  10. var CourseCredit = Number($("#Credit").val());
  11. var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  12. $.each(roleViewList, function (index, value) {
  13. TotalWeight = Number(TotalWeight).add(Number(value.Weight));
  14. TotalCredit = Number(TotalCredit).add(Number(value.Credit));
  15. });
  16. if(TotalWeight != 100)
  17. {
  18. $.messager.confirm("系统提示", "SOC权重之和不等于100是否保存?", function (r) {
  19. if (r) {
  20. $(document.forms[0]).submit();
  21. }
  22. });
  23. }
  24. else if(TotalCredit != CourseCredit)
  25. {
  26. $.messager.confirm("系统提示", "SOC学分之和不等于课程学分是否保存?", function (r) {
  27. if (r) {
  28. $(document.forms[0]).submit();
  29. }
  30. });
  31. }else{
  32. $(document.forms[0]).submit();
  33. }
  34. }
  35. //获取选中的数据
  36. function validChoose() {
  37. var d = [];
  38. $.each($("#dgSOCDetailList").cmsXDataTable("getSelections"), function (index) {
  39. d.push(this.SOCDetailID);
  40. });
  41. return d;
  42. }
  43. //获取选中的数据
  44. function validChooseMassage() {
  45. var d = [];
  46. $.each($("#dgSOCDetailList").cmsXDataTable("getSelections"), function (index) {
  47. d.push(this);
  48. });
  49. return d;
  50. }
  51. function SOCDetail_Edit() {
  52. var d = validChoose();
  53. if (d.length == 0) {
  54. $.messager.alert("系统信息", "请选择您要进行修改的信息。");
  55. return;
  56. }
  57. if (d.length > 1) {
  58. $.messager.alert("系统信息", "只能选择单个记录进行修改。");
  59. return;
  60. }
  61. var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  62. var idstring = validChoose().join(',');
  63. var massage = validChooseMassage();
  64. var detail = massage[0];
  65. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOC/DeleteDetailCheck', { detailIDs: idstring }, function (data) {
  66. if (data.IsSuccess) {
  67. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOC/SOCDetailEdit?detailID=" + d + "&MNU=" + mnu;
  68. $.popupTopWindow('课程SOC修改', redirectTo, 800, 400, SOCDetailSet, detail);
  69. } else {
  70. $.messager.alert("系统提示", "选中的soc明细存在关联数据(SOC分组、SOC学生成果、SOC学生成绩等),不能修改!");
  71. }
  72. });
  73. }
  74. function SOCDetail_Delete() {
  75. var d = validChoose();
  76. if (d.length == 0) {
  77. $.messager.alert("系统信息", "请选择您要删除的信息。");
  78. return;
  79. }
  80. var idstring = validChoose().join(',');
  81. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOC/DeleteDetailCheck', { detailIDs: idstring }, function (data) {
  82. if (data.IsSuccess) {
  83. var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  84. var i, j;
  85. var len = roleViewList.length;
  86. for (i = len - 1; i >= 0; i--) {
  87. for (j = 0; j < d.length; j++) {
  88. if (roleViewList[i].SOCDetailID == d[j]) {
  89. roleViewList.splice(i, 1);
  90. break;
  91. }
  92. }
  93. }
  94. $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  95. } else {
  96. $.messager.alert("系统提示", data.Message);
  97. }
  98. });
  99. // var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  100. // var i, j;
  101. // var len = roleViewList.length;
  102. // for (i = len - 1; i >= 0; i--) {
  103. // for (j = 0; j < d.length; j++) {
  104. // if (roleViewList[i].SOCDetailID == d[j]) {
  105. // roleViewList.splice(i, 1);
  106. // break;
  107. // }
  108. // }
  109. // }
  110. // $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  111. }
  112. function SOCDetail_Add() {
  113. var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  114. var SOCDetailID = Guid.NewGuid().ToString();
  115. var count = roleViewList.length;
  116. var newName = "SOC" + count;
  117. roleViewList.push({
  118. SOCDetailID: SOCDetailID,
  119. Name: newName,
  120. Credit: null,
  121. Weight: null,
  122. Description: null,
  123. StartTime: null,
  124. EndTime: null,
  125. });
  126. $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  127. }
  128. function SOCDetailSet(data) {
  129. var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  130. if(data != null)
  131. {
  132. $.each(roleViewList, function (index, value) {
  133. if (data.SOCDetailID == roleViewList[index].SOCDetailID) {
  134. roleViewList[index].SOCDetailID = data.SOCDetailID;
  135. roleViewList[index].Name = data.Name;
  136. roleViewList[index].Credit = (data.Credit == "" ) ? null : data.Credit;
  137. roleViewList[index].Weight = (data.Weight == "" ) ? null : data.Weight;
  138. roleViewList[index].IsGroup = data.IsGroup;
  139. roleViewList[index].IsGroupin = data.IsGroupin;
  140. roleViewList[index].IsGroupStr = data.IsGroup ? "是" : "否";
  141. roleViewList[index].Description = data.Description;
  142. var reg =/(\d{4})\-(\d{2})\-(\d{2})/;
  143. roleViewList[index].StartTimeStr = data.StartTime.replace(reg,"$1/$2/$3").split(" ")[0];
  144. roleViewList[index].StartTime = data.StartTime;
  145. roleViewList[index].EndTimeStr = data.EndTime.replace(reg,"$1/$2/$3").split(" ")[0];
  146. roleViewList[index].EndTime = data.EndTime;
  147. roleViewList[index].IsGroupin = data.IsGroup;
  148. }
  149. });
  150. }
  151. $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  152. }
  153. function SOCDetail_Upload(){
  154. var d = validChoose();
  155. if (d.length == 0) {
  156. $.messager.alert("系统信息", "请选择您要进行附件管理的信息。");
  157. return;
  158. }
  159. if (d.length > 1) {
  160. $.messager.alert("系统信息", "只能选择单个记录进行附件管理。");
  161. return;
  162. }
  163. selectDetailID = d.join(',');
  164. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOC/Upload?detailID=" + d + "&MNU=" + mnu;
  165. $.popupTopWindow('附件上传', redirectTo, 700, 400, setAttachment);
  166. }
  167. function setAttachment(){
  168. $.ajaxSetup({ 
  169.     async : false 
  170. });
  171. var fileList;
  172. var detailID = selectDetailID
  173. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOC/GetFileListByDetailID', { DetailID: detailID }, function (data) {
  174. fileList = data;
  175. });
  176. var count = fileList.length;
  177. var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
  178. var nameStr = "";
  179. var len = roleViewList.length;
  180. for(var i = 0; i < count; i++)
  181. {
  182. var detailID = fileList[i].FormID;
  183. var name = fileList[i].FileName;
  184. nameStr = nameStr + "、" + name;
  185. }
  186. nameStr = nameStr.substr(1, (nameStr.length - 1));
  187. if(detailID != null)
  188. {
  189. $.each(roleViewList, function (index, value) {
  190. if (detailID == roleViewList[index].SOCDetailID) {
  191. roleViewList[index].IsChangeAttachment = 1;
  192. }
  193. });
  194. }
  195. for(var j = 0; j < len; j++){
  196. if (roleViewList[j].SOCDetailID == detailID) {
  197. roleViewList[j].SOCDetailAttachment = nameStr;
  198. }
  199. }
  200. $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  201. }