Bläddra i källkod

添加客户基本信息

dujinyan 7 år sedan
förälder
incheckning
093cbd10d9

+ 21 - 2
watero-rst-web/src/main/webapp/WEB-INF/views/customer/save_customer_info.ftl

@@ -724,6 +724,25 @@
         $("#contactTbodyId").hide();
         return false;
     }
+
+    //制保留2位小数,如:2,会在2后面补上00.即2.00
+    function toDecimal2(x) {
+        var f = parseFloat(x);
+        if (isNaN(f)) {
+            return false;
+        }
+        var f = Math.round(x*100)/100;
+        var s = f.toString();
+        var rs = s.indexOf('.');
+        if (rs < 0) {
+            rs = s.length;
+            s += '.';
+        }
+        while (s.length <= rs + 2) {
+            s += '0';
+        }
+        return s;
+    }
     /*保存客户销售信息到列表*/
     function toAddChannelSaleInfo() {
         var channelCategory = document.getElementById("channelCategory").value;
@@ -744,8 +763,8 @@
         var supplyPrice = document.getElementById("supplyPrice").value;
         var writeSupplyPrice = document.getElementById("writeSupplyPrice").value;//手动输入价格
         if(writeSupplyPrice != null && writeSupplyPrice !=""){
-            /*writeSupplyPrice = writeSupplyPrice.toFixed(2);
-            alert(writeSupplyPrice);*/
+            writeSupplyPrice = toDecimal2(writeSupplyPrice);
+            alert(writeSupplyPrice);
             supplyPrice = writeSupplyPrice;
         }
         var accountPeriod = document.getElementById("accountPeriod").value;