游畅
2023-04-29 cc266a1e4080bb3ecc47ea4a202dd549545111e1
force-app/main/default/pages/SelectAssetEstimateVM.page
@@ -42,13 +42,8 @@
var RCbottonChanged = 0;
// 2022故障品加费 start
// var RCButtonDisable = document.getElementById("emailSend");
// RCButtonDisable.style.display = "none";
// 2022故障品加费 end
var hasSendEmail = {!hasSendEmail};
console.log('***hasSendEmail',hasSendEmail);
// if(hasSendEmail == true){
//     j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
//     j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
@@ -161,6 +156,7 @@
    // if(!ResonCannotWarranty.contains("弃修")){
    //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).attr("display", none);
    // }
    if (isDisabled) {
        j$(escapeVfId('allPage:allForm:allBlock:contract:depart')).attr("disabled", true);
@@ -169,7 +165,6 @@
        j$(escapeVfId('allPage:allForm:allBlock:contract:estimateTarget')).attr("disabled", true);
        j$(escapeVfId('allPage:allForm:allBlock:contract:EndUserType')).attr("disabled", true);
        var rowCnt = {!productCount};
        console.log('isDisabled='+isDisabled);
        for (var i = 0; i < rowCnt; i++) {
            // alert(11111111111111 +rowCnt);
            var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
@@ -250,8 +245,35 @@
    // disable1();
    // 2021、8、26 合同报价页面的优化,无保有设备点检对象选择框变黑 fxk end
    console.log('ApprovalBtnDisabled=='+{!ApprovalBtnDisabled});
    pageSetDisabled();
    refreshAsset({!productCount});
    //上限合同 20230103 hql start
    // console.log('Limit_PriceHidden2=='+Limit_PriceHidden2);
    var RequestquotationAmount = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val();
    console.log('申请报价金额='+RequestquotationAmount);
    var AssetRepairSumPrice    = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
    console.log('合同设备修理总额='+AssetRepairSumPrice);
    Limit_Price_Amount = (localParseFloat(AssetRepairSumPrice)+localParseFloat(RequestquotationAmount))*1.3;
    Limit_Price_Amount = Math.round(Limit_Price_Amount);
    // console.log('Limit_Price_Amount'+Limit_Price_Amount);
    Limit_Price_AmountOne =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).value();
    Limit_PriceHidden =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_PriceHidden')).value();
    if (Limit_PriceHidden*1==0) {
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
    }
    Limit_PriceHidden2 =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price2Hidden')).value();
    if (Limit_PriceHidden2 == 'false') {
        // lpa =  document.getElementById('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount');
        // lpa.style.display = "none";
        // console.log('隐藏完毕');
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val('');
    }
    Price111 = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val();
    // console.log('上限金额为'+Limit_Price_Amount);
    // console.log('原有上限金额为'+Limit_PriceHidden);
    // console.log('不是上限合同的金额为'+Price111);
    //上限合同 20230103 hql end
    pageSetDisabled();
    var createdDate = new Date('{!estimate.CreatedDate}');
    // 报价中设备的机身编码为空时的新品合同有效期延长 20200710 gzw
    var aLLManual = 'true';
@@ -340,6 +362,7 @@
    }
    
    if ('{!DecideBtnDisabled}' == 'false') {
        // console.log('oldMainteReal修改完成');
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).val(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
    }
}
@@ -370,6 +393,7 @@
}
function checkDiscount(val) {
    // var alerts = 0;
    if (val == null || val == "") {
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val("");
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:discount_Rate')).text("");
@@ -381,10 +405,53 @@
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(0.00);
        return;
    }
    // 报价金额改善 20230314 start
    // var startime1 =  new Date(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:PastContractendday')).value());
    // var startime2 = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
    // var result = (startime2-startime1)/(3600*24*1000);
    // Is_Blank_period1 =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Is_Blank_period')).value();
    // Cost_rate_ForecastF =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Cost_rate_ForecastF')).value();
    // downprice = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).value();
    // var renewTenOFF = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:renewTenOFF')).value();
    // if (Is_Blank_period1 == 'true' && ((parseFloat(Cost_rate_ForecastF)<100)||Cost_rate_ForecastF.length == 0) && result <=1 && downprice > val ) {
    //    alerts = 1;
    // }
    // if (alerts == 1 && renewTenOFF == 'false') {
    //     if (confirm("本单可以继续申请10%折扣,请确认是否申请,申请后合同开始日自动锁定为合同预定开始日,后续无法更改合同开始日")) {
    //         j$(escapeVfId('allPage:allForm:allBlock:contractInfo:renewTenOFF')).val(true);
    //         val = val*0.9;
    //         j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
    //     } else {
    //     }
    // }
    // 报价金额改善 20230314 end
    val = localParseFloat(val);
    //val = Math.round(val * 100) / 100;
    val = Math.round(val);
    j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val(toNumComma(val));
    //上限合同 20230117 HQL start
    var RequestquotationAmount = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val();
    console.log('申请报价金额='+RequestquotationAmount);
    var AssetRepairSumPrice    = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
    console.log('合同设备修理总额='+AssetRepairSumPrice);
    Limit_Price_Amount = (localParseFloat(AssetRepairSumPrice)+localParseFloat(RequestquotationAmount))*1.3;
    Limit_Price_Amount = Math.round(Limit_Price_Amount);
    Limit_Price_AmountOne =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).value();
    Limit_PriceHidden =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_PriceHidden')).value();
    // if (Limit_PriceHidden*1==0) {
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
    // }
    Limit_PriceHidden2 =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price2Hidden')).value();
    if (Limit_PriceHidden2 == 'false') {
        // lpa =  document.getElementById('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount');
        // lpa.style.display = "none";
        // console.log('隐藏完毕');
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val('');
    }
    amount = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).value();
    console.log('上限金额填入:'+amount);
    //上限合同 20230117 HQL end
   makeRealPrice(1);
}
@@ -418,7 +485,189 @@
    ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
    console.log('方法2是否审批通过=='+ISReducedpriceapproval+'==============');
}
var number1 = 0;
// function seamlessRenew(cnt){
//     // 报价规则改善 20230309 start
//     var isSeamlessRenew = 0;
//     var isSeamlessRenew1 = 0;
//     var isSeamlessRenew3 = 0;
//     var isSeamlessRenew4 = 0;
//     // 报价规则改善 20230309 end
//     // 报价规则改善 20230310 start
//     var downPriceSum = 0;
//     var upPriceSum = 0;
//     var downPriceSum1 = 0;
//     var upPriceSum1 = 0;
//     var downPriceSum3 = 0;
//     var upPriceSum3 = 0;
//     var downPriceSum4 = 0;
//     var upPriceSum4 = 0;
//     // 报价规则改善 20230310 end
//     // 报价规则改善 20230310 start
//     var renewTenOFF = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:renewTenOFF')).value();
//     if (renewTenOFF == 'true') {
//         j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
//     }
//         document.getElementById("startdateaddsix1").value = addMonths(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:PastContractendday')).value(),6);
//         document.getElementById("startdateaddsix2").value = addMonths(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:PastContractendday')).value(),6);
//         document.getElementById("startdateaddsix3").value = addMonths(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:PastContractendday')).value(),12);
//     // 报价规则改善 20230310 end
//     for (var i = 0; i < cnt; i++) {
//         // 报价规则改善 20230310 start
//         var  downPrice1 = 0;
//         var  upPrice1 = 0;
//         var  downPrice3 = 0;
//         var  upPrice3 = 0;
//         var  downPrice4 = 0;
//         var  upPrice4 = 0;
//          var Price_YearTXT = 0;
//         var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
//         var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
//         // 合同月数乗算
//         var month = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
//         if (month == undefined || month == "") {
//             month = 1;
//         }
//         var month2 = 0;
//         if (month > 12) {
//             month2 = month - 12;
//             month = 12;
//         }
//         var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
//         var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
//         if(b != ''){
//                     // var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
//                     var lastContRange = 0;
//                     if(LastMContractRecord == 'VM_Contract'){
//                         // lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
//                         lastContRange = 36;
//                     }else{
//                         lastContRange = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':lastContRange')).value();
//                     }
//         }
//         var Punish = calculateNtoMRatio( lastContRange,(month + month2));
//          // 报价规则改善 20230310 end
//         if (!isDisabled) {
//             var Adjustment_ratio_Lower = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Lower')).val());
//             var Adjustment_ratio_Upper = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_ratio_Upper')).val());
//              strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
//                 Price_YearTXT = strMoney * 12;
//                 if (isnew == 'true') {
//                     strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
//                 } else {
//                     strMoney = month * strMoney + month2 * strMoney;
//                 }
//             // 服务合同报价规则改善 20230227 start
//                     var LastMContractID = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractID')).value();
//                     // var ISStandardPricing = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISStandardPricing')).value();
//                     // 缺少首签设备逻辑
//                     if (LastMContractID == '') {
//                         console.log('新签设备');
//                         j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(strMoney));
//                         j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(strMoney);
//                         j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(strMoney));
//                         j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(strMoney);
//                     }
//             // 服务合同报价规则改善 20230227 end
//             var startdate11 = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:PastContractendday')).value();
//             var startdate1 = j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value();
//             var startdate = new Date(startdate1);
//             var startdatesix1 = new Date(addMonths(startdate11,6));
//             startdatesix1.setDate(startdatesix1.getDate()-1);
//             var startdatesix2 = new Date(addMonths(startdate11,6));
//             startdatesix2.setDate(startdatesix2.getDate()+1);
//             var startdatesix3 = new Date(addMonths(startdate11,12));
//             startdatesix3.setDate(startdatesix3.getDate()+1);
//             // 第一个日期
//             var result1 = Blankperiod(startdate,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,1);
//             var arr=result1.split( '/');
//             downPrice=parseInt(arr[0]);
//             upPrice=parseInt(arr[1]);
//             isSeamlessRenew=isSeamlessRenew+parseInt(arr[2]);
//             // console.log('result1='+result1);
//             // 第二个日期
//             var result2 = Blankperiod(startdatesix1,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,2);
//             var arr2=result2.split( '/');
//             downPrice1=parseInt(arr2[0]);
//             upPrice1=parseInt(arr2[1]);
//             isSeamlessRenew1=isSeamlessRenew1+parseInt(arr2[2]);
//             // console.log('result2='+result2);
//             // 第三个日期
//             var result3 = Blankperiod(startdatesix2,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,2);
//             var arr3=result3.split( '/');
//             downPrice3=parseInt(arr3[0]);
//             upPrice3=parseInt(arr3[1]);
//             isSeamlessRenew3=isSeamlessRenew3+parseInt(arr3[2]);
//             // console.log('result3='+result3);
//             // 第四个日期
//             var result4 = Blankperiod(startdatesix3,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,2);
//             var arr4=result4.split( '/');
//             downPrice4=parseInt(arr4[0]);
//             upPrice4=parseInt(arr4[1]);
//             isSeamlessRenew4=isSeamlessRenew4+parseInt(arr4[2]);
//             // console.log('result4='+result4);
//             // 报价规则改善 20230308 end
//             // 报价规则改善 20230310 start
//             downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
//             upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
//             downPriceSum1 = downPriceSum1 + localParseFloat(toNum(downPrice1));
//             upPriceSum1 =  upPriceSum1 + localParseFloat(toNum(upPrice1));
//             downPriceSum3 = downPriceSum3 + localParseFloat(toNum(downPrice3));
//             upPriceSum3=  upPriceSum3 + localParseFloat(toNum(upPrice3));
//             downPriceSum4 = downPriceSum4 + localParseFloat(toNum(downPrice4));
//             upPriceSum4=  upPriceSum4 + localParseFloat(toNum(upPrice4));
//             // 报价规则改善 20230310 end
//         }
//     }
//     // 报价规则改善 20230309 start
//     // console.log('isSeamlessRenew='+isSeamlessRenew);
//         if (isSeamlessRenew==0) {
//             j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Is_Blank_period')).val(true);
//         }else{
//             j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Is_Blank_period')).val(false);
//         }
//         var startime1 =  new Date(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:PastContractendday')).value());
//         var startime2 = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
//         var result = (startime2-startime1)/(3600*24*1000);
//         Is_Blank_period1 =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Is_Blank_period')).value();
//         Cost_rate_ForecastF =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Cost_rate_ForecastF')).value();
//         // 5.当预测成本率为空时实绩连动价格是否享受9折优惠
//         if (isSeamlessRenew==0 && ((parseFloat(Cost_rate_ForecastF)<100)||Cost_rate_ForecastF.length == 0)) {
//             downPriceSum = downPriceSum*0.9;
//             upPriceSum = upPriceSum*0.9;
//         }
//         if (isSeamlessRenew1==0) {
//             downPriceSum1 = downPriceSum1*0.9;
//             upPriceSum1 = upPriceSum1*0.9;
//         }
//         if (isSeamlessRenew3==0) {
//             downPriceSum3 = downPriceSum3*0.9;
//             upPriceSum3 = upPriceSum3*0.9;
//         }
//         if (isSeamlessRenew4==0) {
//             downPriceSum4 = downPriceSum4*0.9;
//             upPriceSum4 = upPriceSum4*0.9;
//         }
//         if (!isDisabled) {
//         j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text(toNumComma(Math.round(upPriceSum)));
//         j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val(toNum(Math.round(upPriceSum)));
//         j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text(toNumComma(Math.round(downPriceSum)));
//         j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val(toNum(Math.round(downPriceSum)));
//         }
//         document.getElementById("GuidePriceDown5").value = toNumComma(Math.round(downPriceSum));
//         document.getElementById("GuidePriceUp5").value = toNumComma(Math.round(upPriceSum));
//         document.getElementById("GuidePriceDown4").value = toNumComma(Math.round(downPriceSum1));
//         document.getElementById("GuidePriceUp4").value = toNumComma(Math.round(upPriceSum1));
//         document.getElementById("GuidePriceDown3").value = toNumComma(Math.round(downPriceSum3));
//         document.getElementById("GuidePriceUp3").value = toNumComma(Math.round(upPriceSum3));
//         document.getElementById("GuidePriceDown2").value = toNumComma(Math.round(downPriceSum4));
//         document.getElementById("GuidePriceUp2").value = toNumComma(Math.round(upPriceSum4));
//     // 报价规则改善 20230309 end
// }
function refreshAsset(cnt) {
    console.log('执行refreshAsset');
    console.log('decide==='+{!DecideBtnDisabled});
     // alert(cnt);
    // 提交后就页面不计算了
    var isDisabled = {!PageDisabled};
@@ -434,25 +683,31 @@
    // 新品合同 判断
    var newCon = true;
    var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
    //上限合同 20230103 LY start
    // var mainteReal = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text();
    // Limit_Price_Amount = localParseFloat(mainteReal)*1.3;
    // console.log('Limit_Price_Amount'+Limit_Price_Amount);
    // j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
    //上限合同 20230103 LY end
    //多年保续签合同数量 thh 20220316 start
    var GuranteeCount = 0;
    //多年保续签合同数量 thh 20220316 end
    //2022故障品加费 获取userInfo简档名称 是否为FSE start
    var isFSE = {!isFSE};
    // var isFSE = true;
    console.log('***isFSE',isFSE);
    //2022故障品加费 获取userInfo简档名称 end
    //20230208 上限合同开发 hql start
    if (isFSE) {
        // lpa =  document.getElementById('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount');
        // lpa.style.display = "none";
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).attr("disabled", true);
        console.log('上限金额隐藏');
    }
    //20230208 上限合同开发 hql end
    // 预定开始日
    var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
    // 报价规则改善
    // document.getElementById("startdateaddsix4").value = j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value();
    // 报价规则改善
    // 预定开始日-6个月
    startdate.setMonth(startdate.getMonth() - 6);
    // 申请日 当前日期
