<?xml version="1.0" encoding="UTF-8"?> <!-- $Author: jessen $Date: 2011-9-29 下午3:25:52 $Revision: 1.0 $Purpose: --> <a:screen xmlns:a="http://www.leaf-framework.org/application"> <a:view> <script type="text/javascript"><![CDATA[ onerror = function(m, u, l) { alert("msg:"+m + "\nurl:" + u + "\nlin:" + l); }; function msrenderer() { return this.value + 'ms'; } function refresh() { var r = $('query_ds2').getCurrentRecord(); var sd = r.get('startDate'); var ed = r.get('endDate'); if (ed > new Date()) { ed = new Date(); r.set('endDate', ed); } if(!r.validateRecord()){ return; } var ds = $('analytics_top_use_ds'); ds.query(); $('btn_refresh2').disable(); } function checkNotEmpty(obj) { return typeof(obj) != 'undefined' && !Ext.isEmpty(obj); } function dateValidator(record, name, value) { if (name == 'startDate' || name == 'endDate') { var start_date = record.get('startDate'); var end_date = record.get('endDate'); if ( checkNotEmpty(start_date) && checkNotEmpty(end_date) && (start_date > end_date)) { return '开始日期不能大于结束日期'; } } return true; } function onload(ds){ $('btn_refresh2').enable(); } ]]></script> <a:dataSets> <a:dataSet id="query_ds2" autoCreate="true"> <a:fields> <a:field name="startDate" required="true" validator="dateValidator"/> <a:field name="endDate" required="true" validator="dateValidator"/> </a:fields> </a:dataSet> <a:dataSet id="analytics_top_use_ds" model="sys.SYS2520.sys_analytics_top_use" pageSize="100" queryDataSet="query_ds2"> <a:fields> <a:field name="page" prompt="页面"/> <a:field name="visits" datatype="float" prompt="访问量"/> </a:fields> <a:events> <a:event name="load" handler="onload"/> </a:events> </a:dataSet> </a:dataSets> <a:screenBody> <a:hBox> <a:datePicker name="startDate" bindTarget="query_ds2" prompt="起始日期"/> <a:datePicker name="endDate" bindTarget="query_ds2" prompt="结束日期"/> <a:button id="btn_refresh2" click="refresh" text="刷新"/> </a:hBox> <a:chart bindTarget="analytics_top_use_ds" inverted="true" marginBottom="65" marginRight="75" style="width: 850px; height: 400px; margin:10px" type="column"> <a:title text="最常用功能" x="-20"/> <a:xAxis> <a:xAxi name="page"/> </a:xAxis> <a:yAxis> <a:yAxi name="visits"> <a:title text="visits"/> </a:yAxi> </a:yAxis> </a:chart> </a:screenBody> <script type="text/javascript"><![CDATA[ var r = $('query_ds2').getCurrentRecord(); r.set('endDate', new Date()); var d = new Date(); d.setTime(d.getTime() - 1000 * 60 * 60 * 24 * 10); r.set('startDate', d); ]]></script> </a:view> </a:screen>