<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2014-8-27 下午3:22:31  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:init-procedure><![CDATA[
        
    ]]></a:init-procedure>
    <a:view>
        <a:link id="con_contract_incept_apply_insert_link" model="cont.CON509.con_contract_incept_apply_insert" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            // function save_contract_info(){
                // var ds=$('contract_info_ds');
                // var records=ds.getAll();
                // if(ds.validate()){
                   // for(var i=0;i<records.length;i++){
                       // var employee_suggest_dec=records[i].get('employee_suggest_dec');
                       // var suggest_incept_date=records[i].get('suggest_incept_date');
                       // // alert(suggest_incept_date);
                       // Leaf.request({
		                            // url:$('con_contract_incept_apply_insert_link').getUrl(),
		                            // para:{
		                                // instance_id:'${/parameter/@instance_id}',
		                                // contract_id:'${/parameter/@contract_id}',
		                                // employee_suggest_dec:employee_suggest_dec,
		                                // suggest_incept_date:suggest_incept_date
		                            // },
		                            // success:function(res){
		                                // Leaf.SideBar.show({ msg: '${l:HLS.SUBMIT_SUCCESS}',duration: 2000});
		                                
		                            // },
		                            // scope:this
		                        // });
                   // } 
                // }
            // }
            function save_contract_info(ds,record,name,value,oldvalue){
                // if(ds.validate()){
              if(value==oldvalue){
                  return;
              }

                var now = new Date();
                var year = now.getFullYear();       //年
                var month = now.getMonth() + 1;     //月
                   if(month<10){
                       month='0'+month;
                   }
                 var day = now.getDate();
                   if(name=='lease_condition'){
                       if(record.get('lease_condition')==10){
                           var incept_date=year+'-'+month+'-'+'10';
                           record.set('suggest_incept_date',incept_date);
                           record.getField('suggest_incept_date').setReadOnly(true);
                           
                       }
                       if(record.get('lease_condition')==15){
                           var incept_date=year+'-'+month+'-'+'15';
                           record.set('suggest_incept_date',incept_date);
                           record.getField('suggest_incept_date').setReadOnly(true);                       }
                       if(record.get('lease_condition')==25){
                           var incept_date=year+'-'+month+'-'+'25';
                           record.set('suggest_incept_date',incept_date);
                           record.getField('suggest_incept_date').setReadOnly(true);                       }
                       else{
                          record.getField('suggest_incept_date').setReadOnly(false);                       }
                   }
                   
                    var employee_suggest_dec=record.get('employee_suggest_dec');
                       var suggest_incept_date=record.get('suggest_incept_date');
                       // alert(suggest_incept_date);
                       Leaf.request({
		                            url:$('con_contract_incept_apply_insert_link').getUrl(),
		                            para:{
		                                instance_id:'${/parameter/@instance_id}',
		                                contract_id:'${/parameter/@contract_id}',
		                                employee_suggest_dec:employee_suggest_dec,
		                                suggest_incept_date:suggest_incept_date,
		                                lease_condition:record.get('lease_condition')
		                            },
		                            success:function(res){
		                                Leaf.SideBar.show({ msg: '${l:HLS.SUBMIT_SUCCESS}',duration: 2000});
		                                
		                            },
		                            scope:this
		                        });
                // }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="lease_condition_ds">
                <a:datas>
                    <a:record code_value="10" code_value_name="本月10号"/>
                    <a:record code_value="15" code_value_name="本月15号"/>
                    <a:record code_value="25" code_value_name="本月25号"/>
                    <a:record code_value="30" code_value_name="其它"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="contract_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="loan_amount" readOnly="true"/>
                    <a:field name="loan_date" readOnly="true"/>
                    <a:field name="lease_condition"/>
                    <a:field name="finance_amount" readOnly="true"/>
                    <a:field name="pre_incept_date" readOnly="true"/>
                    <a:field name="employee_suggest_dec" readOnly="${/parameter/@readOnly}" required="true"/>
                    <a:field name="suggest_incept_date" readOnly="${/parameter/@readOnly}" required="true"/>
                    <a:field name="lease_condition_desc" displayField="code_value_name" options="lease_condition_ds" returnField="lease_condition" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="save_contract_info"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:grid bindTarget="contract_info_ds" height="200" marginHeight="235" marginWidth="30" navBar="true">
                <!-- <a:toolBar>
                    <a:button click="save_contract_info" icon="${/request/@context_path}/images/save.gif" text="保存"/>
                </a:toolBar> -->
                <a:columns>
                    <a:column name="contract_number" prompt="租赁附表编号" width="150"/>
                    <a:column name="contract_name" prompt="租赁合同名称" width="250"/>
                    <a:column name="finance_amount" align="right" prompt="实际融资金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="loan_amount" align="right" prompt="已投放金额" renderer="Leaf.formatMoney" width="130"/>
                    <a:column name="loan_date" align="center" prompt="最后投放日期" renderer="Leaf.formatDate"/>
                    <a:column name="pre_incept_date" align="center" prompt="预计起租日期" renderer="Leaf.formatDate"/>
                    <a:column name="lease_condition_desc" editor="lease_editor" prompt="选择起租日期"/>
                    <a:column name="suggest_incept_date" editor="suggest_date_dp" prompt="建议起租日期" renderer="Leaf.formatDate"/>
                    <a:column name="employee_suggest_dec" editor="employee_opinion_ta" prompt="主办客户经理意见" width="210"/>
                </a:columns>
                <a:editors>
                    <a:comboBox id="lease_editor"/>
                    <a:textArea id="employee_opinion_ta"/>
                    <a:datePicker id="suggest_date_dp"/>
                </a:editors>
            </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>
    </a:view>
</a:screen>