@@ -479,6 +734,7 @@
        month = 12;
    }
    for (var i = 0; i < cnt; i++) {
        // console.log('第'+i+'个设备');
        var strMoney = 0;
        var repairMoney = 0;
        // 行项目 最高、最低价格合计
@@ -486,15 +742,20 @@
        // 下线价格
        var downPrice = 0;
        // 上线价格
        var upPrice = 0;
        var upPrice = 0;
        // 12个月合同金额
        var Price_YearTXT = 0;
        var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
        var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
        var assetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
        console.log('***isManual=:'+isManual);
        //市场多年保修价格开发 DC 2023/02/09 start
        var VMassetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Maintenance_Price_Year__c')).val();
        // console.log('***合同定价:'+VMassetListmonth);
        //市场多年保修价格开发 DC 2023/02/09 end
        // console.log('***isManual=:'+isManual);
        if (isManual == 'true') {
            var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
            if (a != '') {
@@ -506,17 +767,21 @@
                //}
                strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
                // alert(strMoney);
                Price_YearTXT = strMoney * 12;
                if (isnew == 'true') {
                    newCount ++;
                    strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
                } else {
                    newCon = false;
                    strMoney = month * strMoney + month2 * strMoney;
                }
                var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
                var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
                // console.log('***维修合同记录类型1'+LastMContractRecord);
                if(b != ''){
                    conCCount ++;
                    // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。)
@@ -555,31 +820,137 @@
                    // 判断有无报价:没有按照标准价格实际联动
                    var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                    if(Estimate_Num == 0){
                        if(LastMContractRecord == 'VM_Contract'){
                       if(LastMContractRecord == 'VM_Contract'){
                            // gzw 20220630  实际联动6个月价格区分
                            var nowdate = new Date();
                            lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                            nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
                            if(nowdate < Date.parse(lastendDate)){
                                upPrice = strMoney;
                                downPrice = strMoney * 0.8;
                            //市场多年保修价格开发 DC 2023/1/30 start
                            var Maxcoefficient =0;
                            var Mincoefficient =0;
                            var ContractMonth = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
                            // console.log('***消费率:'+AssetRate);
                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
                            if(AssetRate<= 50){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>50 &&AssetRate<=60){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>60 &&AssetRate<=70){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>70 &&AssetRate<=80){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>80 &&AssetRate<=90){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>90 &&AssetRate<=100){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>100 &&AssetRate<=110){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>110 &&AssetRate<=120){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>120 &&AssetRate<=130){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>130 &&AssetRate<=140){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>140){
                                Maxcoefficient = (1+0.3);
                                Mincoefficient = (1+0.2);
                            }
                            //市场多年保修价格开发 DC 2023/1/30 end
                            // console.log('***最高系数'+Maxcoefficient);
                            // console.log('***最低系数'+Mincoefficient);
                        if(nowdate < Date.parse(lastendDate)){
                            //设备小于两年半
                            // upPrice = strMoney;
                            // downPrice = strMoney * 0.8;
                        // console.log('***小于2年半')
                        // 市场多年保修价格开发 start DC 2023/01/19
                            //市场多年保设备小于2年半
                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
                            // console.log('***设备型号'+AssetModelNo);
                            // console.log('***产品类型'+Category4);
                            //设备设备消费率小于1.4
                            if(AssetRate<140){
                                upPrice = VMassetListmonth * ContractMonth /12;
                                // console.log('消费率小于1.4 upPrice = 定价 *经历月数 /12'+ upPrice);
                                // if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
                                //     downPrice = upPrice;
                                //     // console.log('消费率小于1.4 产品无最低价 downPrice '+ downPrice);
                                // }else{
                                    downPrice = upPrice * 0.8;
                                    // console.log('消费率小于1.4 产品最低价 downPrice = upPrice* 0.8:'+ downPrice);
                                // }
                            }else{
                                upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                                downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                // console.log('消费率大于1.4 upPrice'+ upPrice);
                                // console.log('消费率大于1.4 downPrice'+ downPrice);
                            }
                            // 市场多年保修价格开发 end DC 2023/01/19
                            }else{
                                // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                                // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                                //市场多年保修价格开发 DC 2023/1/30 start  设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                // console.log('设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数 upPrice'+ upPrice);
                                // console.log('设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数 downPrice'+ downPrice);
                                //市场多年保修价格开发 DC 2023/1/30 end
                            }
                            // gzw 20220630  实际联动6个月价格区分
                        }else{
                            upPrice = strMoney;
                            downPrice = strMoney * 0.8;
                            console.log('选择1');
                        }
                    }else{
                        upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
                        downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
                        console.log('选择2');
                    }
                }else{
                    //firstCCount ++;
                    upPrice = strMoney;
                    downPrice = strMoney * 0.8;
                    console.log('选择3');
                }
                // 上下限四舍五入
                upPrice = upPrice.toFixed(2);
@@ -626,14 +997,19 @@
                newCon = false;
            }
            strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
            Price_YearTXT = strMoney * 12;
            if (isnew == 'true') {
                strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
            } else {
                strMoney = month * strMoney + month2 * strMoney;
            }
            var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value(); 
            var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
            // console.log('***维修合同记录类型2'+LastMContractRecord);
            if(b != ''){
                conCCount ++;
                // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。)
@@ -679,21 +1055,124 @@
                        var nowdate = new Date();
                        lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                        nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
                        // console.log('**结束日',lastendDate);
                        //市场多年保修价格开发 DC 2023/1/30 start
                            var Maxcoefficient =0;
                            var Mincoefficient =0;
                            var ContractMonth = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
                            // console.log('***经历月数'+ContractMonth);
                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
                            // console.log('***消费率:'+AssetRate);
                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
                            if(AssetRate<= 50){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>50 &&AssetRate<=60){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>60 &&AssetRate<=70){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>70 &&AssetRate<=80){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>80 &&AssetRate<=90){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>90 &&AssetRate<=100){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>100 &&AssetRate<=110){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>110 &&AssetRate<=120){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>120 &&AssetRate<=130){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>130 &&AssetRate<=140){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>140){
                                Maxcoefficient = (1+0.3);
                                Mincoefficient = (1+0.2);
                            }
                            // 市场多年保修价格开发 DC 2023/1/30 end
                            console.log('***最高系数'+Maxcoefficient);
                            console.log('***最低系数'+Mincoefficient);
                        if(nowdate < Date.parse(lastendDate)){
                            upPrice = strMoney;
                            downPrice = strMoney * 0.8;
                            //设备小于两年半
                            // upPrice = strMoney;
                            // downPrice = strMoney * 0.8;
                        // 市场多年保修价格开发 start DC 2023/01/19
                            //市场多年保设备小于2年半
                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
                            // console.log('***设备型号'+AssetModelNo);
                            // console.log('***产品类型'+Category4);
                            //设备设备消费率小于1.4
                            if(AssetRate<140){
                                upPrice = VMassetListmonth *ContractMonth / 12;
                                // console.log('消费率小于1.4 upPrice = VMassetListmonth *month /12'+ upPrice);
                                // if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
                                //     downPrice = upPrice;
                                //     // console.log('消费率小于1.4 产品无最低价 downPrice '+ downPrice);
                                // }else{
                                    downPrice = upPrice * 0.8;
                                    // console.log('消费率小于1.4 产品最低价 downPrice = upPrice* 0.8:'+ downPrice);
                                // }
                            }else{
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                // console.log('消费率大于1.4 upPrice'+ upPrice);
                                // console.log('消费率大于1.4 downPrice'+ downPrice);
                            }
                        // 市场多年保修价格开发 end DC 2023/01/19
                        }else{
                            upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                            downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                            //设备大于两年半
                            // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                            // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                            //市场多年保修价格开发 DC 2023/1/30 start  设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
                            upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                            downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                            // console.log('设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数 upPrice'+ upPrice);
                            // console.log('设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数 downPrice'+ downPrice);
                            //市场多年保修价格开发 DC 2023/1/30 end
                        }
                        // gzw 20220630  实际联动6个月价格区分
                    }else{
                        upPrice = strMoney;
                        downPrice = strMoney * 0.8;
                        console.log('选择4');
                    }
                }else{
                    upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
                    downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
                    // console.log('选择5');
                }
            }else{
                if (isnew == 'true') {
@@ -712,39 +1191,42 @@
            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text(toNumComma(Price_YearTXT));
            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val(Price_YearTXT);
            if (!isDisabled) {
                // else{
                // 实际联动价格 start
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice));
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(downPrice);
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice));
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val(upPrice);
                // 实际联动价格 end
                // }
            }
            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
            //<!-- (2022年12月上线)故障品加费 start -->
            //<!-- (2022年12月上线)故障品加费 start -->
            Repair_Price_AutoPrice = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto'));
            Repair_Price_Auto = Repair_Price_AutoPrice.value();
            repairMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
            Repair_Price_pass = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val();
            console.log((i+1)+'号repairMoney='+repairMoney);
            console.log((i+1)+'号Repair_Price_Auto='+Repair_Price_Auto);
            // console.log((i+1)+'号repairMoney='+repairMoney);
            // console.log((i+1)+'号Repair_Price_Auto='+Repair_Price_Auto);
            if ((repairMoney+1)==1) {
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_Auto);
                console.log('repairMoney修改成功');
                // console.log('repairMoney修改成功');
            }
            if ((Repair_Price_pass+1)==1) {
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val(Repair_Price_Auto);
                console.log('Repair_Price_pass修改成功');
                // console.log('Repair_Price_pass修改成功');
            }
            repairMoney1 = localParseFloat(repairMoney);
            ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
            console.log('ISReducedpriceapproval=='+ISReducedpriceapproval);
            // console.log('ISReducedpriceapproval=='+ISReducedpriceapproval);
            var isDisabled = {!PageDisabled};
            if (ISReducedpriceapproval =='有八折以下待审批' || ISReducedpriceapproval =='是'|| isDisabled) {
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
            }else{
                console.log('无八折以下待审批和是的金额');
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", false);
            }
            ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
