buli
2023-03-15 291421a8735fbc7a1a821ffabd8dcca08bfe3b7e
force-app/main/default/pages/SelectAssetEstimateVM.page
@@ -1,4 +1,4 @@
<apex:page controller="SelectAssetEstimateVMController" tabStyle="Maintenance_Contract_Estimate__c" sidebar="false" showHeader="true" id="allPage" action="{!init}">
<apex:page controller="SelectAssetEstimateVMController" tabStyle="Maintenance_Contract_Estimate__c" lightningStylesheets="true" sidebar="false" showHeader="true" id="allPage" action="{!init}">
<head>
 <!-- <meta http-equiv="x-ua-compatible" content="ie=edge" /> -->
 <!-- <meta name="viewport" content="width=device-width, initial-scale=1" /> -->
@@ -7,8 +7,8 @@
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:includeScript value="/soap/ajax/29.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/29.0/apex.js"/>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<style type="text/css">
    table { border-collapse: collapse; }
    
@@ -40,14 +40,42 @@
var Confirm_EstimateRefresh = '已超过创建日3个月,是否更新报价?';
window.sfdcPage.appendToOnloadQueue(function() { calonLoad() });
var RCbottonChanged = 0;
// 故障品
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');
//     console.log('已提交RC 按钮不可见');
// }
function approvalJs() {
    approvalDate = new Date();
    var rowCnt = j$(escapeVfId('allPage:allForm:allBlock:assetSection:productCnt')).val();
    refreshAsset(rowCnt);
}
//故障品加费 RC 点击后不可见
function rcJs() {
    hasSendEmail = true;
    j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
    j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
    console.log('点击RC 按钮不可见hasSendEmail' +hasSendEmail);
}
//add by gwy 2021-01-27 start 提交时的提示框
function KindsAndMonths() {
   //   故障品加费 系统检查修理减价审批完成 Start
         ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
        console.log('点击提交待审批时 是否审批通过='+ISReduced);
        if( ISReduced == '审批中' || ISReduced == '有八折以下待审批'){
            alert('请通过修理减价审批再提交');
            // approvalbtntop1.style.display = "none";
            return false;
        }
    //   故障品加费 系统检查修理减价审批完成 end
    var months      = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).val());
    var contrNew    = document.getElementById("allPage:allForm:allBlock:contractInfo:Contract_TypeTXT").innerHTML;
    if(months>12 && months<60 && contrNew == '新品合同'){
@@ -57,7 +85,17 @@
            return false;  
        }
    }
        return true;
    // 先款后修-提交报价时如果是先款对象进行提示 thh 20220408 start
    var FirstParagraphEnd = j$(escapeVfId('allPage:allForm:allBlock:contract:FirstParagraphEnd'))[0].checked;
    if(FirstParagraphEnd){
        if (confirm('本次签约经销商是先款对象,请确认是否提交报价?')) {
            return true;
        }else{
            return false;
        }
    }
    // 先款后修-提交报价时如果是先款对象进行提示 thh 20220408 end
    return true;
}
//add by gwy 2021-01-27 end 提交时的提示框
@@ -79,6 +117,9 @@
    j$("#sbArea").fadeOut(500, function(){
        j$("#sbArea").remove();
    });
    console.log('发送邮件成功');
}
//<!-- HWAG-B4R3SS  START 20181026-->
function clearAndSearch() {
@@ -95,8 +136,31 @@
//<!-- HWAG-B4R3SS  END 20181026-->
// 初始化设定画面项目不可用
function pageSetDisabled(){
    // if (RCbottonChanged == 0) {
    //     console.log('test初始化');
        // 故障品加费 提交RC按钮不可见 start
        // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
        // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
        // 故障品加费 提交RC按钮不可见 end
    // }
    // 故障品加费 start
    var hasSendEmail ={!hasSendEmail};
    console.log('page hasSendEmail',hasSendEmail);
    if(hasSendEmail == true){
        j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
        j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
        console.log('已提交RC 按钮不可见 page set');
    }
    //故障品加费 end
    var isDisabled = {!PageDisabled};
    // ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
    // 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);
        j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).attr("disabled", true);
        j$(escapeVfId('allPage:allForm:allBlock:contract:monthRange')).attr("disabled", true);
@@ -113,6 +177,7 @@
            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetCheck')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':comment')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Third_Party_Return__c')).attr("disabled", true);
        }
        j$(escapeVfId('allPage:allForm:allBlock:appendCondition:Examination_Count')).attr("disabled", true);
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:disPercent')).attr("disabled", true);
@@ -181,6 +246,35 @@
    // 2021、8、26 合同报价页面的优化,无保有设备点检对象选择框变黑 fxk star
    // disable1();
    // 2021、8、26 合同报价页面的优化,无保有设备点检对象选择框变黑 fxk end
    console.log('ApprovalBtnDisabled=='+{!ApprovalBtnDisabled});
    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
