<?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:view>
        <a:link id="con620n_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con626_dunning_letter_info_link_id" model="cont.CON626.con_dunning_letter_info" modelaction="batch_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/CON626/con_rent_dun_print.lsc"/>
        <a:link id="leg_content_print_detail_link" url="${/request/@context_path}/modules/leg/LEG400/leg_content_print_detail.lview"/>
        <script type="text/javascript"><![CDATA[
            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;
                //
                /* new Leaf.Window({
                 id: 'con_get_layout_code_winid',
                 params: param,
                 url: $('con_contract_update_link_id').getUrl(),
                 title: param['url_title'] + '(' + 'CONTRACT_QUERY' + ')',
                 fullScreen: true,
                 draggable: true
                 }); */
                hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_contract_update_link_id', ds_id);
            }
            
            // function doc_print(contract_id){
            
            // }
            
            function print() {
                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}', '请选择数据');
                } else {
            
                    for (i = 0;i < records.length;i++) {
                        var contract_id = records[i].get('contract_id');
                        var contract_number = records[i].get('contract_number');
                        var file_name = '催款通知书' + contract_number;
                        var url = $('con602_excel_export_link').getUrl() + '?contract_id=' + contract_id + '&file_name=' + file_name + '&templt_name=' + 'leg_dunning_notice.xml';
                        window.open(url);
                    }
                }
            }
            
            //打印催款函
            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 records = $(ds_id).getSelected();
                if (records.length == 0) {
                    Leaf.showMessage('${l:PROMPT}', '请选择数据');
                }
                var datas = [];
                for (var i = 0;i < records.length;i++) {
                    var obj = {};
                    obj['contract_id'] = records[i].get('contract_id');
                    obj['_status'] = 'update';
                    datas[i] = obj;
                }
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                Leaf.request({
                    url: $('con626_dunning_letter_info_link_id').getUrl(),
                    para: datas,
                    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}_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;
            };
            
            //查询时调用(grid,table,gridBox)
            /*    window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
             var con_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
             if (ds.id == con_ds_id) {
             }
             }; */
        ]]></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>
