用 FileSaver 导出excel表

//   处理数据
   function data(content) {
        console.log("数据处理开始.sheet..");

        var wb = new Workbook();
        $.each(content.data, function (index, dataObj) {
            
            var scmPcinfor = dataObj.scmPcinfor;//车主相关
            var scmInventory = dataObj.scmInventory;//车辆信息
            var tissueName = scmInventory.tissueName; // console.log("tissueName=" + tissueName); //店名
         //spc
         var scmPricePolicyNew = dataObj.content.scmPricePolicyNew;//新政策
         var scmPackageDetails = dataObj.content.scmPackageDetails;//精品
         var scmInsuranceDetails = dataObj.content.scmInsuranceDetails;//保险
         //savedPs
         var savedPs = dataObj.content.savedPs; // []
            //estimateGrossProfit 预估毛利
         var estimateGrossProfit = dataObj.content.estimateGrossProfit;
            //前三行数据 //订单编号
            var orderCode = dataObj.orderCode;  //console.log("订单编号=orderCode=>" + orderCode);
         //订单日期
            var orderDate = getMyDateF(dataObj.orderDate); //console.log("订单日期=orderDate=>" + orderDate);
         //车主姓名
         var ownerName = dataObj.ownerName; //console.log("车主姓名=ownerName=>" + ownerName);
         //turnTel 车主电话,加密
            var ownerTel = turnTelF(dataObj.ownerTel);  //console.log("车主电话(加密)=turnTel=>" + ownerTel);
         //销售顾问
         var chargerName = dataObj.chargerName;  //console.log("销售顾问=chargerName=>" + chargerName);
         //expectDealDate 预计交车日期
            var expectDealDate = getMyDateF(dataObj.expectDealDate);
            //第五行数据  documentType identityId validityDate
         // 证件类型
            var documentType =typeNameF(scmPcinfor.documentType);
            //证件号码
            var identityId = scmPcinfor.identityId;
            //订单有效期
            var validityDate = getMyDateF(dataObj.validityDate);
            //6行数据 pcName pcTel indicatorWay
            var pcName = scmPcinfor.pcName;//销售联系人姓名
            var pcTel = turnTelF(scmPcinfor.pcTel);//销售联系人电话
            var indicatorWay = indicatorWayF(scmPcinfor.indicatorWay);//指标方式
            //7行数据 fcContactName fcContactTel gender
            var fcContactName = dataObj.fcContactName;//售后联系人姓名
         var fcContactTel = turnTelF(dataObj.fcContactTel);//售后联系人电话
            var gender = genderF(scmPcinfor.gender);//性别
         //8行数据 localName address
         var localName = localnameF(scmPcinfor.isLocal);//本地/外地
         var address = scmPcinfor.address;//通信地址
         //9行数据 dealWay traderName traderExpenses
         var dealWay = dealWayNameF(dataObj.dealWay);//成交类型
         var traderName = (dataObj.traderName == "请选择") ? "" : dataObj.traderName;//经销商
         var traderExpenses = parseFloat(dataObj.traderExpenses).toFixed(1);//佣金
         //10 ownerNature
         var ownerNature = ownerNatureF(dataObj.ownerNature);//车主性质
         //11 intendModelName intendDetailModelName
         var intendModelName = scmPcinfor.intendModelName;//车型
          var intendDetailModelName = scmPcinfor.intendDetailModelName;//车型号
            //12            var carFrameNoOder = scmInventory.carFrameNo;//车架号
         var engineNoOder = scmInventory.engineNo;//发动机号
            //13         var vehicleColorTextOder = scmInventory.vehicleColorText;//车身颜色
         var interiorColorTextOder = scmInventory.interiorColorText;//内饰颜色
            //14            var carTopColorTextOder = scmInventory.carTopColorText;//车顶颜色
            var hubOder = scmInventory.hub;//轮廓样式
            //15         var inventoryStateOder = carStateF(scmInventory.inventoryState);//车辆状态
            var quotationGmdOder = parseFloat(0).toFixed(1);//总经理优惠额度
            var quotationScMOder = parseFloat(0).toFixed(1);//销售经理优惠额度
            //16            var quotationCrmOder =parseFloat(0).toFixed(1);//大客户优惠额度
            var quotationScLOder = parseFloat(0).toFixed(1);//展厅经理优惠额度
            var quotationScOder = parseFloat(0).toFixed(1);//销售顾问优惠额度
            //17            var priceGuideOder = parseFloat(scmInventory.priceGuide).toFixed(1);//指导价
            var carDisCashOder =  parseFloat(dataObj.carDisCash).toFixed(1);//现金优惠
            var carPriceOder = parseFloat(accSub(priceGuideOder , carDisCashOder)).toFixed(1);//车辆价格
         //精品

            var boutique = 0;//精品条数
            var guidePricecount = parseFloat(0).toFixed(1);//精品包指导价合计
            var contents = parseFloat(0).toFixed(1);//精品包总自费

            var productsGuidePrice = parseFloat(0).toFixed(1); //其他精品指导价
            var productsDiscount = parseFloat(0).toFixed(1); // 其他精品折扣%
            var productsTotalSelfePrice = parseFloat(0).toFixed(1); //计算付款金额的精品自费
            var packageCost= parseFloat(0).toFixed(1); //
            var packageGuidePriceNew= parseFloat(0).toFixed(1);
            var packageGuidePrice= parseFloat(0).toFixed(1);
            var scmPac = 0;
            var yHui = parseFloat(0).toFixed(1);//精品 -等同现金优惠
            //保险
            var scmIdcount=0;//保险的条数
         var insurancePrice = parseFloat(0).toFixed(1); //保险合计
            var countOrder = parseFloat(0).toFixed(1);
            var insuranceBusinesscount = parseFloat(0).toFixed(1);
            var insuranceCompulsorycount = parseFloat(0).toFixed(1);
            var carBoatTaxcount = parseFloat(0).toFixed(1)
            var repairRebatecount = parseFloat(0).toFixed(1);
            var peichecount = parseFloat(0).toFixed(1);

            var fukPrice = parseFloat(0).toFixed(1); //付款金额

            var approvePositionNameOder = "";//终审岗位
         if(scmPricePolicyNew != null){
                quotationGmdOder = parseFloat(scmPricePolicyNew.quotationGmd).toFixed(1);
                quotationScMOder = parseFloat(scmPricePolicyNew.quotationScM).toFixed(1);
                quotationCrmOder =parseFloat(scmPricePolicyNew.quotationCrm).toFixed(1);
                quotationScLOder = parseFloat(scmPricePolicyNew.quotationScL).toFixed(1);
                quotationScOder = parseFloat(scmPricePolicyNew.quotationSc).toFixed(1);

                if (dataObj.dealWay == 1) { //大客户
                    if (dataObj.discountTatle >= scmPricePolicyNew.quotationGmd) {//大于总经理优惠额度,需要总部审批
                        approvePositionNameOder = "总部审核";
                    } else if (dataObj.discountTatle >= scmPricePolicyNew.quotationCrm) {//大于大客户优惠额度
                        approvePositionNameOder = "总经理";
                    } else {
                        approvePositionNameOder = "展厅经理";
                    }
                }else{
                    if (dataObj.discountTatle >= scmPricePolicyNew.quotationGmd) {//大于总经理优惠额度,需要总部审批
                        approvePositionNameOder= "总部审核";
                    }else if (dataObj.discountTatle >= scmPricePolicyNew.quotationScM) {//大于销售经理优惠额度
                        approvePositionNameOder= "总经理";
                    }else if (dataObj.discountTatle >= scmPricePolicyNew.quotationScL) {//大于展厅经理优惠额度
                        approvePositionNameOder = "销售经理-总监";
                    }else if (dataObj.discountTatle >= scmPricePolicyNew.quotationSc) {//大于销售顾问优惠额度
                        approvePositionNameOder = "展厅经理";
                    }else{
                        approvePositionNameOder= "展厅经理";
                    }
                }
         }
            if (content.positionCode == "SC-L") {// SC-L
                quotationGmdOder = parseFloat(0).toFixed(1);
                quotationScMOder = parseFloat(0).toFixed(1);
            } else if (content.positionCode == "SC-M"){// SC-M
                quotationGmdOder = parseFloat(0).toFixed(1);
            }

            var sheet = ownerName + "(" + (index+1) + ")";//sheet表名
            console.log("sheet表名==>" + sheet);
         var sheetData = [];
         sheetData.push([
                {"v": "订单明细", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 23, bold: true }, alignment: {horizontal: "center"}}},
                {"v": "", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center"}}},
                {"v": "", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center"}}},
                {"v": "", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center"}}},
                {"v": "", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center"}}},
                {"v": "", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center"}}},
                {"v": "", "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center"}}}
            ]);
            //2行数据模板 1-0
            sheetInsertd("导出时间", dateF(), "", "店名称", tissueName, "", "");
            //3行数据模板 顾客信息 2-
            sheetInsertd("顾客信息", "订单编号", orderCode, "销售顾问", chargerName, "订单日期", orderDate);
            //4行数据模板 顾客信息  3-
            sheetInsertd("顾客信息", "车主姓名", ownerName, "电话", ownerTel, "预计交车日期", expectDealDate);
            //5行数据模板 顾客信息  4-
            sheetInsertd("顾客信息", "证件类型", documentType, "证件号码", identityId, "订单有效期", validityDate);
         //6行数据模板 顾客信息  5-
            sheetInsertd("顾客信息", "销售联系人姓名", pcName, "销售联系人电话", pcTel, "指标方式", indicatorWay);
            //7行数据模板 顾客信息  6-
            sheetInsertd("顾客信息", "售后联系人姓名", fcContactName, "售后联系人电话", fcContactTel, "性别", gender);
            //8行数据模板 顾客信息  7-
            sheetInsertd("顾客信息", "本地/外地", localName, "通信地址", address, "", "");
         //9行数据模板 顾客信息 8-
            sheetInsertd("顾客信息", "成交类型", dealWay, "经销商", traderName, "佣金", traderExpenses);
            //10行数据模板 顾客信息 9-
            sheetInsertd("顾客信息", "车主性质", ownerNature, "", "", "", "");
            //11 车辆限价信息 10-
            sheetInsertd("车辆限价信息", "车型", intendModelName, "", "车型号", intendDetailModelName, "");
            //12 车辆限价信息 11-
            sheetInsertd("车辆限价信息", "车架号", carFrameNoOder, "", "发动机号", engineNoOder, "");
            //13 车辆限价信息 12-
            sheetInsertd("车辆限价信息", "车身颜色", vehicleColorTextOder, "", "内饰颜色", interiorColorTextOder, "");
            //14 车辆限价信息 13-
            sheetInsertd("车辆限价信息", "车顶颜色", carTopColorTextOder, "", "轮廓样式", hubOder, "");
            //15 车辆限价信息 14-
            sheetInsertd("车辆限价信息", "车辆状态", inventoryStateOder, "总经理优惠额度", quotationGmdOder, "销售经理优惠额度", quotationScMOder);
            //16 车辆限价信息 15-
            sheetInsertd("车辆限价信息", "大客户优惠额度", quotationCrmOder, "展厅经理优惠额度", quotationScLOder, "销售顾问优惠额度", quotationScOder);
            //17 车辆限价信息 16-
            sheetInsertd("车辆限价信息", "指导价", priceGuideOder, "现金优惠", carDisCashOder, "车辆价格", carPriceOder);
            //18 车辆限价信息 17-
            sheetInsertd("车辆限价信息", "优惠合计", yHui, "预估毛利", estimateGrossProfit, "终审岗位", approvePositionNameOder);
            /* 精品 scmPackageDetails*/

            //精品
            if (dataObj.packageIds != null && !dataObj.packageIds == "") {//精品有数据
                var scmPackageDetails = dataObj.content.scmPackageDetails;
                if(scmPackageDetails!=null) {
                    //占用行数
               var scmPackageDetailsLength = scmPackageDetails.length;
                    scmPac = Math.round( scmPackageDetailsLength/ 2) ;
                    var odd = scmPackageDetailsLength % 2;   console.log("精品占用行数=单双数=>" + scmPac + " " + odd); //单双数
                    var stringEvenKey = "";
                    var stringEvenValue = "";

                    var stringOddKey = "";
                    var stringOddValue = "";

                    $.each(scmPackageDetails, function (index, scmPackageDetail) {
                        guidePricecount = accAdd(guidePricecount, (parseFloat(scmPackageDetail.guidePrice).toFixed(2)) * (parseFloat(scmPackageDetail.number).toFixed(1)));
                        contents = accAdd(contents, parseFloat(scmPackageDetail.countPrice).toFixed(1));
                        if (index % 2 == 0) {
                            stringEvenKey = scmPackageDetail.packageName + "(" + scmPackageDetail.number + ")";
                            stringEvenValue = parseFloat(scmPackageDetail.countPrice).toFixed(1);
                        } else {
                            stringOddKey = scmPackageDetail.packageName + "(" + scmPackageDetail.number + ")";
                            stringOddValue = parseFloat(scmPackageDetail.countPrice).toFixed(1);

                            sheetInsertd("", stringEvenKey, stringEvenValue, stringOddKey, stringOddValue, "精品包总自费", parseFloat(contents).toFixed(1));
                        };
                        if (odd == 1 && index == (scmPackageDetailsLength-1)){
                            sheetInsertd("", stringEvenKey, stringEvenValue, "", "", "精品包总自费", parseFloat(contents).toFixed(1));
                        };
                        packageGuidePriceNew = parseFloat(accAdd(packageGuidePriceNew , accMul(scmPackageDetail.carSalePrice , scmPackageDetail.number))).toFixed(1);
                        packageGuidePrice = parseFloat(accAdd(packageGuidePrice , accMul(scmPackageDetail.guidePrice , scmPackageDetail.number))).toFixed(1);
                    });
                    sheetInsertd("附加费用", "精品包指导价合计", parseFloat(guidePricecount).toFixed(2), "", "", "", "");
                };
            }else{ //精品没有数据
                guidePricecount = parseFloat(0).toFixed(1);
                sheetInsertd("附加费用", "精品包指导价合计", guidePricecount, "", "", "精品包总自费", parseFloat(contents).toFixed(1));
            }
            console.log("精品包总自费==>" + contents);
         //其他精品指导价 ProductsGuidePrice
         productsGuidePrice = parseFloat(dataObj.productsGuidePrice).toFixed(1);
            // 其他精品折扣% productsDiscount
            productsDiscount = parseFloat(dataObj.productsDiscount).toFixed(1);
            sheetInsertd("附加费用", "其他精品指导价", productsGuidePrice, "其他精品折扣%", productsDiscount, "其他精品自费", parseFloat(accMul(productsGuidePrice, productsDiscount/100)).toFixed(1));
            //精品指导价总合计
         //精品总指导价
         var productsTotalPrice = parseFloat(accAdd(guidePricecount , productsGuidePrice)).toFixed(1);
         //精品总自费

         productsTotalSelfePrice = parseFloat(accAdd(contents , accMul(productsGuidePrice, productsDiscount/100))).toFixed(1);
            var productsYHuiJingPrice = parseFloat(accSub(packageCost , contents)).toFixed(1);
            sheetInsertd("附加费用", "精品指导价总合计", productsTotalPrice, "精品总自费", productsTotalSelfePrice, "打折额度", parseFloat(accSub(productsTotalPrice , productsTotalSelfePrice)).toFixed(1));
            sheetInsertd("附加费用", "精品成本合计", parseFloat(packageCost).toFixed(1), "", "等同现金优惠", productsYHuiJingPrice, "");
         //保险
         var insurers = dataObj.content.insurers;
            sheetInsertd("附加费用", "保险公司", insurers, "", "其他/打包险种", parseFloat(dataObj.insuranceOtherBusiness).toFixed(1), "");
            var scmInsuranceDetails = dataObj.content.scmInsuranceDetails;
            if(scmInsuranceDetails !=null && scmInsuranceDetails.length >0){
               var scmInsuranceDetailsLength = scmInsuranceDetails.length;
                scmIdcount = Math.round( scmInsuranceDetailsLength / 2) ;
                var odd = scmInsuranceDetailsLength % 2;   console.log("保险占用行数=单双数=>" + scmIdcount + " " + odd); //单双数
                var stringEvenKey = "";
                var stringEvenValue = "";

                var stringOddKey = "";
                var stringOddValue = "";
                $.each(scmInsuranceDetails , function(index , sicdts){
                    var insuranceName = sicdts.insuranceName;
                    console.log("保险的name==>" + insuranceName);
                    console.log("保险value==>" + sicdts.insurancePrice);

                    if (index % 2 == 0) {
                        stringEvenKey = sicdts.insuranceName ;
                        stringEvenValue = parseFloat(sicdts.insurancePrice).toFixed(1);

                    } else {
                        stringOddKey = sicdts.insuranceName;
                        stringOddValue = parseFloat(sicdts.insurancePrice).toFixed(1);

                        sheetInsertd( "附加费用", "险种", stringEvenKey, stringEvenValue, stringOddKey, stringOddValue, "");
                    }
                    if (odd != 0 && index == (scmInsuranceDetailsLength - 1)) {
                        sheetInsertd( "附加费用", "险种", stringEvenKey, stringEvenValue, stringOddKey, stringOddValue, "");
                    }
                    insurancePrice = parseFloat(accAdd(insurancePrice , parseFloat(sicdts.insurancePrice).toFixed(1))).toFixed(1);
                });
            }else{
                sheetInsertd( "附加费用", "险种", "", "", "", "", "");
         };

            if(savedPs!=null){
                $.each(savedPs, function (index, spt){
                    if(spt.parameterCode == "o1_productsRebate"){//订单精品成本比例 80
                        countOrder=parseFloat(spt.parameterValue).toFixed(1);
                    }else if(spt.parameterCode == "o3_insuranceBusiness"){//商业险
                        insuranceBusinesscount = parseFloat(spt.parameterValue).toFixed(1); //0
                    }else if(spt.parameterCode == "o4_insuranceCompulsory"){//交强险
                        insuranceCompulsorycount=parseFloat(spt.parameterValue).toFixed(1);
                    }else if(spt.parameterCode == "o5_carBoatTax"){//车船税
                        carBoatTaxcount=parseFloat(spt.parameterValue).toFixed(1);
                    }else if(spt.parameterCode == "o2_repairRebate"){//赠送维修
                        repairRebatecount=parseFloat(spt.parameterValue).toFixed(1);
                    }else if(spt.parameterCode == "o91_EnablePackageCost"){
                        peichecount = parseFloat(spt.parameterValue).toFixed(1); //精品配车销售成本
                    };
                });
            }else if(dataObj.orderParams != null){
                var orderParams = dataObj.orderParams.split("\\,");
                var orderParamvalue = null;
                $.each(dataObj.orderParams, function (index, odp){
                    orderParamvalue = orderParams[index].split("\\:");
                    if(orderParamvalue[0] == "o1_productsRebate"){
                        countOrder = parseFloat(orderParamvalue[1]).toFixed(1);
                    }else if(orderParamvalue[0] == "o3_insuranceBusiness"){//商业险
                        insuranceBusinesscount = parseFloat(orderParamvalue[1]).toFixed(1);
                    }else if(orderParamvalue[0] == "o4_insuranceCompulsory"){//交强险
                        insuranceCompulsorycount = parseFloat(orderParamvalue[1]).toFixed(1);
                    }else if(orderParamvalue[0] == "o5_carBoatTax"){//车船税
                        carBoatTaxcount = parseFloat(orderParamvalue[1]).toFixed(1);
                    }else if(orderParamvalue[0] == "o2_repairRebate"){//赠送维修
                        repairRebatecount = parseFloat(orderParamvalue[1]).toFixed(1);
                    }else if(orderParamvalue[0] == "o91_EnablePackageCost"){//精品配车销售成本
                        peichecount = parseFloat(orderParamvalue[1]).toFixed(1);
                    };
                });
            };
            // 附加费用 商业险指导价 商业险折扣率 商业险自费

         // 商业险指导价 = 商险价格 + 其他商险
            var insuranceBusiness = parseFloat(accAdd(insurancePrice , dataObj.insuranceOtherBusiness)).toFixed(1);
            var insuranceBusinessDiscount =  parseFloat(dataObj.insuranceBusinessDiscount).toFixed(1);
            // 商业险自费 = 商业险指导价 * 商业险折扣率

            var insuranceBusinessSelf = parseFloat(accMul(insuranceBusiness , insuranceBusinessDiscount/100)).toFixed(1);

            sheetInsertd("附加费用", "商业险指导价", insuranceBusiness, "商业险折扣率", insuranceBusinessDiscount, "商业险自费", insuranceBusinessSelf);

            // 打折额度 商业险成本 等同现金优惠

            var discountLimitC01 = parseFloat( accSub(insuranceBusiness , insuranceBusinessSelf)).toFixed(1);

         var insuranceCostC01 = parseFloat( accMul(insuranceBusiness , insuranceBusinesscount/100)).toFixed(1);
         // 等同现金优惠 = 商业险成本 - 商业险自费
         var businessInsuranceEquivalent = parseFloat(accSub(insuranceCostC01 , insuranceBusinessSelf)).toFixed(1);
         sheetInsertd("附加费用", "打折额度", discountLimitC01, "商业险成本", insuranceCostC01, "等同现金优惠", businessInsuranceEquivalent);
         // 交强险指导价  交强险折扣率 交强险自费
         var insuranceCompulsory = parseFloat(dataObj.insuranceCompulsory).toFixed(1);
         //交强险自费 = 交强险指导价 * 交强险折扣率
         var compulsoryInsurance = parseFloat( accMul(insuranceCompulsory , insuranceCompulsorycount/100)).toFixed(1);
            sheetInsertd("附加费用", "交强险指导价", insuranceCompulsory, "交强险折扣率", insuranceCompulsorycount, "交强险自费", compulsoryInsurance);
            // 打折额度 交强险成本 等同现金优惠
            var discountLimitC51 = parseFloat( accSub(insuranceCompulsory , compulsoryInsurance)).toFixed(1);
            var insuranceCostC51 = parseFloat( accMul(insuranceCompulsory , insuranceCompulsorycount/100)).toFixed(1);
            var equivalentDiscountC51 = parseFloat(accSub(insuranceCostC51 , compulsoryInsurance)).toFixed(1);
         //等同优惠 = 交强险成本 - 交强险自费
            sheetInsertd("附加费用", "打折额度", discountLimitC51, "交强险成本", insuranceCostC51, "等同现金优惠", equivalentDiscountC51);

            // 车船税指导价 车船税折扣率 车船税自费
            var carBoatTax = parseFloat( dataObj.carBoatTax ).toFixed(1);
            var carBoatTaxDiscount = parseFloat(dataObj.carBoatTaxDiscount ).toFixed(1);
            //车船税自费 = 车船税指导价 * 车船税折扣率
            var taxSelf = parseFloat( accMul( carBoatTax, carBoatTaxDiscount/100)).toFixed(1);
            sheetInsertd("附加费用", "车船税指导价", carBoatTax, "车船税折扣率", carBoatTaxDiscount, "车船税自费", taxSelf);

            // 打折额度 车船税成本 等同现金优惠
            var discountLimitTax = parseFloat( accSub( carBoatTax, taxSelf)).toFixed(1);
            var insuranceCostTax = parseFloat( accMul( carBoatTax, carBoatTaxcount/100)).toFixed(1);
            var equivalentDiscountTax = parseFloat(accSub( insuranceCostTax, taxSelf)).toFixed(1);
            //等同优惠 = 交强险成本 - 交强险自费
            sheetInsertd("附加费用", "打折额度", discountLimitTax, "交强险成本", insuranceCostTax, "等同现金优惠", equivalentDiscountTax);

            //验车上牌费 延保费 PDS出库费
         var validateExpenses = parseFloat(dataObj.validateExpenses).toFixed(1);
         var guaranteeExpenses = parseFloat(dataObj.guaranteeExpenses).toFixed(1);
            var deliveryCost = parseFloat(dataObj.deliveryCost).toFixed(1);
            sheetInsertd("附加费用", "验车上牌费", validateExpenses, "延保费", guaranteeExpenses, "PDS出库费", deliveryCost);
         //赠送维修 repairGiftExpenses 维修成本 *repairRebatecount 等同现金优惠
            var repairGiftExpenses = parseFloat(dataObj.repairGiftExpenses).toFixed(1);
            var presentMaintenanceCost = parseFloat( accMul( repairGiftExpenses, repairRebatecount/100)).toFixed(1);
            sheetInsertd("附加费用", "赠送维修", repairGiftExpenses, "维修成本", presentMaintenanceCost, "等同现金优惠", presentMaintenanceCost);
            //金融补贴 大客户补贴
            var subsidyFinance = parseFloat(dataObj.subsidyFinance).toFixed(1);
            var subsidyCustomer = parseFloat(dataObj.subsidyCustomer).toFixed(1);
            sheetInsertd("附加费用", "金融补贴", subsidyFinance, "", "大客户补贴", subsidyCustomer, "");
         //本地上牌补贴 二手车补贴
            var subsidyLocalLicence = parseFloat(dataObj.subsidyLocalLicence).toFixed(1);
            var subsidyUsedCar = parseFloat(dataObj.subsidyUsedCar).toFixed(1);
            sheetInsertd("附加费用", "本地上牌补贴", subsidyLocalLicence, "", "二手车补贴", subsidyUsedCar, "");

         //按揭 按揭公司 mortgageCompany 首付金额 oncePayment 贷款金额 loanAmount
            var mortgageCompany = dataObj.mortgageCompany;
            var oncePayment = parseFloat(dataObj.oncePayment).toFixed(1);
            var loanAmount = parseFloat(dataObj.loanAmount).toFixed(1);
            sheetInsertd("按揭", "按揭公司", mortgageCompany, "首付金额", oncePayment, "贷款金额", loanAmount);
         //按揭 金融服务费 manageExpenses 续保押金 insuranceAmount
            var manageExpenses = parseFloat(dataObj.manageExpenses).toFixed(1);
            var insuranceAmount = parseFloat(dataObj.insuranceAmount).toFixed(1);
            sheetInsertd("按揭", "金融服务费", manageExpenses, "续保押金", insuranceAmount, "", "");

            //开票信息 购置税 receiptPurchaseTax 定金金额 receiptFrontMoney 二手车车款 receiptUsedCar
            var receiptPurchaseTax = parseFloat(dataObj.receiptPurchaseTax).toFixed(1);
            var receiptFrontMoney = parseFloat(dataObj.receiptFrontMoney).toFixed(1);
            var receiptUsedCar = parseFloat(dataObj.receiptUsedCar).toFixed(1);
            sheetInsertd("开票信息", "购置税", receiptPurchaseTax, "定金金额", receiptFrontMoney, "二手车车款", receiptUsedCar);
            //开票信息 付款金额(138714.0)  paymentAmount 开票价格 receiptAmount 付款方式 fukWay--paymentWayName
            var paymentAmount = parseFloat(dataObj.paymentAmount).toFixed(1);
            var receiptAmount = parseFloat(dataObj.receiptAmount).toFixed(1);

            //最后计算几个合计
            //精品成本合计 等同现金优惠
            var finishedPackageProduct = parseFloat(0).toFixed(1);
            if(scmPackageDetails!=null){
                if(peichecount == 1){
                    packageCost =packageGuidePriceNew;
                }else{
         //精品的成本在这里不按照各自的成本核算,而是从店参数的精品成本进行统一核算
                    packageCost = parseFloat(accMul(packageGuidePrice , countOrder / 100)).toFixed(2);
                }
                packageCost = parseFloat(accAdd(packageCost , accMul(dataObj.productsGuidePrice , countOrder/100))).toFixed(1);
            }else{
                packageCost=parseFloat(accMul( dataObj.productsGuidePrice,  countOrder/100)).toFixed(2);
            }
            //精品陈本的等同优惠 = 精品成本 packageCost - 精品总自费 productsTotalSelfePrice
            productsYHuiJingPrice = parseFloat(accSub(packageCost , productsTotalSelfePrice)).toFixed(1);
            console.log("精品成本的等同优惠 ==>" + productsYHuiJingPrice);

            //优惠合计
            yHui =parseFloat(accAdd(accAdd(accAdd(traderExpenses , productsYHuiJingPrice) , accAdd(carDisCashOder , presentMaintenanceCost))
                , accAdd(accAdd(accAdd(businessInsuranceEquivalent , equivalentDiscountC51) , accAdd(subsidyCustomer , subsidyLocalLicence) )
            , subsidyUsedCar))).toFixed(1);
            console.log("优惠合计==>" + yHui);
         //付款金额
           /* carGuidePrice //汽车指导价格 - carDisCashOder //现金优惠  - loanAmount //贷款金额  + manageExpenses // 金融服务费  + insuranceAmount //续保押金 + productsTotalSelfePrice //精品总自费  + insuranceBusinessSelf //商业险自费  + compulsoryInsurance //交强险自费  + insuranceCostTax //车船税成本  + validateExpenses //验车上牌费  + guaranteeExpenses //延保费  + deliveryCost //PDS出库费  - subsidyFinance //金融补贴  + subsidyCustomer //大客户补贴  + subsidyLocalLicence //本地上牌补贴 + subsidyUsedCar //二手车补贴 + receiptPurchaseTax //购置税  -receiptFrontMoney //定金金额  - receiptUsedCar //二手车车款 */
            var carGuidePrice = parseFloat(dataObj.carGuidePrice).toFixed(1);
         fukPrice =
                parseFloat( accAdd(accAdd(accSub(carGuidePrice , carDisCashOder) , accAdd(loanAmount , manageExpenses))
               , accAdd(accAdd(accAdd(insuranceAmount , productsTotalSelfePrice) , accAdd(insuranceBusinessSelf  , compulsoryInsurance))
               , accAdd(accAdd(accAdd(insuranceCostTax  , validateExpenses) , accAdd(guaranteeExpenses , deliveryCost))
               , accAdd(accAdd(accAdd(subsidyFinance , subsidyCustomer) , accAdd(subsidyLocalLicence , subsidyUsedCar))
               , accAdd(accAdd(receiptPurchaseTax , receiptFrontMoney) , receiptUsedCar)))))

                ).toFixed(1);

/*
            console.log("优惠traderExpenses==>" + traderExpenses);
            console.log("优惠productsYHuiJingPrice==>" + productsYHuiJingPrice);
            console.log("优惠presentMaintenanceCost==>" + presentMaintenanceCost);
            console.log("优惠businessInsuranceEquivalent==>" + businessInsuranceEquivalent);
            console.log("优惠equivalentDiscountC51==>" + equivalentDiscountC51);
            console.log("优惠equivalentDiscountTax==>" + equivalentDiscountTax);

            console.log("+优惠 付款carDisCashOder= - =>" + carDisCashOder);
            console.log("+优惠 付款subsidyFinance= - =>" + subsidyFinance);
            console.log("+优惠 付款subsidyCustomer==>" + subsidyCustomer);
            console.log("+优惠 付款subsidyLocalLicence==>" + subsidyLocalLicence);
            console.log("+优惠 付款subsidyUsedCar==>" + subsidyUsedCar);

         console.log("付款carGuidePrice==>" + carGuidePrice);
            console.log("付款loanAmount= - =>" + loanAmount);
            console.log("付款manageExpenses==>" + manageExpenses);
            console.log("付款insuranceAmount==>" + insuranceAmount);
            console.log("付款productsTotalSelfePrice==>" + productsTotalSelfePrice);
            console.log("付款insuranceBusinessSelf==>" + insuranceBusinessSelf);
            console.log("付款compulsoryInsurance==>" + compulsoryInsurance);
            console.log("付款insuranceCostTax==>" + insuranceCostTax);
            console.log("付款validateExpenses==>" + validateExpenses);
            console.log("付款guaranteeExpenses==>" + guaranteeExpenses);
            console.log("付款deliveryCost==>" + deliveryCost);
            console.log("付款receiptPurchaseTax==>" + receiptPurchaseTax);
            console.log("付款receiptFrontMoney= - =>" + receiptFrontMoney);
            console.log("付款receiptUsedCar= - =>" + receiptUsedCar);*/


            console.log("付款金额==>" + parseFloat(fukPrice).toFixed(1));
            var payment = "付款金额\r\n" + "(" + parseFloat(fukPrice).toFixed(1) + ")";
            sheetInsertd("开票信息", payment, paymentAmount, "开票价格", receiptAmount, "付款方式", fukWay(dataObj.paymentWay));
         //备注
            var remark = dataObj.remark == null ? "" : dataObj.remark;
            sheetInsertd("备注", remark, "", "", "", "", "");
         //审批流程
         var appProcess = dataObj.content.appProcess;
            sheetInsertd("审批流程", appProcess, "", "", "", "", "");


            //parseFloat(0).toFixed(1)
         // var  = parseFloat(dataObj.).toFixed(1);
            //sheetInsertd("", "", "", "", "", "", "");
            //sheetInsertd("", "", , "", , "", );
         function sheetInsertd(strOne, strTwo, strThree, strFour, strFive, strSix, strSeven){
                    sheetData.push([
                        {"v": strOne, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12, bold: true }, alignment:{horizontal: "center", vertical: "center"}}},
                        {"v": strTwo, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center", vertical: "center"}}},
                        {"v": strThree, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center", vertical: "center"}}},
                        {"v": strFour, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center", vertical: "center"}}},
                        {"v": strFive, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center", vertical: "center"}}},
                        {"v": strSix, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center", vertical: "center"}}},
                        {"v": strSeven, "s": {border: {top: {style: "thin"}, bottom: {style: "thin"}, left: {style: "thin"}, right:{style: "thin"}},font: {name: "宋体", sz: 12 }, alignment: {horizontal: "center", vertical: "center"}}}
                    ]);

         };
            //sheet1
         //console.log("sheetData==>" + JSON.stringify(sheetData));
            var sheetInsert = wb.addRowsToSheet(sheet, sheetData);
            sheetInsert.mergeCells(sheet, {
                //1行 合并单元格 (横向)
                "s": {"c": 0, "r": 0 },
                "e": {"c": 6, "r": 0 }
            }).mergeCells(sheet, {
                //2行 合并单元格 (横向)
                "s": {"c": 1, "r": 1 },
                "e": {"c": 2, "r": 1 }
            }).mergeCells(sheet, {
                //2行 合并单元格 (横向)
                "s": {"c": 4, "r": 1 },
                "e": {"c": 6, "r": 1 }
            }).mergeCells(sheet, {
                //8行 合并单元格 (横向)
                "s": {"c": 4, "r": 7 },
                "e": {"c": 6, "r": 7 }
            }).mergeCells(sheet, {
                //10行 合并单元格 (横向)
                "s": {"c": 3, "r": 9 },
                "e": {"c": 6, "r": 9 }
            }).mergeCells(sheet, {
                //11行 合并单元格 (横向1)
                "s": {"c": 2, "r": 10 },
                "e": {"c": 3, "r": 10 }
            }).mergeCells(sheet, {
                //11行 合并单元格 (横向2)
                "s": {"c": 5, "r": 10 },
                "e": {"c": 6, "r": 10 }
            }).mergeCells(sheet, {
                //12行 合并单元格 (横向1)
                "s": {"c": 2, "r": 11 },
                "e": {"c": 3, "r": 11 }
            }).mergeCells(sheet, {
                //12行 合并单元格 (横向2)
                "s": {"c": 5, "r": 11 },
                "e": {"c": 6, "r": 11 }
            }).mergeCells(sheet, {
                //13行 合并单元格 (横向1)
                "s": {"c": 2, "r": 12 },
                "e": {"c": 3, "r": 12 }
            }).mergeCells(sheet, {
                //13行 合并单元格 (横向2)
                "s": {"c": 5, "r": 12 },
                "e": {"c": 6, "r": 12 }
            }).mergeCells(sheet, {
                //14行 合并单元格 (横向1)
                "s": {"c": 2, "r": 13 },
                "e": {"c": 3, "r": 13 }
            }).mergeCells(sheet, {
                //14行 合并单元格 (横向2)
                "s": {"c": 5, "r": 13 },
                "e": {"c": 6, "r": 13 }
            }) ;
            if(scmPac > 0){
                sheetInsert.mergeCells(sheet, {
                    //合并单元格 (纵向)
                    "s": {"c": 5, "r": 18 },
                    "e": {"c": 5, "r": 18 + scmPac }
                }).mergeCells(sheet, {
                    //合并单元格 (纵向)
                    "s": {"c": 6, "r": 18 },
                    "e": {"c": 6, "r": 18 + scmPac }
                });
         }else{
                sheetInsert.mergeCells(sheet, {
                    //20行 合并单元格 (横向)
                    "s": {"c": 2, "r": 18 },
                    "e": {"c": 4, "r": 18 }
                });
         };
            sheetInsert.mergeCells(sheet, {
                //23行 合并单元格 (横向1)
                "s": {"c": 2, "r": 21 + scmPac },
                "e": {"c": 3, "r": 21 + scmPac }
            }).mergeCells(sheet, {
                //23行 合并单元格 (横向2)
                "s": {"c": 5, "r": 21 + scmPac },
                "e": {"c": 6, "r": 21 + scmPac }
            }).mergeCells(sheet, {
                //24行 合并单元格 (横向1)
                "s": {"c": 2, "r": 22 + scmPac },
                "e": {"c": 3, "r": 22 + scmPac }
            }).mergeCells(sheet, {
                //24行 合并单元格 (横向2)
                "s": {"c": 5, "r": 22 + scmPac },
                "e": {"c": 6, "r": 22 + scmPac }
            });
            if(scmIdcount>0){
                scmIdcount = scmIdcount - 1 ;
                //纵向合并
                sheetInsert.mergeCells(sheet, {
                    //合并单元格 (纵向)
                    "s": {"c": 1, "r": 23 + scmPac },
                    "e": {"c": 1, "r": 23 + scmPac + scmIdcount }
                }).mergeCells(sheet, {
                    //合并单元格 (纵向)
                    "s": {"c": 6, "r": 23 + scmPac },
                    "e": {"c": 6, "r": 23 + scmPac + scmIdcount }
                });
         }else{
                sheetInsert.mergeCells(sheet, {
                    //25行 合并单元格 (横向)
                    "s": {"c": 2, "r": 23 + scmPac },
                    "e": {"c": 6, "r": 23 + scmPac }
                });
         };
            sheetInsert.mergeCells(sheet, {
                //34行 合并单元格 (横向1)
                "s": {"c": 2, "r": 32 + scmPac + scmIdcount },
                "e": {"c": 3, "r": 32 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //34行 合并单元格 (横向2)
                "s": {"c": 5, "r": 32 + scmPac + scmIdcount },
                "e": {"c": 6, "r": 32 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //35行 合并单元格 (横向1)
                "s": {"c": 2, "r": 33 + scmPac + scmIdcount },
                "e": {"c": 3, "r": 33 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //35行 合并单元格 (横向2)
                "s": {"c": 5, "r": 33 + scmPac + scmIdcount },
                "e": {"c": 6, "r": 33 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //40行 合并单元格 (横向)
                "s": {"c": 1, "r": 38 + scmPac + scmIdcount },
                "e": {"c": 6, "r": 38 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //41行 合并单元格 (横向)
                "s": {"c": 1, "r": 39 + scmPac + scmIdcount },
                "e": {"c": 6, "r": 39 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //合并单元格 (纵向)
                "s": {"c": 0, "r": 2 },
                "e": {"c": 0, "r": 9 }
            }).mergeCells(sheet, {
                //合并单元格 (纵向)
                "s": {"c": 0, "r": 10 },
                "e": {"c": 0, "r": 17 }
            }).mergeCells(sheet, {
                //合并单元格 (纵向)
                "s": {"c": 0, "r": 18 },
                "e": {"c": 0, "r": 33 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //合并单元格 (纵向)
                "s": {"c": 0, "r": 34 + scmPac + scmIdcount },
                "e": {"c": 0, "r": 35 + scmPac + scmIdcount }
            }).mergeCells(sheet, {
                //合并单元格 (纵向)
                "s": {"c": 0, "r": 36 + scmPac + scmIdcount },
                "e": {"c": 0, "r": 37 + scmPac + scmIdcount }
            });
            sheetInsert.setColWidthChars(sheet, 0, "13").setColWidthChars(sheet, 1, "20"). setColWidthChars(sheet, 2, "23"). setColWidthChars(sheet, 3, "17").setColWidthChars(sheet, 4, "20"). setColWidthChars(sheet, 5, "18").setColWidthChars(sheet, 6, "18").finalize();

        });//遍历数据完成
        var wopts = { bookType:'xlsx', bookSST:false, type:'binary' ,cellStyles: true};
        var wbout = XLSX.write(wb,wopts);
        function s2ab(s) {
            var buf = new ArrayBuffer(s.length);
            var view = new Uint8Array(buf);
            for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
            return buf;
        }

        saveAs(new Blob([s2ab(wbout)],{type:""}), "orderDetails.xlsx");
    }
    /*
    * 获取当前年月日
    * */
    function dateF(){
        var mydate = new Date();
        var year =  mydate.getFullYear();
        var month = mydate.getMonth()+1;
        var oDay =  mydate.getDate();

        return year + "-"  + (month >= 10 ? month : "0" + month)  + "-" + (oDay < 10 ? "0" + oDay : oDay);//最后拼接时间

    }
    //传入毫秒值,返回年月日      得到日期oTime
    function getMyDateF(str){

        var oDate = new Date(str);
        var oYear = oDate.getFullYear();
        var oMonth = oDate.getMonth()+1;
        var oDay = oDate.getDate();
     return oYear + "-"  + (oMonth >= 10 ? oMonth : "0" + oMonth)  + "-" + (oDay <= 9 ? "0" + oDay : oDay);//最后拼接时间
    }
    /**
     * 手机电话加密
     **/
    function turnTelF(tel){
        if(tel==null)return "";
        if (tel.length <= 6) {
            return tel;
        }
        var telText = tel.substring(0, 4) + "****" + tel.substring(tel.length - 4, tel.length);
        return telText;
    }
    /*
    * 证件类型
    * */
    function typeNameF(str){
        var documentTypeName = "";
        if(str == "0"){
            documentTypeName="身份证";
        }else if(str == "1"){
            documentTypeName="组织机构代码证";
        }else if(str == "2"){
            documentTypeName="税务登记证号";
        }else if(str == "3"){
            documentTypeName="护照";
        }
        return documentTypeName;
    }
    /*指标方式*/
    function indicatorWayF(str){
        var indicatorWay = "";
        if(str==null){
            indicatorWay="";
        }else if(str=="0"){
            indicatorWay="置换";
        }else if(str=="1"){
            indicatorWay="摇号";
        }else if(str=="2"){
            indicatorWay="竞拍";
        }else if(str=="3"){
            indicatorWay="外地牌";
        }else if(str=="6"){
            indicatorWay="本地牌";
        }else if(str=="4"){
            indicatorWay="其他";
        }else if(str=="5"){
            indicatorWay="";
        }
        return indicatorWay;
    }
    /*性别*/
    function genderF(str){
        var gender="";
        if(str==null){
            gender="";
        }else if(str == "0"){
            gender="";
        }else if(str == "1"){
            gender="";
        }
        return gender;
   }
   /*本地/外地*/
   function localnameF(str){
        var localName="";
        if(str){
            localName="本地";
        }else{
            localName="外地";
        }
        return localName;
   }
   /*成交类型*/
   function dealWayNameF(str){
        var dealWayName="";
        if(str == 0){
            dealWayName="展厅";
        }else if(str == 1){
            dealWayName="大客户";
        }else if(str == 2){
            dealWayName="经销商";
        }
        return dealWayName;
   }
   /*车主性质*/

   function ownerNatureF(str){
        var ownerNature="";
        if(str == 0){
            ownerNature="";
        }else if(str == 1){
            ownerNature="私户";
        }else if(str == 2){
            ownerNature="公户";
        }
        return ownerNature;
   }
   /*车辆状态*/
   function carStateF(str){
      var carState = "";
        if(str == "1"){
            carState="订购未付款";
        }else if(str == "2"){
            carState="付款在途";
        }else if(str == "3"){
            carState="在库";
        }else{
            carState="";
        }
        return carState;
   }
   /*付款方式*/
   function fukWay(paymentWayName){
        var paymentWay="";
        if(paymentWayName == "0"){
            paymentWay="现金";
        }else if(paymentWayName == "1"){
            paymentWay="刷卡";
        }else if(paymentWayName == "2"){
            paymentWay="转账";
        }else if(paymentWayName == "3"){
            paymentWay="现金+刷卡";
        }
        return paymentWay;
   }
    //以下四个函数是算术运算得到精确方法
//除法函数,用来得到精确的除法结果
//说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
//调用:accDiv(arg1,arg2)
//返回值:arg1除以arg2的精确结果
    function accDiv(arg1,arg2)
    {
//    var t1=0,t2=0,r1,r2;
//    try{t1=arg1.toString().split(".")[1].length}catch(e){}
//    try{t2=arg2.toString().split(".")[1].length}catch(e){}
//    with(Math){
//    r1=Number(arg1.toString().replace(".",""))
//    r2=Number(arg2.toString().replace(".",""))
//    return (r1/r2)*pow(10,t2-t1);
//    }
        return accMul(arg1,1/arg2);
    }

//乘法函数,用来得到精确的乘法结果
//说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
//调用:accMul(arg1,arg2)
//返回值:arg1乘以arg2的精确结果
    function accMul(arg1,arg2){
      if(arg1 == 0 || arg2 == 0 || arg1 == 0.0 || arg2 == 0.0){
         return 0;
      }
        var m=0,s1=arg1.toString(),s2=arg2.toString();
        try{m+=s1.split(".")[1].length}catch(e){}
        try{m+=s2.split(".")[1].length}catch(e){}
        return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
    }

//加法函数,用来得到精确的加法结果
//说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
//调用:accAdd(arg1,arg2)
//返回值:arg1加上arg2的精确结果
    function accAdd(arg1,arg2){
//    var r1,r2,m;
//    try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
//    try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
//    m=Math.pow(10,Math.max(r1,r2))
//    return (arg1*m+arg2*m)/m
        var r1,r2,m;
        try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
        try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
        m=Math.pow(10,Math.max(r1,r2));
        return (accMul(arg1,m)+accMul(arg2,m))/m;
    }

//减法函数,用来得到精确的减法结果
//说明:javascript的减法结果会有误差,在两个浮点数减法的时候会比较明显。这个函数返回较为精确的减法结果。
//调用:accSub(arg1,arg2)
//返回值:arg1减法arg2的精确结果
    function accSub(arg1,arg2){
//     var r1,r2,m,n;
//     try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
//     try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
//     m=Math.pow(10,Math.max(r1,r2));
//     //last modify by deeka
//     //动态控制精度长度
//     n=(r1>=r2)?r1:r2;
//     return ((arg1*m-arg2*m)/m).toFixed(n);
        return accAdd(arg1,-arg2);
    }

//四舍五入方法
//说明:javascript的四舍五入函数toFixed()IE5.5以后支持,但在数值很小时的会出错。
//如:var money=0.00542;//0.006; alert(Number(money).toFixed(2)); 值为0.00
//这个函数返回较为精确的四舍五入结果。
//调用:accRound(number,fractionDigits)
//返回值:number四舍五入保留fractionDigits位小数的精确结果
    function accRound(number,fractionDigits){
        with(Math){
            return round(number*pow(10,fractionDigits))/pow(10,fractionDigits);
        }
    }
}
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页