<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangguangfan2864
    $Date: 2011-8-5 下午02:29:26  
    $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_user" 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_user_result" autoQuery="true" loadData="true" model="hls_fnd.HLS_SYS1020.hls_sys_homepage_msg_user" queryUrl="${/request/@context_path}/autocrud/hls_fnd.HLS_SYS1020.hls_sys_homepage_msg_user/query?message_id=${/parameter/@message_id}" selectable="true">
                <a:fields>
                    <a:field name="user_name" lovGridHeight="340" lovHeight="460" lovService="hls_fnd.hls_fnd_user_for_lov" lovWidth="340" required="true" title="HLS_SYS_HOMEPAGE_MESSAGE.USER_INFO">
                        <a:mapping>
                            <a:map from="user_id" to="user_id"/>
                            <a:map from="user_name" to="user_name"/>
                            <a:map from="description" to="description"/>
                        </a: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_user" prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_CODE"/>
                <a:textField name="message_desc" bindTarget="hls_sys_homepage_message_user" prompt="HLS_SYS_HOMEPAGE_MESSAGE.MESSAGE_DESC"/>
            </a:fieldSet>
            <a:grid id="user_grid_id" bindTarget="hls_sys_homepage_message_user_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="user_name" editor="lovEdit" prompt="SYS_USER.USER_NAME"/>
                    <a:column name="description" prompt="SYS_USER.DESCRIPTION" 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>
