SOCTemplateEdit.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. var mnu = "";
  2. //加载
  3. $(function () {
  4. mnu = $.SystemGeneral.getUrlParam("MNU");
  5. })
  6. var selectDetailID;
  7. function SOCTemplateSetting_Save() {
  8. var TotalWeight = 0;
  9. var TotalCredit = 0;
  10. var CourseCredit = Number($("#Credit").val());
  11. var roleViewList = $("#dgSOCTemplateDetailList").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.alert("系统信息", "SOC权重之和要等于100。");
  19. return;
  20. }
  21. if(TotalCredit != CourseCredit)
  22. {
  23. $.messager.alert("系统信息", "SOC学分之和要等于课程学分。");
  24. return;
  25. }
  26. $(document.forms[0]).submit();
  27. }
  28. //function upload(rowindex, rowdata) {
  29. // var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOCTemplate/Upload?SOCTemplateItemID=" + rowdata.SOCTemplateItemID + "&MNU=" + mnu;
  30. // $.popupTopWindow('附件上传', redirectTo, 600, 400, null, null);
  31. //}
  32. //获取选中的数据
  33. function validChoose() {
  34. var d = [];
  35. $.each($("#dgSOCTemplateDetailList").cmsXDataTable("getSelections"), function (index) {
  36. d.push(this.SOCTemplateItemID);
  37. });
  38. return d;
  39. }
  40. function validChooseAll() {
  41. var d = [];
  42. $.each($("#dgSOCTemplateDetailList").cmsXDataTable("getSelections"), function (index) {
  43. d.push(this);
  44. });
  45. return d;
  46. }
  47. function SOCTemplateDetail_Add() {
  48. var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows");
  49. var SOCTemplateItemID = Guid.NewGuid().ToString();
  50. // $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOCTemplate/GetNewGuidForSOCTemplateItemID', { count: 1 }, function (data) {
  51. // SOCTemplateItemID = data;
  52. // });
  53. var count = roleViewList.length;
  54. var newName = "SOC" + count;
  55. roleViewList.push({
  56. SOCTemplateItemID: SOCTemplateItemID,
  57. Name: newName,
  58. Credit: null,
  59. Weight: null,
  60. Description: null,
  61. AttachmentName: null,
  62. //IsGroupStr: null,
  63. });
  64. $("#dgSOCTemplateDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  65. }
  66. function SOCTemplateDetail_Delete() {
  67. var d = validChooseAll();
  68. var da = validChoose().join(',');
  69. if (da == "") {
  70. $.messager.alert("系统提示", "请选择您要删除的信息。");
  71. return;
  72. }
  73. var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows");
  74. var i, j;
  75. var len = roleViewList.length;
  76. for (i = len - 1; i >= 0; i--) {
  77. for (j = 0; j < d.length; j++) {
  78. if (roleViewList[i].SOCTemplateItemID == d[j].SOCTemplateItemID) {
  79. roleViewList.splice(i, 1);
  80. break;
  81. }
  82. }
  83. }
  84. $("#dgSOCTemplateDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  85. }
  86. function SOCTemplateDetail_Upload(){
  87. var d = validChoose();
  88. if (d.length == 0) {
  89. $.messager.alert("系统信息", "请选择您要进行附件管理的信息。");
  90. return;
  91. }
  92. if (d.length > 1) {
  93. $.messager.alert("系统信息", "只能选择单个记录进行附件管理。");
  94. return;
  95. }
  96. selectDetailID = d.join(',');
  97. var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOCTemplate/Upload?SOCTemplateItemID=" + d + "&MNU=" + mnu;
  98. $.popupTopWindow('附件上传', redirectTo, 700, 400, setAttachment);
  99. }
  100. function setAttachment(){
  101. $.ajaxSetup({ 
  102.     async : false 
  103. });
  104. var fileList;
  105. var detailID = selectDetailID
  106. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOCTemplate/GetFileListByItemID', {TemplateDetailID : detailID }, function (data) {
  107. fileList = data;
  108. });
  109. var count = fileList.length;
  110. var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows");
  111. var nameStr = "";
  112. var detailID;
  113. var len = roleViewList.length;
  114. for(var i = 0; i < count; i++)
  115. {
  116. detailID = fileList[i].FormID;
  117. var name = fileList[i].FileName;
  118. nameStr = nameStr + "、" + name;
  119. }
  120. if(detailID != null)
  121. {
  122. $.each(roleViewList, function (index, value) {
  123. if (detailID == roleViewList[index].SOCTemplateItemID) {
  124. roleViewList[index].IsChangeAttachment = 1;
  125. }
  126. });
  127. }
  128. nameStr = nameStr.substr(1, (nameStr.length - 1));
  129. for(var j = 0; j < len; j++){
  130. if (roleViewList[j].SOCTemplateItemID == detailID) {
  131. roleViewList[j].AttachmentName = nameStr;
  132. }
  133. }
  134. $("#dgSOCTemplateDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  135. }