var mnu = ""; //加载 $(function () { mnu = $.SystemGeneral.getUrlParam("MNU"); }) var selectDetailID; function SOCTemplateSetting_Save() { var TotalWeight = 0; var TotalCredit = 0; var CourseCredit = Number($("#Credit").val()); var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows"); $.each(roleViewList, function (index, value) { TotalWeight = Number(TotalWeight).add(Number(value.Weight)); TotalCredit = Number(TotalCredit).add(Number(value.Credit)); }); if(TotalWeight != 100) { $.messager.alert("系统信息", "SOC权重之和要等于100。"); return; } if(TotalCredit != CourseCredit) { $.messager.alert("系统信息", "SOC学分之和要等于课程学分。"); return; } $(document.forms[0]).submit(); } //function upload(rowindex, rowdata) { // var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOCTemplate/Upload?SOCTemplateItemID=" + rowdata.SOCTemplateItemID + "&MNU=" + mnu; // $.popupTopWindow('附件上传', redirectTo, 600, 400, null, null); //} //获取选中的数据 function validChoose() { var d = []; $.each($("#dgSOCTemplateDetailList").cmsXDataTable("getSelections"), function (index) { d.push(this.SOCTemplateItemID); }); return d; } function validChooseAll() { var d = []; $.each($("#dgSOCTemplateDetailList").cmsXDataTable("getSelections"), function (index) { d.push(this); }); return d; } function SOCTemplateDetail_Add() { var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows"); var SOCTemplateItemID = Guid.NewGuid().ToString(); // $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOCTemplate/GetNewGuidForSOCTemplateItemID', { count: 1 }, function (data) { // SOCTemplateItemID = data; // }); var count = roleViewList.length; var newName = "SOC" + count; roleViewList.push({ SOCTemplateItemID: SOCTemplateItemID, Name: newName, Credit: null, Weight: null, Description: null, AttachmentName: null, //IsGroupStr: null, }); $("#dgSOCTemplateDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length }); } function SOCTemplateDetail_Delete() { var d = validChooseAll(); var da = validChoose().join(','); if (da == "") { $.messager.alert("系统提示", "请选择您要删除的信息。"); return; } var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows"); var i, j; var len = roleViewList.length; for (i = len - 1; i >= 0; i--) { for (j = 0; j < d.length; j++) { if (roleViewList[i].SOCTemplateItemID == d[j].SOCTemplateItemID) { roleViewList.splice(i, 1); break; } } } $("#dgSOCTemplateDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length }); } function SOCTemplateDetail_Upload(){ var d = validChoose(); if (d.length == 0) { $.messager.alert("系统信息", "请选择您要进行附件管理的信息。"); return; } if (d.length > 1) { $.messager.alert("系统信息", "只能选择单个记录进行附件管理。"); return; } selectDetailID = d.join(','); var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOCTemplate/Upload?SOCTemplateItemID=" + d + "&MNU=" + mnu; $.popupTopWindow('附件上传', redirectTo, 700, 400, setAttachment); } function setAttachment(){ $.ajaxSetup({      async : false  }); var fileList; var detailID = selectDetailID $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOCTemplate/GetFileListByItemID', {TemplateDetailID : detailID }, function (data) { fileList = data; }); var count = fileList.length; var roleViewList = $("#dgSOCTemplateDetailList").cmsXDataTable("getRows"); var nameStr = ""; var detailID; var len = roleViewList.length; for(var i = 0; i < count; i++) { detailID = fileList[i].FormID; var name = fileList[i].FileName; nameStr = nameStr + "、" + name; } if(detailID != null) { $.each(roleViewList, function (index, value) { if (detailID == roleViewList[index].SOCTemplateItemID) { roleViewList[index].IsChangeAttachment = 1; } }); } nameStr = nameStr.substr(1, (nameStr.length - 1)); for(var j = 0; j < len; j++){ if (roleViewList[j].SOCTemplateItemID == detailID) { roleViewList[j].AttachmentName = nameStr; } } $("#dgSOCTemplateDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length }); }