<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2014-1-7 下午02:47:38  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query model="gld.gld_period_status" rootPath="gld_periods_combo"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
			function query()
			{
			    $('con_unearned_finance_result_ds').query();			    
			}
			function reset()
			{
			    $('con_unearned_finance_query_ds').reset();			    
			}
			
			function summaryRenderer(datas, name) {
           		
                var sum = 0;
         
                for (var i = 0;i < datas.length;i++) {
                    record = datas[i];
                    if (name == "unearned_finance_income" ) {
                        var t_1 = record.get("unearned_finance_income" );
                        var  t_2 = parseFloat(t_1);
                        if (!isNaN(t_2)) {
                            sum += t_2;
                        }
                    }
                   
                
                
                }
                if (name == "calc_end_date") {
                    return '<div align="right">合计:</div>';
                }
                if (name == "unearned_finance_income" ) {           
                    return '<font color="red">' + Leaf.formatNumber(sum, 2) + '</font>';
                }
            
            }
		]]></script>
        <a:dataSets>
            <a:dataSet id="con330_period_name_ds">
                <a:datas dataSource="/model/gld_periods_combo"/>
            </a:dataSet>
            <a:dataSet id="finance_income_recognized_ds">
                <a:datas>
                    <a:record code_value="Y" code_value_name="是"/>
                    <a:record code_value="N" code_value_name="否"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="con_unearned_finance_query_ds">
                <a:fields>
                    <a:field name="period_name_from" displayField="period_name" options="con330_period_name_ds" returnField="period_name_from" valueField="period_name"/>
                    <a:field name="period_name_to" displayField="period_name" options="con330_period_name_ds" returnField="period_name_to" valueField="period_name"/>
                    <a:field name="contract_id"/>
                    <a:field name="contract_number" lovGridHeight="300" lovHeight="430" lovService="cont.CON330.con_contract_lov" lovWidth="400">
                        <a:mapping>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="contract_number" to="contract_number"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_vender"/>
                    <a:field name="bp_vender_n" lovGridHeight="300" lovHeight="430" lovService="basic.hls_bp_master_v_all_lov?bp_category=VENDER" lovWidth="550">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_vender"/>
                            <a:map from="bp_name" to="bp_vender_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="bp_tenant_n" lovGridHeight="300" lovHeight="430" lovService="basic.hls_bp_master_v_all_lov?bp_category=TENANT" lovWidth="550">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                            <a:map from="bp_name" to="bp_tenant_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_agent_level1"/>
                    <a:field name="bp_id_agent_level1_n" lovGridHeight="300" lovHeight="430" lovService="basic.hls_bp_master_v_all_lov?bp_category=AGENT" lovWidth="550">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_agent_level1"/>
                            <a:map from="bp_name" to="bp_id_agent_level1_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="finance_income_recognized" displayField="code_value" options="finance_income_recognized_ds" returnField="finance_income_recognized" valueField="code_value"><![CDATA[                   	
                    ]]></a:field>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_unearned_finance_result_ds" autoQuery="true" model="cont.CON326.con_unearned_finance_income" autoPageSize="true" queryDataSet="con_unearned_finance_query_ds"><![CDATA[
			]]></a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
	        <a:screenTitle/>
                <a:gridButton click="query" text="HLS.QUERY"/>
                <a:gridButton click="reset" text="HLS.RESET"/>
            </a:screenTopToolbar>
            <a:form column="4" marginWidth="80" title="支付表收益分摊查询">
                <a:lov name="contract_number" bindTarget="con_unearned_finance_query_ds" prompt="支付表编号"/>
                <a:lov name="bp_tenant_n" bindTarget="con_unearned_finance_query_ds" prompt="承租人"/>
                <a:lov name="bp_id_agent_level1_n" bindTarget="con_unearned_finance_query_ds" prompt="经销商"/>
                <a:comboBox name="period_name_from" bindTarget="con_unearned_finance_query_ds" prompt="期间从"/>
                <a:comboBox name="period_name_to" bindTarget="con_unearned_finance_query_ds" prompt="期间到"/>
                <a:comboBox name="finance_income_recognized" bindTarget="con_unearned_finance_query_ds" prompt="是否确认"/>
            </a:form>
            <a:grid bindTarget="con_unearned_finance_result_ds" marginHeight="270" marginWidth="80" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="支付表编号" sortable="true" width="130"/>
                    <a:column name="times" align="center" prompt="期数" sortable="true" width="40"/>
                    <a:column name="period_name" align="center" prompt="期间" sortable="true" width="70"/>
                    <a:column name="calc_start_date" align="center" prompt="起算日" renderer="Leaf.formatDate" sortable="true"/>
                    <a:column name="calc_end_date" align="center" footerRenderer="summaryRenderer" prompt="截止日" renderer="Leaf.formatDate" sortable="true"/>
                    <a:column name="unearned_finance_income" align="right" footerRenderer="summaryRenderer" prompt="未实现收益" renderer="Leaf.formatMoney" sortable="true" width="100"/>
                    <a:column name="finance_income_recognized" align="center" prompt="是否确认" sortable="true" width="60"/>
                    <a:column name="bp_id_tenant_n" prompt="承租人" width="200"/>
                    <a:column name="bp_id_agent_level1_n" prompt="经销商" width="200"/>
                    <a:column name="lease_organization_n" prompt="事业部" width="200"/>
                    <a:column name="division_n" prompt="产品线" width="200"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
