buli
2022-05-13 08a21f49f2eaf9cfc19ceb67b196cc36ba689305
force-app/main/default/staticresources/NewQuoteEntryJS.bin
@@ -1,3300 +1,85 @@
// excel导入 按钮用,弹出自开发页面导入数据用
var QuotationCalculationFag = 'false';
function openQuoteExcelImport(e) {
    //openPopup('/apex/QuoteExcelImport', 'doc', 450, 210, 'width=450,height=210,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
    if (openQuoteExcelImportWindow == null || openQuoteExcelImportWindow.closed) {
        openQuoteExcelImportWindow = window.open('/apex/QuoteExcelImport', 'xlsdoc', 'width=450,height=210');
    } else {
        openQuoteExcelImportWindow.focus();
    }
}
// 废方法,应该不再使用了
function copyToClipboard(event, displayCost, quoid, currencyName) {
    //alert( 'copyToClipboard() executed!!');
    //alert( event);
    //alert( displayCost);
    //alert( quoid);
    //var hiddenQuoid = j$(escapeVfId( 'Page:mainForm:hiddenQuoid')).text();
    //alert( hiddenQuoid);
    if (quoid == null || quoid == '') {
        alert(Message_Please_Save_Quote);
        return null;
    }
    var records;
    try {
        sforce.connection.sessionId = Session_ID;
        records = sforce.apex.execute("NewQuoteEntryWebService", "getQuoteLineItem", { quoId: quoid });
    } catch (e) {
        alert(e.faultcode + ',' + e.faultstring);
    }
    var x;
    var targetString = 'No.\t编码\t状态\t名称\tListPrice\t数量\t单价\t规格\tTotal\t商品成本\t通货';
    for (var i = 0; i < records.length; i++) {
        x = records[i];
        //      targetString += '\r\n' + (i+1) + '\t' + x.ProductCode__c + '\t' + x.SFDA_Status__c + '\t' + x.Name__c + '\t' + toNumComma( x.ListPrice__c) + '\t' + x.Quantity + '\t' + toNumComma( x.UnitPrice__c) + '\t' + x.Qty_Unit__c + '\t' + toNumComma( x.Subtotal__c);
        targetString += '\r\n' + (i + 1) + '\t' + '=MID(( "_" & "' + x.ProductCode__c + '"),2,LEN("' + '_' + x.ProductCode__c + '")-1)' + '\t' + x.SFDA_Status__c + '\t' + x.Name__c + '\t' + toNumComma(x.ListPrice__c) + '\t' + x.Quantity + '\t' + toNumComma(x.UnitPrice__c) + '\t' + (x.Qty_Unit__c == null ? '' : x.Qty_Unit__c) + '\t' + toNumComma(x.UnitPrice__c * x.Quantity);
        if (displayCost == 'true') {
            targetString += '\t' + toNumComma(x.Cost__c) + '\t' + currencyName;
        }
    }
    try {
        clipboardData.setData("Text", targetString);
        alert(Message_Check_Your_Clipboard);
    } catch (e) {
        alert(e);
    }
}
// CHAN-B4YAB8 2018/11/09 格式化位一位小数 start
function toNumComma_One_digit(input) {
    return number_format_common(input, 1, ".", ",");
}
// CHAN-B4YAB8 2018/11/09 格式化位一位小数 end
// CHAN-B4YAB8 2018/11/09 业务机会产品的赠送、经销商小计、单价 start
function copyToClipboardNewQuoteEntry(event, displayCost, quoid, currencyName) {
    //alert( 'copyToClipboard() executed!!');
    //alert( event);
    //alert( displayCost);
    //alert( quoid);
    //var hiddenQuoid = j$(escapeVfId( 'Page:mainForm:hiddenQuoid')).text();
    //alert( hiddenQuoid);
    if (quoid == null || quoid == '') {
        alert(Message_Please_Save_Quote);
        return null;
    }
    var records;
    try {
        sforce.connection.sessionId = Session_ID;
        records = sforce.apex.execute("NewQuoteEntryWebService", "getQuoteLineItem", { quoId: quoid });
    } catch (e) {
        alert(e.faultcode + ',' + e.faultstring);
    }
    var x;
    var targetString = 'No.\t编码\t状态\t名称\tListPrice\t数量\t规格\t医院单价\t医院小计\t赠送\t经销商单价\t经销商小计';
    //外贸多年保 取消内外贸判断 2021/01/21 精琢技术 wql start
    // if(currencyName == 'CNY'){
    //     targetString += '\t多年保修\t保修\tNoDiscount小计';
    // }
    targetString += '\t多年保修\t保修\tNoDiscount小计';
    //外贸多年保 取消内外贸判断 2021/01/21 精琢技术 wql end
    targetString += '\t保修期\t通货';
    for (var i = 0; i < records.length; i++) {
        x = records[i];
        //      targetString += '\r\n' + (i+1) + '\t' + x.ProductCode__c + '\t' + x.SFDA_Status__c + '\t' + x.Name__c + '\t' + toNumComma( x.ListPrice__c) + '\t' + x.Quantity + '\t' + toNumComma( x.UnitPrice__c) + '\t' + x.Qty_Unit__c + '\t' + toNumComma( x.Subtotal__c);
        targetString += '\r\n' + (i + 1) + '\t' + '=MID(( "_" & "' + x.ProductCode__c + '"),2,LEN("' + '_' + x.ProductCode__c + '")-1)' + '\t' + x.SFDA_Status__c + '\t' + x.Name__c + '\t' + toNumComma(x.ListPrice__c) + '\t' + x.Quantity + '\t' + (x.Qty_Unit__c == null ? '' : x.Qty_Unit__c) + '\t' + toNumComma(x.UnitPrice__c) + '\t' + toNumComma(x.UnitPrice__c * x.Quantity) +
            '\t' + x.Present__c + '\t' + toNumComma_One_digit(x.AgencyUnitPrice__c) + '\t' + toNumComma_One_digit(x.AgencySubtotal__c);
        // 多年保修 start
        //外贸多年保 取消内外贸判断 2021/01/21 精琢技术 wql start
        // if(currencyName == 'CNY'){
        //     if(!x.warrantyType__c){
        //         x.warrantyType__c = '';
        //     }
        //     targetString += '\t' + x.multiYearWarranty__c + '\t' + x.warrantyType__c
        //     +'\t' + toNumComma(x.NoDiscountTotal__c);
        // }
        if (!x.warrantyType__c) {
            x.warrantyType__c = '';
        }
        targetString += '\t' + x.multiYearWarranty__c + '\t' + x.warrantyType__c +
            '\t' + toNumComma(x.NoDiscountTotal__c);
        //外贸多年保 取消内外贸判断 2021/01/21 精琢技术 wql end
        targetString += '\t' + x.GuaranteePeriod__c;
        // 多年保修 end
        ;
        if (displayCost == 'true') {
            targetString += '\t' + toNumComma(x.Cost__c) + '\t' + currencyName;
        }
    }
    try {
        var clipboard = new ClipboardJS('.btn', {
            text: function() {
                return targetString;
            }
        });
        clipboard.on('success', function(e) {
            alert(Message_Check_Your_Clipboard);
        });
        clipboard.on('error', function(e) {
            alert(e);
            //console.log(e);
        });
    } catch (e) {
        alert(e);
    }
}
// CHAN-B4YAB8 2018/11/09 业务机会产品的赠送、经销商小计、单价 end
var searchSetProductWindow = null;
// 正常报价跳转至选取产品配套页面
function searchSetProduct() {
    //openPopup('/apex/SearchSetProduct', 'search', 950, 450, 'width=950,height=450,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
    if (searchSetProductWindow == null || searchSetProductWindow.closed) {
        searchSetProductWindow = window.open('/apex/SearchSetProduct', 'SearchSetProduct', 'width=950,height=450');
    } else {
        searchSetProductWindow.focus();
    }
}
// SI报价跳转至选取产品配套页面
function searchSetProductSI() {
    //openPopup('/apex/SISearchSetProduct', 'search', 950, 450, 'width=950,height=450,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
    if (searchSetProductWindow == null || searchSetProductWindow.closed) {
        searchSetProductWindow = window.open('/apex/SISearchSetProduct', 'SISearchSetProduct', 'width=950,height=450');
    } else {
        searchSetProductWindow.focus();
    }
}
// 跳转至选择产品页面
function searchProduct(i, str) {
    // CNY USDを取得
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).attr('readonly', true);
    //    var trade = j$(escapeVfId("Page:mainForm:block:CurrencyIsoCode")).value();
    //    openPopup('/apex/SearchProduct?trade=' + trade + '&lineno=' + i + '&val=' + str, 'setsearch', 950, 450, 'width=950,height=450,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
    openPopup('/apex/SearchProduct?lineno=' + i + '&val=' + str, 'setsearch', 950, 450, 'width=950,height=450,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
    //var w = openPopup('/apex/SearchProduct?trade=' + trade + '&lineno=' + i + '&val=' + str, 'search','width=950,height=450');
    //w.focus();
}
// 打开报价PDF页面
function openQuotePage(b, b2, b3) {
    quoid = b3;
    if (b2 == 'true') {
function searchSetProduct(){
    var quoid = j$(escapeVfId("quoid")).value();
    var quoteLineSetNameDiscountJson = j$(escapeVfId("quoteLineSetNameDiscountJson")).value();
    var gainQuoteSetNameAndSetQty = '';
    if (quoteLineSetNameDiscountJson != '') {
        var quoteLineSetNameDiscountMap = JSON.parse(quoteLineSetNameDiscountJson);
        for (var i =1;i<30;i++) {
            var SetQty = j$(escapeVfId("Page:mainForm:block:SetQty" + i)).value();
            var SetName = j$(escapeVfId("Page:mainForm:block:SetName" + i)).value();
    } else {
        if (b == 'true') {
            //openPopup('/apex/contractdetailpdf?id=quoid');
            window.open('/apex/contractdetailpdf?id=' + quoid, 'Contract');
        } else {
            //openPopup('/apex/quotepdf?id=quoid');
            window.open('/apex/quotepdf?id=' + quoid, 'Quote');
        }
    }
}
jQuery(function() {
});
function reSet() {}
// 页面初始化方法
function calonLoad() {
    var productStatusUpdated = j$(escapeVfId('Page:mainForm:productStatusUpdated')).val();
    var pathname = window.location.pathname;
    if (pathname.indexOf('SI') != -1) {
        EstimationListPrice.call();
        calUnitPriceTotal.call();
        quoteTotalPrice.call();
        setOCMAmount.call();
        checkProductStatusValidPeriod();
        ProSFDC_Status_Update();
        // 多年保修 start
        calGuranteeAllFields();
        // 多年保修 end
    } else if (productStatusUpdated == 'true') {
        calPriceAll();
        setOCMAmount.call();
    } else {
        EstimationListPrice.call();
        calUnitPriceTotal.call();
        //HWAG-BLDE4M decide后成本为空 精琢技术 20200227 start
        setCostTatal();
        //HWAG-BLDE4M decide后成本为空 精琢技术 20200227 end
        checkProductStatusValidPeriod();
    }
    // 报价 精琢技术 fy 2021-09-06 start
    var IsQuoteTrial =j$(escapeVfId('Page:mainForm:block:IsQuoteTrial')).value();
    debugger
    if(IsQuoteTrial){
        j$(escapeVfId('Page:mainForm:block:SalesAmount1')).attr('disabled',true);
        // j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).attr('disabled',true);
    }else{
        j$(escapeVfId('Page:mainForm:block:SalesAmount1')).attr('disabled',false);
        // j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).attr('disabled',false);
    }
    // 报价 精琢技术 fy 2021-09-06 end
}
// 格式化数字
function number_format() {
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var a = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).value();
        if (a != '') {
            var x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPricetext')).text();
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPricetext')).text(toNumComma(x));
            var y = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPricetext')).text();
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(toNumComma(y));
        }
    }
}
/*
 * 计算隐藏 listPirce 汇总 和 UnitPrice(医院单价) 汇总
 * 先置为空,然后从新计算
 * 报价页面 逻辑优化, 先暂时注释掉,看看有什么影响
 */
function calUnitPriceTotal() {
    //j$(escapeVfId( 'ListPriceTotal')).val(0);
    //j$(escapeVfId( 'UnitPriceTotal')).val(0);
    var ListPriceTotal = 0.0,
        listPrice = 0.0;
    var unitPriceTotal = 0.0,
        unitPrice = 0.0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        listPrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        unitPrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value();
        ListPriceTotal += localParseFloat(listPrice);
        unitPriceTotal += localParseFloat(unitPrice);
    }
    j$(escapeVfId('ListPriceTotal')).val(ListPriceTotal);
    j$(escapeVfId('UnitPriceTotal')).val(unitPriceTotal);
}
// CHAN-B4YAB8 2018/9/28 经销商单价和小计 start
/*
  根据数量和经销商单价 计算经销商小计
 */
function calAgencyPrice(i) {
    var x, y, z, c;
    x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
    y = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).value();
    x = localParseInt(x);
    y = localParseFloat(y);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).val(x);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val(toNumComma(y));
    z = x * y;
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text(toNumComma_One_digit(z));
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val(toNum(z));
}
// CHAN-B4YAB8 2018/9/28 经销商单价和小计 end
/*
  取行项目的数量、医院单价、成本,算医院小计、成本小计
 */
