<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-8-1 下午02:44:52  
    $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_maintain_link" url="${/request/@context_path}/modules/cont/CON501N/con_lease_item_maintain.lview"/>
        <a:link id="contract_history_window_link" url="${/request/@context_path}/modules/cont/CON501N/con_document_history_query.lview"/>
        <a:link id="con501_item_detail_maintain" url="${/request/@context_path}/modules/cont/CON501N/con_item_detail_maintain.lview"/>
        <a:link id="con501_hls_bp_master_modify_link" url="${/request/@context_path}/modules/cont/CON501N/hls_bp_master_modify.lview"/>
        <a:link id="con501_contract_maintain_flag_update_link" model="cont.CON500.con_contract_prj_maintain_flag_update" modelaction="update"/>
        <a:link id="con501_contract_maintain_entrance_link" url="${/request/@context_path}/modules/cont/CON501N/con_contract_modify_entrance.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}_user_button2_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:$('con501_contract_maintain_flag_update_link').getUrl(),
					    para: {
                            contract_id:contract_id
                        },
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '已提交',
                                duration: 2000
                            });
                           $('${/parameter/@winid}').close(); 
                        },
                        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;
                param['function_code']='CON501M';
                param['function_usage']='MODIFY';
                param['url_title']='租赁物明细维护';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con501_item_detail_maintain', record.ds.id, '${/parameter/@layout_code}');
                // 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_id:'${/parameter/@contract_id}',
                        // 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'] = 'CON501H';
                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, 'con501_hls_bp_master_modify_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>
