<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-7-7 下午04:15:08  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="upload_file_link" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
        	function tre_finance_contract_attach_back() {
        	    $('${/parameter/@winid}').close();
        	}
        	
        	function tre_finance_contract_attach_save() {
        	    $('tre_loan_contract_note_info_ds').submit();
        	}
        	
        	
        	
        	function attach_win(fin_contract_id) {
        	    var url = $('upload_file_link').getUrl() + '?table_name=TRE_LOAN_FINANCE_CONTRACT&header_id=' + fin_contract_id;
        	    new Leaf.Window({
        	        url: url,
        	        title: '${l:HLS.SUPPORTING_DOCUMENT}',
        	        id: 'upload_file_win',
        	        width: 850,
        	        height: 400
        	    });
        	}
        	
        	function attachment_renderer(value, record, name) {
        	    if (record.get('fin_contract_id')) {
        	        return '<a href="javascript:attach_win(' + record.get('fin_contract_id') + ')">附件</a>';
        	    }
        	    return value;
        	}
        	
    	]]></script>
        <a:dataSets>
            <a:dataSet id="loan_contract_ds" autoQuery="true" model="tre.tre502.tre_loan_contract" queryUrl="${/request/@context_path}/autocrud/tre.tre502.tre_loan_contract/query?loan_contract_id=${/parameter/@loan_contract_id}"/>
            <a:dataSet id="con_contract_ds" autoPageSize="true" loadData="true" model="cont.CON751.con_contract_v_query"/>
            <a:dataSet id="tre_loan_contract_note_info_ds" autoQuery="true" model="tre.TRE600.tre_loan_contract_note_info" queryUrl="${/request/@context_path}/autocrud/tre.TRE600.tre_loan_contract_note_info/query?contract_id=${/parameter/@contract_id}">
                <a:fields>
                    <a:field name="contract_id" defaultValue="${/parameter/@contract_id}"/>
                    <a:field name="bank_branch_name" lovGridHeight="350" lovHeight="500" lovService="basic.csh_bank_branch_for_lov" lovWidth="450">
                        <a:mapping>
                            <a:map from="bank_branch_id" to="bank_branch_id"/>
                            <a:map from="bank_branch_name" to="bank_branch_name"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="tre_loan_finance_analyse_ds" autoQuery="true" model="tre.tre503.tre_loan_finance_analyse" queryUrl="${/request/@context_path}/autocrud/tre.tre503.tre_loan_finance_analyse/query?loan_contract_id=${/parameter/@loan_contract_id}"/>
            <a:dataSet id="tre_loan_finance_contract_ds" autoQuery="true" model="tre.tre503.tre_loan_finance_contract" queryUrl="${/request/@context_path}/autocrud/tre.tre503.tre_loan_finance_contract/query?loan_contract_id=${/parameter/@loan_contract_id}" selectable="true">
                <a:fields>
                    <a:field name="finance_contract_type"/>
                    <a:field name="finance_contract_type_desc" displayField="code_value_name" options="financing_contract_type_ds" returnField="finance_contract_type" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenTopToolbar>
            <a:gridButton click="tre_finance_contract_attach_back" text="HLS.BACK"/>
            <a:gridButton click="tre_finance_contract_attach_save" text="HLS.SAVE"/>
        </a:screenTopToolbar>
        <a:form column="4" labelWidth="120" style="margin:5px 0px 0px 10px" title="租赁合同" width="1112">
            <a:textField name="contract_number" bindTarget="con_contract_ds" prompt="合同编号" readOnly="true"/>
            <a:textField name="contract_name" bindTarget="con_contract_ds" colspan="2" prompt="合同名称" readOnly="true" width="428"/>
            <a:textField name="employee_name" bindTarget="con_contract_ds" prompt="项目经理" readOnly="true"/>
            <a:numberField name="finance_amount" allowFormat="true" bindTarget="con_contract_ds" prompt="租赁融资额" readOnly="true"/>
            <a:percentField name="irr" bindTarget="con_contract_ds" prompt="项目IRR" readOnly="true"/>
        </a:form>
        <a:form column="4" labelWidth="120" style="margin:5px 0px 0px 10px" title="银票信息" width="1112">
            <a:lov name="bank_branch_name" bindTarget="tre_loan_contract_note_info_ds" prompt="开票银行"/>
            <a:textField name="noted_person" bindTarget="tre_loan_contract_note_info_ds" prompt="受票人"/>
            <a:numberField name="note_amount" bindTarget="tre_loan_contract_note_info_ds" prompt="银票金额"/>
            <a:textField name="note_term" bindTarget="tre_loan_contract_note_info_ds" prompt="开票期限"/>
            <a:datePicker name="note_date" bindTarget="tre_loan_contract_note_info_ds" prompt="出票日期"/>
            <a:datePicker name="note_due_date" bindTarget="tre_loan_contract_note_info_ds" prompt="汇票到期日"/>
            <a:percentField name="deposit_ratio" allowNegative="false" bindTarget="tre_loan_contract_note_info_ds" prompt="保证金比例"/>
            <a:numberField name="deposit_amount" allowFormat="true" allowNegative="false" bindTarget="tre_loan_contract_note_info_ds" prompt="保证金金额"/>
        </a:form>
        <a:form id="finance_analyse_form_id" column="4" labelWidth="120" style="margin:5px 0px 0px 10px" title="融资分析" width="1112">
            <a:percentField name="project_irr" allowNegative="false" bindTarget="tre_loan_finance_analyse_ds" prompt="项目IRR" readOnly="true"/>
            <a:numberField name="own_amount" allowFormat="true" allowNegative="false" bindTarget="tre_loan_finance_analyse_ds" prompt="自有资金投入" readOnly="true"/>
            <a:numberField name="project_profit" allowFormat="true" allowNegative="false" bindTarget="tre_loan_finance_analyse_ds" prompt="项目利润" readOnly="true"/>
            <a:percentField name="multiple_irr" allowNegative="false" bindTarget="tre_loan_finance_analyse_ds" prompt="融资综合IRR" readOnly="true"/>
            <a:textArea name="guarant_measure" bindTarget="tre_loan_finance_analyse_ds" colspan="4" prompt="反担保措施" readOnly="true" width="988"/>
        </a:form>
        <a:box id="finance_contract_id">
            <a:grid bindTarget="tre_loan_finance_contract_ds" height="150" navBar="true" style="margin:5px 0px 0px 10px" width="1112">
                <a:columns>
                    <a:column name="finance_contract_type_desc" prompt="融资合同类型" width="100"/>
                    <a:column name="finance_contract_number" prompt="融资合同编号" width="100"/>
                    <a:column name="bp_name" prompt="商业伙伴名称" width="200"/>
                    <a:column name="bp_category" prompt="商业伙伴类别" width="100"/>
                    <a:column name="bp_type" prompt="商业伙伴类型" width="100"/>
                    <a:column name="description" prompt="备注" width="200"/>
                    <a:column name="attachment" align="center" prompt="附件" renderer="attachment_renderer" width="50"/>
                </a:columns>
            </a:grid>
        </a:box>
        <script type="text/javascript"><![CDATA[
        	Leaf.onReady(function(){
        		if(!'${/parameter/@loan_contract_id}'){
        		    Ext.fly('finance_analyse_form_id').dom.style.display="none";
        		    Ext.fly('finance_contract_id').dom.style.display="none";
        		}
        	});
        ]]></script>
    </a:view>
</a:screen>