function calPrice(i) {
    var x, y, z, c;
    x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
    y = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value();
    c = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).value();
    x = localParseInt(x);
    y = localParseFloat(y);
    c = localParseFloat(c);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).val(x);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(toNumComma(y));
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).val(toNum(c));
    z = x * y;
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(toNumComma(z));
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val(toNum(z));
    z = x * c;
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).val(toNum(z));
    updateNoDiscountPricetotal.call();
    EstimationListPrice.call();
    calUnitPriceTotal.call();
    quoteTotalPrice.call();
}
//HWAG-BLWB9F 询价报价:多年保产品未登录计提金额时不可报价 精琢技术  20200224 start
function CheckForGuranteeType() {
    var trade = j$(escapeVfId("Page:mainForm:block:CurrencyIsoCode")).val();
    var GuranteeType, ProductGuranteePrice, cnt;
    cnt = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        GuranteeType = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteeType')).value();
        ProductGuranteePrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ProductGuranteePrice__c')).value();
        //不用区分外贸 因为外贸的报价金额为空 是不能加载到行项目上的
        //   if((GuranteeType == '市场' ||GuranteeType == '服务' ) && ProductGuranteePrice <= 0){
        //         cnt =cnt+1;
        // }
        if (trade) {
            // if(trade == "CNY"){
            //     if((GuranteeType == '市场' ||GuranteeType == '服务' ) && ProductGuranteePrice <= 0){
            //     cnt =cnt+1;
            //     }
            // }else if(trade == "USD"){
            // }
            //外贸多年保 精琢技术 wql 2021/01/18 start
            if ((GuranteeType == '市场' || GuranteeType == '服务') && ProductGuranteePrice <= 0) {
                cnt = cnt + 1;
            }
            //外贸多年保 精琢技术 wql 2021/01/18 end
        }
    }
    if (cnt > 0) {
        return true;
    } else {
        return false;
    }
}
//SWAG-C3BAVY 【委托】询价新旧code 替换 精琢技术 wql 20210607 start
//检查报价行的NMPA状态
function checkNMPA() {
    var cnt = 0;
    var nmpa;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        nmpa = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Status__c')).value();
        if (nmpa == '停止') {
            cnt = cnt + 1;
            break;
        }
    }
    if (cnt > 0) {
        return true;
    } else {
        return false;
    }
}
//SWAG-C3BAVY 【委托】询价新旧code 替换 精琢技术 wql 20210607 end
function CheckForCost() {
    var trade = j$(escapeVfId("Page:mainForm:block:CurrencyIsoCode")).val();
    var Cost, cnt, name;
    cnt = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        Cost = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).value();
        name = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).value();
        if (name && Cost <= 0) {
            cnt = cnt + 1;
        }
        //  if(trade == "CNY") {
        // } else if(trade == "USD"){
        //     if(!GuranteeType){
        //         cnt =cnt+1;
        //     }
        // }
    }
    if (cnt > 0) {
        return true;
    } else {
        return false;
    }
}
//HWAG-BLWB9F 询价报价:多年保产品未登录计提金额时不可报价 精琢技术  20200224 end
//CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 start
function checkAgencyPrice() {
    var agencyPrice, cnt, agencyPriceTotal, assertModel;
    cnt = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        assertModel = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).value();
        agencyPrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).value();
        agencyPrice = localParseFloat(agencyPrice);
        agencyPriceTotal = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).value();
        agencyPriceTotal = localParseFloat(agencyPriceTotal);
        if (assertModel) {
            if (agencyPrice <= 0 || agencyPriceTotal <= 0) {
                cnt = cnt + 1;
            }
        }
    }
    if (cnt > 0) {
        return true;
    } else {
        return false;
    }
}
//CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 end
function AlertForCFDA() {
    var SFDA_Status__c, cnt;
    cnt = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        SFDA_Status__c = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Status__c')).value();
        if (SFDA_Status__c == '失效-重新申请中' || SFDA_Status__c == '失効(再申請中)') {
            cnt = cnt + 1;
        }
    }
    if (cnt > 0) {
        return true;
    } else {
        return false;
    }
}
function AlertForUpdate() {
    var StatusCheck;
}
/*
    根据行项目上产品的信息 更新多年保修行项目所有字段, 并且更新No Discount Price合计
 */
function calPriceAll() {
    // 多年保修 start
    calGuranteeAllFields.call();
    // 多年保修 end
    var x, y, z, c;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        x = localParseInt(x);
        if (x > 0) {
            y = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value();
            c = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).value();
            y = localParseFloat(y);
            c = localParseFloat(c);
            z = x * y;
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(toNumComma(z));
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val(toNum(z));
            z = x * c;
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).val(toNum(z));
        }
    }
    EstimationListPrice.call();
    calUnitPriceTotal.call();
    quoteTotalPrice.call();
    quoteAgencyTotalPriceAction.call();
    AgencyDiscountCalculation1.call();
}
// 多年保修  start
// 计算 No Discount Price合计
function updateNoDiscountPricetotal() {
    var noDiscountPriceTotal = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        //行项目 no discount price:
        var noDiscountPrice =
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val();
        noDiscountPrice = localParseFloat(noDiscountPrice);
        // 数量
        var Quantity =
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        Quantity = localParseFloat(Quantity);
        noDiscountPriceTotal = noDiscountPriceTotal + noDiscountPrice * Quantity;
        var index = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':indexNo')).text();
        if (document.getElementById('Page:mainForm:block:lists:' + i + ':warranty2:NoDiscountTotal') != null &&
            i + 1 == index) {
            document.getElementById('Page:mainForm:block:lists:' + i +
                    ':warranty2:NoDiscountTotal').value =
                toNumComma(noDiscountPrice * Quantity);
        }
    }
    // 设置多年保修价格合计
    j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val(noDiscountPriceTotal);
    j$(escapeVfId('Page:mainForm:block:contractWarranty:MultiYearWarrantyTotalPrice_out')).text(
        toNumComma(noDiscountPriceTotal));
}
// 多年保修  end
// 更改第一经销商 经销商折扣
function callFromAgencyDiscount() {
    setSalesAmount1();
    salesProfit1();
    setOCMAmount();
    quoteAgencyTotalPriceAction1('经销商');
}
function setSalesAmount1() {
    var AgencyDiscount = j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).value();
    if (AgencyDiscount.length != 0) {
        var Estimation_List_Price = j$(escapeVfId('Page:mainForm:block:Estimation_List_Price')).value();
        AgencyDiscount = AgencyDiscount.replace(/ /g, "");
        if (Estimation_List_Price.length != 0) {
            AgencyDiscount = localParseFloat(AgencyDiscount);
            Estimation_List_Price = localParseFloat(Estimation_List_Price);
            // 多年保修 start
            //no discount price 合计
            var noDiscountPriceTotal =
                j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val();
            noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
            // 第三方产品报价总额
            var thirdPartyEstimation_List_Price = 0;
            var price = 0;
            var Quantity = 0;
            for (var i = 0; i < QuoteEntryMaxLine; i++) {
                var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
                //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
                var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
                if (backbutton == '') {
                    VenderName = '';
                }
                //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
                if (VenderName != '' && VenderName != 'OSH') {
                    price = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
                    price = localParseFloat(price);
                    Quantity = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
                    Quantity = localParseInt(Quantity);
                    thirdPartyEstimation_List_Price =
                        thirdPartyEstimation_List_Price + price * Quantity;
                }
            }
            thirdPartyEstimation_List_Price = localParseFloat(thirdPartyEstimation_List_Price);
            var SalesAmount1 = AgencyDiscount *
                (Estimation_List_Price - thirdPartyEstimation_List_Price) /
                100 + thirdPartyEstimation_List_Price + noDiscountPriceTotal;
            // 多年保修 end
            j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val(toNumComma(SalesAmount1));
        } else {
            j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val(toNumComma(0));
        }
    } else {
        j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val(toNumComma(0));
    }
}
// 取消合同市场保修
function callFromCancelgurantee_MD() {
    calPriceAll.call();
}
/*
    根据行项目上产品的信息 更新多年保修所有字段,
    如果no discount price  变多, 则unit price + no discount price
     如果no discount price  变少, 则unit price- 老 no discount price
 */
function calGuranteeAllFields() {
    var CurrencyIsoCode = j$(escapeVfId('Page:mainForm:block:CurrencyIsoCode')).val();
    // if(CurrencyIsoCode != 'CNY'){
    //     return;
    // }
    // 合同保修期
    var AllGurantee_Period = j$(escapeVfId('Page:mainForm:block:AllGurantee_Period')).val();
    // 是否取消市场多年保修
    var contractmultiYearWarranty = true;
    if (document.getElementById('Page:mainForm:block:contractWarranty:multiYearWarranty') != null) {
        contractmultiYearWarranty = document.getElementById('Page:mainForm:block:contractWarranty:multiYearWarranty').checked;
    }
    var MultiYearWarrantyTotalPrice__c = 0.00;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var index = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':indexNo')).text();
        if (i + 1 == index) {
            // 产品保修类型
            var GuranteeType =
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteeType')).val();
            // 保修类型
            var warrantyType = '';
            // 产品保修期
            var ProductEntend_gurantee_period = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ProductEntend_gurantee_period_all__c')).val();
            // 产品是否耗材
            //var ProductIfConsumable__c = j$(escapeVfId('Page:mainForm:block:lists:'+ i + ':ProductIfConsumable__c')).val();
            // 产品计提金额
            var ProductGuranteePrice__c = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ProductGuranteePrice__c')).val();
            // 产品 service Price
            var ServicePrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':productServicePrice__c')).value();
            // 保修
            var multiYearWarranty = false;
            // 是否取消保修
            var If_Cancel_Guarantee = false;
            //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql start
            var CanNotCancelledGurantee = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CanNotCancelledGurantee__c')).val();
            //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql end
            // 老 no discount price
            var oldServicePrice =
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val();
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val(0);
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val('');
            // NoDiscount小计
            var NoDiscountTotal = 0;
            if (GuranteeType == '服务') {
                multiYearWarranty = true;
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val('服务多年保修');
                warrantyType = '服务多年保修';
            } else if (GuranteeType == '市场' && contractmultiYearWarranty == false) {
                multiYearWarranty = true;
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val(ServicePrice);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val('市场多年保修');
                warrantyType = '市场多年保修';
                // 数量
                var Quantity =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
                MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c +
                    localParseFloat(ServicePrice) * localParseFloat(Quantity);
                NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity);
            }
            //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql start
            else if (GuranteeType == '市场' && contractmultiYearWarranty == true && CanNotCancelledGurantee == 'true') {
                multiYearWarranty = true;
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val(ServicePrice);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val('市场多年保修');
                warrantyType = '市场多年保修';
                // 数量
                var Quantity =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
                MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c +
                    localParseFloat(ServicePrice) * localParseFloat(Quantity);
                NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity);
            }
            //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql end
            else if (GuranteeType == '市场') {
                If_Cancel_Guarantee = true;
            }
            if (document.getElementById('Page:mainForm:block:lists:' + i + ':warranty2:NoDiscountTotal') != null) {
                document.getElementById('Page:mainForm:block:lists:' + i +
                        ':warranty2:NoDiscountTotal').value =
                    toNumComma(NoDiscountTotal);
            }
            // 更新后的 no discount price
            var newServicePrice =
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val();
            newServicePrice = localParseFloat(newServicePrice);
            oldServicePrice = localParseFloat(oldServicePrice);
            if (newServicePrice != oldServicePrice) {
                var unitPrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val();
                unitPrice = localParseFloat(unitPrice);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(
                    toNum(unitPrice + newServicePrice - oldServicePrice));
            }
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':If_Cancel_Guarantee__c')).val(If_Cancel_Guarantee);
            // 设置保修
            if (document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty') !=
                null) {
                document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty').checked = multiYearWarranty;
            }
            var GuranteePrice = 0;
            //j$(escapeVfId('Page:mainForm:block:lists:'+ i + ':provistonPeriod__c')).val(0);
            // 计提年限
            var provistonPeriod = 0;
            // 根据产品信息设置保修年限 和计提金额
            if (GuranteeType == '服务') {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(ProductEntend_gurantee_period | 0);
                //j$(escapeVfId('Page:mainForm:block:lists:'+ i + ':provistonPeriod__c')).val(ProductEntend_gurantee_period | 0);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(ProductEntend_gurantee_period | 0);
                GuranteePrice = ProductGuranteePrice__c;
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteePrice__c')).val(GuranteePrice);
                provistonPeriod = ProductEntend_gurantee_period;
                //外贸多年保 精琢技术 wql 2021/01/18 start
            } else if (GuranteeType == '市场') {
                //外贸多年保 精琢技术 wql 2021/01/18 end
                //}else if (GuranteeType == '市场' && CurrencyIsoCode == 'CNY'){
                if (contractmultiYearWarranty == false) {
                    if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) {
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(ProductEntend_gurantee_period | 0);
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(ProductEntend_gurantee_period | 0);
                    } else {
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(AllGurantee_Period);
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(AllGurantee_Period);
                    }
                    //j$(escapeVfId('Page:mainForm:block:lists:'+ i + ':provistonPeriod__c')).val(ProductEntend_gurantee_period | 0);
                    provistonPeriod = ProductEntend_gurantee_period;
                    GuranteePrice = ProductGuranteePrice__c;
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteePrice__c')).val(GuranteePrice);
                }
                //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql start
                else if (contractmultiYearWarranty == true && CanNotCancelledGurantee == 'true') {
                    if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) {
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(ProductEntend_gurantee_period | 0);
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(ProductEntend_gurantee_period | 0);
                    } else {
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(AllGurantee_Period);
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(AllGurantee_Period);
                    }
                    //j$(escapeVfId('Page:mainForm:block:lists:'+ i + ':provistonPeriod__c')).val(ProductEntend_gurantee_period | 0);
                    provistonPeriod = ProductEntend_gurantee_period;
                    GuranteePrice = ProductGuranteePrice__c;
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteePrice__c')).val(GuranteePrice);
                }
                //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql end
                else {
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(1);
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(1);
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteePrice__c')).val(GuranteePrice);
                }
            } else {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(AllGurantee_Period);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(AllGurantee_Period);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteePrice__c')).val(GuranteePrice);
            }
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':provistonPeriod__c')).val(provistonPeriod | 0);
        }
    }
    // 设置多年保修价格合计
    j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val(MultiYearWarrantyTotalPrice__c);
    j$(escapeVfId('Page:mainForm:block:contractWarranty:MultiYearWarrantyTotalPrice_out')).text(
        toNumComma(MultiYearWarrantyTotalPrice__c));
}
// 更新多年保修 保修期
function calGuranteePeriod() {
    var CurrencyIsoCode = j$(escapeVfId('Page:mainForm:block:CurrencyIsoCode')).val();
    // if(CurrencyIsoCode != 'CNY'){
    //     return;
    // }
    // 合同保修期
    var AllGurantee_Period = j$(escapeVfId('Page:mainForm:block:AllGurantee_Period')).val();
    var Gurantee_Period__c = j$(escapeVfId('Page:mainForm:block:Gurantee_Period__c')).val();
    // 合同保修期不能设为空
    if (!AllGurantee_Period) {
        j$(escapeVfId('Page:mainForm:block:AllGurantee_Period')).val(Gurantee_Period__c);
        alert('保修期请不要选择空!');
        return;
    }
    j$(escapeVfId('Page:mainForm:block:Gurantee_Period__c')).val(AllGurantee_Period);
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var index = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':indexNo')).text();
        if (i + 1 == index) {
            // 保修
            var multiYearWarranty = true;
            if (document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty') !=
                null) {
                multiYearWarranty =
                    document.getElementById('Page:mainForm:block:lists:' +
                        i + ':warranty:itemMultiYearWarranty').checked;
            }
            // 保修类型
            var warrantyType =
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val();
            // 产品保修类型
            var GuranteeType =
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuranteeType')).val();
            // 产品保修期
            var ProductEntend_gurantee_period = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ProductEntend_gurantee_period_all__c')).val();
            // 计提年限
            var provistonPeriod = 0;
            // 根据产品信息设置保修年限
            if (GuranteeType == '服务') {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(ProductEntend_gurantee_period | 0);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(ProductEntend_gurantee_period | 0);
                provistonPeriod = ProductEntend_gurantee_period;
                //外贸多年保 精琢技术 wql 2021/01/18 start
            } else if (GuranteeType == '市场') {
                //外贸多年保 精琢技术 wql 2021/01/18 end
                //}else if ( GuranteeType == '市场' && CurrencyIsoCode == 'CNY'){
                if (multiYearWarranty == true) {
                    if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) {
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(ProductEntend_gurantee_period | 0);
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(ProductEntend_gurantee_period | 0);
                    } else {
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(AllGurantee_Period);
                        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(AllGurantee_Period);
                    }
                    provistonPeriod = ProductEntend_gurantee_period;
            if (SetName != '' ) {
                if (gainQuoteSetNameAndSetQty == '') {
                    gainQuoteSetNameAndSetQty = SetName + ',' + SetQty + ',' + quoteLineSetNameDiscountMap[SetName]
                } else {
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(1);
                    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(1);
                   gainQuoteSetNameAndSetQty = gainQuoteSetNameAndSetQty + ';' + SetName + ',' + SetQty + ',' + quoteLineSetNameDiscountMap[SetName]
                }
            } else {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(AllGurantee_Period);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(AllGurantee_Period);
                //document.getElementById("Page:mainForm:block:SetQty" + i).value = '';
                //document.getElementById("Page:mainForm:block:SetName" + i).value = '';
            }
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':provistonPeriod__c')).val(provistonPeriod | 0);
        }
    }
}
// 多年保修 end
// 计算产品标准定价总额
function EstimationListPrice() {
    var x, y, z;
    x = 0;
    y = 0;
    z = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        y = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        x = localParseFloat(x);
        y = localParseFloat(y);
        z = z + (x * y);
    }
    j$(escapeVfId('Page:mainForm:block:hidden_Estimation_List')).val(toNum(z));
    j$(escapeVfId('Page:mainForm:block:Estimation_List_Price')).text(toNumComma(z));
}
// 根据医院小计计算报价总额
function quoteTotalPrice() {
    var x = 0;
    var y = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).value();
        x = localParseFloat(x);
        y = y + localParseFloat(x);
    }
    j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).val(toNumComma(y));
    //DisCalculation.call();
    DisAmount.call();
    QuoteAdjust.call();
    //salesProfit1.call();
    salesProfit2.call();
    setCostTatal.call();
}
// CHAN-B4YAB8 2018/9/28 计算经销商单价和小计 start
//  如果是OCSM直销,则更改医院合同价格时会计算经销商单价和小计
//  如果是 经销商销售,则更改 第一经销商总价是会计算经销商单价和小计
function quoteAgencyTotalPriceAction1(str) {
    var Sales_Root =
        j$(escapeVfId('Page:mainForm:block:Sales_Root')).value();
    Sales_Root = Sales_Root.replace(/\s+/g, "");
    if (str == Sales_Root) {
        quoteAgencyTotalPriceAction();
    }
}
/*
    计算经销商单价和经销商小计
 */
