<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: duzhihong  
    $Date: 2015-1-16 下午4:43:51  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="(exists(select 1 from hls_lease_org_assign ha where ha.unit_id=t1.unit_id))" fetchAll="true" model="basic.exp_org_unit_manager_lov" rootPath="con501_exp_org_unit_manager_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contract_update_link_id" url="${/request/@context_path}/modules/cont/CON501N/con_contract_modify.lview"/>
        <a:link id="con_contract_interest_float_link" url="${/request/@context_path}/modules/cont/CON112/con_contract_change_info.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_batch_adjust_interest_ln_link_id" model="cont.CON112.con_batch_adjust_interest_ln" modelaction="execute"/>
        <a:link id="con112_report_print_link" url="${/request/@context_path}/modules/cont/CON112/con_adjust_interest_print.lview"/>
        <script type="text/javascript"><![CDATA[
            function con501_con_contract_return() {
                $('batch_adjust_detail_winid').close();
            }
            
            function con501_con_contract_query() {
                $('con112_contract_result_ds').query();
            }
            
            function con501_con_contract_reset() {
                $('con112_contract_query_ds').reset();
            }
            
            function con112_contractRenderer(value, record, name) {
                 var rec = $('bacth_adjust_hd_query').getAt(0);
                if (name == 'change_req_id') {
                    //if (rec.get('approval_status') == 'APPROVED') {
                        //return '';
                    //} else {
                        if (record.get('adjust_flag') == 'Y') {
                            return '<a href="javascript:con501_con_contract_cal(' + record.id + ');">' + '调息明细' + '</a>';
                        } 
                        if (record.get('adjust_flag') == 'E') {
                            return '<font color="orange">' + record.get('batch_adjust_note') + '</font>';
                        } else {
                            return '';
                        }
                    //}
                }
                return '';
            }
            function con501_con_contract_cal(id) {

                var record = $('con112_contract_result_ds').findById(id);
                var param = record.data;
                param['contract_id'] = record.get('contract_id');
                param['document_id'] = record.get('contract_id');
                param['change_req_id'] = record.get('change_req_id');
                if(record.get('approval_status')=='APPROVED'){
                    param['function_code'] = 'CON112_QUERY';
                }else
                {
                    param['function_code'] = 'CON110';
                }
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'UPDATE';
                param['url_title'] = '调息现金流对比';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_interest_float_link');
            }
          
            function con505_render_contractMaintainDs_grid(value, record, name) {
                if (name == 'contract_number') {
                    return '<a href="javascript:con505_contractMaintainDs_grid_update(' + record.id + ');">' + value + '</a>';
                }
            }
            
            function con505_contractMaintainDs_grid_update(id) {
                var current_record = $('con112_contract_result_ds').findById(id);
                var param = current_record.data;
                param['document_id'] = current_record.get('project_id');
                con505_param_set_value(param);
            }
            
            function con505_param_set_value(param) {
                param['function_code'] = 'CON301';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_update_link_id');
            }
            function submit_workflow(){
                Leaf.request({
                        url: $('con_batch_adjust_interest_ln_link_id').getUrl(),
                        para: {
                            batch_hd_id: '${/parameter/@batch_hd_id}'
                        },
                        success: function(args) {
                            unlock_list_window();
                            Leaf.SideBar.show({ msg: '${l:HLS.SUBMIT_SUCCESS}' ,duration: 2000});
                        },
                        scope: this,
                        sync: true
                    });
            }
            function adjust_flagRenderer(value, record, name) {
                var adjust_flag = record.get('adjust_flag');
                var batch_adjust_flag = record.get('batch_adjust_flag');
                if (name == 'inception_of_lease') {
                    if (adjust_flag == 'N') {
                        return '<font color="red">' + Leaf.formatDate(value) + '</font>';
                    }
                    if (adjust_flag == 'E') {
                        return '<font color="orange">' + Leaf.formatDate(value) + '</font>';
                    }
                    return Leaf.formatDate(value);
                }
                if (adjust_flag == 'E') {
                    return '<font color="orange">' + value + '</font>';
                }
                if (adjust_flag == 'N') {
                    return '<font color="red">' + value + '</font>';
                }
            
                return value;
            
            }
            
            function adjust_interest_print() {
                Leaf.showConfirm('提示', '确定要打印选中项吗？', function() {
                    Leaf.Masker.mask(Ext.getBody(), '正在提交');
                    var recs = $('con112_contract_result_ds').getSelected();
                    if (recs.length > 0) {
                        rec = recs[0];
                        var templt_name = 'adjust_interest_notice.xml';
                        var contract_id = rec.get('contract_id');
                        var url = $('con112_report_print_link').getUrl() + '?templt_name=' + templt_name + '&contract_id=' + contract_id;
                        var form = document.createElement("form");
                        form.target = "word_export_window";
                        form.method = "post";
                        form.action = url;
                        var iframe = Ext.get('word_export_window') || new Ext.Template('<iframe id ="word_export_window" name="word_export_window" style="position:absolute;left:-10000px;top:-10000px;width:1px;height:1px;display:none"></iframe>').insertFirst(document.body, {}, true);
                        document.body.appendChild(form);
                        form.submit();
                        Ext.fly(form).remove();
                        Leaf.Masker.unmask(Ext.getBody());
                    } else {
                        Leaf.Masker.unmask(Ext.getBody());
                    }
                });
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="con501_employee_name_of_manager_ds">
                <a:datas dataSource="/model/con501_exp_org_unit_manager_path"/>
            </a:dataSet>
            <a:dataSet id="con501_lease_organization_name_ds" loadData="true" model="basic.hls_lease_organization_for_lov"/>
            <a:dataSet id="con501_lease_channel_name_ds" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="con501_status_name_ds" lookupCode="CON500_CONTRACT_STATUS"/>
            <a:dataSet id="bacth_adjust_hd_query" autoQuery="true" model="cont.CON112.con_batch_adjust_interest_hd" queryUrl="${/request/@context_path}/autocrud/cont.CON112.con_batch_adjust_interest_hd/query?batch_hd_id=${/parameter/@batch_hd_id}">
                <a:fields>
                    <a:field name="batch_num" readOnly="true"/>
                    <a:field name="approval_status_n" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con112_contract_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="bp_code" autoComplete="true" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="project_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="prj.PRJ501.prj_project_for_lov" lovWidth="500" title="HLS.PROJECT_NUMBER">
                        <a:mapping>
                            <a:map from="project_number" to="project_number"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_employee_name" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="basic.hls_exp_employees_for_lov?sales_flag=Y" lovWidth="500" title="HLS.SALES_EMPLOYEE">
                        <a:mapping>
                            <a:map from="name" to="project_employee_name"/>
                            <a:map from="employee_id" to="employee_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON500.con_contract_number_lov" lovWidth="500" title="HLS.CONTRACT_NUMBER">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="employee_id"/>
                    <a:field name="employee_name_of_manager" displayField="mgr_employee_name" options="con501_employee_name_of_manager_ds" returnField="employee_id_of_manager" valueField="mgr_employee_id"/>
                    <a:field name="lease_organization_name" displayField="description" options="con501_lease_organization_name_ds" returnField="lease_organization" valueField="lease_organization"/>
                    <a:field name="lease_channel_desc" displayField="description" options="con501_lease_channel_name_ds" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="contract_status_desc" displayField="code_value_name" options="con501_status_name_ds" readOnly="true" returnField="contract_status" valueField="code_value"/>
                    <a:field name="contract_status"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con112_contract_result_ds" autoQuery="true" model="cont.CON112.con_batch_adjust_interest_ln" queryDataSet="con112_contract_query_ds" queryUrl="${/request/@context_path}/autocrud/cont.CON112.con_batch_adjust_interest_ln/query?batch_hd_id=${/parameter/@batch_hd_id}" selectable="true" selectionModel="single"><![CDATA[
            ]]></a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con501_con_contract_query" text="HLS.QUERY"/>
                <a:gridButton click="con501_con_contract_reset" text="HLS.RESET"/>
                <!-- <a:gridButton id="adjust_print" click="adjust_interest_print" text="租金调整通知书"/> -->
            </a:screenTopToolbar>
            <a:form column="4" labelSeparator=" " labelWidth="100" marginWidth="100" title="CON301.CONTRACT_QUERY">
                <a:textField name="batch_num" bindTarget="bacth_adjust_hd_query" prompt="批量调息编号"/>
                <a:comboBox name="approval_status_n" bindTarget="bacth_adjust_hd_query" prompt="审批状态"/>
                <a:lov name="bp_code" bindTarget="con112_contract_query_ds" prompt="HLS.TENANT_CODE"/>
                <a:textField name="bp_name" bindTarget="con112_contract_query_ds" prompt="HLS.TENANT_NAME"/>
                <a:datePicker name="lease_start_date_from" bindTarget="con112_contract_query_ds" prompt="HLS.LEASE_START_DATE_FROM"/>
                <a:datePicker name="lease_start_date_to" bindTarget="con112_contract_query_ds" prompt="HLS.LEASE_START_DATE_TO"/>
                <!-- <a:lov name="project_number" bindTarget="con112_contract_query_ds" prompt="HLS.PROJECT_NUMBER"/> -->
                <!-- <a:textField name="project_name" bindTarget="con112_contract_query_ds" prompt="HLS.PROJECT_NAME"/> -->
                <a:textField name="virtual_con_number" bindTarget="con112_contract_query_ds" prompt="合同号"/>
                <a:textField name="virtual_con_name" bindTarget="con112_contract_query_ds" prompt="合同名称"/>
                <a:lov name="project_employee_name" bindTarget="con112_contract_query_ds" prompt="HLS.SALES_EMPLOYEE"/>
                <a:comboBox name="lease_organization_name" bindTarget="con112_contract_query_ds" prompt="HLS.LEASE_ORGANIZATION"/>
                <a:lov name="contract_number" bindTarget="con112_contract_query_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <!-- <a:textField name="contract_name" bindTarget="con112_contract_query_ds" prompt="HLS.CONTRACT_NAME"/> -->
                <a:comboBox name="employee_name_of_manager" bindTarget="con112_contract_query_ds" prompt="HLS.EMPLOYEE_OF_MANAGER"/>
                <!-- <a:comboBox name="lease_channel_desc" bindTarget="con112_contract_query_ds" prompt="HLS.LEASE_CHANNEL_NAME"/> -->
                <!-- <a:comboBox name="con_mdy_status_desc" bindTarget="con112_contract_query_ds" prompt="调息状态"/> -->
                <!-- <a:textField name="prj_search_term_1" bindTarget="con112_contract_query_ds" prompt="CON301.CON_CONTRACT_V.PRJ_SEARCH_TERM_1"/>
                <a:textField name="prj_search_term_2" bindTarget="con112_contract_query_ds" prompt="CON301.CON_CONTRACT_V.PRJ_SEARCH_TERM_2"/>
                <a:textField name="con_search_term_1" bindTarget="con112_contract_query_ds" prompt="CON301.CON_CONTRACT_V.CON_SEARCH_TERM_1"/>
                <a:textField name="con_search_term_2" bindTarget="con112_contract_query_ds" prompt="CON301.CON_CONTRACT_V.CON_SEARCH_TERM_2"/> -->
            </a:form>
            <a:grid id="con501_con_contract_grid_ds" bindTarget="con112_contract_result_ds" marginHeight="265" marginWidth="100" navBar="true">
                <a:columns>
                    <a:column name="contract_number" lock="true" prompt="合同编号" width="120"/>
                    <a:column name="virtual_con_number" lock="true" prompt="合同号" width="120"/>
                    <a:column name="virtual_con_name" lock="true" prompt="合同名称" width="220"/>
                    <a:column name="change_req_id" align="center" prompt="调息明细" renderer="con112_contractRenderer"/>
                    <!-- <a:column name="contract_name" prompt="HLS.CONTRACT_NAME" renderer="adjust_flagRenderer" width="200"/> -->
                    <a:column name="inception_of_lease" prompt="放款日" renderer="adjust_flagRenderer" width="80"/>
                    <a:column name="bp_name" prompt="HLS.TENANT_NAME" renderer="adjust_flagRenderer" width="160"/>
                    <!-- <a:column name="project_number" prompt="HLS.PROJECT_NUMBER" renderer="adjust_flagRenderer"/> -->
                    <!-- <a:column name="project_name" prompt="HLS.PROJECT_NAME" renderer="adjust_flagRenderer" width="200"/> -->
                    <a:column name="employee_name" prompt="HLS.SALES_EMPLOYEE" renderer="adjust_flagRenderer" width="70"/>
                    <a:column name="employee_name_of_manager" prompt="HLS.EMPLOYEE_OF_MANAGER" renderer="adjust_flagRenderer" width="70"/>
                    <a:column name="lease_organization_desc" prompt="HLS.LEASE_ORGANIZATION" renderer="adjust_flagRenderer" width="70"/>
                    <!-- <a:column name="lease_channel_desc" prompt="HLS.LEASE_CHANNEL_NAME" width="70"/> -->
                    <!-- <a:column name="document_type_desc" prompt="HLS.CONTRACT_TYPE" renderer="adjust_flagRenderer" width="100"/> -->
                    <a:column name="base_rate_n" align="right" prompt="基准利率(%)" renderer="adjust_flagRenderer"/>
                    <a:column name="int_rate_fixing_way_des" align="center" prompt="利率调整规则" renderer="adjust_flagRenderer"/>
                    <a:column name="int_rate_fixing_range_n" align="right" prompt="幅度(%)" renderer="adjust_flagRenderer"/>
                    <a:column name="int_rate_n" align="right" prompt="租赁利率(%)" renderer="adjust_flagRenderer"/>
                    <!-- <a:column name="flt_execute_times_rule_n" prompt="浮动周期规则" renderer="adjust_flagRenderer"/> -->
                    <a:column name="flt_annual_adj_times_des" align="center" prompt="调整频率" renderer="adjust_flagRenderer"/>
                    <!-- <a:column name="contract_status_desc" prompt="合同状态" renderer="adjust_flagRenderer" width="60"/> -->
                    <a:column name="adjust_flag_desc" prompt="调息状态" renderer="adjust_flagRenderer" width="60"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
