<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ouyangzhaochang2663 $
    $Date: 2010/11/15 07:47:58 $
    $Revision: 1.3 $
    $Purpose: 任务定义及授权
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="sys_alert_rule_privilege_link" url="${/request/@context_path}/modules/sys/SYS2030/sys_alert_rule_privilege.lview"/>
        <a:link id="sys_alert_rule_parameters_link" url="${/request/@context_path}/modules/sys/SYS2030/sys_alert_rule_parameters.lview"/>
        <script type="text/javascript"><![CDATA[
            function queryAlertRules(){
                $('sys_alert_rules_result_ds').query();
            }
           	function resetAlertRules(){
           		$('sys_alert_rules_query_ds').reset();
           	}
            function setParameters(value, record, name){
                var alertRuleId = record.get('alert_rule_id');
                if(alertRuleId){
                    return '<a href="javascript:setParametersInfo('+alertRuleId+')">${l:PARAMATER_DEFINED}</a>';
                }else{
                    return '';
                }
            }
            
            function setParametersInfo(alertRuleId){
                new Leaf.Window({id:'sys_alert_rules_parameters_window', url:/*sys_alert_rule_parameters.screen*/$('sys_alert_rule_parameters_link').getUrl()+'?alert_rule_id='+alertRuleId, title:'${l:PROJECT_PARAMATER_DEFINED}', height:410,width:680});
            }
            
            function setPrivilege(value, record, name){
                var alertRuleId = record.get('alert_rule_id');
                if(alertRuleId){
                    return '<a href="javascript:setPrivilegeInfo('+alertRuleId+')">${l:ROLE_GRANT}</a>';
                }else{
                    return '';
                }
            }
            
            function setPrivilegeInfo(alertRuleId){
                new Leaf.Window({id:'sys_alert_rule_privilege_window', url:/*sys_alert_rule_privilege.screen*/$('sys_alert_rule_privilege_link').getUrl()+'?alert_rule_id='+alertRuleId, title:'${l:PROJECT_ROLE_GRANT}', height:410,width:600});
            }
            
            function alertRuleCodeEdit(record,name){
                if(record.isNew){
                    return 'alert_rule_code_grid_tf';
                }else{
                    return '';
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="sys_alert_rules_query_ds" model="sys.SYS2030.sys_alert_rules"/>
            <a:dataSet id="sys_alert_rules_result_ds" autoQuery="true" fetchAll="false" model="sys.SYS2030.sys_alert_rules" queryDataSet="sys_alert_rules_query_ds" selectable="true">
                <a:fields>
                    <a:field name="alert_rule_code" required="true"/>
                    <a:field name="event_name" lovGridHeight="300" lovHeight="460" lovService="sys.SYS2030.sys_alert_rules_event_lov" lovWidth="480" required="true" title="SYS_ALERT_RULES.SELECT_EVENT">
                        <a:mapping>
                            <a:map from="event_name" to="event_name"/>
                            <a:map from="event_desc" to="event_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form column="2" title="SYS_ALERT_RULES.ALERT_RULES_QUERY" width="500">
                <a:textField name="alert_rule_code" bindTarget="sys_alert_rules_query_ds" typeCase="upper">
                    <a:events>
                        <a:event name="enterdown" handler="queryAlertRules"/>
                    </a:events>
                </a:textField>
                <a:textField name="description" bindTarget="sys_alert_rules_query_ds">
                    <a:events>
                        <a:event name="enterdown" handler="queryAlertRules"/>
                    </a:events>
                </a:textField>
            </a:form>
            <a:hBox>
                <a:button click="queryAlertRules" text="HAP_QUERY"/>
                <a:button click="resetAlertRules" text="HAP_RESET"/>
            </a:hBox>
            <a:grid id="sys_alert_rules_grid" bindTarget="sys_alert_rules_result_ds" height="330" navBar="true" width="750">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="clear"/>
                    <a:button type="save"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="alert_rule_code" align="center" editorFunction="alertRuleCodeEdit" sortable="true" width="120"/>
                    <a:column name="description" align="left" editor="description_grid_tf" width="150"/>
                    <a:column name="event_name" align="center" editor="event_nme_lov" width="130"/>
                    <a:column name="event_desc" align="left" width="150"/>
                    <a:column name="enabled_flag" editor="enabled_flag_cb" sortable="true" width="40"/>
                    <a:column name="alert_rule_id" align="center" prompt="SYS_ALERT_RULES.PARAMETER_DEFINE" renderer="setParameters" width="60"/>
                    <a:column name="id" align="center" prompt="SYS_ALERT_RULES.ROLE_ASSIGN" renderer="setPrivilege" width="60"/>
                </a:columns>
                <a:editors>
                    <a:textField id="alert_rule_code_grid_tf" typeCase="upper"/>
                    <a:textField id="description_grid_tf"/>
                    <a:checkBox id="enabled_flag_cb"/>
                    <a:lov id="event_nme_lov"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>