function quoteAgencyTotalPriceAction() {
    // 第一经销商的合同金额
    var SalesAmount1 = j$(escapeVfId('Page:mainForm:block:SalesAmount1')).value();
    // 多年保修 start
    // 手动算出第三方和非第三方产品标准定价总额
    // 非第三方产品标准定价总额
    var Estimation_List_Price = 0;
    // 第三方产品标准定价总额
    var thirdPartyEstimation_List_Price = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        // 供应商名称
        var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
        s = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        s = localParseInt(s);
        l = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        l = localParseInt(l);
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
        var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
        if (backbutton == '') {
            VenderName = '';
        }
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
        if (VenderName == '' || VenderName == 'OSH') {
            Estimation_List_Price = Estimation_List_Price + s * l;
        } else {
            thirdPartyEstimation_List_Price = thirdPartyEstimation_List_Price + s * l;
        }
    }
    // 多年保修 end
    // 医院的合同金额
    var Dealer_Final_Price =
        j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    // 销售渠道
    var Sales_Root =
        j$(escapeVfId('Page:mainForm:block:Sales_Root')).value();
    var TotalPrice = 0;
    var StardardPrice = 0;
    var totalAgencyPrice = 0;
    var AgencySubtotal = 0;
    var LastAgencySubtotal = 0;
    var j = 0;
    var lastQuantity = 0;
    Sales_Root = Sales_Root.replace(/\s+/g, "");
    if (Sales_Root == '经销商') {
        TotalPrice = SalesAmount1;
    } else {
        TotalPrice = Dealer_Final_Price;
    }
    //多年保修 start
        for (var i =1;i<30;i++) {
            var SetQty = j$(escapeVfId("Page:mainForm:block:SetQty" + i)).value();
            var SetName = j$(escapeVfId("Page:mainForm:block:SetName" + i)).value();
    TotalPrice = localParseFloat(TotalPrice);
    var oldTotalPrice = TotalPrice;
    totalAgencyPrice = TotalPrice;
    //no discount price 合计
    var noDiscountPriceTotal =
        j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val();
    noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
    TotalPrice = TotalPrice - noDiscountPriceTotal;
    //多年保修  end
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        s = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        s = localParseInt(s);
        l = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        l = localParseInt(l);
        if ((s == 0) || (l == 0)) {
            //処理なし
        } else if (oldTotalPrice == 0) {
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val(0);
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text(toNumComma_One_digit(0));
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val(toNumComma_One_digit(0));
        } else {
            StardardPrice = s * l;
            StardardPrice = localParseFloat(StardardPrice);
            // 多年保修 start
            // 供应商名称
            var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
            //行项目 no discount price:
            var noDiscountPrice =
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val();
            noDiscountPrice = localParseFloat(noDiscountPrice);
            var Agency_UnitPrice = (l).toFixed(1);
            //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
            var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
            if (backbutton == '') {
                VenderName = '';
            }
            //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
            if (VenderName == '' || VenderName == 'OSH') {
                var Agency_UnitPrice = (StardardPrice *
                    (TotalPrice - thirdPartyEstimation_List_Price) /
                    (Estimation_List_Price * s) +
                    noDiscountPrice
                ).toFixed(1);
            }
            //多年保修 end
            AgencySubtotal = Agency_UnitPrice * s;
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val(AgencySubtotal);
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text(toNumComma_One_digit(AgencySubtotal));
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val(toNumComma_One_digit(Agency_UnitPrice));
            totalAgencyPrice = totalAgencyPrice - toNum(AgencySubtotal);
            j = i;
            lastQuantity = s;
            LastAgencySubtotal = AgencySubtotal;
        }
    }
    //多年保修 start
    if (oldTotalPrice == 0) {} else {
        LastAgencySubtotal = LastAgencySubtotal + totalAgencyPrice;
        j$(escapeVfId('Page:mainForm:block:lists:' + j + ':AgencySubtotal__c')).val(toNum(LastAgencySubtotal));
        j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_TotalPrice')).text(toNumComma_One_digit(LastAgencySubtotal));
        j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_UnitPrice')).val(toNumComma_One_digit(LastAgencySubtotal / lastQuantity));
    }
    // 多年保修 end
}
// CHAN-B4YAB8 2018/9/28 计算经销商单价和小计 end
/*
   1、手动修改报价总额,先使用list Price 和 数量计算出产品标准定价总额y;
   2、 然后计算出每一个行项目的 行项目产品标准定价总额,按比例 计算出医院小计和医院单价;
   3、累加所有医院小计,赋值到产品报价;
 */
function quoteTotalPriceAction() {
    //var t = 0;
    var s = 0;
    var x = 0;
    // 非第三方产品标准定价总额
    var y = 0;
    var yy = 0;
    // 非第三方产品报价总额
    var z = j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).value();
    // 产品报价总额
    var zz = 0;
    z = localParseFloat(z);
    //多年保修 start
    //no discount price 合计
    var noDiscountPriceTotal =
        j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val();
    noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
    // 多年保修 end
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        s = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        s = localParseInt(s);
        l = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        l = localParseInt(l);
        x = s * l;
        // 多年保修 start
        // 供应商名称
        var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
        var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
        if (backbutton == '') {
            VenderName = '';
        }
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
        // OSH 计算标准定价总额
        if (VenderName == 'OSH' || VenderName == '') {
            y = y + x;
            // 非OSH 将产品报价总额 减去 第三方产品
        } else {
            z = z - x;
        }
        // 多年保修 end
    }
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        // 多年保修 start
        //行项目 no discount price:
        var noDiscountPrice =
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val();
        noDiscountPrice = localParseFloat(noDiscountPrice);
        // 供应商名称
        var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
        //多年保修 end
        s = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        s = localParseInt(s);
        l = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        l = localParseInt(l);
        // 行项目 标准定价小计
        x = s * l;
        x = localParseFloat(x);
        if ((s == 0) || (x == 0)) {
            //不处理
        } else {
            //多年保修 start
            //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
            var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
            if (backbutton == '') {
                VenderName = '';
            }
            //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
            if (VenderName == 'OSH' || VenderName == '') {
                yy = localParseFloat(x * (z - noDiscountPriceTotal) / y);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val(toNum(yy +
                    s * noDiscountPrice));
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(toNumComma(yy +
                    s * noDiscountPrice));
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(toNumComma(yy / s +
                    noDiscountPrice));
            } else {
                yy = localParseFloat(x);
            }
            // 多年保修 end
            zz = zz + yy;
        }
    }
    //多年保修 start
    j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).val(toNumComma(zz + noDiscountPriceTotal));
    // 多年保修 end
    calUnitPriceTotal.call();
    QuoteAdjust.call();
    //DisCalculation.call();
    DisAmount.call();
}
/*
    x: 产品标准定价总额;
    y: 调整金额;
    报价总额 = 产品标准定价总额 + 调整金额;
    如果调整金额 = 0, 则执行UnitPriceUpdate
    否则执行quoteTotalPriceAction
 */
function calFromQuoAmont() {
    var x = 0,
        y = 0;
    x = j$(escapeVfId('Page:mainForm:block:hidden_Estimation_List')).value();
    x = localParseFloat(x);
    y = j$(escapeVfId('Page:mainForm:block:QuoAmount')).value();
    j$(escapeVfId('Page:mainForm:block:QuoAmount')).val(toNumComma(y));
    y = localParseFloat(y);
    // 多年保修 start
    var noDiscountPriceTotal =
        j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).value();
    noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
    j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).val(toNumComma(y + x + noDiscountPriceTotal));
    // 多年保修 end
    if (y == 0) {
        j$(escapeVfId('Page:mainForm:block:QuoCalculation')).val(0);
        UnitPriceUpdate.call();
    } else {
        quoteTotalPriceAction.call();
    }
}
/*
  医院的合同金额 格式化为 带分位符的字段;
 */
function calFromContactPrice() {
    var x = 0;
    x = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    x = localParseFloat(x);
    j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).val(toNumComma(x));
    //quoteTotalPrice.call();
    //DisCalculation.call();
    DisAmount.call();
    salesProfit1.call();
    salesProfit2.call();
    setCostTatal.call();
}
/*
    1、按删除、 行UP 、 行 Down 按钮后根据逻辑进行判断是否可以执行,不能执行报错;
    2、执行 对应的操作;
    3、如果是删除按钮成功删掉一个后, 则会执行calPriceAll;
    4、只要执行删除按钮,则会反选所有行项目。
 */
