sys_analytics.lview 4.68 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: jessen
    $Date: 2011-10-6 下午10:31:56
    $Revision: 1.0
    $Purpose:
-->
<a:screen xmlns:c="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" trace="true">
    <a:init-procedure>
        <a:model-query model="sys.SYS2520.sys_analytics_customize" rootPath="/model/customize"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            //onerror = function(m, u, l) {
            //    alert("msg : " + m + "\nurl : " + u + "\nline: " + l);
            //};
            var iii=0;
            function emptyRenderer() {
                return "";
            }
            
            function msRenderer() {
                if(Number(this.value)<0){
                   return "";
                }
                return this.value + "ms";
            }
            
            function dayRenderer(){
                //2011-10-10
                //返回10-10
                if(this.value){
                    return this.value.substr(5);
                }
            }
            
            function percentRenderer(){
                var n = Number(this.value);
                if(n<0||n>1){
                    return "";
                }else if(n==0){
                    return "0";
                }
                return (n*100).toFixed(2)+"%";
            }
            
            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 refreshAll() {
                var r = $('query_ds').getCurrentRecord();
                var sd = r.get('startDate');
                var ed = r.get('endDate');
                var date = new Date();
                date.setTime(date.getTime() - 1000 * 60 * 60 * 24);
                if (ed > date) {
                    ed = date;
                    r.set('endDate', ed);
                }
                //$('summary_of_day_ds').query();
                if (!r.validateRecord()) {
                    return;
                }
                var recs= $('min_screen_ds').getAll();
                for (var i = 0;i < recs.length;i++) {
                    eval(recs[i].get('callback')+"()");
                }
            }
            ]]></script>
        <a:dataSets>
            <a:dataSet id="query_ds" 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="min_screen_ds">
                <a:datas dataSource="/model/customize"/>
            </a:dataSet>
            <!--<a:dataSet id='summary_of_day_ds' model='sys.analytics.sys_analytics_summary_of_day' queryDataSet = 'query_ds' />-->
        </a:dataSets>
        <a:screenBody>
            <center>
                <a:form column="3">
                    <a:placeHolder id="screen_include_id"/>
                </a:form>
                <a:hBox>
                    <a:datePicker name="startDate" bindTarget="query_ds" prompt="起始日期"/>
                    <a:datePicker name="endDate" bindTarget="query_ds" prompt="结束日期"/>
                    <a:button click="refreshAll" text="刷新"/>
                </a:hBox>
            </center>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            var r = $('query_ds').getCurrentRecord();
            var date = new Date();
            date.setTime(date.getTime() - 1000 * 60 * 60 * 24);
            r.set('endDate', date);
            var d = new Date();
            d.setTime(date.getTime() - 1000 * 60 * 60 * 24 * 10);
            r.set('startDate', d);
            refreshAll();
        ]]></script>
    </a:view>
    <a:view-config>
        <c:create-config targetId="screen_include_id">
            <p:loop nullable="true" source="/model/customize">
                <c:process-config>
                    <a:screen-include screen="${@screen}"/>
                </c:process-config>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>