From df3e719955cc93b4e762ac75fbb61737fbf3b7a8 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 16 六月 2025 08:38:12 +0800
Subject: [PATCH] 1

---
 WebTM/views/采购管理/应付单/Cg_PayableBill.html | 1145 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 959 insertions(+), 186 deletions(-)

diff --git "a/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\345\272\224\344\273\230\345\215\225/Cg_PayableBill.html" "b/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\345\272\224\344\273\230\345\215\225/Cg_PayableBill.html"
index 3074712..86d5f62 100644
--- "a/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\345\272\224\344\273\230\345\215\225/Cg_PayableBill.html"
+++ "b/WebTM/views/\351\207\207\350\264\255\347\256\241\347\220\206/\345\272\224\344\273\230\345\215\225/Cg_PayableBill.html"
@@ -47,6 +47,7 @@
                         <div class="layui-btn-group">
                             <button type="button" id="set_SaveBill" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">淇濆瓨</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="set_SelectMainBill">閫夋暣鍗�</button>
                             <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">閫�鍑�</button>
                         </div>
                     </div>
@@ -54,7 +55,9 @@
                         <h1 style="text-align: center; padding: 10px 0;"><b>搴斾粯鍗�</b></h1>
                         <ul class="layui-tab-title" lay-filter="tab-all">
                             <li lay-id="1" style="padding:1px;" class="layui-this">鍩烘湰淇℃伅</li>
-                            <li lay-id="2" style="padding:1px;">鍒跺崟淇℃伅</li>
+                            <li lay-id="2" style="padding:1px;">鍏朵粬淇℃伅</li>
+                            <li lay-id="3" style="padding:1px;">鍒跺崟淇℃伅</li>
+
                         </ul>
                         <div class="layui-tab-content">
                             <!--鍩烘湰淇℃伅-->
@@ -81,9 +84,9 @@
                                                     <!--鍔ㄦ�佹覆鏌撴簮鍗曠被鍨�-->
                                                 </select>
                                                 <!--<select name="BillType" id="BillType" lay-filter="BillType" style="width: 180px; ">
-                                    <option style="color:blue;" selected="selected" value="1102">閲囪喘璁㈠崟</option>
-                                    <option style="color:blue;" value="1201">閲囪喘鍏ュ簱鍗�</option>
-                                </select>-->
+                            <option style="color:blue;" selected="selected" value="1102">閲囪喘璁㈠崟</option>
+                            <option style="color:blue;" value="1201">閲囪喘鍏ュ簱鍗�</option>
+                        </select>-->
                                             </div>
                                         </div>
                                         <div class="layui-inline">
@@ -92,7 +95,7 @@
                                                 <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType" class="layui-input" value="" style="float:left;width:150px;">
-                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
+                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float: left; width: 150px; " readonly>
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HMainSource" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                 </button>
@@ -100,14 +103,14 @@
                                         </div>
                                     </div>
                                     <div class="layui-row">
-                                        <div class="layui-inline" style="width:625px">
+                                        <div class="layui-inline" >
                                             <label class="layui-form-label">渚涘簲鍟�<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HSupName" id="HSupName" class="layui-input" value="" style="background-color: #efefef4d; width: 505px" readonly>
-                                                <input type="hidden" name="HSupID" id="HSupID" class="layui-input" value="0" style="float: left; width: 505px;">
+                                                <input type="text" name="HSupName" id="HSupName" class="layui-input" value="" style="background-color: #efefef4d; width: 150px" readonly>
+                                                <input type="hidden" name="HSupID" id="HSupID" class="layui-input" value="0" style="float: left; width: 150px;">
                                                 <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HSupList" style="width:40px;">
-                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                    </button>-->
+                <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+            </button>-->
                                             </div>
                                         </div>
                                         <div class="layui-inline">
@@ -130,24 +133,6 @@
                                                 </button>
                                             </div>
                                         </div>
-                                    </div>
-                                    <div class="layui-row">
-                                        <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="background-color: #efefef4d; float: left; width: 150px;" readonly>
-                                                <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>
-                                                </button>
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
-                                            <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" style="background-color: #efefef4d;" readonly>
-                                            </div>
-                                        </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label">閲囪喘鏂瑰紡</label>
                                             <div class="layui-input-inline">
@@ -158,17 +143,8 @@
                                                 </button>
                                             </div>
                                         </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">缁撶畻鏂瑰紡</label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" 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>
-                                                </button>
-                                            </div>
-                                        </div>
                                     </div>
+                                    
                                     <div class="layui-row">
                                         <div class="layui-inline">
                                             <label class="layui-form-label">涓荤</label>
@@ -180,10 +156,24 @@
                                                 </button>
                                             </div>
                                         </div>
+                                        <div class="layui-inline" style="">
+                                            <label class="layui-form-label">鍙戠エ缂栧彿</label>
+                                            <div class="layui-input-inline" style="background-color: #efefef4d; float: left; width: 150px;">
+                                                <input class="layui-input" name="HInvoiceBillNo" id="HInvoiceBillNo" autocomplete="off">
+                                            </div>
+                                        </div>
                                         <div class="layui-inline">
-                                            <label class="layui-form-label">浠樻鏃ユ湡<label style="color:red"> * </label></label>
-                                            <div class="layui-input-block">
-                                                <input type="date" class="layui-input" lay-verify="HReceiveDate" name="HReceiveDate" id="HReceiveDate" style="width:190px;">
+                                            <label class="layui-form-label">椤圭洰鍚嶇О</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HProjectName" id="HProjectName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
+                                                <input type="hidden" name="HProjectID" id="HProjectID" class="layui-input" value="0" style="float: left; width: 150px; background-color: #efefef4d;">
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">椤圭洰缂栫爜</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HProjectNumber" id="HProjectNumber" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
+                                                
                                             </div>
                                         </div>
                                     </div>
@@ -192,16 +182,6 @@
                                             <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" style="margin-top:10px;">
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label" style="width: 85px;">缁勭粐<label style="color:red"> * </label></label>
-                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
-                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
-                                                    <!--鍔ㄦ�佹覆鏌撶粍缁�-->
-                                                </select>
                                             </div>
                                         </div>
                                     </div>
@@ -227,6 +207,59 @@
                                             </div>
                                         </div>
                                     </div>
+                                </div>
+                            </div>
+
+                            <!--鍏朵粬淇℃伅-->
+                            <div class="layui-tab-item">
+                                <div class="layui-form-item" style="padding-top: 10px;">
+                                    <div class="layui-row">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">缁撶畻鏂瑰紡</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" 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>
+                                                </button>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">浠樻鏃ユ湡<label style="color:red"> * </label></label>
+                                            <div class="layui-input-block">
+                                                <input type="date" class="layui-input" lay-verify="HReceiveDate" name="HReceiveDate" id="HReceiveDate" style="width:190px;">
+                                            </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="background-color: #efefef4d; float: left; width: 150px;" readonly>
+                                                <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>
+                                                </button>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row">
+                                        <div class="layui-inline">
+                                            <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" style="background-color: #efefef4d;" readonly>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row" style="margin-top:10px;">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label" style="width: 85px;">缁勭粐<label style="color:red"> * </label></label>
+                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
+                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
+                                                    <!--鍔ㄦ�佹覆鏌撶粍缁�-->
+                                                </select>
+                                            </div>
+                                        </div>
+                                    </div>
+
                                 </div>
                             </div>
                             <!--鍒跺崟淇℃伅-->
@@ -366,7 +399,7 @@
 
             var allVal;
             var HModName = "Cg_PayableBill";
-
+            var topScroll = 0;//璁板綍婊氬姩鏉$殑浣嶇疆
             //璁板綍缁勭粐鐨勫��
             var HOrgIDBar = 0;
 
@@ -463,6 +496,12 @@
             //#region 瀹℃牳鎸夐挳
             form.on('submit(set_CheckBill)', function (data) {
                 set_CheckBill(0);
+            });
+            //#endregion
+
+            //#region 閫夋暣鍗�
+            form.on('submit(set_SelectMainBill)', function (data) {
+                set_SelectMainBill();
             });
             //#endregion
 
@@ -575,6 +614,254 @@
             });
             //#endregion
 
