<?xml version="1.0" encoding="UTF-8"?>
<!--
  create by nyl  2014-12-3 
  for contract context create
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query model="acr.ACR516.acr_vat_import_batch_id" rootPath="batch_id"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con620n_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con620n_dunning_record_link_id" model="cont.CON620N.lsh_dun_email" modelaction="update"/>
        <!-- <a:link id="con_contract_update_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update.lview"/> -->
        <a:link id="con_contract_lawyer_letter_print_link_id" url="${/request/@context_path}/modules/cont/CON620/con_contract_lawyer_letter_print.lview"/>
        <a:link id="con_contract_legal_letter_create_link_id" url="${/request/@context_path}/modules/leg/LEG600/legal_opinion_letter_create.lview"/>
        <a:link id="con_contract_rent_dun_link_id" url="${/request/@context_path}/modules/cont/CON621/con_contract_rent_dun_modify.lview"/>
        <a:link id="con_dunning_letter_create_link_id" url="${/request/@context_path}/modules/cont/CON625/con_dunning_letter_create.lview"/>
        <a:link id="con_contract_update_link_id" url="${/request/@context_path}/modules/cont/CON301/con_contract_query_n.lview"/>
        <a:link id="con602_excel_export_link" url="${/request/@context_path}/modules/cont/CON620N/con_dun_word_export.lview"/>
        <a:link id="con620_excel_export_id" url="${/request/@context_path}/modules/cont/CON620N/con_export_excel_sheets.lsc"/>
        <a:link id="con602_import_link_id" url="${/request/@context_path}/modules/cont/CON620N/con_dun_import_upload.lview"/>
        <a:link id="con_dunning_letter_modify_link_id" url="${/request/@context_path}/modules/cont/CON627/con_dunning_letter_modify.lview"/>
        <script type="text/javascript"><![CDATA[
        
        	 //催收明细导入
            window['${/parameter/@layout_code}_user_button6_layout_dynamic_click'] = function() {
            
               new Leaf.Window({
                 //   id: 'upload_window',
                    url: $('con602_import_link_id').getUrl() + '?batch_id=${/model/batch_id/record/@batch_id}',
                    title: '导入催收明细',
                    width: 420,
                    height: 280
                });
            
            };
        	
        	
            function con620n_open_contract_win(record_id, ds_id) {
               var record = $(ds_id).findById(record_id);
               var param = record.data; 
              
                maintain_type = 'READONLY';
                param['function_code'] = 'CON301R';
                param['function_usage'] = 'MODIFY'; 
                param['url_title'] = '合同明细';
                url_l = 'con_contract_update_link_id';
                param['maintain_type'] = maintain_type;
 
               hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_contract_update_link_id', ds_id);                        
            }
            //记录邮件信息
          function email_info(){
               var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var records = $(ds_id).getSelected();
                if (records.length == 0) {
                    Leaf.showMessage('${l:PROMPT}', '请选择数据');
                    return;
                }
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                Leaf.request({
                    url: $('con620n_dunning_record_link_id').getUrl(),
                    para: null,
                    success: function(res) {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        Leaf.SideBar.show({
                            msg: '${l:HLS.SUBMIT_SUCCESS}',
                            duration: 2000
                        });
                        print();
                    },
                    failure: function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    error: function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    sync: true,
                    scope: this
                });
          }
            
         //催收记录打印
            window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function() {
              
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var records = $(ds_id).getSelected();
                if (records.length == 0) {
                    Leaf.showMessage('提示', '请选择数据！', null, 350);
                    return;
                }
                var contract_id = '(';
				for(i=0;i<records.length;i++){
				    contract_id += records[i].get('contract_id'); 
				    if(i == records.length-1){
				        contract_id += ')';
				    }else{
				        contract_id += ',';
				    }
				}
				var url = $('con620_excel_export_id').getUrl() + '?contract_id=' + contract_id;
	    	    window.open(url);
	    	   // Leaf.post(url);
            };
            
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'contract_number') {
                    return '<a href="javascript:con620n_open_contract_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
            
                return value;
            };
            
            
            //催款函申请
            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 records = $(ds_id).getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('提示', '请选择单条数据！', null, 350);
                    return;
                }
                var param = records[0].data;
            
                param['function_code'] = 'CON625';
                param['function_usage'] = 'CREATE';
                param['url_title'] = '催款函创建';
                hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_dunning_letter_create_link_id', ds_id);
            
            };
            
            //租金催收记录
            window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                //  var record = $(ds_id).findById(record_id);
                var records = $(ds_id).getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('提示', '请选择单条数据！', null, 350);
                    return;
                }
                var param = records[0].data;
                //var param = record.data;
                param['function_code'] = 'CON621';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '租金催收';
                hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_contract_rent_dun_link_id', ds_id);
            
            };
            //律师函申请
            window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function() {
           
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var records = $(ds_id).getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('提示', '请选择单条数据！', null, 350);
                    return;
                }
                var param = records[0].data;
                var maintain_type = 'CREATE';
                param['function_code'] = 'LEG600';
                param['function_usage'] = 'CREATE';
                param['url_title'] = '律师函申请创建';
                param['maintain_type'] = maintain_type;
                hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_contract_legal_letter_create_link_id');
            
            };
 
            
             //催款函发送情况维护
            window['${/parameter/@layout_code}_user_button7_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var records = $(ds_id).getSelected();
              
                if (records.length != 1) {
                    Leaf.showMessage('提示', '请选择单条数据！', null, 350);
                    return;
                }
                var param = records[0].data;
                var maintain_type = 'MODIFY';
                param['function_code'] = 'CON627';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '催款函发送情况维护';
                param['maintain_type'] = maintain_type;
                hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_dunning_letter_modify_link_id');
            };
            
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'contract_number') {
                    return '<a href="javascript:con620n_open_contract_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
            
                return value;
            };
            
             window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON620N"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
