<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei5743 
    $Date: 2014-12-19 上午10:00:35  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:view>
        <script type="text/javascript"><![CDATA[
            function con_contract_info_query() {
                $('con_contract_info_ds').query();
            }
            
            function on_renderer(value, record, name) {
                if (name == 'hd_user_col_n06' || name == "irr" || name == "down_payment_ratio" || name == "deposit_ratio") {
                    return value * 100;
                }
            }
            
            
            function return_number(value, record, name) {
                if (name == "lease_term") {
                    return Leaf.formatNumber(value, 0);
                }
            }
            
            function on_update_document_category(ds, record, name, value) {
                if (name == 'document_category') {
                    if (value == 'PROJECT') {
                        record.set('document_status', '');
                        record.set('document_status_des', '');
                        record.getField('document_status_des').setOptions('prj500n_project_status_ds');
                        record.getField('document_status_des').setReadOnly(false);
                    } else if (value == 'CONTRACT') {
                        record.set('document_status', '');
                        record.set('document_status_des', '');
                        record.getField('document_status_des').setOptions('con_contract_status_ds');
                        record.getField('document_status_des').setReadOnly(false);
                    } else {
                        record.set('document_status', '');
                        record.set('document_status_des', '');
                        record.getField('document_status_des').setReadOnly(true);
                    }
                }
            }
            
            
            function summaryRenderer(datas, name) {
                var sum = 0;
                var sum2 = 0;
                var sum3 = 0;
                var sum4 = 0;
                var sum5 = 0;
                var sum6 = 0;
                var sum7 = 0;
                var sum8 = 0;
                var sum9 = 0;
                var sum10 = 0;
                var sum11 = 0;
                var sum12 = 0;
                var sum13 = 0;
                var sum14 = 0;
                var sum15 = 0;
                var sum16 = 0;
                var sum17 = 0;
                var sum18 = 0;
                for (var i = 0;i < datas.length;i++) {
                    record = datas[i];
                    if (name == "finance_income") {
                        var finance_income_1 = record.get("finance_income");
                        var finance_income_2 = parseFloat(finance_income_1);
                        if (!isNaN(finance_income_2)) {
                            sum += finance_income_2;
                        }
                    }
                    if (name == "lease_item_amount") {
                        var lease_item_amount_1 = record.get("lease_item_amount");
                        var lease_item_amount_2 = parseFloat(lease_item_amount_1);
                        if (!isNaN(lease_item_amount_2)) {
                            sum2 += lease_item_amount_2;
                        }
                    }
                    if (name == "down_payment") {
                        var down_payment_1 = record.get("down_payment");
                        var down_payment_2 = parseFloat(down_payment_1);
                        if (!isNaN(down_payment_2)) {
                            sum3 += down_payment_2;
                        }
                    }
                    if (name == "finance_amount") {
                        var finance_amount_1 = record.get("finance_amount");
                        var finance_amount_2 = parseFloat(finance_amount_1);
                        if (!isNaN(finance_amount_2)) {
                            sum4 += finance_amount_2;
                        }
                    }
                    if (name == "lease_charge") {
                        var lease_charge_1 = record.get("lease_charge");
                        var lease_charge_2 = parseFloat(lease_charge_1);
                        if (!isNaN(lease_charge_2)) {
                            sum5 += lease_charge_2;
                        }
                    }
                    if (name == "pmt") {
                        var pmt_1 = record.get("pmt");
                        var pmt_2 = parseFloat(pmt_1);
                        if (!isNaN(pmt_2)) {
                            sum6 += pmt_2;
                        }
                    }
                    if (name == "residual_value") {
                        var residual_value_1 = record.get("residual_value");
                        var residual_value_2 = parseFloat(residual_value_1);
                        if (!isNaN(residual_value_2)) {
                            sum7 += residual_value_2;
                        }
                    }
                    if (name == "deposit") {
                        var deposit_1 = record.get("deposit");
                        var deposit_2 = parseFloat(deposit_1);
                        if (!isNaN(deposit_2)) {
                            sum8 += deposit_2;
                        }
                    }
                    if (name == "hd_user_col_n03") {
                        var hd_user_col_n03_1 = record.get("hd_user_col_n03");
                        var hd_user_col_n03_2 = parseFloat(hd_user_col_n03_1);
                        if (!isNaN(hd_user_col_n03_2)) {
                            sum9 += hd_user_col_n03_2;
                        }
                    }
                    if (name == "hd_user_col_n12") {
                        var hd_user_col_n12_1 = record.get("hd_user_col_n12");
                        var hd_user_col_n12_2 = parseFloat(hd_user_col_n12_1);
                        if (!isNaN(hd_user_col_n12_2)) {
                            sum10 += hd_user_col_n12_2;
                        }
                    }
                    if (name == "other_fee") {
                        var other_fee_1 = record.get("other_fee");
                        var other_fee_2 = parseFloat(other_fee_1);
                        if (!isNaN(other_fee_2)) {
                            sum11 += other_fee_2;
                        }
                    }
            
                    if (name == "other_fee3") {
                        var other_fee3_1 = record.get("other_fee3");
                        var other_fee3_2 = parseFloat(other_fee3_1);
                        if (!isNaN(other_fee3_2)) {
                            sum12 += other_fee3_2;
                        }
                    }
                    if (name == "insurance_fee") {
                        var insurance_fee_1 = record.get("insurance_fee");
                        var insurance_fee_2 = parseFloat(insurance_fee_1);
                        if (!isNaN(insurance_fee_2)) {
                            sum13 += insurance_fee_2;
                        }
                    }
                    if (name == "hd_user_col_n05") {
                        var hd_user_col_n05_1 = record.get("hd_user_col_n05");
                        var hd_user_col_n05_2 = parseFloat(hd_user_col_n05_1);
                        if (!isNaN(hd_user_col_n05_2)) {
                            sum14 += hd_user_col_n05_2;
                        }
                    }
                    if (name == "car_invoice_total_amount") {
                        var car_invoice_total_amount_1 = record.get("car_invoice_total_amount");
                        var car_invoice_total_amount_2 = parseFloat(car_invoice_total_amount_1);
                        if (!isNaN(car_invoice_total_amount_2)) {
                            sum15 += car_invoice_total_amount_2;
                        }
                    }
                    if (name == "fee_invoice_total_amount") {
                        var fee_invoice_total_amount_1 = record.get("fee_invoice_total_amount");
                        var fee_invoice_total_amount_2 = parseFloat(fee_invoice_total_amount_1);
                        if (!isNaN(fee_invoice_total_amount_2)) {
                            sum16 += fee_invoice_total_amount_2;
                        }
                    }
                    if (name == "insurance_invoice_total_amount") {
                        var insurance_invoice_total_amount_1 = record.get("insurance_invoice_total_amount");
                        var insurance_invoice_total_amount_2= parseFloat(insurance_invoice_total_amount_1);
                        if (!isNaN(insurance_invoice_total_amount_2)) {
                            sum17 += insurance_invoice_total_amount_2;
                        }
                    }
                    if (name == "hd_user_col_n02") {
                        var hd_user_col_n02_1 = record.get("hd_user_col_n02");
                        var hd_user_col_n02_2 = parseFloat(hd_user_col_n02_1);
                        if (!isNaN(hd_user_col_n02_2)) {
                            sum18 += hd_user_col_n02_2;
                        }
                    }
                }
            
                if (name == "price_list_des") {
                    return '<div align="center" ><font color="red" style="font-weight:bold;">合计:</font></div>';
                }
                if (name == "finance_income") {
                    return '<font color="red">' + Leaf.formatNumber(sum, 2) + '</font>';
                }
                if (name == "lease_item_amount") {
                    return '<font color="red">' + Leaf.formatNumber(sum2, 2) + '</font>';
                }
                if (name == "down_payment") {
                    return '<font color="red">' + Leaf.formatNumber(sum3, 2) + '</font>';
                }
                if (name == "finance_amount") {
                    return '<font color="red">' + Leaf.formatNumber(sum4, 2) + '</font>';
                }
                if (name == "lease_charge") {
                    return '<font color="red">' + Leaf.formatNumber(sum5, 2) + '</font>';
                }
                if (name == "pmt") {
                    return '<font color="red">' + Leaf.formatNumber(sum6, 2) + '</font>';
                }
                if (name == "residual_value") {
                    return '<font color="red">' + Leaf.formatNumber(sum7, 2) + '</font>';
                }
                if (name == "deposit") {
                    return '<font color="red">' + Leaf.formatNumber(sum8, 2) + '</font>';
                }
                if (name == "hd_user_col_n03") {
                    return '<font color="red">' + Leaf.formatNumber(sum9, 2) + '</font>';
                }
                if (name == "hd_user_col_n12") {
                    return '<font color="red">' + Leaf.formatNumber(sum10, 2) + '</font>';
                }
                if (name == "other_fee") {
                    return '<font color="red">' + Leaf.formatNumber(sum11, 2) + '</font>';
                }
                if (name == "other_fee3") {
                    return '<font color="red">' + Leaf.formatNumber(sum12, 2) + '</font>';
                }
                if (name == "insurance_fee") {
                    return '<font color="red">' + Leaf.formatNumber(sum13, 2) + '</font>';
                }
                if (name == "hd_user_col_n05") {
                    return '<font color="red">' + Leaf.formatNumber(sum14, 2) + '</font>';
                }
                  if (name == "car_invoice_total_amount") {
                    return '<font color="red">' + Leaf.formatNumber(sum15, 2) + '</font>';
                }
                 if (name == "fee_invoice_total_amount") {
                    return '<font color="red">' + Leaf.formatNumber(sum16, 2) + '</font>';
                }
                 if (name == "insurance_invoice_total_amount") {
                    return '<font color="red">' + Leaf.formatNumber(sum17, 2) + '</font>';
                }
                 if (name == "hd_user_col_n02") {
                    return '<font color="red">' + Leaf.formatNumber(sum18, 2) + '</font>';
                }
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=PROJECT&amp;function_code=CON390"/>
        <a:dataSets>
            <a:dataSet id="con500_contract_status_ds" lookupCode="YONDA_DOC_STATUS"/>
            <a:dataSet id="con_contract_status_ds" lookupCode="CON500_CONTRACT_STATUS"/>
            <a:dataSet id="prj500n_district_areas_ds" lookupCode="PRJ500N_DISTRICT_AREAS"/>
            <a:dataSet id="prj500n_project_status_ds" lookupCode="PRJ501_PRJ_STATUS"/>
            <a:dataSet id="bp_class_ds" lookupCode="HLS211_BP_CLASS"/>
            <a:dataSet id="lease_channel_ds" loadData="true" model="basic.hls_lease_channel_for_lov"/>
            <a:dataSet id="document_cat_ds">
                <a:datas>
                    <a:record name="租赁申请" value="PROJECT"/>
                    <a:record name="合同" value="CONTRACT"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="business_type_ds" loadData="true" model="cont.CON390.hls_business_type"/>
            <a:dataSet id="query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="document_category"/>
                    <a:field name="document_status"/>
                    <a:field name="document_status_des" displayField="code_value_name" options="con_contract_status_ds" readOnly="true" returnField="document_status" valueField="code_value"/>
                    <a:field name="document_category_des" displayField="name" options="document_cat_ds" returnField="document_category" valueField="value"/>
                    <a:field name="contract_status"/>
                    <a:field name="contract_status_des" displayField="code_value_name" options="con500_contract_status_ds" returnField="contract_status" valueField="code_value"/>
                    <a:field name="district"/>
                    <a:field name="district_des" displayField="code_value_name" options="prj500n_district_areas_ds" returnField="district" valueField="code_value"/>
                    <a:field name="lease_channel"/>
                    <a:field name="lease_channel_des" displayField="description" options="lease_channel_ds" returnField="lease_channel" valueField="lease_channel"/>
                    <a:field name="company_id"/>
                    <a:field name="company_short_name" lovGridHeight="350" lovHeight="500" lovService="fnd.fnd_companies_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="company_id" to="company_id"/>
                            <a:map from="company_short_name" to="company_short_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="unit_id"/>
                    <a:field name="unit_id_desc" lovGridHeight="350" lovHeight="500" lovService="basic.exp_org_unit_v?org_unit_type=4S&amp;enabled_flag=Y" lovWidth="500" title="供应商信息">
                        <a:mapping>
                            <a:map from="unit_id" to="unit_id"/>
                            <a:map from="unit_name" to="unit_id_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="organization_id"/>
                    <a:field name="organization_name" lovGridHeight="350" lovHeight="500" lovService="hls.HLS052.hls_car_organization" lovWidth="500" title="品牌事业部">
                        <a:mapping>
                            <a:map from="organization_name" to="organization_name"/>
                            <a:map from="organization_id" to="organization_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="business_type"/>
                    <a:field name="business_type_des" displayField="description" options="business_type_ds" returnField="business_type" valueField="business_type"/>
                    <a:field name="price_list"/>
                    <a:field name="price_list_des" lovGridHeight="350" lovHeight="500" lovService="hls.HLS052.hls_price_list" lovWidth="500" title="产品">
                        <a:mapping>
                            <a:map from="description" to="price_list_des"/>
                            <a:map from="price_list" to="price_list"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="employee_id_des" lovGridHeight="350" lovHeight="500" lovService="cont.CON543.exp_employees_lov" lovWidth="500" title="客户经理">
                        <a:mapping>
                            <a:map from="employee_id" to="employee_id"/>
                            <a:map from="name" to="employee_id_des"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="employee_id"/>
                    <a:field name="bp_class"/>
                    <a:field name="bp_class_des" displayField="code_value_name" options="bp_class_ds" returnField="bp_class" valueField="code_value"/>
                    <a:field name="submit_start_date"/>
                    <a:field name="submit_end_date"/>
                    <a:field name="create_date_fmt_start"/>
                    <a:field name="create_date_fmt_end"/>
                    <a:field name="inception_of_lease_start"/>
                    <a:field name="inception_of_lease_end"/>
                    <a:field name="lease_term"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="on_update_document_category"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="con_contract_info_ds" autoPageSize="true" autoQuery="true" model="cont.CON390.con_contract_all_v" queryDataSet="query_ds">
                <!--  <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events> --><![CDATA[
                
                
               
            ]]></a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton id="hls_standard_his_id" click="con_contract_info_query" text="查询"/>
            </a:screenTopToolbar>
            <a:form column="5" labelWidth="120" marginWidth="80" title="查询条件">
                <a:textField name="contract_number" bindTarget="query_ds" prompt="单据编号"/>
                <a:comboBox name="document_category_des" bindTarget="query_ds" prompt="单据类别"/>
                <a:comboBox name="document_status_des" bindTarget="query_ds" prompt="单据状态"/>
                <a:comboBox name="contract_status_des" bindTarget="query_ds" prompt="业务状态"/>
                <a:comboBox name="lease_channel_des" bindTarget="query_ds" prompt="业务分类"/>
                <a:comboBox name="district_des" bindTarget="query_ds" prompt="区域"/>
                <a:lov name="company_short_name" bindTarget="query_ds" prompt="公司"/>
                <a:lov name="unit_id_desc" bindTarget="query_ds" prompt="供应商"/>
                <a:lov name="organization_name" bindTarget="query_ds" prompt="品牌事业部"/>
                <a:comboBox name="business_type_des" bindTarget="query_ds" prompt="租赁模式"/>
                <a:lov name="price_list_des" bindTarget="query_ds" prompt="产品"/>
                <a:lov name="employee_id_des" bindTarget="query_ds" prompt="区域融资经理"/>
                <a:comboBox name="bp_class_des" bindTarget="query_ds" prompt="客户分类"/>
                <a:numberField name="lease_term" bindTarget="query_ds" prompt="租赁期限(年)" renderer="return_number"/>
                <a:datePicker name="submit_start_date" bindTarget="query_ds" prompt="申请时间从"/>
                <a:datePicker name="submit_end_date" bindTarget="query_ds" prompt="申请时间到"/>
                <a:datePicker name="create_date_fmt_start" bindTarget="query_ds" prompt="信审时间从"/>
                <a:datePicker name="create_date_fmt_end" bindTarget="query_ds" prompt="信审时间到"/>
                <a:datePicker name="inception_of_lease_start" bindTarget="query_ds" prompt="起租时间从"/>
                <a:datePicker name="inception_of_lease_end" bindTarget="query_ds" prompt="起租时间到"/>
            </a:form>
            <a:grid bindTarget="con_contract_info_ds" marginHeight="230" marginWidth="80" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="price_list_des" footerRenderer="summaryRenderer" lock="true" prompt="产品" width="150"/>
                    <a:column name="contract_status_des" lock="true" prompt="业务状态" width="120"/>
                    <a:column name="document_status_des" lock="true" prompt="单据状态" width="80"/>
                    <!--  <a:column name="document_category_name" lock="true" prompt="单据类型" width="100" /> -->
                    <a:column name="contract_number" lock="true" prompt="单据编号" width="130"/>
                    <a:column name="lease_channel_des" prompt="业务分类" width="80"/>
                    <a:column name="district_des" prompt="区域" width="130"/>
                    <a:column name="company_short_name" prompt="公司" width="150"/>
                    <a:column name="spv_company" prompt="出租方" width="150"/>
                    <a:column name="invoice_agent_name" prompt="开票经销商" width="180"/>
                    <a:column name="unit_id_des" prompt="供应商"/>
                    <a:column name="organization_name" prompt="所属事业部"/>
                    <a:column name="business_type_des" prompt="租赁模式"/>
                    <a:column name="bp_class_des" align="center" prompt="客户分类"/>
                    <a:column name="plate_resource_des" prompt="牌照来源"/>
                    <a:column name="brand_id_des" prompt="品牌"/>
                    <a:column name="series_id_des" prompt="车系"/>
                    <a:column name="model_id_des" prompt="车型" width="150"/>
                    <a:column name="tenant_name" prompt="承租人" width="120"/>
                    <a:column name="bp_property_des" prompt="单位性质" width="150"/>
                    <a:column name="car_user_name" prompt="实际用车人" width="150"/>
                    <a:column name="tenant_sec_name" prompt="联合承租人" width="120"/>
                    <a:column name="guarantor_name" prompt="担保人"/>
                    <a:column name="employee_id_des" prompt="区域融资经理"/>
                    <a:column name="owner_user_id_des" prompt="金融经理"/>
                    <a:column name="sale_consultant" prompt="4S店销售人员"/>
                    <a:column name="submit_date" prompt="申请日期" renderer="Leaf.formatDate"/>
                    <a:column name="create_date_fmt" prompt="信审日期" renderer="Leaf.formatDate"/>
                    <a:column name="action_type_desc" prompt="信审结果"/>
                    <a:column name="return_reason" prompt="信审意见" width="400"/>
                    <a:column name="signing_date" prompt="签约日期" renderer="Leaf.formatDate"/>
                    <a:column name="inception_of_lease" prompt="起租日" renderer="Leaf.formatDate"/>
                    <a:column name="lease_end_date" prompt="合同到期日" renderer="Leaf.formatDate"/>
                    <a:column name="item_frame_number" prompt="车架号"/>
                    <a:column name="hd_user_col_n06_v" align="right" prompt="静态收益"/>
                    <a:column name="irr_v" align="right" prompt="IRR"/>
                    <a:column name="finance_income" align="right" footerRenderer="summaryRenderer" prompt="项目粗利" renderer="Leaf.formatMoney"/>
                    <a:column name="lease_item_amount" align="right" footerRenderer="summaryRenderer" prompt="融资总额" renderer="Leaf.formatMoney"/>
                    <a:column name="down_payment" align="right" footerRenderer="summaryRenderer" prompt="首付" renderer="Leaf.formatMoney"/>
                    <a:column name="down_payment_ratio_v" align="right" prompt="首付比例"/>
                    <a:column name="finance_amount" align="right" footerRenderer="summaryRenderer" prompt="租赁概算本金" renderer="Leaf.formatMoney"/>
                    <a:column name="lease_term" align="center" prompt="租赁期限"/>
                    <a:column name="lease_charge" align="right" footerRenderer="summaryRenderer" prompt="手续费" renderer="Leaf.formatMoney"/>
                    <a:column name="pmt" align="right" footerRenderer="summaryRenderer" prompt="每期租金" renderer="Leaf.formatMoney"/>
                    <a:column name="annual_pay_times_des" align="center" prompt="租金周期"/>
                    <a:column name="pay_type" align="center" prompt="支付方式"/>
                    <a:column name="residual_value" align="right" footerRenderer="summaryRenderer" prompt="留购价" renderer="Leaf.formatMoney"/>
                    <a:column name="deposit" align="right" footerRenderer="summaryRenderer" prompt="保证金" renderer="Leaf.formatMoney"/>
                    <a:column name="deposit_ratio_v" align="right" prompt="保证金比例"/>
                    <a:column name="deposit_deduction_des" prompt="保证金处理方式"/>
                    <a:column name="hd_user_col_n03" align="right" footerRenderer="summaryRenderer" prompt="资金敞口" renderer="Leaf.formatMoney"/>
                    <a:column name="hd_user_col_n12" align="right" footerRenderer="summaryRenderer" prompt="厂方指导价" renderer="Leaf.formatMoney"/>
                    <a:column name="other_fee" align="right" footerRenderer="summaryRenderer" prompt="车价" renderer="Leaf.formatMoney"/>
                    <a:column name="other_fee3" align="right" footerRenderer="summaryRenderer" prompt="购置税" renderer="Leaf.formatMoney"/>
                    <a:column name="insurance_fee" align="right" footerRenderer="summaryRenderer" prompt="保险费" renderer="Leaf.formatMoney"/>
                    <a:column name="hd_user_col_n05" align="right" footerRenderer="summaryRenderer" prompt="牌照费" renderer="Leaf.formatMoney"/>
                    <a:column name="full_write_off_date" prompt="首付到账日" renderer="Leaf.formatDate"/>
                    <a:column name="car_invoice_number" prompt="车价发票号"/>
                    <a:column name="car_invoice_date" prompt="车价开票日期" renderer="Leaf.formatDate"/>
                    <a:column name="car_invoice_total_amount" align="right" footerRenderer="summaryRenderer" prompt="车价金额" renderer="Leaf.formatMoney"/>
                    <a:column name="car_accounting_date" prompt="递交财务时间" renderer="Leaf.formatDate"/>
                    <a:column name="car_payment_completed_date" prompt="付款日期" renderer="Leaf.formatDate"/>
                    <a:column name="fee_invoice_number" prompt="购置税发票号"/>
                    <a:column name="fee_invoice_total_amount" align="right" footerRenderer="summaryRenderer" prompt="购置税金额" renderer="Leaf.formatMoney"/>
                    <a:column name="fee_accounting_date" prompt="递交财务时间" renderer="Leaf.formatDate"/>
                    <a:column name="fee_payment_completed_date" prompt="付款日期" renderer="Leaf.formatDate"/>
                    <a:column name="insurance_invoice_number" prompt="保险发票号"/>
                    <a:column name="insurance_invoice_total_amount" align="right" footerRenderer="summaryRenderer" prompt="保险金额" renderer="Leaf.formatMoney"/>
                    <a:column name="insurance_accounting_date" prompt="递交财务时间" renderer="Leaf.formatDate"/>
                    <a:column name="insurance_payment_date" prompt="付款日期" renderer="Leaf.formatDate"/>
                    <a:column name="hd_user_col_n02" footerRenderer="summaryRenderer" prompt="厂商贴息" renderer="Leaf.formatMoney"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
