sch_schedule_maintain.lview 10.7 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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-26 下午2:37:49  
    $Revision: 1.0  
    $Purpose: scheduleMaintainScreen
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="pageLink_scheduleMaintainScreen_schedule_update" url="${/request/@context_path}/modules/sch/SCH101/sch_schedule_update.lview"/>
        <a:link id="pageLink_scheduleMaintainScreen_schedule_create" url="${/request/@context_path}/modules/sch/SCH101/sch_schedule_create.lview"/>
        <script type="text/javascript"><![CDATA[
        
        //-----------------------------------------------------------------------------------------------------------
        //下面代码用于子页面
        
        function validate_integer(value)
        {
            var reg = /^-?([0-9]{1,2})(,-?[0-9]{1,2})*$/;
       		if(reg.test(value))
       		{
       		    return true;
       		}
       		else
       		{
       		    return false;
       		}
        }
        
        function get_integer_array(value)
        {
            return value.split(',');
        }
        
        function validate_integer_common(value,errMsg,allow_null,func)
        {
            if(allow_null&&Ext.isEmpty(value))
            {
                return true;
            }
            if(validate_integer(value)==true)
            {
                var array = get_integer_array(value);
   		        for (var i=0;i<array.length;i++)
   		        {
   		            var n_value=Number(array[i]);
   		            
   		            if(func(n_value)==false)
   		            {
   		                return errMsg;
   		            }
   		            
   		        }
   		        return true;
            }
       		else
       		{
       		    return errMsg;
       		}
        }
        
        function validate_number_list(min,max,value,errMsg,allow_null)
        {
            return validate_integer_common(value,errMsg,allow_null,function(value){
            	if(!(value>= min) || !(value <= max))
   		        {
   		            return false;
   		        }
            });
        }
        
        function validate_functionName(record,name,value)
        {
            var reg = /^[a-zA-z]+.*$/;
       		if(reg.test(value))
       		{
       		    return true;
       		}
       		return '首字符只能为英文字母';
        }
        
        
        function validate_para_bymonthday(record,name,value)
        {
            if(record.getField(name).isReadOnly())
            {
                return true;
            }
            return validate_integer_common(value,'-31~-1 or 1~31[,-31~-1 or 1~31];example:-5,-3,5,25',true,function(value){
                if(value==0 || !(value>= -31) || !(value <= 31))
   		        {
   		            return false;
   		        }
   		        return true;
            });
        }
        
        function validate_0_23(record,name,value)
        {
            if(record.getField(name).isReadOnly())
            {
                return true;
            }
            return validate_number_list(0,23,value,'0~23[,0~23];example:0,6,12,18',true);
        }
        
        function validate_0_59(record,name,value)
        {
            if(record.getField(name).isReadOnly())
            {
                return true;
            }
            return validate_number_list(0,59,value,'0~59[,0~59];example:0,10,20,30,40,50',true);
        }
        
        function validate_1_7(record,name,value)
        {
            if(record.getField(name).isReadOnly())
            {
                return true;
            }
            return validate_number_list(1,7,value,'1=Monday;1~7[,1~7];example:1,3,5',true);
        }
        
        function validate_para_interval(record,name,value)
        {
            if(Number(value) >=1 && Number(value) <=99)
            {
                return true;
            }
            else
            {
                return '1~99';
            }
        }
        
        function field_enable(record,name,required)
        {
            var field=record.getField(name);
            field.setReadOnly(false);
            if(required)
            {
                field.setRequired(true);
            }
        }
        
        
        
        function field_disable(record,name)
        {
            var field=record.getField(name);
            field.setReadOnly(true);
            field.setRequired(false);
            record.set(name,'');
        }
        
        function setDefaultValue(record,name,value)
        {
            if(Ext.isEmpty(record.get(name)))
            {
                record.set(name,value);
            }
            
        }
        
        function controlPage(record,value)
        {
            //频率为小时和分钟,不启用时分
            if(value=='MINUTELY'||value=='HOURLY')
            {
                field_disable(record,'para_byhour');
            	field_disable(record,'para_byminute');
            }
            else
            {
                field_enable(record,'para_byhour',false);
            	field_enable(record,'para_byminute',false);
            	//setDefaultValue(record,'para_byhour','0');
            	//setDefaultValue(record,'para_byminute','0');
            	//setDefaultValue(record,'para_bysecond','0');
            }
            
            //月启用第几天,周启用周几,其他都不启用
            if(value=='MONTHLY')
            {
                field_enable(record,'para_bymonthday');
                field_disable(record,'para_byday');
            }
            else if(value=='WEEKLY')
            {
                field_disable(record,'para_bymonthday');
                field_enable(record,'para_byday');
            }
            else
            {
                field_disable(record,'para_bymonthday');
                field_disable(record,'para_byday');
            }
        }
        
        //上面代码用于子页面
        //-----------------------------------------------------------------------------------------------------------
        
        
        function scheduleMaintainScreen_forward() {
            history.go(1);
        }
        
        function scheduleMaintainScreen_back() {
            history.go(-1);
        }
        
        function scheduleMaintainScreen_query() {
            $('scheduleMaintainScreen_mainDs').query();
        }
        
        function scheduleMaintainScreen_add() {
            new Leaf.Window({
                id: 'sch_schedule_create',
                url: $('pageLink_scheduleMaintainScreen_schedule_create').getUrl(),
                title: '${l:SCH101.SCHEDULE_CREATE}',
                width:480,
                height:550
            });
        }
        
        
        
        function scheduleMaintainScreen_remove() {
            $('scheduleMaintainScreen_mainDs_grid').remove();
        }
        
        function scheduleMaintainScreen_save() {
            var ds = $('scheduleMaintainScreen_mainDs');
            if (ds.validate()) {
                ds.submit();
            }
        }
        
        function editFunction_scheduleMaintainScreen_schedule_name(record, name) {
            if(record.isNew)
            {
                return 'scheduleMaintainScreen_mainDs_grid_tf';
            }
            else
            {
                return '';
            }
        }
        
        function render_scheduleMaintainScreen_schedule_update(value, record, name)
        {
            if(!record.isNew){
	            var schedule_name = record.get('schedule_name');
	            return '<a href="javascript:winOpen_scheduleMaintainScreen_schedule_update(\'' + schedule_name + '\');">' + '${l:SCH101.SCHEDULE_UPDATE_LINK}' + '</a>';
            }
            return '';
        }
        
        function winOpen_scheduleMaintainScreen_schedule_update(schedule_name)
        {
            new Leaf.Window({
                id: 'sch_schedule_update',
                url: $('pageLink_scheduleMaintainScreen_schedule_update').getUrl(),
                params:{
                	schedule_name:schedule_name
                },
                title: '${l:SCH101.SCHEDULE_UPDATE}',
                width:480,
                height:550
            });
        }
            
        ]]></script>
        <a:dataSets>
            <a:dataSet id="scheduleMaintainScreen_paraDs" autoCreate="true" model="sch.SCH101.sch_schedule">
                <a:fields>
                    <a:field name="setup_mode" defaultValue="SIMPLE"/>
                    <a:field name="schedule_name"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="scheduleMaintainScreen_mainDs" autoPageSize="true" autoQuery="true" model="sch.SCH101.sch_schedule" queryDataSet="scheduleMaintainScreen_paraDs" selectable="true">
                <a:fields>
                    <a:field name="schedule_name" required="true"/>
                    <a:field name="short_desc" required="true"/>
                    <a:field name="full_desc" required="true"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="scheduleMaintainScreen_back" text="HLS.BACK"/>
                <a:gridButton click="scheduleMaintainScreen_forward" text="HLS.FORWARD"/>
                <a:gridButton click="scheduleMaintainScreen_query" text="HLS.QUERY"/>
                <a:gridButton click="scheduleMaintainScreen_add" text="HLS.NEW"/>
                <a:gridButton click="scheduleMaintainScreen_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="2" title="HAP_QUERY_TITLE">
                <a:textField name="schedule_name" bindTarget="scheduleMaintainScreen_paraDs" typeCase="upper"/>
                <a:textField name="short_desc" bindTarget="scheduleMaintainScreen_paraDs"/>
            </a:form>
            <a:grid id="scheduleMaintainScreen_mainDs_grid" bindTarget="scheduleMaintainScreen_mainDs" marginHeight="180" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="schedule_name" editorFunction="editFunction_scheduleMaintainScreen_schedule_name" width="150"/>
                    <a:column name="short_desc" editor="scheduleMaintainScreen_mainDs_grid_tf" width="200"/>
                    <a:column name="full_desc" editor="scheduleMaintainScreen_mainDs_grid_tf" width="350"/>
                    <a:column name="schedule_update" prompt="SCH101.SCHEDULE_UPDATE" renderer="render_scheduleMaintainScreen_schedule_update"/>
                </a:columns>
                <a:editors>
                    <a:textField id="scheduleMaintainScreen_mainDs_grid_tf"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>