<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-8-28 上午09:29:17  
    $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('lease_item_code')) {
                    return true;
                }
            
                Leaf.request({
                    url: $('get_special_fields_link_id').getUrl(),
                    para: {
                        document_category: record.get('document_category') || 'LEASE_ITEM',
                        function_code: '${/parameter/@function_code}',
                        function_usage: '${/parameter/@function_usage}'
                    },
                    success: function(res) {
                        var lease_item_code = res.result.document_number;
                        record.set('lease_item_code', lease_item_code);
                        record.set('document_category', 'LEASE_ITEM');
                        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>
