<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-11-20 上午11:10:31  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:c="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc">
    <a:init-procedure>
        <a:model-query defaultWhereClause="column_name in (&apos;IRR&apos;,&apos;FINANCE_AMOUNT&apos;,&apos;DEPOSIT&apos;,&apos;TOTAL_FEE&apos;,&apos;LEASE_TIMES&apos;,&apos;ANNUAL_PAY_TIMES&apos;,&apos;LEASE_TERM&apos;,&apos;BILLING_METHOD&apos;,&apos;RENTAL&apos;)" fetchAll="true" model="cont.CON751.hls_document_compare" rootPath="hls_document_compare_rp"/>
        <a:model-query fetchAll="true" model="cont.CON751.con_contract_change_req_query" rootPath="con751_change_req_rp"/>
    </a:init-procedure>
    <a:view>
        <a:link id="lease_item_list_link" url="${/request/@context_path}/modules/cont/CON751/con_contract_change_lease_detail_query.lview"/>
        <a:link id="con751_con_lease_item_query_link" url="${/request/@context_path}/modules/cont/CON504/con_lease_item_query.lview"/>
        <a:link id="con751_attach_downloadfile_link" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="con751_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con751_hls_bp_master_query_link" url="${/request/@context_path}/modules/hls/HLS215N/hls_bp_master_query.lview"/>
        <a:link id="con751_item_detail_query" url="${/request/@context_path}/modules/cont/CON501N/con_item_detail_query.lview"/>
        <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <script type="text/javascript"><![CDATA[
            Ext.ux.Lightbox.register('a[ref=img]', true);
            
            function lease_item_new_renderer(value, record, name) {
                if (name == 'lease_item_new' || name == 'lease_item_old') {
                    var contract_lease_item_id = record.get('contract_lease_item_id');
                    if (!Ext.isEmpty(contract_lease_item_id)) {
                        return '<a href="javascript:open_lease_item_win(' + contract_lease_item_id + ')">${l:HLS201.HLS_LEASE_ITEM_LIST}</a>';
                    }
                }
            }
            
            function open_lease_item_win(contract_lease_item_id) {
                new Leaf.Window({
                    url: $('lease_item_list_link').getUrl() + '?contract_lease_item_id=' + contract_lease_item_id,
                    title: '${l:HLS201.HLS_LEASE_ITEM_LIST}',
                    id: 'lease_item_list_win',
                    width: 900,
                    height: 400
                });
            }
            
            
            function con_quotation_ds_load(ds) {
                if (ds.getAll().length > 0) {
                    var ds_length = ds.getAll().length;
                    var record;
                    var column_name;
                    var from_column_value;
                    var to_column_value;
                    for (var i = 0;i < ds_length;i++) {
                        record = ds.getAt(i);
                        column_name = record.get('column_name');
                        from_column_value = record.get('from_column_value');
                        to_column_value = record.get('to_column_value');
                        if (column_name == 'IRR') {
                            from_column_value = process_percent_number(from_column_value);
                            to_column_value = process_percent_number(to_column_value);
                            record.set('from_column_value', from_column_value);
                            record.set('to_column_value', to_column_value);
            
                        }
                        if (column_name == 'FINANCE_AMOUNT' || column_name == 'DEPOSIT' || column_name == 'TOTAL_FEE') {
                            record.set('from_column_value', Leaf.formatMoney(from_column_value));
                            record.set('to_column_value', Leaf.formatMoney(to_column_value));
                        }
                    }
                }
            }
            
            
            //处理百分位的数字
            
            function process_percent_number(column_value) {
                return mul(column_value, 100) + '%';
            }
            
            function con_quotation_change_processfuncton(datas) {
                for (var i = 0;i < datas.length;i++) {
                    var temp = datas[i];
                    for (var name in temp) {
                        var temp_value = temp[name];
                        if (!isNaN(parseFloat(temp_value))) {
                            temp[name] = parseFloat(temp_value);
                        }
                    }
                }
                return datas;
            }
            
            function con_quotation_from_column_value_edf(record, name) {
                var con_quotation_grid = $('con_quotation_grid_id'),
                    column_value = record.get(name);
                var coulmn1 = con_quotation_grid.columns[1];
                var coulmn2 = con_quotation_grid.columns[2];
                if (!isNaN(parseFloat(column_value))) {
                    coulmn1.align = 'right';
                    coulmn2.align = 'right';
                } else {
                    coulmn1.align = 'left';
                    coulmn2.align = 'left';
                }
            }
            
            function con_contract_change_query_ds_load(ds) {
                var record = ds.getCurrentRecord();
                if (record) {
                    record.set('description', '${/model/con751_change_req_rp/record/@description}');
                }
            }
            
            // function attachment_renderer(value, record, name) {
                // return '<a href="javascript:open_attach_win()" style="font-size:15px;">' + '${l:PROMPT.VIEW_ATTACHMENT}' + '<a>';
            // }
            
            // function open_attach_win() {
                // var url = $('con751_attach_downloadfile_link').getUrl() + '?table_name=CON_CONTRACT&header_id=${/parameter/@new_contract_id}';
                // new Leaf.Window({
                    // url: url,
                    // title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    // id: 'con751_attach_downloadfile_win',
                    // width: 850,
                    // height: 400
                // });
            // }
            
            function con751_lease_item_detail_renderer(value, record, name) {
                if (record.get('contract_lease_item_id')) {
                    return '<a href="javascript:con751_open_lease_item_detail(\'' + record.id + '\')">' + '车辆明细' + '<a>';
                }
            }
            
            function con751_open_lease_item_detail(record_id) {
                var record = $('con_contract_lease_ds').findById(record_id);
                var param = record.data;
                var contract_lease_item_id = record.get('contract_lease_item_id');
                param['function_code'] = 'CON501Q';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '租赁物明细查询';
                hls_doc_get_layout_code('con751_con_contract_get_layout_code_link_id', param, 'con751_item_detail_query', record.ds.id);
            }
            
            function con751_g_bp_renderer(value, record, name) {
                if (record.get('bp_id')) {
                    return '<a href="javascript:con751_open_bp_master_detail(\'' + record.id + '\',\'' + record.ds.id + '\')">' + '商业伙伴明细' + '<a>';
                }
            }
            
            function con751_open_bp_master_detail(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'HLS214D';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '商业伙伴查询';
                hls_doc_get_layout_code('con751_con_contract_get_layout_code_link_id', param, 'con751_hls_bp_master_query_link');
            }
            
            
            
            
            function attach_file_name_re(value, record, name, config_record, bp_seq) {
                var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                if (value) {
                    var str = value.split(';;');
                    var url = '';
                    for (var i = 0;i < str.length;i++) {
                        var temp = str[i].split('--');
                        if (!Leaf.isEmpty(temp[0])) {
                            var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
                            if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                url = url + '<a ref="img" href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            } else {
                                url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            }
                            return url;
                        }
                    }
                }
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <!-- 报价信息 -->
            <a:dataSet id="con_quotation_change_ds" pageSize="8">
                <!-- processfunction="con_quotation_change_processfuncton"> -->
                <a:datas dataSource="/model/hls_document_compare_rp"/>
                <a:fields>
                    <a:field name="prompt"/>
                    <a:field name="from_column_value"/>
                    <a:field name="to_column_value"/>
                    <a:field name="column_name"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="con_quotation_ds_load"/>
                </a:events>
            </a:dataSet>
            <!-- 其他信息 -->
            <a:dataSet id="con_quotation_ds" autoQuery="true" fetchAll="true" pageSize="9" queryUrl="${/request/@context_path}/autocrud/cont.CON751.hls_document_compare/query?contract_id=${/parameter/@new_contract_id}"><![CDATA[
            	
            ]]></a:dataSet>
            <!-- 合同信息 -->
            <a:dataSet id="con_contract_change_query_ds" autoQuery="true" fetchAll="true" pageSize="9" queryUrl="${/request/@context_path}/autocrud/cont.CON751.con_contract_v_query/query?contract_id=${/parameter/@old_contract_id}&amp;new_contract_id=${/parameter/@new_contract_id}">
                <a:fields>
                    <a:field name="description" readOnly="true"/>
                    <a:field name="attachment"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="con_contract_change_query_ds_load"/>
                </a:events>
            </a:dataSet>
            <!-- 附件信息 -->
            <a:dataSet id="con_contract_file_attachment_ds" autoQuery="true" fetchAll="true" model="cont.CON751.con_contract_file_attachment_query" queryUrl="${/request/@context_path}/autocrud/cont.CON751.con_contract_file_attachment_query/query?contract_id=${/parameter/@new_contract_id}"><![CDATA[
            ]]></a:dataSet>
            <!-- 承租人 -->
            <a:dataSet id="con_contract_change_bp_new_ds" autoQuery="true" fetchAll="true" pageSize="9" queryUrl="${/request/@context_path}/autocrud/cont.CON751.con_contract_change_bp_query/query?contract_id=${/parameter/@new_contract_id}">
                <a:fields>
                    <a:field name="enabled_flag" checkedValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_change_bp_old_ds" autoQuery="true" fetchAll="true" pageSize="9" queryUrl="${/request/@context_path}/autocrud/cont.CON751.con_contract_change_bp_query/query?nomal_contract_contract_id=${/parameter/@old_contract_id}&amp;change_req_contract_id=${/parameter/@new_contract_id}">
                <a:fields>
                    <a:field name="enabled_flag" checkedValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
            <!-- 租赁物清单 -->
            <a:dataSet id="con_contract_change_lease_new_ds" autoQuery="true" fetchAll="true" pageSize="9" queryUrl="${/request/@context_path}/autocrud/cont.CON751.con_contract_lease_item_v/query?contract_id=${/parameter/@new_contract_id}">
                <a:fields>
                    <a:field name="lease_item_id_n"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_change_lease_old_ds" autoQuery="true" fetchAll="true" model="cont.CON751.con_contract_lease_item_v" pageSize="9" queryUrl="${/request/@context_path}/autocrud/cont.CON751.con_contract_lease_item_v/query?nomal_contract_contract_id=${/parameter/@old_contract_id}&amp;change_req_contract_id=${/parameter/@new_contract_id}">
                <a:fields>
                    <a:field name="lease_item_id_n"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:tabPanel height="300" width="1160">
                <a:tabs>
                    <a:tab prompt="基本信息" selected="true" width="500">
                        <a:hBox>
                            <a:form title="CON721.CONTRACT_BASE_INFO">
                                <a:hBox>
                                    <a:box column="4" labelWidth="100">
                                        <a:textField name="contract_number" bindTarget="con_contract_change_query_ds" prompt="HLS.CONTRACT_NUMBER" readOnly="true" width="150"/>
                                        <a:textField name="contract_name" bindTarget="con_contract_change_query_ds" prompt="HLS.CONTRACT_NAME" readOnly="true" width="150"/>
                                        <a:textField name="project_number" bindTarget="con_contract_change_query_ds" prompt="HLS.PROJECT_NUMBER" readOnly="true" width="150"/>
                                        <a:textField name="project_name" bindTarget="con_contract_change_query_ds" prompt="HLS.PROJECT_NAME" readOnly="true" width="150"/>
                                        <a:textField name="bp_name" bindTarget="con_contract_change_query_ds" prompt="HLS.TENANT_CODE" readOnly="true" width="150"/>
                                        <a:textField name="lease_organization_desc" bindTarget="con_contract_change_query_ds" prompt="HLS.LEASE_ORGANIZATION" readOnly="true" width="150"/>
                                        <a:textField name="employee_name_of_manager" bindTarget="con_contract_change_query_ds" prompt="HLS.EMPLOYEE_OF_MANAGER" readOnly="true" width="150"/>
                                        <a:textField name="employee_name" bindTarget="con_contract_change_query_ds" prompt="HLS.SALES_EMPLOYEE" readOnly="true" width="150"/>
                                        <!-- <a:textArea name="description" bindTarget="con_contract_change_query_ds" colspan="3" prompt="HLS.COMMENT" width="665"/> -->
                                    </a:box>
                                </a:hBox>
                                <a:hBox>
                                    <a:box labelWidth="100">
                                        <a:textArea name="change_req_description" bindTarget="con_contract_change_query_ds" colspan="3" prompt="变更说明" readOnly="true" width="665"/>
                                    </a:box>
                                    <a:vBox labelWidth="90">
                                        <a:textField name="change_req_type" bindTarget="con_contract_change_query_ds" prompt="变更类型" readOnly="true" width="150"/>
                                        <!-- <a:label name="attachment" bindTarget="con_contract_change_query_ds" renderer="attachment_renderer"/> -->
                                    </a:vBox>
                                </a:hBox>
                            </a:form>
                        </a:hBox>
                    </a:tab>
                    <a:tab prompt="附件查看" selected="true">
                        <a:grid id="con_contract_file_attachment_id" bindTarget="con_contract_file_attachment_ds" height="200" width="1150">
                            <a:columns>
                                <a:column name="description" prompt="文档名称" readOnly="true" width="200"/>
                                <a:column name="attach_file_name" prompt="附件名" readOnly="true" renderer="attach_file_name_re" width="500"/>
                                <a:column name="note" prompt="备注" readOnly="true" width="200"/>
                                <a:column name="last_file_upload_time" prompt="最后上传时间" readOnly="true" width="220"/>
                            </a:columns>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
            <a:tabPanel id="con751_all_tabpannel_id" height="350" marginWidth="30">
                <a:tabs>
                    <a:placeHolder id="con751dynamic_tab_id"/>
                    <!--   <a:tab prompt="CON721.OTHER_MEG" width="100">
                        <a:hBox>
                            <a:grid bindTarget="con_quotation_ds" height="300" navBar="true" width="650">
                                <a:columns>
                                    <a:column prompt="CON721.QUOTATION_MSG">
                                        <a:column name="prompt" prompt="CON721.CONTRACT_QUOTATION_CONTENT" width="195"/>
                                        <a:column name="from_column_value" prompt="CON721.CONTRACT_QUOTATION_CHANGE_OLD_MSG" width="150"/>
                                        <a:column name="to_column_value" prompt="CON721.CONTRACT_QUOTATION_CHANGE_NEW_MSG" width="150"/>
                                    </a:column>
                                </a:columns>
                            </a:grid>
                        </a:hBox>
                    </a:tab> -->
                </a:tabs>
            </a:tabPanel>
        </a:screenBody>
    </a:view>
    <a:view-config>
        <c:create-config targetId="con751dynamic_tab_id">
            <p:loop source="/model/con751_change_req_rp">
                <p:switch test="@change_quotation">
                    <p:case value="Y">
                        <c:process-config>
                            <a:tab prompt="HLS.QUOTATION_INFORMATION" width="100">
                                <a:hBox>
                                    <a:grid id="con_quotation_grid_id" bindTarget="con_quotation_change_ds" height="300" navBar="true" width="650">
                                        <a:columns>
                                            <a:column prompt="CON721.QUOTATION_MSG">
                                                <a:column name="prompt" prompt="CON721.CONTRACT_QUOTATION_CONTENT" width="195"/>
                                                <a:column name="from_column_value" align="right" prompt="CON721.CONTRACT_QUOTATION_CHANGE_OLD_MSG" width="150"/>
                                                <a:column name="to_column_value" align="right" prompt="CON721.CONTRACT_QUOTATION_CHANGE_NEW_MSG" width="150"/>
                                            </a:column>
                                        </a:columns>
                                    </a:grid>
                                </a:hBox>
                            </a:tab>
                        </c:process-config>
                    </p:case>
                </p:switch>
                <p:switch test="@change_bp">
                    <p:case value="Y">
                        <c:process-config>
                            <a:tab prompt="CON721.CONTRACT_BP_CHANGE_MSG" ref="${/request/@context_path}/modules/wfl_screen/CON_CONTRACT/hls_standard_history_bp_query.lview?contract_id=${/parameter/@new_contract_id}" width="150"><![CDATA[
                            ]]></a:tab>
                        </c:process-config>
                    </p:case>
                    <p:case value="C">
                        <c:process-config>
                            <a:tab prompt="CON721.CONTRACT_BP_CHANGE_MSG" ref="${/request/@context_path}/modules/wfl_screen/CON_CONTRACT/hls_standard_history_bp_query.lview?contract_id=${/parameter/@new_contract_id}" width="150"><![CDATA[
                                
                            ]]></a:tab>
                        </c:process-config>
                    </p:case>
                </p:switch>
                <p:switch test="@change_lease_item">
                    <p:case value="Y">
                        <c:process-config>
                            <a:tab id="con751_bp_tab" prompt="CON721.CONTRACT_LEASE_CHANGE_MSG" ref="${/request/@context_path}/modules/wfl_screen/CON_CONTRACT/hls_standard_history_lease_query.lview?contract_id=${/parameter/@new_contract_id}" width="150"><![CDATA[
                            ]]></a:tab>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>