123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- var mnu = "";
- //加载
- $(function () {
- mnu = $.SystemGeneral.getUrlParam("MNU");
- })
- var selectDetailID;
- function SOC_Save() {
- var TotalWeight = 0;
- var TotalCredit = 0;
- var CourseCredit = Number($("#Credit").val());
- var roleViewList = $("#dgSOCDetailList").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.confirm("系统提示", "SOC权重之和不等于100是否保存?", function (r) {
- if (r) {
- $(document.forms[0]).submit();
- }
- });
- }
- else if(TotalCredit != CourseCredit)
- {
- $.messager.confirm("系统提示", "SOC学分之和不等于课程学分是否保存?", function (r) {
- if (r) {
- $(document.forms[0]).submit();
- }
- });
- }else{
- $(document.forms[0]).submit();
- }
-
- }
- //获取选中的数据
- function validChoose() {
- var d = [];
- $.each($("#dgSOCDetailList").cmsXDataTable("getSelections"), function (index) {
- d.push(this.SOCDetailID);
- });
- return d;
- }
- //获取选中的数据
- function validChooseMassage() {
- var d = [];
- $.each($("#dgSOCDetailList").cmsXDataTable("getSelections"), function (index) {
- d.push(this);
- });
- return d;
- }
- function SOCDetail_Edit() {
- var d = validChoose();
- if (d.length == 0) {
- $.messager.alert("系统信息", "请选择您要进行修改的信息。");
- return;
- }
- if (d.length > 1) {
- $.messager.alert("系统信息", "只能选择单个记录进行修改。");
- return;
- }
- var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
- var idstring = validChoose().join(',');
- var massage = validChooseMassage();
- var detail = massage[0];
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOC/DeleteDetailCheck', { detailIDs: idstring }, function (data) {
- if (data.IsSuccess) {
- var redirectTo = CMS_SystemConfig.VirtualDirectoryPath + "/SOC/SOCDetailEdit?detailID=" + d + "&MNU=" + mnu;
- $.popupTopWindow('课程SOC修改', redirectTo, 800, 400, SOCDetailSet, detail);
- } else {
- $.messager.alert("系统提示", "选中的soc明细存在关联数据(SOC分组、SOC学生成果、SOC学生成绩等),不能修改!");
- }
- });
-
- }
- function SOCDetail_Delete() {
- var d = validChoose();
- if (d.length == 0) {
- $.messager.alert("系统信息", "请选择您要删除的信息。");
- return;
- }
- var idstring = validChoose().join(',');
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOC/DeleteDetailCheck', { detailIDs: idstring }, function (data) {
- if (data.IsSuccess) {
- var roleViewList = $("#dgSOCDetailList").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].SOCDetailID == d[j]) {
- roleViewList.splice(i, 1);
- break;
- }
- }
- }
- $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
- } else {
- $.messager.alert("系统提示", data.Message);
- }
- });
- // var roleViewList = $("#dgSOCDetailList").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].SOCDetailID == d[j]) {
- // roleViewList.splice(i, 1);
- // break;
- // }
- // }
- // }
- // $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
- }
- function SOCDetail_Add() {
- var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
- var SOCDetailID = Guid.NewGuid().ToString();
- var count = roleViewList.length;
- var newName = "SOC" + count;
- roleViewList.push({
- SOCDetailID: SOCDetailID,
- Name: newName,
- Credit: null,
- Weight: null,
- Description: null,
- StartTime: null,
- EndTime: null,
- });
- $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
- }
- function SOCDetailSet(data) {
- var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
- if(data != null)
- {
- $.each(roleViewList, function (index, value) {
- if (data.SOCDetailID == roleViewList[index].SOCDetailID) {
- roleViewList[index].SOCDetailID = data.SOCDetailID;
- roleViewList[index].Name = data.Name;
- roleViewList[index].Credit = (data.Credit == "" ) ? null : data.Credit;
- roleViewList[index].Weight = (data.Weight == "" ) ? null : data.Weight;
- roleViewList[index].IsGroup = data.IsGroup;
- roleViewList[index].IsGroupin = data.IsGroupin;
- roleViewList[index].IsGroupStr = data.IsGroup ? "是" : "否";
- roleViewList[index].Description = data.Description;
- var reg =/(\d{4})\-(\d{2})\-(\d{2})/;
- roleViewList[index].StartTimeStr = data.StartTime.replace(reg,"$1/$2/$3").split(" ")[0];
- roleViewList[index].StartTime = data.StartTime;
- roleViewList[index].EndTimeStr = data.EndTime.replace(reg,"$1/$2/$3").split(" ")[0];
- roleViewList[index].EndTime = data.EndTime;
- roleViewList[index].IsGroupin = data.IsGroup;
- }
- });
- }
- $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
- }
- function SOCDetail_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 + "/SOC/Upload?detailID=" + d + "&MNU=" + mnu;
- $.popupTopWindow('附件上传', redirectTo, 700, 400, setAttachment);
- }
- function setAttachment(){
- $.ajaxSetup({
- async : false
- });
- var fileList;
- var detailID = selectDetailID
- $.post(CMS_SystemConfig.VirtualDirectoryPath + '/SOC/GetFileListByDetailID', { DetailID: detailID }, function (data) {
- fileList = data;
- });
- var count = fileList.length;
- var roleViewList = $("#dgSOCDetailList").cmsXDataTable("getRows");
- var nameStr = "";
- var len = roleViewList.length;
- for(var i = 0; i < count; i++)
- {
- var detailID = fileList[i].FormID;
- var name = fileList[i].FileName;
- nameStr = nameStr + "、" + name;
- }
- nameStr = nameStr.substr(1, (nameStr.length - 1));
- if(detailID != null)
- {
- $.each(roleViewList, function (index, value) {
- if (detailID == roleViewList[index].SOCDetailID) {
- roleViewList[index].IsChangeAttachment = 1;
- }
- });
- }
- for(var j = 0; j < len; j++){
- if (roleViewList[j].SOCDetailID == detailID) {
- roleViewList[j].SOCDetailAttachment = nameStr;
- }
- }
- $("#dgSOCDetailList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
- }
|