s:datagrid
<?xml version="1.0" encoding="utf-8"?> <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:component="com.ylsoft.component.*" width="100%" height="100%" creationComplete="init()"> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <![CDATA[ import com.ylsoft.common.Message; import com.ylsoft.common.Pagelimit; import com.ylsoft.core.Amf; import com.ylsoft.core.AppConfig; import com.ylsoft.core.ModuleFactory; import com.ylsoft.core.ModuleGlobal; import com.ylsoft.core.UIProgressBar; import com.ylsoft.event.AppEvent; import mx.collections.ArrayCollection; import mx.collections.ArrayList; import mx.collections.IList; import mx.controls.Alert; import mx.controls.dataGridClasses.DataGridColumn; import mx.core.FlexGlobals; import spark.components.gridClasses.GridColumn; private var amf:Amf; private var columsInited:Boolean = false; private function init():void{ //禁用返回列表 FlexGlobals.topLevelApplication.form_return.enabled=false; initColumns(); amf = new Amf(); amf.registerCallBack(initDataGrid); amf.startService('mergeServerApplyService','lists',new Pagelimit(0,AppConfig.PAGECOUNT)); initSubpage(); } public function initDataGrid(evt:AppEvent):void{ var result:ArrayCollection if(amf != null){ result = new ArrayCollection(amf.getResult() as Array); } else if(sb.amf != null) result = new ArrayCollection(sb.amf.getResult() as Array); dg.dataProvider = result; amf = null; } private function initColumns():void{ if(!columsInited){ var col1:GridColumn = new GridColumn(); col1.dataField = 'id'; col1.headerText = 'ID'; col1.width = 100; var col2:GridColumn = new GridColumn(); col2.dataField = 'fromservernames'; col2.headerText = '被合成服'; col2.width = 300; var col3:GridColumn = new GridColumn(); col3.dataField = 'toservername'; col3.headerText = '合成服'; col3.width = 200; var col4:GridColumn = new GridColumn(); col4.dataField = 'mergetime'; col4.headerText = '合服时间'; col4.width = 200; var col5:GridColumn = new GridColumn(); col5.dataField = 'buissnesserchange'; col5.headerText = '运营商变更'; col5.width = 150; var col6:GridColumn = new GridColumn(); col6.dataField = 'statname'; col6.headerText = '状态'; col6.width = 100; var columns:ArrayList = new ArrayList([col1,col5,col2,col3,col4,col6]); columns.addAll(dg.columns); dg.columns = columns; columsInited = true; } } private function addMerge(evt:MouseEvent):void{ FlexGlobals.topLevelApplication.main_right.removeAllElements(); ModuleGlobal.Modulefactory_main = new ModuleFactory(); ModuleGlobal.Modulefactory_main.setProgress(UIProgressBar.getInstance()); ModuleGlobal.Modulefactory_main.loadModule('managefunc/merge_server_apply',FlexGlobals.topLevelApplication.main_right); ModuleGlobal.Modulefactory_pre_unload = new Array(ModuleGlobal.Modulefactory_main); AppConfig.formoperation = AppConfig.FORMADD; } private function initSubpage():void{ sb.service = 'adminService'; sb.method = 'lists'; sb.methodTotal = 'num_rows'; sb.container = this; sb.initTotal(); } public function refuse():void{ var item : Object = this.dg.selectedItem; Message.confirm('请确认要拒绝吗?',this,function():void{ amf = new Amf; amf.registerCallBack(refuseDone,[item]); amf. startService("mergeServerApplyService","refuse",item.id); }); } public function refuseDone(array:Array):void{ var data:Object = array[0]; data.statname = "已拒绝"; data._enabled = false; //(this.dg.dataProvider as ArrayCollection).refresh(); this.dg.invalidateTypicalItem();//刷新组件状态 } public function allow():void{ var item : Object = this.dg.selectedItem; Message.confirm('请确认要允许吗?',this,function():void{ amf = new Amf; amf.registerCallBack(allowDone,[item]); amf. startService("mergeServerApplyService","allow",item.id); }); } private function allowDone(array:Array):void{ var data:Object = array[0]; data.statname = "已批准"; data._enabled = false; //(this.dg.dataProvider as ArrayCollection).refresh(); this.dg.invalidateTypicalItem(); } ]]> </fx:Script> <s:Panel width="100%" height="100%" dropShadowVisible="true" title="合服列表"> <component:Search x="0" top="0"> </component:Search> <s:DataGrid id="dg" width="100%" height="85%" verticalCenter="18"> <s:columns> <s:ArrayList> <s:GridColumn dataField="operation" headerText="操作"> <s:itemRenderer> <fx:Component> <s:GridItemRenderer > <s:HGroup color="#093F8A" paddingLeft="5" paddingTop="2"> <mx:Button toolTip="拒绝" label="拒绝" fontWeight="bold" buttonMode="true" click="outerDocument.refuse()" enabled="{data._enabled}"/> <mx:Button toolTip="批准" label="批准" fontWeight="bold" buttonMode="true" click="outerDocument.allow()" enabled="{data._enabled}" /> </s:HGroup> </s:GridItemRenderer> </fx:Component> </s:itemRenderer> </s:GridColumn> </s:ArrayList> </s:columns> </s:DataGrid> <component:Subpages id="sb" x="0" bottom="0"> </component:Subpages> <s:HGroup right="2" top="2" width="94"> <s:Button y="3" right="11" width="83" height="25" label="申请合服" buttonMode="true" click="addMerge(event)"/> </s:HGroup> </s:Panel> </s:Module>
mx:datagrid
<?xml version="1.0" encoding="utf-8"?> <s:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:component="com.ylsoft.component.*" width="100%" height="100%" creationComplete="init()"> <!--运营商账号申请审核--> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <![CDATA[ import com.ylsoft.common.Message; import com.ylsoft.common.Pagelimit; import com.ylsoft.common.Toolkit; import com.ylsoft.component.BuissnesserChooserMuti; import com.ylsoft.config.ContentConfig; import com.ylsoft.core.Amf; import com.ylsoft.core.AppConfig; import com.ylsoft.core.ModuleFactory; import com.ylsoft.core.ModuleGlobal; import com.ylsoft.core.UIProgressBar; import com.ylsoft.event.AppEvent; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.controls.dataGridClasses.DataGridColumn; import mx.core.FlexGlobals; import mx.formatters.DateFormatter; import mx.managers.PopUpManager; import mx.utils.ObjectUtil; private var amf:Amf; private var temp_obj:Object; private var temp_selectItem:Object; private function init():void{ //禁用返回列表 FlexGlobals.topLevelApplication.form_return.enabled=false; initColumns(); this.state.dataProvider = new ContentConfig().get_states(); this.state.labelField='label'; this.state.selectedIndex = 0; this.doSearch(); } public function initDataGrid(evt:AppEvent):void{ var result:ArrayCollection if(amf != null){ result = new ArrayCollection(amf.getResult() as Array); } else if(sb.amf != null) result = new ArrayCollection(sb.amf.getResult() as Array); initSubpage(); this.cd.dataProvider = result; amf = null; } private function initColumns():void{ var col1:DataGridColumn = new DataGridColumn(); col1.dataField = 'applytime'; col1.headerText = '日期'; col1.width = 120; var col2:DataGridColumn = new DataGridColumn(); col2.dataField = 'admin'; col2.headerText = '账号'; col2.width = 120; var col3:DataGridColumn = new DataGridColumn(); col3.dataField = 'permission'; col3.headerText = '权限'; col3.width = 120; var col4:DataGridColumn = new DataGridColumn(); col4.dataField = 'buissnesser'; col4.headerText = '运营商'; col4.width = 120; var col5:DataGridColumn = new DataGridColumn(); col5.dataField = 'op_admin'; col5.headerText = '申请人'; col5.width = 120; var col6:DataGridColumn = new DataGridColumn(); col6.dataField = 'stateName'; col6.headerText = '状态'; col6.width = 120; var col7:DataGridColumn = new DataGridColumn(); col7.dataField = 'flagname'; col7.headerText = '描述'; col7.width = 120; cd.columns = new Array(col1,col2,col3,col4,col5,col6,col7).concat(cd.columns); } private function initSubpage():void{ sb.service = 'adminApplyManageService'; sb.method = 'lists'; sb.methodTotal = 'num_rows'; sb.container = this; sb.condition = getCondition(); sb.initTotal(); } private function buissnesserChooser():void{ var bc : BuissnesserChooserMuti = new BuissnesserChooserMuti(); bc.width = 800; bc.height = 400; PopUpManager.addPopUp(bc,this,true); PopUpManager.centerPopUp(bc); } private function getCondition():Object{ var condition : Object = new Object(); condition.state = this.state.selectedItem.value; return condition; } private function doSearch():void{ this.sb.is_total_exec = false; amf = new Amf(); amf.setFaultMessage("通信失败"); amf.registerCallBack(initDataGrid); amf.startService('adminApplyManageService','lists',new Pagelimit(0,AppConfig.PAGECOUNT),getCondition()); } public function permit(obj:Object):void{ var apply:Object = this.cd.selectedItem; if(apply!=null){ Message.confirm('请确认要这么做吗?',this,function():void{ temp_selectItem = apply; amf = new Amf; amf.setFaultMessage('操作失败'); amf.registerCallBack(permitHandler); amf.startService('adminApplyManageService','permit',apply); }); } } private function permitHandler(evt:AppEvent):void{ if(amf.getResult() as Boolean == true){ Alert.show('操作成功'); temp_selectItem.stateName = '已批准'; temp_selectItem._enabled = false; this.cd.invalidateList(); } } public function refuse(obj:Object):void{ var apply:Object = this.cd.selectedItem; if(apply!=null){ Message.confirm('请确认要这么做吗?',this,function():void{ temp_selectItem = apply; amf = new Amf; amf.setFaultMessage('操作失败'); amf.registerCallBack(refuseHandler); amf.startService('adminApplyManageService','refuse',apply); }); } } private function refuseHandler(evt:AppEvent):void{ if(amf.getResult() as Boolean == true){ Alert.show('操作成功'); temp_selectItem.stateName = '已拒绝'; temp_selectItem._enabled = false; this.cd.invalidateList(); } } ]]> </fx:Script> <s:Panel width="100%" height="100%" dropShadowVisible="true" title="运营商用户申请"> <component:Search x="0" top="0"> </component:Search> <mx:DataGrid id="cd" height="85%" width="100%" verticalCenter="8"> <mx:columns> <mx:DataGridColumn headerText="操作"> <mx:itemRenderer> <fx:Component> <mx:HBox paddingLeft="5"> <mx:Button label="批准" buttonMode="true" id="permit_btn" click="outerDocument.permit(this)" enabled="{data._enabled}"></mx:Button> <mx:Button label="拒绝" buttonMode="true" id="refuse_btn" click="outerDocument.refuse(this)" enabled="{data._enabled}"></mx:Button> </mx:HBox> </fx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <component:Subpages id="sb" x="0" bottom="0"> </component:Subpages> <s:HGroup right="2" top="2" width="73"> <s:Button id="search_btn" label="查询" click="doSearch()" enabled="true" buttonMode="true"/> </s:HGroup> <mx:ComboBox x="41" y="8" id="state" openDuration="300"/> <s:Label x="10" y="10" text="状态"/> </s:Panel> </s:Module>