<?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:view>
        <a:link id="con_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_dunning_letter_submit_link_id" model="cont.CON625.con_dunning_letter_submit" modelaction="update"/>
        <!--         <a:link id="leg_legal_fee_modify_link_id" url="${/request/@context_path}/modules/leg/LEG450/leg_legal_fee_modify.lview"/> -->
        <script type="text/javascript"><![CDATA[
            window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
                 var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_dunning_letter');
                 
                  var record = $(ds_id).getCurrentRecord();
                var dunning_letter_id = record.get('dunning_letter_id');
            
                if ($(ds_id).validate()) {
            
                    window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                    Leaf.request({
                        url: $('con_dunning_letter_submit_link_id').getUrl(),
                        para: {
                            dunning_letter_id: dunning_letter_id
                        },
                        success: function(res) {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            $('${/parameter/@winid}').close();
                        },
                        failure: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        error: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        scope: this
                    });
                } else {
                    Leaf.showMessage('提示', '请先保存再提交审批！', null, 350);
                }
            
            };
            
           
           //保存前调用
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                
                var dun_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_dunning_letter');
                  var dun_record = $(dun_ds_id).getCurrentRecord();
                var con_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                 var con_record = $(con_ds_id).getCurrentRecord();  
            
                dun_record.set('overdue_amount',con_record.data['overdue_amount']);
                dun_record.set('overdue_times',con_record.data['overdue_times']);
                dun_record.set('bp_id_tenant',con_record.data['bp_id_tenant']);
                dun_record.set('reamin_principal',con_record.data['reamin_principal']);
                dun_record.set('promised_return_date',con_record.data['promised_return_date']);
                dun_record.set('promised_return_amount',con_record.data['promised_return_amount']);
                dun_record.set('contract_status',con_record.data['contract_status']);//
                var check_flag = true;
                return check_flag;
            }; 

        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