function radioChecker2(str) {
    j$(escapeVfId("Page:mainForm:block:Btn_RowDelete")).attr("disabled", true);
    j$(escapeVfId("Page:mainForm:block:Btn_RowUp")).attr("disabled", true);
    j$(escapeVfId("Page:mainForm:block:Btn_RowDown")).attr("disabled", true);
    //error初期化
    replaceErrorClass.call();
    var lastLineNoNext = getLastLineNoNext(document);
    try {
        var hasCheckedCnt = 0;
        for (var i = 0; i < lastLineNoNext; i++) {
            var iChecked = document.forms['Page:mainForm']['checklist'][i].checked;
            if (iChecked) {
                hasCheckedCnt++;
                if (hasCheckedCnt > 1) {
                    // 複数件チェックされているか、わかればbreak;
                    break;
                }
            }
        }
        if (hasCheckedCnt == 0) {
            throw Error_Message34;
        }
        var hasCheckedCnt1 = 0; // 実際変更できた件数
        if (str == 'up') {
            for (var i = 0; i < lastLineNoNext; i++) {
                var iChecked = document.forms['Page:mainForm']['checklist'][i].checked;
                if (!iChecked) { continue; }
                if (i == 0) {
                    throw Error_Message35;
            if (SetName != '' ) {
                if (gainQuoteSetNameAndSetQty == '') {
                    gainQuoteSetNameAndSetQty = SetName + ',' + SetQty + ',' + ''
                } else {
                    if (setlists(str, i)) {
                        hasCheckedCnt1++;
                    } else {
                        if (hasCheckedCnt1 == 0) {
                            // 移動できない
                            throw Error_Message35;
                        }
                    }
                   gainQuoteSetNameAndSetQty = gainQuoteSetNameAndSetQty + ';' + SetName + ',' + SetQty + ',' + ''
                }
            }
        } else if (str == 'down') {
            for (var i = lastLineNoNext - 1; i >= 0; i--) {
                var iChecked = document.forms['Page:mainForm']['checklist'][i].checked;
                if (!iChecked) { continue; }
                if (i == 149 && iChecked) {
                    throw Error_Message36;
                } else {
                    if (setlists(str, i)) {
                        hasCheckedCnt1++;
                    } else {
                        if (hasCheckedCnt1 == 0) {
                            // 移動できない
                            throw Error_Message36;
                        }
                    }
                }
            }
        } else if (str == 'del') {
            for (var i = lastLineNoNext - 1; i >= 0; i--) {
                var iChecked = document.forms['Page:mainForm']['checklist'][i].checked;
                if (iChecked) {
                    hasCheckedCnt1++;
                    deletelist(i, document);
                }
            }
        } else {
            throw 'Unknow Operation';
        }
        if (hasCheckedCnt1 > 0) {
            if (str == 'del') {
                calPriceAll.call();
                //document.getElementById("Page:mainForm:block:SetQty" + i).value = '';
                //document.getElementById("Page:mainForm:block:SetName" + i).value = '';
            }
        }
        if (str == 'del') {
            /* xudan 20140627 削除後のチェック外すロジック
            // 複数選択して削除した場合、削除後チェックを外す
            if (hasCheckedCnt > 1) {
                for(var i = 0; i < lastLineNoNext; i++) {
                    document.forms['Page:mainForm']['checklist'][i].checked = false;
                }
    }
    for (var i =1;i<30;i++) {
        var SetQty = j$(escapeVfId("Page:mainForm:block:SetQty" + i)).value();
        var SetName = j$(escapeVfId("Page:mainForm:block:SetName" + i)).value();
        if (SetName != '' ) {
            if (gainQuoteSetNameAndSetQty == '') {
                gainQuoteSetNameAndSetQty = SetName + ',' + SetQty + ',' + quoteLineSetNameDiscountMap[SetName]
            } else {
                // lastLineNoNextの行も外す
                document.forms['Page:mainForm']['checklist'][lastLineNoNext - 2].checked = false;
               gainQuoteSetNameAndSetQty = gainQuoteSetNameAndSetQty + ';' + SetName + ',' + SetQty + ',' + quoteLineSetNameDiscountMap[SetName]
            }
    */
            clearAllCheck();
        }
    } catch (e) {
        alert(e);
    }
    document.getElementById("Page:mainForm:block:Btn_RowDelete").disabled = false;
    document.getElementById("Page:mainForm:block:Btn_RowUp").disabled = false;
    document.getElementById("Page:mainForm:block:Btn_RowDown").disabled = false;
    return true;
}
/*
  1、检索出产品主数据的各种字段,判断此报价金额、注册证相关字段是否和行项目上保存的产品数据一致,
  2、如果不一致则更新此报价上各种最新字段为产品主数据的所有字段;
  3、弹窗后确认是否更新行项目上金额、注册证等字段,
  4、如果确认更新,则把此报价上各种最新字段赋值到此报价金额、注册证相关字段
  5、最后运行 calPriceAll 、 quoteAgencyTotalPriceAction
 */
function productCompare() {
    try {
        sforce.connection.sessionId = Session_ID;
        var b = true;
        var t = j$(escapeVfId('Page:mainForm:block:Trade')).value();
        var ids = new Array();
        for (var i = 0; i < QuoteEntryMaxLine; i++) {
            var id = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
            if (id != '') {
                ids.push(j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value());
            }
        }
        var results = sforce.apex.execute("NewQuoteEntryWebService", "getProduct2", { id: ids });
        var id2Product = new Object();
        for (var j = 0; j < results.length; j++) {
            id2Product[results[j].Id] = results[j];
        }
        for (var i = 0; i < QuoteEntryMaxLine; i++) {
            var a = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
            if (a != '') {
                // 多年保修 start
                var newProductGuranteePrice = 0;
                var newProductServicePrice = 0;
                var newMaintenance_Price_Year = 0;
                // 多年保修 end
                if (t == '外貿') {
                    var recordTypeRecord = id2Product[a];
                    var y1 = recordTypeRecord.Name;
                    var y2 = recordTypeRecord.Foreign_Trade_List_US__c;
                    var y3 = recordTypeRecord.Foreign_Trade_Cost_US__c;
                    // 外贸多年保 精琢技术 wql 2021/01/29  start
                    newProductGuranteePrice =
                        recordTypeRecord.Intra_Trade_Foreign_RMB__c;
                    newProductServicePrice = recordTypeRecord.NoDiscount_Foreign__c;
                    newMaintenance_Price_Year = recordTypeRecord.Repair_Contract_USD__c;
                    // 外贸多年保 精琢技术 wql 2021/01/29  end
                } else {
                    var recordTypeRecord = id2Product[a];
                    var y1 = recordTypeRecord.Name;
                    var y2 = recordTypeRecord.Intra_Trade_List_RMB__c;
                    var y3 = recordTypeRecord.Intra_Trade_Cost_RMB__c;
                    // 多年保修 start
                    newProductGuranteePrice =
                        recordTypeRecord.Intra_Trade_Gurantee_RMB__c;
                    newProductServicePrice = recordTypeRecord.Intra_Trade_Service_RMB__c;
                    newMaintenance_Price_Year = recordTypeRecord.Maintenance_Price_Year__c;
                    // 多年保修 end
                }
                // 保修类型
                var newGuranteeType =
                    recordTypeRecord.GuranteeType__c;
                if (!newGuranteeType) {
                    var newGuranteeType =
                        '';
                }
                var newProductEntend_gurantee_period_all =
                    recordTypeRecord.Entend_gurantee_period_all__c;
                var oldGuranteeType =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i +
                        ':GuranteeType')).value();
                var oldProductEntend_gurantee_period_all =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i +
                        ':ProductEntend_gurantee_period_all__c')).value();
                var oldProductGuranteePrice =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i +
                        ':ProductGuranteePrice__c')).value();
                var oldProductServicePrice =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i +
                        ':productServicePrice__c')).value();
                var oldMaintenance_Price_Year =
                    j$(escapeVfId('Page:mainForm:block:lists:' + i +
                        ':Maintenance_Price_Year__c')).value();
                oldProductServicePrice = localParseFloat(oldProductServicePrice);
                newProductServicePrice = localParseFloat(newProductServicePrice);
                oldProductGuranteePrice = localParseFloat(oldProductGuranteePrice);
                newProductGuranteePrice = localParseFloat(newProductGuranteePrice);
                newProductEntend_gurantee_period_all = localParseFloat(newProductEntend_gurantee_period_all);
                oldMaintenance_Price_Year =
                    localParseFloat(oldMaintenance_Price_Year);
                newMaintenance_Price_Year =
                    localParseFloat(newMaintenance_Price_Year);
                // 多年保修 end
                var y4 = recordTypeRecord.SFDA_Status__c;
                var s1 = recordTypeRecord.StorageStatus__c;
                var x1 = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).value();
                var x2 = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
                //CHAN-B2B34Y修改
                var x3 = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).value();
                var x4 = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':SFDA')).value();
                //連続半角スペース対応
                y1 = y1.replace(/\s+/g, " ");
                x2 = localParseFloat(x2);
                x3 = localParseFloat(x3);
                y2 = localParseFloat(y2);
                //CHAN-B2B34Y修改 start
                y3 = localParseFloat(y3);
                //CHAN-B2B34Y修改 end
                //外贸多年保 取消外贸判断 注释源代码 精琢技术 2021/01/29 start
                // if ((x1==y1) && (x2==y2) && (x3==y3) && (x4==y4)
                // // 多年保修 start
                //     && (oldGuranteeType == newGuranteeType)
                //     && (oldProductEntend_gurantee_period_all == newProductEntend_gurantee_period_all)
                //     && (t=='外貿'
                //     || ((oldProductGuranteePrice == newProductGuranteePrice)
                //     && (oldProductServicePrice == newProductServicePrice)
                //     && ( oldMaintenance_Price_Year == newMaintenance_Price_Year) ))
                //  // 多年保修 end
                //  ){
                // }else{
                //     b=false;
                // }
                if ((x1 == y1) && (x2 == y2) && (x3 == y3) && (x4 == y4)
                    // 多年保修 start
                    &&
                    (oldGuranteeType == newGuranteeType) &&
                    (oldProductEntend_gurantee_period_all == newProductEntend_gurantee_period_all) &&
                    (oldProductGuranteePrice == newProductGuranteePrice) &&
                    (oldProductServicePrice == newProductServicePrice) &&
                    (oldMaintenance_Price_Year == newMaintenance_Price_Year)
                    // 多年保修 end
                ) {} else {
                    b = false;
                }
                //外贸多年保 取消外贸判断 注释源代码 精琢技术 2021/01/29 end
                // 多年保修 start
                j$(escapeVfId('Page:mainForm:block:lists:' + i +
                    ':latestGuranteeType')).val(newGuranteeType);
                j$(escapeVfId('Page:mainForm:block:lists:' + i +
                    ':latestProductEntend_gurantee_period_all')).val(newProductEntend_gurantee_period_all);
                j$(escapeVfId('Page:mainForm:block:lists:' + i +
                    ':latestIntra_Trade_Gurantee')).val(
                    localParseFloat(recordTypeRecord.Intra_Trade_Gurantee_RMB__c));
                j$(escapeVfId('Page:mainForm:block:lists:' + i +
                    ':latestProductIntra_Trade_Service')).val(
                    localParseFloat(recordTypeRecord.Intra_Trade_Service_RMB__c));
                j$(escapeVfId('Page:mainForm:block:lists:' + i +
                    ':latestMaintenance_Price_Year')).val(
                    localParseFloat(recordTypeRecord.Maintenance_Price_Year__c));
                // 多年保修 end
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Name')).val(recordTypeRecord.Name);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_ListPrice')).val(y2);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Cost')).val(y3);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_SFDA')).val(y4);
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':StorageStatus__c')).val(s1);
            }
        }
        if (b == false) {
            if (window.confirm(Message_001)) {
                PriceStatusUpdate.call();
                blockme();
                j$(escapeVfId('Page:mainForm:productStatusUpdated')).val('true');
                j$(escapeVfId('Page:mainForm:SFDA_Flg')).val('false');
                return true;
            } else {
                return false;
            }
        } else {
            alert("价格状态没有变化。");
            j$(escapeVfId('Page:mainForm:productStatusUpdated')).val('true');
            return false;
        }
    } catch (e) {
        alert(e);
    }
}
/* SWAG-C3BAVY 【委托】询价新旧code 替换 精琢技术 wql 20210607 start */
function updateOtcode() {
    blockme();
    sforce.connection.sessionId = Session_ID;
    var id = document.getElementById('Page:mainForm:hiddenQuoid').innerHTML;
    var nmpa = checkNMPA();
    if (nmpa) {
        var results = sforce.apex.execute("NewQuoteEntryWebService", "updateOTCode", { tempQuoId: id });
        if (results) {
            alert('产品otcode替换完成!');
            location.reload();
        } else {
            alert('产品otcode替换失败,请联系管理员!');
        }
    } else {
        alert('报价行项目没有NMPA状态为停止的产品,无法替换!');
    }
}
//SWAG-C3BAVY 【委托】询价新旧code 替换 精琢技术 wql 20210607 end
function addFigure(str) {
    var num = new String(str).replace(/,/g, "");
    while (num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
    return num;
}
/*
 1、取出报价调整百分比;
 2、行项目医院单价 等于 行项目 list price 乘以 (1+ 百分比)
 3、执行 Subtotalupdate 、 calUnitPriceTotal 、 quoteTotalPrice
 */
function UnitPriceUpdate() {
    var num;
    num = j$(escapeVfId('Page:mainForm:block:QuoCalculation')).value();
    num = localParseFloat(num);
    j$(escapeVfId('Page:mainForm:block:QuoCalculation')).val(toNumComma(num));
    num = (100 + num) / 100;
    var price = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
        price = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        price = localParseFloat(price);
        // 多年保修 start
        //行项目 no discount price:
        var noDiscountPrice =
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ServicePrice__c')).val();
        noDiscountPrice = localParseFloat(noDiscountPrice);
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
        var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
        if (backbutton == '') {
            VenderName = '';
        }
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
        if (price != '' && VenderName == 'OSH') {
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(toNumComma(price * num + noDiscountPrice));
        } else if (price != '' && VenderName == '') {
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(toNumComma(price * num + noDiscountPrice));
        }
        //多年保修 end
    }
    Subtotalupdate.call();
    calUnitPriceTotal.call();
    quoteTotalPrice.call();
}
/*
  取出所有医院单价,数量,计算医院小计
 */
function Subtotalupdate() {
    var x, y, z;
    z = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        x = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
        x = localParseInt(x);
        y = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value();
        y = localParseFloat(y);
        z = x * y;
        if (j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value() != "") {
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(toNumComma(z));
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val(toNum(z));
            //document.getElementById("Page:mainForm:block:SetQty" + i).value = '';
            //document.getElementById("Page:mainForm:block:SetName" + i).value = '';
        }
    }
}
// 疑似废弃的方法
function getId1() {
    var s = j$(escapeVfId('Page:mainForm:block:SalesName1')).value();
    if ((s != null) && (s != '')) {
        var x = j$(escapeVfId('Page:mainForm:block:SalesName1_lkid')).value();
        getSalesId1.call(x, x);
    } else {
        j$(escapeVfId('Page:mainForm:block:SalesShopClass1')).text('');
        //j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val('');
        //j$(escapeVfId('Page:mainForm:block:Salesprofit1')).text('');
        //j$(escapeVfId('Page:mainForm:block:SalesCalculation1')).text('');
    }
}
// 疑似废弃的方法
function getId2() {
    var s = j$(escapeVfId('Page:mainForm:block:SalesName2')).value();
    if ((s != null) && (s != '')) {
        var x = j$(escapeVfId('Page:mainForm:block:SalesName2_lkid')).value();
        getSalesId2.call(x, x);
    } else {
        j$(escapeVfId('Page:mainForm:block:SalesShopClass2')).text('');
        //j$(escapeVfId('Page:mainForm:block:SalesAmount2')).val('');
        //j$(escapeVfId('Page:mainForm:block:Salesprofit2')).text('');
        //j$(escapeVfId('Page:mainForm:block:SalesCalculation2')).text('');
    }
}
// 优惠折扣 = 优惠价格 / (报价总额 -  No discount price 合计);
function DisCalculation() {
    var x = j$(escapeVfId('Page:mainForm:block:hidden_DisAmountvalue')).value();
    x = localParseFloat(x);
    var y = j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).value();
    y = localParseFloat(y);
    if ((y == 0)) {
        j$(escapeVfId('Page:mainForm:block:DisCalculationvalue')).val('');
        //j$(escapeVfId('Page:mainForm:block:DisCalculation')).text('');
    } else {
        var z = 0;
        z = x / y * 100;
        z = z.toFixed(2);
        j$(escapeVfId('Page:mainForm:block:DisCalculationvalue')).val(toNum(z));
        //j$(escapeVfId('Page:mainForm:block:DisCalculation')).text(toNumComma(z));
    }
}
// 优惠价格 = 报价总额 - 医院的合同金额
// 然后调用 DisCalculation
function DisAmount() {
    var x = j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).value();
    x = localParseFloat(x);
    var y = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    y = localParseFloat(y);
    j$(escapeVfId('Page:mainForm:block:hidden_DisAmountvalue')).val(toNum(x - y));
    //j$(escapeVfId('Page:mainForm:block:DisAmount')).text(toNumComma( x - y));
    DisCalculation.call();
}
/* x:报价总额
   y:产品标准定价总额
   1、调整金额  =  x - No Discount Price合计 - y
   2、如果y等于0, 则百分比为0;
   3、否则等于 (调整金额 - 第三方产品标准定价总额) 除以 (产品标准定价总额 - 第三方产品标准定价总额)
*/
function QuoteAdjust() {
    var x = j$(escapeVfId('Page:mainForm:block:quoTotalPrice')).value();
    x = localParseFloat(x);
    var y = j$(escapeVfId('Page:mainForm:block:hidden_Estimation_List')).value();
    y = localParseFloat(y);
    // 多年保修 start
    //No discount price合计
    var noDiscountPriceTotal =
        j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val();
    noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
    // 计算第三方产品标准定价总额
    var thirdPartyEstimation_List_Price = 0;
    var price = 0;
    var Quantity = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
        var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
        if (backbutton == '') {
            VenderName = '';
        }
        //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
        if (VenderName != '' && VenderName != 'OSH') {
            price = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
            price = localParseFloat(price);
            Quantity = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
            Quantity = localParseInt(Quantity);
            thirdPartyEstimation_List_Price =
                thirdPartyEstimation_List_Price + price * Quantity;
        }
    }
    thirdPartyEstimation_List_Price = localParseFloat(thirdPartyEstimation_List_Price);
    j$(escapeVfId('Page:mainForm:block:QuoAmount')).val(toNumComma(x - noDiscountPriceTotal - y));
    // 如果 非第三方产品标准定价总额 = 0,则调整金额百分比为0
    if (y - thirdPartyEstimation_List_Price == 0) {
        // 多年保修 end
        //TODO QuoCalculationでgrepして、toNumComma->toNum
        j$(escapeVfId('Page:mainForm:block:QuoCalculation')).val(toNumComma(0));
    } else {
        //多年保修 start
        j$(escapeVfId('Page:mainForm:block:QuoCalculation')).val(toNumComma((x -
                noDiscountPriceTotal - y) /
            (y - thirdPartyEstimation_List_Price) * 100));
        // 多年保修 end
    }
}
/*
    如果没有第二经销商,则第一经销商利润 = 医院的合同金额 - 第一经销商价格
    如果有第二经销商,则第一经销商利润 =  第二经销商价格 - 第一经销商价格
    然后运行salesCalculation1
 */
