<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-8-28 下午01:18:02  
    $Revision: 1.0  
    $Purpose: 抵质押物创建
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="get_special_fields_link_id" model="cont.CON500.con_contract_get_special_fields" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            //保存前调用，生成商机编号
            window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var check_flag = false;

                if (record.get('mortgage_code')) {
                    return true;
                }
            
                Leaf.request({
                    url: $('get_special_fields_link_id').getUrl(),
                    para: {
                        document_category: record.get('document_category') || 'MORTGAGE',
                        function_code: '${/parameter/@function_code}',
                        function_usage: '${/parameter/@function_usage}'
                    },
                    success: function(res) {
                        var mortgage_code = res.result.document_number;
                        record.set('mortgage_code', mortgage_code);
                        record.set('document_category', 'MORTGAGE');
                        check_flag = true;
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    sync: true,
                    scope: this
                });
                return check_flag;
            };
        ]]></script>
    </a:view>
</a:screen>
