<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-6-24 下午1:28:49  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="cont.CON500.con_contract_get_guid_file_name" rootPath="file_name_path"/>
        <s:server-script import="con_print_path.js"><![CDATA[
            set_parameter_file_path();
        ]]></s:server-script>
    </a:init-procedure>
    <a:view package="leaf.ui.std" template="default">
        <a:link id="con_contract_et_heads_save_link" modelaction="insert" url="${/request/@context_path}/autocrud/cont.CON701.con_contract_et_heads/batch_update"/>
        <a:link id="con_contract_et_lines_save_link" modelaction="insert" url="${/request/@context_path}/autocrud/cont.CON701.con_contract_et_lines/batch_update"/>
        <a:link id="con_contract_et_calculate_link" url="${/request/@context_path}/modules/cont/CON701/con_contract_et_calculate.lsc"/>
        <a:link id="con_contract_et_save_link" model="cont.CON610.con_contract_et_save" modelaction="execute"/>
        <a:link id="con_contract_et_submit_link" model="cont.CON701.con_contract_et_submit" modelaction="execute"/>
        <a:link id="con_contract_termination_date_check_link" model="cont.CON701.con_contract_termination_date_check" modelaction="execute"/>
        <a:link id="et_attachment_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="con_contract_et_link" url="${/request/@context_path}/modules/cont/CON701/con_contract_et_print.lsc"/>
        <!-- <a:link id="con_contract_change_download_link" url="${/request/@context_path}/modules/cont/CON701/hls_con_contract_change_download.lsc"/> -->
        <a:link id="get_role_code_link" model="cont.CON701.get_role_code" modelaction="update"/>
        <a:link id="attachment_et_link" model="cont.CON701.con_contract_attachment_et" modelaction="update"/>
        <!--一下为打印使用-->
        <a:link id="hls_doc_file_content_link_id" model="cont.CON701.con701_hls_doc_file_content" modelaction="update"/>
        <a:link id="hls_doc_file_batch_create_print_link_id" url="${/request/@context_path}/modules/cont/CON701/hls_doc_file_batch_create.lsc"/>
        <a:link id="hls_doc_batch_download_pdf_print_link_id" url="${/request/@context_path}/modules/cont/CON701/hls_doc_batch_download_pdf.lsc"/>
        <div/>
        <script type="text/javascript"><![CDATA[
            var new_recs = []; //任务数组
            var total_index = 0;
            var current_index = 0;
            var file_path = '${/parameter/@file_path}';
            var download_arr = [];
            
            
            
            
            var save_flag = false;
            
            function Screen_forward() {
                history.go(1);
            }
            
            function Screen_back() {
                history.go(-1);
            }
            
            function lock_current_window() {
                Leaf.Masker.mask(Ext.getBody(), '提交中......');
            }
            
            function unlock_current_window() {
                Leaf.Masker.unmask(Ext.getBody());
            }
            
            function Screen_exit() {
                $('${/parameter/@winId}').close();
            }
            
            function contractCreateScreen_calculate() {
                var ds = $('contractQueryScreen_mainDs'),
                    et_ds = $('early_terminationDs'),
                    et_record = et_ds.getAt(0),
                    record = ds.getCurrentRecord();
                var et_agreement_id, et_fee, et_profile, et_first_calc_flag = 'N';
                // if (!save_flag && et_record.dirty) {
                // Leaf.showWarningMessage('提示', '提前结清信息已经变更，请先保存之后再测算');
                // return;
                // }
                if (record.validateRecord(true)) {
                    var termination_date = Leaf.formatDate(record.get('termination_date'));
                    var contract_id = record.get('contract_id');
                    var et_ratio = $('contract_et_ratio_ds').getAt(0).get('et_ratio');
                    et_profile = record.get('et_profile') ? record.get('et_profile') : et_record.get('et_profile');
                    if (et_record) {
                        et_agreement_id = et_record.get('et_agreement_id');
                        et_fee = et_record.get('et_fee');
                    } else {
                        et_first_calc_flag = 'Y';
                    }
                    Leaf.Masker.mask($('con_contract_adv_settle_create_window').wrap, '正在加载......');
                    Leaf.request({
                        url: $('con_contract_et_calculate_link').getUrl(),
                        para: {
                            termination_date: termination_date,
                            contract_id: contract_id,
                            et_type: 'AD',
                            et_agreement_id: et_agreement_id,
                            et_profile: et_profile,
                            et_ratio: et_ratio,
                            et_fee: et_fee,
                            et_first_calc_flag: et_first_calc_flag
                        },
                        success: function(args) { //
                            var et_agreement_id = args.result.et_agreement_id;
                            et_ds.setQueryParameter('et_agreement_id', et_agreement_id);
                            et_ds.query();
            
                            $('unreceivedAmountDs').setQueryParameter('contract_id', record.get('contract_id'));
                            $('unreceivedAmountDs').setQueryParameter('et_agreement_id', et_agreement_id);
                            $('unreceivedAmountDs').query();
            
                            $('unreceivedAmountSumDs').setQueryParameter('contract_id', record.get('contract_id'));
                            $('unreceivedAmountSumDs').setQueryParameter('et_agreement_id', et_agreement_id);
                            $('unreceivedAmountSumDs').query();
            
                            var er_record = $('early_terminationDs').getCurrentRecord();
                            var su_record = $('unreceivedAmountSumDs').getCurrentRecord();
            
                            var sum_principal = su_record.get('sum_principal') || 0;
                            var ref_n03 = er_record.get('ref_n03') || 0;
                            var recovered_amount = er_record.get('recovered_amount') || 0;
                            var dealers_amount = er_record.get('dealers_amount') || 0;
                            var risk_amount = er_record.get('risk_amount') || 0;
                            var loss_assets_amount = sum_principal - ref_n03 - recovered_amount - dealers_amount - risk_amount;
                            er_record.set('loss_assets_amount', loss_assets_amount);
            
                            $('receivedAmountDs').setQueryParameter('contract_id', record.get('contract_id'));
                            $('receivedAmountDs').query();
                            document.getElementById("detail_flag_id").style.display = "";
                            Leaf.Masker.unmask($('con_contract_adv_settle_create_window').wrap);
                        },
                        failure: function() {
                            Leaf.Masker.unmask($('con_contract_adv_settle_create_window').wrap);
                        },
                        error: function() {
                            Leaf.Masker.unmask($('con_contract_adv_settle_create_window').wrap);
                        },
                        scope: this
                    });
                }
            }
            
            function et_save(value) {
                var et_ds = $('early_terminationDs'),
                    et_record = et_ds.getAt(0);
                var et_agreement_id = et_record.get('et_agreement_id');
                var record = $('contractQueryScreen_mainDs').getCurrentRecord();
                var trial = record.get('trial');
                var received_times = record.get('received_times');
                var role_code;
                //var role_code = res.result.role_code;
                if (trial == 'Y') {
                    Leaf.showWarningMessage('提示', '勾选了试算标志，不能进行保存操作！');
                } else {
                    if (et_agreement_id) {
                        if (Ext.isEmpty(et_record.get('recovered_amount'))) {
                            Leaf.showMessage('提示', '请填写可回收金额！');
                            return;
                        }
                        var ref_n04 = et_record.get('ref_n04');
                        var ref_n05 = et_record.get('ref_n05');
                        var ref_n06 = et_record.get('ref_n06');
                        var ref_n07 = et_record.get('ref_n07');
                        var penalty = et_record.get('penalty');
                        var et_fee = et_record.get('et_fee');
                        var ref_n01 = et_record.get('ref_n01');
                        var ref_n02 = et_record.get('ref_n02');
                        var note = et_record.get('note');
                        var su_record = $('unreceivedAmountSumDs').getCurrentRecord();
                        var recovered_amount = et_record.get('recovered_amount');
                        var dealers_amount = et_record.get('dealers_amount');
                        var risk_amount = et_record.get('risk_amount');
                        var loss_assets_amount = et_record.get('loss_assets_amount');
                        var write_off_desc_loss = et_record.get('write_off_desc_loss');
                        var sum_due_amount = su_record.get('sum_due_amount');
                        var sum_principal = su_record.get('sum_principal');
                        var sum_interest = su_record.get('sum_interest');
            
                        Leaf.Masker.mask($('${/parameter/@winId}').wrap, '正在加载...');
                        Leaf.request({
                            url: $('con_contract_et_save_link').getUrl(),
                            para: {
                                et_agreement_id: et_agreement_id,
                                recovered_amount: recovered_amount,
                                loss_assets_amount: loss_assets_amount,
                                dealers_amount: dealers_amount,
                                risk_amount: risk_amount,
                                sum_due_amount: sum_due_amount,
                                sum_principal: sum_principal,
                                sum_interest: sum_interest,
                                write_off_desc_loss: write_off_desc_loss
            
                            },
                            success: function(args) {
                                save_flag = true;
                                if (value == 'sub') {
                                    et_submit();
                                } else if (value === 'calc') {
                                    contractCreateScreen_calculate();
                                } else {
            
                                    et_ds.setQueryParameter('et_agreement_id', et_agreement_id);
                                    et_ds.query();
                                    $('unreceivedAmountDs').setQueryParameter('contract_id', et_record.get('contract_id'));
                                    $('unreceivedAmountDs').setQueryParameter('et_agreement_id', et_agreement_id);
                                    $('unreceivedAmountDs').query();
            
                                    $('unreceivedAmountSumDs').setQueryParameter('contract_id', record.get('contract_id'));
                                    $('unreceivedAmountSumDs').setQueryParameter('et_agreement_id', et_agreement_id);
                                    $('unreceivedAmountSumDs').query();
            
            
                                    var er_record = $('early_terminationDs').getCurrentRecord();
                                    var su_record = $('unreceivedAmountSumDs').getCurrentRecord();
            
                                    var sum_principal = su_record.get('sum_principal') || 0;
                                    var ref_n03 = er_record.get('ref_n03') || 0;
                                    var recovered_amount = er_record.get('recovered_amount') || 0;
                                    var dealers_amount = er_record.get('dealers_amount') || 0;
                                    var risk_amount = er_record.get('risk_amount') || 0;
                                    var loss_assets_amount = sum_principal - ref_n03 - recovered_amount - dealers_amount - risk_amount;
                                    er_record.set('loss_assets_amount', loss_assets_amount);
            
                                    Leaf.Masker.unmask($('${/parameter/@winId}').wrap);
                                    Leaf.SideBar.show({
                                        msg: '保存成功',
                                        duration: 2000
                                    });
                                }
                            },
                            scope: this
                        });
            
                    } else {
                        Leaf.showWarningMessage('提示', '请先测算！');
                    }
                }
            }
            
            function SumDs_onLoad(ds, record, name, value) {
                var er_record = $('early_terminationDs').getCurrentRecord();
                var su_record = $('unreceivedAmountSumDs').getCurrentRecord();
            
                var sum_principal = su_record.get('sum_principal') || 0;
                var ref_n03 = er_record.get('ref_n03') || 0;
                var recovered_amount = er_record.get('recovered_amount') || 0;
                var dealers_amount = er_record.get('dealers_amount') || 0;
                var risk_amount = er_record.get('risk_amount') || 0;
                var loss_assets_amount = sum_principal - ref_n03 - recovered_amount - dealers_amount - risk_amount;
                er_record.set('loss_assets_amount', loss_assets_amount);
            }
            
            function onUpdate1(ds, record, name, value) {
                record = $('early_terminationDs').getAt(0);
                var penalty = record.get('penalty') || 0;
                var et_fee = record.get('et_fee') || 0;
                var ref_n01 = record.get('ref_n01') || 0;
                var ref_n02 = record.get('ref_n02') || 0;
            
                var collecting_fee = record.get('collecting_fee') || 0;
                var take_back_fee = record.get('take_back_fee') || 0;
                var damages_fee = record.get('damages_fee') || 0;
                var assessment_fee = record.get('assessment_fee') || 0;
                var collection_fee = record.get('collection_fee') || 0;
                var loy_fee = record.get('loy_fee') || 0;
            
                debt_fee = penalty * 1 + collecting_fee * 1 + take_back_fee * 1 + damages_fee * 1 + assessment_fee * 1 + collection_fee * 1 + loy_fee * 1;
                record.set('debt_fee', debt_fee);
            
            }
            
            function onUpdate2(ds, record, name, value) {
                if (name == 'et_ratio') {
                    var et_ratio = $('contract_et_ratio_ds').getAt(0).get('et_ratio');
                    record2 = $('early_terminationDs').getAt(0);
                    var et_fee_calc;
                    var et_fee = record2.get('et_fee');
                    var penalty = record2.get('penalty');
                    var residual_value = record2.get('residual_value');
                    var overdue_amount = record2.get('overdue_amount');
                    var undue_principal = record2.get('undue_principal');
                    if (!penalty) {
                        penalty = 0;
                    }
                    if (!et_ratio) {
                        et_ratio = 0;
                    }
                    if (et_fee > 0) {
                        et_fee_calc = et_fee;
                    } else {
                        et_fee_calc = 0;
                    }
                    et_interest = ((et_fee_calc + penalty + overdue_amount + undue_principal + residual_value) * et_ratio).toFixed(2);
                    et_interest = parseFloat(et_interest);
                    record2.set('et_interest', et_interest);
                    record2.set('et_total_amount', et_fee_calc + penalty + residual_value + overdue_amount + undue_principal + et_interest);
                }
            
            }
            
            function et_submit() {
                //
                var et_ds = $('early_terminationDs'),
                    et_record = et_ds.getAt(0);
                if (et_record) {
                    var et_agreement_id = et_record.get('et_agreement_id');
                    Leaf.showConfirm('${l:HLS.PROMPT}', '确定要提交？', function() {
                        lock_current_window();
                        Leaf.request({
                            url: $('con_contract_et_submit_link').getUrl(),
                            para: {
                                et_agreement_id: et_agreement_id
                            },
                            success: function(args) { //
                                unlock_current_window();
                                Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                $('con_contract_adv_settle_create_window').close();
                            },
                            failure: function() {
                                unlock_current_window();
                            },
                            error: function() {
                                unlock_current_window();
                            },
                            scope: this
                        });
                        unlock_current_window();
                    });
                } else {
                    Leaf.showMessage('提示', '请先测算！');
                }
                Leaf.Masker.unmask($('${/parameter/@winId}').wrap);
            }
            
            function et_submit_entrance() {
                et_save();
                var et_ds = $('early_terminationDs'),
                    et_record = et_ds.getAt(0);
                var et_agreement_id = et_record.get('et_agreement_id');
                Leaf.request({
                    url: $('attachment_et_link').getUrl(),
                    para: {
                        table_name: 'CON_CONTRACT_ET_HD',
                        table_pk_value: et_agreement_id
                    },
                    success: function(res) {
                        var attachment_num = res.result.attachment_num;
                        //alert(attachment_num);
                        if (attachment_num == 0) {
                            //  Leaf.showMessage('提示', '您未上传附件不能进行提交，请先上传附件！');
                            // return;
                            et_save('sub');
                        } else {
                            et_save('sub');
                        }
                    },
                    failure: function() {
                        unlock_current_window();
                    },
                    error: function() {
                        unlock_current_window();
                    },
                    scope: this
                });
            }
            
            function et_calc_entrance() {
                if (save_flag) {
                    et_save('calc');
                } else {
                    contractCreateScreen_calculate();
                }
            }
            
            function detail_attachment() {
                if (!$('early_terminationDs').getCurrentRecord('status')) {
                    Leaf.showMessage('提示', '请先保存再上传附件');
                    return;
                }
            
                if ($('early_terminationDs').getAt(0).get('status') != 'NEW') {
                    Leaf.showMessage('提示', '请先保存再上传附件');
                    return;
                }
                var val = $('early_terminationDs').getAt(0).get('et_agreement_id');
                var url = $('et_attachment_uploadFile_id').getUrl() + '?table_name=CON_CONTRACT_ET_HD&header_id=' + val;
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'et_uploadFile_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {});
            }
            
            function calc_et_total_amount_update(ds, record, name, value) {
                var ref_n03 = record.get('ref_n03') || 0;
                if (name == 'recovered_amount' || name == 'dealers_amount' || name == 'risk_amount') {
                    var su_record = $('unreceivedAmountSumDs').getCurrentRecord();
                    var sum_principal = su_record.get('sum_principal') || 0;
                    var recovered_amount = record.get('recovered_amount') || 0;
                    var dealers_amount = record.get('dealers_amount') || 0;
                    var risk_amount = record.get('risk_amount') || 0;
                    var loss_assets_amount = sum_principal - ref_n03 - recovered_amount - dealers_amount-risk_amount;
                    record.set('loss_assets_amount', loss_assets_amount);
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="et_pay_method_ds" lookupCode="ET_PAY_METHOD"/>
            <a:dataSet id="early_terminationDs" autoCreate="true" model="cont.CON701.con_contract_et_hd">
                <a:fields>
                    <a:field name="others_fee" required="true"/>
                    <a:field name="et_fee" required="true"/>
                    <a:field name="pay_method"/>
                    <a:field name="pay_method_desc" displayField="code_value_name" options="et_pay_method_ds" returnField="pay_method" valueField="code_value"/>
                    <a:field name="recovered_amount" required="true"/>
                    <a:field name="dealers_amount" required="true"/>
                    <a:field name="risk_amount"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="onUpdate1"/>
                    <a:event name="update" handler="calc_et_total_amount_update"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="contract_et_ratio_ds" autoCreate="true">
                <a:fields>
                    <a:field name="et_ratio" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate2"/>
                </a:events>
            </a:dataSet>
            <!-- <a:dataSet id="rentPaymentDs" model="cont.CON701.con_ren_payment_status_query" submitUrl="${/request/@context_path}/autocrud/cont.CON701.con_contract_et_lines/batch_update"><![CDATA[
            ]]></a:dataSet> -->
            <a:dataSet id="receivedAmountDs" fetchAll="true" model="cont.CON701.con_contract_received_amount"/>
            <a:dataSet id="unreceivedAmountDs" fetchAll="true" model="cont.CON701.con_contract_unreceived_amount"/>
            <a:dataSet id="unreceivedAmountSumDs" autoQuery="true" model="cont.CON610.con_contract_unreceived_amount_sum">
                <a:events>
                    <a:event name="load" handler="SumDs_onLoad"/>
                </a:events>
            </a:dataSet>
            <!-- <a:dataSet id="contractQueryScreen_mainDs" loadData="true" model="cont.CON370.con_contract_et_hd_info_query"/> -->
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="Screen_exit" text="关闭"/>
                <a:gridButton click="et_calc_entrance" text="测算"/>
                <a:gridButton click="et_save" text="HLS.SAVE"/>
                <a:gridButton click="et_submit_entrance" text="提交"/>
                <!-- <a:gridButton click="detail_attachment" text="HLS.ATTACHMENT"/> -->
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="110" marginWidth="30" title="基础信息">
                <a:textField name="contract_number" bindTarget="contractQueryScreen_mainDs" prompt="合同编码" readOnly="true"/>
                <a:textField name="contract_name" bindTarget="contractQueryScreen_mainDs" prompt="合同名称" readOnly="true"/>
                <a:textField name="document_type_desc" bindTarget="contractQueryScreen_mainDs" prompt="合同类型" readOnly="true"/>
                <!-- <a:textField name="document_category_desc" bindTarget="contractQueryScreen_mainDs" prompt="合同类别" readOnly="true"/> -->
                <a:textField name="bp_name" bindTarget="contractQueryScreen_mainDs" prompt="承租人名称" readOnly="true"/>
                <a:textField name="received_times" bindTarget="contractQueryScreen_mainDs" prompt="已还款期数" readOnly="true"/>
                <a:textField name="status_desc" bindTarget="contractQueryScreen_mainDs" prompt="合同状态" readOnly="true"/>
                <a:datePicker name="inception_of_lease" bindTarget="contractQueryScreen_mainDs" prompt="起租日期" readOnly="true"/>
                <a:datePicker name="start_due_date" bindTarget="contractQueryScreen_mainDs" prompt="支付开始日" readOnly="true"/>
                <a:textField name="overdue_status" bindTarget="contractQueryScreen_mainDs" prompt="是否逾期" readOnly="true"/>
                <a:datePicker name="termination_date" bindTarget="contractQueryScreen_mainDs" prompt="资产处置日" renderer="Leaf.formatDate"/>
                <a:lov name="bp_agent" bindTarget="contractQueryScreen_mainDs" prompt="经销商" readOnly="true"/>
                <!-- <a:textField name="car_description" bindTarget="contractQueryScreen_mainDs" prompt="车辆描述" readOnly="true"/> -->
                <a:lov name="item_frame_number" bindTarget="contractQueryScreen_mainDs" prompt="车架号" readOnly="true"/>
                <a:textField name="division_n" bindTarget="contractQueryScreen_mainDs" prompt="产品线" readOnly="true"/>
                <a:lov name="bp_name_1" bindTarget="contractQueryScreen_mainDs" prompt="供应商" readOnly="true"/>
                <a:lov name="product_name_write" bindTarget="contractQueryScreen_mainDs" prompt="融资租赁产品" readOnly="true"/>
                <a:textField name="lease_times" bindTarget="contractQueryScreen_mainDs" prompt="租赁期数" readOnly="true"/>
                <a:textField name="int_rate_display" bindTarget="contractQueryScreen_mainDs" prompt="租赁年利率" readOnly="true"/>
                <a:numberField name="invoice_price" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="购置价" readOnly="true"/>
                <a:numberField name="finance_amount" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="融资额" readOnly="true"/>
                <a:numberField name="down_payment" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="首付金额" readOnly="true"/>
                <a:textField name="down_payment_ratio" bindTarget="contractQueryScreen_mainDs" prompt="首付比例" readOnly="true"/>
                <a:textField name="deposit_ratio" bindTarget="contractQueryScreen_mainDs" prompt="保证金比例" readOnly="true"/>
                <a:numberField name="deposit" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="保证金" readOnly="true"/>
                <a:textField name="lease_charge_ratio" bindTarget="contractQueryScreen_mainDs" prompt="手续费比例" readOnly="true"/>
                <a:numberField name="lease_charge" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="手续费" readOnly="true"/>
                <a:textField name="license_fee_flag_n" bindTarget="contractQueryScreen_mainDs" prompt="是否包牌" readOnly="true"/>
                <a:numberField name="plate_price" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="上牌费" readOnly="true"/>
                <a:textField name="insurance_flag_n" bindTarget="contractQueryScreen_mainDs" prompt="是否融保险" readOnly="true"/>
                <a:numberField name="insurance_amount" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="保险费" readOnly="true"/>
                <a:textField name="purchase_tax_flag_n" bindTarget="contractQueryScreen_mainDs" prompt="是否融购置税" readOnly="true"/>
                <a:numberField name="purchase_tax" allowDecimals="true" allowFormat="true" bindTarget="contractQueryScreen_mainDs" decimalPrecision="2" prompt="购置税" readOnly="true"/>
            </a:form>
            <div id="detail_flag_id">
                <a:form title="资产处置信息">
                    <a:form column="4" labelWidth="100" marginWidth="30">
                        <a:numberField name="sum_due_amount" allowDecimals="true" allowFormat="true" bindTarget="unreceivedAmountSumDs" decimalPrecision="2" prompt="未收租金" readOnly="true"/>
                        <a:numberField name="sum_principal" allowDecimals="true" allowFormat="true" bindTarget="unreceivedAmountSumDs" decimalPrecision="2" prompt="未收本金" readOnly="true"/>
                        <a:numberField name="sum_interest" allowDecimals="true" allowFormat="true" bindTarget="unreceivedAmountSumDs" decimalPrecision="2" prompt="未收利息" readOnly="true"/>
                        <a:numberField name="sum_interest" allowDecimals="true" allowFormat="true" bindTarget="unreceivedAmountSumDs" decimalPrecision="2" prompt="未收利息减免" readOnly="true"/>
                        <a:numberField name="residual_value" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="留购金" readOnly="true"/>
                        <a:numberField name="residual_value" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="留购金减免" readOnly="true"/>
                        <a:numberField name="ref_n08" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="未收贴息-承租人" readOnly="true"/>
                        <a:numberField name="ref_n08" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="未收贴息-承租人减免" readOnly="true"/>
                        <a:numberField name="penalty" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="罚息" readOnly="true"/>
                        <a:numberField name="penalty" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="罚息减免" readOnly="true"/>
                        <a:numberField name="et_fee" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="违约金" readOnly="true"/>
                        <a:numberField name="et_fee" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="违约金减免" readOnly="true"/>
                        <a:numberField name="ref_n01" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="应收经销商保证金" readOnly="true"/>
                        <a:numberField name="ref_n01" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="应收经销商保证金减免" readOnly="true"/>
                        <a:numberField name="ref_n02" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="应收风险金" readOnly="true"/>
                        <a:numberField name="ref_n02" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="风险金减免" readOnly="true"/>
                        <a:numberField name="recovered_amount" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="可回收金额"/>
                        <a:numberField name="ref_n03" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="客户保证金" readOnly="true"/>
                        <a:numberField name="balance_amount" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="经销商保证金余额" readOnly="true"/>
                        <a:numberField name="dealers_amount" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="经销商承担金额"/>
                        <a:numberField name="risk_amount" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="风险金"/>
                        <a:numberField name="loss_assets_amount" allowDecimals="true" allowFormat="true" bindTarget="early_terminationDs" decimalPrecision="2" prompt="资产处置损失" readOnly="true"/>
                    </a:form>
                    <a:form column="4" labelWidth="110" marginWidth="30">
                        <a:textArea name="write_off_desc_loss" bindTarget="early_terminationDs" height="50" prompt="核销详述" width="820"/>
                    </a:form>
                    <a:tabPanel marginHeight="400" marginWidth="30">
                        <a:tabs>
                            <a:tab prompt="未收金额" width="110">
                                <a:grid bindTarget="unreceivedAmountDs" marginHeight="430" marginWidth="100" navBar="true">
                                    <a:columns>
                                        <a:column name="times" prompt="期数"/>
                                        <a:column name="cf_item_dis" prompt="类型"/>
                                        <a:column name="due_amount" align="right" prompt="应收金额" renderer="Leaf.formatMoney"/>
                                        <a:column name="received_amount" align="right" prompt="已收金额" renderer="Leaf.formatMoney"/>
                                        <a:column name="due_date" prompt="预定支付日期"/>
                                        <a:column name="principal" align="right" prompt="未收本金" renderer="Leaf.formatMoney"/>
                                        <a:column name="interest" align="right" prompt="未收利息" renderer="Leaf.formatMoney"/>
                                        <a:column name="cf_status_dis" prompt="现金流状态"/>
                                    </a:columns>
                                </a:grid>
                            </a:tab>
                            <a:tab prompt="已收金额" width="110">
                                <a:grid bindTarget="receivedAmountDs" marginHeight="430" marginWidth="100" navBar="true">
                                    <a:columns>
                                        <a:column name="times" prompt="期数"/>
                                        <a:column name="cf_item_dis" prompt="类型"/>
                                        <a:column name="due_amount" align="right" prompt="应收金额" renderer="Leaf.formatMoney"/>
                                        <a:column name="received_amount" align="right" prompt="已收金额" renderer="Leaf.formatMoney"/>
                                        <a:column name="due_date" prompt="预定支付日期"/>
                                        <a:column name="received_principal" align="right" prompt="已收本金" renderer="Leaf.formatMoney"/>
                                        <a:column name="received_interest" align="right" prompt="已收利息" renderer="Leaf.formatMoney"/>
                                        <a:column name="cf_status_dis" prompt="现金流状态"/>
                                    </a:columns>
                                </a:grid>
                            </a:tab>
                        </a:tabs>
                    </a:tabPanel>
                </a:form>
            </div>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            Leaf.onReady(init);
            
            function init() {
                var record = $('contractQueryScreen_mainDs').getCurrentRecord();
                var early_termination_profile = record.get('early_termination_profile');
                var ratio_record = $('contract_et_ratio_ds').getAt(0);
                //租金结清 手续费率等于0并且只读
                if (early_termination_profile !== 'DISCOUNT_STD') {
                    //ratio_record.set('et_ratio',0);
                    ratio_record.getField('et_ratio').setReadOnly(true);
                }
                record.getField('contract_number').setReadOnly(true);
                record.getField('contract_name').setReadOnly(true);
            
                // 已还款期数
                record.getField('received_times').setReadOnly(true);
                var received_times = record.get('received_times');
            
                // 车辆入库日
                record.getField('car_in_date').setReadOnly(true);
                //测算标志
                var trial = record.get('trial');
                //alert(trial);
            
                record.getField('document_type_desc').setReadOnly(true);
                record.getField('document_category_desc').setReadOnly(true);
                record.getField('bp_name').setReadOnly(true);
                record.getField('employee_name').setReadOnly(true);
                record.getField('project_name').setReadOnly(true);
                record.getField('status_desc').setReadOnly(true);
                record.getField('inception_of_lease').setReadOnly(true);
                record.getField('user_desc').setReadOnly(true);
                record.getField('overdue_status').setReadOnly(true);
                document.getElementById("detail_flag_id").style.display = "none";
            }
        ]]></script>
    </a:view>
</a:screen>