@@ -754,21 +1236,26 @@
                isresduce = isresduce+1;
            }
          
            console.log('初始化isresduce='+isresduce);
            ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
            // console.log('初始化isresduce='+isresduce);
            rppa =  document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto');
            ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
            // console.log('不可参保原因为:'+ResonCannotWarranty);
            // console.log('repairMoney执行次数为'+repairMoney);
            if(!(ResonCannotWarranty.indexOf("弃修") != -1)&&(repairMoney+1)==1){
                // if (!(situation.indexOf("修理中")!=-1)&& !(Agreed_Date.indexOf("为空")!=-1)) {
                    rppa.style.display = "none";
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val('');
                    // console.log('###修改成功');
                // }
            }
            situation = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_situation')).value();
            // Agreed_Date =  j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Agreed_Date')).value();
            console.log('situation='+situation);
            // console.log('situation='+situation);
            // console.log('Agreed_Date1='+Agreed_Date);
            if(!(ResonCannotWarranty.indexOf("弃修") != -1)&&(repairMoney+1)==1){
                    rppa.style.display = "none";
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val('');
                    console.log('###修改成功');
            }
            console.log('判断1'+(situation.indexOf("修理中")!=-1));
            // console.log('判断'+(Agreed_Date.indexOf("不为空")!=-1));
            // if ((situation.indexOf("修理中")!=-1)&& (Agreed_Date.indexOf("不为空")!=-1)) {
            //     console.log('开始操作2');