function salesProfit1() {
    var x = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    var y = j$(escapeVfId('Page:mainForm:block:SalesAmount1')).value();
    y = y.replace(/ /g, "");
    if (y.length == 0) {
        var z = j$(escapeVfId('Page:mainForm:block:SalesAmount2')).value();
        z = z.replace(/ /g, "");
        if (z.length == 0) {
            j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val('');
            j$(escapeVfId('Page:mainForm:block:Salesprofit1value')).val('');
            j$(escapeVfId('Page:mainForm:block:Salesprofit1')).text('');
        } else {
            j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val(toNumComma(0));
            j$(escapeVfId('Page:mainForm:block:Salesprofit1value')).val(toNum(0));
            j$(escapeVfId('Page:mainForm:block:Salesprofit1')).text(toNumComma(0));
        }
    } else {
        j$(escapeVfId('Page:mainForm:block:SalesAmount1')).val(toNumComma(y));
        x = localParseFloat(x);
        y = localParseFloat(y);
        var t = j$(escapeVfId('Page:mainForm:block:SalesAmount2')).value();
        if (t.length == 0) {
            j$(escapeVfId('Page:mainForm:block:Salesprofit1value')).val(toNum(x - y));
            j$(escapeVfId('Page:mainForm:block:Salesprofit1')).text(toNumComma(x - y));
        } else {
            t = localParseFloat(t);
            j$(escapeVfId('Page:mainForm:block:Salesprofit1value')).val(toNum(t - y));
            j$(escapeVfId('Page:mainForm:block:Salesprofit1')).text(toNumComma(t - y));
        }
    }
    salesCalculation1.call();
}
/*
    第二经销商利润 = 医院的合同金额 - 第二经销商价格
    然后运行salesCalculation2 、 salesProfit1
 */
function salesProfit2() {
    var x = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    var y = j$(escapeVfId('Page:mainForm:block:SalesAmount2')).value();
    y = y.replace(/ /g, "");
    if (y.length == 0) {
        j$(escapeVfId('Page:mainForm:block:SalesAmount2')).val('');
        j$(escapeVfId('Page:mainForm:block:Salesprofit2value')).val('');
        j$(escapeVfId('Page:mainForm:block:Salesprofit2')).text('');
    } else {
        x = localParseFloat(x);
        y = localParseFloat(y);
        j$(escapeVfId('Page:mainForm:block:SalesAmount2')).val(toNumComma(y));
        j$(escapeVfId('Page:mainForm:block:Salesprofit2value')).val(toNum(x - y));
        j$(escapeVfId('Page:mainForm:block:Salesprofit2')).text(toNumComma(x - y));
    }
    salesCalculation2.call();
    salesProfit1();
}
// 2018/09/28 CHAN-B4YAB8 第一经销商价格变化后更新第一经销商折扣 start
// 第一经销商折扣 = 第一经销商价格 除以 产品标准定价总额
function AgencyDiscountCalculation1() {
    var y = j$(escapeVfId('Page:mainForm:block:SalesAmount1')).value();
    if (y != '' && y.length != 0) {
        var Estimation_List_Price = j$(escapeVfId('Page:mainForm:block:Estimation_List_Price')).value();
        y = y.replace(/ /g, "");
        if (Estimation_List_Price.length != 0) {
            y = localParseFloat(y);
            Estimation_List_Price = localParseFloat(Estimation_List_Price);
            // 多年保修 start
            // 第三方产品标准定价总额
            var thirdPartyEstimation_List_Price = 0;
            var price = 0;
            var Quantity = 0;
            for (var i = 0; i < QuoteEntryMaxLine; i++) {
                var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).value();
                //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 start
                var backbutton = j$(escapeVfId('Page:mainForm:block:j_id141')).value();
                if (backbutton == '') {
                    VenderName = '';
                }
                //CHAN-BKU3XH 根据返回询价按钮 判断是否为普通询价 精琢技术 2020/02/18 end
                if (VenderName != '' && VenderName != 'OSH') {
                    price = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
                    price = localParseFloat(price);
                    Quantity = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
                    Quantity = localParseInt(Quantity);
                    thirdPartyEstimation_List_Price =
                        thirdPartyEstimation_List_Price + price * Quantity;
                }
            }
            thirdPartyEstimation_List_Price = localParseFloat(thirdPartyEstimation_List_Price);
            if (Estimation_List_Price - thirdPartyEstimation_List_Price == 0) {
                j$(escapeVfId('Page:mainForm:block:AgencyDiscountValue')).val(toNumComma(0));
                j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(0));
            } else {
                //no discount price 合计
                var noDiscountPriceTotal =
                    j$(escapeVfId('Page:mainForm:block:hidden_MultiYearWarrantyTotalPrice')).val();
                noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
                var t = (y - noDiscountPriceTotal - thirdPartyEstimation_List_Price) /
                    (Estimation_List_Price - thirdPartyEstimation_List_Price) * 100;
                // 多年保修 end
                j$(escapeVfId('Page:mainForm:block:AgencyDiscountValue')).val(toNumComma(t));
                j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(t));
            }
        } else {
            j$(escapeVfId('Page:mainForm:block:AgencyDiscountValue')).val(toNumComma(0));
            j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(0));
        }
    } else {
        j$(escapeVfId('Page:mainForm:block:AgencyDiscountValue')).val(toNumComma(0));
        j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(0));
    }
}
// 2018/09/28 CHAN-B4YAB8 更新经销商折扣 end
/*
   计算第一经销商栏最右边的百分比 1次販売店利益率_元
   如果 不存在第二经销商利润,= 第一经销商利润除以医院的合同金额
   如果存在第二经销商利润, =  第一经销商利润除以第二经销商合同金额
 */
function salesCalculation1() {
    var w = j$(escapeVfId('Page:mainForm:block:SalesAmount1')).value();
    w = w.replace(/ /g, '');
    var x = j$(escapeVfId('Page:mainForm:block:Salesprofit1value')).value();
    var y = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    var z = j$(escapeVfId('Page:mainForm:block:SalesAmount2')).value();
    z = z.replace(/ /g, '');
    if (w.length == 0) {
        j$(escapeVfId('Page:mainForm:block:SalesCalculation1value')).val('');
        j$(escapeVfId('Page:mainForm:block:SalesCalculation1')).text('');
    } else {
        x = localParseFloat(x);
        var t = 0;
        if (z.length == 0) {
            y = localParseFloat(y);
            if (y != 0) {
                t = x / y * 100;
            } else {
                t = 0;
            }
        } else {
            z = localParseFloat(z);
            if (z != 0) {
                t = x / z * 100;
            } else {
                t = 0;
            }
        }
        j$(escapeVfId('Page:mainForm:block:SalesCalculation1value')).val(toNum(t));
        j$(escapeVfId('Page:mainForm:block:SalesCalculation1')).text(toNumComma(t));
    }
}
/*
   计算第二经销商栏最右边的百分比 2次販売店利益率_元 =  第二经销商利润除以医院的合同金额
 */
function salesCalculation2() {
    var w = j$(escapeVfId('Page:mainForm:block:SalesAmount2')).value();
    w = w.replace(/ /g, '');
    var x = j$(escapeVfId('Page:mainForm:block:Salesprofit2value')).value();
    var y = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    if (w.length == 0) {
        j$(escapeVfId('Page:mainForm:block:SalesCalculation2value')).val('');
        j$(escapeVfId('Page:mainForm:block:SalesCalculation2')).text('');
    } else {
        x = localParseFloat(x);
        y = localParseFloat(y);
        if ((y == 0)) {
            j$(escapeVfId('Page:mainForm:block:SalesCalculation2value')).val(toNum(0));
            j$(escapeVfId('Page:mainForm:block:SalesCalculation2')).text(toNumComma(0));
        } else {
            var z = x / y * 100;
            j$(escapeVfId('Page:mainForm:block:SalesCalculation2value')).val(toNum(z));
            j$(escapeVfId('Page:mainForm:block:SalesCalculation2')).text(toNumComma(z));
        }
    }
}
function setlistFocus(i) {
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).focus();
}
/*
   使用行项目上的成本小计计算成本总额
 */
function setCostTatal() {
    var z = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var s = 0;
        s = eval(j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).value());
        if (isNaN(s) == false) {
            z = z + s;
        }
    }
    j$(escapeVfId('Page:mainForm:block:hidden_Stocking_Price')).val(toNum(z));
    if (displayCost == 'true') {
        j$(escapeVfId('Page:mainForm:block:Stocking_Price')).text(toNumComma(z));
    }
}
/*
  如果询价是经销商贩卖,OCM预测额销售 = 第一经销商
  如果询价是OCM直销,OCM预测额销售 = 医院的合同金额
 */