@@ -212,6 +306,11 @@
            //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
            j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
            //故障品加费 RC按钮
            j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
            //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
            
            if (confirm(Confirm_EstimateRefresh)) {
@@ -244,6 +343,10 @@
            //j$(escapeVfId('allPage:allForm:decidebtn')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:savebtn')).attr("class", 'btnDisabled');
            j$(escapeVfId('allPage:allForm:approvalbtn')).attr("class", 'btnDisabled');
            //故障品加费RC按钮
            j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
            j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
            //j$(escapeVfId('allPage:allForm:decidebtn')).attr("class", 'btnDisabled');
            
            if (confirm('已超过创建日6个月,是否更新报价?')) {
@@ -261,6 +364,7 @@
    }
    
    if ('{!DecideBtnDisabled}' == 'false') {
        console.log('oldMainteReal修改完成');
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:oldMainteReal')).val(j$(escapeVfId('allPage:allForm:allBlock:contractInfo:mainteReal')).text());
    }
}
@@ -306,6 +410,28 @@
    //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);
}
@@ -329,13 +455,693 @@
    //contractStartDateChange();
    refreshAsset(cnt);
}
function toChange1(){
    tochange();
    ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
    console.log('方法1是否审批通过=='+ISReducedpriceapproval+'====================');
}
function toChange2(){
    tochange2();
    ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
    console.log('方法2是否审批通过=='+ISReducedpriceapproval+'==============');
}
var number1 = 0;
function refreshAsset(cnt) {
    console.log('执行refreshAsset');
    console.log('decide==='+{!DecideBtnDisabled});
     // alert(cnt);
    // 提交后就页面不计算了
    var isDisabled = {!PageDisabled};
    // 合同总理
    var newCount = 0;
    var isresduce = 0;
    var oyearCount = 0;
    var firstCCount = 0;
    var conCCount = 0;
    // row金額合計
    var repairSum = 0;
    var listSum = 0;
    // 新品合同 判断
    var newCon = true;
    var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
    //多年保续签合同数量 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());
    // 预定开始日-6个月
    startdate.setMonth(startdate.getMonth() - 6);
    // 申请日 当前日期
    if(approvalDate != ''){
        //申请日
        approvalDate = new Date(approvalDate.toLocaleDateString());
        if (Date.parse(approvalDate) < Date.parse(startdate)) {
            newCon = false;
        }
    }
    // 最高、最低价格合计
    var downPriceSum = 0;
    var upPriceSum = 0;
    // 合同月数乗算
    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;
    }
    for (var i = 0; i < cnt; i++) {
        var strMoney = 0;
        var repairMoney = 0;
        // 行项目 最高、最低价格合计
        // 续签价格取联动价格页面计算,首签或产品取 实际价格
        // 下线价格
        var downPrice = 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();
        //市场多年保修价格开发 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 != '') {
                // 所有设备按安装日、发货日(最早的),距离合同开始日6个月内都是新品合同
                //var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
                //isNewDate.setMonth(isNewDate.getMonth() + 6);
                //if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
                //    newCon = false;
                //}
                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个月后才可报价。)
                    // 2.一年以上的合同,在结束前6个月开始可以开放续签报价。
                    var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
                    var lastContRange = 0;
                    if(LastMContractRecord == 'VM_Contract'){
                        newCount++;
                        //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
                        GuranteeCount++;
                        newCon = false;
                        //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
                        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();
                    }
                    //最后结束日+1年
                    lastendDate.setMonth(lastendDate.getMonth() + 12);
                    if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
                        oyearCount ++;
                    }
                    // 取联动价格
                    // 上一期合同实际报价月额
                    //
                    var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
                    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());
                    //计算惩罚率
                    var Punish = calculateNtoMRatio( lastContRange,(month + month2));
                    if(Punish == 0){
                        return;
                    }
                    // 判断有无报价:没有按照标准价格实际联动
                    var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                    if(Estimate_Num == 0){
                        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);
                            //市场多年保修价格开发 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>0 &&AssetRate<=0.5){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>1.4){
                                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<1.4){
                                upPrice = VMassetListmonth * ContractMonth /12;
                                console.log('消费率小于1.4 upPrice = 定价 *经历月数 /12'+ upPrice);
                                if(AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF')){
                                    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);
                                //市场多年保修价格开发 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);
                downPrice = downPrice.toFixed(2);
                // 12个月合同金额
                //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) {
                    // // 服务合同报价规则改善 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 == '' && ISStandardPricing == '是') {
                    //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(upPrice));
                    //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(upPrice);
                    //     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);
                    // }
                    // // 服务合同报价规则改善 20230227 end
                    // 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);
                repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
            } else {
                // TODO 一時的な対応、なんで別行の金額リフレッシュされた?
                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text("");
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val();
                // 12个月合同金额
                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXT')).text("");
                //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceTXTHidden')).val();
                if (!isDisabled) {
                    // 实际联动价格 start
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text("");
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val();
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_price')).text("");
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Upper_priceHidden')).val();
                    // 实际联动价格 end
                 }
            }
        }
        else {
            // 所有设备按安装日、发货日(最早的),距离合同开始日6个月内都是新品合同
            var isNewDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':isNewDate')).value());
            isNewDate.setMonth(isNewDate.getMonth() + 6);
            if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
                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个月后才可报价。)
                // 2.一年以上的合同,在结束前6个月开始可以开放续签报价。
                var lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':End_Date')).value());
                var lastContRange = 0;
                if(LastMContractRecord == 'VM_Contract'){
                    newCount++;
                    //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
                    GuranteeCount++;
                    newCon = false;
                    //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
                    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();
                }
                //最后结束日+1年
                lastendDate.setMonth(lastendDate.getMonth() + 12);
                // alert('+++++++++--------' + lastendDate);
                // alert('+++++++++--------' + Date.parse(contractStartDate) + '77777' + Date.parse(lastendDate));
                if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
                    oyearCount ++;
                }
                // 取联动价格
                // 上一期合同实际报价月额
                //
                var LastMContract_Price = localParseFloat(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':LastMContract_Price')).val());
                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());
                //计算惩罚率
                var Punish = calculateNtoMRatio( lastContRange,(month + month2));
                if(Punish == 0){
                    return;
                }
                // 判断有无报价:没有按照标准价格实际联动
                var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                if(Estimate_Num == 0){
                    if(LastMContractRecord == 'VM_Contract'){
                        // alert('11111');
                        // 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);
                        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>0 &&AssetRate<=0.5){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>1.4){
                                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;
                        // 市场多年保修价格开发 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<1.4){
                                upPrice = VMassetListmonth *ContractMonth / 12;
                                console.log('消费率小于1.4 upPrice = VMassetListmonth *month /12'+ upPrice);
                                if(AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF')){
                                    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);
                            //市场多年保修价格开发 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') {
                    newCount ++;
                } else {
                    newCon = false;
                    firstCCount ++;
                }
                upPrice = strMoney;
                downPrice = strMoney * 0.8;
            }
            // 上下限四舍五入
            upPrice = upPrice.toFixed(2);
            downPrice = downPrice.toFixed(2);
            // 12个月合同金额
            //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) {
                // // 服务合同报价规则改善 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();
                // console.log('ISStandardPricing=='+ISStandardPricing);
                // if (LastMContractID == '' && ISStandardPricing == '是') {
                //     console.log('开始执行');
                //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_price')).text(toNumComma(upPrice));
                //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Adjustment_Lower_priceHidden')).val(upPrice);
                //     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);
                // }
                // // 服务合同报价规则改善 20230227 end
                // 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 -->
            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);
            if ((repairMoney+1)==1) {
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_Auto);
                // 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修改成功');
            }
            repairMoney1 = localParseFloat(repairMoney);
            ISReducedpriceapproval = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
            console.log('ISReducedpriceapproval=='+ISReducedpriceapproval);
            var isDisabled = {!PageDisabled};
            if (ISReducedpriceapproval =='有八折以下待审批' || ISReducedpriceapproval =='是'|| isDisabled) {
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", true);
            }else{
                j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).attr("disabled", false);
            }
            ISReducedpriceapproval1 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ISReducedpriceapproval1')).val();
            ISReduced = j$(escapeVfId('allPage:allForm:allBlock:ISReducedpriceapproval')).val();
            if (repairMoney1> 0 && (repairMoney1 <Repair_Price_Auto*0.80)) {
                isresduce = isresduce+1;
            }
            // 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('Agreed_Date1='+Agreed_Date);
            // console.log('判断'+(Agreed_Date.indexOf("不为空")!=-1));
            // if ((situation.indexOf("修理中")!=-1)&& (Agreed_Date.indexOf("不为空")!=-1)) {
            //     console.log('开始操作2');
            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).val(0);
            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(0);
            // }
        //<!-- (2022年12月上线)故障品加费 end -->
        }
        repairSum = repairSum + localParseFloat(repairMoney);
        listSum = listSum + localParseFloat(toNum(strMoney));
        downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
        upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
    }
    j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
    //j$(escapeVfId('allPage:allForm:allBlock:assetListSumNum')).text(toNumComma(listSum));
    //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)));
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDown')).text(toNumComma(Math.round(downPriceSum)));
        j$(escapeVfId('allPage:allForm:allBlock:contractInfo:GuidePriceDownHidden')).val(toNum(Math.round(downPriceSum)));
    }
    j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPrice')).text(toNumComma(repairSum));
    j$(escapeVfId('allPage:allForm:allBlock:contractInfo:assetRepairSumPriceHidden')).val(toNum(repairSum));
    var allcount = j$(escapeVfId('allPage:allForm:allBlock:productCount3')).value();
    var result = '';
    if (allcount == 0) {
        result = null;
    //如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 start
    }else if(GuranteeCount > 0 && GuranteeCount == allcount){
        result = '市场多年保续签合同';
    //如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 end
    }else if (newCount > 0 && newCount == allcount && newCon == true) {
        result = '新品合同';
    }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
        result = '首签合同';
    }else if(firstCCount > 0 && firstCCount == allcount){
        result = '首签合同';
    // 20220328 ljh update  LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备 start
    // }else if(oyearCount > 0 && oyearCount == conCCount){
    }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
    // 20220328 ljh update  LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备 start
        result = '非续签合同(空白期一年以上)';
    }else{
        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();
    number1++;
}
function changeAsset(cnt) {
    console.log('执行了changeAsset');
    // alert(cnt);
    // 提交后就页面不计算了
    var isDisabled = {!PageDisabled};
    // 合同总理
    var newCount = 0;
    var isresduce = 0;
    var oyearCount = 0;
    var firstCCount = 0;
    var conCCount = 0;
@@ -346,6 +1152,25 @@
    var newCon = true;
    var contractStartDate = new Date(j$(escapeVfId('allPage:allForm:contractstartdate')).value());
    //多年保续签合同数量 thh 20220316 start
    var GuranteeCount = 0;
    //多年保续签合同数量 thh 20220316 end
    //2022故障品加费 获取userInfo简档名称 是否为FSE start
    var isFSE = {!isFSE};
    // var hasSendEmail = {!hasSendEmail};
    // var isFSE = true;
    console.log('***isFSE',isFSE);
    // console.log('***hasSendEmail',hasSendEmail);
    // if(hasSendEmail == true){
    //     j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", true);
    //     j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btnDisabled');
    //     console.log('8折以下提交RC可见 ');
    // }
    //2022故障品加费 获取userInfo简档名称 end
    // 预定开始日
    var startdate = new Date(j$(escapeVfId('allPage:allForm:allBlock:contract:startdate')).value());
@@ -383,13 +1208,17 @@
        var downPrice = 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();
        //市场多年保修价格开发 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 != '') {
@@ -401,17 +1230,22 @@
                //}
                strMoney = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPriceHidden')).val();
                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个月后才可报价。)