@@ -782,6 +1269,7 @@
        listSum = listSum + localParseFloat(toNum(strMoney));
        downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
        upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
    }
    
   
@@ -790,6 +1278,7 @@
    
    //j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPrice')).text(toNumComma(listSum));
    //j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetSumPriceHidden')).val(toNum(listSum));
    if (!isDisabled) {
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUp')).text(toNumComma(Math.round(upPriceSum)));
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceUpHidden')).val(toNum(Math.round(upPriceSum)));
@@ -821,16 +1310,21 @@
    }else{
        result = '续签合同';
    }
    console.log(result);
    // console.log(result);
    document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML = result;
    document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXTHidden").value = result;
    // 取消酸化水
    //NotUseOxygenatedWaterAmount(1);
    examinationPriceCal(cnt);
    getLastContractRate();
    // 报价规则改善 20230315 start
    // seamlessRenew(cnt);
    // 报价规则改善 20230315 end
    number1++;
}
function changeAsset(cnt) {
    console.log('执行了changeAsset');
    // alert(cnt);
    // 提交后就页面不计算了
    var isDisabled = {!PageDisabled};
@@ -910,6 +1404,10 @@
        var isManual = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':IsManual')).text();
        var isnew = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetNewHidden')).val();
        var assetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
        //市场多年保修价格开发 DC 2023/02/09 start
        var VMassetListmonth = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Maintenance_Price_Year__c')).val();
        //市场多年保修价格开发 DC 2023/02/09 end
        if (isManual == 'true') {
            var a = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Assert')).value();
            if (a != '') {
@@ -921,17 +1419,22 @@
                //}
                strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
                // alert(strMoney);
                var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
                // // alert(strMoney);
                // console.log('***维修合同记录类型3'+LastMContractRecord);
                Price_YearTXT = strMoney * 12;
                if (isnew == 'true') {
                    newCount ++;
                    strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
                } else {
                    newCon = false;
                    strMoney = month * strMoney + month2 * strMoney;
                }
                var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value();
                var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
                // var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
                if(b != ''){
                    conCCount ++;
                    // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。)
@@ -975,12 +1478,108 @@
                            var nowdate = new Date();
                            lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                            nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
                            if(nowdate < Date.parse(lastendDate)){
                                upPrice = strMoney;
                                downPrice = strMoney * 0.8;
                            //市场多年保修价格开发 DC 2023/1/30 start
                            var Maxcoefficient =0;
                            var Mincoefficient =0;
                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
                            console.log('***消费率:'+AssetRate);
                            var ContractMonth = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
                            if(AssetRate<= 50){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>50 &&AssetRate<=60){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>60 &&AssetRate<=70){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>70 &&AssetRate<=80){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>80 &&AssetRate<=90){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>90 &&AssetRate<=100){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>100 &&AssetRate<=110){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>110 &&AssetRate<=120){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>120 &&AssetRate<=130){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>130 &&AssetRate<=140){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>140){
                                Maxcoefficient = (1+0.3);
                                Mincoefficient = (1+0.2);
                            }
                            //市场多年保修价格开发 DC 2023/1/30 end
                            // console.log('***最高系数'+Maxcoefficient);
                            // console.log('***最低系数'+Mincoefficient);
                        if(nowdate < Date.parse(lastendDate)){
                            //设备小于两年半
                            // upPrice = strMoney;
                            // downPrice = strMoney * 0.8;
                        // console.log('***小于2年半')
                        // 市场多年保修价格开发 start DC 2023/01/19
                            //市场多年保设备小于2年半
                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
                            // console.log('***设备型号'+AssetModelNo);
                            // console.log('***产品类型'+Category4);
                            //设备设备消费率小于1.4
                            if(AssetRate<140){
                                upPrice = VMassetListmonth * ContractMonth / 12 ;
                                // console.log('消费率小于1.4 upPrice = VMassetListmonth *ContractMonth / 12'+ upPrice);
                                // if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
                                //     downPrice = upPrice;
                                //     // console.log('消费率小于1.4 产品无最低价 downPrice '+ downPrice);
                                // }else{
                                    downPrice = upPrice * 0.8;
                                    // console.log('消费率小于1.4 产品最低价 downPrice = upPrice* 0.8:'+ downPrice);
                                // }
                            }else{
                                upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                                downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                    // console.log('消费率大于1.4 upPrice'+ upPrice);
                                    // console.log('消费率大于1.4 downPrice'+ downPrice);
                            }
                            // 市场多年保修价格开发 end DC 2023/01/19
                            }else{
                                // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                                // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                                //市场多年保修价格开发 DC 2023/1/30 start  设备大于2年半 续签价格 =定价*消费率对应系数 / 12 *合同月数
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                //市场多年保修价格开发 DC 2023/1/30 end
                            }
                            // gzw 20220630  实际联动6个月价格区分
                        }else{
@@ -1041,14 +1640,17 @@
                newCon = false;
            }
            strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
            Price_YearTXT = strMoney * 12;
            if (isnew == 'true') {
                strMoney = month * strMoney + month2 * strMoney / {!isNewPriceAdj};
            } else {
                strMoney = month * strMoney + month2 * strMoney;
            }
            var b = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contract_No')).value(); 
            var LastMContractRecord = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContractRecord')).value();
            console.log('***维修合同记录类型4'+LastMContractRecord);
            if(b != ''){
                conCCount ++;
                // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。)
@@ -1094,12 +1696,108 @@
                        var nowdate = new Date();
                        lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                        nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
                         //市场多年保修价格开发 DC 2023/1/30 start
                            var Maxcoefficient =0;
                            var Mincoefficient =0;
                            var AssetRate = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':AssetConsumptionRateNew')).val());
                            console.log('***消费率:'+AssetRate);
                            var ContractMonth = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Contractrate')).text(AssetRate +'%');
                            if(AssetRate<= 50){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>50 &&AssetRate<=60){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>60 &&AssetRate<=70){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>70 &&AssetRate<=80){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>80 &&AssetRate<=90){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>90 &&AssetRate<=100){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>100 &&AssetRate<=110){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>110 &&AssetRate<=120){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>120 &&AssetRate<=130){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>130 &&AssetRate<=140){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>140){
                                Maxcoefficient = (1+0.3);
                                Mincoefficient = (1+0.2);
                            }
                            //市场多年保修价格开发 DC 2023/1/30 end
                            // console.log('***最高系数'+Maxcoefficient);
                            // console.log('***最低系数'+Mincoefficient);
                        if(nowdate < Date.parse(lastendDate)){
                            upPrice = strMoney;
                            downPrice = strMoney * 0.8;
                            //设备小于两年半
                            // upPrice = strMoney;
                            // downPrice = strMoney * 0.8;
                        // console.log('***小于2年半')
                        // 市场多年保修价格开发 start DC 2023/01/19
                            //市场多年保设备小于2年半
                            var AssetModelNo = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_Model_No__c')).value();
                            var Category4 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Category4__c')).value();
                            // console.log('***设备型号'+AssetModelNo);
                            // console.log('***产品类型'+Category4);
                            //设备设备消费率小于1.4
                            if(AssetRate<140){
                                upPrice = VMassetListmonth * ContractMonth /12;
                                // console.log('消费率小于1.4 upPrice = VMassetListmonth *ContractMonth /12'+ upPrice);
                               // if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
                                //     downPrice = upPrice;
                                //     // console.log('消费率小于1.4 产品无最低价 downPrice '+ downPrice);
                                // }else{
                                    downPrice = upPrice * 0.8;
                                    // console.log('消费率小于1.4 产品最低价 downPrice = upPrice* 0.8:'+ downPrice);
                                // }
                            }else{
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                // console.log('消费率大于1.4 upPrice'+ upPrice);
                                // console.log('消费率大于1.4 downPrice'+ downPrice);
                            }
                            // 市场多年保修价格开发 end DC 2023/01/19
                        }else{
                            upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                            downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                            // upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                            // downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                            //市场多年保修价格开发 DC 2023/1/30 start  设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
                            upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                            downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                            //市场多年保修价格开发 DC 2023/1/30 end
                        }
                        // gzw 20220630  实际联动6个月价格区分
                    }else{
@@ -1145,16 +1843,16 @@
            repairMoney1 = localParseFloat(repairMoney);
            ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
            ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
            console.log('ISReduced='+ISReduced);
            // console.log('ISReduced='+ISReduced);
            
            console.log('Repair_Price_Auto='+Repair_Price_Auto);
            console.log('第'+(i+1)+'个设备ISReducedpriceapproval1='+ISReducedpriceapproval1);
            console.log('repairMoney1='+repairMoney1);
            // console.log('Repair_Price_Auto='+Repair_Price_Auto);
            // console.log('第'+(i+1)+'个设备ISReducedpriceapproval1='+ISReducedpriceapproval1);
            // console.log('repairMoney1='+repairMoney1);
            
            Repair_Price_pass1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_pass')).val();
            Repair_Price_pass2 = localParseFloat(Repair_Price_pass1);
            console.log('结果='+(repairMoney1<Repair_Price_pass2));
            console.log('Repair_Price_pass2='+Repair_Price_pass2);
            // console.log('结果='+(repairMoney1<Repair_Price_pass2));
            // console.log('Repair_Price_pass2='+Repair_Price_pass2);
            if (repairMoney1> 0 && repairMoney1<(Repair_Price_Auto*0.80) && Repair_Price_Auto != null && isFSE == true) {
                 if (Repair_Price_pass1!=null && repairMoney1<Repair_Price_pass2) {
                    alert('由于存在折扣率超过20%以上的修理加费减价申请,请先点击“提交RC评估”按钮,待RC评估后服务管理部会推进审批');
@@ -1183,13 +1881,13 @@
            situation = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Asset_situation')).value();
            // Agreed_Date =  j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Agreed_Date')).value();
            console.log('situation='+situation);
            // console.log('situation='+situation);
            // console.log('Agreed_Date1='+Agreed_Date);
            //if(ResonCannotWarranty!=null&&!(ResonCannotWarranty.indexOf("弃修") != -1)){
           //         rppa.style.display = "none";
            //        j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val('');
            //       console.log('###修改成功');
           // }
            // if(!(ResonCannotWarranty.indexOf("弃修") != -1)){
            //         rppa.style.display = "none";
            //         // j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val('');
            //         // console.log('###修改成功');
            // }
            // if ((situation.indexOf("修理中")!=-1)&& (Agreed_Date.indexOf("为空")!=-1)) {
            //     console.log('开始操作1');
            //     rppa.style.display = "none";
@@ -1207,7 +1905,7 @@
        downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
        upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
    }
    console.log('改变金额isresduce='+isresduce);
    // console.log('改变金额isresduce='+isresduce);
     if (isresduce!=0) {
                toChange1();
        }else{
@@ -1252,6 +1950,33 @@
     
    examinationPriceCal(cnt);
    getLastContractRate();
    //上限合同 20230214 hql start
    var RequestquotationAmount = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:quotation_Amount')).val();
    console.log('申请报价金额='+RequestquotationAmount);
    var AssetRepairSumPrice    = j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text();
    console.log('合同设备修理总额='+AssetRepairSumPrice);
    Limit_Price_Amount = (localParseFloat(AssetRepairSumPrice)+localParseFloat(RequestquotationAmount))*1.3;
    Limit_Price_Amount = Math.round(Limit_Price_Amount);
    // console.log('取整1='+Math.round(124.5));
    // console.log('取整2='+Math.round(124.4));
    // console.log('取整3='+Math.round(124.6));
    Limit_Price_AmountOne =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).value();
    Limit_PriceHidden =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_PriceHidden')).value();
    // if (Limit_PriceHidden*1==0) {
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val(Limit_Price_Amount);
    // }
    Limit_PriceHidden2 =  j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price2Hidden')).value();
    if (Limit_PriceHidden2 == 'false') {
        // lpa =  document.getElementById('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount');
        // lpa.style.display = "none";
        // console.log('隐藏完毕');
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:Limit_Price_Amount')).val('');
    }
    console.log('上限金额为'+Limit_Price_Amount);
    //上限合同 20230214 hql end
    // 报价规则改善 20230315 start
    // seamlessRenew(cnt);
    // 报价规则改善 20230315 end
}
@@ -1481,8 +2206,136 @@
    //     return true;
    // }
}
// 报价规则改善 20230310 start
// function addMonths(yearMonthDay ,monthNum){
//     var arr=yearMonthDay.split( '/');
//     var year=parseInt(arr[0]);
//     var month=parseInt(arr[1]);
//     var day=parseInt(arr[2]);
//     month=month+monthNum;
//     if(month>12){//月份加
//         var yearNum=parseInt( (month-1)/12);
//         month=month%12==0?12 :month%12;
//         year+=yearNum;
//         }else if(month<=0){//月份减
//             month=Math.abs( month);
//             var yearNum=parseInt( (month+12)/12);
//             year-=yearNum;
//         }
//         month=month<10?"0"+month :month;
//         return year+"/"+month+"/"+day;
// }
// function Blankperiod(startdate,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,type){
//             var  downPrice = 0;
//             var  upPrice = 0;
//             var  isSeamlessRenew = 0;
//             Blank_period = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Blank_period')).value();
//             var lastendDate1= j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value()
//             var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
//             // console.log("lastendDate1="+lastendDate1);
//             var today = new Date();
//             if (lastendDate1.length !=0) {
//                 if (startdate == null) {
//                     // console.log(1);
//                      Blank_period=(today-lastendDate)/(3600*24*1000);
//                 }else{
//                     // console.log(2);
//                     Blank_period=(startdate-lastendDate)/(3600*24*1000);
//                 }
//                 j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Blank_period')).val(Blank_period);
//             }
//             if (Number(Blank_period)<15&&Blank_period.length != 0) {
//                 // console.log(3);
//                 j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Blank_period')).val('无缝续签');
//             }
//             Blank_period1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Blank_period')).value();
//             // console.log('Blank_period1='+Blank_period1);
//             // 2.无空白期设备是否算无缝续签设备 是否包含在无缝续签的报价判断中(首签的设备)?
//             if (Blank_period1 != '无缝续签' && Blank_period.length != 0) {
//                 isSeamlessRenew++;
//             }
//             // 1.实绩连动价格和设备参保定价 逻辑查看
//             upPrice1 = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
//             downPrice1 = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
//             // 定价8折
//             downPrice2 = strMoney * 0.8;
//             upPrice1 = upPrice1.toFixed(2);
//             upPrice2 = strMoney.toFixed(2);
//             downPrice1 = downPrice1.toFixed(2);
//             downPrice2 = downPrice2.toFixed(2);
//             // console.log('LastMContract_Price='+LastMContract_Price);
//             // console.log('upPrice1='+upPrice1);
//             // console.log('downPrice1='+downPrice1);
//             // console.log('upPrice2='+upPrice2);
//             // console.log('downPrice2='+downPrice2);
//             if (!isDisabled) {
//                 if (Blank_period1.length==0) {
//                     downPrice = downPrice2;
//                     upPrice = upPrice2;
//                 }
//                 if (Blank_period1.length!=0 && Number(Blank_period1)<180 || Blank_period1 == '无缝续签' ) {
//                     if (type == 1) {
//                         console.log('续签设备小于6个月');
//                         j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice1));
//                         j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice1));
//                     }
//                      downPrice = downPrice1;
//                      upPrice = upPrice1;
//                 }
//                 if (Blank_period1 != '无缝续签' && Number(Blank_period1)>180 && Number(Blank_period1)<365) {
//                     if (downPrice1<downPrice2) {
//                         if (type == 1) {
//                             console.log('续签设备6-12个月1');
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice2));
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice2));
//                         }
//                         downPrice = downPrice2;
//                         upPrice = upPrice2;
//                     }else{
//                          if (type == 1) {
//                             console.log('续签设备6-12个月2');
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice1));
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice1));
//                           }
//                         downPrice = downPrice1;
//                         upPrice = upPrice1;
//                     }
//                 }
//                 if (Blank_period1 != '无缝续签' && Number(Blank_period1)>365) {
//                     if (downPrice1<upPrice2) {
//                         if (type == 1) {
//                             console.log('续签设备12个月1');
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(upPrice2));
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice2));
//                         }
//                         downPrice = upPrice2;
//                         upPrice = upPrice2;
//                     }else{
//                         if (type == 1) {
//                             console.log('续签设备12个月2');
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(downPrice1));
//                             j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text(toNumComma(upPrice1));
//                         }
//                         downPrice = downPrice1;
//                         upPrice = upPrice1;
//                     }
//                 }
//             }
//         return downPrice+"/"+upPrice+"/"+isSeamlessRenew;
// }
// 报价规则改善 20230310 end
function changeEstiStartdate(val) {
    // 报价规则改善 20230310 start
       // var startday = addMonths(val,6);
       // var startday1 = addMonths(val,12);
       //  document.getElementById("startdateaddsix1").value = startday;
       //  document.getElementById("startdateaddsix2").value = startday;
       //  document.getElementById("startdateaddsix3").value = startday1;
       //  document.getElementById("startdateaddsix4").value = val;
    // 报价规则改善 20230310 end
    if ('{!SaveBtnDisabled}' == 'false') {
        j$(escapeVfId('allPage:allForm:contractstartdate')).val(val);
        changeContractStartdate(val);
@@ -1654,6 +2507,25 @@
            var dayStr = '00' + contractDate.getDate();
            dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
            var contractDateStr = contractDate.getFullYear() + '/' + monthStr + '/' + dayStr;
            //贸易合规 you 20230414 start
            var AccDealerBlacklist = j$(escapeVfId('allPage:allForm:AccDealerBlacklist')).value();//黑名单,警示名单
            var TradeComplianceStatusFlagFW = '{!$Label.TradeComplianceStatusFlagFW}';//贸易合规开关
            var IFTradeComplianceAlert = '{!$Label.IFTradeComplianceAlert}';//贸易合规提醒
            if(TradeComplianceStatusFlagFW=='true'){
            if(AccDealerBlacklist =='1'){
               alert('您所选择的客户(医院/经销商)存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+IFTradeComplianceAlert);
               var reflag = interceptsend();
               unblockUI();
               return null;
            }else if(AccDealerBlacklist =='2'){
               if (!confirm('您所选择的客户(医院/经销商)存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+IFTradeComplianceAlert)) {
                unblockUI();
                return null;
                }
            }
            }
            //贸易合规 you 20230414 end
            //var neDt = contractDate.getFullYear() + contractDate.getMonth() + contractDate.getDate();
            //monthStr = '00' + (oldDate.getMonth()+1);
@@ -1667,7 +2539,8 @@
            } else {
                var oldp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).value());
                var newp = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
                // console.log('oldp='+oldp);
                //  console.log('newp='+newp);
                if (oldp != newp) {
                    // 20201106 高章伟 提醒消息修改 start
                    j$(escapeVfId('allPage:allForm:changedAfterPrint')).val('true');
@@ -1858,6 +2731,10 @@
    <apex:inputHidden id="changedAfterPrint" value="{!changedAfterPrint}"/>
    <apex:inputHidden id="changedSubmitPrice" value="{!changedSubmitPrice}"/>
    <apex:inputHidden id="isSaveOrApproval" value="{!isSaveOrApproval}"/>
    <!-- 贸易合规 you 20230414-->
    <apex:inputHidden id="AccDealerBlacklist" value="{!contract.AccDealerBlacklist__c}"/>
    <apex:actionFunction name="interceptsend" action="{!interceptsend}"  oncomplete="unblockUI();"/>
    <!-- HWAG-B4R3SS  START 20181026-->
    <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,assetSection2,pageMessages,allBlock" onComplete="unblockUI();"></apex:actionFunction>
@@ -1944,7 +2821,7 @@
        <apex:pageBlockSection title="服务合同" id="contract">
        <!-- <apex:outputPanel/> -->
            <apex:outputPanel >
            <table align="center" width="100%"  style="border-collapse:separate; border-spacing:0px 10px" >
             <table align="center" width="100%"  style="border-collapse:separate; border-spacing:0px 10px" >
                <tr>    
                    <td width="50%" align="right"> <label class="labelCol vfLabelColTextWrap " style="margin-left:22%">报价编码</label> </td>
                    <td width="50%" align="left"> <apex:outputField value="{!estimate.Name}"/> </td>
@@ -2084,21 +2961,35 @@
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
                        
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Management_Code__c.label}</th>
                        <!-- <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th> -->
                        <!-- <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}</th> -->
                        <!-- 市场多年保修价格开发 DC 2023/02/20  start-->
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset__c.fields.IS_VMContract_Asset__c.label}</th>
                        <!-- 市场多年保修价格开发 DC 2023/02/20  end-->
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th>
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}</th>
                        <!-- 市场多年保修价格开发 DC 2023/1/30 start -->
                        <!-- <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Asset_Consumption_rate__c.label}</th>
 -->
                        <!-- 市场多年保修价格开发 DC 2023/1/30 end -->
                        <th style="width:70px" class="headerRow  booleanColumn">
                            <!-- 最近一期维修合同结束 -->
                            {!$ObjectType.Asset.fields.CurrentContract_End_Date__c.label}
                        </th>
                        <!-- 实绩联动价格计算 start -->
                        <th style="width:35px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Upper_price__c.label}</th>
                        <th style="width:35px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Adjustment_Lower_price__c.label}</th>
                        <!-- 实绩联动价格计算 end -->
                        <!-- 隐藏合同月数
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract__c.fields.Contract_Range__c.label}</th>-->
                        
                        <!-- <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</th>
                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</th>