+            //#region 鍥炶溅閫夋嫨婧愬崟
+            $('#HMainSourceBillNo').on('keydown', function (event) {
+                var HSourceBillNo = $('#HMainSourceBillNo').val();//锛堟簮鍗曞崟鎹彿锛�
+                if (event.keyCode == 13) {
+                    var ajaxLoad = layer.load();
+                    var url;
+                    //鍒ゆ柇鏂囨湰妗嗘槸鍚︽湁鏁版嵁    new
+                    if (HSourceBillNo == "") {
+                        layer.close(ajaxLoad);
+                        return;
+                    }
+                    if ($("#BillType").val() == "1102") {
+                        //婧愬崟绫诲瀷鏄噰璐鍗�
+                        url = "/Cg_POOrderBill/PushList";
+                    } else if ($("#BillType").val() == "1201") {
+                        //婧愬崟绫诲瀷鏄敹鏂欓�氱煡鍗�
+                        url = "/Kf_POStockInBill/PushList";
+                    }
+                    $.ajax({
+                        url: GetWEBURL() + url,
+                        type: "GET",
+                        data: { "HBillNo": HSourceBillNo, "user": sessionStorage["HUserName"] },
+                        success: function (result) {
+                            if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                                var dataArray = result.data;
+                                if ($("#BillType").val() == "1102") {
+                                    form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
+                                        "HMainSourceInterID": "0"
+                                        , "HMainSourceEntryID": "0"
+                                        /*, "HMainSourceBillNo": ""*/
+                                        , "HMainSourceBillType": $("#BillType").val()
+
+                                        , "HDeptID": dataArray[0].HDeptID
+                                        , "HDeptName": dataArray[0].閮ㄩ棬
+                                        , "HMangerID": dataArray[0].HManagerID
+                                        , "HMangerName": dataArray[0].涓荤
+                                        , "HEmpID": dataArray[0].HEmpID
+                                        , "HEmpName": dataArray[0].涓氬姟鍛�
+                                        , "HSupID": dataArray[0].HSupID
+                                        , "HSupName": dataArray[0].渚涘簲鍟�
+                                        , "HCurID": dataArray[0].HCurID
+                                        , "HCurName": dataArray[0].甯佸埆
+                                        , "HExRate": dataArray[0].姹囩巼
+                                        , "HSSID": dataArray[0].HSSID
+                                        , "HSSName": dataArray[0].缁撶畻鏂瑰紡
+                                        , "HPSStyleID": dataArray[0].HPSStyleID
+                                        , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                                        , "HProjectID": dataArray[0].HProjectID
+                                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                                    });
+
+                                    //瀛愯〃Entry  璧嬪��
+                                    var rowdataEntry = [];
+                                    for (var i = 0; i < dataArray.length; i++) {
+                                        var HQty = dataArray[i].鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺;                           //鏁伴噺
+                                        var HPrice = dataArray[i].鍗曚环;               //鍗曚环
+                                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                        var HTaxRate = dataArray[i].绋庣巼 * 0.01;           //绋庣巼
+                                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                        var HExRate = $("#HExRate").val();                      //姹囩巼
+                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                                        var HMoneyBB = HMoney * HExRate;
+                                        rowdataEntry.push(
+                                            {
+                                                "HMaterID": dataArray[i].HMaterID
+                                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                                , "HUnitID": dataArray[i].HUnitID
+                                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                                , "HQty": dealDoubleToFixed(HQty, 1)
+                                                , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                                , 'HDiscountRate': "1"                                                     //
+                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                                , "HTaxRate": dataArray[i].绋庣巼
+                                                , 'HTaxMoney': HTaxMoney                                                         //
+                                                , "HMoney": dealDoubleToFixed(HMoney, 2)
+                                                , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
+                                                , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
+                                                , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
+                                                , "HRemark": ""
+
+                                                , "HSourceInterID": dataArray[i].hmainid
+                                                , "HSourceEntryID": dataArray[i].hsubid
+                                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                                , "HSourceBillType": dataArray[i].鍗曟嵁绫诲瀷
+                                                , "HRelationQty": "0"
+                                                , "HRelationMoney": "0"
+
+                                                , 'HPOOrderInterID': "0"
+                                                , 'HPOOrderEntryID': "0"
+                                                , 'HPOOrderBillNo': ""
+
+                                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                                , "HSeOrderInterID": dataArray[i].hmainid
+                                                , "HSeOrderEntryID": dataArray[i].hsubid
+                                                , "HSeOrderBillNo": dataArray[i].鍗曟嵁鍙�
+                                            }
+                                        );
+                                    }
+                                    optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
+                                    table.render(optionEntry);
+                                    //瀛愯〃姹囨��
+                                    for (var i = 0; i < rowdataEntry.length; i++) {
+                                        var item = rowdataEntry[i];
+
+                                        for (var j = i + 1; j < rowdataEntry.length; j++) {
+                                            if (rowdataEntry[j].HMaterID == item.HMaterID) {
+                                                rowdataEntry[i].HQty += rowdataEntry[j].HQty;//鏁伴噺
+                                                rowdataEntry[i].HMoney += rowdataEntry[j].HMoney;//閲戦
+                                                rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//鍗曚环
+                                                //rowdataEntry[i].HMoney = rowdataEntry[i].HQty * rowdataEntry[i].HPrice//閲戦=鏁伴噺*鍗曚环
+                                                rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//绋庨
+                                                rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //浠风◣鍚堣
+                                                var HExRate = $("#HExRate").val();
+                                                rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //鏈綅甯佷环绋庡悎璁�
+                                                rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //鏈綅甯侀噾棰�
+                                                rowdataEntry.splice(j, 1);
+                                                j = j - 1;
+                                            }
+                                        }
+                                    }
+                                    set_InitGridHaveSource();
+                                    option.data = rowdataEntry;
+
+                                } else if ($("#BillType").val() == "1201") {
+                                    form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
+                                        "HMainSourceInterID": "0"
+                                        , "HMainSourceEntryID": "0"
+                                        /*, "HMainSourceBillNo": ""*/
+                                        , "HMainSourceBillType": $("#BillType").val()
+
+                                        , "HDeptID": dataArray[0].HDeptID
+                                        , "HDeptName": dataArray[0].閮ㄩ棬
+                                        , "HMangerID": dataArray[0].hmanagerid == null ? "0" : dataArray[0].hmanagerid
+                                        , "HMangerName": dataArray[0].涓荤
+                                        , "HEmpID": dataArray[0].HEmpID
+                                        , "HEmpName": dataArray[0].涓氬姟鍛�
+                                        , "HSupID": dataArray[0].HSupID
+                                        , "HSupName": dataArray[0].渚涘簲鍟�
+                                        , "HCurID": dataArray[0].HCurID
+                                        , "HCurName": dataArray[0].甯佸埆
+                                        , "HExRate": dataArray[0].姹囩巼
+                                        , "HSSID": "0"
+                                        , "HSSName": ""
+                                        , "HPSStyleID": dataArray[0].HPSStyleID
+                                        , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                                        , "HProjectID": dataArray[0].HProjectID
+                                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                                        , "HInvoiceBillNo": dataArray[0].鍙戠エ缂栧彿
+                                    });
+                                    //瀛愯〃Entry  璧嬪��
+                                    var rowdataEntry = [];
+                                    for (var i = 0; i < dataArray.length; i++) {
+                                        var HQty = dataArray[i].瀹炴敹鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺;                           //鏁伴噺
+                                        var HPrice = dataArray[i].鍗曚环;               //鍗曚环
+                                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                        var HTaxRate = dataArray[i].绋庣巼 * 0.01;           //绋庣巼
+                                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                        var HExRate = $("#HExRate").val();                      //姹囩巼
+                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                                        var HMoneyBB = HMoney * HExRate;
+                                        rowdataEntry.push(
+                                            {
+                                                "HMaterID": dataArray[i].HMaterID
+                                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                                , "HUnitID": dataArray[i].HUnitID
+                                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                                , "HQty": dealDoubleToFixed(HQty, 1)
+                                                , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                                , 'HDiscountRate': "1"                                                     //
+                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                                , "HTaxRate": dataArray[i].绋庣巼
+                                                , 'HTaxMoney': HTaxMoney                                                         //
+                                                , "HMoney": dealDoubleToFixed(HMoney, 2)
+                                                , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
+                                                , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
+                                                , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
+                                                , "HRemark": ""
+
+                                                , "HSourceInterID": dataArray[i].hmainid
+                                                , "HSourceEntryID": dataArray[i].hsubid
+                                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                                , "HSourceBillType": dataArray[i].鍗曟嵁绫诲瀷
+                                                , "HRelationQty": "0"
+                                                , "HRelationMoney": "0"
+
+                                                , 'HPOOrderInterID': "0"
+                                                , 'HPOOrderEntryID': "0"
+                                                , 'HPOOrderBillNo': ""
+
+                                                // , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                                , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID : "0"
+                                                , "HSeOrderEntryID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceEntryID : "0"
+                                                , "HSeOrderBillNo": dataArray[i].HSourceBillType == "1401" ? dataArray[i].婧愬崟鍗曞彿 : ""
+                                            }
+                                        );
+                                    }
+                                    optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
+                                    table.render(optionEntry);
+                                    //瀛愯〃姹囨��
+                                    for (var i = 0; i < rowdataEntry.length; i++) {
+                                        var item = rowdataEntry[i];
+                                        for (var j = i + 1; j < rowdataEntry.length; j++) {
+                                            if (rowdataEntry[j].HMaterID == item.HMaterID) {
+                                                rowdataEntry[i].HQty += rowdataEntry[j].HQty;
+                                                rowdataEntry[i].HMoney += rowdataEntry[j].HMoney;//閲戦
+                                                rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//鍗曚环
+                                                rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//绋庨
+                                                rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //浠风◣鍚堣
+                                                var HExRate = $("#HExRate").val();
+                                                rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //鏈綅甯佷环绋庡悎璁�
+                                                rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //鏈綅甯侀噾棰�
+                                                rowdataEntry.splice(j, 1);
+                                                j = j - 1;
+                                            }
+                                        }
+                                    }
+                                    set_InitGridHaveSource();
+                                    option.data = rowdataEntry;
+                                    
+                                }
+                                haveSource = true;
+                                table.render(option);
+                                layer.close(ajaxLoad);
+                                layer.msg("鏌ヨ鎴愬姛", { time: 1 * 1000, icon: 1 });
+                            } else {
+                                layer.alert(result.Message, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                                layer.close(ajaxLoad);
+                            }
+                        }, error: function () {
+                            layer.alert(result.Message + "鍙戠敓閿欒!", { icon: 5 });
+                            layer.close(ajaxLoad);
+                        }
+                    });
+                }
+            });
+            //#endregion
+
+
             //#endregion
 
             //#region 澶嶉�夋鐘舵�佸彉鏇�
