<?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_contract_maintain_flag_update_link" model="cont.CON504.con_contract_maintain_flag_update" modelaction="execute"/>
        <a:link id="con_contract_content_confirm_link_1" url="${/request/@context_path}/modules/cont/CON504/con_contract_content_print.lview"/>
        <a:link id="con504_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_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}_user_button3_layout_dynamic_click'] = function() {
				 Leaf.showConfirm('提示','您确认拒绝?',function() {
					Leaf.request({
					    url:$('con504_contract_maintain_flag_update_link').getUrl(),
					    para: {
                            contract_id:'${/parameter/@contract_id}'
                        },
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '已拒绝',
                                duration: 2000
                            });
                            Leaf.go($('con_contract_content_confirm_link_1').getUrl());
                            $('con505_contract_result_ds').query();
                        },
                        scope: this
					});		
				});	
            };
        
        	
            // 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, 'con504_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>