<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyu 
    $Date: 2016-10-19 下午17:01:32  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <script type="text/javascript"><![CDATA[
			function hn2020_region_detail_close(){
			    $('${/parameter/@winid}').close();
			}
			
			function region_sum_foot(data, name) {
                if (name == 'ref_v05_n') {
                    return '<font color=red>' + '合计' + '</font>';
                } else if (name == 'region_sum_principal') {
                    return region_colum_caculateTotal(data, name);
                } else if (name == 'region_rec_principal') {
                    return region_colum_caculateTotal(data, name);
                }
            }
            
            function region_colum_caculateTotal(data, name) {
                var total = 0;
                var length = data.length;
                var value = 0;
                for (var i = 0;i < length;i++) {
                    if (Ext.isEmpty(data[i].get(name))) {
                        value = 0;
                    } else {
                        value = data[i].get(name);
                    }
                    total = plus(total, value);
                }
                return '<font color=red>' + Leaf.formatMoney(total) + '</font>';
            }
            
		]]></script>
        <a:dataSets>
            <a:dataSet id="hn2020_region_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="calc_date" defaultValue="${/parameter/@calc_date}" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hn2020_region_result_ds" autoPageSize="true" autoQuery="true" model="hn.HN2020.hn_rpt2020_region_detail"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hn2020_region_detail_close" text="退出"/>
                <a:gridButton bind="hn2020_region_detail_grid_id" type="excel"/>
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="120" marginWidth="30" title="查询条件">
                <a:datePicker name="calc_date" bindTarget="hn2020_region_query_ds" prompt="统计截止日"/>
            </a:form>
            <a:grid id="hn2020_region_detail_grid_id" bindTarget="hn2020_region_result_ds" marginHeight="180" marginWidth="30" navBar="true" showRowNumber="true">
                <a:columns>
                    <a:column name="ref_v05_n" footerRenderer="region_sum_foot" prompt="区域" width="260"/>
                    <a:column name="region_sum_principal" align="right" footerRenderer="region_sum_foot" prompt="融资本金总额" renderer="Leaf.formatMoney" width="140"/>
                    <a:column name="region_sum_prin_percent" align="right" prompt="融资本金总额占比" width="120"/>
                    <a:column name="region_rec_principal" align="right" footerRenderer="region_sum_foot" prompt="剩余本金总额" renderer="Leaf.formatMoney" width="140"/>
                    <a:column name="region_rec_prin_percent" align="right" prompt="剩余本金总额占比" width="120"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>