<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-9 下午04:24:11  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="hls_bp_master_dynamic_update_link_id" url="${/request/@context_path}/modules/hls/HLS213/hls_bp_master_dynamic_update.lview"/>
        <a:link id="hls_bp_master_get_layout_code_link_id" model="hls.HLS213.hls_bp_master_get_layout_code" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
        	function hls_hls309_back(){
        	    history.go(-1);
        	}
        	
        	 
            function hls_hls309_next() {
                history.go(1);
            }
            
        
        	function hls_hls209_query() {
                $('hls_mortgage_result_ds').query();
            }
            
            function hls_hls209_reset() {
                $('hls_mortgage_query_ds').reset();
            }
            
            function mortgageCodeRender(value,record,name){
                return '<a href="javascript:openMortgageMaintain('+record.get('mortgage_id')+');">'+value+'</a>';
            }

            function mortgageQueryDsUpdate(ds, record, name, value, oldvalue){
                
                if(name=='mortgage_type'){
                    record.set('mortgage_ast_classfication','');
                    record.set('mortgage_ast_classfication_desc','');
                    record.set('mortgage_asset_detail','');
                    record.set('mortgage_asset_detail_desc','');
                    
                    var field = record.getField('mortgage_ast_classfication_desc');
                    if(value=='MORTGAGE'){
                        field.setOptions('asset_mortgage_ds');
                    }else{
                        field.setOptions('asset_pledge_ds');
                    }
                }else if(name=='mortgage_ast_classfication'){
                    record.set('mortgage_asset_detail','');
                    record.set('mortgage_asset_detail_desc','');
                    var field = record.getField('mortgage_asset_detail_desc');
                    if(value=='RIGHT_P'){
                        field.setOptions('asset_detail_right_p_ds');
                    }else if(value=='MOVABLE_PROPERTY_M' || value=='MOVABLE_PROPERTY_P'){
                        field.setOptions('asset_detail_movable_property_m_ds');
                    }else if(value=='IMMOVABLE_PROPERTY_M'){
                        field.setOptions('asset_detail_immovable_property_m_ds');
                    }else{
                        //field.setReadOnly(true);
                    }
                }
            }
            
            function mortgage_code_renderer(value,record,name){
                var mortgage_id=record.get('mortgage_id');
                if(!Ext.isEmpty(mortgage_id)){
                	return '<a href="javascript:open_window('+record.id+')">'+value+'</a>';
                }
            }
            function open_window(record_id){
                var current_record=$('hls_mortgage_result_ds').findById(record_id);
                var param=current_record.data;
                set_layout_parameters(param);
            }
            
             function set_layout_parameters(param){
                param['function_code'] = 'HLS309';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '${l:HLS_MORTGAGE.MORTGAGER_QUERY}';
                param['master_type']='MORTGAGE';
                param['master_id'] = param['mortgage_id'];
                hls_doc_get_layout_code('hls_bp_master_get_layout_code_link_id',param,'hls_bp_master_dynamic_update_link_id','hls_lease_item_result_ds');
            
            }
            
        ]]></script>
        <a:dataSets>
            <a:dataSet id="mortgage_type_ds" lookupCode="HLS209_MORTGAGE_TYPE"/>
            <a:dataSet id="asset_mortgage_ds" lookupCode="HLS209_ASSET_MORTGAGE"/>
            <a:dataSet id="asset_pledge_ds" lookupCode="HLS209_ASSET_PLEDGE"/>
            <a:dataSet id="asset_detail_right_p_ds" lookupCode="HLS209_ASSET_DETAIL_RIGHT_P"/>
            <a:dataSet id="asset_detail_movable_property_m_ds" lookupCode="HLS209_ASSET_DETAIL_MOVABLE_PROPERTY_M"/>
            <a:dataSet id="asset_detail_immovable_property_m_ds" lookupCode="HLS209_ASSET_DETAIL_IMMOVABLE_PROPERTY_M"/>
            <a:dataSet id="mortgage_status_ds" lookupCode="HLS209_MORTGAGE_STATUS"/>
            <a:dataSet id="hls_mortgage_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="mortgage_id"/>
                    <a:field name="mortgage_code" lovGridHeight="350" lovHeight="550" lovService="hls.HLS309.hls_mortgage_lv_for_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="mortgage_name" to="mortgage_name"/>
                            <a:map from="mortgage_code" to="mortgage_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="mortgage_type_desc" displayField="code_value_name" options="mortgage_type_ds" returnField="mortgage_type" valueField="code_value"/>
                    <a:field name="mortgage_ast_classfication_desc" displayField="code_value_name" options="asset_mortgage_ds" returnField="mortgage_ast_classfication" valueField="code_value"><![CDATA[
                    ]]></a:field>
                    <a:field name="mortgage_asset_detail_desc" displayField="code_value_name" options="asset_detail_right_p_ds" returnField="mortgage_asset_detail" valueField="code_value"/>
                    <a:field name="project_id"/>
                    <a:field name="project_number" lovGridHeight="300" lovHeight="550" lovService="prj.PRJ501.prj_project_for_lov" lovWidth="600">
                        <a:mapping>
                            <a:map from="project_id" to="project_id"/>
                            <a:map from="project_number" to="project_number"/>
                            <a:map from="project_name" to="project_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_mortgagor" fetchRemote="false" lovGridHeight="300" lovHeight="550" lovService="hls.HLS309.hls_bp_master_pledger_for_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_id_mortgagor"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_evaluator"/>
                    <a:field name="evaluator_name" lovAutoQuery="true" lovGridHeight="300" lovHeight="450" lovService="basic.hls_bp_master_v_for_lov" lovWidth="600" title="HLS209.EVALUATOR_QUERY">
                        <a:mapping>
                            <a:map from="bp_name" to="evaluator_name"/>
                            <a:map from="bp_id" to="bp_id_evaluator"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="mortgage_status_desc" displayField="code_value_name" options="mortgage_status_ds" prompt="HLS_MORTGAGE.MORTGAGE_STATUS" returnField="mortgage_status" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="mortgageQueryDsUpdate"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="hls_mortgage_result_ds" autoPageSize="true" autoQuery="true" model="hls.HLS309.hls_mortgage" queryDataSet="hls_mortgage_query_ds">
                <a:fields>
                    <a:field name="mortgage_status_desc"/>
                    <a:field name="enabled_flag" checkedValue="Y" readOnly="true" uncheckedValue="N"/>
                    <a:field name="bp_id_mortgagor_n"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screen-include screen="modules/hls/HLS213/hls_bp_master_get_layout_code.lview"/>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hls_hls309_back" text="HLS.BACK"/>
                <a:gridButton click="hls_hls309_next" text="HLS.FORWARD"/>
                <a:gridButton click="hls_hls209_query" text="HLS.QUERY"/>
                <a:gridButton click="hls_hls209_reset" text="HLS.RESET"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="200" title="HLS.QUERY_TITLE" width="1100">
                <a:lov name="mortgage_code" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.MORTGAGE_CODE"/>
                <a:textField name="mortgage_name" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.MORTGAGE_NAME"/>
                <a:lov name="project_number" bindTarget="hls_mortgage_query_ds" prompt="HLS.PROJECT_NUMBER"/>
                <a:textField name="project_name" bindTarget="hls_mortgage_query_ds" prompt="HLS.PROJECT_NAME"/>
                <a:comboBox name="mortgage_type_desc" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.MORTGAGE_TYPE"/>
                <a:comboBox name="mortgage_ast_classfication_desc" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.MORTGAGE_AST_CLASSFICATION"/>
                <a:comboBox name="mortgage_asset_detail_desc" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.MORTGAGE_ASSET_DETAIL"/>
                <a:textField name="mortgage_contract_no" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.MORTGAGE_CONTRACT_NO"/>
                <a:lov name="bp_id_mortgagor" bindTarget="hls_mortgage_query_ds" prompt="HLS_MORTGAGE.BP_ID_MORTGAGOR_N"/>
                <a:comboBox name="mortgage_status_desc" bindTarget="hls_mortgage_query_ds"/>
            </a:form>
            <a:grid id="hls_mortgage_grid_id" bindTarget="hls_mortgage_result_ds" marginHeight="230" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="mortgage_code" prompt="HLS_MORTGAGE.MORTGAGE_CODE" renderer="mortgage_code_renderer" width="150"/>
                    <a:column name="mortgage_name" prompt="HLS_MORTGAGE.MORTGAGE_NAME"/>
                    <a:column name="project_name" prompt="HLS.PROJECT_NAME" width="200"/>
                    <a:column name="mortgage_type_desc" prompt="HLS_MORTGAGE.MORTGAGE_TYPE" width="100"/>
                    <a:column name="mortgage_ast_class_desc" prompt="HLS_MORTGAGE.MORTGAGE_AST_CLASSFICATION" width="100"/>
                    <a:column name="mortgage_asset_detail_desc" prompt="HLS_MORTGAGE.MORTGAGE_ASSET_DETAIL" width="100"/>
                    <a:column name="bp_id_mortgagor_n" prompt="HLS_MORTGAGE.BP_ID_MORTGAGOR_N" width="200"/>
                    <a:column name="mortgage_contract_no" prompt="HLS_MORTGAGE.MORTGAGE_CONTRACT_NO"/>
                    <a:column name="mortgage_status_desc" prompt="HLS_MORTGAGE.MORTGAGE_STATUS"/>
                </a:columns>
                <a:editors>
                    <a:checkBox id="mortgage_grid_cb" checkedValue="Y" uncheckedValue="N"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
