flex角色管理视图
最近要用flex实现权限管理军火库装配,记下来吧,流失得太多了。
主要是角色应该拥有的资源,spring security 3.x里面需要的,角色列表,某角色拥有的资源,资源树checkbox的操作。
代码如下:
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="creationCompleteHandler(event)" minWidth="955" minHeight="600" xmlns:control="com.gwtjs.control.*"> <mx:Script> <![CDATA[ import com.gwtjs.components.RoleEditorWindow; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.events.CloseEvent; import mx.events.FlexEvent; import mx.managers.PopUpManager; private var pageIndex:int=0; private var pageSize:int=5; [Bindable] public var roleArray:ArrayCollection = new ArrayCollection([ {id:1,roleName:'系统超级管理员',roleDesc:"管理系统",issys:true,enable:true,resource:""}, {id:2,roleName:'系统管理员',roleDesc:"管理系统",issys:true,enable:true,resource:""}, {id:3,roleName:'编辑1',roleDesc:"营销策划者",issys:false,enable:true,resource:"1,2,3,7,8"}, {id:4,roleName:'系统超级管理员',roleDesc:"管理系统",issys:true,enable:true}, {id:5,roleName:'系统管理员',roleDesc:"管理系统",issys:true,enable:true}, {id:6,roleName:'编辑2',roleDesc:"营销策划者",issys:false,enable:true,resource:"1,2,3,7,8"}, {id:7,roleName:'系统超级管理员',roleDesc:"管理系统",issys:true,enable:true}, {id:8,roleName:'系统管理员',roleDesc:"管理系统",issys:true,enable:true}, {id:9,roleName:'编辑3',roleDesc:"营销策划者",issys:false,enable:true,resource:"1,2,3,7,8"}, {id:10,roleName:'系统超级管理员',roleDesc:"管理系统",issys:true,enable:true}, {id:11,roleName:'系统管理员',roleDesc:"管理系统",issys:true,enable:true}, {id:12,roleName:'编辑4',roleDesc:"营销策划者",issys:false,enable:true,resource:"1,2,3,7,8"} ]); protected function creationCompleteHandler(event:FlexEvent):void { serverPagingBar1.dataGrid=roleAdg; serverPagingBar1.pagingFunction=pagingFunction; } private function pagingFunction(pageIndex:int,pageSize:int):void{ //new StorageFactory().getOrderPaged(onResult,pageIndex,pageSize); } protected function addHandler(event:MouseEvent):void { var editWin:RoleEditorWindow = new RoleEditorWindow(); editWin.action = "Insert"; editWin.title = "新增角色"; PopUpManager.addPopUp(editWin,this,true); PopUpManager.centerPopUp(editWin); } protected function updateHandler(event:MouseEvent):void { var editWin:RoleEditorWindow = new RoleEditorWindow(); editWin.role = roleAdg.selectedItem; editWin.action = "Update"; editWin.title = "编辑角色"; PopUpManager.addPopUp(editWin,this,true); PopUpManager.centerPopUp(editWin); } protected function removeHandler(event:MouseEvent):void { var item:Object = roleAdg.selectedItem; Alert.show("确定删除["+item.roleName+"] ?","信息提示",(1|2),this,function(event:CloseEvent):void{ if(event.detail == Alert.YES){ for(var i:int=0;i<roleArray.length;i++){ if(item.roleName==roleArray[i].roleName){ roleArray.removeItemAt(i); } } } }); } ]]> </mx:Script> <mx:VBox width="100%" height="100%"> <mx:HBox width="100%"> <mx:LinkButton label="添加角色" click="addHandler(event)"/> <mx:LinkButton label="修改角色" click="updateHandler(event)"/> <mx:LinkButton label="删除角色" click="removeHandler(event)"/> </mx:HBox> <mx:DataGrid id="roleAdg" width="100%" height="100%" dataProvider="{roleArray}" variableRowHeight="true"> <mx:columns> <mx:DataGridColumn dataField="roleName" headerText="角色名称"/> <mx:DataGridColumn dataField="roleDesc" headerText="角色说明"/> <mx:DataGridColumn dataField="issys" headerText="系统角色"/> <mx:DataGridColumn dataField="enable" headerText="起用"/> <mx:DataGridColumn headerText="编辑"/> </mx:columns> </mx:DataGrid> <control:PagingBar id="serverPagingBar1" height="36" width="100%" paddingTop="6"/> </mx:VBox> </mx:Application>