@@ -422,6 +1256,10 @@
                    var lastContRange = 0;
                    if(LastMContractRecord == 'VM_Contract'){
                        newCount++;
                        //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
                        GuranteeCount++;
                        newCon = false;
                        //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
                        lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                        lastContRange = 36;
                    }else{
@@ -447,10 +1285,114 @@
                    var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                    if(Estimate_Num == 0){
                        if(LastMContractRecord == 'VM_Contract'){
                            //upPrice = (strMoney) * (1 + Adjustment_ratio_Upper/100);
                            //downPrice = (strMoney) * (1 + Adjustment_ratio_Lower/100);
                            upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                            downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                            // 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);
                            //市场多年保修价格开发 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>0 &&AssetRate<=0.5){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>1.4){
                                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<1.4){
                                upPrice = VMassetListmonth * ContractMonth / 12 ;
                                console.log('消费率小于1.4 upPrice = VMassetListmonth *ContractMonth / 12'+ upPrice);
                                if(AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF')){
                                    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);
                                //市场多年保修价格开发 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{
                            upPrice = strMoney;
                            downPrice = strMoney * 0.8;
@@ -509,14 +1451,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个月后才可报价。)
@@ -526,6 +1471,10 @@
                var lastContRange = 0;
                if(LastMContractRecord == 'VM_Contract'){
                    newCount++;
                    //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
                    GuranteeCount++;
                    newCon = false;
                    //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
                    lastendDate = new Date(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':endDateGurantee_Text')).value());
                    lastContRange = 36;
                }else{
@@ -533,6 +1482,8 @@
                }
                //最后结束日+1年
                lastendDate.setMonth(lastendDate.getMonth() + 12);
                // alert('+++++++++--------' + lastendDate);
                // alert('+++++++++--------' + Date.parse(contractStartDate) + '77777' + Date.parse(lastendDate));
                if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
                    oyearCount ++;
                }