@@ -596,7 +883,7 @@
                     , "HQty": "0"
                     , "HPrice": "0"
                     , "HTaxPrice": "0"
-                    , 'HDiscountRate': "0"
+                    , 'HDiscountRate': "1"
                     , 'HRelTaxPrice': "0"
                     , "HTaxRate": "0"
                     , 'HTaxMoney': "0"
@@ -1002,7 +1289,17 @@
                         if (checkStatus.data.length === 0) {
                             return layer.msg('璇烽�夋嫨鏁版嵁');
                         }
-
+                        var HSupID = $("#HSupID").val();//鍒ゆ柇渚涘簲鍟�
+                        if (HSupID == 0 || HSupID == '') {
+                            HSupID = checkStatus.data[0]["HSupID"];
+                        }
+                        for (var i = 0; i < checkStatus.data.length; i++) {
+                            if (checkStatus.data[i]["HSupID"] != HSupID) {
+                                layer.msg("涓嬫帹澶辫触!宸茬粡閫変腑鐨勮褰曚腑瀛樺湪涓嶅悓渚涘簲鍟�!");
+                                layer.close(index);//鍏抽棴寮圭獥
+                                return;
+                            }
+                        }
                         if ($("#BillType").val() == "1102") {
                             setInitByPOOrderBill(checkStatus);
                         }
@@ -1017,6 +1314,318 @@
                 })
             }
             //#endregion