@@ -2106,12 +2997,12 @@
                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Maintenance_Price_YearTXT__c.label}</th>-->
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price__c.label}</th>
                        <!-- (2022年12月上线)故障品加费 start -->
                        <th style="width:70px" class="headerRow ">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Repair_Price_Auto__c.label}</th>
                       <!-- (2022年12月上线)故障品加费 end -->
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Comment__c.label}</th>
                        <!-- (2022年12月上线)故障品加费 第三方回归 -->
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Third_Party_Return__c.label}</th>
                    </tr>
@@ -2173,17 +3064,53 @@
                               
                                <td class="dataCell" width="70px">
                                    <apex:outputField value="{!ar.rec.CurrentContract_F__r.Maintenance_Contract_No_F__c}" rendered="{!Not(ar.IsManual)}" id="Contract_No"/>
                                    <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.RecordType_DeveloperName__c}" id="LastMContractRecord"/>
                                    <apex:inputField value="{!ar.rec.CurrentContract_F_asset__r.endDateGurantee_Text__c}" id="endDateGurantee_Text" style="display: none" showDatePicker="false"/>
                                    <apex:inputHidden value="{!ar.rec.CurrentContract_F__c}" id="LastMContractID"/>
                                    <!-- 市场多年保价格开发 start 20223/01/17 维修合同/保有设备 设备消费率 -->
                                    <!-- <apex:outputField value="{!ar.rec.CurrentContract_F_asset__r.IS_VMContract_Asset__c}" rendered="{!Not(ar.IsManual)}" id="IS_VMContract_Asset"/> -->
                                    <apex:inputHidden value="{!ar.rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c}" id="AssetConsumptionRateNew"/>
                                    <apex:inputHidden value="{!ar.rec.CurrentContract_F_asset__r.Maintenance_Price_Year__c}" id="Maintenance_Price_Year__c"/>
                                 <!--    <apex:inputField value="{!ar.rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c}" id="AssetConsumptionRateNew2" style="display: none" showDatePicker="false" />
                                    <apex:outputText value="{!ar.rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c}" id="AssetConsumptionRateNew3" rendered="{!Not(ar.IsManual)}" style="display: none"/> -->
                                    <apex:inputField value="{!ar.rec.Product2.Asset_Model_No__c}" id="Asset_Model_No__c" style="display: none" showDatePicker="false"/>
                                    <apex:inputField value="{!ar.rec.Product2.Category4__c}" id="Category4__c" style="display: none" showDatePicker="false"/>
                                    <!-- 市场多年保价格开发 end 20223/01/17 设备消费率 -->
                                </td>
                                 <!-- <td class="dataCell" width="70px"> -->
                                    <!-- old: 直接拿保有设备的最近一期维修合同 -->
                                    <!-- <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_End_Date__c}" rendered="{!(Not(ar.IsManual)&& ar.rec.CurrentContract_F__c != null)}" id="End_Date" /> -->
                                    <!-- new: 在获取保有设备信息时直接判断保有设备的字段时间(保修期至/最近一期维修合同结束日) -->
                                   <!--  <apex:outputField value="{!ar.rec.CurrentContract_End_Date__c}" rendered="{!(Not(ar.IsManual) && ar.rec.CurrentContract_F__c != null )}" id="End_Date" />
                                </td> -->
                                 <!-- 市场多年保价格开发 end 20223/02/20 是否多年保设备 start -->
                                <td class="dataCell" width="90px" style="text-align:center">
                                    <apex:outputField value="{!ar.rec.CurrentContract_F_asset__r.IS_VMContract_Asset__c}" rendered="{!Not(ar.IsManual)}" id="IS_VMContract_Asset"/>
                                </td>
                                 <!-- 市场多年保价格开发 end 20223/02/20 是否多年保设备 end -->
                                <td class="dataCell" width="90px" style="text-align:right" >
                                    <apex:outputField value="{!ar.mcae.Asset_Consumption_rate__c}" rendered="{!Not(ar.IsManual)}" id="Contractrate"/>
                                    <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Contract_Range__c}" id="lastContRange"/>
                                </td>
                                <!-- 2023/03/21  !ar.rec.CurrentContract_F_asset__r.IS_VMContract_Asset__c 为true  保有设备结束时间:true:多年保:保修期至;false.最近一期维修合同结束日 -->
                                <td class="dataCell" width="70px">
                                    <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_End_Date__c}" rendered="{!(Not(ar.IsManual)&& ar.rec.CurrentContract_F__c != null)}" id="End_Date" />
                                    <!-- old: 直接拿保有设备的最近一期维修合同 -->
                                    <!-- <apex:outputField value="{!ar.rec.CurrentContract_F__r.Contract_End_Date__c}" rendered="{!(Not(ar.IsManual)&& ar.rec.CurrentContract_F__c != null)}" id="End_Date" /> -->
                                    <!-- new: 在获取保有设备信息时直接判断保有设备的字段时间(保修期至/最近一期维修合同结束日) -->
                                    <apex:outputField value="{!ar.rec.CurrentContract_End_Date__c}" rendered="{!(Not(ar.IsManual) && ar.rec.CurrentContract_F__c != null )}" id="End_Date" />
                                </td>
                                 <!-- 实绩联动价格计算 start -->
                                <td class="dataCell" width="35px">
                                    <apex:outputText value="{!ar.mcae.Adjustment_Upper_price__c}" id="Adjustment_Upper_price"/>