@@ -551,10 +1502,115 @@
                var Estimate_Num = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Estimate_NumHidden')).val();
                if(Estimate_Num == 0){
                    if(LastMContractRecord == 'VM_Contract'){
                        //upPrice = (strMoney) * (1 + Adjustment_ratio_Upper/100);
                        //downPrice = (strMoney) * (1 + Adjustment_ratio_Lower/100);
                        upPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Upper/100);
                        downPrice = (assetListmonth * Punish) * (1 + Adjustment_ratio_Lower/100);
                        // alert('11111');
                        // 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);
                         //市场多年保修价格开发 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>0 &&AssetRate<=0.5){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>0.5 &&AssetRate<=0.6){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>0.6 &&AssetRate<=0.7){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>0.7 &&AssetRate<=0.8){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>0.8 &&AssetRate<=0.9){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>0.9 &&AssetRate<=1.0){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>1.0 &&AssetRate<=1.1){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.1 &&AssetRate<=1.2){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>1.2 &&AssetRate<=1.3){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>1.3 &&AssetRate<=1.4){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>1.4){
                                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<1.4){
                                upPrice = VMassetListmonth * ContractMonth /12;
                                console.log('消费率小于1.4 upPrice = VMassetListmonth *ContractMonth /12'+ upPrice);
                                if(AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF')){
                                    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);
                            //市场多年保修价格开发 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{
                        upPrice = strMoney;
                        downPrice = strMoney * 0.8;
@@ -589,19 +1645,86 @@
            }
            //j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPrice')).text(toNumComma(strMoney));
            j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':assetListPricePageHidden')).val(strMoney);
            //
            repairMoney = j$.trim(j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value());
            //<!-- (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();
            // console.log('repairMoney='+repairMoney);
            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('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);
            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评估后服务管理部会推进审批');
                        // j$(escapeVfId('allPage:allForm:emailSend')).attr("disabled", false);
                        // j$(escapeVfId('allPage:allForm:emailSend')).attr("class", 'btn');
                    // RCbottonChanged = 1;
                    // var change_cancel = document.getElementById("emailSend");
                    // change_cancel.style.display = "block";
                    repairMoney = Repair_Price_pass2;
                    j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(Repair_Price_pass2);
                 }
            }
             repairMoney2 = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).value();
            // console.log('repairMoney='+repairMoney);
            repairMoney3 = localParseFloat(repairMoney2);
             if (repairMoney3> 0 && (repairMoney3 <Repair_Price_Auto*0.80)) {
                if (Repair_Price_pass1!=null && repairMoney3<Repair_Price_pass2) {
                         isresduce = isresduce+1;
                }
            }
            ResonCannotWarranty = j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':ResonCannotWarranty')).value();
            rppa =  document.getElementById('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto');
            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('Agreed_Date1='+Agreed_Date);
            // 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";
            // }
            // if ((situation.indexOf("修理中")!=-1)&& (Agreed_Date.indexOf("不为空")!=-1)) {
            //     console.log('开始操作2');
            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':Repair_Price_Auto')).val(0);
            //     j$(escapeVfId('allPage:allForm:allBlock:assetSection:assetTable:' + i + ':repairPrice')).val(0);
            // }
        //<!-- (2022年12月上线)故障品加费 end -->
        }
        repairSum = repairSum + localParseFloat(repairMoney);
        listSum = listSum + localParseFloat(toNum(strMoney));
        downPriceSum = downPriceSum + localParseFloat(toNum(downPrice));
        upPriceSum =  upPriceSum + localParseFloat(toNum(upPrice));
    }
    // console.log('改变金额isresduce='+isresduce);
     if (isresduce!=0) {
                toChange1();
        }else{
            if(ISReduced !='' ){
                 toChange2();
            }
        }
    j$(escapeVfId('allPage:allForm:allBlock:assetRepairSumNum')).text(toNumComma(repairSum));
    //j$(escapeVfId('allPage:allForm:allBlock:assetListSumNum')).text(toNumComma(listSum));
    //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)));
