<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zlf 
    $Date: 2014-11-10 下午5:42:24  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="contract_lease_item_query_link" url="${/request/@context_path}/modules/cont/CON505/con_lease_item_query.lview"/>
        <a:link id="contract_history_window_link" url="${/request/@context_path}/modules/cont/CON501N/con_document_history_query.lview"/>
        <a:link id="con505_hls_bp_master_query_link" url="${/request/@context_path}/modules/cont/CON505/hls_bp_master_query.lview"/>
        <a:link id="con505_item_detail_query" url="${/request/@context_path}/modules/cont/CON501N/con_item_detail_query.lview"/>
        <script type="text/javascript"><![CDATA[
        
        	window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
				var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
				var contract_id = $(ds_id).getCurrentRecord().get('contract_id');
				new Leaf.Window({
				    id:'contract_history_window',
				    url:$('contract_history_window_link').getUrl(),
				    params:{
				        contract_id:contract_id
				    },
				    fullScreen:true
				});			
            };
        
        	
            // window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
            
                // if (name == 'car_detail') {
                    // return '<a href="javascript:open_contract_window(\'' + record.id + '\',\'' + record.ds.id + '\')">' + config_record.get('prompt') + '</a>';
                // }
                // return value;
            // };
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) {
                var link_function = '';
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'bp_link' && record.get('bp_id') && record.get('record_id')) {
                    link_function = '${/parameter/@layout_code}_open_bp_detail_window';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name == 'car_detail' && record.get('contract_lease_item_id')) {
                    link_function = '${/parameter/@layout_code}_open_lease_item_detail_window';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + config_record.get('prompt') + '</a>';
                }
            };
            
            window['${/parameter/@layout_code}_open_lease_item_detail_window'] = function(id, name) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var param = record.data;
                var contract_lease_item_id = record.get('contract_lease_item_id');
                param['function_code']='CON501Q';
                param['function_usage']='QUERY';
                param['url_title']='租赁物明细查询';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con505_item_detail_query', record.ds.id, '${/parameter/@layout_code}');
            };
            
            window['${/parameter/@layout_code}_open_bp_detail_window'] = function(id, name) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var param = record.data;
                param['function_code'] = 'CON505H';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con505_hls_bp_master_query_link', record.ds.id, '${/parameter/@layout_code}');
            };
            
            
            // function open_contract_window(record_id, ds_id) {
            
                // var record = $(ds_id).findById(record_id);
            
                // var param = record.data;
                // var contract_lease_item_id = record.get('contract_lease_item_id');
                // new Leaf.Window({
                    // id: 'contract_lease_item_maintain_window',
                    // url: $('contract_lease_item_maintain_link').getUrl(),
                    // params: {
                        // contract_lease_item_id: contract_lease_item_id
                    // },
                    // fullScreen: true
                // });
                // // param['function_code'] = 'CON501D';
                // // param['function_usage'] = 'MODIFY';
                // // param['maintain_type'] = 'UPDATE';
                // // param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                // // hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link',ds_id);
            // }
        ]]></script>
    </a:view>
</a:screen>