@@ -2192,6 +3119,10 @@
                                </td>
                                <td class="dataCell" width="35px" >
                                    <apex:outputText value="{!ar.mcae.Adjustment_Lower_price__c}" id="Adjustment_Lower_price"/>
                                  <!--   // 服务合同报价规则改善 20230227 start -->
                                      <!-- <apex:inputHidden value="{!ar.ISStandardPricing}" id="ISStandardPricing" /> -->
                                  <!-- // 服务合同报价规则改善 20230227 end -->
                                    <apex:inputHidden value="{!ar.mcae.LastMContract_Price__c}" id="LastMContract_Price"/>
                                    <apex:inputHidden value="{!ar.mcae.Adjustment_ratio_Lower__c}" id="Adjustment_ratio_Lower"/>
                                    <apex:inputHidden value="{!ar.mcae.Adjustment_Lower_price__c}" id="Adjustment_Lower_priceHidden"/>
@@ -2199,7 +3130,7 @@
                                        <apex:inputHidden value="{!ar.mcae.Estimate_List_Price__c}" id="assetListPriceHidden"/>
                                        <apex:inputHidden value="{!ar.mcae.Estimate_List_Price_Page__c}" id="assetListPricePageHidden" />
                                        <apex:inputHidden value="{!ar.rec.CurrentContract_F__r.Estimate_Num__c}" id="Estimate_NumHidden" />
                                    </apex:outputPanel>
                                    
                                    <apex:outputPanel layout="none" rendered="{!Not($ObjectType.Maintenance_Contract_Asset_Estimate__c.createable)}" >
