<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangguangfan2864
    $Date: 2011-8-5 下午02:47:36  
    $Revision: 1.0  
    $Purpose: 为消息分配角色
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view package="leaf.ui.std" template="default">
        <div/>
        <script type="text/javascript"><![CDATA[
        	function compareDate(start, end){
                if(start > end){
                    return false;
                }
                return true;
            }
            
            function dateValidator(record, name, value){
                if(name == 'start_date' || name == 'end_date'){
                    var start_date = record.get('start_date');
                    var end_date = record.get('end_date');
                    if(typeof(end_date) != 'undefined' && !Ext.isEmpty(end_date)){
                        if(!compareDate(start_date, end_date)){
                            return '开始时间不能大于结束时间';
                        }
                    }
                    return true;
                }
            }
            
            function onUpdate(ds,record,name,value){
                if(name == 'start_date' || name == 'end_date'){
                    record.validate((name == 'start_date') ? 'end_date' : 'start_date');
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls_sys_homepage_message_role" autoQuery="true" loadData="true" model="hls_fnd.HLS_SYS1020.hls_sys_homepage_message_for_maintain" queryUrl="${/request/@context_path}/autocrud/hls_fnd.HLS_SYS1020.hls_sys_homepage_message_for_maintain/query?message_id=${/parameter/@message_id}">
                <a:fields>
                    <a:field name="message_code" readOnly="true"/>
                    <a:field name="message_desc" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls_sys_homepage_message_role_result" autoQuery="true" loadData="true" model="hls_fnd.HLS_SYS1020.hls_sys_homepage_msg_role" queryUrl="${/request/@context_path}/autocrud/hls_fnd.HLS_SYS1020.hls_sys_homepage_msg_role/query?message_id=${/parameter/@message_id}" selectable="true">
                <a:fields>
                    <a:field name="role_code" lovGridHeight="340" lovHeight="460" lovService="sys.SYS1002.sys_role" lovWidth="340" required="true" title="HAP_SELECT_ROLE">
                        <mapping>
                            <map from="role_id" to="role_id"/>
                            <map from="role_code" to="role_code"/>
                            <map from="role_name" to="role_name"/>
                        </mapping>
                    </a:field>
                    <a:field name="start_date" required="true" validator="dateValidator"/>
                    <a:field name="end_date" validator="dateValidator"/>
                    <a:field name="message_id" defaultValue="${/parameter/@message_id}"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:fieldSet column="2" style="margin:10px" title="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_INFO" width="410">
                <a:textField name="message_code" bindTarget="hls_sys_homepage_message_role" prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_CODE"/>
                <a:textField name="message_desc" bindTarget="hls_sys_homepage_message_role" prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_DESC"/>
            </a:fieldSet>
            <a:grid id="role_grid_id" bindTarget="hls_sys_homepage_message_role_result" height="320" navBar="true" width="480">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="delete"/>
                    <a:button type="save"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="role_code" editor="lovEdit" prompt="SYS_ROLE.ROLE_CODE"/>
                    <a:column name="role_name" prompt="SYS_ROLE.ROLE_NAME" width="154"/>
                    <a:column name="start_date" editor="dateEdit" prompt="HLS_SYS_HOMEPAGE_MSG_USER.START_DATE" renderer="Leaf.formatDate"/>
                    <a:column name="end_date" editor="dateEdit" prompt="HLS_SYS_HOMEPAGE_MSG_USER.END_DATE" renderer="Leaf.formatDate"/>
                </a:columns>
                <a:editors>
                    <a:lov id="lovEdit"/>
                    <a:datePicker id="dateEdit"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
