<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2015-12-02 下午1:29:07  
    $Revision: 1.0  
    $Purpose: 
-->
<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_contract_debt_exemption_req_change_req_submit_link_id" model="cont.CON715.con_contract_debt_exemption_req_change_req_submit" modelaction="update"/>
        <a:link id="con_contract_debt_exemption_req_change_req_cancel_link_id" model="cont.CON715.con_contract_debt_exemption_req_change_req_cancel" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            function get_warning_message(msg) {
                var warning_message, duration;
                if (msg) {
                    warning_message = msg;
                    warning_message = '<font color="red">' + warning_message + '</font>';
                    duration = 8000;
                } else {
                    warning_message = '${l:HLS.SUBMIT_SUCCESS}';
                    duration = 2000;
                }
                parent.Leaf.SideBar.enable = true;
                parent.Leaf.SideBar.show({
                    html: '<div style="background-color:#ccfbd5;position:absolute;padding-top:5px;padding-bottom:5px;padding-left:20px;padding-right:20px;border:0px solid #009900"><b>' + warning_message + '</b></div>',
                    duration: duration
                });
            }
            
            
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            
            //新增和加载时调用(form)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) {
                if (ds.id.match(/con_debt_exemption_req_ds$/)) {
                    if (!record.get('change_req_number')) {
                        record.dirty = true;
                    }
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                }
            };
            
            
            window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
                var ajax_flag = 'N';
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var confirm_win = Leaf.showConfirm('${HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function() {
                    ajax_flag = 'Y';
                    Leaf.request({
                        url: $('con_contract_debt_exemption_req_change_req_submit_link_id').getUrl(),
                        para: {
                            change_req_id: '${/parameter/@change_req_id}'
                        },
                        success: function(res) {
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            parent.Leaf.SideBar.enable = true;
                            parent.Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            $('${/parameter/@winid}').close();
                        },
                        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
                    });
                }, function() {
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                });
                confirm_win.on('close', function() {
                    if (ajax_flag == 'N') {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    }
                });
            };
            
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ajax_flag = 'N';
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var confirm_win = Leaf.showConfirm('${HLS.PROMPT}', '是否确认取消？', function() {
                    ajax_flag = 'Y';
                    Leaf.request({
                        url: $('con_contract_debt_exemption_req_change_req_cancel_link_id').getUrl(),
                        para: {
                            change_req_id: '${/parameter/@change_req_id}'
                        },
                        success: function(res) {
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            parent.Leaf.SideBar.enable = true;
                            parent.Leaf.SideBar.show({
                                msg: '取消成功',
                                duration: 2000
                            });
                            $('${/parameter/@winid}').close();
                        },
                        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
                    });
                }, function() {
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                });
                confirm_win.on('close', function() {
                    if (ajax_flag == 'N') {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    }
                });
            };
            
            //更新时调用
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {

                if (ds.id.match(/con_debt_exemption_req_cf_ds$/) && name == 'exemption_amount') {
                    var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_debt_exemption_req');
                    var req_record = $(req_ds_id).getCurrentRecord();
                    if (req_record) {
                        req_record.set('total_exemption_amount', plus(minus(req_record.get('total_exemption_amount') || 0, old_value || 0), value || 0));
                    }
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