@@ -615,8 +1738,11 @@
    var result = '';
    if (allcount == 0) {
        result = null;
    }else
    if (newCount > 0 && newCount == allcount && newCon == true) {
    //如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 start
    }else if(GuranteeCount > 0 && GuranteeCount == allcount){
        result = '市场多年保续签合同';
    //如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 end
    }else if (newCount > 0 && newCount == allcount && newCon == true) {
        result = '新品合同';
    }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
        result = '首签合同';
@@ -630,15 +1756,36 @@
    }else{
        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();
    //上限合同 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
}
function examinationPriceCal(cntWithKara) {
@@ -962,8 +2109,10 @@
function ComputeLTY() {
    var  urlNameJs = j$(escapeVfId('allPage:allForm:urlName')).val();
    urlNameJs = '{!$Label.ID_of_SelectAssetEstimate}'+urlNameJs ;
    var w = window.open(encodeURI(urlNameJs),'过去两年修理实绩','menubar=no,height=720,width=986');
    w.focus();
    //URF限次合同2期 LY 20220920 start
    // var w = window.open(encodeURI(urlNameJs),'过去两年修理实绩','menubar=no,height=720,width=986');
    // w.focus();
    //URF限次合同2期 LY 20220920 end
}
function recordNumChangeJs() {
    recordNumChangeAction();
@@ -1051,7 +2200,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');
@@ -1245,6 +2395,10 @@
    <!-- HWAG-B4R3SS  START 20181026-->
    <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,assetSection2,pageMessages,allBlock" onComplete="unblockUI();"></apex:actionFunction>
    <apex:actionfunction action="{!tochange}" name="tochange" rerender="ISReducedpriceapproval" oncomplete="unblockUI();">
        </apex:actionfunction>
        <apex:actionfunction action="{!tochange2}" name="tochange2" rerender="ISReducedpriceapproval" oncomplete="unblockUI();">
        </apex:actionfunction>
    <!-- HWAG-B4R3SS  END 20181026-->
    <apex:actionFunction name="ComputeLTYRepair" action="{!ComputeLTYRepair}" rerender="pageMessages" oncomplete="unblockUI();ComputeLTY();"/>
    <apex:actionFunction name="ShowLTYRepair" action="{!ShowLTYRepair}"  oncomplete="unblockUI();ComputeLTY();"/>
@@ -1464,7 +2618,16 @@
                        <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>
                        <!-- 市场多年保修价格开发 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>
                        <!-- 市场多年保修价格开发 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>
@@ -1485,7 +2648,15 @@
                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Maintenance_Contract_Asset_Estimate__c.fields.Estimate_List_Price_All__c.label}</th>
                        <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>
                    
                    <apex:variable value="{!1}" var="cnt" />
@@ -1503,8 +2674,13 @@
                                    <apex:inputField value="{!ar.mcae.Product_Manual__c}" id="Assert" style="width:90%;" rendered="{!ar.IsManual}" onchange="blockme();refreshProductData({!ar.lineNo});"/>
                                    <apex:inputText id="ProductId" value="{!ar.mcae.Product_Manual__c}" style="display:none;" disabled="true"/>
                                </td>
                                <!-- URF限次合同2期 LY 20220811 start -->
                                    <apex:inputHidden value="{!ar.rec.URF_Maintenance_Contract__r.Management_Code__c}" rendered="{!Not(ar.IsManual)}" id="URF_Contract_No"/>
                                <!-- URF限次合同2期 LY 20220811 end -->
                                <td class="dataCell" width="70px">
                                    <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" />
                                    <apex:outputField value="{!ar.rec.Asset_situation__c}" rendered="{!Not(ar.IsManual)}" id="Asset_situation"/>
                                </td>
                                <td class="dataCell" width="70px">
                                    <apex:outputLink value="/{!ar.recId}" rendered="{!Not(ar.IsManual)}" >{!ar.rec.SerialNumber}</apex:outputLink>
@@ -1540,10 +2716,35 @@
                               
                                <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>
                                 <!-- 市场多年保价格开发 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"/>
@@ -1559,6 +2760,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"/>
@@ -1566,6 +2771,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)}" >
@@ -1577,11 +2783,26 @@
                                    <!-- 20200103 Gzw 计算实际报价金额 end -->
                                </td>
                                <td class="dataCell" width="70px" style="text-align:right" >
                                    <apex:inputField value="{!ar.mcae.Repair_Price__c}" id="repairPrice" style="ime-mode: disabled; width:95%; text-align:right;" onchange="refreshAsset({!productCount});"/>
                                <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%; "/>
                                    <!-- <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;"/>
                                    <apex:inputHidden value="{!ar.mcae.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval1"/>
                                     <apex:outputText value="{!ar.rec.Reson_Can_not_Warranty__c}" id="ResonCannotWarranty" style="display:none;" rendered="{!Not(ar.IsManual)}" />
                                </td>
                                <!-- (2022年12月上线)故障品加费 end -->
                                <td class="dataCell" width="70px" style="text-align:right" >
                                    <apex:inputField value="{!ar.mcae.Comment__c}" id="comment" style="width:95%;"/>
                                </td>
                                <!--(2022年12月上线)故障品加费 第三方回归  -->
                                <td class="dataCell" width="40px" style="text-align:center;" >
                                    <apex:inputCheckbox value="{!ar.mcae.Third_Party_Return__c}" id="Third_Party_Return__c"/>
                                </td>
                            </tr>
