<?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/CON504/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="con_contract_update_print_detail_link_id" url="${/request/@context_path}/modules/cont/CON504/con_contract_content_confirm.lview"/>
        <a:link id="con504_change_confirm_status_link" model="cont.CON504.con_change_content_confirm_status" modelaction="execute"/>
        <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');
				Leaf.showConfirm('提示','您确定该合同信息无误？',function() {
					Leaf.request({
					   url: $('con504_change_confirm_status_link').getUrl(),
					   para:{
					       contract_id:contract_id
					   }
					});		
				});
            };
            
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
				 new Leaf.Window({
                    id: 'con_contract_update_print_detail_winid',
                    params: {
                        contract_id: '${/parameter/@contract_id}',
                        company_id: '${/parameter/@company_id}',
                        document_category:'${/parameter/@document_category}',
                        business_type :'${/parameter/@business_type}',
                        winid: 'con_contract_update_print_detail_winid'
                    },
                    url: $('con_contract_update_print_detail_link_id').getUrl(),
                    title: '合同文本生成',
                    width:1200,
                    height:550
                });
            };
        
        	
            // 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');
                new Leaf.Window({
                    id: 'contract_lease_item_maintain_window',
                    url: $('contract_lease_item_query_link').getUrl(),
                    params: {
                        contract_lease_item_id: contract_lease_item_id,
                        winid: 'contract_lease_item_maintain_window'
                    },
                    draggable: true,
                    fullScreen: true
                });
            };
            
            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>
