<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ericyin  
    $Date: 2012-12-18 上午11:03:33  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="rsc_five_class_code_link" url="${/request/@context_path}/modules/rsc/RSC202/rsc_five_class_codes.lview"/>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
            function rsc_202_query() {
                $('rsc202_result_ds').query();
            }
            
            function rsc_202_grid_submit() {
                var result_ds = $('rsc202_result_ds');
                if (result_ds.validate()) {
                    result_ds.submit();
                }
            }
            
            function rsc_202_grid_add() {
                $('rsc_class_plan_grid').showEditorByRecord($('rsc202_result_ds').create());
            }
            
            function rsc_202_next() {
                history.go(1);
            }
            
            function rsc_202_back() {
                history.go(-1);
            }
            
            function rsc_202_quit() {
                location.href = $('sys_service_welcome_link').getUrl();
                parent.shMenu('show');
            }
            
            function rsc_202_grid_clear() {
                $('rsc_class_plan_grid').remove();
            }
            
            function rsc202PlanCodeFunction(record, name) {
                if (record.isNew) {
                    return 'rsc202_five_class_plan_tf';
                } else {
                    return '';
                }
            }
            
            function rsc202ModifyPageRenderer(value, record, name) {
                var plan_code = record.get('five_class_plan_code');
                if (record.isNew) {
                    return '';
                }
                return '<a href="javascript:rsc202OpenPage(\'' + plan_code + '\')">${l:RSC_FIVE_CLASS_PLANS.MODIFY_PAGE}</a>';
            }
            
            function rsc202OpenPage(plan_code) {
                new Leaf.Window({
                    id: 'rsc_five_class_code_window',
                    url: $('rsc_five_class_code_link').getUrl() + '?plan_code=' + plan_code,
                    title: '${l:RSC_FIVE_CLASS_PLANS.SET_CODE}',
                    height: 435,
                    width: 620
                });
            }
            
            function planCodeValidator(record, name, value) {
                if (name == 'five_class_plan_code' && record.isNew) {
                    var records = $('rsc202_result_ds').getAll();
            
                    for (var i = 0,
                        length = records.length;i < length;i++) {
                        var r = records[i],
                            v = r.get(name);
            
                        if (r != record && v == value) {
                            return '${l:RSC_FIVE_CLASS_PLANS.E001}';
                        }
                    }
                }
                return true;
            }
            
            function rsc202ClassPlanUpdate(ds, record, name, valid) {
                if (name == 'five_class_plan_code' && !valid) {
            		Leaf.showInfoMessage('错误', '${l:RSC_FIVE_CLASS_PLANS.E001}');
                   }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="rsc202_query_ds" model="rsc.RSC202.rsc_five_class_plans"/>
            <a:dataSet id="rsc202_result_ds" autoCount="true" autoQuery="true" fetchAll="false" model="rsc.RSC202.rsc_five_class_plans" pageSize="15" queryDataSet="rsc202_query_ds" selectable="true">
                <a:fields>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="five_class_plan_code" required="true" validator="planCodeValidator"/>
                    <a:field name="five_class_plan_type"/>
                    <a:field name="calculate_object"/>
                    <a:field name="update_system_method"/>
                    <a:field name="description" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="valid" handler="rsc202ClassPlanUpdate"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar height="29">
                <a:button click="rsc_202_back" height="20" icon="${/request/@context_path}/images/back.png" iconAlign="left" text="HLS.BACK" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="rsc_202_next" height="20" icon="${/request/@context_path}/images/forward.png" iconAlign="left" text="HLS_FORWARD" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="rsc_202_quit" height="20" icon="${/request/@context_path}/images/quit.png" iconAlign="left" text="HLS.EXIT" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="rsc_202_grid_add" height="20" icon="${/request/@context_path}/images/add.png" iconAlign="left" text="HLS.NEW" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="rsc_202_grid_clear" height="20" icon="${/request/@context_path}/images/remove.png" iconAlign="left" text="HLS_REMOVE" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="rsc_202_grid_submit" height="20" icon="${/request/@context_path}/images/save.png" iconAlign="left" text="HLS.SAVE" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="rsc_202_query" height="20" icon="${/request/@context_path}/images/search.png" iconAlign="left" text="HAP_QUERY" width="50"/>
                <a:separator style="margin-left:3px;"/>
            </a:screenTopToolbar>
            <a:grid id="rsc_class_plan_grid" bindTarget="rsc202_result_ds" height="490" marginWidth="20" navBar="true" width="1000">
                <a:columns>
                    <a:column name="five_class_plan_code" align="left" editorFunction="rsc202PlanCodeFunction" sortable="true" width="100"/>
                    <a:column name="description" align="left" editor="rsc202_five_class_plan_tf" width="200"/>
                    <a:column name="five_class_plan_type" align="left" editor="rsc202_five_class_plan_tf" width="100"/>
                    <a:column name="calculate_object" align="left" editor="rsc202_five_class_plan_tf" width="100"/>
                    <a:column name="update_system_method" align="left" editor="rsc202_five_class_plan_tf" width="100"/>
                    <a:column name="rsc_202_link" align="left" prompt="RSC_FIVE_CLASS_PLANS.MODIFY" renderer="rsc202ModifyPageRenderer" width="80"/>
                    <a:column name="enabled_flag" align="center" editor="rsc202_five_class_plan_cb" width="50"/>
                </a:columns>
                <a:editors>
                    <a:textField id="rsc202_five_class_plan_tf"/>
                    <a:checkBox id="rsc202_five_class_plan_cb"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>