+
+            //#region 閫夋暣鍗�
+            function set_SelectMainBill() {
+                var url;
+                if ($("#BillType").val() == "1102") {
+                    url = "../../閲囪喘绠$悊/閲囪喘璁㈠崟/Cg_POOrderBillQuery.html?openType=2&HOrgID=" + HOrgID;
+                } else if ($("#BillType").val() == "1201") {
+                    url = "../../楠屾敹鍏ュ簱/澶栬喘鍏ュ簱/Kf_POStockInBillListQuery.html?openType=2&HOrgID=" + HOrgID;
+                } else {
+                    return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟閫夋嫨锛侊紒');
+                }
+                //椤甸潰灞�-鑷畾涔�
+                layer.open({
+                    type: 2
+                    , skin: "layui-layer-rim" //鍔犱笂杈规
+                    , title: '' + '婧愬崟' + '鍒楄〃'  //鏍囬
+                    , closeBtn: 1  //绐椾綋鍙充笂瑙掑叧闂� 鐨� 鏍峰紡
+                    , shift: 2 //寮瑰嚭鍔ㄧ敾
+                    , area: ["90%", "90%"] //绐椾綋澶у皬
+                    , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
+                    , content: [url, "yes"]
+                    , btn: ["纭畾", "鍙栨秷"]
+                    , btn1: function (index, laero) {
+                        //鎸夐挳涓�  鐨勫洖璋�
+                        var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
+
+                        if (checkStatus.data.length == 0) {
+                            return layer.msg("璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�!");
+                        }
+                        var HSupID = $("#HSupID").val();//鍒ゆ柇渚涘簲鍟�
+                        if (HSupID == 0 || HSupID == '') {
+                            HSupID = checkStatus.data[0]["HSupID"];
+                        }
+                        //鑾峰彇渚涘簲鍟嗕唬鐮�,璁剧疆鏉′欢
+                        var sMainWhere = " and hmainid in(";
+                        for (var i = 0; i < checkStatus.data.length; i++) {
+                            if (checkStatus.data[i]["HSupID"] != HSupID) {
+                                layer.msg("涓嬫帹澶辫触!宸茬粡閫変腑鐨勮褰曚腑瀛樺湪涓嶅悓渚涘簲鍟�!");
+                                layer.close(index);//鍏抽棴寮圭獥
+                                return;
+                            }
+                            sMainWhere += checkStatus.data[i]["hmainid"]
+                            if (i != checkStatus.data.length - 1) {
+                                sMainWhere += ",";
+                            } else {
+                                sMainWhere += ") ";
+                            }
+                        }
+                        getSeletMainInfo(sMainWhere);
+                        layer.close(index);//鍏抽棴寮圭獥
+                    }
+                });
+            }
+            //#endregion
+
+            //#region 鏁村崟淇℃伅鑾峰彇鏂规硶
+            function getSeletMainInfo(sMainWhere) {
+                var ajaxLoad = layer.load();
+                if ($("#BillType").val() == "1102") {
+                    $.ajax({
+                        url: GetWEBURL() + '/Cg_POOrderBill/list',
+                        async: false,
+                        type: "GET",
+                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
+                        success: function (data1) {
+                            if (data1.count == 1) {
+                                var dataArray = data1.data;
+                                option.data = [];//娓呯┖瀛愯〃
+                                form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
+                                    "HMainSourceInterID": "0"
+                                    , "HMainSourceEntryID": "0"
+                                    /*, "HMainSourceBillNo": ""*/
+                                    , "HMainSourceBillType": $("#BillType").val()
+
+                                    , "HDeptID": dataArray[0].HDeptID
+                                    , "HDeptName": dataArray[0].閮ㄩ棬
+                                    , "HMangerID": dataArray[0].HManagerID
+                                    , "HMangerName": dataArray[0].涓荤
+                                    , "HEmpID": dataArray[0].HEmpID
+                                    , "HEmpName": dataArray[0].涓氬姟鍛�
+                                    , "HSupID": dataArray[0].HSupID
+                                    , "HSupName": dataArray[0].渚涘簲鍟�
+                                    , "HCurID": dataArray[0].HCurID
+                                    , "HCurName": dataArray[0].甯佸埆
+                                    , "HExRate": dataArray[0].姹囩巼
+                                    , "HSSID": dataArray[0].HSSID
+                                    , "HSSName": dataArray[0].缁撶畻鏂瑰紡
+                                    , "HPSStyleID": dataArray[0].HPSStyleID
+                                    , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                                    , "HProjectID": dataArray[0].HProjectID
+                                    , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                                    , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                                });
+
+                                //瀛愯〃Entry  璧嬪��
+                                var rowdataEntry = [];
+                                for (var i = 0; i < dataArray.length; i++) {
+                                    var HQty = dataArray[i].鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺;                           //鏁伴噺
+                                    var HPrice = dataArray[i].鍗曚环;               //鍗曚环
+                                    var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                    var HTaxRate = dataArray[i].绋庣巼 * 0.01;           //绋庣巼
+                                    var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                    var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                    var HExRate = $("#HExRate").val();                      //姹囩巼
+                                    var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                                    var HMoneyBB = HMoney * HExRate;
+                                    rowdataEntry.push(
+                                        {
+                                            "HMaterID": dataArray[i].HMaterID
+                                            , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                            , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                            , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                            , "HUnitID": dataArray[i].HUnitID
+                                            , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                            , "HQty": dealDoubleToFixed(HQty, 1)
+                                            , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                            , 'HDiscountRate': "1"                                                     //
+                                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                            , "HTaxRate": dataArray[i].绋庣巼
+                                            , 'HTaxMoney': HTaxMoney                                                         //
+                                            , "HMoney": dealDoubleToFixed(HMoney, 2)
+                                            , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
+                                            , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
+                                            , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
+                                            , "HRemark": ""
+
+                                            , "HSourceInterID": dataArray[i].hmainid
+                                            , "HSourceEntryID": dataArray[i].hsubid
+                                            , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                            , "HSourceBillType": dataArray[i].鍗曟嵁绫诲瀷
+                                            , "HRelationQty": "0"
+                                            , "HRelationMoney": "0"
+
+                                            , 'HPOOrderInterID': "0"
+                                            , 'HPOOrderEntryID': "0"
+                                            , 'HPOOrderBillNo': ""
+
+                                            , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                            , "HSeOrderInterID": dataArray[i].hmainid
+                                            , "HSeOrderEntryID": dataArray[i].hsubid
+                                            , "HSeOrderBillNo": dataArray[i].鍗曟嵁鍙�
+                                        }
+                                    );
+                                }
+                                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
+                                table.render(optionEntry);
+                                //瀛愯〃姹囨��
+                                for (var i = 0; i < rowdataEntry.length; i++) {
+                                    var item = rowdataEntry[i];
+
+                                    for (var j = i + 1; j < rowdataEntry.length; j++) {
+                                        if (rowdataEntry[j].HMaterID == item.HMaterID) {
+                                            rowdataEntry[i].HQty += rowdataEntry[j].HQty;//鏁伴噺
+                                            rowdataEntry[i].HMoney += rowdataEntry[j].HMoney;//閲戦
+                                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//鍗曚环
+                                            rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//绋庨
+                                            rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //浠风◣鍚堣
+                                            var HExRate = $("#HExRate").val();
+                                            rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //鏈綅甯佷环绋庡悎璁�
+                                            rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //鏈綅甯侀噾棰�
+                                            rowdataEntry.splice(j, 1);
+                                            j = j - 1;
+                                        }
+                                    }
+                                }
+                                set_InitGridHaveSource();
+                                option.data = rowdataEntry;
+                                haveSource = true;
+                                table.render(option);
+                                layer.close(ajaxLoad);
+                                //layer.alert("鏌ヨ鎴愬姛", { icon: 1 });
+                            } else {
+                                layer.close(ajaxLoad);
+                                layer.alert(data1.code + data1.Message, { icon: 5 });
+                                return;
+                            }
+                        }, error: function () {
+                            layer.close(ajaxLoad);
+                            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                            return;
+                        }
+                    });
+
+                } else if ($("#BillType").val() == "1201") {
+                    $.ajax({
+                        url: GetWEBURL() + '/Kf_POStockInBill/list',
+                        type: "GET",
+                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
+                        success: function (data1) {
+                            if (data1.count == 1) {
+                                dataArray = data1.data;
+                                form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
+                                    "HMainSourceInterID": "0"
+                                    , "HMainSourceEntryID": "0"
+                                    /*, "HMainSourceBillNo": ""*/
+                                    , "HMainSourceBillType": $("#BillType").val()
+
+                                    , "HDeptID": dataArray[0].HDeptID
+                                    , "HDeptName": dataArray[0].閮ㄩ棬
+                                    , "HMangerID": dataArray[0].hmanagerid == null ? "0" : dataArray[0].hmanagerid
+                                    , "HMangerName": dataArray[0].涓荤
+                                    , "HEmpID": dataArray[0].HEmpID
+                                    , "HEmpName": dataArray[0].涓氬姟鍛�
+                                    , "HSupID": dataArray[0].HSupID
+                                    , "HSupName": dataArray[0].渚涘簲鍟�
+                                    , "HCurID": dataArray[0].HCurID
+                                    , "HCurName": dataArray[0].甯佸埆
+                                    , "HExRate": dataArray[0].姹囩巼
+                                    , "HSSID": "0"
+                                    , "HSSName": ""
+                                    , "HPSStyleID": dataArray[0].HPSStyleID
+                                    , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                                    , "HProjectID": dataArray[0].HProjectID
+                                    , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                                    , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                                    , "HInvoiceBillNo": dataArray[0].鍙戠エ缂栧彿
+                                });
+                                //瀛愯〃Entry  璧嬪��
+                                var rowdataEntry = [];
+                                for (var i = 0; i < dataArray.length; i++) {
+                                    var HQty = dataArray[i].瀹炴敹鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺;                           //鏁伴噺
+                                    var HPrice = dataArray[i].鍗曚环;               //鍗曚环
+                                    var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                    var HTaxRate = dataArray[i].绋庣巼 * 0.01;           //绋庣巼
+                                    var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                    var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                    var HExRate = $("#HExRate").val();                      //姹囩巼
+                                    var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                                    var HMoneyBB = HMoney * HExRate;
+                                    rowdataEntry.push(
+                                        {
+                                            "HMaterID": dataArray[i].HMaterID
+                                            , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                            , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                            , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                            , "HUnitID": dataArray[i].HUnitID
+                                            , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                            , "HQty": dealDoubleToFixed(HQty, 1)
+                                            , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                            , 'HDiscountRate': "1"                                                     //
+                                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                            , "HTaxRate": dataArray[i].绋庣巼
+                                            , 'HTaxMoney': HTaxMoney                                                         //
+                                            , "HMoney": dealDoubleToFixed(HMoney, 2)
+                                            , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
+                                            , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
+                                            , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
+                                            , "HRemark": ""
+
+                                            , "HSourceInterID": dataArray[i].hmainid
+                                            , "HSourceEntryID": dataArray[i].hsubid
+                                            , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                            , "HSourceBillType": dataArray[i].鍗曟嵁绫诲瀷
+                                            , "HRelationQty": "0"
+                                            , "HRelationMoney": "0"
+
+                                            , 'HPOOrderInterID': "0"
+                                            , 'HPOOrderEntryID': "0"
+                                            , 'HPOOrderBillNo': ""
+
+                                            // , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                            , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID : "0"
+                                            , "HSeOrderEntryID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceEntryID : "0"
+                                            , "HSeOrderBillNo": dataArray[i].HSourceBillType == "1401" ? dataArray[i].婧愬崟鍗曞彿 : ""
+                                        }
+                                    );
+                                }
+                                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
+                                table.render(optionEntry);
+                                //瀛愯〃姹囨��
+                                for (var i = 0; i < rowdataEntry.length; i++) {
+                                    var item = rowdataEntry[i];
+                                    for (var j = i + 1; j < rowdataEntry.length; j++) {
+                                        if (rowdataEntry[j].HMaterID == item.HMaterID) {
+                                            rowdataEntry[i].HQty += rowdataEntry[j].HQty;
+                                            rowdataEntry[i].HMoney += rowdataEntry[j].HMoney;//閲戦
+                                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//鍗曚环
+                                            rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//绋庨
+                                            rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //浠风◣鍚堣
+                                            var HExRate = $("#HExRate").val();
+                                            rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //鏈綅甯佷环绋庡悎璁�
+                                            rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //鏈綅甯侀噾棰�
+                                            rowdataEntry.splice(j, 1);
+                                            j = j - 1;
+                                        }
+                                    }
+                                }
+                                set_InitGridHaveSource();
+                                option.data = rowdataEntry;
+                                haveSource = true;
+                                table.render(option);
+                                layer.close(ajaxLoad);
+                            } else {
+                                layer.close(ajaxLoad);
+                                layer.alert(data1.code + data1.Message, { icon: 5 });
+                                return;
+                            }
+                        }, error: function () {
+                            layer.close(ajaxLoad);
+                            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                            return;
+                        }
+                    });
+                } else {
+                    return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟閫夋嫨锛侊紒');
+                }
+            }
+            //#endregion
+
             //#endregion
 
             //#region 瀛愯〃鍒濆鍖�
@@ -1038,8 +1647,8 @@
                         , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                         , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100, edit: 'text', event: "HUnitID"}//f7
                         , { field: 'HQty', title: '鏁伴噺', width: 100, totalRow: true, edit: 'text'}
-                        , { field: 'HPrice', title: '鍗曚环', width: 100, edit: 'text', event: "HPrice" }
-                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
+                        , { field: 'HPrice', title: '鍗曚环', width: 100, event: "HPrice", style: 'background-color:#efefef4d;' }
+                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true, edit: 'text' }
                         , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, edit: 'text', event: "HTaxPrice" }
                         , { field: 'HDiscountRate', title: '鎶樻墸鐜�', width: 100, edit: 'text' }
                         , { field: 'HRelTaxPrice', title: '瀹為檯鍚◣鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
@@ -1067,6 +1676,10 @@
                         , { field: 'HSeOrderBillNo', title: '閿�鍞鍗曞彿', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                         , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 70 }
                     ]]
+                    , done: function (res, curr, count) {
+                        $(".layui-table-main").scrollTop(topScroll);
+                    }
+
                 }
                 optionEntry = {
                     elem: '#mainTableEntry'
@@ -1123,7 +1736,7 @@
                     , "HQty": "0"
                     , "HPrice": "0"
                     , "HTaxPrice": "0"
-                    , 'HDiscountRate': "0"
+                    , 'HDiscountRate': "1"
                     , 'HRelTaxPrice': "0"
                     , "HTaxRate": "0"
                     , 'HTaxMoney': "0"
@@ -1156,52 +1769,15 @@
                 table.render(optionEntry);
             }
             function set_InitGridHaveSource() {
-                option = {
-                    elem: '#mainTable'
-                    , toolbar: '#toolbarDemo'
-                    , totalRow: true
-                    , limit: 500
-                    , height: 500
-                    , loading: false
-                    , cols: [[ //瀛愯〃
-                        { type: 'checkbox', totalRowText: '鍚堣琛�' }
-                        , { type: 'numbers', title: '搴忓彿', width: 100 }
-                        , { 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, 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, edit: 'text', event: "HUnitID" }//f7
-                        , { field: 'HQty', title: '鏁伴噺', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
-                        , { field: 'HPrice', title: '鍗曚环', width: 100, edit: 'text', event: "HPrice" }
-                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, edit: 'text', event: "HTaxPrice" }
-                        , { field: 'HDiscountRate', title: '鎶樻墸鐜�', width: 100, edit: 'text' }
-                        , { field: 'HRelTaxPrice', title: '瀹為檯鍚◣鍗曚环', width: 100, edit: 'text' }
-                        , { field: 'HTaxRate', title: '绋庣巼', width: 100, edit: 'text' }
-                        , { field: 'HTaxMoney', title: '绋庨', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HMoneyBB', title: '鏈綅甯侀噾棰�', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HlineTotal', title: '浠风◣鍚堣', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HlineTotalBB', title: '鏈綅甯佷环绋庡悎璁�', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HRemark', title: '澶囨敞', width: 100, edit: 'text' }
-
-                        , { field: 'HSourceInterID', title: '婧愬崟鍐呯爜', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HSourceEntryID', title: '婧愬崟瀛愬唴鐮�', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HSourceBillNo', title: '婧愬崟鍙�', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HSourceBillType', title: '婧愬崟绫诲瀷', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HRelationQty', title: '鍏宠仈鏁伴噺', width: 100, totalRow: true, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HRelationMoney', title: '鍏宠仈閲戦', width: 100, totalRow: true, hide: true, style: 'background-color:#efefef4d;' }
-
-                        , { field: 'HPOOrderInterID', title: '閲囪喘璁㈠崟鍐呯爜', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HPOOrderEntryID', title: '閲囪喘璁㈠崟瀛愬唴鐮�', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HPOOrderBillNo', title: '閲囪喘璁㈠崟鍙�', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-
-                        , { field: 'HSeOrderTaxPrice', title: '璁㈠崟鍚◣鍗曚环', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HSeOrderInterID', title: '閿�鍞鍗曞唴鐮�', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HSeOrderEntryID', title: '閿�鍞鍗曞瓙鍐呯爜', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { field: 'HSeOrderBillNo', title: '閿�鍞鍗曞彿', width: 100, hide: true, style: 'background-color:#efefef4d;' }
-                        , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 70 }
-                    ]]
+                //閫変腑婧愬崟鍚庢暟閲忎笉鍙紪杈�
+                for (var i = 0; i < option.cols[0].length; i++) {
+                    if (option.cols[0][i]["field"] == "HQty") {
+                       option.cols[0][i]["edit"] = false;
+                    }
+                    //if (option.cols[0][i]["field"] == "HMoney") {
+                    //    option.cols[0][i]["edit"] = false;
+                    //}
+                    
                 }
             }
             //#endregion
@@ -1211,11 +1787,13 @@
             table.on('edit(mainTable)', function (obj) {
                 //鏁板�兼牸寮忔牎楠屽伐鍏�
                 var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
+                var ref1 = /^-?\d+(\.\d+)?$/;          //鍒ゆ柇瀛楃涓叉槸鍚︿负鏁板瓧(鍖呭惈鏁存暟銆佹诞鐐规暟)锛屾鍒欒〃杈惧紡
                 var temp = "";
                 var Dec = getDecByMaterID(obj.data.HMaterID) //鑾峰彇绮惧害
                 var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //鏁伴噺绮惧害
                 var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //鍗曚环绮惧害
                 var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //閲戦绮惧害
+                topScroll = $('#mainTable').next('.layui-table-view').find('.layui-table-body').scrollTop();//鑾峰彇婊氬姩鏉′綅缃�
                 // 鍗曞厓鏍肩紪杈戜箣鍓嶇殑鍊�
                 var oldText = $(this).prev().text();
                 var value = obj.value //寰楀埌淇敼鍚庣殑鍊�
@@ -1227,14 +1805,23 @@
                     case "HQty":                                         //鏁伴噺
                         //鏁版嵁鏍煎紡鏍¢獙
                         temp = value + "";
-                        if (!ref.test(temp) || temp == 0) {
+                        if (!ref1.test(temp)) {
                             //鎭㈠鏁版嵁鍒扮紪杈戝墠
                             obj.update({
                                 HQty: oldText
                             });
                             table.render(option);
 
-                            layer.msg("鏁伴噺璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
+                            layer.msg("鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛�!");
+                            return;
+                        } else if (temp * 1 == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HQty: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛�!");
                             return;
                         }
 
@@ -1248,6 +1835,7 @@
                         var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
                         var HExRate = $("#HExRate").val();                      //姹囩巼
                         var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HMoneyBB = HMoney * HExRate;
 
                         HQty = Number(HQty.toFixed(HQtyDec));
                         HPrice = Number(HPrice.toFixed(HPriceDec));
@@ -1255,6 +1843,7 @@
                         HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                         HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                         HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
+                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
@@ -1263,6 +1852,7 @@
                             , HTaxMoney: HTaxMoney
                             , HlineTotal: HlineTotal
                             , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
                         table.render(option);
                         break;
@@ -1274,7 +1864,7 @@
                             obj.update({
                                 HPrice: oldText
                             });
-
+                            table.render(option);
                             layer.msg("鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
                             return;
                         }
@@ -1291,16 +1881,17 @@
                         var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
                         var HExRate = $("#HExRate").val();                      //姹囩巼
                         var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
-
+                        var HMoneyBB = HMoney * HExRate;
                         //鏁板瓧绮惧害
                         HQty = Number(HQty.toFixed(HQtyDec));
                         HPrice = Number(HPrice.toFixed(HPriceDec));
                         HMoney = Number(HMoney.toFixed(HMoneyDec));
                         HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
-                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
-                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                         HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                         HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
@@ -1311,6 +1902,7 @@
                             , HTaxPrice, HTaxPrice
                             , HRelTaxPrice: HRelTaxPrice
                             , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
                         table.render(option);
                         break;
@@ -1322,7 +1914,7 @@
                             obj.update({
                                 HTaxRate: oldText
                             });
-
+                            table.render(option);
                             layer.msg("绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛�!");
                             return;
                         }
@@ -1341,15 +1933,17 @@
                         var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
                         var HExRate = $("#HExRate").val();                       //姹囩巼
                         var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));       //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HMoneyBB = HMoney * HExRate;
                         //鏁板瓧绮惧害
                         HQty = Number(HQty.toFixed(HQtyDec));
                         HPrice = Number(HPrice.toFixed(HPriceDec));
                         HMoney = Number(HMoney.toFixed(HMoneyDec));
                         HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
-                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
-                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                         HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                         HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HTaxRate: HTaxRate * 100
@@ -1362,6 +1956,7 @@
                             , HTaxPrice, HTaxPrice
                             , HRelTaxPrice: HRelTaxPrice
                             , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
                         table.render(option);
                         break;
@@ -1373,7 +1968,7 @@
                             obj.update({
                                 HDiscountRate: oldText
                             });
-
+                            table.render(option);
                             layer.msg("鎶樻墸鐜囪杈撳叆涓嶅皬浜�0鐨勬暟瀛�!");
                             return;
                         }
@@ -1393,8 +1988,8 @@
                         HQty = Number(HQty.toFixed(HQtyDec));
                         HPrice = Number(HPrice.toFixed(HPriceDec));
                         HMoney = Number(HMoney.toFixed(HMoneyDec));
-                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
-                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                         HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
@@ -1409,7 +2004,6 @@
                         });
                         table.render(option);
                         break;
-                        
                     case "HTaxPrice":                                         //鍗曚环
                         //鏁版嵁鏍煎紡鏍¢獙  
                         temp = value + "";     //淇敼鍚庣殑鍊� 杞负瀛楃涓� 璧嬪�肩粰  鍙橀噺temp
@@ -1436,6 +2030,7 @@
                         var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
                         var HExRate = $("#HExRate").val();                      //姹囩巼
                         var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HMoneyBB = HMoney * HExRate;
                         //鏁板瓧绮惧害
                         HQty = Number(HQty.toFixed(HQtyDec));
                         HPrice = Number(HPrice.toFixed(HPriceDec));
@@ -1445,6 +2040,7 @@
                         HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                         HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                         HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
+                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({                    //鏇存柊琛ㄦ牸鏁版嵁                鏂规硶鏄瀵硅薄鎻愪緵鐨勪竴涓柟娉曪紝鐢ㄤ簬鏇存柊鍏跺唴閮ㄧ姸鎬佹垨涓庝箣鍏宠仈鐨勬暟鎹簮
                             HQty: HQty                               //鏇存柊HQty瀛楁锛孒Qty
@@ -1455,6 +2051,65 @@
                             , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
                             , HRelTaxPrice: HRelTaxPrice            //鏇存柊HRelTaxPrice瀛楁锛屽叾鍊兼潵鑷彉閲廐RelTaxPrice
                             , HlineTotalBB: HlineTotalBB              //鏇存柊HlineTotalBB瀛楁锛屽叾鍊兼潵鑷彉閲廐lineTotalBB
+                            , HMoneyBB: HMoneyBB
+                        });
+                        table.render(option);
+                        break;
+                    case "HMoney":                                         //閲戦
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref1.test(temp)) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HMoney: oldText
+                            });
+                            table.render(option);
+                            layer.msg("閲戦鎴栨暟閲忚杈撳叆澶т簬0鐨勬暟瀛�!");
+                            return;
+                        } else if (temp * 1 == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HMoney: oldText
+                            });
+                            table.render(option);
+                            layer.msg("閲戦鎴栨暟閲忚杈撳叆澶т簬0鐨勬暟瀛�!");
+                            return;
+                        }
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HMoney = value * 1;                     //閲戦=鏁伴噺*鍗曚环
+                        var HPrice = HMoney / HQty;
+                        var HTaxRate = obj.data.HTaxRate * 0.01;           //绋庣巼 
+                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HDiscountRate = obj.data.HDiscountRate * 1;   //鎶樻墸鐜�
+                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
+                        var HExRate = $("#HExRate").val();                      //姹囩巼
+                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HMoneyBB = HMoney * HExRate;
+                        //鏁板瓧绮惧害
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
+                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
+                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HMoney: HMoney
+                            , HTaxMoney: HTaxMoney
+                            , HlineTotal: HlineTotal
+                            , HTaxPrice, HTaxPrice
+                            , HRelTaxPrice: HRelTaxPrice
+                            , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
                         table.render(option);
                         break;
