1398 lines
52 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@page import="jbo.prd.BUSINESS_TYPE"%>
<%@page import="com.tenwa.reckon.util.TbBeanTools"%>
<%@page import="com.tenwa.reckon.bean.TabCalBean"%>
<%@page import="com.amarsoft.awe.control.model.Parameter"%>
<%@page import="com.amarsoft.app.base.util.DateHelper"%>
<%@page import="com.tenwa.util.SerialNumberUtil"%>
<%@page import="com.tenwa.reckon.product.ProductCondition"%>
<%@page import="com.amarsoft.app.util.ProductParamUtil"%>
<%@ page import="com.amarsoft.app.lc.workflow.action.GetFlowAction" %>
<%@ page import="java.util.Vector" %>
<%@ page import="com.amarsoft.awe.dw.ui.validator.ValidateRule" %>
<%@ page import="com.tenwa.reckon.product.ASObjectWindowCalc" %>
<%@page import="com.amarsoft.are.jbo.BizObject"%>
<%@page import="com.amarsoft.are.jbo.JBOException"%>
<%@page import="com.amarsoft.are.jbo.JBOFactory"%>
<%@page import="jbo.com.tenwa.lease.comm.LB_EQUIPMENT_CAR_TEMP"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%>
<%
/*获取参数*/
String flowunid = CurPage.getParameter("FlowUnid");
String plannumber=CurPage.getParameter("plannumber");
String productId=CurPage.getParameter("ProductId");
String ishistory=CurPage.getParameter("IsHistory");
String nodeNo=CurPage.getParameter("NodeNo");
String RightType= CurPage.getParameter("RightType");
String calType = CurPage.getParameter("calType");
String carAttributes = CurPage.getParameter("carAttributes");
String projectId=CurPage.getParameter("ProjectId");
//判断是否为汽车业务
boolean isCarProduct = "004".equals(productId) ? false : true;
/*获取参数*/
/*根据参数判断 是否去数据库查询*/
BizObject flow=GetFlowAction.getFlowBussinessObject(flowunid);
if(productId==null){
productId=flow.getAttribute("productId").getString();
}
if(calType == null){
calType = "proj_process";
}
TabCalBean tcb=TbBeanTools.getTabInfo(calType);
String planCName=tcb.getPlanCName();
//方案编号
if(plannumber==null){
if("pay_process".equals(calType)||"onHire_process".equals(calType)){
BizObject condtion=JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP","flowunid=:flowunid and PAYMENT_NUMBER is not null and length(PAYMENT_NUMBER)>0 ").setParameter("flowunid", flowunid).getSingleResult(false);
if(condtion!=null){
plannumber=condtion.getAttribute(planCName).getString();
}
}else{
//安鹏只有多方案没有单方案。产品配置中方案信息prd0314停用
// String planType=ProductParamUtil.getProductParameterValue(productId, "PRD0314", "planinformation");
// if("SinglePlan".equals(planType)){
BizObject condtion=JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP","flowunid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false);
if(condtion!=null){
plannumber=condtion.getAttribute(planCName).getString();
}
// }
}
}
//新增数据 自动生成方案编号
if(plannumber==null){
String sSerialType="";
JBOTransaction tx=JBOFactory.createJBOTransaction();
if("proj_process".equals(calType)){
BizObject proj=JBOFactory.createBizObjectQuery("jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP","flowunid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false);
sSerialType=(proj==null)?"":proj.getAttribute("PROJECT_NO").getString();
}else{
BizObject contract=JBOFactory.createBizObjectQuery("jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP","flowunid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false);
sSerialType=(contract==null)?"":contract.getAttribute("CONTRACT_NO").getString();
}
plannumber=SerialNumberUtil.getPlannumber(sSerialType,calType,tx);
tx.commit();
}
/*根据参数判断 是否去数据库查询*/
String sTempletNo = "LoanSimulationBasicInfo";//--模板号--
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
/*设置字段事件*/
doTemp.setHtmlEvent("SETTLE_METHOD", "onchange", "changeSettleMethod");//租金计算方式
doTemp.setHtmlEvent("RENT_OR_RATE", "onchange", "rentOrRateChange");//租金推算方法
doTemp.setHtmlEvent("INCOME_NUMBER_YEAR", "onchange", "changeIncomeNumber");//还款间隔
doTemp.setHtmlEvent("INCOME_INTERVAL_MONTH", "onchange", "changeIntervalMonth");//还款间隔(月)
doTemp.setHtmlEvent("INCOME_NUMBER", "onchange", "changeNumber");//还款次数
doTemp.setHtmlEvent("PERIOD_TYPE", "onchange", "changePeriod");//期初/期末
doTemp.setHtmlEvent("GRACE", "onchange", "changeGrace");//宽限期RATTermID
doTemp.setHtmlEvent("RATE_FLOAT_TYPE", "onchange", "changeRateFloat");//利率计算方式
doTemp.setHtmlEvent("BASE_RATE", "onchange", "changeBaseRate");//基准利率
doTemp.setHtmlEvent("RATE_FLOAT_AMT", "onchange", "changeRateFloatAmt");//利率调整值
doTemp.setHtmlEvent("CAUTION_MONEY", "onchange", "cautionMoney");//保证金
doTemp.setHtmlEvent("CAUTION_MONEY_METHOD", "onchange", "cautionMoney");//保证金
doTemp.setHtmlEvent("CAUTION_DEDUCTION_MONEY", "onchange", "cautionDeductionMoney");//保证金抵扣金额
doTemp.setHtmlEvent("LEASE_AMT_DATE", "onchange", "changeLeaseAmtDate");//投放日
doTemp.setHtmlEvent("START_DATE", "onchange", "changeStartDate");//起租日
doTemp.setHtmlEvent("DEFAULTDUEDAY", "onchange", "changeLeaseAmtDate");
doTemp.setHtmlEvent("FIRST_PLAN_DATE", "onchange", "changeFistPlanDate");//第一期计划日期
doTemp.setHtmlEvent("CORPUS_RATIO", "onchange", "changeCorpusRatio");//期限内本金比例
doTemp.setHtmlEvent("EQUIP_AMT", "onchange", "changgeCompare");//车价
/*设置字段事件*/
/*设置模板属性*/
Vector<ValidateRule> vali=new Vector<ValidateRule>();
//费用规则
ProductCondition pc=new ProductCondition();
pc.getProductFundRules(doTemp, productId);
String calcRules=pc.getProductRules(doTemp, productId,vali);
//获取产品名称
BizObject bo = JBOFactory.createBizObjectQuery(BUSINESS_TYPE.CLASS_NAME,"typeno=:productID")
.setParameter("productID", productId).getSingleResult(false);
String productName = (bo==null)?"":bo.getAttribute("typename").getString();
//非车辆产品,融资额可编辑
String productType = Sqlca.getString(new SqlObject("select attribute2 from business_type where typeno='"+productId+"'"));
if("car_product".equals(productType)){
doTemp.setReadOnly("CLEAN_LEASE_MONEY", true);
}else if("business_product".equals(productType)){
// doTemp.setVisible("CORPUS_RATIO", true);
// doTemp.setVisible("CORPUS", true);
// doTemp.setRequired("CORPUS_RATIO", true);
}
if("quoted_price".equals(calType)){//客户报价 流程号存的是客户主键
doTemp.setDefaultValue("cust_id", flowunid);
}
doTemp.setColumnAttribute(planCName,"isipdate","1");
doTemp.setJboClass(tcb.getCondition_tb());
doTemp.setDefaultValue(planCName, plannumber);
doTemp.setDefaultValue("flowunid", flowunid);
doTemp.setDefaultValue("PRODUCT_NAME", productName);
doTemp.appendJboWhere(" and "+planCName+"='"+plannumber+"'");
/* if(null!=ishistory&&ishistory.equals("true")){ --这个是插入到历史表中的每一步数据。
doTemp.setDataQueryClass("com.tenwa.lease.flow.flowarchive.calcarchive.CalcCondtionInfoArachiveShow");//如果是历史则新显示历史数据
} */
/*设置模板属性*/
/*设置页面属性*/
CurPage.getCurComp().setAttribute("RightType", null);
Parameter p=new Parameter("plannumber",plannumber);
Vector<Parameter> v=CurPage.parameterList;
v.add(p);
/*设置页面属性*/
boolean flag=CurUser.hasRole("401");
if(CurUser.hasRole("401")){
doTemp.setVisible("CAUTION_MONEY_METHOD",false);
doTemp.setVisible("DISCOUNT", false);
// doTemp.setColumnAttribute("DISCOUNT","colvisible","0");
}
if(CurUser.hasRole("800R00000013")||CurUser.hasRole("800R00000014")||CurUser.hasRole("800R00000015")){
doTemp.setVisible("YEAR_RATE", true);
doTemp.setVisible("RENT_RATIO",true);
}
ASObjectWindowCalc dwTemp = new ASObjectWindowCalc(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
if((null!=RightType&&RightType.equals("ReadOnly"))||(null!=ishistory&&ishistory.equals("true"))){
dwTemp.ReadOnly = "1";//只读模式
isShowButton=false;
}else{
isShowButton=true;
}
dwTemp.setVali(vali);
dwTemp.setAttr("inputWidth","120");
dwTemp.setAttr("spanWidth","107");
dwTemp.setAttr("showRatio", true);
dwTemp.genHTMLObjectWindow(flowunid);
CurPage.getCurComp().setAttribute("RightType", RightType);
String compClientID = request.getParameter("CompClientID");
dwTemp.replaceColumn("condition_plan", "<iframe type='iframe' id='frame_list' name=\"frame_list\" width=\"100%\" height=\"600px\" frameborder=\"0\" src=\""+sWebRootPath+"/Accounting/LoanSimulation/condition_plan.jsp?CompClientID="+compClientID+"&flowunid="+flowunid+"&plannumber="+plannumber+"&planCName="+planCName+"&IsHistory="+ishistory+"&NodeNo="+nodeNo+"&RightType="+RightType+"&ProductId="+productId+"&calType="+calType+"\"></iframe>", CurPage.getObjectWindowOutput());
//dwTemp.replaceColumn("even_subsection", "<iframe type='iframe' id='frame_even_break' name=\"frame_even_subsection\" width=\"100%\" height=\"300px\" frameborder=\"0\" src=\""+sWebRootPath+"/Accounting/LoanSimulation/subsection/LCCalcSubsectionList.jsp?CompClientID="+compClientID+"&flowunid="+flowunid+"&plannumber="+plannumber+"&planCName="+planCName+"&IsHistory="+ishistory+"&NodeNo="+nodeNo+"&RightType="+RightType+"&calType="+calType+"\"></iframe>", CurPage.getObjectWindowOutput());
//dwTemp.replaceColumn("knowing_config", "<iframe type='iframe' id='frame_list_knowing' name=\"frame_list_knowing\" width=\"100%\" height=\"400px\" frameborder=\"0\" src=\""+sWebRootPath+"/Accounting/LoanSimulation/KnowConfigList.jsp?CompClientID="+compClientID+"&flowunid="+flowunid+"&plannumber="+plannumber+"&planCName="+planCName+"&IsHistory="+ishistory+"NodeNo="+nodeNo+"&RightType="+RightType+"&calType="+calType+"\"></iframe>", CurPage.getObjectWindowOutput());
String businessDate = DateHelper.getBusinessDate();
//获取对应车辆指导价
BizObject bo1 = JBOFactory.createBizObjectQuery(LB_EQUIPMENT_CAR_TEMP.CLASS_NAME,"PROJECT_ID=:projectId")
.setParameter("projectId",projectId).getSingleResult(false);
String nowTotal = (bo1==null)?"":bo1.getAttribute("NOW_TOTAL").getString();
String sButtons[][] = {
//{"true","All","Button","重置","重置","reloadSelf()","","","",""},
{"true","All","Button","租金测算","租金测算","saveRecord()","","","","btn_icon_save"},
// {((isCarProduct) && ("proj_process".equals(calType)||"cont_process".equals(calType)))?"true":"false","","Button","引入客户报价","引入客户报价","importCustomerQuot()","","","","btn_icon_edit"}
};
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
var productName="<%=productName%>";
setItemValue(0, 0, "PRODUCT_NAME", productName);
var calcRules=eval("(<%=calcRules%>)");
var rentOrRateOption;
var incomeNumberYear;
var adjustType;
var incomeNumber;
var count = 0;
$(function(){
changgeCompare();
//document.getElementById('div_my0').innerHTML = '<div style="width:1160px;overflow: scroll;">'+document.getElementById('div_my0').innerHTML+'</div>';
if("ReadOnly"!="<%=RightType%>"){
CalcControl.InitStartDate();
rentOrRateOption=$("#RENT_OR_RATE").children();
incomeNumberYear=$("#INCOME_NUMBER_YEAR").children();
adjustType=$("#ADJUST_TYPE").children();
incomeNumber=$("#INCOME_NUMBER").children();
var fundRules=calcRules["fund"];
for(var key in fundRules){
$("#"+key).bind("change",function(){
getRatioByMoney(this);
});
if($("#"+key+"_FINA").length > 0){
$("#"+key+"_FINA").bind("change",function(){
getRatioByMoney(this);
});
}
}
$("#EQUIP_AMT").bind("change", function() {
getRatioByMoney(this);
});
CalcControl.InitLsaseTerm();
//CalcControl.PeriodTypeView();
//CalcControl.SettleMethodView();
//changeSettleMethod2();
//changeRateType();
//CalcControl.RentOrRateView();
var inerNumber = $("#INCOME_NUMBER").val();
$("#INCOME_NUMBER").empty();
var inNumber=calcRules['incomeNumber']['INCOME_NUMBER'];
inNumber=inNumber.split(",");
var inco={};
for(var i=0;i<inNumber.length;i++){
inco[inNumber[i]]="1";
}
$(incomeNumber).each(function(){
var value=$(this).attr("value");
if(inco[value]==1){
$("#INCOME_NUMBER").append(this);
}
});
$("#INCOME_NUMBER").val(inerNumber);
count++;
}else{
changeSettleMethod3();
}
getRatioByMoney(getObj(0, "EQUIP_AMT"));
});
function financingCar(){
var financingCar = getItemValue(0, 0, "EQUIP_AMT")-getItemValue(0, 0, "FIRST_PAYMENT");
setItemValue(0, 0, "financing_car", financingCar);
}
function changgeCompare(){
var nowTotal=Number("<%=nowTotal%>");
var equipAmt=Number(getItemValue(0, 0, "EQUIP_AMT"));
var flag="<%=flag%>";
if(equipAmt>nowTotal){
$("#EQUIP_AMT").css("color","red");
}else{
$("#EQUIP_AMT").css("color","none");
}
financingCar();
}
function isFina(){
var fundRules=calcRules["fund"];
for(var key in fundRules){
var flag = getItemValue(0,0,key+"_FINA");
if(flag!="finatype02"){
setItemValue(0,0,key+"_FIRST_PAYMENT_RATIO","");
setItemValue(0,0,key+"_FINANCE","");
}
}
}
function importCustomerQuot(){
AsDialog.OpenSelector("SelectCustomerQuot","flowunid,<%=flowunid%>,productid,<%=productId%>","dialogWidth=800px;dialogHeight=500px",
function(sReturn){
if(!sReturn||sReturn=="_CANCEL_"||sReturn==""||sReturn=="_NONE_")
{
//alert(getHtmlMessage('1'));//请选择一条信息!
return;
}
sReturn = sReturn.split("@");
var quotid=sReturn[0];
var customerid=sReturn[1];
var param="flowunid=<%=flowunid%>,quotid="+quotid+",planCName=<%=planCName%>,planCValue=<%=plannumber%>";
AsControl.RunJavaMethodTrans("com.tenwa.reckon.action.CalcAction","copyCustomerQuotToTemp",param);
var param2="FlowUnid=<%=flowunid%>&calType=<%=calType%>&plannumber=<%=plannumber%>";
AsControl.OpenView("/Accounting/LoanSimulation/LoanBasicInfo.jsp",param2, "_self");
},"请选择客户报价",'');
}
var CalcControl={};
CalcControl.IncomeNumberView=function(){
var incomeNumber=getItemValue(0,0,"INCOME_NUMBER_YEAR");
if(incomeNumber=="income_n"){
setEnable("INCOME_INTERVAL_MONTH");
}else{
setDisable("INCOME_INTERVAL_MONTH");
}
}
CalcControl.IncomeNumberInit=function(){
var settleMethod = getItemValue(0,0,"SETTLE_METHOD");
var incomeNumber = getItemValue(0,0,"INCOME_NUMBER_YEAR");
//按月付息一次还本和按月付息按季还本目前只允许等额本金和均息法选择
if(("one_1" == incomeNumber || "three_1" == incomeNumber) && !("even_corpus" == settleMethod || "even_interest" == settleMethod)){
setItemValue(0,0,"INCOME_NUMBER_YEAR","income_1");
incomeNumber = "income_1";
alert("只允许等额本金和均息法选择");
}
if(incomeNumber=="income_n" || incomeNumber=="irregular"){
setItemValue(0,0,"INCOME_INTERVAL_MONTH",1);
}else{
if(incomeNumber.length>0){
var month=incomeNumber.split("_")[1];
setItemValue(0,0,"INCOME_INTERVAL_MONTH",month);
}else{
setItemValue(0,0,"INCOME_INTERVAL_MONTH",1);
}
}
CalcControl.InitLsaseTerm();
var leaseAmtDate = getItemValue(0,getRow(),"LEASE_AMT_DATE");
if(leaseAmtDate){
CalcControl.InitStartDate();
}
}
CalcControl.InitLsaseTerm=function(){
var INCOME_NUMBER_YEAR = getItemValue(0,0,"INCOME_NUMBER_YEAR");// 还款间隔
var INCOME_INTERVAL_MONTH = getItemValue(0,getRow(),"INCOME_INTERVAL_MONTH");//还款间隔(月)
var INCOME_NUMBER = getItemValue(0,getRow(),"INCOME_NUMBER");//还款次数
if("three_1" == INCOME_NUMBER_YEAR && INCOME_NUMBER % 3 != 0){
alert("按月付息按季还本还款次数必须能被3整除");
setItemValue(0,0,"INCOME_NUMBER","");
return;
}
var grace = getItemValue(0,getRow(),"GRACE");
setItemValue(0,getRow(),"LEASE_TERM",INCOME_INTERVAL_MONTH* (Number(INCOME_NUMBER) + Number(grace)));
}
CalcControl.InitStartDate=function(){
var leaseAmtDate=getItemValue(0,getRow(),"LEASE_AMT_DATE");//投放日
//var startDate=getItemValue(0,getRow(),"START_DATE");//起租日
var startDate=leaseAmtDate;//起租日
setItemValue(0, 0, "START_DATE", startDate);
var periodType=getItemValue(0,getRow(),"PERIOD_TYPE");//期初期末
var incomenumberyear=Number(getItemValue(0,getRow(),"INCOME_NUMBER_YEAR").split("_")[1]);//还款间隔
var rentDay=getItemValue(0,getRow(0),"DEFAULTDUEDAY");//还款日
var method = calcRules["method"];
var methodName = "";
for(var i in method) {
methodName = i;
break;
}
//是按起租日计算的情况,直接读取当前日期
if(calcRules["method"][methodName]["DefaultDueDay"] != "02") {
rentDay = calcRules["method"][methodName]["ActualDay"];
}
//默认起租日为投放日
if("period_type_1" == periodType){//期初 第一期还款日为投放日
setItemValue(0,0,"FIRST_PLAN_DATE",leaseAmtDate);
if(Number(rentDay)<10){
leaseAmtDate=leaseAmtDate.substring(0,8)+"0"+rentDay;
}else{
leaseAmtDate=leaseAmtDate.substring(0,8)+rentDay;
}
setItemValue(0,0,"SECOND_PLAN_DATE",dateAdd('m',incomenumberyear,new Date(leaseAmtDate)).format('yyyy\/MM\/dd'));
}else{
var firstPlanDate = dateAdd('m',incomenumberyear,new Date(startDate)).format('yyyy\/MM\/dd');
if(Number(rentDay)<10){
firstPlanDate=firstPlanDate.substring(0,8)+"0"+rentDay;
}else{
firstPlanDate=firstPlanDate.substring(0,8)+rentDay;
}
setItemValue(0,0,"FIRST_PLAN_DATE",firstPlanDate);
setItemValue(0,0,"SECOND_PLAN_DATE",dateAdd('m',incomenumberyear,new Date(firstPlanDate)).format('yyyy\/MM\/dd'));
}
}
CalcControl.InitFistPlanDate=function(){
var incomenumberyear = Number(getItemValue(0,getRow(),"INCOME_INTERVAL_MONTH"));//获取还款间隔 月
var periodType = getItemValue(0,getRow(),"PERIOD_TYPE");//获取 期初/期末
var startDate=getItemValue(0,getRow(),"START_DATE");//起租日
if(!startDate)return;
if("period_type_1" == periodType){//期初 第一期还款日为投放日
setItemValue(0,0,"FIRST_PLAN_DATE",startDate);
}else{
var firstPlanDate = dateAdd('m',incomenumberyear,new Date(startDate)).format('yyyy\/MM\/dd');
setItemValue(0,0,"FIRST_PLAN_DATE",firstPlanDate);
}
CalcControl.InitSecondPlanDate();
}
CalcControl.InitSecondPlanDate=function(){
var incomenumberyear = Number(getItemValue(0,getRow(),"INCOME_INTERVAL_MONTH"));//获取还款间隔 月
var firstPlanDate=getItemValue(0,0,"FIRST_PLAN_DATE");
if(!firstPlanDate)return;
setItemValue(0,0,"SECOND_PLAN_DATE",dateAdd('m',incomenumberyear,new Date(firstPlanDate)).format('yyyy\/MM\/dd'));
}
CalcControl.PeriodTypeView=function(){
var periodType = getItemValue(0,getRow(),"PERIOD_TYPE");
if(periodType == 'period_type_1'){
setDisable("GRACE");
}else{
setEnable("GRACE");
}
}
CalcControl.PeriodTypeInit=function(){
var periodType = getItemValue(0,getRow(),"PERIOD_TYPE");
if(periodType == 'period_type_1'){
setItemValue(0,0,"GRACE","0");
}
CalcControl.InitLsaseTerm();
var leaseAmtDate = getItemValue(0,getRow(),"LEASE_AMT_DATE");
if(leaseAmtDate){
CalcControl.InitStartDate();
}
}
CalcControl.RateFloatTypeView=function(){
var rateway = getItemValue(0,getRow(),"RATE_FLOAT_TYPE");//利率计算方式
var rateOrRate=getItemValue(0,0,"RENT_OR_RATE");//租金推算方式
if(rateway=="fixed"){
setDisable('BASE_RATE');
setDisable('RATE_FLOAT_AMT');
setDisable('RENT_VALUE');
setEnable('YEAR_RATE');
}else if(rateway=="base"){
setEnable('BASE_RATE');
setDisable('RATE_FLOAT_AMT');
setDisable('RENT_VALUE');
setDisable('YEAR_RATE');
}else{
setEnable('BASE_RATE');
setEnable('RATE_FLOAT_AMT');
setDisable('RENT_VALUE');
setDisable('YEAR_RATE');
}
}
CalcControl.RateFloatTypeInit=function(){
var rateway = getItemValue(0,getRow(),"RATE_FLOAT_TYPE");//利率计算方式
var baserate = getItemValue(0,getRow(),"BASE_RATE");//基准利率
var ratefloatamt = getItemValue(0,getRow(),"RATE_FLOAT_AMT");//利率调整值
var rate="";
if(rateway=="add"){
rate=Number(baserate)+Number(ratefloatamt);
}else if(rateway=="proportion"){
rate=Number(baserate)*(1+Number(ratefloatamt));
}else if(rateway=="base"){
rate=baserate;
}else{
setItemValue(0,0,"BASE_RATE","0");
setItemValue(0,0,"RATE_FLOAT_AMT","0");
}
if(rateway != 'fixed'){
setItemValue(0,0,"YEAR_RATE",rate);
}
}
CalcControl.SettleMethodView=function(){
var method=getItemValue(0,getRow(),"SETTLE_METHOD");
//按计算方式 显示按钮 和分段测算录入页面
document.all("A_Group_even_subsection").style.display="none";
if("true"=="<%=isShowButton%>"){
var button = document.getElementById("InfoButtonArea").getElementsByTagName('a')[0];
if(method == 'irregular_rent'){
button.title = '保存';
button.childNodes[2].childNodes[1].innerText = '保存';
}else{
button.title = '租金测算';
button.childNodes[2].childNodes[1].innerText = '租金测算';
if(method=='even_subsection'){
document.all("A_Group_even_subsection").style.display="block";
}
}
}
var ids="RENT_OR_RATE,INCOME_NUMBER_YEAR,INCOME_INTERVAL_MONTH,INCOME_NUMBER,PERIOD_TYPE,GRACE,RATE_FLOAT_TYPE,BASE_RATE,RATE_FLOAT_AMT,YEAR_RATE,RENT_VALUE,FIRST_PLAN_DATE,SECOND_PLAN_DATE";
if(method == 'irregular_rent'||method=="even_subsection"){
setDisable(ids);
var showIds="RATE_FLOAT_DAY,FIRST_PLAN_DATE,SECOND_PLAN_DATE,PERIOD_TYPE,GRACE";
if(method == 'irregular_rent'){
setDisable(showIds);
}else{
setEnable(showIds);
}
setItemRequired(0,"YEAR_RATE",false);
setItemRequired(0,"INCOME_NUMBER",false);
setItemRequired(0,"FIRST_PLAN_DATE",false);
setItemRequired(0,"SECOND_PLAN_DATE",false);
}else{
setEnable(ids);
CalcControl.IncomeNumberView();
CalcControl.PeriodTypeView();
CalcControl.RateFloatTypeView();
CalcControl.RentOrRateView();
setItemRequired(0,"YEAR_RATE",true);
}
//日期
//计划日期
var plan;
if(method=="even_subsection"||method=="irregular_rent"||method==""){
plan="";
}else{
plan=calcRules['method'][method]["date_proc"].split(",");
}
var planflag={};
for(var i=0;i<plan.length;i++){
if(plan[i]==1){
showItem(0,"FIRST_PLAN_DATE");
setItemRequired(0,"FIRST_PLAN_DATE",true);
planflag["FIRST_PLAN_DATE"]=0;
}
if(plan[i]==4){
showItem(0,"SECOND_PLAN_DATE");
setItemRequired(0,"SECOND_PLAN_DATE",true);
planflag["SECOND_PLAN_DATE"]=0;
}
if(plan[i]==2){
showItem(0,"LAST_PLAN_DATE")
setItemRequired(0,"LAST_PLAN_DATE",true);
planflag["LAST_PLAN_DATE"]=0;
}
if(plan[i]==3){
showItem(0,"PLAN_DATE_HOILDAY")
setItemRequired(0,"PLAN_DATE_HOILDAY",true);
planflag["PLAN_DATE_HOILDAY"]=0;
}
}
var plana=["PLAN_DATE_HOILDAY","SECOND_PLAN_DATE","LAST_PLAN_DATE","PLAN_DATE_HOILDAY"];
for(var i=0;i<plana.length;i++){
if(planflag[plana[i]]!=0){
hideItem(0,plana[i]);
setItemRequired(0,plana[i],false);
}
}
//计息日期
var interest;
if(method=="even_subsection"||method=="irregular_rent"||method==""){
interest="";
}else{
interest=calcRules['method'][method]["interest_date_proc"].split(",");
}
var interestflag={};
for(var i=0;i<interest.length;i++){
if(interest[i]==1){
showItem(0,"FIRST_INTEREST_DATE");
setItemRequired(0,"FIRST_INTEREST_DATE",true);
interestflag["FIRST_INTEREST_DATE"]=0;
}
if(interest[i]==2){
showItem(0,"LAST_INTEREST_DATA")
setItemRequired(0,"LAST_INTEREST_DATA",true);
interestflag["LAST_INTEREST_DATA"]=0;
}
if(interest[i]==3){
showItem(0,"INTEREST_DATE_HOLIDAY")
setItemRequired(0,"INTEREST_DATE_HOLIDAY",true);
interestflag["INTEREST_DATE_HOLIDAY"]=0;
}
}
var interesta=["FIRST_INTEREST_DATE","LAST_INTEREST_DATA","INTEREST_DATE_HOLIDAY"];
for(var i=0;i<interesta.length;i++){
if(interestflag[interesta[i]]!=0){
hideItem(0,interesta[i]);
setItemRequired(0,interesta[i],false);
}
}
var isShowRate;
if(method=="even_subsection"||method=="irregular_rent"||method==""){
isShowRate="";
}else{
isShowRate=calcRules['method'][method]["isShowRate"];
}
if(isShowRate=="Y"){
showItem(0,"RATE");
showItem(0,"ADDITIONAL_RATE");
setItemRequired(0,"RATE",true);
setItemRequired(0,"ADDITIONAL_RATE",true);
}else{
hideItem(0,"RATE");
hideItem(0,"ADDITIONAL_RATE");
setItemRequired(0,"RATE",false);
setItemRequired(0,"ADDITIONAL_RATE",false);
}
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>&ProductId=<%=productId%>&method="+method;
AsControl.OpenView("/Accounting/LoanSimulation/condition_plan.jsp",param, "frame_list");
}
CalcControl.SettleMethodInit=function(){
var method=getItemValue(0,getRow(),"SETTLE_METHOD");
if(method == 'irregular_rent'||method=="even_subsection"){
setItemValue(0,0,"INCOME_NUMBER_YEAR","irregular");
setItemValue(0,0,"INCOME_INTERVAL_MONTH","1");
setItemValue(0,0,"LEASE_TERM","");
setItemValue(0,0,"INCOME_NUMBER","");
setItemValue(0,0,"RATE_FLOAT_TYPE","fixed");
CalcControl.RateFloatTypeInit();
setItemValue(0,0,"YEAR_RATE","");
setItemValue(0,0,"RENT_VALUE","");
setItemRequired(0,"INCOME_NUMBER",false);
if(method == 'irregular_rent'){
setItemValue(0,0,"RATE_FLOAT_DAY","360");
setItemValue(0,0,"FIRST_PLAN_DATE","");
setItemValue(0,0,"SECOND_PLAN_DATE","");
setItemValue(0,0,"PERIOD_TYPE","period_type_0");
setItemValue(0,0,"GRACE","0");
}
}else{
setItemRequired(0,"INCOME_NUMBER",true);
}
if(method=="even_subsection"||method=="irregular_rent"||method==""){
setItemValue(0,0,"PLAN_DATE_HOILDAY","unchanged");
setItemValue(0,0,"INTEREST_DATE_HOLIDAY","unchanged");
setItemValue(0,0,"RATE","0");
setItemValue(0,0,"ADDITIONAL_RATE","0");
setItemValue(0,0,"INTEREST_DAY_TYPE","start_date");
}else{
setItemValue(0,0,"PLAN_DATE_HOILDAY",calcRules['method'][method]["HolidayAdjust"]);
setItemValue(0,0,"INTEREST_DATE_HOLIDAY",calcRules['method'][method]["InterestHolidayAdjust"]);
setItemValue(0,0,"RATE",calcRules['method'][method]["RATE"]);
setItemValue(0,0,"ADDITIONAL_RATE",calcRules['method'][method]["AdditionalRate"]);
setItemValue(0,0,"INTEREST_DAY_TYPE",calcRules['method'][method]["InterestDayType"]);
}
}
CalcControl.RentOrRateView=function(){
var rentOrRate = getItemValue(0,getRow(),"RENT_OR_RATE");//租金推算方式
var method=getItemValue(0,getRow(),"SETTLE_METHOD");//租金计算方式
document.all("A_Group_calc_config").style.display="none";
var ids="RATE_FLOAT_TYPE,BASE_RATE,RATE_FLOAT_AMT,RATE_FLOAT_DAY,YEAR_RATE,RENT_VALUE,INCOME_NUMBER";
var ids2="INCOME_NUMBER_YEAR,PERIOD_TYPE,GRACE,FIRST_PLAN_DATE,SECOND_PLAN_DATE";
setItemRequired(0,"RENT_VALUE",false);
if(rentOrRate == 'rate'){//按年利率算租金
if(method=="irregular_rent"||method=="even_subsection"){
}else{
setEnable(ids);
setEnable(ids2);
CalcControl.RateFloatTypeView();
setItemRequired(0,"YEAR_RATE",true);
}
}else if(rentOrRate == 'rent'){//按租金算年利率
setDisable(ids);
setEnable(ids2);
setEnable('RENT_VALUE');
setEnable('INCOME_NUMBER');
setItemRequired(0,"YEAR_RATE",false);
setItemRequired(0,"RENT_VALUE",true);
}else if(rentOrRate == 'knowing_rent'){//已知租金规则 只能固定利率
setDisable(ids);
setEnable(ids2);
setItemRequired(0,"YEAR_RATE",false);
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&Ishistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/KnowConfigList.jsp",param,"frame_list_knowing");
}else if(rentOrRate== 'knowing_corpus'){//已知本金规则
setDisable(ids);
setEnable(ids2);
setItemRequired(0,"YEAR_RATE",true);
setEnable('RATE_FLOAT_TYPE');
CalcControl.RateFloatTypeView();
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/KnowConfigList.jsp",param,"frame_list_knowing");
}else if(rentOrRate=='rent_period'||rentOrRate=='rent_period_360'){//已知租金表
setDisable(ids);
setDisable(ids2);
setItemRequired(0,"YEAR_RATE",false);
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/reriod/LCCalcReriodList.jsp",param,"frame_list_knowing");
}else if(rentOrRate=='corpus_period'){//已知本金表
setDisable(ids);
setDisable(ids2);
setEnable('RATE_FLOAT_TYPE');
setItemRequired(0,"YEAR_RATE",true);
CalcControl.RateFloatTypeView();
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/reriod/LCCalcReriodList.jsp",param,"frame_list_knowing");
}
}
CalcControl.RentOrRateInit=function(){
var rentOrRate = getItemValue(0,getRow(),"RENT_OR_RATE");//租金推算方式
if(rentOrRate=="rent"){
setItemValue(0,0,"RATE_FLOAT_TYPE","fixed");
CalcControl.RateFloatTypeInit();
setItemValue(0,0,"YEAR_RATE","");
setItemValue(0,0,"RATE_FLOAT_DAY","360");
}else if(rentOrRate=="knowing_rent"){
setItemValue(0,0,"RATE_FLOAT_TYPE","fixed");
CalcControl.RateFloatTypeInit();
setItemValue(0,0,"INCOME_NUMBER","0");
setItemValue(0,0,"YEAR_RATE","");
setItemValue(0,0,"RENT_VALUE","");
setItemValue(0,0,"RATE_FLOAT_DAY","360");
}else if(rentOrRate=="rent_period"||rentOrRate=="rent_period_360"){
setItemValue(0,0,"RATE_FLOAT_TYPE","fixed");
CalcControl.RateFloatTypeInit();
setItemValue(0,0,"YEAR_RATE","");
setItemValue(0,0,"RENT_VALUE","");
setItemValue(0,0,"INCOME_NUMBER_YEAR","income_1");
setItemValue(0,0,"INCOME_INTERVAL_MONTH","1");
setItemValue(0,0,"PERIOD_TYPE","period_type_0");
setItemValue(0,0,"GRACE","0");
setItemValue(0,0,"FIRST_PLAN_DATE","");
setItemValue(0,0,"SECOND_PLAN_DATE","");
setItemValue(0,0,"RATE_FLOAT_DAY","360");
}else if(rentOrRate=="knowing_corpus"){
setItemValue(0,0,"INCOME_NUMBER","0");
setItemValue(0,0,"RATE_FLOAT_DAY","360");
}else if(rentOrRate=="corpus_period"){
setItemValue(0,0,"INCOME_NUMBER","0");
setItemValue(0,0,"RATE_FLOAT_DAY","360");
setItemValue(0,0,"FIRST_PLAN_DATE","");
setItemValue(0,0,"SECOND_PLAN_DATE","");
}
}
//改变租金计算方式
function changeSettleMethod(){
CalcControl.SettleMethodInit();
changeSettleMethod2();
CalcControl.SettleMethodView();
if(count > 0){
AsControl.RunJavaMethod("com.tenwa.reckon.executor.CreateTransactionExecutor","runDeleSubsection","flowunid=<%=flowunid%>,plannumber=<%=plannumber%>,planCName=<%=planCName%>,calType=<%=calType%>");
}
rentOrRateChange();
}
function changeSettleMethod2(){
var sele=$("#RENT_OR_RATE").val();
var a={};
a["even_rent"]={"rate":1,"rent":1,"knowing_rent":1};
a["even_corpus"]={"rate":1,"corpus_period":1,"knowing_corpus":1};
a["even_rent_rate"]={"rate":1};
a["even_corpus_rate"]={"rate":1,"corpus_period":1,"knowing_corpus":1};
a["even_interest"]={"rate":1,"rent":1};
a["car_even_rent"]={"rate":1};
a["car_even_interest"]={"rate":1};
a["even_rent_day"]={"rate":1,"rent":1,"knowing_rent":1,"rent_period":1,"rent_period_360":1};
a["even_subsection"]={"rate":1};
a["irregular_rent"]={"rate":1};
a[""]={};
//***********设置租金推算方法
var settleMethod=getItemValue(0,0,"SETTLE_METHOD");
$("#RENT_OR_RATE").empty();
$(rentOrRateOption).each(function(){
var value=$(this).attr("value");
if(value.length==0||a[settleMethod][value]==1){
$("#RENT_OR_RATE").append(this);
}
});
$("#RENT_OR_RATE").val(sele);
if(count>0){
$("#RENT_OR_RATE").val("rate");
}
//**********设置还款间隔
var incomeValue=$("#INCOME_NUMBER_YEAR").val();
$("#INCOME_NUMBER_YEAR").empty();
if(calcRules['method'][settleMethod]&&calcRules['method'][settleMethod]['PayFrequencyType']){
var incomerNumber=calcRules['method'][settleMethod]['PayFrequencyType'];
incomerNumber=incomerNumber.split(",");
var inco={};
for(var i=0;i<incomerNumber.length;i++){
inco[incomerNumber[i]]="1";
}
$(incomeNumberYear).each(function(){
var value=$(this).attr("value");
if(value.length==0||inco[value]==1){
$("#INCOME_NUMBER_YEAR").append(this);
}
});
$("#INCOME_NUMBER_YEAR").val(incomeValue);
if(count>0&&incomerNumber.length>0){
$("#INCOME_NUMBER_YEAR").val(incomerNumber[0]);
$("#INCOME_NUMBER_YEAR").change();
}
}else{
$(incomeNumberYear).each(function(){
$("#INCOME_NUMBER_YEAR").append(this);
});
$("#INCOME_NUMBER_YEAR").val(incomeValue);
}
}
function changeRateType(){
var a={};
a["fixed"]={"fixed":1,"add":1};
a["base"]={"fixed":1,"add":1};
a["proportion"]={"fixed":1,"calculation":1,"add":1};
a["add"]={"fixed":1,"calculation":1,"add":1};
var RATE_FLOAT_TYPE=getItemValue(0,0,"RATE_FLOAT_TYPE");
var adjustTypeValue=getItemValue(0,0,"ADJUST_TYPE");
$("#ADJUST_TYPE").empty();
$(adjustType).each(function(){
var value=$(this).attr("value");
if(value.length==0||a[RATE_FLOAT_TYPE][value]==1){
$("#ADJUST_TYPE").append(this);
}
});
$("#ADJUST_TYPE").val(adjustTypeValue);
if(count>0||adjustTypeValue==""){
$("#ADJUST_TYPE").val("fixed");
}
}
//根据金额算比例
function getRatioByMoney(e){
if(e.value === "") {
setItemValue(0, 0, e.id, "0");
}
var equipAmt=getItemValue(0,0,"EQUIP_AMT");//设备款
var cleanLeaseMoney=getItemValue(0,0,"CLEAN_LEASE_MONEY");//融资额
var allMoney = 0;
var fundRules=calcRules["fund"];
for(var key in fundRules) {
var fundMoney = getItemValue(0,0,key);//金额
if(typeof(fundRules[key]["financing"]) != "undefined" && fundRules[key]["financing"] == "true") {
if(fundMoney == "") {
fundMoney = 0;
setItemValue(0, 0, key, "0");
}
allMoney = eval(allMoney + "+" + fundMoney);
}
var fundFina=getItemValue(0,0,key+"_FINA");// 是否参与融资
if(fundFina == "finatype02" || fundFina == "finatype03"){
allMoney = Number(allMoney)+Number(fundMoney);
}
}
//得到总价款
setItemValue(0, 0, "TOTAL_ALL", eval(allMoney + "+" + equipAmt) + "");
var firstPaymentRatio = getItemValue(0, 0, "FIRST_PAYMENT_RATIO_0");
//计算综合融资额
if(e.id == "FIRST_PAYMENT") {
firstPaymentRatio = Number(getItemValue(0, 0, "FIRST_PAYMENT"))/Number(equipAmt)*100;
}
var ratio = 100 - Number(firstPaymentRatio);
var firstPayment = equipAmt * Number(firstPaymentRatio) / 100;
/* if(Number(getItemValue(0, 0, "FIRST_PAYMENT")) != firstPayment) {
firstPayment = Number(getItemValue(0, 0, "FIRST_PAYMENT"));
} */
cleanLeaseMoney = equipAmt - firstPayment + Number(allMoney);
setItemValue(0, 0, "RENT_RATIO", ((cleanLeaseMoney / equipAmt) * 100).toFixed(6) + "");
setItemValue(0, 0, "CLEAN_LEASE_MONEY", cleanLeaseMoney + "");
allMoney = eval(allMoney + "+" + equipAmt);
for(var key in fundRules){
var fundMoney=getItemValue(0,0,key);//金额
var fundRatio=getItemValue(0,0,key+"_RATIO");// 比例
var money=0;
if(fundRules[key]["ratioFee"]=="EquipEndAmt"&&key!="FIRST_PAYMENT"){//比例参照项
money=cleanLeaseMoney;
}else if(fundRules[key]["ratioFee"]=="TOTAL_ALL"&&key!="FIRST_PAYMENT"){//比例参照项
money = allMoney;
}else{
money=equipAmt;
}
if(fundRules[key]["ratioType"]=="InputMode03"){//互算
if(e.id==key){
if(Number(equipAmt)!=0){
fundRatio=Number(fundMoney/money*100).toFixed(6);
}else{
fundRatio=Number(0).toFixed(6);
}
setValue(key+"_RATIO",fundRatio);
$("#"+key+"_RATIO_0").val(Number(fundRatio).toFixed(2));
}else{
setValue(key,Number(money*fundRatio/100).toFixed(2));
}
}else if(fundRules[key]["ratioType"]=="InputMode02"){//比例算金额
setValue(key,Number(money*fundRatio/100).toFixed(2));
}else{
if(Number(equipAmt)!=0){
if(key=='FIRST_PAYMENT'){
fundMoney=Number(firstPayment).toFixed(2);
fundRatio=Number(fundMoney/money*100).toFixed(6);
setValue(key,fundMoney);
}
fundRatio=Number(fundMoney/money*100).toFixed(6);
}else{
fundRatio=Number(0).toFixed(6);
}
setValue(key+"_RATIO",fundRatio);
if(fundRules[key]["isShowRatio"]!="false"){
$("#"+key+"_RATIO_0").val(Number(fundRatio).toFixed(2));
}
}
}
// var firstPayment = Number(getItemValue(0, 0, "FIRST_PAYMENT"));
if(allMoney != 0 ) {
setItemValue(0, 0, "ALL_FIRST_PAYMENT", firstPayment + "");
setItemValue(0, 0, "FIRST_PAYMENT", firstPayment + "");
setItemValue(0, 0, "ALL_FIRST_PAYMENT_RATIO", ((firstPayment / allMoney) * 100).toFixed(6));
setItemValue(0, 0, "ALL_FIRST_PAYMENT_RATIO_0", ((firstPayment / allMoney) * 100).toFixed(6));
}
cautionMoney();
financingCar();
}
//根据比例算金额
function getMoneyByRatio(e){
var colRatio=e.id;
var ratio=e.value;
var col=colRatio.replace('_RATIO_0','');
if(ratio!='')$(e).val(FormatKNumber(ratio,2));
var equipAmt=getItemValue(0,0,"EQUIP_AMT");//设备款
var cleanLeaseMoney=getItemValue(0,0,"CLEAN_LEASE_MONEY");//融资额
var fundRules=calcRules["fund"];
var firstPayment=getItemValue(0,0,"FIRST_PAYMENT");//首付款
var money=0;
if(col=="FIRST_PAYMENT"){
firstPayment=Number(equipAmt*ratio/100).toFixed(2);
setValue(col+"_RATIO",ratio);
setValue(col,firstPayment);
getRatioByMoney(e);
}else{
if(fundRules[col]["ratioFee"]=="EquipEndAmt"){//比例参照项
money=cleanLeaseMoney;
}else{
money=equipAmt;
}
setValue(col+"_RATIO",ratio);
setValue(col,Number(money*ratio/100).toFixed(2));
}
cautionMoney();
financingCar();
}
function setValue(colName,value){
setItemValue(0,0,colName,value);
}
function changeCorpusRatio(){
var corpusRatio = getItemValue(0,0,"CORPUS_RATIO");
var firstPaymentRatio = getItemValue(0,0,"FIRST_PAYMENT_RATIO");
if(corpusRatio < 0){
alert("期限内本金比例不能小于0");
return;
}
if(Number(firstPaymentRatio) + Number(corpusRatio) > 100){
alert("期限内本金比例+首付比例不能大于100%");
return;
}
setItemValue(0,0,"CORPUS",(Number(getItemValue(0,0,"EQUIP_AMT"))*Number(corpusRatio)/100).toFixed(2));
}
function saveRecord(sPostEvents){
if(getItemValue(0,0,"PURCHASE_TAX") < 0){
alert("购置税不能小于0");
return;
}
if(getItemValue(0,0,"INSURANCE_PREMIUM") < 0){
alert("保险费不能小于0");
return;
}
if(getItemValue(0,0,"INCIDENTAL") < 0){
alert("杂费不能小于0");
return;
}
if(getItemValue(0,0,"FACTORY_ACCESSORIES") < 0){
alert("原厂配件费不能小于0");
return;
}
var corpusRatio = getItemValue(0,0,"CORPUS_RATIO");
var firstPaymentRatio = getItemValue(0,0,"FIRST_PAYMENT_RATIO");
if(corpusRatio < 0){
alert("期限内本金比例不能小于0");
return;
}
if(Number(firstPaymentRatio) + Number(corpusRatio) > 100){
alert("期限内本金比例+首付比例不能大于100%");
return;
}
//设备款大于0
var equipAmt = getItemValue(0,getRow(),"EQUIP_AMT");
if(!equipAmt || Number(equipAmt) <= 0){
alert('设备款需大于0 ');
return ;
}
var cleanLeaseMoney = getItemValue(0,getRow(),"CLEAN_LEASE_MONEY");
if(!cleanLeaseMoney || Number(cleanLeaseMoney) <= 0){
alert('融资额需大于0 ');
return ;
}
var incomeNumebr = getItemValue(0,getRow(),"INCOME_NUMBER");
if(incomeNumebr && Number(incomeNumebr) <= 0){
alert('还租次数需大于0 ');
return ;
}
var startDate=getItemValue(0,getRow(),"START_DATE");
var FIRST_PLAN_DATE=getItemValue(0,getRow(),"FIRST_PLAN_DATE");
var SECOND_PLAN_DATE=getItemValue(0,getRow(),"SECOND_PLAN_DATE");
if(SECOND_PLAN_DATE&&FIRST_PLAN_DATE&&SECOND_PLAN_DATE<FIRST_PLAN_DATE){
alert("第二期租金计划日期不能小于第一期租金计划日期!");
return ;
}
if(FIRST_PLAN_DATE&&startDate&&FIRST_PLAN_DATE<startDate){
alert("第一期租金计划日期不能小于起租日!");
return ;
}
//已知本金已知租金,判断保存后的租金和本地是否跟净融资额匹配?
var rentOrRate = getItemValue(0,getRow(),"RENT_OR_RATE");
var cleanLeaseMoney = getItemValue(0,getRow(),"CLEAN_LEASE_MONEY");
var equipEndValue = getItemValue(0,getRow(),"EQUIP_END_VALUE");
if(rentOrRate.indexOf('knowing') > -1||rentOrRate.indexOf('period')>-1){
var result = AsControl.RunJavaMethod("com.tenwa.reckon.executor.CreateTransactionExecutor","checkKnowingConfig","flowunid=<%=flowunid%>,plannumber=<%=plannumber%>,calType=<%=calType%>,planCName=<%=planCName%>,rentOrRate="+rentOrRate+",cleanLeasemoney="+cleanLeaseMoney+",equipEndValue="+equipEndValue);
if(result){
alert(result);
return;
}
}
// 如果是不规则租金测算的话,那么仅保存商务报价。
var settleMethod = getItemValue(0,getRow(),"SETTLE_METHOD");
if(settleMethod == 'irregular_rent'){
as_save("myiframe0");
}else{
as_save("myiframe0","run()");
}
}
function run()
{
var result = AsControl.RunJavaMethod("com.tenwa.reckon.executor.CreateTransactionExecutor","run","flowunid=<%=flowunid%>,plannumber=<%=plannumber%>,calType=<%=calType%>,productId=<%=productId%>");
document.all("frame_list").src = document.all("frame_list").src;
if(result.info){
for(var p in result.info){
setItemValue(0,getRow(),p.toUpperCase(),result.info[p]);
}
}
if(result.message){
alert(result.message);
}
}
//strInterval 增加日期类型 ,num 数量 ,date 起始日期
function dateAdd(strInterval, num, date){
date = arguments[2] || new Date();
switch (strInterval) {
case 's' :return new Date(date.getTime() + (1000 * num));
case 'n' :return new Date(date.getTime() + (60000 * num));
case 'h' :return new Date(date.getTime() + (3600000 * num));
case 'd' :return new Date(date.getTime() + (86400000 * num));
case 'w' :return new Date(date.getTime() + ((86400000 * 7) * num));
case 'm' :return new Date(date.getFullYear(), (date.getMonth()) + num, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
case 'y' :return new Date((date.getFullYear() + num), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
}
}
//在input框后设置比例
function setItemRatio(fieldName,unit){
var dwname=0;
var rowindex=0;
if(!isNaN(dwname))dwname = "myiframe" + dwname;
var dwindex = dwname.substring(8);
var sColIndex = getColIndexFromName(fieldName);
var oSpanInput = document.getElementById("Ratio_" + sColIndex);
oSpanInput.innerHTML = unit;
}
//设置可编辑
function setEnable(ids){
var id=ids.split(",");
for(var i=0;i<id.length;i++){
setItemDisabled(0,getRow(),id[i],false);
getObj(0,id[i]).style.backgroundColor="";
}
}
//设置只读
function setDisable(ids){
var id=ids.split(",");
for(var i=0;i<id.length;i++){
setItemDisabled(0,getRow(),id[i],true);
getObj(0,id[i]).style.backgroundColor="#EBEBE4";
}
}
//保证金事件
function cautionMoney(){
var cautionMoney = getItemValue(0,getRow(),"CAUTION_MONEY");//保证金
var cautionMoneyMethod = getItemValue(0,getRow(),"CAUTION_MONEY_METHOD");//保证金期末处理方式
if("caution_money_method01" == cautionMoneyMethod) {
setItemValue(0, 0, "CAUTION_DEDUCTION_MONEY", cautionMoney);
setItemValue(0, 0, "CAUTION_MONEY_REMAIN", "0");
} else if("caution_money_method02" == cautionMoneyMethod) {
setItemValue(0, 0, "CAUTION_DEDUCTION_MONEY", "0");
setItemValue(0, 0, "CAUTION_MONEY_REMAIN", cautionMoney);
}
var cautionDeductionMoney = getItemValue(0,getRow(),"CAUTION_DEDUCTION_MONEY");//保证金抵扣
var cautionMoneyRemain=getItemValue(0,getRow(),"CAUTION_MONEY_REMAIN");//保证金退还
if(Number(cautionMoneyRemain)==Number(cautionMoney)-Number(cautionDeductionMoney)){
return ;
}
cautionDeductionMoney = cautionMoney;//保证金抵扣
setItemValue(0,0,"CAUTION_DEDUCTION_MONEY",cautionDeductionMoney);
cautionMoneyRemain=Number(cautionMoney)-Number(cautionDeductionMoney);//保证金退还
if(cautionMoneyRemain<0){
setItemValue(0,0,"CAUTION_DEDUCTION_MONEY",cautionMoney);
AsDebug.alert("提示", "保证金退还金额填写过大!");
return;
}else{
setItemValue(0,0,"CAUTION_MONEY_REMAIN",cautionMoneyRemain);
}
if(!getItemValue(0,getRow(),"CAUTION_MONEY_REMAIN")){
setItemValue(0,0,"CAUTION_MONEY_REMAIN","0");
}
}
//保证金抵扣事件
function cautionDeductionMoney(){
var cautionMoney = getItemValue(0,getRow(),"CAUTION_MONEY");//保证金
var cautionDeductionMoney = getItemValue(0,getRow(),"CAUTION_DEDUCTION_MONEY");//保证金抵扣
var cautionMoneyRemain=Number(cautionMoney)-Number(cautionDeductionMoney);//保证金退还
if(cautionMoneyRemain<0){
setItemValue(0,0,"CAUTION_DEDUCTION_MONEY",cautionMoney);
setItemValue(0,0,"CAUTION_MONEY_REMAIN","0");
alert("保证金退还金额填写过大!");
return;
}else{
setItemValue(0,0,"CAUTION_MONEY_REMAIN",cautionMoneyRemain);
}
if(!getItemValue(0,getRow(),"CAUTION_MONEY_REMAIN")){
setItemValue(0,0,"CAUTION_MONEY_REMAIN","0");
}
}
//利率计算方式 租金计算方式
function changeRateFloat(){
CalcControl.RateFloatTypeView();
CalcControl.RateFloatTypeInit();
changeRateType();
}
//期初期末
function changePeriod(){
CalcControl.PeriodTypeView();
CalcControl.PeriodTypeInit();
}
//改变还款间隔
function changeIncomeNumber(){
CalcControl.IncomeNumberView();
CalcControl.IncomeNumberInit();
}
//改变还款月数
function changeIntervalMonth(){
CalcControl.InitLsaseTerm();
var leaseAmtDate = getItemValue(0,getRow(),"LEASE_AMT_DATE");
if(leaseAmtDate){
CalcControl.InitStartDate();
}
}
//改变还租次数
function changeNumber(){
CalcControl.InitLsaseTerm();
}
//改变宽限期
function changeGrace(){
CalcControl.InitLsaseTerm();
}
//改变基准利率
function changeBaseRate(){
CalcControl.RateFloatTypeInit();
}
//改变利率调整值
function changeRateFloatAmt(){
CalcControl.RateFloatTypeInit();
}
//改变投放日
function changeLeaseAmtDate(){
CalcControl.InitStartDate();
}
//改变起租日
function changeStartDate(){
CalcControl.InitFistPlanDate();
}
//改变第一期租金计划日期
function changeFistPlanDate(){
CalcControl.InitSecondPlanDate();
}
//租金推算方法
function rentOrRateChange(){
CalcControl.RentOrRateInit();
CalcControl.RentOrRateView();
//document.all("frame_list_knowing").src = document.all("frame_list_knowing").src;
if(count > 0){
AsControl.RunJavaMethod("com.tenwa.reckon.executor.CreateTransactionExecutor","runDelteKnowing","flowunid=<%=flowunid%>,plannumber=<%=plannumber%>,planCName=<%=planCName%>,calType=<%=calType%>");
}
}
function changeSettleMethod3(){
var method="<%=dwTemp.getData().get("SETTLE_METHOD")%>";
//按计算方式 显示按钮 和分段测算录入页面
document.all("A_Group_even_subsection").style.display="none";
if(method=='even_subsection'){
document.all("A_Group_even_subsection").style.display="block";
}
<%-- var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>&method="+method;
AsControl.OpenView("/Accounting/LoanSimulation/condition_plan.jsp",param, "frame_list"); --%>
var rentOrRate ="<%=dwTemp.getData().get("RENT_OR_RATE")%>";//租金推算方式
document.all("A_Group_calc_config").style.display="none";
if(rentOrRate == 'knowing_rent'){//已知租金规则 只能固定利率
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/KnowConfigList.jsp",param,"frame_list_knowing");
}else if(rentOrRate== 'knowing_corpus'){//已知本金规则
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/KnowConfigList.jsp",param,"frame_list_knowing");
}else if(rentOrRate=='rent_period'||rentOrRate=='rent_period_360'){//已知租金表
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/reriod/LCCalcReriodList.jsp",param,"frame_list_knowing");
}else if(rentOrRate=='corpus_period'){//已知本金表
document.all("A_Group_calc_config").style.display="block";
var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>";
AsControl.OpenView("/Accounting/LoanSimulation/reriod/LCCalcReriodList.jsp",param,"frame_list_knowing");
}
//日期
//计划日期
var plan;
if(method=="even_subsection"||method=="irregular_rent"||method==""){
plan="";
}else{
plan=calcRules['method'][method]["date_proc"].split(",");
}
var planflag={};
for(var i=0;i<plan.length;i++){
if(plan[i]==1){
showItem(0,"FIRST_PLAN_DATE");
//setItemRequired(0,"FIRST_PLAN_DATE",true);
planflag["FIRST_PLAN_DATE"]=0;
}
if(plan[i]==4){
showItem(0,"SECOND_PLAN_DATE");
//setItemRequired(0,"SECOND_PLAN_DATE",true);
planflag["SECOND_PLAN_DATE"]=0;
}
if(plan[i]==2){
showItem(0,"LAST_PLAN_DATE")
//setItemRequired(0,"LAST_PLAN_DATE",true);
planflag["LAST_PLAN_DATE"]=0;
}
if(plan[i]==3){
showItem(0,"PLAN_DATE_HOILDAY")
//setItemRequired(0,"PLAN_DATE_HOILDAY",true);
planflag["PLAN_DATE_HOILDAY"]=0;
}
}
var plana=["PLAN_DATE_HOILDAY","SECOND_PLAN_DATE","LAST_PLAN_DATE","PLAN_DATE_HOILDAY"];
for(var i=0;i<plana.length;i++){
if(planflag[plana[i]]!=0){
hideItem(0,plana[i]);
//setItemRequired(0,plana[i],false);
}
}
//计息日期
var interest;
if(method=="even_subsection"||method=="irregular_rent"||method==""){
interest="";
}else{
interest=calcRules['method'][method]["interest_date_proc"].split(",");
}
var interestflag={};
for(var i=0;i<interest.length;i++){
if(interest[i]==1){
showItem(0,"FIRST_INTEREST_DATE");
//setItemRequired(0,"FIRST_INTEREST_DATE",true);
interestflag["FIRST_INTEREST_DATE"]=0;
}
if(interest[i]==2){
showItem(0,"LAST_INTEREST_DATA")
//setItemRequired(0,"LAST_INTEREST_DATA",true);
interestflag["LAST_INTEREST_DATA"]=0;
}
if(interest[i]==3){
showItem(0,"INTEREST_DATE_HOLIDAY")
//setItemRequired(0,"INTEREST_DATE_HOLIDAY",true);
interestflag["INTEREST_DATE_HOLIDAY"]=0;
}
}
var interesta=["FIRST_INTEREST_DATE","LAST_INTEREST_DATA","INTEREST_DATE_HOLIDAY"];
for(var i=0;i<interesta.length;i++){
if(interestflag[interesta[i]]!=0){
hideItem(0,interesta[i]);
//setItemRequired(0,interesta[i],false);
}
}
var isShowRate;
if(method=="even_subsection"||method=="irregular_rent"||method==""){
isShowRate="";
}else{
isShowRate=calcRules['method'][method]["isShowRate"];
}
if(isShowRate=="Y"){
showItem(0,"RATE");
showItem(0,"ADDITIONAL_RATE");
//setItemRequired(0,"RATE",true);
//setItemRequired(0,"ADDITIONAL_RATE",true);
}else{
hideItem(0,"RATE");
hideItem(0,"ADDITIONAL_RATE");
//setItemRequired(0,"RATE",false);
//setItemRequired(0,"ADDITIONAL_RATE",false);
}
}
var ischeck=true;
function checkModified(){
var sUnloadMessage = "\n\r当前页面内容已经被修改\n\r按“取消”则留在当前页然后再按当前页上的“保存”按钮以保存修改过的数据\n\r按“确定”则不保存修改过的数据并且离开当前页";
if(!ischeck){
return true;
}
if(as_isPageChanged()){
return confirm(sUnloadMessage);
}
return true;
}
var fundError={};
function showErrors(tableIndex){
var list = $("#myiframe0").validate().errorList;
document.getElementById("messageBox").style.display='block';
var iExtCount = 8;
if(list.length<=iExtCount){
$("#showpart").hide();
$("#mobtn").hide();
$("#hidbtn").hide();
}else{
$("#showpart").hide();
$("#hidbtn").hide();
}
for(var ii=0;ii<list.length;ii++){
var ele_error = document.createElement("li");
var errmsg = fundError[list[ii].element.getAttribute('name')];;
ele_error.innerHTML = "<a href='javascript:void(0)' target='_self' element_name='"+list[ii].element.getAttribute('name')+"'>" + errmsg + "</a>";
if(ii>=iExtCount){
document.getElementById("ul_error_1").appendChild(ele_error);
}else{
document.getElementById("ul_error_0").appendChild(ele_error);
}
var eventHander = function(e){
var sourceObj = e.srcElement?e.srcElement:e.target;
try{
document.getElementsByName(sourceObj.getAttribute("element_name"))[0].focus();
}catch(ex){
//alert('该控件无法聚焦');
}
};
if(window.attachEvent)//IE
ele_error.childNodes[0].attachEvent("onclick", eventHander );
else{
//FF
ele_error.childNodes[0].addEventListener("click", eventHander, false);
}
}
if(list && list[0] && list[0].element){
try{
document.getElementsByName(list[0].element.getAttribute("name"))[0].focus();
}
catch(e){}
}
}
jQuery.validator.prototype.showLabel = function(element,message){
var id=element.getAttribute('id');
if(element.getAttribute('errorInfo')){
message=element.getAttribute('errorInfo');
element.removeAttribute('errorInfo');
}
fundError[id]=message;
};
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>