123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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 });
- }
|