@@ -426,6 +426,19 @@ namespace Learun.Application.Web.Areas.LogisticsManagement.Controllers | |||
return Success("保存成功!"); | |||
} | |||
/// <summary> | |||
/// 寝室分配床位 | |||
/// <summary> | |||
/// <returns></returns> | |||
[HttpPost] | |||
[ValidateAntiForgeryToken] | |||
[AjaxOnly] | |||
public ActionResult SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | |||
{ | |||
//List<Acc_DormitoryBuildEntity> list = strEntity.ToObject<List<Acc_DormitoryBuildEntity>>(); | |||
accommodationIBLL.SaveRoom(RoomId, list); | |||
return Success("保存成功!"); | |||
} | |||
/// <summary> | |||
/// 学生宿舍的单元、楼层、房间、床位添加 | |||
/// </summary> | |||
@@ -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 += '<div class="col-xs-12 lr-form-item div12">'; | |||
html += '<div class="col-xs-6 lr-form-item">'; | |||
html += '<div class="lr-form-item-title">床位</div>'; | |||
@@ -52,46 +54,39 @@ var bootstrap = function ($, learun) { | |||
html += '<div class="Student" id="' + data[i].ID + '"></div>'; | |||
html += '</div>'; | |||
html += '</div>'; | |||
$('#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); | |||
} | |||
} |
@@ -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) { | |||
@@ -632,6 +632,25 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||
} | |||
} | |||
public void SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list) | |||
{ | |||
try | |||
{ | |||
accommodationService.SaveRoom(RoomId, list); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 批量添加单元、楼层、宿舍、床位 | |||
/// </summary> | |||
@@ -81,7 +81,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||
/// <returns></returns> | |||
void SaveEntity(string keyValue, Acc_DormitoryBuildEntity entity); | |||
void SaveDeptClass(string keyValue, Acc_DormitoryBuildEntity entity,int type); | |||
void SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> list); | |||
/// <summary> | |||
/// 批量添加单元、楼层、房间、床位 | |||
@@ -1614,6 +1614,67 @@ a.name as ApartmentName,b.name as UnitName,c.Name as FloorName | |||
} | |||
} | |||
/// <summary> | |||
/// 分配宿舍 | |||
/// </summary> | |||
/// <param name="RoomId"></param> | |||
/// <param name="list"></param> | |||
public void SaveRoom(string RoomId, List<Acc_DormitoryBuildEntity> 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); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 同步宿舍信息 | |||
/// </summary> | |||
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<Acc_DormitoryBuildEntity>(); | |||
//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 提交数据 | |||
} |