<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2014-8-27 下午3:22:54  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:init-procedure><![CDATA[
        <!--<a:model-update model="cont.CON509.con_contract_wfl_info"/>-->
    ]]></a:init-procedure>
    <a:view>
        <a:link id="con_contract_update_link_id" url="${/request/@context_path}/modules/nanshan_all_layout.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="CON509_contract_link" model="cont.CON509.con_contract_wfl_info" modelaction="execute"/>
        <a:link id="con_contract_balance_details_link" url="${/request/@context_path}/modules/csh/CSH501/con_contract_balance_details.lview"/>
        <a:link id="con509_con_contract_info_link" url="${/request/@context_path}/modules/prj/PRJ506/virtual_contract_query.lview"/>
        <a:link id="con509_cdd_DownFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
        
             //合同明细
                function virtual_con_number(record_id){
                var record =$('con_contract_wfl_info_ds').findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON301';
                //param['document_id'] = record.get('project_id');
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
                param['cond_para2'] = record.get('hn_industry_classification');
                param['url_title'] = '合同明细';
                param['winid']='con509_virtual_contract_query_detail_link_id_pre';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con509_con_contract_info_link');
                }
                
        
        	function virtual_con_number_renderer(value,record,name){
        	    return '<a href="javascript:virtual_con_number('+record.id+')">'+value+'</a>';
        	}
        	
             
        	function contract_number_renderer(value,record,name){
        	    return '<a href="javascript:con_contract_cashflow_link('+record.id+')">'+value+'</a>';
        	}
        	
        	  function con_contract_cashflow_link(record_id) {
                var record=$('con_contract_wfl_info_ds').findById(record_id);
                var contract_id = record.get('contract_id');
                new Leaf.Window({
                    title: '合同余额明细信息',
                    id: 'con_contract_balance_details_win',
                    url: $('con_contract_balance_details_link').getUrl(),
                    params: {
                        'contract_id': contract_id
                    },
                    fullScreen: true
                });
            }
        
            function init_contract_data(ds) {
                //
                var contract_id = '${/parameter/@contract_id}';
            
                if ('${/parameter/@check_flag}'=='Y') {
                    Leaf.request({
                        url: $('CON509_contract_link').getUrl(),
                        para: {
                            contract_id: contract_id
                        },
                        success: function(res) {

                            var flag = res.result.flag;
                            if (flag == 'Y') {
                                return
                            } else {
                                Leaf.showMessage('', '<font color="red">温馨提示:建议起租日和租前息计算起租日不相同,请重新计算租前息！</font>', null, 450, 100);
                            }
                        },
                        failure: function() {
            
                           },
                        error: function() {
            
                           },
                        scope: this
                    });
                }
            }
            function winOpen_upload(id) {
                  var record = $('con_contract_wfl_info_ds').findById(id);
                if (record.get('contract_id')) {
                    var url;
                       //设置虚拟表名CON_CONTRACT_CON509
                        url = $('con509_cdd_DownFile_id').getUrl() + '?table_name=CON_CONTRACT_CON509&header_id=' + record.get('contract_id');
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'tre610_cdd_uploadFile_screen_id',
                        width: 850,
                        height: 400
                    });
            
                  
                }
            }
            
            function render_objectDs_grid(value, record, name) {
                if (!record.isNew) {
                    return '<a href="javascript:winOpen_upload(\'' + record.id + '\')">' + '起租附件' + '</a>';
                }
             }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="con_contract_wfl_info_ds" autoQuery="true" model="cont.CON509.con_contract_wfl_info" queryUrl="${/request/@context_path}/autocrud/cont.CON509.con_contract_wfl_info/query?wfl_instance_id=${/parameter/@instance_id}&amp;contract_id=${/parameter/@contract_id}">
                <a:fields>
                    <a:field name="contract_number" readOnly="true"/>
                    <a:field name="contract_name" readOnly="true"/>
                    <a:field name="finance_amount" readOnly="true"/>
                    <a:field name="loan_amount" readOnly="true"/>
                    <a:field name="loan_date" readOnly="true"/>
                    <a:field name="pre_incept_date" readOnly="true"/>
                    <a:field name="employee_suggest_dec" readOnly="true"/>
                    <a:field name="suggest_incept_date" readOnly="true"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="init_contract_data"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:grid bindTarget="con_contract_wfl_info_ds" marginHeight="455" marginWidth="100" navBar="true" showRowNumber="true">
                <a:columns>
                    <a:column name="virtual_con_number" lock="true" prompt="合同号" renderer="virtual_con_number_renderer" width="100"/>
                    <a:column name="contract_number" lock="true" prompt="合同编号" renderer="contract_number_renderer" width="120"/>
                    <a:column name="contract_name" lock="true" prompt="租赁合同名称" width="150"/>
                    <a:column name="bp_id_tenant_n" lock="true" prompt="承租人名称" showTitle="true" width="150"/>
                    <a:column name="finance_amount" align="right" prompt="实际融资金额" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="lease_aomunt_recevied_date" align="center" prompt="款项支付日" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="pre_incept_date" align="center" prompt="起租日" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="employee_id_n" align="center" prompt="主办客户经理" width="100"/>
                    <a:column name="unit_id_n" align="center" prompt="业务部" width="90"/>
                    <a:column name="division_n" align="center" prompt="产品线" width="90"/>
                    <a:column name="loan_amount" align="right" prompt="已投放金额" renderer="Leaf.formatMoney" width="100"/>
                    <!-- <a:column name="loan_date" align="center" prompt="最后投放日期" renderer="Leaf.formatDate" width="100"/> -->
                    <a:column name="upload_incept_att" align="center" prompt="附件下载" renderer="render_objectDs_grid" width="80"/>
                    <!-- <a:column name="pre_incept_date" align="center" prompt="预计起租日期" renderer="Leaf.formatDate"/> -->
                    <!-- <a:column name="employee_suggest_dec" prompt="主办客户经理意见"/> -->
                    <!-- <a:column name="suggest_incept_date" prompt="建议起租日期" renderer="Leaf.formatDate"/> -->
                </a:columns>
            </a:grid>
        </a:screenBody>
        <a:switch test="/parameter/@upload_flag">
            <a:case value="Y">
                <a:screen-include screen="atm_upload.lview?document_id=${/parameter/@contract_id}&amp;document_table=HY_RENT_PROCESS&amp;showflag=N"/>
            </a:case>
            <a:case value="N">
                <a:screen-include screen="atm_query.lview?document_id=${/parameter/@contract_id}&amp;document_table=HY_RENT_PROCESS&amp;showflag=N"/>
            </a:case>
        </a:switch>
        <!--<script type="text/javascript"><![CDATA[
                    Leaf.onReady(init);
                    
                    function init() {

                        var para='${/parameter/@flag}';
                        
                    }
                ]]></script>-->
    </a:view>
</a:screen>
