<?xml version="1.0" encoding="UTF-8"?>

<!--
    $Author: sf
$Date: 2019/09/24 21:19
$Revision: 1.0
$Purpose: 商业伙伴授信创建
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="basic.get_sys_default_time" rootPath="sys_default_time"/>-->
    </a:init-procedure>
    <a:view>
        <a:link id="credit_enhance_detail_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>

        <script type="text/javascript"><![CDATA[
        //保存前调用
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var check_flag = true;


           if( record.get('credit_total_amount')<0){
               $L.showErrorMessage("错误",'信用总额度不能为负数',null,null);
               window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
               return false;
           }
           if(record.get('credit_date_to')<record.get('credit_date_from')){
               $L.showErrorMessage("错误",'授信结束时间不能小于开始时间',null,null);
               window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
               return false;
           }

            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
           return  check_flag;


        };

        //更新时调用
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq){
            var f_bp_create_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_credit_hd');
            if(f_bp_create_ds_id==ds.id){
                if(record.get('credit_type')=='CAPITAL_LOAN_CREDIT'){
                    record.set('amount_type','CIRCULATION');
                    record.set('amount_type_n','循环');
                }else if(record.get('credit_type')=='ASSET_PROCUREMENT') {
                    record.set('amount_type','IMMOBILIZATION');
                    record.set('amount_type_n','固定');
                }
                if(name=='bp_id'){
                    record.set('credit_type','');
                    record.set('credit_type_n','');
                }
            }
        };

        //保存成功后刷新页面credit_ds
        // window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res, bp_seq) {
        //     Leaf.SideBar.show({
        //         msg: '操作成功',
        //         duration: 2000
        //     });
        //     $('credit_ds').query();
        //     $('${/parameter/@winid}').close();
        //     window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        // };

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