@@ -1638,9 +2859,12 @@
                    <th width="90px" style="text-align:right">设备数量</th>
                    <td width="90px" style="text-align:right"><apex:outputtext value="{!productCount3}" id="productCount3"/></td>
                    <td width="25px">&nbsp;</td>
                    <th width="90px" style="text-align:right">
                        <apex:inputField value="{!estimate.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval" style="display:none"/></th>
                         <!-- <apex:inputField value="{!estimate.IS_Reduced_price_approval__c}" id="ISReducedpriceapproval"/></th> -->
                    <td width="25px">&nbsp;</td>
                    <!--<th width="90px" style="text-align:right">报价总额</th>
                    <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetListSumNum" ></span></th>-->
                    <td width="25px">&nbsp;</td>
                    <th width="90px" style="text-align:right">修理总额</th>
                    <th width="90px" style="text-align:right"><span id="allPage:allForm:allBlock:assetRepairSumNum" ></span></th>
                    <td width="95px">&nbsp;</td>
@@ -1661,7 +2885,7 @@
                        <th style="width:70px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.SerialNumber.label}</th>
                        <th class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Department_Name__c.label}</th>
                        <!-- <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.Installation_Site__c.label}</th> -->
                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty__c.label}</th>
                        <th style="width:90px" class="headerRow  booleanColumn">{!$ObjectType.Asset.fields.IF_Warranty_Service__c.label}</th>
                         <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
                        <th style="width:90px" class="headerRow  booleanColumn">主机/耗材</th>
                         <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---End -->