function setOCMAmount() {
    var s, t;
    s = j$(escapeVfId('Page:mainForm:block:SalesRoot_Flg')).value();
    if (s == 'true') {
        t = j$(escapeVfId('Page:mainForm:block:SalesAmount1')).value();
    } else {
        t = j$(escapeVfId('Page:mainForm:block:Dealer_Final_Price')).value();
    }
    t = localParseFloat(t);
    j$(escapeVfId('Page:mainForm:block:hidden_Wholesale_Price')).val(toNum(t));
    j$(escapeVfId('Page:mainForm:block:Wholesale_Price')).text(toNumComma(t));
}
// LHJ Start
function AlertAuthorize() {
    var Authorized_DB_No = j$(escapeVfId('Page:mainForm:block:Authorized_DB_No')).value();
    var If_Need_Authorize = j$(escapeVfId('Page:mainForm:block:If_Need_Authorize')).value();
    if (If_Need_Authorize == 'true') {
        if (Authorized_DB_No == null || Authorized_DB_No == '') {
            // 需要授权的场合,如果授权编码为空,需要授权
            return false;
        } else {
            return true;
        }
    } else {
        return true;
    }
}
// LHJ End
// CHAN-BTF4XQ start
// 检查是否有标准定价为0的情况
function CheckForListPrice() {
    var ListPrice, name;
    var cnt = 0;
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        ListPrice = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
        name = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).value();
        if (name && ListPrice <= 0) {
            cnt = cnt + 1;
        }
    }
    if (cnt > 0) {
        return true;
    } else {
        return false;
    }
}
// CHAN-BTF4XQ end
function decision2btn() {
        checkchangedAfterPrint();
        var Shut = AlertForCFDA();
        // LHJ Start
        var ifAuth = AlertAuthorize();
    
        //CHAN-BKU3XH 检查是否存在不是同一个供销商名称 精琢技术 2020/02/13 Start
        var arr = [];
        var Venderflag = false;
        for (var i = 0; i < QuoteEntryMaxLine; i++) {
            var VenderName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).text();
            var prdouctName = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Nametext1')).text();
            if (prdouctName) {
                arr.push(VenderName);
            }
        }
        for (var i = 0; i < arr.length; i++) {
            if (arr[0] != arr[i]) {
                Venderflag = true;
            }
        }
        //CHAN-BKU3XH 检查是否存在不是同一个供销商名称 精琢技术 2020/02/13 end
        // LHJ End
        // CHAN-BTF4XQ start
        var listPrice = CheckForListPrice();
        var cost = CheckForCost();
        // CHAN-BTF4XQ end
        //CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 start
        var agencyPriceFlag = checkAgencyPrice();
        //CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 end
        //CHAN-BKU3XH 检查是否存在不是同一个供销商名称 精琢技术 2020/02/13 end
        // LHJ End
        if (Shut == true) {
            alert('提示:包含重新申请CFDA的产品,不可Decide。');
            // LHJ Start
        } else if (ifAuth == false) {
            alert('提示:该询价未授权,不可Decide');
            // LHJ End
            //CHAN-BKU3XH 检查是否存在不是同一个供销商名称 精琢技术 2020/02/13 Start
        } else if (Venderflag == true) {
            alert('提示:请按照不同供应商拆单,不允许decide。');
            // CHAN-BKU3XH 检查是否存在不是同一个供销商名称 精琢技术 2020/02/13 End
        }
        // CHAN-BTF4XQ start
        else if (listPrice == true || cost == true) {
            alert('产品定价/成本为0,请联系产品本部。');
        }else if(QuotationCalculationFag == 'true'){
            alert('产品配置发生变化,请再次进行报价计算');
        }
        // CHAN-BTF4XQ end
        //CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 start
        //else if (agencyPriceFlag) {
        //    alert('经销商单价或者经销商小计小于0时,不能保存!');
        //}
        //CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 end
        else {
            return chkSalesPossibilityDecision();
        }
}
function chkSalesPossibilityDecision() {
    try {
        sforce.connection.sessionId = Session_ID;
        //        var b = true;
        var ids = new Array();
        for (var i = 0; i < QuoteEntryMaxLine; i++) {
            var id = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
            if (id != '') {
                ids.push(id);
            }
        }
        var results = sforce.apex.execute("NewQuoteEntryWebService", "getProduct2", { id: ids });
        var id2Product = new Object();
        for (var j = 0; j < results.length; j++) {
            id2Product[results[j].Id] = results[j];
        }
        //        for(var i=0; i<QuoteEntryMaxLine; i++){
        //            var a = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
        //            if (a != ''){
        //               var recordTypeRecord = id2Product[a];
        //                var x = recordTypeRecord.Sales_Possibility__c;
        //                if (x == '△'){
        //                    b = false;
        //                }
        //            }
        //        }
        //        if (b == false){
        //            alert("你选择了不可销售的产品");
        //            return false;
        //            if(window.confirm(Error_Message11)){
        //                QuoteDecision.call();
        //                blockme();
        //                return true;
        //            }else{
        //                return false;
        //            }
        //        }else{
        QuoteDecision.call();
        blockme();
        return true; // by katsu なぜ return false? return true に変更した!
        //        }
    } catch (e) {
        alert(e);
    }
}
// 読んだ後にchangedAfterPrintに値がセットされます。
// 処理ない場合、途中returnしています。
// 20150507 xud changedAfterBidも設定(中标通知书ありなし)
function checkchangedAfterPrint() {
    sforce.connection.sessionId = Session_ID;
    // 明細変更があるかの比較
    var id = document.getElementById('Page:mainForm:hiddenQuoid').innerHTML;
    j$(escapeVfId('Page:mainForm:changedAfterPrint')).val('false');
    j$(escapeVfId('Page:mainForm:changedAfterBid')).val('false');
    var detailChanged = 'false';
    var changedAfterPrint = 'false';
    var changedAfterBid = 'false';
    if (id == null || id == '') {
        return;
    }
    var activities = [];
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var lineId = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':PricebookEntryId')).value();
        if (lineId != '') {
            var item = new Object();
            item.PricebookEntryId = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':PricebookEntryId')).value();
            item.SFDA_Status__c = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':SFDA')).value();
            item.UnitPrice__c = localParseFloat(j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value());
            item.ListPrice__c = localParseFloat(j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value());
            item.Quantity = localParseInt(j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value());
            //检索 阿西赛多 wql 2020/09/10 start
            item.Is_DangerousChemicals = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Is_DangerousChemicals__c')).value();
            //检索 阿西赛多 wql 2020/09/10 end
            //检索 不可取消多年保 CHAN-BWH2WP wql 2020/12/12 start
            item.Is_CanNotCancelFlag = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CanNotCancelledGurantee__c')).value();
            //检索 不可取消多年保  CHAN-BWH2WP wql 2020/12/12 end
            activities.push(item);
        }
    }
    var results = sforce.apex.execute("NewQuoteEntryWebService", "getQuoteLineItem", { quoId: id });
    var quote_Date__c = null;
    var bidAnnounceId = "";
    if (results.length > 0) {
        quote_Date__c = results[0]['Quote']['Quote_Date__c'];
        bidAnnounceId = results[0]['Quote']['BidAnnounce__c'];
    }
    //    var quote_Date__c = null;
    //    if (results.length > 0) {
    //        quote_Date__c = results[0]['Quote']['Quote_Date__c'];
    //        if(!quote_Date__c) {
    //            return;
    //        }
    //    } else {
    //        return;
    //    }
    if (detailChanged == 'false') {
        if (activities.length != results.length) {
            detailChanged = 'true';
        }
    }
    if (detailChanged == 'false') {
        for (var j = 0; j < results.length; j++) {
            if (results[j].PricebookEntryId != activities[j].PricebookEntryId ||
                results[j].SFDA_Status__c != activities[j].SFDA_Status__c ||
                results[j].UnitPrice__c != activities[j].UnitPrice__c ||
                results[j].ListPrice__c != activities[j].ListPrice__c ||
                results[j].Quantity != activities[j].Quantity
            ) {
                detailChanged = 'true';
                break;
            }
        }
    }
    //报价行发生变化但没有生成新报价必须重新做报价计算才可以decide   fy  2021-10-22
    if (detailChanged == 'true' && bidAnnounceId != null && bidAnnounceId != "" && bidAnnounceId != undefined) {
        changedAfterBid = 'true';
    }
    if (detailChanged == 'true' && quote_Date__c != null && quote_Date__c != "" && quote_Date__c != undefined) {
        changedAfterPrint = 'true';
    }
    debugger
    j$(escapeVfId('Page:mainForm:changedAfterPrint')).val(changedAfterPrint);
    j$(escapeVfId('Page:mainForm:changedAfterBid')).val(changedAfterBid);
    if(detailChanged == 'true' && changedAfterPrint == 'false'&&changedAfterBid == 'false'){
        QuotationCalculationFag= 'true';
    }
    return;
}
// 产品状态变更,需要更新
function ProSFDC_Status_Update() {
    var SFDC_Status = j$(escapeVfId('Page:mainForm:block:SFDA_Flg')).value();
    if (SFDC_Status == 'true') {
        alert('产品状态发生变化,请更新');
    }
}
// 90日以上更新してないとfalse
function checkProductStatusValidPeriod() {
    var period = j$(escapeVfId('Page:mainForm:block:hidden_PriceRefreshPeriod')).value();
    //console.log(QuoteDecide);
    if (parseInt(period) > parseInt(Price_Valid_Period) &&
        QuoteDecide != true) {
        if (confirm(Confirm_PriceRefresh)) {
            productCompare();
            return true;
    if ( searchSetProductWindow == null || searchSetProductWindow.closed) {
        if (baseUrl.indexOf("production") != -1) {
            searchSetProductWindow = window.open('/production/apex/SearchSetProduct?gainQuoteSetNameAndSetQty='+ encodeURIComponent(gainQuoteSetNameAndSetQty), 'SearchSetProduct', 'width=950,height=450');
        } else {
            return false;
            searchSetProductWindow = window.open('/apex/SearchSetProduct?gainQuoteSetNameAndSetQty='+ encodeURIComponent(gainQuoteSetNameAndSetQty), 'SearchSetProduct', 'width=950,height=450');
        }
    }
    return true;
}
function print2btn() {
    var id = document.getElementById('Page:mainForm:hiddenQuoid').innerHTML;
    if (id == null || id == '') {
        alert(Error_Message33);
        unblockUI();
        return false;
    }
    //if (checkProductStatusValidPeriod() == false) {
    //
    //    unblockUI();
    //   return false;
    //}
    //checkchangedAfterPrint();
    //var changedAfterPrint = j$(escapeVfId('Page:mainForm:changedAfterPrint')).value();
    //var changedAfterBid = j$(escapeVfId('Page:mainForm:changedAfterBid')).value();
    //if (changedAfterBid == 'true') {
    //    if (confirm(Confirm_ChangedAfterBid)) {
    //        return chkEstimation_Entry_Possibility(id);
    //    }
    //} else if (changedAfterPrint == 'true') {
    //    if (confirm(Confirm_ChangedAfterPrint)) {
    //        return chkEstimation_Entry_Possibility(id);
    //    }
    //} else {
    return chkEstimation_Entry_Possibility(id);
    //}
}
function chkEstimation_Entry_Possibility(q) {
    var id = q;
    if (id == null || id == '') {
        alert(Error_Message33);
        unblockUI();
        return false;
    }
    try {
        sforce.connection.sessionId = Session_ID;
        // var b = true;
        var ids = new Array();
        for (var i = 0; i < QuoteEntryMaxLine; i++) {
            var id = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
            if (id != '') {
                ids.push(j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value());
            }
        }
        var results = sforce.apex.execute("NewQuoteEntryWebService", "getProduct2", { id: ids });
        var id2Product = new Object();
        for (var j = 0; j < results.length; j++) {
            id2Product[results[j].Id] = results[j];
        }
        //for(var i=0; i<QuoteEntryMaxLine; i++){
        //    var a = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
        //    if (a != ''){
        //        var recordTypeRecord = id2Product[a];
        //        var x = recordTypeRecord.Estimation_Entry_Possibility__c;
        //if (x==null || x != '○'){
        //    b = false;
        //}
        //    }
        //}
        //if (b == false){
        //    alert(Error_Message29);
        //    return false;
        //}else{
        blockme();
        Print.call();
        return true;
        //}
    } catch (e) {
        alert(e);
    }
}
function save2btn() {
    checkchangedAfterPrint();
    var shut = AlertForCFDA();
    //WLIG-BXVB6M 【委托】【紧急】取消报价单中多年保计提金额为0的检查 精琢技术 2021/02/03 start
    //HWAG-BLWB9F 询价报价:多年保产品未登录计提金额时不可报价 精琢技术  20200224 start
    //var flag = CheckForGuranteeType();
    //WLIG-BXVB6M 【委托】【紧急】取消报价单中多年保计提金额为0的检查 精琢技术 2021/02/03 end
    if (shut == true) {
        alert('提示:包含重新申请CFDA的产品,不可进行订货。');
    }
    var cost = CheckForCost();
    //WLIG-BXVB6M 【委托】【紧急】取消报价单中多年保计提金额为0的检查 精琢技术 2021/02/03 start
    // if(flag == true){
    //     alert('多年保产品未登录计提金额时不可报价!');
    //     return false;
    // }else
    //WLIG-BXVB6M 【委托】【紧急】取消报价单中多年保计提金额为0的检查 精琢技术 2021/02/03 end
    //CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 start
    var agencyPriceFlag = checkAgencyPrice();
    if (cost == true) {
        alert('产品成本为空时不可报价!');
    }
    // else if(agencyPriceFlag){
    //     alert('经销商单价或者经销商小计为0时,不能保存!');
    // }
    //CHAN-BYJ9VF 增加经销商单价小计 不为0的check 精琢技术 wql 2021/03/08 end
    else {
        //CHAN-BTF4XQ start
        //标准定价为0时提醒
        var listPrice = CheckForListPrice();
        if (listPrice == true) {
            alert('目前产品定价未确定,请于产品本部联系确认!');
        }
        //CHAN-BTF4XQ end
        blockme();
        Save();
        return true;
    searchSetProductWindow.focus();
    }
    //HWAG-BLWB9F 询价报价:多年保产品未登录计提金额时不可报价 精琢技术  20200224 end
    // blockme();
    // Save();
    // return true;
}
function oppReflection2btn() {
    checkchangedAfterPrint();
    var changedAfterPrint = j$(escapeVfId('Page:mainForm:changedAfterPrint')).value();
    var changedAfterBid = j$(escapeVfId('Page:mainForm:changedAfterBid')).value();
    if (changedAfterBid == 'true') {
        if (confirm(Confirm_ChangedAfterBid)) {
            blockme();
            OppReflection.call();
            return;
        }
    } else if (changedAfterPrint == 'true') {
        if (confirm(Confirm_ChangedAfterPrint)) {
            blockme();
            OppReflection.call();
            return true;
        }
    } else {
        blockme();
        OppReflection.call();
        return true;
    }
}
function replaceErrorClass() {
    var div = document.getElementsByTagName('div');
    for (var e in div) {
        if (div[e].className == 'errorMsg') {
            div[e].className = 'dataCell';
            //div[e].innerHTML=div[e].innerHTML.replace(/Error_Message40/g,'');
            div[e].innerHTML = div[e].innerHTML.replace(Error_Message40, '');
            //div[e].innerHTML=div[e].innerHTML.replace(/Error_Message3/g,'');
            div[e].innerHTML = div[e].innerHTML.replace(Error_Message3, '');
        }
    }
    var input = document.getElementsByTagName('input');
    for (var i in input) {
        if (input[i].className == 'error') {
            input[i].className = 'dataCell';
        }
    }
}
function setlists(str, i) {
    var iChecked = document.forms['Page:mainForm']['checklist'][i].checked;
    if (!iChecked) {
        return false;
    }
    var j = 0;
    if (str == 'up') {
        //up
        j = parseInt(i) - 1;
        var b = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Assert')).value();
        if (b == null || b == '') {
            return false;
        }
    } else {
        //down
        j = parseInt(i) + 1;
        var b = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Assert')).value();
        if (b == null || b == '') {
            return false;
        }
    }
    var jChecked = j$(escapeVfId('checklist')[j]).checked;
    //var jChecked = document.forms['Page:mainForm']['checklist'][j].checked;
    //製品番号
    var assetdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Assert')).value();
    var assetup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Assert')).val(assetup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).val(assetdown);
    //SFDAステータス
    var sfdadown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Status__c')).text();
    var sfdaup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Status__c')).text();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Status__c')).text(sfdaup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Status__c')).text(sfdadown);
    //SFDAステータスのstyle
    var sfdadownColor = j$(escapeVfId(j + ':td_Status__c')).css("color");
    var sfdaupColor = j$(escapeVfId(i + ':td_Status__c')).css("color");
    j$(escapeVfId(j + ':td_Status__c')).css({ "color": sfdaupColor });
    j$(escapeVfId(i + ':td_Status__c')).css({ "color": sfdadownColor });
    //VenderName和配套
    //供应商
    var VendernameDown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':VenderName')).text();
    var VendernameUp = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).text();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':VenderName')).val(VendernameUp);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':VenderName__c')).val(VendernameUp);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).val(VendernameDown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName__c')).val(VendernameDown);
    var Product_Set_NameDown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Set_Name')).text();
    var Product_Set_NameUp = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Set_Name')).text();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Set_Name')).val(Product_Set_NameUp);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Set_Name')).val(Product_Set_NameDown);
    //SFDC停止预警 lt 20211009 start
    //预计消耗日期
    // document.getElementById('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate').style.color = "red";
    var ConsumptionDueDateDown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Estimated_ConsumptionDueDate')).text();
    var ConsumptionDueDateUp = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate')).text();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Estimated_ConsumptionDueDate')).val(ConsumptionDueDateUp);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate')).val(ConsumptionDueDateDown);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Estimated_ConsumptionDueDate1')).val(ConsumptionDueDateUp);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate1')).val(ConsumptionDueDateDown);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Estimated_ConsumptionDueDate')).text(ConsumptionDueDateUp);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate')).text(ConsumptionDueDateDown);
    MarkRed();
    //SFDC停止预警 lt 20211009 end
    //SFDA
    var sfdadown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':SFDA')).value();
    var sfdaup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':SFDA')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':SFDA')).val(sfdaup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':SFDA')).val(sfdadown);
    //Id
    var iddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Id')).value();
    var idup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Id')).val(idup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).val(iddown);
    //品目名
    var namedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Name__c')).value();
    var nameup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).value();
    var nameLinkdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':NameLink')).html();
    var nameLinkup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameLink')).html();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Name__c')).val(nameup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':NameLink')).html(nameLinkup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).val(namedown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameLink')).html(nameLinkdown);
    //ListPrice
    var lpdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':ListPrice')).value();
    var lpup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':ListPrice')).val(lpup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':ListPricetext')).text(toNumComma(lpup));
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).val(lpdown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPricetext')).text(toNumComma(lpdown));
    //数量
    var Quantitydown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Quantity')).value();
    var Quantityup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Quantity')).val(Quantityup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).val(Quantitydown);
    //価格
    var UnitPricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).value();
    var UnitPriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).val(UnitPriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(UnitPricedown);
    //  CHAN-B4YAB8 2018/9/28 販売店価格 start
    var Agency_UnitPricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_UnitPrice')).value();
    var Agency_UnitPriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_UnitPrice')).val(Agency_UnitPriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val(Agency_UnitPricedown);
    //  CHAN-B4YAB8 2018/9/28 販売店価格 end
    //  CHAN-B4YAB8 2018/10/30 赠送 start
    // if(document.getElementById('Page:mainForm:block:lists:' + j + ':Present__c') != null && document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c') != null ){
    //     var Presentidown = document.getElementById('Page:mainForm:block:lists:' + j + ':Present__c').checked;
    //     var Presentiup = document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c').checked;
    //     document.getElementById('Page:mainForm:block:lists:' + j + ':Present__c').checked = Presentiup;
    //     document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c').checked = Presentidown;
    // }
    //  CHAN-B4YAB8 2018/10/30 赠送 end
    //  CHAN-B4YAB8 2018/9/28 販売店小計 start
    var AgencySubtotaldown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':AgencySubtotal__c')).value();
    var AgencySubtotalup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':AgencySubtotal__c')).val(AgencySubtotalup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_TotalPrice')).text(toNumComma_One_digit(AgencySubtotalup));
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val(AgencySubtotaldown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text(toNumComma_One_digit(AgencySubtotaldown));
    //  CHAN-B4YAB8 2018/9/28 販売店小計 end
    //単位
    //var Qtydown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Qty_Unit')).value();
    //var Qtyup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty_Unit')).value();
    //j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Qty_Unit')).val(Qtyup);
    //j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Qty')).text(Qtyup);
    //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty_Unit')).val(Qtydown);
    //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty')).text(Qtydown);
    //小計
    // 多年保修 2019/07/25 start
    // 是否保修
    if (document.getElementById('Page:mainForm:block:lists:' + j +
            ':warranty:itemMultiYearWarranty') != null &&
        document.getElementById('Page:mainForm:block:lists:' + i +
            ':warranty:itemMultiYearWarranty') != null) {
        var itemMultiYearWarrantyidown = document.getElementById('Page:mainForm:block:lists:' + j +
            ':warranty:itemMultiYearWarranty').checked;
        var itemMultiYearWarrantyiup = document.getElementById('Page:mainForm:block:lists:' + i +
            ':warranty:itemMultiYearWarranty').checked;
        document.getElementById('Page:mainForm:block:lists:' + j +
            ':warranty:itemMultiYearWarranty').checked = itemMultiYearWarrantyiup;
        document.getElementById('Page:mainForm:block:lists:' + i +
            ':warranty:itemMultiYearWarranty').checked = itemMultiYearWarrantyidown;
    }
    // 保修
    var warrantyTypedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':warranty:warrantyType')).value();
    var warrantyTypedup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':warranty:warrantyType')).val(warrantyTypedup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val(warrantyTypedown);
    //不可取消多年保
    var CanNotCancelledGuranteedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':CanNotCancelledGurantee__c')).value();
    var CanNotCancelledGuranteeup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CanNotCancelledGurantee__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':CanNotCancelledGurantee__c')).val(CanNotCancelledGuranteeup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CanNotCancelledGurantee__c')).val(CanNotCancelledGuranteedown);
    //是否危化品 阿西赛多
    var Is_DangerousChemicalsdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Is_DangerousChemicals__c')).value();
    var Is_DangerousChemicalsup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Is_DangerousChemicals__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Is_DangerousChemicals__c')).val(Is_DangerousChemicalsup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Is_DangerousChemicals__c')).val(Is_DangerousChemicalsdown);
    // 保修期限
    var itemGuaranteePerioddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':GuaranteePeriod__c')).value();
    var itemGuaranteePeriodup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':GuaranteePeriod__c')).val(itemGuaranteePeriodup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':itemGuaranteePeriod')).text(itemGuaranteePeriodup | 0);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(itemGuaranteePerioddown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(itemGuaranteePerioddown | 0);
    // 计提年限
    var provistonPerioddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':provistonPeriod__c')).value();
    var provistonPeriodup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':provistonPeriod__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':provistonPeriod__c')).val(provistonPeriodup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':provistonPeriod__c')).val(provistonPerioddown);
    //是否取消市场多年保修
    var If_Cancel_Guaranteedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':If_Cancel_Guarantee__c')).value();
    var If_Cancel_Guaranteeup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':If_Cancel_Guarantee__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':If_Cancel_Guarantee__c')).val(If_Cancel_Guaranteeup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':If_Cancel_Guarantee__c')).val(If_Cancel_Guaranteedown);
    // no discount price
    var ServicePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':ServicePrice__c')).value();
    var ServicePriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':ServicePrice__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':ServicePrice__c')).val(ServicePriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':ServicePrice__c')).val(ServicePricedown);
    // no discount total
    if (document.getElementById('Page:mainForm:block:lists:' +
            i + ':warranty2:NoDiscountTotal') != null) {
        var NoDiscountTotaldown = document.getElementById('Page:mainForm:block:lists:' + j +
            ':warranty2:NoDiscountTotal').value;
        var NoDiscountTotalup = document.getElementById('Page:mainForm:block:lists:' + i +
            ':warranty2:NoDiscountTotal').value;
        document.getElementById('Page:mainForm:block:lists:' + j +
            ':warranty2:NoDiscountTotal').value = NoDiscountTotalup;
        document.getElementById('Page:mainForm:block:lists:' + i +
            ':warranty2:NoDiscountTotal').value = NoDiscountTotaldown;
    }
    // 供应商 医院单价 disabled
    var UnitPriceDisableddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).prop('disabled');
    var UnitPriceDisabledup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).prop('disabled');
    if (UnitPriceDisabledup == true) {
        j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).attr('disabled', 'disabled');
    } else {
        j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).removeAttr('disabled');
    }
    if (UnitPriceDisableddown == true) {
        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).attr('disabled', 'disabled');
    } else {
        j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).removeAttr('disabled');
    }
    //计提金额
    var GuranteePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':GuranteePrice__c')).value();
    var GuranteePriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':GuranteePrice__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':GuranteePrice__c')).val(GuranteePriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':GuranteePrice__c')).val(GuranteePricedown);
    // 维修合同报价
    var Maintenance_Price_Yeardown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':Maintenance_Price_Year__c')).value();
    var Maintenance_Price_Yearup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':Maintenance_Price_Year__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':Maintenance_Price_Year__c')).val(Maintenance_Price_Yearup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':Maintenance_Price_Year__c')).val(Maintenance_Price_Yeardown);
    // 保修类型
    var GuranteeTypedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':GuranteeType')).value();
    var GuranteeTypeup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':GuranteeType')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':GuranteeType')).val(GuranteeTypeup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':GuranteeType')).val(GuranteeTypedown);
    //产品保修期
    var ProductEntend_gurantee_period_alldown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':ProductEntend_gurantee_period_all__c')).value();
    var ProductEntend_gurantee_period_allup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':ProductEntend_gurantee_period_all__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':ProductEntend_gurantee_period_all__c')).val(ProductEntend_gurantee_period_allup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':ProductEntend_gurantee_period_all__c')).val(ProductEntend_gurantee_period_alldown);
    //产品计提金额
    var ProductGuranteePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':ProductGuranteePrice__c')).value();
    var ProductGuranteePriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':ProductGuranteePrice__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':ProductGuranteePrice__c')).val(ProductGuranteePriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':ProductGuranteePrice__c')).val(ProductGuranteePricedown);
    //产品是否消耗品
    // var ProductIfConsumabledown = j$(escapeVfId('Page:mainForm:block:lists:' + j
    //     + ':ProductIfConsumable__c')).value();
    // var ProductIfConsumableup = j$(escapeVfId('Page:mainForm:block:lists:' + i
    //     + ':ProductIfConsumable__c')).value();
    // j$(escapeVfId('Page:mainForm:block:lists:' + j
    //     + ':ProductIfConsumable__c')).val(ProductIfConsumableup);
    // j$(escapeVfId('Page:mainForm:block:lists:' + i
    //     + ':ProductIfConsumable__c')).val(ProductIfConsumabledown);
    //产品service price
    var ProductServicePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':productServicePrice__c')).value();
    var ProductServicePriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':productServicePrice__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':productServicePrice__c')).val(ProductServicePriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':productServicePrice__c')).val(ProductServicePricedown);
    //最新产品内贸 no discount price
    var latestProductIntra_Trade_Servicedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestProductIntra_Trade_Service')).value();
    var latestProductIntra_Trade_Serviceup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestProductIntra_Trade_Service')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestProductIntra_Trade_Service')).val(latestProductIntra_Trade_Serviceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestProductIntra_Trade_Service')).val(latestProductIntra_Trade_Servicedown);
    // 最新保修类型
    var latestGuranteeTypedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestGuranteeType')).value();
    var latestGuranteeTypeup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':GuranteeType')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestGuranteeType')).val(latestGuranteeTypeup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestGuranteeType')).val(latestGuranteeTypedown);
    //最新产品多年保修期
    var latestProductEntend_gurantee_period_alldown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestProductEntend_gurantee_period_all')).value();
    var latestProductEntend_gurantee_period_allup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestProductEntend_gurantee_period_all')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestProductEntend_gurantee_period_all')).val(latestProductEntend_gurantee_period_allup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestProductEntend_gurantee_period_all')).val(latestProductEntend_gurantee_period_alldown);
    //最新内贸计提金额
    var latestIntra_Trade_Guranteedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestIntra_Trade_Gurantee')).value();
    var latestIntra_Trade_Guranteeup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestIntra_Trade_Gurantee')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestIntra_Trade_Gurantee')).val(latestIntra_Trade_Guranteeup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestIntra_Trade_Gurantee')).val(latestIntra_Trade_Guranteedown);
    // 最新维修合同报价
    var latestMaintenance_Price_Yeardown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestMaintenance_Price_Year')).value();
    var latestMaintenance_Price_Yearup = j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestMaintenance_Price_Year')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j +
        ':latestMaintenance_Price_Year')).val(latestMaintenance_Price_Yearup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i +
        ':latestMaintenance_Price_Year')).val(latestMaintenance_Price_Yeardown);
    // 多年保修 2019/07/25 end
    var Subtotaldown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Subtotal__c')).value();
    var Subtotalup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Subtotal__c')).val(Subtotalup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':TotalPrice')).text(toNumComma(Subtotalup));
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val(Subtotaldown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(toNumComma(Subtotaldown));
    //Product_SFDA
    var Product_SFDAdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_SFDA')).value();
    var Product_SFDAup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_SFDA')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_SFDA')).val(Product_SFDAup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_SFDA')).val(Product_SFDAdown);
    //NameCode
    var NameCodedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':NameCode')).value();
    var NameCodeup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameCode')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':NameCode')).val(NameCodeup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameCode')).val(NameCodedown);
    //Product_Name
    var Product_Namedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Name')).value();
    var Product_Nameup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Name')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Name')).val(Product_Nameup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Name')).val(Product_Namedown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameCode')).val(NameCodedown);
    //Product_ListPrice
    var Product_ListPricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_ListPrice')).value();
    var Product_ListPriceup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_ListPrice')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_ListPrice')).val(Product_ListPriceup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_ListPrice')).val(Product_ListPricedown);
    //Product_Cost
    var Product_Costdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Cost')).value();
    var Product_Costup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Cost')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Cost')).val(Product_Costup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Cost')).val(Product_Costdown);
    //Sales_Possibility
    var Sales_Possibilitydown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Sales_Possibility')).value();
    var Sales_Possibilityup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Sales_Possibility')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Sales_Possibility')).val(Sales_Possibilityup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Sales_Possibility')).val(Sales_Possibilitydown);
    //Cost
    var Costdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Cost')).value();
    var Costup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Cost')).val(Costup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).val(Costdown);
    //CostSubTotal
    var CostSubTotaldown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':CostSubTotal')).value();
    var CostSubTotalup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':CostSubTotal')).val(CostSubTotalup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).val(CostSubTotaldown);
    //Bsscategory
    var Bsscategorydown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Bsscategory')).value();
    var Bsscategoryup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Bsscategory')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Bsscategory')).val(Bsscategoryup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Bsscategory')).val(Bsscategorydown);
    //Storagestatus
    var Storagestatusdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Storagestatus')).value();
    var Storagestatusup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatus')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Storagestatus')).val(Storagestatusup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Storagestatustext')).text(Storagestatusup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatus')).val(Storagestatusdown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatustext')).text(Storagestatusdown);
    //Specifications
    var Specificationsdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Specifications')).value();
    var Specificationsup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Specifications')).value();
    var Product_Specificationsdown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Specifications')).value();
    var Product_Specificationsup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Specifications')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Specifications')).text(Specificationsup);
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Specifications')).val(Product_Specificationsup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Specifications')).text(Specificationsdown);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Specifications')).val(Product_Specificationsdown);
    //PricebookEntryId
    var PricebookEntryIddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':PricebookEntryId')).value();
    var PricebookEntryIdup = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':PricebookEntryId')).value();
    j$(escapeVfId('Page:mainForm:block:lists:' + j + ':PricebookEntryId')).val(PricebookEntryIdup);
    j$(escapeVfId('Page:mainForm:block:lists:' + i + ':PricebookEntryId')).val(PricebookEntryIddown);
    //radio Refresh
    document.forms['Page:mainForm']['checklist'][i].checked = jChecked;
    document.forms['Page:mainForm']['checklist'][j].checked = true;
    return true;
}
// 真ん中の空行を削除、最後一行のデータ次の行
function getLastLineNoNext(doc) {
    var hasRecordFlg = false;
    var lastLineNo = 0;
    for (var i = 149; i >= 0; i--) {
        if (j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).value() != '') {
            if (!hasRecordFlg) {
                lastLineNo = i;
            }
            hasRecordFlg = true;
        }
        if (hasRecordFlg == true) {
            if (j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).value() == '') {
                var moveCheckbox = true;
                deletelist(i, doc, moveCheckbox);
                lastLineNo = i;
            }
        }
    }
    if (hasRecordFlg) {
        lastLineNo = lastLineNo + 1;
    }
    return lastLineNo;
}
function deletelist(k, doc, moveCheckbox) {
    var j = 0;
    for (var i = k; i < QuoteEntryMaxLine; i++) {
        j = parseInt(i) + 1;
        // xudan 20140627 削除時、空行から空行へのコピーをスキップ
        var productId1 = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).value();
        var productId2 = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Id')).value();
        if (productId1 == "" && productId2 == "") continue;
        if (j < QuoteEntryMaxLine) {
            if (moveCheckbox) {
                doc.forms['Page:mainForm']['checklist'][i].checked = doc.forms['Page:mainForm']['checklist'][j].checked;
            }
            //製品番号
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Assert')).value());
            //LineNo
            if (j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Assert')).value() == '') {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':indexNo')).text('');
            } else {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':indexNo')).text(j);
            }
            //SFDA
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':SFDA')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':SFDA')).value());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Status__c')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Status__c')).text());
            var sfdadownColor = j$(escapeVfId(j + ':td_Status__c')).css("color");
            j$(escapeVfId(i + ':td_Status__c')).css({ "color": sfdadownColor });
            //供应商
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':VenderName__c')).val());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).html(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':VenderName')).html());
            //SFDC停止预警 lt 20211009 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate1')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Estimated_ConsumptionDueDate1')).val());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate')).html(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Estimated_ConsumptionDueDate')).html());
            MarkRed();
            //SFDC停止预警 lt 20211009 end
            //不可取消多年保
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CanNotCancelledGurantee__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':CanNotCancelledGurantee__c')).val());
            //是否危化品 阿西赛多
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Is_DangerousChemicals__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Is_DangerousChemicals__c')).val());
            //配套名
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Set_Name__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Set_Name__c')).val());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Set_Name')).html(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Set_Name')).html());
            //Id
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Id')).value());
            //品目名
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Name__c')).value());
            //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameLink')).html(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':NameLink')).html());
            document.getElementById('Page:mainForm:block:lists:' + i + ':Nametext1').innerText = document.getElementById('Page:mainForm:block:lists:' + j + ':Nametext1').innerText;
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Nametext1')).attr('href', document.getElementById('Page:mainForm:block:lists:' + j + ':Nametext1').href);
            //ListPrice
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':ListPrice')).value());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPricetext')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':ListPricetext')).text());
            //Storagestatus
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatus')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Storagestatus')).value());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatustext')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Storagestatustext')).text());
            //Specifications
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Specifications')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Specifications')).text());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Specifications')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Specifications')).value());
            //数量
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Quantity')).value());
            //価格
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).value());
            //CHAN-B4YAB8 2018/9/28 販売店価格 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_UnitPrice')).value());
            //CHAN-B4YAB8 2018/9/28 販売店価格 end
            //CHAN-B4YAB8 2018/9/28 販売店小計 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':AgencySubtotal__c')).value());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Agency_TotalPrice')).text());
            //CHAN-B4YAB8 2018/9/28 販売店小計 end
            //CHAN-B4YAB8 2018/10/31 赠送 start
            // if(document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c') !=null && document.getElementById('Page:mainForm:block:lists:' + j + ':Present__c') != null ){
            //     document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c').checked =
            //         document.getElementById('Page:mainForm:block:lists:' + j + ':Present__c').checked ;
            // }
            //CHAN-B4YAB8 2018/10/31 赠送 end
            // 多年保修  2019/07/25 start
            // 多年保修
            if (document.getElementById('Page:mainForm:block:lists:' + j + ':warranty:itemMultiYearWarranty') != null &&
                document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty') != null) {
                document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty').checked =
                    document.getElementById('Page:mainForm:block:lists:' + j + ':warranty:itemMultiYearWarranty').checked;
            }
            // 保修
            var warrantyTypeddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':warranty:warrantyType')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val(warrantyTypeddown);
            // 保修期
            var itemGuaranteePerioddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':GuaranteePeriod__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val(itemGuaranteePerioddown);
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text(itemGuaranteePerioddown);
            // 计提年限
            var provistonPerioddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':provistonPeriod__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':provistonPeriod__c')).val(provistonPerioddown);
            //是否取消市场多年保修
            var If_Cancel_Guaranteedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':If_Cancel_Guarantee__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':If_Cancel_Guarantee__c')).val(If_Cancel_Guaranteedown);
            //no discount price
            var ServicePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':ServicePrice__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':ServicePrice__c')).val(ServicePricedown);
            // no discount total
            if (document.getElementById('Page:mainForm:block:lists:' +
                    i + ':warranty2:NoDiscountTotal') != null) {
                var NoDiscountTotaldown = document.getElementById('Page:mainForm:block:lists:' + j +
                    ':warranty2:NoDiscountTotal').value;
                document.getElementById('Page:mainForm:block:lists:' + i +
                    ':warranty2:NoDiscountTotal').value = NoDiscountTotaldown;
            }
            //计提金额
            var GuranteePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':GuranteePrice__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':GuranteePrice__c')).val(GuranteePricedown);
            //维修合同报价
            var Maintenance_Price_Yeardown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':Maintenance_Price_Year__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':Maintenance_Price_Year__c')).val(Maintenance_Price_Yeardown);
            // 保修类型
            var GuranteeTypedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':GuranteeType')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':GuranteeType')).val(GuranteeTypedown);
            //产品保修期
            var ProductEntend_gurantee_period_alldown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':ProductEntend_gurantee_period_all__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':ProductEntend_gurantee_period_all__c')).val(ProductEntend_gurantee_period_alldown);
            //产品计提金额
            var ProductGuranteePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':ProductGuranteePrice__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':ProductGuranteePrice__c')).val(ProductGuranteePricedown);
            //产品no discount price
            var ProductServicePricedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':productServicePrice__c')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':productServicePrice__c')).val(ProductServicePricedown);
            //最新产品内贸service price
            var latestProductIntra_Trade_Servicedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':latestProductIntra_Trade_Service')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestProductIntra_Trade_Service')).val(latestProductIntra_Trade_Servicedown);
            //最新保修类型
            var latestGuranteeTypedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':latestGuranteeType')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestGuranteeType')).val(latestGuranteeTypedown);
            //最新产品多年保修期
            var latestProductEntend_gurantee_period_alldown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':latestProductEntend_gurantee_period_all')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestProductEntend_gurantee_period_all')).val(latestProductEntend_gurantee_period_alldown);
            //最新内贸计提金额
            var latestIntra_Trade_Guranteedown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':latestIntra_Trade_Gurantee')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestIntra_Trade_Gurantee')).val(latestIntra_Trade_Guranteedown);
            // 最新 维修合同报价
            var latestMaintenance_Price_Yeardown = j$(escapeVfId('Page:mainForm:block:lists:' + j +
                ':latestMaintenance_Price_Year')).value();
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestMaintenance_Price_Year')).val(latestMaintenance_Price_Yeardown);
            // 医院单价 取消 disabled
            var UnitPriceDisableddown = j$(escapeVfId('Page:mainForm:block:lists:' + j + ':UnitPrice')).prop('disabled');
            if (UnitPriceDisableddown == true) {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).attr('disabled', 'disabled');
            } else {
                j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).removeAttr('disabled');
            }
            // 多年保修  2019/07/25  end
            //単位
            //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Qty')).text());
            //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty_Unit')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Qty_Unit')).value());
            //小計
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Subtotal__c')).value());
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':TotalPrice')).text());
            //Product_SFDA
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_SFDA')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_SFDA')).value());
            //NameCode
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameCode')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':NameCode')).value());
            //Product_Name
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Name')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Name')).value());
            //Product_ListPrice
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_ListPrice')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_ListPrice')).value());
            //Product_Cost
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Cost')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Product_Cost')).value());
            //Sales_Possibility
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Sales_Possibility')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Sales_Possibility')).value());
            //Cost
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Cost')).value());
            //CostSubTotal
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':CostSubTotal')).value());
            //Bsscategory
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Bsscategory')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':Bsscategory')).value());
            //PricebookEntryId
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':PricebookEntryId')).val(j$(escapeVfId('Page:mainForm:block:lists:' + j + ':PricebookEntryId')).value());
        } else {
            //製品番号
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).val('');
            //LineNo
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':indexNo')).text('');
            //SFDA
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':SFDA')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Status__c')).text('');
            //供应商
            //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName__c')).val();
            //Id
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Id')).val('');
            //品目名
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Name__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Nametext1')).text('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Nametext1')).attr('href', '#');
            //ListPrice
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPrice')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':ListPricetext')).text('');
            //Storagestatus
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatus')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Storagestatustext')).text('');
            //Specifications
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Specifications')).text('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Specifications')).val('');
            //供应商
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':VenderName')).html('');
            //SFDC停止预警 lt 20211009 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate1')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate')).html('');
            //SFDC停止预警 lt 20211009 end
            //配套名
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Set_Name__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Set_Name')).text('');
            //数量
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Quantity')).val('');
            //価格
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).val('');
            //単位
            //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty')).text('');
            //j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Qty_Unit')).val('');
            //CHAN-B4YAB8 2018/9/28 販売店価格 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val('');
            //CHAN-B4YAB8 2018/9/28 販売店価格 end
            //CHAN-B4YAB8 2018/9/28 販売店小計 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text('');
            //CHAN-B4YAB8 2018/9/28 販売店小計 end
            //CHAN-B4YAB8 2018/10/31 赠送 start
            if (document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c') != null) {
                document.getElementById('Page:mainForm:block:lists:' + i + ':Present__c').checked = false;
            }
            //CHAN-B4YAB8 2018/10/31 赠送 end
            //小計
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Subtotal__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':TotalPrice')).text('');
            //Product_SFDA
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_SFDA')).val('');
            //NameCode
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':NameCode')).val('');
            //Product_Name
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Name')).val('');
            //Product_ListPrice
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_ListPrice')).val('');
            //Product_Cost
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Product_Cost')).val('');
            //Sales_Possibility
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Sales_Possibility')).val('');
            //Cost
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Cost')).val('');
            //CostSubTotal
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':CostSubTotal')).val('');
            //Bsscategory
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Bsscategory')).val('');
            //PricebookEntryId
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':PricebookEntryId')).val('');
            //CHAN-B4YAB8 2018/9/28 販売店価格 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_UnitPrice')).val('');
            //CHAN-B4YAB8 2018/9/28 販売店価格 end
            //CHAN-B4YAB8 2018/9/28 販売店小計 start
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':AgencySubtotal__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Agency_TotalPrice')).text('');
            //CHAN-B4YAB8 2018/9/28 販売店小計 end
            // 多年保修  2019/07/25 start
            // 多年保修
            if (document.getElementById('Page:mainForm:block:lists:' + j + ':warranty:itemMultiYearWarranty') != null &&
                document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty') != null) {
                document.getElementById('Page:mainForm:block:lists:' + i + ':warranty:itemMultiYearWarranty').checked =
                    false;
            }
            // 医院单价 取消 disabled
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':UnitPrice')).removeAttr('disabled');
            // 保修
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':warranty:warrantyType')).val('');
            // 保修期
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':GuaranteePeriod__c')).val('');
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':itemGuaranteePeriod')).text('');
            // 计提年限
            j$(escapeVfId('Page:mainForm:block:lists:' + i + ':provistonPeriod__c')).val('');
            //是否取消市场多年保修
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':If_Cancel_Guarantee__c')).val('');
            //no discount price
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':ServicePrice__c')).val('');
            //no discount total
            if (document.getElementById('Page:mainForm:block:lists:' +
                    i + ':warranty2:NoDiscountTotal') != null) {
                document.getElementById('Page:mainForm:block:lists:' + i +
                    ':warranty2:NoDiscountTotal').value = '';
            }
            // 供应商取消 disable
            //计提金额
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':GuranteePrice__c')).val('');
            //维修合同报价
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':Maintenance_Price_Year__c')).val('');
            // 保修类型
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':GuranteeType')).val('');
            //产品保修期
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':ProductEntend_gurantee_period_all__c')).val('');
            //产品计提金额
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':ProductGuranteePrice__c')).val('');
            //产品no discount price
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':productServicePrice__c')).val('');
            //最新产品内贸service price
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestProductIntra_Trade_Service')).val('');
            // 保修类型
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestGuranteeType')).val('');
            //最新产品多年保修期
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestProductEntend_gurantee_period_all')).val('');
            //最新内贸计提金额
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestIntra_Trade_Gurantee')).val('');
            //最新维修合同报价
            j$(escapeVfId('Page:mainForm:block:lists:' + i +
                ':latestMaintenance_Price_Year')).val('');
            // 多年保修  2019/07/25  end
        }
    }
    return true;
}
function setProductEntryGateway(str) {
    blockme();
    setProductEntry(str);
}
// excel 导入文件按钮弹出页面输入数据后,点保存触发这个;
function excelImportGateway(str) {
    blockme();
    excelImport(str);
}
// xudan 20140626 行追加ロジック
function addRowJs(idx) {
    // 真ん中の空行を削除
    var lastLineNoNext = getLastLineNoNext(document);
    var last = j$(escapeVfId('Page:mainForm:block:lists:149:Product_Id')).value();
    if (last != null && last != "") {
        alert("无法再添加新的行");
    } else {
        blockme();
        addRow(idx);
    }
}
//精琢技术 2021/02/08 start
//页面输入添加行
function addMultipleRowJS(idx) {
    //需要增加的行号
    var addRow = j$(escapeVfId('addMultipleRow')).value();
    if (!idx) {
        idx = addRow;
    }
    // 真ん中の空行を削除
    var lastLineNoNext = getLastLineNoNext(document);
    var last = j$(escapeVfId('Page:mainForm:block:lists:149:Product_Id')).value();
    if (last != null && last != "") {
        alert("无法再添加新的行");
    } else {
        blockme();
        addMultipleRow(idx);
        //关闭dialog
        popupBox.hide();
        //给前端行号赋值 多处用
        QuoteEntryMaxLine = QuoteEntryMaxLine + addRow;
    }
}
// SFDC停止预警(预计消耗到期日<3个月 标红) lt 20210927 add start
function MarkRed() {
    for (var i = 0; i < QuoteEntryMaxLine; i++) {
        var a = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Assert')).value();
        var b = j$(escapeVfId('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate')).value();
        if (a != '') {
            //GMT转标准日期格式(gttDate)
            //得到得预计消耗日期为GMT格式
            // let date = new Date(b);
            // let gttDate = date.getFullYear()+'/'+(date.getMonth() + 1)+'/'+date.getDate();
            //获取当前日期(currentdate)
            var date1 = new Date();
            var seperator = "/";
            var year = date1.getFullYear();
            var month = date1.getMonth() + 1;
            var day = date1.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (day >= 0 && day <= 9) {
                day = "0" + day;
            }
            var currentdate = year + seperator + month + seperator + day;
            //预计消耗到期日  -  当前日  相差天数(difDate)
            var ndate = new Date(currentdate);
            var nowDate = ndate.getTime();
            var edate = new Date(b);
            var endDate = edate.getTime();
            var difDate = (endDate - nowDate) / ((1000 * 60 * 60 * 24));
            //判断
            if (difDate < 90) {
                document.getElementById('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate').style.color = "red";
            }else{
                document.getElementById('Page:mainForm:block:lists:' + i + ':Estimated_ConsumptionDueDate').style.color = "black";
            }
        }
    }
}
// SFDC停止预警(预计消耗到期日<3个月 标红) lt 20210927 add end