From 64d3850e7ce0552010595df9fe01448dbf34dabd Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Fri, 18 Feb 2022 17:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=85=8D=E5=AE=BF=E8=88=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccommodationController.cs | 13 +++ .../Views/Accommodation/FormRoom.js | 95 +++++++++++-------- .../Views/Accommodation/IndexDistribution.js | 2 +- .../Accommodation/AccommodationBLL.cs | 19 ++++ .../Accommodation/AccommodationIBLL.cs | 2 +- .../Accommodation/AccommodationService.cs | 35 +++++++ 6 files changed, 123 insertions(+), 43 deletions(-) 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 8e924d0a2..eadc78e89 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 @@ -359,6 +359,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 3e04337de..6157526a8 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 @@ -571,6 +571,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 362d566ca..b09bf2076 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 @@ -79,7 +79,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 54e1ccd8c..88e58316d 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 @@ -1507,6 +1507,41 @@ 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); + } + } + } + /// /// 同步宿舍信息 ///