@@ -1679,7 +2903,7 @@
                        <apex:repeat value="{!assetsView}" var="ar" id="assetTable2">
                            <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
                                <td class="dataCell" width="25px">
                                    <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty__c = '否', 'true', 'false')}"/>
                                    <apex:inputCheckbox value="{!ar.rec_checkBox_c}" id="assetRowCheckbox2" disabled="{!IF(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty_Service__c = '否', 'true', 'false')}"/>
                                </td>
                                <td class="dataCell" width="25%">
                                    <apex:outputField value="{!ar.rec.name}" id="assetName"/>
@@ -1697,7 +2921,7 @@
                                    <apex:outputField value="{!ar.rec.Installation_Site__c}"/>
                                </td> -->
                                <td class="dataCell" width="90px" style="text-align:center">
                                    <apex:outputField value="{!ar.rec.IF_Warranty__c}"/>
                                    <apex:outputField value="{!ar.rec.IF_Warranty_Service__c}"/>
                                </td>
                                 <!-- //JZHG-BSDUT4 ---20200825---update By rentongxiao---Start -->
                                <td class="dataCell" width="90px" style="text-align:center">
@@ -1782,6 +3006,9 @@
                        <th style="text-align: center">申请报价金额</th>
                        <th style="text-align: center">合同设备修理总额</th>
                        <th style="text-align: center">合同总金额</th>
                        <!-- 上限合同 20230103 hql start -->
                        <th style="text-align: center">上限金额</th>
                        <!-- 上限合同 20230103 hql end -->
                    </tr>
                    <tr>
                        <td style="text-align: center">
