<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: niminmin
    $Date: 2018-12-20 上午9:30:25  
    $Revision: 1.0  
    $Purpose: 租金余额报表
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" customizationEnabled="true" trace="true">
    <a:init-procedure>
<!--        <a:model-query autoCount="false"  model="rpt.RPT5012.rpt5012_get_batch" rootPath="batch_id"/>-->
    </a:init-procedure>
    <a:view>
        <a:link id="rpt5012_report_query_link" url="${/request/@context_path}/modules/rpt/RPT5012/rpt5012_repory_query.lview"/>

        <a:link id="rpt5012_print_link_id" model="rpt.RPT5012.rpt5012_result_query" modelaction="execute"/>
        <script><![CDATA[
            function rpt5012_reset() {
                $('rpt5012_query_ds').reset();
            }

            function ref_n01_time(record, name, value) {
                var reg = /^\d\d\d\d\d\d$/;
                if (reg.test(value)) {
                    return true;
                }
                return '时间格式应为【yyyymm】,举例【201812】';
            }

            function rpt5012_query() {
                debugger;
                Leaf.Masker.mask(Ext.getBody(), '${l:BEING_IMPLEMENTED}');
                var record = $('rpt5012_query_ds').getAt(0);
                if (!record) {
                    Leaf.Masker.unmask(Ext.getBody());
                    Leaf.showMessage('${l:PROMPT}', '年月未填写');
                    return;
                }
                var month = record.get('month');
                if (!month) {
                    Leaf.Masker.unmask(Ext.getBody());
                    Leaf.showMessage('${l:PROMPT}', '年月未填写');
                    return;
                }

                Leaf.request({
                    url: $('rpt5012_print_link_id').getUrl(),
                    para: {
                        month: month
                    },
                    success: function(res) {
                        debugger;
                        Leaf.Masker.unmask(Ext.getBody());
                        var cur_begin = Leaf.formatDate(res.result.cur_begin),
                            cur_end = Leaf.formatDate(res.result.cur_end),
                            before_begin = Leaf.formatDate(res.result.before_begin),
                            before_end = Leaf.formatDate(res.result.before_end);
                        var win = new Leaf.Window({
                            id: 'rpt5012_report_query_link_id',
                            url: $('rpt5012_report_query_link').getUrl(),
                            params: {
                                month:month,
                                cur_begin:cur_begin,
                                cur_end:cur_end,
                                before_begin:before_begin,
                                before_end:before_end
                            },
                            title: '月结报表',
                            fullScreen: true
                        });
                        win.on('close', function () {
                            // document.getElementsByClassName('alert')[0].remove();
                        });

                    },
                    error: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    failure: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });





            }

        ]]></script>
        <a:dataSets>
            <a:dataSet id="four_month_date_ds" loadData="true" model="rpt.RPT5012.rpt5012_four_month"/>
            <a:dataSet id="rpt5012_query_ds">
                <a:fields>
                    <a:field name="month"/>
                    <a:field name="month_desc" displayField="value_name" options="four_month_date_ds" required="true" returnField="month" valueField="value_code"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="rpt5012_reset" text="HLS.RESET"/>
                <a:gridButton click="rpt5012_query" text="查询"/>
            </a:screenTopToolbar>
            <a:form  column="1" labelWidth="100" title="条件" width="300">
                <a:comboBox name="month_desc" bindTarget="rpt5012_query_ds" prompt="月结年月"/>
            </a:form>
        </a:screenBody>
    </a:view>
</a:screen>