diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs index c191c64f6..f66d1a954 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Controllers/AccommodationController.cs @@ -426,6 +426,19 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers return Success("保存成功!"); } + /// + /// 寝室分配床位 + /// + /// + [HttpPost] + [ValidateAntiForgeryToken] + [AjaxOnly] + public ActionResult SaveRoom(string RoomId, List list) + { + //List list = strEntity.ToObject>(); + accommodationIBLL.SaveRoom(RoomId, list); + return Success("保存成功!"); + } /// /// 学生宿舍的单元、楼层、房间、床位添加 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js index 028955da9..ee92b9db6 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/FormRoom.js @@ -38,8 +38,10 @@ var bootstrap = function ($, learun) { initData: function () { if (!!keyValue) { $.lrSetForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/GetBedListByRoomId?RoomId=' + keyValue, function (data) { - var html = ''; + $('#content').html(''); + for (var i = 0; i < data.length; i++) { + var html = ''; html += '
'; html += '
'; html += '
床位
'; @@ -52,46 +54,39 @@ var bootstrap = function ($, learun) { html += '
'; html += '
'; html += '
'; + $('#content').append(html); - //$('#' + data[i].ID).lrselectRefresh({ - // value: "stuid", - // text: "stuname", - // url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', - // param: { code: "StuInfoBasic", strWhere: "ClassNo='" + Class + "'" }, - // select: function (item) { - // if (item) { - // console.log(item); - // $.each(arr, - // function (index, value) { - // console.log('arr_index', value); - // console.log('arr_index', value); - // }); - // } + $('#' + data[i].ID).lrselect({ + value: "stuid", + text: "stuname", + url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', + param: { code: "StuInfoBasic", strWhere: "ClassNo='" + Class + "'" }, + select: function (item) { + // console.log(item); + var stuid = ''; + if (item) { + stuid = item.stuid; - // } - //}); - $('#' + data[i].ID).lrselectSet(data[i].StudentID); + } + var id = $(this).attr('id'); + //console.log('id', id); + //console.log('item',item); + arr.forEach(item => { + if (item.ID == id) { + //如果存在删除 + removeByValue(arr, 'ID', id); - arr.push({ ID: data[i].ID, StudentID: data[i].StudentID }); - } - $('#content').html(html); - $('.Student').lrselect({ - value: "stuid", - text: "stuname", - url: top.$.rootUrl + '/LR_SystemModule/DataSource/GetDataTable', - param: { code: "StuInfoBasic", strWhere: "ClassNo='" + Class + "'" }, - select: function (item) { - if (item) { - console.log(item); - $.each(arr, - function (index, value) { - console.log('arr_index', value); - console.log('arr_index', value); - }); + } + }); + arr.push({ ID: id, StudentID: stuid }); } + }); + $('#' + data[i].ID).lrselectSet(data[i].StudentID); - } - }); + //arr.push({ ID: data[i].ID, StudentID: data[i].StudentID }); + } + + }); } @@ -99,13 +94,19 @@ var bootstrap = function ($, learun) { }; // 保存数据 acceptClick = function (callBack) { - if (!$('body').lrValidform()) { - return false; - } + //if (!$('body').lrValidform()) { + // return false; + //} + //var postData = { + // strEntity: JSON.stringify($('body').lrGetFormData()) + //}; + //console.log('arr',arr); + var postData = { - strEntity: JSON.stringify($('body').lrGetFormData()) + list: arr }; - $.lrSaveForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/SaveDeptClass?type=2&keyValue=' + keyValue, postData, function (res) { + + $.lrSaveForm(top.$.rootUrl + '/LogisticsManagement/Accommodation/SaveRoom?RoomId=' + keyValue, postData, function (res) { // 保存成功后才回调 if (!!callBack) { callBack(); @@ -113,4 +114,16 @@ var bootstrap = function ($, learun) { }); }; page.init(); + //删除数组元素 + function removeByValue(arr, attr, value) { + var index = 0; + for (var i in arr) { + if (arr[i][attr] == value) { + index = i; + break; + } + } + arr.splice(index, 1); + } + } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js index 430a002e6..c926eb781 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LogisticsManagement/Views/Accommodation/IndexDistribution.js @@ -458,7 +458,7 @@ var bootstrap = function ($, learun) { mainId: 'ID', isPage: true, isMultiselect: true, - sidx: 'CheckInStu desc,ApartmentId asc,UnitId asc ,FloorId asc ', + sidx: 'CheckInStu asc,ApartmentId asc,UnitId asc ,FloorId asc ', //sord: 'ASC', isSubGrid: true, // 是否有子表 subGridExpanded: function (subContentId, rowItem) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs index f03a49428..ee125e205 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationBLL.cs @@ -631,6 +631,25 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } + public void SaveRoom(string RoomId, List list) + { + try + { + accommodationService.SaveRoom(RoomId, list); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + /// /// 批量添加单元、楼层、宿舍、床位 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs index a98a181e2..84cee539c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationIBLL.cs @@ -81,7 +81,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement /// void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity); void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity,int type); - + void SaveRoom(string RoomId, List list); /// /// 批量添加单元、楼层、房间、床位 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs index de48bd784..1573f0d4e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/Accommodation/AccommodationService.cs @@ -1614,6 +1614,67 @@ a.name as ApartmentName,b.name as UnitName,c.Name as FloorName } } + /// + /// 分配宿舍 + /// + /// + /// + public void SaveRoom(string RoomId, List list) + { + var db = this.BaseRepository("CollegeMIS").BeginTrans(); + try + { + foreach (var entity in list) + { + string sql = $"update Acc_DormitoryBuild set StudentID='{entity.StudentID}' where ID='{entity.ID}'"; + db.ExecuteBySql(sql); + } + + int checkInStu = list.Where(x => x.StudentID != null).Count(); + string checkInSql = $"update Acc_DormitoryBuild set CheckInStu='{checkInStu}' where ID='{RoomId}'"; + db.ExecuteBySql(checkInSql); + + db.Commit(); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + + /// + /// 同步宿舍信息 + /// + public void SyncData() + { + var db = this.BaseRepository("CollegeMIS").BeginTrans(); + try + { + string sql = "select 学号,姓名,性别,公寓,单元,楼层,宿舍号,床位号 from t1 where 学号 is not null order by 公寓,单元,楼层,宿舍号,床位号"; + DataTable dt = db.FindTable(sql); + //var list = db.FindList(); + //select * from Acc_DormitoryBuild where parentid= (select ID from Acc_DormitoryBuild where parentid=( select ID from Acc_DormitoryBuild where name='一号学生公寓')); + + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion 提交数据 }