<?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="con620n_dunning_record_link_id" model="cont.CON620N.cus_dun_email" modelaction="update"/>
        <a:link id="con_contract_legal_letter_create_link_id" url="${/request/@context_path}/modules/cont/CON610/legal_opinion_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="legal_letter_create_link_id" url="${/request/@context_path}/modules/cont/CON610/legal_letter_create.lsc"/>
        <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;
            
                hls_doc_get_layout_code('con620n_get_layout_code_link_id', param, 'con_contract_update_link_id', ds_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}_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('提示', '请选择数据！', null, 350);
                    return;
                }
                var param = new Object();
                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;
                }
           
                param['line_info'] = datas;
            
            
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                Leaf.request({
                    url: $('legal_letter_create_link_id').getUrl(),
                    para: param,
                    success: function(res) {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        /* Leaf.SideBar.show({
                         msg: '${l:HLS.SUBMIT_SUCCESS}',
                         duration: 2000
                         }); */
                        if (res.result.letter_hd_id) {
                            var param = {
                                function_code: 'CON610D',
                                url_title: '律师函申请创建',
                                function_usage: 'CREATE',
                                maintain_type: 'CREATE',
                                letter_hd_id: res.result.letter_hd_id
                            };
                            hls_doc_get_layout_code('con620n_get_layout_code_link_id', param,'con_contract_legal_letter_create_link_id', ds_id);
                        }
                    },
                    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']();
                    },
                    scope: this
                });
            
            
            };
            
            
            
            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=CON610"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