@@ -1792,6 +3019,7 @@
                            <apex:outputField value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUp" />
                            <apex:inputHidden value="{!estimate.GuidePrice_Up__c}" id="GuidePriceUpHidden" />
                        </td>
                        <td style="text-align: center">
                            <!--<apex:inputField value="{!estimate.Request_quotation_Amount__c}" id="quotation_Amount" />-->
                            <apex:inputField value="{!estimate.Request_quotation_Amount__c}" style="ime-mode: disabled; text-align: right; width:100px" id="quotation_Amount" onchange="checkDiscount(this.value);"/>
@@ -1801,10 +3029,17 @@
                            <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 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" />
                            <apex:inputHidden value="{!isLimitPrice}" id="Limit_Price2Hidden" />
                            <apex:inputHidden value="{!OldLimitPrice}" id="Limit_PriceHidden" />
                        </td>
                        <!-- 上限合同 20230103 hql end -->
                    </tr>
                    <tr>
                        <th style="text-align: center">{!$ObjectType.Maintenance_Contract_Estimate__c.fields.Service_discount_Rate__c.label}</th>
@@ -1974,9 +3209,12 @@
                        <td>&nbsp;</td>
                        <td width="30px">&nbsp;</td>
                        <!-- <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!onclickCheckchangedAfterPrint('true','true')) return false;" oncomplete="unblockUI();"/></td> -->
                        <td><apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/></td>
                        <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="提交待审批" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();"/>
                        <!-- 故障修理费  添加提交修理减价按钮  disabled="true" -->
                        <td><apex:commandButton id="emailSend" action="{!sendEmail}" value="提交RC评估" rerender="allForm" disabled="{!SendEmailBtnDisabled}" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/></td>
                        <td>
                            <apex:commandButton id="approvalbtn1" action="{!toApprovalProcess}" value="提交修理减价审批" disabled="{!ApprovalBtnNewDisabled}" />
                        </td>
                        <td width="200px"><apex:commandButton id="approvalbtn" action="{!approvalProcess}" value="提交待审批" disabled="{!ApprovalBtnDisabled}" rerender="allForm" onclick="if (!KindsAndMonths()) return false;if (!EGFlgconfim()) return false;approvalJs();" oncomplete="unblockUI();toApprovalProcess();"/>
                        <!-- HWAG-B399Q8 2018/08/20 新增请提交待审批 提示字段 start-->
                        &nbsp; <apex:outputText style="color:red;font-size:20px;" value="请提交待审批" rendered="{!IS_Clone_After_Decide}"/>
                        <!-- HWAG-B399Q8 2018/08/20 新增请提交待审批 提示字段 end-->
@@ -1990,6 +3228,9 @@
                        <td><apex:outputField value="{!estimate.Contract_End_Date__c}" id="contractenddate"/></td>
                        <td>&nbsp;</td>
                        <td><apex:commandButton id="decidebtn" value="{!$Label.QuoteDecision_Button}" disabled="{!DecideBtnDisabled}" onclick="decideJs(); return false;"/></td>
                           <td>  <apex:commandButton id="savebtn" action="{!save}" value="{!$Label.Save_Button}" disabled="{!SaveBtnDisabled}" rerender="allForm" onclick="if (!EGFlgconfim()) return false;" oncomplete="unblockUI();"/>
                        </td>
                        <!-- <td><apex:commandButton id="decidebtn1" value="{!$Label.QuoteDecision_Button}" action="{!dosomething}"/></td> -->
                        <td style="text-align:right"><apex:commandButton id="undecidebtn" action="{!undecide}" value="取消{!$Label.QuoteDecision_Button}" disabled="{!UnDecideBtnDisabled}" rerender="allForm" onclick="blockme();" oncomplete="unblockUI();"/></td>
                    </tr>
                </table>
@@ -2144,7 +3385,7 @@
        // xud 20140529 ここは明細変更判断
        // xudan 20150729 ソート項目にIdを追加
        var sql = "SELECT Id, Asset__c, Asset__r.SerialNumber, Check_Result__c, Product_Manual__c,"
                + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c"
                + " Repair_Price__c, Comment__c, Maintenance_Contract_Estimate__r.Maintenance_Price__c,Third_Party_Return__c"
                + "  FROM Maintenance_Contract_Asset_Estimate__c"
                + " WHERE Maintenance_Contract_Estimate__c = '{!targetEstimateId}'"
                + " ORDER BY id,Asset__c,Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate";