From fc69a1e9655df3e8a01dc36ea2742c99f4a651ed Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期三, 17 一月 2024 13:22:08 +0800
Subject: [PATCH] 特批申请单:数据校验 销售订单:维护页面增加字段 销售出库关联数量、销售出库未关联数量、生产关联数量、生产未关联数量

---
 WebTM/views/销售管理/销售订单/Add_Edit_Xs_SeOrderBillList.html | 1013 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 834 insertions(+), 179 deletions(-)

diff --git "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html" "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html"
index 77274d2..74a32ce 100644
--- "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html"
+++ "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\350\256\242\345\215\225/Add_Edit_Xs_SeOrderBillList.html"
@@ -16,7 +16,7 @@
     <script src="../../../layuiadmin/PubCustom.js"></script>
     <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
     <style type="text/css">
-        .layui-form-item .layui-inline {
+        /*.layui-form-item .layui-inline {
             margin-right: 0;
         }
 
@@ -33,7 +33,7 @@
             margin-top: -10px;
             margin-left: -15px;
             margin-right: -15px;
-        }
+        }*/
     </style>
 </head>
 <body>
@@ -45,6 +45,8 @@
                     <div class="layui-card-header">
                         <div class="layui-btn-group">
                             <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_SaveBill">淇濆瓨</button>
+                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">瀹℃牳</button>
+                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="btn-print">鎵撳嵃</button>
                             <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">閫�鍑�</button>
                         </div>
                     </div>
@@ -60,7 +62,7 @@
                                 <div class="layui-form-item" style="padding-top: 10px;">
                                     <div class="layui-row">
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">鍗曟嵁缂栧彿</label>
+                                            <label class="layui-form-label">鍗曟嵁缂栧彿<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
                                                 <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                 <input type="hidden" name="HInterID" id="HInterID" value="0">
@@ -68,15 +70,15 @@
                                             </div>
                                         </div>
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">鏃ユ湡</label>
-                                            <div class="layui-input-inline">
-                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 80px;">
+                                            <label class="layui-form-label">鏃ユ湡<label style="color:red"> * </label></label>
+                                            <div class="layui-input-block">
+                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="width:190px;">
                                             </div>
                                         </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label">閿�鍞儴闂�</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                 <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -86,7 +88,7 @@
                                         <div class="layui-inline">
                                             <label class="layui-form-label">閿�鍞憳</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                 <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -96,9 +98,19 @@
                                     </div>
                                     <div class="layui-row">
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">閿�鍞竵鍒�</label>
+                                            <label class="layui-form-label">瀹㈡埛<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;">
+                                                <input type="hidden" name="HCusID" id="HCusID" class="layui-input" value="0" style="float:left;width:150px;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCusList" style="width:40px;">
+                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+                                                </button>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">閿�鍞竵鍒�<label style="color:red"> * </label></label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;">
                                                 <input type="hidden" name="HCurID" id="HCurID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HCurList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -106,27 +118,17 @@
                                             </div>
                                         </div>
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">姹囩巼</label>
+                                            <label class="layui-form-label">姹囩巼<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0" readonly>
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline" style="width:900px;">
-                                            <label class="layui-form-label">瀹㈡埛</label>
-                                            <div class="layui-input-inline" style="width:700px;">
-                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float:left;width:465px;">
-                                                <input type="hidden" name="HCusID" id="HCusID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCusList" style="width:40px;">
-                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>
+                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0" style="background-color: #efefef4d;" readonly>
                                             </div>
                                         </div>
                                     </div>
                                     <div class="layui-row">
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">缁撶畻鏂瑰紡</label>
+                                            <label class="layui-form-label">缁撶畻鏂瑰紡<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                 <input type="hidden" name="HSSID" id="HSSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HSSList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -136,7 +138,7 @@
                                         <div class="layui-inline">
                                             <label class="layui-form-label">閿�鍞柟寮�</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                 <input type="hidden" name="HSellSID" id="HSellSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HSellSList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -144,27 +146,9 @@
                                             </div>
                                         </div>
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">鎽樿</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="HExplanation" id="HExplanation" autocomplete="off" style="width: 501px;">
-                                            </div>
-                                        </div>
-                                    </div>
-                                    <div class="layui-row">
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">閿�鍞富绠�</label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float:left;width:150px;">
-                                                <input type="hidden" name="HManagerID" id="HManagerID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
-                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
                                             <label class="layui-form-label">鑱旂郴浜�</label>
                                             <div class="layui-input-inline">
-                                                <input class="layui-input" name="HLinkMan" id="HLinkMan" autocomplete="off" value="" >
+                                                <input class="layui-input" name="HLinkMan" id="HLinkMan" autocomplete="off" value="">
                                             </div>
                                         </div>
                                         <div class="layui-inline">
@@ -173,18 +157,38 @@
                                                 <input class="layui-input" name="HLinkPhone" id="HLinkPhone" autocomplete="off" value="">
                                             </div>
                                         </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">鍐呴儴璁㈠崟鍙�</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" autocomplete="off" readonly>
-                                            </div>
-                                        </div>
                                     </div>
                                     <div class="layui-row">
                                         <div class="layui-inline">
                                             <label class="layui-form-label">澶囨敞</label>
                                             <div class="layui-input-block">
                                                 <input class="layui-input" name="HRemark" id="HRemark" autocomplete="off" style="width: 1135px;">
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">瀹㈡埛浣欓<i class="layui-icon layui-icon-tips" id="tips-HCusBalance"></i></label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HCusBalance" id="HCusBalance" autocomplete="off" readonly>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">淇$敤棰濆害</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HCreditRating_Now" id="HCreditRating_Now" autocomplete="off" readonly>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">鍙敤棰濆害<i class="layui-icon layui-icon-tips" id="tips-HAvailableBalance"></i></label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HAvailableBalance" id="HAvailableBalance" autocomplete="off" readonly>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">闇�姹傞噾棰�<i class="layui-icon layui-icon-tips" id="tips-HBillMoney"></i></label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HBillMoney" id="HBillMoney" autocomplete="off" readonly>
                                             </div>
                                         </div>
                                     </div>
@@ -197,21 +201,33 @@
                                                 </select>
                                             </div>
                                         </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">瀹㈡埛浣欓</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="" id="" autocomplete="off" readonly>
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">瀹㈡埛淇$敤棰濆害</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="" id="" autocomplete="off" readonly>
-                                            </div>
-                                        </div>
                                     </div>
 
                                     <!--闅愯棌瀛楁锛氭殏鏃舵病鏈夌敤澶�-->
+                                    <div class="layui-row" style="display:none;">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">閿�鍞富绠�</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
+                                                <input type="hidden" name="HManagerID" id="HManagerID" class="layui-input" value="0" style="float:left;width:150px;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
+                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+                                                </button>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">鍐呴儴璁㈠崟鍙�</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" style="background-color: #efefef4d;" autocomplete="off" readonly>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">鎽樿</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HExplanation" id="HExplanation" autocomplete="off" style="width: 501px;">
+                                            </div>
+                                        </div>
+                                    </div>
                                     <div class="layui-row" style="display:none;">
                                         <div class="layui-inline">
                                             <label class="layui-form-label">缁撶畻鏃ユ湡</label>
@@ -392,11 +408,27 @@
             //#endregion 
 
             //#region 鍒ゆ柇骞惰缃搷浣滅被鍨嬨�侀〉闈㈠垵濮嬪寲
-            if (OperationType == null || OperationType == 1) {                            //鏂板
+            if (OperationType == null || OperationType == 1) {                          //鏂板
                 //鏂板椤甸潰鍒濆鍖�
                 Init_setAdd();
             }
-            else if (OperationType == 3) {                                                 //缂栬緫
+            else if (OperationType == 2) {                                              //澶嶅埗
+                //瀛愯〃鍒濆鍖�
+                set_InitGrid();
+                //鍔犺浇琛ㄤ綋鍜岃〃浣撴暟鎹�
+                RoadBillMain(linterid);
+
+                //鐢熸垚骞惰缃富琛ㄧ殑鍐呯爜鍜屽崟鎹彿
+                createBillNo();
+
+                //鐩稿叧鏂囨湰妗嗕俊鎭垵濮嬪寲
+                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
+                $("#HSSDate").val(Format(new Date(), "yyyy-MM-dd"));
+                $("#HMaker").val(sessionStorage["HUserName"]);
+                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
+
+            }
+            else if (OperationType == 3) {                                              //缂栬緫
                 $("#HInterID").val(linterid);
                 //瀛愯〃鍒濆鍖�
                 set_InitGrid();
@@ -407,6 +439,10 @@
 
             //#region 鍒濆鍖栫粍缁�
             Organ();
+            //#endregion
+
+            //#region 椤甸潰鍒濆鍖栧悗锛屾牴鎹鎴疯幏鍙栧鎴蜂綑棰�
+            getCustomerBalance( $("#HCusID").val() );
             //#endregion
 
             //#region 鍒楄缃細瀛愯〃1
@@ -468,15 +504,31 @@
             //#region 琛ㄥご鎸夐挳瑙﹀彂浜嬩欢
             //#region 淇濆瓨鎸夐挳
             form.on('submit(set_SaveBill)', function (data) {
-                //if (AllowLoadData(data)) {
+                if (AllowLoadData(data)) {
                     set_SaveBill(data);
-                //}
+                }
+            });
+            //#endregion
+
+            //#region 瀹℃牳鎸夐挳
+            form.on('submit(set_CheckBill)', function (data) {
+                set_CheckBill(0);
+            });
+            //#endregion
+
+            //#region 鎵撳嵃鎸夐挳
+            form.on('submit(btn-print)', function (data) {
+                get_PrintReport();
             });
             //#endregion
 
             //#region 閫�鍑烘寜閽�
             form.on('submit(Exit)', function () {
-                Pub_Close(1);
+                if (params[1] != null) {
+                    Pub_Close(1);
+                } else if (params[1] == null) {
+                    Pub_Close(2);
+                }
             })
             //#endregion
             //#endregion
@@ -492,6 +544,9 @@
                     "HMaterID": "0",
                     "鐗╂枡浠g爜": "",
                     "鐗╂枡鍚嶇О": "",
+                    "HItemID": "0",
+                    "璁㈠崟绛夌骇浠g爜": "",
+                    "璁㈠崟绛夌骇鍚嶇О": "",
                     "瑙勬牸鍨嬪彿": "",
                     "HUnitID": "0",
                     "璁¢噺鍗曚綅": "",
@@ -505,7 +560,7 @@
                     "HTaxMoney": "0",
                     "HlineTotal": "0",
                     "HlineTotalBB": "0",
-                    "HDate": "",
+                    "HDate": Format(new Date(), 'yyyy-MM-dd'),
                     "HOutStockQty": "0",
                     "HInvoiceQty": "0",
                     "HRemark": ""
@@ -558,6 +613,10 @@
 
             //#region 鐩戝惉鍗曞厓鏍肩紪杈�  鍗曞厓鏍肩紪杈戝悗 鍙樻洿
             table.on('edit(mainTable)', function (obj) {
+                //鏁板�兼牸寮忔牎楠屽伐鍏�
+                var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
+                var temp = "";
+
                 // 鍗曞厓鏍肩紪杈戜箣鍓嶇殑鍊�
                 var oldText = $(this).prev().text();
                 var value = obj.value //寰楀埌淇敼鍚庣殑鍊�
@@ -566,46 +625,227 @@
                 //layer.msg('[ID: ' + data.id + '] ' + field + ' 瀛楁鏇存敼涓猴細' + value);
 
                 switch (field) {
-                    case "HRate":     //鐢ㄩ噺
-                        value = (value * 1).toFixed(6);
+                    case "HQty":                                                       //鏁伴噺
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp) || temp == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HQty: oldText
+                            });
+                            table.render(option);
 
-                        var HWeight = $("#HWeight").val();
-                        var HWaterQty = $("#HWaterQty").val();
-                        var HRate = value;
-                        var HQty = 0;
-                        var HMaterRuleType = obj.data.HMaterRuleType;
-                        if (HMaterRuleType == "鏌撴枡") {
-                            HQty = HRate * HWeight;
-                        } else if (HMaterRuleType == "鍔╁墏") {
-                            HQty = HRate * HWaterQty;
+                            layer.msg("鏁伴噺璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
+                            return;
                         }
+
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = value * 1;                           //鏁伴噺
+                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                        var HTaxRate = obj.data.HTaxRate * 0.01;           //绋庣巼
+                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //鎶樻墸鐜�*/
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                                                                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+                        HQty = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
+
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
-                            HRate: value,
                             HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
                         });
                         table.render(option);
+                        //璁剧疆琛ㄥご鎵�闇�閲戦
+                        set_HBillMoney();
                         break;
-                    case "HMaterRuleType":
-                        var HWeight = $("#HWeight").val();
-                        var HWaterQty = $("#HWaterQty").val();
-                        var HRate = obj.data.HRate;
-                        var HQty = 0;
-                        var HMaterRuleType = value;
-                        if (HMaterRuleType == "鏌撴枡") {
-                            HQty = HRate * HWeight;
-                        } else if (HMaterRuleType == "鍔╁墏") {
-                            HQty = HRate * HWaterQty;
+                    case "HPrice":                                                       //鍗曚环
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp) || temp == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HPrice: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
+                            return;
                         }
+
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HPrice = value * 1;                         //鍗曚环
+                        var HTaxRate = obj.data.HTaxRate * 0.01;           //绋庣巼
+                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //鎶樻墸鐜�*/
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+                        HQty = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
+
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
                         });
+                        table.render(option);
+                        //璁剧疆琛ㄥご鎵�闇�閲戦
+                        set_HBillMoney();
+                        break;
+                    case "HTaxRate":                                                       //鏁伴噺
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp)) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HTaxRate: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛�!");
+                            return;
+                        }
+
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                        var HTaxRate = value * 0.01;                       //绋庣巼
+                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //鎶樻墸鐜�*/
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+                        HQty = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
+                        });
+                        table.render(option);
+                        //璁剧疆琛ㄥご鎵�闇�閲戦
+                        set_HBillMoney();
+                        break;
+                    case "HTaxPrice":                                                       //鏁伴噺
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp)) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HTaxPrice: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("鍚◣鍗曟嵁璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛�!");
+                            return;
+                        }
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HTaxRate = obj.data.HTaxRate * 0.01;        //绋庣巼
+                        var HTaxPrice = value * 1;                          //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HPrice = HTaxPrice / (1 + HTaxRate);        //鍗曚环=鍚◣鍗曟嵁/(1+绋庣巼)
+                        
+                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //鎶樻墸鐜�*/
+                        
+                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+                        HQty = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
+                        });
+                        table.render(option);
+                        //璁剧疆琛ㄥご鎵�闇�閲戦
+                        set_HBillMoney();
                         break;
                     default:
                 }
             });
             //#endregion
+            //#endregion
+
+            //#region 鏂囨湰妗嗙洃鍚�
+            $(document).ready(function () {
+                //#region 瀹㈡埛浣欓鎻愮ず淇℃伅
+                $("#tips-HCusBalance").on('click', function (data) {
+                    var tips_Message = "瀹㈡埛浣欓 = 鏈熷垵+鏈湡鏀舵锛堝凡瀹℃牳锛�-鏈湡閫�娆撅紙宸插鏍革級-鏈湡鍑哄簱锛堝凡瀹℃牳锛�+鏈湡閫�璐э紙宸插鏍革級";
+                    layer.alert(tips_Message, { icon: 0, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                });
+                //#endregion
+
+                //#region 鍙敤浣欓鎻愮ず淇℃伅
+                $("#tips-HAvailableBalance").on('click', function (data) {
+                    var tips_Message = "鍙敤棰濆害 = 瀹㈡埛浣欓 + 淇$敤棰濆害 - 锛堟湰鏈熼攢鍞鍗曟�婚噾棰� * 0.5锛�";
+                    layer.alert(tips_Message, { icon: 0, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                });
+                //#endregion
+
+                //#region 闇�姹傞噾棰�
+                $("#tips-HBillMoney").on('click', function (data) {
+                    var tips_Message = "闇�姹傞噾棰� = 浠风◣鍚堣 * 0.5";
+                    layer.alert(tips_Message, { icon: 0, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                });
+                //#endregion
+            });
             //#endregion
             //#endregion
 
@@ -665,6 +905,37 @@
             }
             //#endregion
 
+            //#region 鏍规嵁璐﹀彿鑾峰彇閮ㄩ棬銆佽亴鍛樸�佷富绠�
+            function getCzyglByUser() {
+                $.ajax({
+                    url: GetWEBURL() + "/Xs_SeOrderBill/getCzyglByUser",
+                    async: false,
+                    type: "GET",
+                    data: {
+                        "CurUserName": sessionStorage["HUserName"]
+                    },
+                    success: function (result) {
+                        if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                            var data = result.data[0];
+
+                            $("#HEmpID").val(data.HEmpID);
+                            $("#HEmpName").val(data.HEmpName);
+                            $("#HDeptID").val(data.HDeptID);
+                            $("#HDeptName").val(data.HDeptName);
+                            $("#HManagerID").val(data.HManagerID);
+                            $("#HManagerName").val(data.HManagerName);
+
+
+                        } else {
+                            layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                        }
+                    }, error: function () {
+                        layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                    }
+                });
+            }
+            //#endregion
+
             //#region 鐢熸垚鍗曟嵁鍙�
             function createBillNo() {
                 $.ajax({
@@ -684,24 +955,28 @@
                 option = {
                     elem: '#mainTable'
                     , toolbar: '#toolbarDemo'
+                    , totalRow: true
                     , limit: 500
                     , height: 500
                     , loading: false
                     , cols: [[ //瀛愯〃
-                        { type: 'checkbox', totalRowText: '鍚堣琛�' }
-                        , { type: 'numbers', title: '搴忓彿', width: 100, totalRow: true }
-                        , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true }
+                        { type: 'checkbox', totalRowText: '鍚堣琛�', style: 'background-color:#efefef4d;' }
+                        , { type: 'numbers', title: '搴忓彿', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                         , { field: '鐗╂枡浠g爜', title: '鐗╂枡浠g爜', width: 150, edit: 'text', event: "HMaterID" }//f7
-                        , { field: '鐗╂枡鍚嶇О', title: '鐗╂枡鍚嶇О', width: 150, }
-                        , { field: '瑙勬牸鍨嬪彿', title: '瑙勬牸鍨嬪彿', width: 100, }
-                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true }
-                        , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100 }//f7
-                        , { field: 'HQty', title: '鏁伴噺', width: 100, edit: 'text' }
+                        , { field: '鐗╂枡鍚嶇О', title: '鐗╂枡鍚嶇О', width: 150, style: 'background-color:#efefef4d;' }
+                        , { field: 'HOrderLevID', title: 'HOrderLevID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
+                        , { field: '璁㈠崟绛夌骇浠g爜', title: '璁㈠崟绛夌骇浠g爜', width: 150, edit: 'text', event: "HOrderLevID" }//f7
+                        , { field: '璁㈠崟绛夌骇鍚嶇О', title: '璁㈠崟绛夌骇鍚嶇О', width: 150, style: 'background-color:#efefef4d;' }
+                        , { field: '瑙勬牸鍨嬪彿', title: '瑙勬牸鍨嬪彿', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
+                        , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100, style: 'background-color:#efefef4d;' }//f7
+                        , { field: 'HQty', title: '鏁伴噺', width: 100, totalRow: true, edit: 'text' }
                         , { field: 'HPrice', title: '鍗曚环', width: 100, edit: 'text' }
                         , { field: 'HTaxRate', title: '绋庣巼', width: 100, edit: 'text' }
                         , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, edit: 'text' }
-                        , { field: 'HMoney', title: '閲戦', width: 100, edit: 'text' }
-                        , { field: 'HlineTotal', title: '浠风◣鍚堣', width: 100, }
+                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
+                        , { field: 'HlineTotal', title: '浠风◣鍚堣', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                         , { field: 'HDate', title: '浜よ揣鏃ユ湡', event: "HDate", width: 120 }
                         , { field: 'HRemark', title: '澶囨敞', width: 100, edit: 'text' }
 
@@ -720,6 +995,9 @@
                     "HMaterID": "0",
                     "鐗╂枡浠g爜": "",
                     "鐗╂枡鍚嶇О": "",
+                    "HOrderLevID": "0",
+                    "璁㈠崟绛夌骇浠g爜": "",
+                    "璁㈠崟绛夌骇鍚嶇О": "",
                     "瑙勬牸鍨嬪彿": "",
                     "HUnitID": "0",
                     "璁¢噺鍗曚綅": "",
@@ -733,7 +1011,7 @@
                     "HTaxMoney": "0",
                     "HlineTotal": "0",
                     "HlineTotalBB": "0",
-                    "HDate": "",
+                    "HDate": Format(new Date(),'yyyy-MM-dd'),
                     "HOutStockQty": "0",
                     "HInvoiceQty": "0",
                     "HRemark": ""
@@ -741,6 +1019,9 @@
 
                 option.data = rowdata;
                 table.render(option);
+
+                //璁剧疆琛ㄥご鎵�闇�閲戦
+                set_HBillMoney();
             }
             //#endregion
 
@@ -757,6 +1038,9 @@
                 $("#HSSDate").val(Format(new Date(), "yyyy-MM-dd"));
                 $("#HMaker").val(sessionStorage["HUserName"]);
                 $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
+
+                //閿�鍞憳銆侀攢鍞儴闂ㄣ�侀攢鍞富绠″垵濮嬪寲
+                getCzyglByUser();
 
                 //鍒濆鍖栧苟鍒楄缃細瀛愯〃1
                 set_InitGrid();
@@ -805,6 +1089,7 @@
                                 , "HLinkMan": data.鑱旂郴浜�
                                 , "HExplanation": data.鎽樿
                                 , "HLinkPhone": data.鑱旂郴鐢佃瘽
+                                , "HCreditRating_Now": data.HCreditRating_Now
                                 , "HRemark": data.琛ㄥご澶囨敞
                                 , "HMaker": data.鍒跺崟浜�
                                 , "HMakeDate": data.鍒跺崟浜� == "" ? "" :formatDate(data.鍒跺崟鏃ユ湡)
@@ -822,6 +1107,8 @@
 
                             //缁勭粐鐨勫�糎OrgID鍙樺寲锛岄噸鏂版覆鏌�
                             HOrgIDBar = data.HOrgID;
+                            //鑾峰彇绋庣巼(鐢ㄤ簬瀛愯〃绋庣巼鐨勯粯璁ゅ��)
+                            getHTaxRateByCusID(data.HCusID);
 
                             //瀛愯〃  璧嬪��
                             var rowdata = [];
@@ -831,18 +1118,21 @@
                                         "HMaterID": result.data[i]["HMaterID"],
                                         "鐗╂枡浠g爜": result.data[i]["鐗╂枡浠g爜"],
                                         "鐗╂枡鍚嶇О": result.data[i]["鐗╂枡鍚嶇О"],
+                                        "HOrderLevID": result.data[i]["HOrderLevID"],
+                                        "璁㈠崟绛夌骇浠g爜": result.data[i]["璁㈠崟绛夌骇浠g爜"],
+                                        "璁㈠崟绛夌骇鍚嶇О": result.data[i]["璁㈠崟绛夌骇鍚嶇О"],
                                         "瑙勬牸鍨嬪彿": result.data[i]["瑙勬牸鍨嬪彿"],
                                         "HUnitID": result.data[i]["HUnitID"],
                                         "璁¢噺鍗曚綅": result.data[i]["璁¢噺鍗曚綅"],
-                                        "HQty": result.data[i]["鏁伴噺"],
-                                        "HPrice": result.data[i]["鍗曚环"],
-                                        "HTaxPrice": result.data[i]["鍚◣鍗曚环"],
-                                        "HMoney": result.data[i]["閲戦"],
+                                        "HQty": dealDoubleToFixed(result.data[i]["鏁伴噺"], 1),
+                                        "HPrice": dealDoubleToFixed(result.data[i]["鍗曚环"], 3),
+                                        "HTaxPrice": dealDoubleToFixed(result.data[i]["鍚◣鍗曚环"], 3),
+                                        "HMoney": dealDoubleToFixed(result.data[i]["閲戦"],2),
                                         "HDiscountRate": result.data[i]["鎶樻墸鐜�"],
                                         "HRelTaxPrice": result.data[i]["瀹為檯鍚◣鍗曚环"],
                                         "HTaxRate": result.data[i]["绋庣巼"],
                                         "HTaxMoney": result.data[i]["绋庨"],
-                                        "HlineTotal": result.data[i]["浠风◣鍚堣"],
+                                        "HlineTotal": dealDoubleToFixed(result.data[i]["浠风◣鍚堣"],2),
                                         "HlineTotalBB": result.data[i]["鏈綅甯佷环绋庡悎璁�"],
                                         "HDate": formatDate(result.data[i]["浜よ揣鏃ユ湡"]),
                                         "HOutStockQty": result.data[i]["鍑哄簱鏁伴噺"],
@@ -858,6 +1148,9 @@
                             option.cols[0][20].edit = null;
 
                             table.render(option);
+
+                            //璁剧疆琛ㄥご鎵�闇�閲戦
+                            set_HBillMoney();
                             layer.close(ajaxLoad);
                         } else {
                             layer.close(ajaxLoad);
@@ -912,8 +1205,10 @@
                         if (checkStatus.data.length === 0) {
                             return layer.msg('璇烽�夋嫨鏁版嵁');
                         }
-                        $("#HCusName").val(checkStatus.data[0].HName);
-                        $("#HCusID").val(checkStatus.data[0].HItemID);
+                        getCustomerByCusID(checkStatus.data[0].HItemID);
+                        //鏍规嵁瀹㈡埛鑾峰彇瀹㈡埛浣欓
+                        getCustomerBalance(checkStatus.data[0].HItemID);
+
                         layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
                     }
                     , btn2: function (index, layero) { }
@@ -1141,8 +1436,27 @@
                     return false;
                 }
 
-                if ($("#HDeptID").val() == "0") {
-                    layer.msg("閿�鍞儴闂ㄦ湭閫夋嫨!");
+                //if ($("#HDeptID").val() == "0") {
+                //    layer.msg("閿�鍞儴闂ㄦ湭閫夋嫨!");
+                //    return false;
+                //}
+
+                //if ($("#HEmpID").val() == "0") {
+                //    layer.msg("閿�鍞憳鏈�夋嫨!");
+                //    return false;
+                //}
+
+                if ($("#HCurID").val() == "0") {
+                    layer.msg("閿�鍞竵鍒湭閫夋嫨!");
+                    return false;
+                }
+
+                temp = $("#HExRate").val() + "";
+                if (temp == 0 || temp == "") {
+                    layer.msg("姹囩巼涓嶈兘涓�0鎴栫┖!");
+                    return false;
+                } else if (!ref.test(temp)) {
+                    layer.msg("姹囩巼璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
                     return false;
                 }
 
@@ -1151,25 +1465,22 @@
                     return false;
                 }
 
-                if ($("#HEmpID").val() == "0") {
-                    layer.msg("閿�鍞憳鏈�夋嫨!");
-                    return false;
-                }
-
-                if ($("#HCurID").val() == "0") {
-                    layer.msg("閿�鍞竵鍒湭閫夋嫨!");
-                    return false;
-                }
-
-                if ($("#HMangerID").val() == "0") {
-                    layer.msg("閿�鍞富绠℃湭閫夋嫨!");
-                    return false;
-                }
-
                 if ($("#HSSID").val() == "0") {
                     layer.msg("缁撶畻鏂瑰紡鏈�夋嫨!");
                     return false;
                 }
+
+                //if ($("#HSellSID").val() == "0") {
+                //    layer.msg("閿�鍞柟寮忔湭閫夋嫨!");
+                //    return false;
+                //}
+
+                //if ($("#HMangerID").val() == "0") {
+                //    layer.msg("閿�鍞富绠℃湭閫夋嫨!");
+                //    return false;
+                //}
+
+                
 
                 //if ($("#HPayCusID").val() == "0") {
                 //    layer.msg("缁撶畻鏂规湭閫夋嫨!");
@@ -1181,14 +1492,7 @@
                 //    return false;
                 //}
 
-                temp = $("HExRate").val() + "";
-                if (temp == 0 || temp == "") {
-                    layer.msg("姹囩巼涓嶈兘涓�0鎴栫┖!");
-                    return false;
-                } else if (!ref.test(temp)){
-                    layer.msg("姹囩巼璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
-                    return false;
-                }
+                
                 //#endregion
 
                 //#region 瀛愯〃 鏁版嵁妫�楠�
@@ -1200,11 +1504,6 @@
 
                     if (option.data[i]["HUnitID"] == "0") {
                         layer.msg("绗�" + i + "琛岋細璁¢噺鍗曚綅鏈�夋嫨锛�");
-                        return false;
-                    }
-
-                    if (option.data[i]["HDate"] == "") {
-                        layer.msg("绗�" + i + "琛岋細浜よ揣鏃ユ湡涓嶈兘涓虹┖锛�");
                         return false;
                     }
 
@@ -1228,6 +1527,13 @@
                         return false;
                     }
 
+                    //绋庣巼鏍煎紡鏍¢獙
+                    temp = option.data[i]["HTaxRate"] + "";
+                    if (!ref.test(temp)) {
+                        layer.msg("绗�" + i + "琛岋細绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛楋紒");
+                        return false;
+                    }
+
                     //鍚◣鍗曚环鏍煎紡鏍¢獙
                     temp = option.data[i]["HTaxPrice"] + "";
                     if (temp == "0") {
@@ -1247,6 +1553,27 @@
                         layer.msg("绗�" + i + "琛岋細閲戦璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
                         return false;
                     }
+
+                    //浠风◣鍚堣鏍煎紡鏍¢獙
+                    temp = option.data[i]["HlineTotal"] + "";
+                    if (temp == "0") {
+                        layer.msg("绗�" + i + "琛岋細浠风◣鍚堣涓嶈兘涓�0锛�");
+                        return false;
+                    } else if (!ref.test(temp)) {
+                        layer.msg("绗�" + i + "琛岋細浠风◣鍚堣璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                        return false;
+                    }
+
+                    if (option.data[i]["HDate"] == "") {
+                        layer.msg("绗�" + i + "琛岋細浜よ揣鏃ユ湡涓嶈兘涓虹┖锛�");
+                        return false;
+                    }
+
+                    
+
+                    
+
+                    
 
                     ////鎶樻墸鐜囨牸寮忔牎楠�
                     //temp = option.data[i]["HDiscountRate"] + "";
@@ -1268,35 +1595,19 @@
                     //    return false;
                     //}
 
-                    //绋庣巼鏍煎紡鏍¢獙
-                    temp = option.data[i]["HTaxRate"] + "";
-                    if (temp == "0") {
-                        layer.msg("绗�" + i + "琛岋細绋庣巼涓嶈兘涓�0锛�");
-                        return false;
-                    } else if (!ref.test(temp)) {
-                        layer.msg("绗�" + i + "琛岋細绋庣巼璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
-                        return false;
-                    }
+                    
 
                     //绋庨鏍煎紡鏍¢獙
-                    temp = option.data[i]["HTaxMoney"] + "";
-                    if (temp == "0") {
-                        layer.msg("绗�" + i + "琛岋細绋庨涓嶈兘涓�0锛�");
-                        return false;
-                    } else if (!ref.test(temp)) {
-                        layer.msg("绗�" + i + "琛岋細绋庨璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
-                        return false;
-                    }
+                    //temp = option.data[i]["HTaxMoney"] + "";
+                    //if (temp == "0") {
+                    //    layer.msg("绗�" + i + "琛岋細绋庨涓嶈兘涓�0锛�");
+                    //    return false;
+                    //} else if (!ref.test(temp)) {
+                    //    layer.msg("绗�" + i + "琛岋細绋庨璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                    //    return false;
+                    //}
 
-                    //浠风◣鍚堣鏍煎紡鏍¢獙
-                    temp = option.data[i]["HlineTotal"] + "";
-                    if (temp == "0") {
-                        layer.msg("绗�" + i + "琛岋細浠风◣鍚堣涓嶈兘涓�0锛�");
-                        return false;
-                    } else if (!ref.test(temp)) {
-                        layer.msg("绗�" + i + "琛岋細浠风◣鍚堣璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
-                        return false;
-                    }
+                    
 
                     ////鏈綅甯佷环绋庡悎璁℃牸寮忔牎楠�
                     //temp = option.data[i]["HlineTotalBB"] + "";
@@ -1344,6 +1655,8 @@
                 table.cache["mainTable"].push(NewRow);
                 option.data = table.cache["mainTable"];
                 table.render(option);
+                //璁剧疆琛ㄥご鎵�闇�閲戦
+                set_HBillMoney();
                 //rows++;
                 layer.msg('澧炲姞涓�琛屾寜閽紒')
             }
@@ -1365,6 +1678,8 @@
                     }
                     option.data = tables;
                     table.render(option);
+                    //璁剧疆琛ㄥご鎵�闇�閲戦
+                    set_HBillMoney();
                 } else {
                     layer.msg('璇烽�夋嫨涓�琛屾暟鎹紪杈戯紒');
                 }
@@ -1389,6 +1704,8 @@
                     option.data[option.data.length - 1].HWeight = "0";
 
                     table.render(option);//灏嗘暟鎹覆鏌撳埌琛ㄦ牸涓�
+                    //璁剧疆琛ㄥご鎵�闇�閲戦
+                    set_HBillMoney();
                 }
             }
             //#endregion
@@ -1413,6 +1730,8 @@
                             option.data[i - 1] = data[0];
                             option.data[i] = tables[0];
                             table.render(option);
+                            //璁剧疆琛ㄥご鎵�闇�閲戦
+                            set_HBillMoney();
                             break;
                         }
                     }
@@ -1444,6 +1763,8 @@
                             option.data[i + 1] = data[0];
                             option.data[i] = tables[0];
                             table.render(option);
+                            //璁剧疆琛ㄥご鎵�闇�閲戦
+                            set_HBillMoney();
                             break;
                         }
                     }
@@ -1469,6 +1790,8 @@
                             oldData.splice(obj.tr.data('index'), 1);
                             option.data = oldData;
                             table.render(option);
+                            //璁剧疆琛ㄥご鎵�闇�閲戦
+                            set_HBillMoney();
                             layer.close(index);
                         }
                     });
@@ -1482,6 +1805,8 @@
                     if (event.key == "F7") {
                         //鐗╂枡
                         if (obj.event == "HMaterID") {
+                            var HOrgID = $("#HOrgID").val();
+
                             layer.open({
                                 type: 2
                                 , skin: "layui-layer-rim" //鍔犱笂杈规
@@ -1490,26 +1815,78 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_MaterialList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Material.html?openType=2&HOrgID=' + HOrgID, 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
                                     var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
                                     var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
 
-                                    if (checkStatus.data.length != 1) {
-                                        return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
-                                    }
+                                    //if (checkStatus.data.length != 1) {
+                                    //    return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                                    //}
 
-                                    //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
-                                    obj.update({
-                                        "HMaterID": checkStatus.data[0].HItemID
-                                        , "鐗╂枡浠g爜": checkStatus.data[0].HNumber
-                                        , "鐗╂枡鍚嶇О": checkStatus.data[0].HName
-                                        , "瑙勬牸鍨嬪彿": checkStatus.data[0].HModel
-                                        , "HUnitID": checkStatus.data[0].HUnitID
-                                        , "璁¢噺鍗曚綅": checkStatus.data[0].HUnitName
-                                    })
+                                    var rowIndex = $(obj.tr).attr("data-index") * 1;
+                                    for (var i = 0; i < checkStatus.data.length; i++) {
+                                        if (rowIndex + i >= option.data.length) {
+                                            var NewRow = {
+                                                "HMaterID": "0", "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HUnitID": "0", "璁¢噺鍗曚綅": "", "HQty": "0", "HPrice": "0", "HTaxPrice": "0"
+                                                , "HMoney": "0", "HDiscountRate": "0", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0"
+                                                , "HDate": Format(new Date(), 'yyyy-MM-dd'), "HOutStockQty": "0", "HInvoiceQty": "0", "HRemark": ""
+                                            }
+                                            btnAddLine(NewRow);
+                                        }
+
+                                        //鑾峰彇閫変腑鐨勭墿鏂欎俊鎭�
+                                        var resultData = checkStatus.data[i];
+
+                                        //鏁板�兼牸寮忔牎楠屽伐鍏�
+                                        var ref = /^\d+(\.\d+)?$/;                                  //闈炶礋鏁版鍒欒〃杈惧紡
+                                        var temp = "";
+                                        //鑾峰彇閫夋嫨鐗╂枡鍓嶅悗鐨勭◣鐜�
+                                        var value = subHTaxRate;                                    //閫夋嫨鐗╂枡鍚庢牴鎹鎴峰緱鍒扮殑绋庣巼
+                                        var oldText = option.data[rowIndex + i].HTaxRate;           //璇ヨ褰曚腑鍘熸湁鐨勭◣鐜�
+
+                                        //绋庣巼鏁版嵁鏍煎紡鏍¢獙锛岃嫢鏍规嵁瀹㈡埛鑾峰彇鐨勭◣鐜囦笉鍚堟硶锛屽垯浣跨敤璁板綍涓師鏈夌殑绋庣巼锛屽苟鎻愮ず
+                                        temp = value + "";
+                                        if (!ref.test(temp)) {
+                                            value = oldText;
+                                            layer.msg("鑾峰彇鍒扮殑绋庣巼涓嶅悎娉曪紝宸茶嚜鍔ㄥ彉鏇翠负鍘熸湁绋庣巼!");
+                                        }
+
+                                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                                        var HQty = option.data[rowIndex + i].HQty;                  //鏁伴噺
+                                        var HPrice = option.data[rowIndex + i].HPrice;              //鍗曚环
+                                        var HTaxRate = value * 0.01;                                //绋庣巼
+                                        /*var HDiscountRate = obj.data.HDiscountRate * 1;           //鎶樻墸鐜�*/
+                                        var HTaxPrice = HPrice * (1 + HTaxRate);                    //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;             //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                                        var HMoney = HQty * HPrice;                                 //閲戦=鏁伴噺*鍗曚环
+                                        var HTaxMoney = HMoney * HTaxRate;                          //绋庨=閲戦*绋庣巼
+                                        var HlineTotal = HMoney + HTaxMoney;                        //浠风◣鍚堣=閲戦+绋庨
+
+
+                                        option.data[rowIndex + i].HMaterID = resultData.HItemID;
+                                        option.data[rowIndex + i].鐗╂枡浠g爜 = resultData.鐗╂枡浠g爜;
+                                        option.data[rowIndex + i].鐗╂枡鍚嶇О = resultData.鐗╂枡鍚嶇О;
+                                        option.data[rowIndex + i].瑙勬牸鍨嬪彿 = resultData.瑙勬牸鍨嬪彿;
+                                        option.data[rowIndex + i].HUnitID = resultData.HUnitID;
+                                        option.data[rowIndex + i].璁¢噺鍗曚綅 = resultData.璁¢噺鍗曚綅鍚嶇О;
+
+                                        option.data[rowIndex + i].HQty = HQty;
+                                        option.data[rowIndex + i].HPrice = HPrice;
+                                        option.data[rowIndex + i].HTaxRate = HTaxRate * 100;
+                                        option.data[rowIndex + i].HTaxPrice = HTaxPrice;
+                                        option.data[rowIndex + i].HMoney = HMoney;
+                                        option.data[rowIndex + i].HlineTotal = HlineTotal;
+
+
+                                    }
+                                    table.render(option);
+                                    //璁剧疆琛ㄥご鎵�闇�閲戦
+                                    set_HBillMoney();
+
                                     layer.close(index);//鍏抽棴寮圭獥
                                 }
                             })
@@ -1543,6 +1920,37 @@
                                 }
                             })
                         }
+                        //璁㈠崟绛夌骇
+                        if (obj.event == "HOrderLevID") {
+                            layer.open({
+                                type: 2
+                                , skin: "layui-layer-rim" //鍔犱笂杈规
+                                , title: "璁㈠崟绛夌骇鍒楄〃"  //鏍囬
+                                , closeBtn: 1  //绐椾綋鍙充笂瑙掑叧闂� 鐨� 鏍峰紡
+                                , shift: 2 //寮瑰嚭鍔ㄧ敾
+                                , area: ["90%", "90%"] //绐椾綋澶у皬
+                                , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_OrderLev.html', 'yes']
+                                , btn: ["纭畾", "鍙栨秷"]
+                                , btn1: function (index, laero) {
+                                    //鎸夐挳涓�  鐨勫洖璋�
+                                    var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
+                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
+
+                                    if (checkStatus.data.length != 1) {
+                                        return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                                    }
+                                    //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
+                                    obj.update({
+                                        "璁㈠崟绛夌骇鍚嶇О": checkStatus.data[0].璁㈠崟绛夌骇
+                                        , "璁㈠崟绛夌骇浠g爜": checkStatus.data[0].璁㈠崟绛夌骇浠g爜
+                                        , "HOrderLevID": checkStatus.data[0].HItemID
+                                    })
+                                    layer.close(index);//鍏抽棴寮圭獥
+                                }
+                            })
+                        }
+
                         obj.event = "";
                         return false;
                     }
@@ -1678,11 +2086,120 @@
             }
             //#endregion
 
+            //#region 鍙嶅鏍�/瀹℃牳鏁版嵁
+            function set_CheckBill(num) {
+                var InterID = $("#HInterID").val();
+                //閫昏緫瀹℃牳鏂规硶
+                $.ajax({
+                    type: "GET",
+                    url: GetWEBURL() + "/Xs_SeOrderBill/AuditXs_SeOrderBill", //鏂规硶鎵�鍦ㄩ〉闈㈠拰鏂规硶鍚�
+                    data: { "HInterID": InterID, "IsAudit": num, "CurUserName": sessionStorage["HUserName"] },
+                    success: function (result) {
+                        if (result.count == 1) {
+                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
+                                // 寰楀埌frame绱㈠紩
+                                var index = layer.getFrameIndex(window.name);
+                                //鍏抽棴褰撳墠frame
+                                layer.close(index);
+                            });
+
+                        } else {
+                            layer.alert(result.code + result.Message, { icon: 5 });
+                        }
+                    }, error: function () {
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                    }
+                });
+            }
+            //#endregion
+
+            //#region 鎵撳嵃
+            function get_PrintReport() {
+                //#region 鍒ゆ柇婧愬崟鐘舵��
+                var HSourceBillData = "";
+                var HSourceBillData = getSourceBillStatus_SeOrderBill();            //鑾峰彇婧愬崟鏁版嵁
+                if (HSourceBillData != "none") {
+                    if (HSourceBillData.length == 0) {
+                        layer.alert("鎵撳嵃澶辫触!鏈煡璇㈠埌鍗曟嵁淇℃伅!", { icon: 5 });
+                        return;
+                    } else if (HSourceBillData[0]["鐘舵��"] != "宸插鏍�") {
+                        layer.alert("鎵撳嵃澶辫触!鍗曟嵁鐘舵�佹湭涓�'宸插鏍�'鐘舵��!", { icon: 5 });
+                        return;
+                    }
+                } else {
+                    return;
+                }
+                //#endregion
+
+
+
+                var InterID = $("#HInterID").val();
+                $.ajax({
+                    type: "GET",
+                    url: GetWEBURL() + "/Xs_SeOrderBill/CheckSeOrderBill_IsExist", //鏂规硶鎵�鍦ㄩ〉闈㈠拰鏂规硶鍚�
+                    data: { "HInterID": InterID},
+                    success: function (result) {
+                        if (result.count == 1) {
+                            layer.open({
+                                type: 2
+                                , area: ['50%', '50%']
+                                , title: '鎵撳嵃妯$増閫夋嫨'
+                                , shade: 0.6 //閬僵閫忔槑搴�
+                                , maxmin: false //鍏佽鍏ㄥ睆鏈�灏忓寲
+                                , anim: 0 //0-6鐨勫姩鐢诲舰寮忥紝-1涓嶅紑鍚�
+                                , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + InterID + '&MyMsg=' + InterID + '&Type=Xs_SeOrderBill', 'yes']
+                                , resize: false
+                            })
+                        } else {
+                            layer.alert(result.code + result.Message, { icon: 5 });
+                        }
+                    }, error: function () {
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                    }
+                });
+            }
+            //#endregion
+
+            //#region 璁剧疆琛ㄥご鎵�闇�閲戦
+            function set_HBillMoney() {
+                var HBillMoney = 0;
+                for (var i = 0; i < option.data.length; i++) {
+                    HBillMoney += option.data[i]["HlineTotal"] * 1;
+                }
+                $("#HBillMoney").val(HBillMoney * 0.5);
+            }
+            //#endregion
+
+            //#region 鑾峰彇婧愬崟-閿�鍞鍗曞崟鎹姸鎬�
+            function getSourceBillStatus_SeOrderBill() {
+                var HSourceBillData = "none";
+                var sWhere = " and hmainid = " + $("#HInterID").val();
+                $.ajax({
+                    url: GetWEBURL() + '/Xs_SeOrderBill/list',
+                    async: false,
+                    type: "GET",
+                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
+                    success: function (data1) {
+                        if (data1.count == 1) {
+                            HSourceBillData = data1.data;
+                        } else {
+                            layer.alert(data1.code + "鍗曟嵁鐘舵�佸垽鏂け璐ワ紒", { icon: 5 });
+                        }
+                    }, error: function () {
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                    }
+                });
+                return HSourceBillData;
+            }
+            //#endregion
             //#endregion
 
 
             //浠ヤ笂鏄痩ayui妯″潡
         });
+        //瀛愯〃绋庣巼锛屾牴鎹鎴峰甫鍑�
+        var subHTaxRate = 0;
+
         // 鍩虹璧勬枡杩斿洖鏁版嵁
         function GetHEmpValue(obj)  //杩斿洖涓氬姟鍛�
         {
@@ -1692,8 +2209,12 @@
 
         function GetHSupValue(obj)  //杩斿洖瀹㈡埛
         {
-            $("#HCusName").val(obj[0].HName);
-            $("#HCusID").val(obj[0].HItemID);
+            //$("#HCusName").val(obj[0].HName);
+            //$("#HCusID").val(obj[0].HItemID);
+            //鏍规嵁瀹㈡埛鑾峰彇鐩稿叧淇℃伅
+            getCustomerByCusID(obj[0].HItemID);
+            //鏍规嵁瀹㈡埛鑾峰彇瀹㈡埛浣欓
+            getCustomerBalance(obj[0].HItemID);
         }
 
         function GetHManagerValue(obj)  //杩斿洖涓荤
@@ -1707,6 +2228,140 @@
             $("#HDeptName").val(obj[0].HName);
             $("#HDeptID").val(obj[0].HItemID);
         }
+
+        function GetSettleStyleValue(obj)           //杩斿洖缁撶畻鏂瑰紡
+        {
+            $("#HSSName").val(obj[0].HName);
+            $("#HSSID").val(obj[0].HItemID);
+        }
+
+        function GetSellStyleValue(obj)           //杩斿洖閿�鍞柟寮�
+        {
+            $("#HSellSName").val(obj[0].HName);
+            $("#HSellSID").val(obj[0].HItemID);
+        }
+
+        //#region 鏍规嵁瀹㈡埛鑾峰彇甯佸埆銆佹眹鐜囥�佺粨绠楁柟寮忋�佸鎴蜂俊鐢ㄩ搴︺�佽仈绯讳汉銆佽仈绯荤數璇�
+        function getCustomerByCusID(HCusID) {
+            $.ajax({
+                url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
+                async: false,
+                type: "GET",
+                data: {
+                    "HCusID": HCusID
+                },
+                success: function (result) {
+                    if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                        var data = result.data[0];
+
+                        $("#HCusID").val(data.HCusID);
+                        $("#HCusName").val(data.HCusName);
+                        $("#HCurID").val(data.HCurID);
+                        $("#HCurName").val(data.HCurName);
+                        $("#HExRate").val(data.HExRate);
+                        $("#HSSID").val(data.HSSID);
+                        $("#HSSName").val(data.HSSName);
+                        $("#HCreditRating_Now").val(data.HCreditRating_Now);
+                        $("#HLinkMan").val(data.HLinkMan);
+                        $("#HLinkPhone").val(data.HLinkPhone);
+
+                        subHTaxRate = data.HTaxRate;
+
+                    } else {
+                        layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                    }
+                }, error: function () {
+                    layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                }
+            });
+        }
+        //#endregion
+
+        //#region 鏍规嵁瀹㈡埛鑾峰彇瀹㈡埛瀵瑰簲绋庣巼
+        function getHTaxRateByCusID(HCusID) {
+            $.ajax({
+                url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
+                async: false,
+                type: "GET",
+                data: {
+                    "HCusID": HCusID
+                },
+                success: function (result) {
+                    if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                        var data = result.data[0];
+                        subHTaxRate = data.HTaxRate;
+
+                    } else {
+                        layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                    }
+                }, error: function () {
+                    layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                }
+            });
+        }
+        //#endregion
+
+        //#region 鏍规嵁瀹㈡埛鑾峰彇瀹㈡埛浣欓
+        function getCustomerBalance(HCusID) {
+            $.ajax({
+                url: GetWEBURL() + "/Xs_CusRatingChangeBill/getCustomerBalance",
+                async: false,
+                type: "GET",
+                data: {
+                    "HCusID": HCusID
+                },
+                success: function (result) {
+                    if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                        var data = result.data[0];
+
+                        $("#HCusBalance").val(data.HCusBalance == null ? 0 : data.HCusBalance);
+                        $("#HCreditRating_Now").val(data.HCreditRating_Now == null ? 0 : data.HCreditRating_Now);
+                        $("#HAvailableBalance").val(data.HAvailableBalance == null ? 0 : data.HAvailableBalance);
+                    } else {
+                        layer.alert(result.Message, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                    }
+                }, error: function () {
+                    layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                }
+            });
+        }
+        //#endregion
+
+        //#region 澶勭悊灏忔暟鏄剧ず浣嶆暟锛坉ata锛氶渶瑕佸鐞嗙殑鏁版嵁锛沶um锛氭暟鎹殑绫诲瀷(濡�1:鏁伴噺锛�2:閲戦锛�3:鍗曚环)锛�
+        function dealDoubleToFixed(data, num) {
+            //鐢ㄤ簬璁剧疆灏忔暟浣嶆暟
+            var dotLength = 0;
+
+            if (num == 1) {                                    //褰撴暟鎹负鏁伴噺鏃讹紝鏈�澶氫繚鐣�6浣嶅皬鏁�
+                //璁剧疆鏈�澶氫繚鐣�6浣嶅皬鏁�
+                dotLength = 6;
+            } else if (num == 2) {                             //褰撴暟鎹负閲戦鏃讹紝鏈�澶氫繚鐣�2浣嶅皬鏁�
+                //璁剧疆鏈�澶氫繚鐣�2浣嶅皬鏁�
+                dotLength = 2;
+            } else if (num == 3) {                             //褰撴暟鎹负鍗曚环鏃讹紝鏈�澶氫繚鐣�4浣嶅皬鏁�
+                //璁剧疆鏈�澶氫繚鐣�4浣嶅皬鏁�
+                dotLength = 4;
+            }
+
+            //鍒ゆ柇鏄惁瀛樺湪灏忔暟鐐瑰強鍏剁储寮曚綅缃�
+            data = data + "";
+            var index = data.indexOf(".");
+
+            //澶勭悊鏁版嵁骞惰繑鍥�
+            if (index < 0) {
+                return data * 1;
+            } else {
+                //鑾峰彇灏忔暟浣嶆暟
+                var length = data.length - index - 1;
+                if (length <= dotLength) {
+                    return data * 1;
+                } else {
+                    data = data * 1;
+                    return data.toFixed(dotLength);
+                }
+            }
+        }
+            //#endregion
     </script>
 </body>
 </html>
\ No newline at end of file

--
Gitblit v1.9.1