<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
          trace="true">
    <a:init-procedure>
        <a:model-query model="cont.CON3500.contract_ifrs9_report_flag" rootPath="status"/>
    </a:init-procedure>
    <a:view>
        <link href="${/request/@context_path}/lib/bootstrap-3.3.7/css/bootstrap.css" rel="stylesheet" type="text/css"/>

        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <a:link id="save_ifrs9_report_link" model="cont.CON3500.contract_ifrs9_report_temp"
                modelaction="update"/>
        <a:link id="${/parameter/@layout_code}con_contract_query_link"
                url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <style>
            body{
                font-size: 12px;
            }
        </style>
        <script type="text/javascript"><![CDATA[


        Leaf.onReady(function(){
            //检查保存按钮
            var flag='${/model/status/record/@flag}';
           if(flag=='Y'){
               $("${/parameter/@layout_code}_user_button1").disable();
               $("${/parameter/@layout_code}_user_button2").disable();
           }else{
               var reminder=document.getElementsByClassName('screenTopToolbar');
               for(var i=0;i<reminder.length;i=i+1){

                   var t=reminder[i];
                   t.insertAdjacentHTML('afterend', '<div class="alert alert-danger" role="alert" >数据只能保存一次，请确认后保存</div>');
               }
           }

            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_ifrs9');
            $(ds_id).setQueryParameter("period_name",'${/parameter/@period_name}');
            $(ds_id).query();
        })
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_ifrs9');
            $(ds_id).setQueryUrl('${/request/@context_path}/autocrud/cont.CON3500.contract_ifrs9_report_temp/query');
            $(ds_id).setQueryParameter('period_name','${/parameter/@period_name}');
            $(ds_id).query();
        }

        //保存数据
        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
           var period_name="${/parameter/@period_name}";
            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            Leaf.request({
                url: $('save_ifrs9_report_link').getUrl(),
                para: {
                    period_name:period_name
                },
                success: function() {
                    $("${/parameter/@layout_code}_user_button1").disable();
                    $("${/parameter/@layout_code}_user_button2").disable();
                    Leaf.SideBar.show({
                        msg: '保存成功',
                        duration: 2000
                    });
                    Leaf.Masker.unmask(Ext.getBody());
                    $(ds_id).query();
                },
                failure: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                error: function() {
                    Leaf.Masker.unmask(Ext.getBody());
                },
                scope: this
            });
        }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>

    </a:view>
</a:screen>