@@ -1510,16 +2165,21 @@
                                 , "HExplanation": data.鎽樿
                                 , "HInnerBillNo": data.鍐呴儴鍗曟嵁鍙�
 
+                                , "HProjectID": data.HProjectID == null ? 0 : data.HProjectID
+                                , "HProjectName": data.椤圭洰鍚嶇О
+                                , "HProjectNumber": data.椤圭洰浠g爜
+                                , "HInvoiceBillNo": data.鍙戠エ缂栧彿
+
                                 , "HMaker": data.鍒跺崟浜�
-                                , "HMakeDate": data.鍒跺崟鏃ユ湡 == null ? "" : Format(new Date(data.鍒跺崟鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
+                                , "HMakeDate": data.鍒跺崟鏃ユ湡 == null ? "" : Format(new Date(data.鍒跺崟鏃ユ湡), "yyyy-MM-dd hh:mm:ss")
                                 , "HUpDater": data.淇敼浜�
-                                , "HUpDateDate": data.淇敼鏃ユ湡 == null ? "" : Format(new Date(data.淇敼鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
+                                , "HUpDateDate": data.淇敼鏃ユ湡 == null ? "" : Format(new Date(data.淇敼鏃ユ湡), "yyyy-MM-dd hh:mm:ss")
                                 , "HChecker": data.瀹℃牳浜�
-                                , "HCheckDate": data.瀹℃牳鏃ユ湡 == null ? "" : Format(new Date(data.瀹℃牳鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
+                                , "HCheckDate": data.瀹℃牳鏃ユ湡 == null ? "" : Format(new Date(data.瀹℃牳鏃ユ湡), "yyyy-MM-dd hh:mm:ss")
                                 , "HCloseMan": data.鍏抽棴浜�
-                                , "HCloseDate": data.鍏抽棴鏃ユ湡 == null ? "" : Format(new Date(data.鍏抽棴鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
+                                , "HCloseDate": data.鍏抽棴鏃ユ湡 == null ? "" : Format(new Date(data.鍏抽棴鏃ユ湡), "yyyy-MM-dd hh:mm:ss")
                                 , "HDeleteMan": data.浣滃簾浜�
-                                , "HDeleteDate": data.浣滃簾鏃ユ湡 == null ? "" : Format(new Date(data.浣滃簾鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
+                                , "HDeleteDate": data.浣滃簾鏃ユ湡 == null ? "" : Format(new Date(data.浣滃簾鏃ユ湡), "yyyy-MM-dd hh:mm:ss")
                             });
 
                             if (data.HMainSourceBillType != "") {
@@ -1645,6 +2305,9 @@
                         , "HSSName": dataArray[0].缁撶畻鏂瑰紡
                         , "HPSStyleID": dataArray[0].HPSStyleID
                         , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                        , "HProjectID": dataArray[0].HProjectID
+                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
                     });
 
                     //瀛愯〃  璧嬪��
@@ -1724,6 +2387,10 @@
                         , "HExRate": dataArray[0].姹囩巼
                         , "HPSStyleID": dataArray[0].HPSStyleID
                         , "HPSStyleSName": dataArray[0].閲囪喘鏂瑰紡
+                        , "HProjectID": dataArray[0].HProjectID
+                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                        , "HInvoiceBillNo": dataArray[0].鍙戠エ缂栧彿
                     });
 
                     //瀛愯〃  璧嬪��
@@ -1788,7 +2455,6 @@
                     $("#HUpDateDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));
                 }
                 var sMainStr = JSON.stringify(data.field);
-
                 //鑾峰彇瀛愯〃鏁版嵁
                 var num = [];
                 for (var i = 0; i < table.cache["mainTable"].length; i++) {
@@ -1832,6 +2498,11 @@
                     success: function (data) {
                         if (data.count == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
                             layer.msg(data.Message, { icon: 1 });
+                            if (data.Verify == "Y") //鑷姩瀹℃牳
+                            {
+                                $("#HInterID").val(data.HInterID);//鑾峰彇鎻愪氦鎴愬姛杩斿洖鐨勫崟鎹富ID
+                                set_CheckBill(0); //瀹℃牳
+                            }
                             $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);
                             //淇濆瓨鍚庢祻瑙�
                             //ReRoadBillMain();
@@ -1853,6 +2524,7 @@
             function AllowLoadData(data) {
                 //鏁板�兼牸寮忔牎楠屽伐鍏�
                 var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
+                var ref1 = /^-?\d+(\.\d+)?$/;          //鍒ゆ柇瀛楃涓叉槸鍚︿负鏁板瓧(鍖呭惈鏁存暟銆佹诞鐐规暟)锛屾鍒欒〃杈惧紡
                 var temp = "";
 
                 //#region 琛ㄥご鏁版嵁妫�楠�
@@ -1865,22 +2537,22 @@
                     layer.msg("鏃ユ湡涓嶈兘涓虹┖!");
                     return false;
                 }
-                if ($("#HCurID").val() == 0) {
-                    layer.msg("璇烽�夋嫨甯佸埆锛�");
-                    return;
-                }
-                if ($("#HExRate").val() == 0) {
-                    layer.msg("璇疯緭鍏ユ眹鐜囷紒");
-                    return;
-                }
+                //if ($("#HCurID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨甯佸埆锛�");
+                //    return;
+                //}
+                //if ($("#HExRate").val() == 0) {
+                //    layer.msg("璇疯緭鍏ユ眹鐜囷紒");
+                //    return;
+                //}
                 //if ($("#HEmpID").val() == 0) {
                 //    layer.msg("璇烽�夋嫨涓氬姟鍛樺憳锛�");
                 //    return;
                 //}
-                if ($("#HDeptID").val() == 0) {
-                    layer.msg("璇烽�夋嫨閲囪喘閮ㄩ棬锛�");
-                    return;
-                }
+                //if ($("#HDeptID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨閲囪喘閮ㄩ棬锛�");
+                //    return;
+                //}
                 if ($("#HSupID").val() == 0) {
                     layer.msg("璇烽�夋嫨渚涘簲鍟嗭紒");
                     return;
@@ -1894,14 +2566,14 @@
                 //    return;
                 //}
 
-                temp = $("#HExRate").val() + "";
-                if (temp == 0) {
-                    layer.msg("姹囩巼涓嶈兘涓�0!");
-                    return false;
-                } else if (!ref.test(temp)) {
-                    layer.msg("姹囩巼璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
-                    return false;
-                }
+                //temp = $("#HExRate").val() + "";
+                //if (temp == 0) {
+                //    layer.msg("姹囩巼涓嶈兘涓�0!");
+                //    return false;
+                //} else if (!ref.test(temp)) {
+                //    layer.msg("姹囩巼璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
+                //    return false;
+                //}
                 //#endregion
 
                 //#region 瀛愯〃 鏁版嵁妫�楠�
@@ -1919,13 +2591,13 @@
                         return false;
                     }
 
-                    //瀹炲彂鏁伴噺鏍煎紡鏍¢獙
+                    //鏁伴噺鏍煎紡鏍¢獙
                     temp = option.data[i]["HQty"] + "";
-                    if (temp == "0") {
-                        layer.msg("绗�" + (i + 1) + "琛岋細瀹炴敹鏁伴噺涓嶈兘涓�0锛�");
+                    if (!ref1.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛楋紒");
                         return false;
-                    } else if (!ref.test(temp)) {
-                        layer.msg("绗�" + (i + 1) + "琛岋細瀹炴敹鏁伴噺璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                    } else if (temp * 1 == 0) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛楋紒");
                         return false;
                     }
 
@@ -1956,26 +2628,26 @@
                         return false;
                     }
 
-                    //閲戦鏍煎紡鏍¢獙
-                    temp = option.data[i]["HMoney"] + "";
-                    if (temp == "0") {
-                        layer.msg("绗�" + (i + 1) + "琛岋細閲戦涓嶈兘涓�0锛�");
-                        return false;
-                    } else if (!ref.test(temp)) {
-                        layer.msg("绗�" + (i + 1) + "琛岋細閲戦璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
-                        return false;
-                    }
-
-                    //浠风◣鍚堣鏍煎紡鏍¢獙
-                    temp = option.data[i]["HTaxMoney"] + "";
+                    ////閲戦鏍煎紡鏍¢獙
+                    //temp = option.data[i]["HMoney"] + "";
                     //if (temp == "0") {
-                    //    layer.msg("绗�" + (i + 1) + "琛岋細浠风◣鍚堣涓嶈兘涓�0锛�");
+                    //    layer.msg("绗�" + (i + 1) + "琛岋細閲戦涓嶈兘涓�0锛�");
                     //    return false;
-                    //} else 
-                    if (!ref.test(temp)) {
-                        layer.msg("绗�" + (i + 1) + "琛岋細绋庨璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
-                        return false;
-                    }
+                    //} else if (!ref.test(temp)) {
+                    //    layer.msg("绗�" + (i + 1) + "琛岋細閲戦璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                    //    return false;
+                    //}
+
+                    ////浠风◣鍚堣鏍煎紡鏍¢獙
+                    //temp = option.data[i]["HTaxMoney"] + "";
+                    ////if (temp == "0") {
+                    ////    layer.msg("绗�" + (i + 1) + "琛岋細浠风◣鍚堣涓嶈兘涓�0锛�");
+                    ////    return false;
+                    ////} else 
+                    //if (!ref.test(temp)) {
+                    //    layer.msg("绗�" + (i + 1) + "琛岋細绋庨璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                    //    return false;
+                    //}
                 }
                 //#endregion
                 return true;
@@ -2227,15 +2899,16 @@
                 if (obj.event === 'del') {
                     layer.confirm('鐪熺殑鍒犻櫎琛屽悧锛�', function (index) {
                         console.log("绱㈠紩涓�:" + rowIndex);
-                        if (rowIndex === '0') {
+                        if (rowIndex === '0' && table.cache["mainTable"].length == 1) {
                             layer.msg('棣栬鏃犳硶鍒犻櫎锛侊紒锛�');
                         } else if (haveSource == true) {
                             layer.msg('鏈夋簮鍗曟棤娉曞垹闄わ紒锛侊紒');
                         }
                         else {
-                            obj.del();
+                            obj.del();//鍋囧垹闄�
+                            table.cache["mainTable"].splice(rowIndex, 1);  //鈶″交搴曠Щ闄ゅ厓绱狅紝浠庣紦瀛橀噷绉婚櫎杩欎竴琛�
                             option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
-                            table.reload(option);
+                            table.render(option);
                             layer.close(index);
                         }
                     });
@@ -2579,11 +3252,23 @@
                     , "HSSName": dataArray[0].缁撶畻鏂瑰紡
                     , "HPSStyleID": dataArray[0].HPSStyleID
                     , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                    , "HProjectID": dataArray[0].HProjectID
+                    , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                    , "HProjectNumber": dataArray[0].椤圭洰浠g爜
                 });
 
                 //瀛愯〃Entry  璧嬪��
                 var rowdataEntry = [];
                 for (var i = 0; i < dataArray.length; i++) {
+                    var HQty = dataArray[i].鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺;                           //鏁伴噺
+                    var HPrice = dataArray[i].鍗曚环;               //鍗曚环
+                    var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                    var HTaxRate = dataArray[i].绋庣巼 * 0.01;           //绋庣巼
+                    var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                    var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                    var HExRate = $("#HExRate").val();                      //姹囩巼
+                    var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                    var HMoneyBB = HMoney * HExRate;
                     rowdataEntry.push(
                         {
                             "HMaterID": dataArray[i].HMaterID
@@ -2592,17 +3277,17 @@
                             , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
                             , "HUnitID": dataArray[i].HUnitID
                             , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
-                            , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺, 1)
+                            , "HQty": dealDoubleToFixed(HQty, 1)
                             , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
                             , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , 'HDiscountRate': "0"                                                     //
-                            , 'HRelTaxPrice': "0"
+                            , 'HDiscountRate': "1"                                                     //
+                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
                             , "HTaxRate": dataArray[i].绋庣巼
-                            , 'HTaxMoney': "0"                                                         //
-                            , "HMoney": dealDoubleToFixed(dataArray[i].閲戦, 2)
-                            , 'HMoneyBB': dealDoubleToFixed(dataArray[i].閲戦 * dataArray[0].姹囩巼, 2)
-                            , 'HlineTotal': dealDoubleToFixed(dataArray[i].浠风◣鍚堣, 2)
-                            , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].浠风◣鍚堣 * dataArray[0].姹囩巼, 2)
+                            , 'HTaxMoney': HTaxMoney                                                         //
+                            , "HMoney": dealDoubleToFixed(HMoney, 2)
+                            , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
+                            , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
+                            , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
                             , "HRemark": ""
 
                             , "HSourceInterID": dataArray[i].hmainid
@@ -2623,7 +3308,7 @@
                         }
                     );
                 }
-                optionEntry.data = rowdataEntry;
+                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                 table.render(optionEntry);
                 //瀛愯〃姹囨��
                 for (var i = 0; i < rowdataEntry.length; i++) {
@@ -2632,11 +3317,13 @@
                     for (var j = i + 1; j < rowdataEntry.length; j++) {
                         if (rowdataEntry[j].HMaterID == item.HMaterID) {
                             rowdataEntry[i].HQty += rowdataEntry[j].HQty;//鏁伴噺
-                            rowdataEntry[i].HMoney = rowdataEntry[i].HQty * rowdataEntry[i].HPrice//閲戦=鏁伴噺*鍗曚环
+                            rowdataEntry[i].HMoney += rowdataEntry[j].HMoney;//閲戦
+                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//鍗曚环
                             rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//绋庨
                             rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //浠风◣鍚堣
                             var HExRate = $("#HExRate").val();
                             rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //鏈綅甯佷环绋庡悎璁�
+                            rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //鏈綅甯侀噾棰�
                             rowdataEntry.splice(j, 1);
                             j = j - 1;
                         }
@@ -2671,6 +3358,12 @@
                         return;
                     }
                 }
+                if (dataArray[0].婧愬崟绫诲瀷 == "1102") {
+                    getPushSource_POOrderBillCur(dataArray[0].婧愬崟涓诲唴鐮�, dataArray[0].婧愬崟瀛愬唴鐮�);
+                } else {
+                    getPushSource_POInStockBillCur(dataArray[0].婧愬崟涓诲唴鐮�, dataArray[0].婧愬崟瀛愬唴鐮�);
+                }
+                
 
                 form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
                     "HMainSourceInterID": "0"
@@ -2693,11 +3386,24 @@
                     , "HSSName": ""
                     , "HPSStyleID": dataArray[0].HPSStyleID
                     , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                    , "HProjectID": dataArray[0].HProjectID
+                    , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                    , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                    , "HInvoiceBillNo": dataArray[0].鍙戠エ缂栧彿
                 });
 
                 //瀛愯〃Entry  璧嬪��
                 var rowdataEntry = [];
                 for (var i = 0; i < dataArray.length; i++) {
+                    var HQty = dataArray[i].瀹炴敹鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺;                           //鏁伴噺
+                    var HPrice = dataArray[i].鍗曚环;               //鍗曚环
+                    var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                    var HTaxRate = dataArray[i].绋庣巼 * 0.01;           //绋庣巼
+                    var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                    var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                    var HExRate = $("#HExRate").val();                      //姹囩巼
+                    var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                    var HMoneyBB = HMoney * HExRate;
                     rowdataEntry.push(
                         {
                             "HMaterID": dataArray[i].HMaterID
@@ -2706,14 +3412,17 @@
                             , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
                             , "HUnitID": dataArray[i].HUnitID
                             , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
-                            , "HQty": dealDoubleToFixed(dataArray[i].瀹炴敹鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺, 1)
+                            , "HQty": dealDoubleToFixed(HQty, 1)
                             , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
                             , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , 'HDiscountRate': "0"                                                     //
-                            , 'HRelTaxPrice': "0"
+                            , 'HDiscountRate': "1"                                                     //
+                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
                             , "HTaxRate": dataArray[i].绋庣巼
-                            , 'HTaxMoney': "0"                                                         //
-                            , "HMoney": dataArray[i].閲戦
+                            , 'HTaxMoney': HTaxMoney                                                         //
+                            , "HMoney": dealDoubleToFixed(HMoney, 2)
+                            , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
+                            , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
+                            , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
                             , "HRemark": ""
 
                             , "HSourceInterID": dataArray[i].hmainid
@@ -2734,7 +3443,7 @@
                         }
                     );
                 }
-                optionEntry.data = rowdataEntry;
+                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                 table.render(optionEntry);
                 //瀛愯〃姹囨��
                 for (var i = 0; i < rowdataEntry.length; i++) {
@@ -2742,11 +3451,13 @@
                     for (var j = i + 1; j < rowdataEntry.length; j++) {
                         if (rowdataEntry[j].HMaterID == item.HMaterID) {
                             rowdataEntry[i].HQty += rowdataEntry[j].HQty;
-                            rowdataEntry[i].HMoney = rowdataEntry[i].HQty * rowdataEntry[i].HPrice//閲戦=鏁伴噺*鍗曚环
+                            rowdataEntry[i].HMoney += rowdataEntry[j].HMoney;//閲戦
+                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//鍗曚环
                             rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//绋庨
                             rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //浠风◣鍚堣
                             var HExRate = $("#HExRate").val();
                             rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //鏈綅甯佷环绋庡悎璁�
+                            rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //鏈綅甯侀噾棰�
                             rowdataEntry.splice(j, 1);
                             j = j - 1;
                         }
@@ -2867,7 +3578,69 @@
             }
             //#endregion
 
-            
+            //#region 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栨簮鍗曢噰璐鍗曞竵鍒眹鐜�
+            function getPushSource_POOrderBillCur(HSourceInterID, HSourceEntryID) {
+                var res = "none";
+                $.ajax({
+                    url: GetWEBURL() + "/Cg_POOrderBill/loadCg_POOrderBill_Push",
+                    async: false,
+                    type: "GET",
+                    data: {
+                        "HInterID": HSourceInterID
+                        , "HSubID": HSourceEntryID
+                    },
+                    success: function (result) {
+                        if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                            res = result.data[0];
+                            form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
+                                "HCurID": res.HCurID
+                                , "HCurName": res.甯佸埆
+                                , "HExRate": res.姹囩巼
+                            });
+                        } else {
+                            res = result.data;
+                            //layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                        }
+                    }, error: function () {
+                        res = "none";
+                        layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                    }
+                });
+                return res;
+            }
+            //#endregion
+
+            //#region 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栨簮鍗曟敹鏂欓�氱煡鍗曞竵鍒眹鐜�
+            function getPushSource_POInStockBillCur(HSourceInterID, HSourceEntryID) {
+                var res = "none";
+                $.ajax({
+                    url: GetWEBURL() + "/Cg_POInStockBill/loadCg_POInStockBill_Push",
+                    async: false,
+                    type: "GET",
+                    data: {
+                        "HInterID": HSourceInterID
+                        , "HSubID": HSourceEntryID
+                    },
+                    success: function (result) {
+                        if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                            res = result.data[0];
+                            form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
+                                "HCurID": res.HCurID
+                                , "HCurName": res.甯佸埆
+                                , "HExRate": res.姹囩巼
+                            });
+                        } else {
+                            res = result.data;
+                            //layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                        }
+                    }, error: function () {
+                        res = "none";
+                        layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                    }
+                });
+                return res;
+            }
+            //#endregion
 
             //#endregion
 

--
Gitblit v1.9.1