@@ -2209,14 +3140,17 @@
                                    <!-- 20200103 Gzw 计算实际报价金额 start -->
                                        <apex:inputHidden value="{!ar.mcae.Estimate_Cost__c}" id="Estimate_Cost"/>
                                    <!-- 20200103 Gzw 计算实际报价金额 end -->
                                </td>
                                <td class="dataCell" width="35px" style="text-align:right" >
                                    <apex:inputField value="{!ar.mcae.Repair_Price__c}" id="repairPrice" style="ime-mode: disabled; width:95%; text-align:right;" onchange="changeAsset({!productCount})"/>
                                </td>
                               <!-- (2022年12月上线)故障品加费 start -->
                                <td class="dataCell" width="35px" style="text-align:right" >
                                    <apex:outputText value="{!ar.Repair_Price_Auto}" id="Repair_Price_Auto" style="width:95%; disabled:disabled;"/>
                                     <!-- // 报价规则改善 20230308 start -->
                                  <!--   <apex:inputField value="{!ar.mcae.Blank_period__c}" id="Blank_period" style="display:none"/> -->
                                     <!-- // 报价规则改善 20230308 start -->
                                    <apex:outputText value="{!ar.Repair_Price_Auto}" id="Repair_Price_Auto" style="width:95%; "/>
                                    <!-- <apex:inputHiddenalue="{!ar.rec.Reson_Can_not_Warranty__c}" id="ResonCannotWarranty"/> -->
                                    <!-- <apex:outputText value="{!ar.Agreed_Date}" id="Agreed_Date" style="width:95%;display: none;"/> -->
                                    <apex:inputField value="{!ar.mcae.Repair_Price_pass__c}" id="Repair_Price_pass" style="width:95%;display: none;"/>
