flex 分页
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:afc="com.aflag.afcTree.*"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="com.aflag.components.*"
xmlns:cti="http://www.a-flag.com/cti"
xmlns:presentation="com.aflag.presentation.*"
width="100%" height="100%" creationComplete="init(event)">
<fx:Declarations>
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.aflag.components.AFCDate;
import com.aflag.components.serverError;
import com.aflag.events.ComponentEvent;
import com.aflag.misc.RenderFactory;
import com.aflag.services.api.ISalesDeliveryReminderService;
import com.aflag.services.impl.SalesDeliveryReminderService;
import com.aflag.utils.Tool;
import flash.utils.Timer;
import flash.utils.getDefinitionByName;
import mx.collections.IList;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.core.ClassFactory;
import mx.core.FlexGlobals;
import mx.core.IVisualElement;
import mx.events.FlexEvent;
import mx.formatters.DateFormatter;
import mx.managers.PopUpManager;
import spark.events.TextOperationEvent;
import org.as3commons.async.command.impl.GenericOperationCommand;
import org.as3commons.async.operation.event.OperationEvent;
import org.as3commons.collections.Map;
import org.as3commons.lang.DateUtils;
[Bindable]
public var codeItemEditor:ClassFactory;
private var pageInstance:ViewBase;
private var _timer:Timer;
private var inbound:String;
private var _hasOpen:Boolean=false;
public var currentBusinessType:String;
private var _incomingBarTimer:Timer;
[Bindable]
private var _dataProvider:IList;
private const _incomingBarTotal:int=180;
private var service:ISalesDeliveryReminderService=new SalesDeliveryReminderService();
public var scheduleMap:Map=new Map();
private var _serviceSite:XML;
[Bindable]
private var _queryString:String;
protected function searchByType(type:String):void{
var currentDate:String = AFCDate.parseCurrentCalendar(new Date()) ;
var endDateString:String = currentDate;
if(type=="week"){
endDateString = AFCDate.parseCurrentCalendar(DateUtils..addWeeks(new Date() , 1));
}else if(type == "month"){
endDateString = AFCDate.parseCurrentCalendar(DateUtils..addMonths(new Date() , 1));
}
startDate.value=currentDate;
endDate.value=endDateString;
query();
}
protected function query():void {
if(!startDate.value){ Alert.show("开始日期不能为空"); return; }
if(!endDate.value){ Alert.show("结束日期不能为空"); return; }
var scheduleQueryWarp:XML=new XML("<scheduleQueryWarp/>");
scheduleQueryWarp.queryString = _queryString;
scheduleQueryWarp.@startDate=startDate.value.toString();
scheduleQueryWarp.@endDate=endDate.value.toString();
if(_requery || _index > _resultCount){
_index = 0;
nowPage.text = "1";
}
if(_index > 0) _index++;
scheduleQueryWarp.@startPosition = _index ;
scheduleQueryWarp.@maxResults = _pageSize;
var _cmd:GenericOperationCommand = service.findSalesDeliveryReminder(scheduleQueryWarp);
_cmd.addCompleteListener(function (event:OperationEvent):void{
var _result:XML =new XML(event.result);
_dataProvider = new XMLListCollection(_result.result.entity);
_requery = false;
_resultCount = int(_result.@resultCount);
_pageCount = _resultCount / int(_pageSize);
if(_resultCount % int(_pageSize) > 0) _pageCount++;
preImg.enabled = true;
firstImg.enabled = true;
nextImg.enabled = true;
lastImg.enabled = true;
//重置分页按钮可用状态
if(int(_pageSize) >= _resultCount){
preImg.enabled = false;
firstImg.enabled = false;
nextImg.enabled = false;
lastImg.enabled = false;
}else if(int(nowPage.text) >= _pageCount){
nextImg.enabled = false;
lastImg.enabled = false;
}else if(int(nowPage.text) <= 1){
preImg.enabled = false;
firstImg.enabled = false;
}
});
_cmd.addErrorListener(function (e:OperationEvent):void{
serverError("加载发货信息失败","系统消息",e);
});
_cmd.execute();
}
//序号
public function documentDGNum(item:Object, column:GridColumn):String{
return ((documentDG.dataProvider.getItemIndex(item) + 1+_index).toString());
}
protected function init(event:FlexEvent):void {
var currentDate:Date=new Date();
startDate.value=AFCDate.parseCurrentCalendar(currentDate);
currentDate.setDate(currentDate.date+6);
endDate.value=AFCDate.parseCurrentCalendar(currentDate);
startDate.addEventListener(ComponentEvent.VALUE_CHANGE,onStartDateChanged);
endDate.addEventListener(ComponentEvent.VALUE_CHANGE,onEndDateChanged);
}
protected function documentDGDoubleClick(event:MouseEvent):void {
if(!documentDG.selectedItem){ return; }
var selectedId:Number=Number(documentDG.selectedItem.@id);
popInfo(selectedId);
}
public function popInfo(selectedId:Number):void{
var menu:XML=FlexGlobals.topLevelApplication.getElementAt(0).getMenu("SALES_DELIVERY_HEAD");
var menuName:String=menu.@name.toString();
if(menu!=null){
popBizTag(menu.@clientClass, "SALES_DELIVERY_HEAD" ,menuName,selectedId);
}else{
Alert.show("加载失败:没有权限或者参数配置出错!");
}
}
public var page:IVisualElement;
private function popBizTag(fullName:String, bizCode:String,modelName:String,onLoadId:Number=0):void{
var pt:Point = new Point(0, 0);
const POPUP_OFFSET:int = 10;
if(!page){
var WIN:Class = getDefinitionByName(fullName) as Class;
page = new WIN() as IVisualElement;
}
if(page){
page["bizCode"] = bizCode;
var pageWindow:ScheduleInformationEachWindow=new ScheduleInformationEachWindow();
pageWindow.pageInstance=page as ViewBase;
page.percentWidth=100;
page.percentHeight=100;
pageWindow.onLoadId=onLoadId;
PopUpManager.addPopUp(pageWindow, FlexGlobals.topLevelApplication as DisplayObject, false);
PopUpManager.centerPopUp(pageWindow);
}
}
protected function onStartDateChanged(event:ComponentEvent):void {
_requery = true;
if(Tool.emptyString(event.currentTarget.value)){ return ;}
var starDay:Date = DateFormatter.parseDateString(event.currentTarget.value);
endDate.value = AFCDate.parseCurrentCalendar(DateUtils.addMonths(starDay,3));
}
protected function onEndDateChanged(event:ComponentEvent):void {
_requery = true;
if(Tool.emptyString(event.currentTarget.value)){ return ;}
var endDay:Date = DateFormatter.parseDateString(event.currentTarget.value);
startDate.value = AFCDate.parseCurrentCalendar(DateUtils.addMonths(endDay,-3));
}
/**是否重置查询 -- 如果查询条件发生改变则重置 -- 查询开始位置为0*/
private var _requery:Boolean = true;
/** 当前下标 */
[Bindable] protected var _index:int = 0;
/**记录总数**/
[Bindable] protected var _resultCount:int = 0;
/**页数**/
[Bindable] protected var _pageCount:int = 0;
[Bindable] protected var _pageSize:String = "25";
/**跳至首页**/
private function onFirstBtnClick(event:MouseEvent):void{
_index = 0;
nowPage.text = "1";
query();
}
/**上一页**/
private function onPreBtnClick(event:MouseEvent):void{
_index = _index - int(_pageSize) -1;
if(_index < 0) _index = 0;
nowPage.text = Tool.trimString(int(nowPage.text) - 1);
query();
}
/**跳至指定页**/
private function onNowPageEnter(event:Event):void{
_index = (int(nowPage.text) - 1) * int(_pageSize) - 1;
if(_index < 0) _index = 0;
query();
}
/**下一页**/
private function onNextBtnClick(event:MouseEvent):void{
nowPage.text = Tool.trimString(int(nowPage.text) + 1);
_index = (int(nowPage.text) - 1) * int(_pageSize) - 1;
if(_index < 0) _index = 0;
query();
}
/**末页**/
private function onLastBtnClick(event:MouseEvent):void{
nowPage.text = Tool.trimString(_resultCount / int(_pageSize));
if(_resultCount % int(_pageSize) > 0) nowPage.text = Tool.trimString(int(nowPage.text) + 1);
_index = (int(nowPage.text) - 1) * int(_pageSize) - 1;
if(_index < 0) _index = 0;
query();
}
protected function onQueryStringChanged(event:TextOperationEvent):void
{
_requery = true;
}
]]>
</fx:Script>
<s:states>
<s:State name="normal"/>
<s:State name="open"/>
<s:State name="disabled"/>
</s:states>
<!--适用于第三方支付公司-->
<s:layout>
<s:VerticalLayout>
</s:VerticalLayout>
</s:layout>
<!--抬头-->
<mx:HDividedBox id="header" width="100%" height="100%">
<s:SkinnableContainer id="documentButtonContainer" width="220" height="100%"
mouseDownOutside="currentState='normal'"
skinClass="com.aflag.skins.frame.DefaultFrameSkin">
<s:layout>
<s:VerticalLayout gap="4" paddingBottom="2" paddingLeft="2" paddingRight="2"
paddingTop="4"/>
</s:layout>
<s:HGroup width="100%" height="24" gap="10" verticalAlign="justify">
<s:Label width="60" height="100%" text="开始时间" verticalAlign="middle"/>
<components:AFCDate id="startDate" width="100%" height="100%" datePattern="showDate"/>
</s:HGroup>
<s:HGroup width="100%" height="24" verticalAlign="justify">
<s:Label width="60" height="100%" text="结束时间" verticalAlign="middle"/>
<components:AFCDate id="endDate" width="100%" height="100%" datePattern="showDate"/>
</s:HGroup>
<s:HGroup width="100%" height="24" verticalAlign="justify">
<s:Label width="60" height="24" text="过滤" verticalAlign="middle"/>
<s:TextInput width="100%" change="onQueryStringChanged(event)" text="@{_queryString}"/>
</s:HGroup>
<s:HGroup width="100%" height="24" gap="11" verticalAlign="justify">
<s:Button width="40" height="20" label="今天" click="searchByType('today')"/>
<s:Button width="40" height="20" label="一周" click="searchByType('week')"/>
<s:Button width="40" height="20" label="一月" click="searchByType('month')"/>
<s:Button width="40" height="20" label="查询" click="query()"/>
</s:HGroup>
</s:SkinnableContainer>
<!--历史-->
<!--单击该Tab时刷新对应的内容表单-->
<s:SkinnableContainer id="history1" width="100%" height="100%"
skinClass="com.aflag.skins.frame.DefaultFrameSkin">
<s:layout>
<s:VerticalLayout gap="0"/>
</s:layout>
<s:TabBar width="100%" height="24" dataProvider="{historyViewStack1}"
skinClass="com.aflag.skins.tabBar.AFCTabBarSkin"/>
<mx:ViewStack id="historyViewStack1" width="100%" height="100%"
borderSkin="com.aflag.skins.standard.AFCViewStackBorderSkin"
creationPolicy="all">
<s:NavigatorContent width="100%" height="100%" label="列表视图">
<s:layout>
<s:VerticalLayout gap="5"/>
</s:layout>
<s:DataGrid id="documentDG" width="100%" height="100%"
dataProvider="{_dataProvider}"
doubleClick="documentDGDoubleClick(event)" doubleClickEnabled="true"
editable="false" horizontalScrollPolicy="auto">
<s:columns>
<s:ArrayList>
<s:GridColumn width="40" editable="false" headerText="序号"
labelFunction="documentDGNum"/>
<s:GridColumn dataField="code" headerText="编码"/>
<s:GridColumn dataField="opWarehouse" headerText="发货仓库"
labelFunction="{RenderFactory.finderLabelFunction}"/>
<s:GridColumn dataField="confirmed" headerText="是否发货"
labelFunction="{RenderFactory.booleanFunction}"/>
<s:GridColumn dataField="requiredDate" headerText="要求发货时间"/>
<s:GridColumn dataField="priority" headerText="优先级"
labelFunction="{RenderFactory.finderLabelFunction}"/>
<s:GridColumn dataField="customer" headerText="售达方"
labelFunction="{RenderFactory.finderLabelFunction}"/>
<s:GridColumn dataField="receiver" headerText="送达方"
labelFunction="{RenderFactory.finderLabelFunction}"/>
<s:GridColumn dataField="receiverContact" headerText="送达方联系人"
labelFunction="{RenderFactory.finderLabelFunction}"/>
<s:GridColumn dataField="remark" headerText="备注"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:HGroup width="100%" height="24" gap="12" horizontalAlign="center"
verticalAlign="justify">
<s:Label text="{'共查询到 '+_resultCount+ ' 行数据,分 '+_pageCount+' 页,每页显示'}"
textAlign="center" verticalAlign="middle"/>
<s:TextInput width="40" height="100%" enter="onNowPageEnter(event)"
restrict="0-9\-" text="@{_pageSize}" textAlign="center"/>
<s:Label text="行" textAlign="center" verticalAlign="middle"/>
<s:Button id="firstImg" click="onFirstBtnClick(event)"
skinClass="com.aflag.skins.arrow2.AFCFirstArrow2Skin" toolTip="首页"/>
<s:Button id="preImg" click="onPreBtnClick(event)"
skinClass="com.aflag.skins.arrow2.AFCPreviousArrow2Skin"
toolTip="上一页"/>
<s:TextInput id="nowPage" width="100" enter="onNowPageEnter(event)"
restrict="0-9\-" textAlign="center"/>
<s:Button id="nextImg" click="onNextBtnClick(event)"
skinClass="com.aflag.skins.arrow2.AFCNextArrow2Skin" toolTip="下一页"/>
<s:Button id="lastImg" click="onLastBtnClick(event)"
skinClass="com.aflag.skins.arrow2.AFCLastArrow2Skin" toolTip="末页"/>
</s:HGroup>
</s:NavigatorContent>
</mx:ViewStack>
</s:SkinnableContainer>
</mx:HDividedBox>
</s:Group>
-----
interface SalesDeliveryReminderRepositoryCustom {
QueryPagination<SalesDeliveryHead> findSalesDeliveryReminder(ScheduleQueryWarp wrap);
}
class SalesDeliveryReminderRepositoryImpl implements SalesDeliveryReminderRepositoryCustom {
@Autowired
private QueryUtils queryUtils;
@SuppressWarnings("unchecked")
@Override
public QueryPagination<SalesDeliveryHead> findSalesDeliveryReminder(ScheduleQueryWarp wrap) {
StringBuffer hql = new StringBuffer("SELECT obj FROM ");
hql.append(SalesDeliveryHead.class.getCanonicalName()).append(" obj ");
hql.append(" LEFT JOIN FETCH obj.customer customer ");
hql.append(" LEFT JOIN FETCH obj.opWarehouse opWarehouse ");
hql.append(" LEFT JOIN FETCH obj.receiver receiver ");
hql.append(" LEFT JOIN FETCH obj.carrier carrier");
hql.append(" LEFT JOIN FETCH obj.receiverContact receiverContact ");
hql.append(" LEFT JOIN FETCH obj.priority priority");
StringBuffer str = new StringBuffer(" WHERE obj.requiredDate between ? and ? ");
List<Object> params = new ArrayList<Object>();
Date startDate = wrap.getStartDate();
Date endDate = wrap.getEndDate();
params.add(startDate);
params.add(endDate);
if (!StringUtils.isEmpty(wrap.getQueryString())) {
str.append(" AND (obj.code LIKE ? OR obj.name LIKE ? )");
params.add("%" + wrap.getQueryString() + "%");
params.add("%" + wrap.getQueryString() + "%");
}
StringBuffer countHql = new StringBuffer("SELECT COUNT(obj.id) FROM ");
countHql.append(SalesDeliveryHead.class.getCanonicalName()).append(" obj ");
hql.append(str);
countHql.append(str);
hql.append(" ORDER BY obj.requiredDate ");
return (QueryPagination<SalesDeliveryHead>) queryUtils.limiteQuery(countHql.toString(), hql.toString(),
wrap.getStartPosition(), wrap.getMaxResults(), params);
}
-----
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ScheduleQueryWarp {
private String queryString;
@XmlAttribute
private Long employeeId;
@XmlAttribute
@XmlJavaTypeAdapter(value = DateAdapter.class)
private Date startDate;
@XmlAttribute
@XmlJavaTypeAdapter(value = DateAdapter.class)
private Date endDate;
@XmlAttribute
private int startPosition;
@XmlAttribute
private int maxResults = 25;
public Long getEmployeeId() {
return employeeId;
}
public void setEmployeeId(Long employeeId) {
this.employeeId = employeeId;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public String getQueryString() {
return queryString;
}
public void setQueryString(String queryString) {
this.queryString = queryString;
}
public int getStartPosition() {
return startPosition;
}
public void setStartPosition(int startPosition) {
this.startPosition = startPosition;
}
public int getMaxResults() {
return maxResults;
}
public void setMaxResults(int maxResults) {
this.maxResults = maxResults;
}
}
flex 分页的更多相关文章
- flex 分页打印表格功能
private function printHandler():void{ var printJob:FlexPrintJob = new FlexPrintJob(); printJob.print ...
- Flex相关案例及资源搜集
Flex一些例子: http://blog.minidx.com/ 上千个Flex例子,对于学习者来说是一个庞大的资源宝库. http://fleksray.org/Flex_skin.html ht ...
- Flex 加载tiff
gis系统常常要加载tiff,因为好多土地证书,各种文件都是扫描件,如果你是用as来写的前台,怎么加载呢,顺便说下用插件AlternaTIFF也是可以得不过浏览器加载这么多插件是不太好的. 首先TIF ...
- ArcGIS Flex API加载大量数据
1.关于大量数据的加载: 直接将所要展示的数据在服务器端发布成一个MapService,在客户端通过ArcGISDynamicMapServiceLayer来加载.这样的话客户端需要展示的仅仅是一张图 ...
- Flex4 自定义分页组件
自己写的Flex4分页组件,去伪存真,只实现基本的分页功能,数据过滤神马的都不应该是分页组件干的活,有呆毛才有真相: [源代码下载] Flex自从转手给Apache后人气急跌,本人也很捉鸡,尽管Apa ...
- Asp.Net MVC结合ExtJs gridPanel 分页和高度自适应
Ext.onReady(function () { gridPanel(); var panel = Ext.getCmp('gridPanel'); window.onresize = functi ...
- Ext4.1 Grid 分页查询
转载:http://blog.csdn.net/zyujie/article/details/16362747 最近用Ext4.1自己做了做项目的练习:把一些知识点,在这里记录下来了! 上面一个for ...
- [Ext JS 4] Grid 实战之分页功能
前言 分页功能的实现有两种途径: 一种是服务端分页方式, 也就是web客户端传递页码参数给服务端,服务端根据页面参数返回指定条数的数据.也就是要多少取多少.这种方式比较适合Grid 的数据量很大,需 ...
- HTML5动态分页效果代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
随机推荐
- 5 Python3 函数进阶&迭代器与生成器
1.函数进阶 1.1.名称空间 又名name space, 顾名思义就是存放名字的地方,存什么名字呢?举例说明,若变量x=1,1存放于内存中,那名字x存放在哪里呢?名称空间正是存放名字x与1绑定关系的 ...
- python之函数嵌套与闭包
一:函数的嵌套:在函数内部在定义一个函数,一层套一层 def father(name): print("from father %s" %name) def son(): prin ...
- nginx HttpLuaModule
http://wiki.nginx.org/HttpLuaModule#Directives Name ngx_lua - Embed the power of Lua into Nginx This ...
- Python 中的垃圾回收机制(转载)
from: https://foofish.net/python-gc.html GC作为现代编程语言的自动内存管理机制,专注于两件事:1. 找到内存中无用的垃圾资源 2. 清除这些垃圾并把内存让出来 ...
- Mybatis知识(2)
1.#{}和${}的区别是什么? 注:这道题是面试官面试我同事的. 答:${}是Properties文件中的变量占位符,它可以用于标签属性值和sql内部,属于静态文本替换,比如${driver}会被静 ...
- Solving SharePoint Server 2010 - 503. The service is unavailable, After installation
Installed: SharePoint Server 2010 for Internet Enterprise Beta (x64) On: Windows Server 2008 Standar ...
- C#累加器函数Aggregate用法 讲解
Enumerable.Aggregate 扩展方法在System.Linq命名空间中,是Enumerable类的第一个方法(按字母顺序排名),但确是Enumerable里面相对复杂的方法. MSDN对 ...
- Layouts
[Layouts] Each layout file must contain exactly one root element, which must be a View or ViewGroup ...
- Java连接MySQL数据库及操作
Java操作MySQL数据库,需要驱动mysql-connector-java 来进行操作,去下载对应的jar包 一.导入需要的jar包 我用的是maven对包进行管理,在maven中添加如下内容 ...
- np.frombuffer()
numpy.frombuffer numpy.frombuffer(buffer, dtype=float, count=-1, offset=0) Interpret a buffer as a 1 ...