<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-4-10 下午01:22:30  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure><![CDATA[
    ]]></a:init-procedure>
    <a:view>
        <a:link id="hls_bp_master_details_define_id" url="${/request/@context_path}/modules/hls/HLS211/hls_bp_master_details_define.lview"/>
        <script type="text/javascript"><![CDATA[
            function hls_hls211_create() {
                $('hls_hls211_create_id').disable();
                if (!$('hls_bp_master_define_head_ds').validate()) {
                    $('hls_hls211_create_id').enable();
                    return;
                }
                var m = 0;
                var head_record = $('hls_bp_master_define_head_ds').getAt(0);
                if (head_record.get('bp_class_display1') != 'N') {
                    head_record.set('bp_class', head_record.get('bp_class_display1'));
                    m = m + 1;
                }
                if (head_record.get('bp_class_display2') != 'N') {
                    head_record.set('bp_class', head_record.get('bp_class_display2'));
                    m = m + 1;
                }
                if (head_record.get('bp_class_display3') != 'N') {
                    head_record.set('bp_class', head_record.get('bp_class_display3'));
                    m = m + 1;
                }
                if (m > 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS_BP_CLASS_UNIQUE}');
                    $('hls_hls211_create_id').enable();
                    return;
                }
                var bp_name = encodeURIComponent(head_record.get('bp_name'));
                var bp_type = encodeURIComponent(head_record.get('bp_type'));
                var bp_code;
                if (Ext.isDefined(head_record.get('bp_code'))) {
                    bp_code = encodeURIComponent(head_record.get('bp_code'));
                } else {
                    bp_code='';
                }
                var bp_class = encodeURIComponent(head_record.get('bp_class'));
                window.location.href = $('hls_bp_master_details_define_id').getUrl() + '?bp_name=' + bp_name + '&bp_type=' + bp_type + '&bp_code=' + bp_code + '&bp_class=' + bp_class;
            }
            
            function hls211_head_update(ds, record, name, value, old_value) {
                if (name == 'bp_class_display1') {
                    if (value != 'N') {
                        record.set('bp_class', value);
                        record.set('bp_class_display2', 'N');
                        record.set('bp_class_display3', 'N');
                    }
                } else if (name == 'bp_class_display2') {
                    if (value != 'N') {
                        record.set('bp_class', value);
                        record.set('bp_class_display1', 'N');
                        record.set('bp_class_display3', 'N');
                    }
                } else if (name == 'bp_class_display3') {
                    if (value != 'N') {
                        record.set('bp_class', value);
                        record.set('bp_class_display1', 'N');
                        record.set('bp_class_display2', 'N');
                    }
                } else if (name == 'auto_coding') {
                    if (value == 'N') {
                        record.getField('bp_code').setReadOnly(false);
                        record.getField('bp_code').setRequired(true);
                    }
                    if (value == 'Y') {
                        record.set('bp_code', '');
                        record.getField('bp_code').setReadOnly(true);
                        record.getField('bp_code').setRequired(false);
                    }
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls_bp_master_define_head_ds" autoCreate="true">
                <a:fields>
                    <a:field name="bp_name" prompt="HLS.BP_NAME" required="true"/>
                    <a:field name="bp_type_desc" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_type_v_for_lov?enabled_flag=Y" lovWidth="500" prompt="HLS_BP_TYPE.BP_TYPE" required="true" title="HLS_BP_TYPE.BP_TYPE">
                        <a:mapping>
                            <a:map from="description" to="bp_type_desc"/>
                            <a:map from="bp_type" to="bp_type"/>
                            <a:map from="bp_category_desc" to="bp_category_desc"/>
                            <a:map from="bp_category" to="bp_category"/>
                            <a:map from="auto_coding" to="auto_coding"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_category_desc" prompt="HLS_BP_TYPE.BP_CATEGORY_DESC" readOnly="true"/>
                    <a:field name="bp_category"/>
                    <a:field name="auto_coding"/>
                    <a:field name="bp_code" prompt="HLS.BP_CODE" readOnly="true"/>
                    <a:field name="bp_class_display1" checkedValue="ORG" defaultValue="ORG" prompt="HLS.ORG" uncheckedValue="N"/>
                    <a:field name="bp_class_display2" checkedValue="NP" defaultValue="N" prompt="HLS.NATURAL_PERSONS" uncheckedValue="N"/>
                    <a:field name="bp_class_display3" checkedValue="INS" defaultValue="N" prompt="HLS.HYBRID" uncheckedValue="N"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="hls211_head_update"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form labelWidth="120" title="HLS_BP_MASTER_CRAETE" width="400">
                <a:textField name="bp_name" bindTarget="hls_bp_master_define_head_ds"/>
                <a:lov name="bp_type_desc" bindTarget="hls_bp_master_define_head_ds"/>
                <a:textField name="bp_category_desc" bindTarget="hls_bp_master_define_head_ds"/>
                <a:textField name="bp_code" bindTarget="hls_bp_master_define_head_ds"/>
                <a:checkBox name="bp_class_display1" bindTarget="hls_bp_master_define_head_ds"/>
                <a:checkBox name="bp_class_display2" bindTarget="hls_bp_master_define_head_ds"/>
                <a:checkBox name="bp_class_display3" bindTarget="hls_bp_master_define_head_ds"/>
            </a:form>
            <a:screenTopToolbar>
                <a:gridButton id="hls_hls211_create_id" click="hls_hls211_create" text="HLS.CREATE"/>
            </a:screenTopToolbar>
        </a:screenBody>
    </a:view>
</a:screen>