@@ -2233,16 +3167,16 @@
                                    <apex:inputCheckbox value="{!ar.mcae.Third_Party_Return__c}" id="Third_Party_Return__c"/>
                                </td>
                            </tr>
                            <!-- LJPH-C9SCX7 【委托】合同无空白期的提醒  lt  20211221  start  -->
                            <!-- <script>
                                DefaultStartDate();
                            </script> -->
                            <!-- LJPH-C9SCX7 【委托】合同无空白期的提醒  lt  20211221  end  -->
                            <apex:variable value="{!cnt + 1}" var="cnt" />
                        </apex:repeat>
                </table>
                    </div>
<!-- </div>
@@ -2434,9 +3368,9 @@
                        <th style="text-align: center">申请报价金额</th>
                        <th style="text-align: center">合同设备修理总额</th>
                        <th style="text-align: center">合同总金额</th>
                        <!-- 上限合同 20230103 LY start -->
                        <!-- <th style="text-align: center">上限金额</th> -->
                        <!-- 上限合同 20230103 LY end -->
                        <!-- 上限合同 20230103 hql start -->
                        <th style="text-align: center">上限金额</th>
                        <!-- 上限合同 20230103 hql end -->
                    </tr>
                    <tr>
                        <td style="text-align: center">
@@ -2457,15 +3391,23 @@
                            <apex:inputHidden value="{!estimate.Asset_Repair_Sum_Price__c}" id="assetRepairSumPriceHidden" />
                        </td>
                        <td style="text-align: center">
                            <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal" />
                            <apex:outputField value="{!estimate.Maintenance_Price__c}" id="mainteReal"/>
                            <apex:inputHidden value="{!estimate.Maintenance_Price__c}" id="mainteRealHidden"/>
                            <apex:inputHidden value="{!OldMaintenancePrice}" id="oldMainteReal"/>
                        </td>
                        <!-- 上限合同 20230103 LY start -->
                       <!--  <td style="text-align: center">
                        <!-- 上限合同 20230103 hql start -->
                        <td style="text-align: center">
                            <apex:inputField value="{!estimate.Limit_Price_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="Limit_Price_Amount" />
                        </td> -->
                        <!-- 上限合同 20230103 LY end -->
                            <apex:inputHidden value="{!isLimitPrice}" id="Limit_Price2Hidden" />
                            <apex:inputHidden value="{!OldLimitPrice}" id="Limit_PriceHidden" />
                            <!-- // 报价规则改善 20230309 start  -->
                            <!-- <apex:inputHidden value="{!Is_Blank_period}" id="Is_Blank_period" />
                            <apex:inputField value="{!estimate.Maintenance_Contract__r.Past_Contract_end_day__c}" style="display:none"  id="PastContractendday" />
                            <apex:inputHidden value="{!estimate.renewTen_OFF__c}" id="renewTenOFF" />
                            <apex:inputHidden value="{!Cost_rate_ForecastF}" id="Cost_rate_ForecastF" /> -->
                            <!-- // 报价规则改善 20230309 end  -->
                        </td>
                        <!-- 上限合同 20230103 hql end -->
                    </tr>
                    <tr>
                        <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Service_discount_Rate__c.label}</th>
@@ -2511,6 +3453,71 @@
                        <td style="text-align: center"></td>
                    </tr>
                </table>
                <!-- // 报价规则改善 20230309 start  -->
               <!--  <table style="width:100%">
                    <tr>
                        <th style="text-align: center" colspan="3">请结合实际可以签约的日期,选择恰当的申请金额,以免后续空白期变化导致标准金额变化,再次申请价格延误时间</th>
                        <th style="text-align: center"></th>
                        <th style="text-align: center"></th>
                    </tr>
                    <tr>
                        <th style="text-align: center">本次计划【合同预定开始日】:<input type="text" id="startdateaddsix4" readonly="readonly" style="border: none;width:70px"></input> </th>
                        <th style="text-align: center">标准价格的最低价总额</th>
                        <th style="text-align: center">标准价格的最高价总额</th>
                    </tr>
                    <tr>
                        <td style="text-align: center"></td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceDown5" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceUp5" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">当【合同预定开始日】在<input type="text" id="startdateaddsix1" readonly="readonly" style="border: none;width:70px"></input> 之前</th>
                        <th style="text-align: center">标准价格的最低价总额</th>
                        <th style="text-align: center">标准价格的最高价总额</th>
                    </tr>
                    <tr>
                        <td style="text-align: center"></td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceDown4" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceUp4" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">当【合同预定开始日】在<input type="text" id="startdateaddsix2" readonly="readonly" style="border: none;width:70px"></input> 之后</th>
                        <th style="text-align: center">标准价格的最低价总额</th>
                        <th style="text-align: center">标准价格的最高价总额</th>
                    </tr>
                    <tr>
                        <td style="text-align: center"></td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceDown3" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceUp3" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">当【合同预定开始日】在<input type="text" id="startdateaddsix3" readonly="readonly" style="border: none;width:70px"></input> 之后</th>
                        <th style="text-align: center">标准价格的最低价总额</th>
                        <th style="text-align: center">标准价格的最高价总额</th>
                    </tr>
                    <tr>
                        <td style="text-align: center"></td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceDown2" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                        <td style="text-align: center">
                            CNY<input type="text" id="GuidePriceUp2" readonly="readonly" style="border: none;width:70px"></input>
                        </td>
                    </tr>
                </table> -->
                <!-- // 报价规则改善 20230309 end  -->
            </apex:outputPanel>
        </apex:pageblocksection>