模块(菜单)的排序是每个系统都必须要有的功能,我们框架模块的排序在业务逻辑中已经体现。
WinForm版本可以直接在界面上对模块进行排序以控制模块展示的顺序。Web版本在3.2版本中也新增了直接可以模块管理界面对模块进行排序的人性化操作,大大的方便了管理人员。模块的排序在模块管理主界面分页按钮的右侧如下图所示。
三个按钮功能分别为:上移、下移、确认修改
WebMVC部分,模块排序功能代码参考:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /// <summary> /// 保存模块排序功能 /// </summary> /// <param name="parentId">父节点</param> /// <param name="rows">数据行</param> /// <returns></returns> [HttpPost] [ValidateInput( false )] [LoginAuthorize] public virtual ActionResult SaveSort( string parentId, string rows) { string message = RDIFrameworkMessage.MSG0001; try { if (!IsAuthorized( "ModuleManagement.Edit" )) { return Content( new JsonMessage { Success = false , Data = "0" , Message = "你没有权限操作!" }.ToString()); } int returnUpdateValue = 0; RDIFramework.Utilities.UserInfo curUser = ManageProvider.Provider.Current(); if (! string .IsNullOrEmpty(parentId)) { var dtModule = RDIFrameworkService.Instance.ModuleService.GetDTByParent(curUser, parentId); var moduleOldSort = new List<KeyValuePair< string , object >>(); if (dtModule != null && dtModule.Rows.Count > 0) { moduleOldSort.AddRange( from DataRow row in dtModule.Rows select BaseEntity.Create<PiModuleEntity>(row) into moduleEntity select new KeyValuePair< string , object >(moduleEntity.Id, moduleEntity.SortCode)); } var moduleNewSort = new List<KeyValuePair< string , object >>(); //把json字符串转换成对象 List<PiModuleEntity> listRows = rows?.JonsToList<PiModuleEntity>(); if (listRows != null && listRows.Count > 0) { moduleNewSort.AddRange(listRows.Select(entity => new KeyValuePair< string , object >(entity.Id, entity.SortCode))); } if (moduleNewSort.Count > 0 && moduleOldSort.Count > 0 && moduleNewSort.Count == moduleOldSort.Count) { for ( int index = 0; index < moduleOldSort.Count; index++) { moduleOldSort[index] = moduleNewSort[index]; } foreach ( var parElement in moduleOldSort) { PiModuleEntity updateEntity = RDIFrameworkService.Instance.ModuleService.GetEntity(curUser,parElement.Key); if (updateEntity.SortCode != null && parElement.Value != null && !updateEntity.SortCode.Equals(BusinessLogic.ConvertToInt32(parElement.Value))) { updateEntity.SortCode = BusinessLogic.ConvertToInt32(parElement.Value); string statusCode; string statusMessage; RDIFrameworkService.Instance.ModuleService.Update(curUser, updateEntity, out statusCode, out statusMessage); returnUpdateValue += statusCode == RDIFramework.Utilities.StatusCode.OKUpdate.ToString()? 1: 0; } } if (returnUpdateValue > 0) { message = "操作提示:" + " <br>排序保存成功,更新数据:" + returnUpdateValue.ToString() + "条。" ; return Content( new JsonMessage {Success = true , Data = "1" , Message = message}.ToString()); } message = "操作提示:" + " <br>没有排序数据被修改。" ; return Content( new JsonMessage { Success = true , Data = "1" , Message = message }.ToString()); } message = "操作提示:" + " <br>当前操作的记录条件与原记录条件不符。" ; return Content( new JsonMessage { Success = false , Data = "0" , Message = message }.ToString()); } message = "操作提示:" + " <br>请选择一个父级节点再操作。" ; return Content( new JsonMessage { Success = false , Data = "0" , Message = message }.ToString()); } catch (Exception ex) { return Content( new JsonMessage { Success = false , Data = "0" , Message = "操作失败:" + ex.Message }.ToString()); } } |
本文转自yonghu86博客园博客,原文链接:http://www.cnblogs.com/huyong/p/7225107.html,如需转载请自行联系原作者