<?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 fetchAll="true" model="cont.CON780.get_current_date" rootPath="default_date_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con1380_query_id" model="cont.CON1380.con1380_result_query_job" modelaction="execute"/>
        <a:link id="query_job" model="cont.CON1380.con1380_result_query_job" modelaction="update"/>
        <script><![CDATA[
        $L.onReady(function(){
            var headers_ds = $('${/parameter/@layout_code}_F_QUERY__ds');
            var record = headers_ds.getCurrentRecord();
            record.set('base_date','${/model/default_date_path/record/@last_month}');
            record.set('base_date_n','${/model/default_date_path/record/@last_month}');
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hlcm_monthly_report_temp');
            $(ds_id).setQueryParameter('commission_month',record.get('base_date'));
            $(ds_id).query();
        });

        //更新全量数据
        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
            var headers_ds = $('${/parameter/@layout_code}_F_QUERY__ds');
            var record = headers_ds.getAt(0);
            if (Ext.isEmpty(record.get('base_date'))) {
                $L.showMessage('提示', '请选择基准日期');
                return;
            }
            Leaf.showConfirm('${l:HLS.PROMPT}', '<font color="red">该任务需执行约30分钟，请耐心等待！</font></br></br><font color="red">【特别注意】任务发起后30分钟内请勿重复点击</font>', function () {
                Leaf.Masker.mask(Ext.getBody(), '${l:BEING_IMPLEMENTED}');
                Leaf.request({
                    url: $('con1380_query_id').getUrl(),
                    para: {
                        month: record.get('base_date')
                    },
                    success: function (res) {
                        Leaf.Masker.unmask(Ext.getBody());
                        Leaf.SideBar.show({
                            msg: '发起成功！',
                            duration: 2000
                        });
                    },
                    error: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    failure: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
            }, null, 300, 150);
        };

        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            var headers_ds = $('${/parameter/@layout_code}_F_QUERY__ds');
            var record = headers_ds.getCurrentRecord();
            if (Ext.isEmpty(record.get('base_date'))) {
                $L.showMessage('提示', '请选择基准日期');
                return;
            }
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hlcm_monthly_report_temp');
            $(ds_id).setQueryParameter('commission_month',record.get('base_date'));
            $(ds_id).query();
        };

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