From f8f2f5063d943d1c8d20575724e33059a087777b Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期二, 30 七月 2024 13:42:53 +0800
Subject: [PATCH] 应付单应收单添加新明细表体

---
 WebTM/views/销售管理/应收单/Xs_ReceivableBill.html |  484 +++++++++++++++++++++++++++++-------
 WebTM/views/采购管理/应付单/Cg_PayableBill.html    |  276 +++++++++++++++++---
 2 files changed, 612 insertions(+), 148 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 fd93baf..709beb7 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"
@@ -81,9 +81,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">
@@ -100,14 +100,14 @@
                                         </div>
                                     </div>
                                     <div class="layui-row">
-                                        <div class="layui-inline"style="width:625px">
+                                        <div class="layui-inline" style="width:625px">
                                             <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;">
                                                 <!--<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">
@@ -305,22 +305,38 @@
                         </div>
                     </div>
 
-                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
-                    <script type="text/html" id="toolbarDemo">
-                        <div class="layui-btn-container">
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>澧炲姞涓�琛�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>鎻掑叆涓�琛�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>澶嶅埗涓�琛�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>涓婄Щ</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>涓嬬Щ</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>搴撳瓨鏌ヨ</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>鍑哄叆搴撹褰曟煡璇�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
+                    <div class="layui-tab" lay-filter="tab-POStockInBill">
+                        <ul class="layui-tab-title" lay-filter="tab-all">
+                            <li style="padding:1px;" class="layui-this">姹囨�昏〃鏍�</li>
+                            <li style="padding:1px;">鏄庣粏琛ㄦ牸</li>
+                        </ul>
+                        <div class="layui-tab-content">
+                            <div class="layui-tab-item layui-show">
+                                <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
+                                <script type="text/html" id="toolbarDemo">
+                                    <div class="layui-btn-container">
+                                        {{# if(haveSource == false){ }}
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>澧炲姞涓�琛�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>鎻掑叆涓�琛�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>澶嶅埗涓�琛�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>涓婄Щ</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>涓嬬Щ</button>
+                                        {{# } }}
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>搴撳瓨鏌ヨ</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>鍑哄叆搴撹褰曟煡璇�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
+                                    </div>
+                                </script>
+                                <script type="text/html" id="xuhao">
+                                    {{d.LAY_TABLE_INDEX+1}}
+                                </script>
+                            </div>
+                            <div class="layui-tab-item">
+                                <table class="layui-hide" id="mainTableEntry" lay-filter="mainTableEntry"></table>
+                            </div>
                         </div>
-                    </script>
-                    <script type="text/html" id="xuhao">
-                        {{d.LAY_TABLE_INDEX+1}}
-                    </script>
+                    </div>
+
                 </form>
             </div>
         </div>
@@ -332,6 +348,8 @@
     <script>
         //#region 鎶樺彔娉ㄩ噴
         //#endregion
+        //鏄惁鏈夋簮鍗�
+        var haveSource = false;
         layui.config({
             base: '../../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
         }).extend({
@@ -352,10 +370,11 @@
             //璁板綍缁勭粐鐨勫��
             var HOrgIDBar = 0;
 
+
             //瀛愯〃娓叉煋鍙傛暟
             var option = {};
+            var optionEntry = {};
             //#endregion
-
 
             //#region 杩涘叆椤甸潰鍗冲姞杞�
 
@@ -1057,7 +1076,51 @@
                         , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 70 }
                     ]]
                 }
+                optionEntry = {
+                    elem: '#mainTableEntry'
+                    , 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, style: 'background-color:#efefef4d;'}
+                        , { field: '鐗╂枡鍚嶇О', title: '鐗╂枡鍚嶇О', width: 150, style: 'background-color:#efefef4d;' }
+                        , { field: '瑙勬牸鍨嬪彿', title: '瑙勬牸鍨嬪彿', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
+                        , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100, style: 'background-color:#efefef4d;'}
+                        , { field: 'HQty', title: '鏁伴噺', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
+                        , { field: 'HPrice', title: '鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
+                        , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HDiscountRate', title: '鎶樻墸鐜�', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HRelTaxPrice', title: '瀹為檯鍚◣鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HTaxRate', title: '绋庣巼', width: 100, style: 'background-color:#efefef4d;' }
+                        , { 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, style: 'background-color:#efefef4d;' }
 
+                        , { 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;' }
+                    ]]
+                }
                 var rowdata = [{
                     "HMaterID": "0"
                     , "鐗╂枡浠g爜": ""
@@ -1096,7 +1159,58 @@
                 }];
 
                 option.data = rowdata;
+
                 table.render(option);
+                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 }
+                    ]]
+                }
             }
             //#endregion
 
@@ -1332,6 +1446,10 @@
                                 , "HDeleteDate": data.浣滃簾鏃ユ湡 == null ? "" : Format(new Date(data.浣滃簾鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
                             });
 
+                            if (data.HMainSourceBillType != "") {
+                                haveSource = true;
+                            }
+
                             HOrgIDBar = 0;
 
                             //瀛愯〃  璧嬪��
@@ -1378,6 +1496,13 @@
                             }
                             option.data = rowdata;
                             table.render(option);
+
+                            //瀛愯〃  璧嬪��
+                            var rowdata = result.list[0];
+                            optionEntry.data = rowdata;
+                            table.render(optionEntry);
+
+                            
                             layer.close(ajaxLoad);
                         } else {
                             layer.close(ajaxLoad);
@@ -1597,7 +1722,20 @@
                     }
                 }
                 var sSubStr = JSON.stringify(num);
-
+                var sSubStr2;
+                if (haveSource == true) {
+                    //鑾峰彇瀛愯〃2鏁版嵁
+                    var num = [];
+                    for (var i = 0; i < table.cache["mainTableEntry"].length; i++) {
+                        if (table.cache["mainTableEntry"][i] != "") {
+                            table.cache["mainTableEntry"][i].LAY_TABLE_INDEX = i;
+                            num.push(table.cache["mainTableEntry"][i])
+                        }
+                    }
+                    sSubStr2 = JSON.stringify(num);
+                } else {
+                    sSubStr2 = JSON.stringify([]);
+                }
                 //鑾峰彇鎿嶄綔鏂瑰紡
                 var refSav = "";
                 if (OperationType == 1 || OperationType == 2 || OperationType == 4) {
@@ -1607,7 +1745,7 @@
                     refSav = "Update";
                 }
 
-                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ';' + sessionStorage["HUserName"];
+                var sMainSub = sMainStr + ';' + sSubStr + ';' + sSubStr2 + ';'+ refSav + ';' + sessionStorage["HUserName"];
 
                 $.ajax({
                     type: "POST",
@@ -1754,11 +1892,12 @@
 
                     //浠风◣鍚堣鏍煎紡鏍¢獙
                     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鐨勬暟瀛楋紒");
+                    //if (temp == "0") {
+                    //    layer.msg("绗�" + (i + 1) + "琛岋細浠风◣鍚堣涓嶈兘涓�0锛�");
+                    //    return false;
+                    //} else 
+                    if (!ref.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細绋庨璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
                         return false;
                     }
                 }
@@ -1869,7 +2008,10 @@
                         console.log("绱㈠紩涓�:" + rowIndex);
                         if (rowIndex === '0') {
                             layer.msg('棣栬鏃犳硶鍒犻櫎锛侊紒锛�');
-                        } else {
+                        } else if (haveSource == true) {
+                            layer.msg('鏈夋簮鍗曟棤娉曞垹闄わ紒锛侊紒');
+                        }
+                        else {
                             obj.del();
                             option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
                             table.reload(option);
@@ -2210,24 +2352,24 @@
                     , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
                 });
 
-                //瀛愯〃  璧嬪��
-                var rowdata = [];
+                //瀛愯〃Entry  璧嬪��
+                var rowdataEntry = [];
                 for (var i = 0; i < dataArray.length; i++) {
-                    rowdata.push(
+                    rowdataEntry.push(
                         {
-                             "HMaterID": dataArray[i].HMaterID
+                            "HMaterID": dataArray[i].HMaterID
                             , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
                             , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
                             , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
                             , "HUnitID": dataArray[i].HUnitID
                             , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
-                            , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺-dataArray[i].鍏宠仈鏁伴噺, 1)
+                            , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺, 1)
                             , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
                             , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , 'HDiscountRate':"0"                                                     //
+                            , 'HDiscountRate': "0"                                                     //
                             , 'HRelTaxPrice': "0"
                             , "HTaxRate": dataArray[i].绋庣巼
-                            , 'HTaxMoney':"0"                                                         //
+                            , 'HTaxMoney': "0"                                                         //
                             , "HMoney": dealDoubleToFixed(dataArray[i].閲戦, 2)
                             , 'HMoneyBB': dealDoubleToFixed(dataArray[i].閲戦 * dataArray[0].姹囩巼, 2)
                             , 'HlineTotal': dealDoubleToFixed(dataArray[i].浠风◣鍚堣, 2)
@@ -2252,7 +2394,28 @@
                         }
                     );
                 }
-                option.data = rowdata;
+                optionEntry.data = 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[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.splice(j, 1);
+                            j = j - 1;
+                        }
+                    }
+                }
+                set_InitGridHaveSource();
+                option.data = rowdataEntry;
+                haveSource = true;
                 table.render(option);
             }
             //#endregion
@@ -2303,10 +2466,10 @@
                     , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
                 });
 
-                //瀛愯〃  璧嬪��
-                var rowdata = [];
+                //瀛愯〃Entry  璧嬪��
+                var rowdataEntry = [];
                 for (var i = 0; i < dataArray.length; i++) {
-                    rowdata.push(
+                    rowdataEntry.push(
                         {
                             "HMaterID": dataArray[i].HMaterID
                             , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
@@ -2314,14 +2477,14 @@
                             , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
                             , "HUnitID": dataArray[i].HUnitID
                             , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
-                            , "HQty": dealDoubleToFixed(dataArray[i].瀹炴敹鏁伴噺-dataArray[i].鍏宠仈鏁伴噺, 1)
+                            , "HQty": dealDoubleToFixed(dataArray[i].瀹炴敹鏁伴噺 - dataArray[i].鍏宠仈鏁伴噺, 1)
                             , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
                             , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
                             , 'HDiscountRate': "0"                                                     //
                             , 'HRelTaxPrice': "0"
                             , "HTaxRate": dataArray[i].绋庣巼
                             , 'HTaxMoney': "0"                                                         //
-                            , "HMoney":dataArray[i].閲戦
+                            , "HMoney": dataArray[i].閲戦
                             , "HRemark": ""
 
                             , "HSourceInterID": dataArray[i].hmainid
@@ -2335,15 +2498,36 @@
                             , 'HPOOrderEntryID': "0"
                             , 'HPOOrderBillNo': ""
 
-                           // , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID: "0"
+                            // , '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].婧愬崟鍗曞彿 : ""
                         }
                     );
                 }
-                option.data = rowdata;
+                optionEntry.data = 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[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.splice(j, 1);
+                            j = j - 1;
+                        }
+                    }
+                }
+                set_InitGridHaveSource();
+                option.data = rowdataEntry;
+                haveSource = true;
                 table.render(option);
+                
             }
             //#endregion
 
diff --git "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html" "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html"
index 92580d7..0711ad8 100644
--- "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html"
+++ "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\345\272\224\346\224\266\345\215\225/Xs_ReceivableBill.html"
@@ -186,6 +186,15 @@
                                                 <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>
+                                            <div class="layui-input-inline">
+                                                <select name="HPriceType" id="HPriceType" lay-filter="HPriceType" style="width: 190px; ">
+                                                    <option value="鎴愭湰浠�" selected="selected">鎴愭湰浠�</option>
+                                                    <option value="缁撶畻浠�">缁撶畻浠�</option>
+                                                </select>
+                                            </div>
+                                        </div>
                                     </div>
                                     <div class="layui-row">
                                         <div class="layui-inline">
@@ -305,22 +314,37 @@
                         </div>
                     </div>
 
-                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
-                    <script type="text/html" id="toolbarDemo">
-                        <div class="layui-btn-container">
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>澧炲姞涓�琛�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>鎻掑叆涓�琛�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>澶嶅埗涓�琛�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>涓婄Щ</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>涓嬬Щ</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>搴撳瓨鏌ヨ</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>鍑哄叆搴撹褰曟煡璇�</button>
-                            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
+                    <div class="layui-tab" lay-filter="tab-POStockInBill">
+                        <ul class="layui-tab-title" lay-filter="tab-all">
+                            <li style="padding:1px;" class="layui-this">姹囨�昏〃鏍�</li>
+                            <li style="padding:1px;">鏄庣粏琛ㄦ牸</li>
+                        </ul>
+                        <div class="layui-tab-content">
+                            <div class="layui-tab-item layui-show">
+                                <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
+                                <script type="text/html" id="toolbarDemo">
+                                    <div class="layui-btn-container">
+                                        {{# if(haveSource == false){ }}/
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>澧炲姞涓�琛�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>鎻掑叆涓�琛�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>澶嶅埗涓�琛�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>涓婄Щ</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>涓嬬Щ</button>
+                                        {{# } }}
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>搴撳瓨鏌ヨ</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>鍑哄叆搴撹褰曟煡璇�</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
+                                    </div>
+                                </script>
+                                <script type="text/html" id="xuhao">
+                                    {{d.LAY_TABLE_INDEX+1}}
+                                </script>
+                            </div>
+                            <div class="layui-tab-item">
+                                <table class="layui-hide" id="mainTableEntry" lay-filter="mainTableEntry"></table>
+                            </div>
                         </div>
-                    </script>
-                    <script type="text/html" id="xuhao">
-                        {{d.LAY_TABLE_INDEX+1}}
-                    </script>
+                    </div>
                 </form>
             </div>
         </div>
@@ -332,6 +356,8 @@
     <script>
         //#region 鎶樺彔娉ㄩ噴
         //#endregion
+        //鏄惁鏈夋簮鍗�
+        var haveSource = false;
         layui.config({
             base: '../../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
         }).extend({
@@ -385,6 +411,11 @@
             //鍒濆鍖栧瓙琛�
             set_InitGrid();
 
+            //鍒濆鍖栫粍缁�
+            Organ();
+
+            //鑾峰彇婧愬崟绫诲瀷
+            HBillType();
             //#region 鍒ゆ柇鎿嶄綔绫诲瀷骞跺垵濮嬪寲鐣岄潰
             if (OperationType == 1) {                                                   //鏃犳簮鍗曟柊澧�
                /* $("#HItemID").val(0);*/
@@ -417,11 +448,7 @@
 
             DisPlay_HideColumn();
 
-            //鍒濆鍖栫粍缁�
-            Organ();
-
-            //鑾峰彇婧愬崟绫诲瀷
-            HBillType();
+            
 
             //#endregion
 
@@ -1255,9 +1282,103 @@
                     , "HSeOrderEntryID": "0"
                     , "HSeOrderBillNo": ""
                 }];
+                optionEntry = {
+                    elem: '#mainTableEntry'
+                    , 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, style: 'background-color:#efefef4d;' }
+                        , { field: '鐗╂枡鍚嶇О', title: '鐗╂枡鍚嶇О', width: 150, style: 'background-color:#efefef4d;' }
+                        , { field: '瑙勬牸鍨嬪彿', title: '瑙勬牸鍨嬪彿', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
+                        , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HQty', title: '鏁伴噺', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
+                        , { field: 'HPrice', title: '鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
+                        , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HDiscountRate', title: '鎶樻墸鐜�', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HRelTaxPrice', title: '瀹為檯鍚◣鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { field: 'HTaxRate', title: '绋庣巼', width: 100, style: 'background-color:#efefef4d;' }
+                        , { 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, style: 'background-color:#efefef4d;' }
 
+                        , { 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;' }
+                    ]]
+                }
                 option.data = rowdata;
                 table.render(option);
+                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 }
+                    ]]
+                }
             }
             //#endregion
 
@@ -1284,7 +1405,7 @@
                                 , "HMainSourceEntryID": data.HMainSourceEntryID
                                 , "HMainSourceBillNo": data.HMainSourceBillNo
                                 , "HMainSourceBillType": data.HMainSourceBillType
-
+                                , "HPriceType": data.鍗曚环绫诲瀷
                                 , "HDeptID": data.HDeptID
                                 , "HDeptName": data.閮ㄩ棬
                                 , "HMangerID": data.HMangerID
@@ -1316,6 +1437,11 @@
                                 , "HDeleteMan": data.浣滃簾浜�
                                 , "HDeleteDate": data.浣滃簾鏃ユ湡 == null ? "" : Format(new Date(data.浣滃簾鏃ユ湡), "yyyy-MM-dd")
                             });
+
+                            if (data.HMainSourceBillType != "") {
+                                haveSource = true;
+                                $("#BillType").val(data.HMainSourceBillType);
+                            }
 
                             HOrgIDBar = sessionStorage["OrganizationID"];
 
@@ -1363,6 +1489,12 @@
                             }
                             option.data = rowdata;
                             table.render(option);
+
+                            //瀛愯〃  璧嬪��
+                            var rowdata = result.list[0];
+                            optionEntry.data = rowdata;
+                            table.render(optionEntry);
+
                             layer.close(ajaxLoad);
                         } else {
                             layer.close(ajaxLoad);
@@ -1582,6 +1714,20 @@
                     }
                 }
                 var sSubStr = JSON.stringify(num);
+                var sSubStr2;
+                if (haveSource == true) {
+                    //鑾峰彇瀛愯〃2鏁版嵁
+                    var num = [];
+                    for (var i = 0; i < table.cache["mainTableEntry"].length; i++) {
+                        if (table.cache["mainTableEntry"][i] != "") {
+                            table.cache["mainTableEntry"][i].LAY_TABLE_INDEX = i;
+                            num.push(table.cache["mainTableEntry"][i])
+                        }
+                    }
+                    sSubStr2 = JSON.stringify(num);
+                } else {
+                    sSubStr2 = JSON.stringify([]);
+                }
 
                 //鑾峰彇鎿嶄綔鏂瑰紡
                 var refSav = "";
@@ -1592,7 +1738,7 @@
                     refSav = "Update";
                 }
 
-                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ';' + sessionStorage["HUserName"];
+                var sMainSub = sMainStr + ';' + sSubStr + ';' + sSubStr2 + ';' + refSav + ';' + sessionStorage["HUserName"];
 
                 $.ajax({
                     type: "POST",
@@ -1859,7 +2005,9 @@
                         console.log("绱㈠紩涓�:" + rowIndex);
                         if (rowIndex === '0') {
                             layer.msg('棣栬鏃犳硶鍒犻櫎锛侊紒锛�');
-                        } else {
+                        } else if (haveSource == true) {
+                            layer.msg('鏈夋簮鍗曟棤娉曞垹闄わ紒锛侊紒');
+                        }else {
                             obj.del();
                             option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
                             table.reload(option);
@@ -2233,49 +2381,115 @@
                     , "HSellSName": dataArray[0].閿�鍞柟寮�
                 });
 
-                //瀛愯〃  璧嬪��
-                var rowdata = [];
-                for (var i = 0; i < dataArray.length; i++) {
-                    rowdata.push(
-                        {
-                             "HMaterID": dataArray[i].HMaterID
-                            , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
-                            , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
-                            , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
-                            , "HUnitID": dataArray[i].HUnitID
-                            , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
-                            , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
-                            , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
-                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , 'HDiscountRate':"0"                                                     //
-                            , 'HRelTaxPrice': "0"
-                            , "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)
-                            , "HRemark": ""
+                if ($("#HPriceType").val() == "鎴愭湰浠�") {
+                    //瀛愯〃鎴愭湰浠稥ntry  璧嬪��
+                    var rowdataEntry = [];
+                    for (var i = 0; i < dataArray.length; i++) {
 
-                            , "HSourceInterID": dataArray[i].hmainid
-                            , "HSourceEntryID": dataArray[i].hsubid
-                            , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
-                            , "HSourceBillType": dataArray[i].HBillType
-                            , "HRelationQty": "0"
-                            , "HRelationMoney": "0"
+                        rowdataEntry.push(
+                            {
+                                "HMaterID": dataArray[i].HMaterID
+                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                , "HUnitID": dataArray[i].HUnitID
+                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
+                                , "HPrice": dealDoubleToFixed(dataArray[i].HNoTaxCost, 3)
+                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxCost, 3)
+                                , 'HDiscountRate': "0"                                                     //
+                                , 'HRelTaxPrice': "0"
+                                , "HTaxRate": dataArray[i].绋庣巼
+                                , 'HTaxMoney': "0"                                                         //
+                                , "HMoney": dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].HNoTaxCost, 2)
+                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].HNoTaxCost, 2)
+                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].浠风◣鍚堣, 2)
+                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].浠风◣鍚堣 * dataArray[0].姹囩巼, 2)
+                                , "HRemark": ""
 
-                            , 'HPOOrderInterID': "0"
-                            , 'HPOOrderEntryID': "0"
-                            , 'HPOOrderBillNo': ""
+                                , "HSourceInterID": dataArray[i].hmainid
+                                , "HSourceEntryID": dataArray[i].hsubid
+                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HSourceBillType": dataArray[i].HBillType
+                                , "HRelationQty": "0"
+                                , "HRelationMoney": "0"
 
-                            , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , "HSeOrderInterID": dataArray[i].hmainid
-                            , "HSeOrderEntryID": dataArray[i].hsubid
-                            , "HSeOrderBillNo": dataArray[i].鍗曟嵁鍙�
-                        }
-                    );
+                                , 'HPOOrderInterID': "0"
+                                , 'HPOOrderEntryID': "0"
+                                , 'HPOOrderBillNo': ""
+
+                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
+                                , "HSeOrderInterID": dataArray[i].hmainid
+                                , "HSeOrderEntryID": dataArray[i].hsubid
+                                , "HSeOrderBillNo": dataArray[i].鍗曟嵁鍙�
+                            }
+                        );
+                    }
+                } else {
+                    //瀛愯〃Entry  璧嬪��
+                    var rowdataEntry = [];
+                    for (var i = 0; i < dataArray.length; i++) {
+                        rowdataEntry.push(
+                            {
+                                "HMaterID": dataArray[i].HMaterID
+                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                , "HUnitID": dataArray[i].HUnitID
+                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
+                                , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
+                                , 'HDiscountRate': "0"                                                     //
+                                , 'HRelTaxPrice': "0"
+                                , "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)
+                                , "HRemark": ""
+
+                                , "HSourceInterID": dataArray[i].hmainid
+                                , "HSourceEntryID": dataArray[i].hsubid
+                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HSourceBillType": dataArray[i].HBillType
+                                , "HRelationQty": "0"
+                                , "HRelationMoney": "0"
+
+                                , 'HPOOrderInterID': "0"
+                                , 'HPOOrderEntryID': "0"
+                                , 'HPOOrderBillNo': ""
+
+                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
+                                , "HSeOrderInterID": dataArray[i].hmainid
+                                , "HSeOrderEntryID": dataArray[i].hsubid
+                                , "HSeOrderBillNo": dataArray[i].鍗曟嵁鍙�
+                            }
+                        );
+                    }
                 }
-                option.data = rowdata;
+                optionEntry.data = 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[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.splice(j, 1);
+                            j = j - 1;
+                        }
+                    }
+                }
+                set_InitGridHaveSource();
+                option.data = rowdataEntry;
+                haveSource = true;
                 table.render(option);
             }
             //#endregion
@@ -2336,50 +2550,116 @@
                     , "HSellSID": dataArray[0].HSellSID
                     , "HSellSName": dataArray[0].閿�鍞柟寮�
                 });
+                if ($("#HPriceType").val() == "鎴愭湰浠�") {
+                    //瀛愯〃  璧嬪��
+                    var rowdataEntry = [];
+                    for (var i = 0; i < dataArray.length; i++) {
+                        rowdataEntry.push(
+                            {
+                                "HMaterID": dataArray[i].hmaterid
+                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                , "HUnitID": dataArray[i].hunitid
+                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
+                                , "HPrice": dealDoubleToFixed(dataArray[i].鎴愭湰鍗曚环, 3)
+                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                , 'HDiscountRate': "0"                                                     //
+                                , 'HRelTaxPrice': "0"
+                                , "HTaxRate": dataArray[i].绋庣巼
+                                , 'HTaxMoney': "0"                                                         //
+                                , "HMoney": dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鎴愭湰鍗曚环, 2)
+                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鎴愭湰鍗曚环 * dataArray[0].姹囩巼, 2)
+                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环, 2)
+                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环 * dataArray[0].姹囩巼, 2)
+                                , "HRemark": ""
 
-                //瀛愯〃  璧嬪��
-                var rowdata = [];
-                for (var i = 0; i < dataArray.length; i++) {
-                    rowdata.push(
-                        {
-                            "HMaterID": dataArray[i].hmaterid
-                            , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
-                            , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
-                            , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
-                            , "HUnitID": dataArray[i].hunitid
-                            , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
-                            , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
-                            , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
-                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
-                            , 'HDiscountRate': "0"                                                     //
-                            , 'HRelTaxPrice': "0"
-                            , "HTaxRate": dataArray[i].绋庣巼
-                            , 'HTaxMoney': "0"                                                         //
-                            , "HMoney": dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环, 2)
-                            , 'HMoneyBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环 * dataArray[0].姹囩巼, 2)
-                            , 'HlineTotal': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环, 2)
-                            , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环 * dataArray[0].姹囩巼, 2)
-                            , "HRemark": ""
+                                , "HSourceInterID": dataArray[i].hmainid
+                                , "HSourceEntryID": dataArray[i].hsubid
+                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HSourceBillType": dataArray[i].HBillType
+                                , "HRelationQty": "0"
+                                , "HRelationMoney": "0"
 
-                            , "HSourceInterID": dataArray[i].hmainid
-                            , "HSourceEntryID": dataArray[i].hsubid
-                            , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
-                            , "HSourceBillType": dataArray[i].HBillType
-                            , "HRelationQty": "0"
-                            , "HRelationMoney": "0"
+                                , 'HPOOrderInterID': "0"
+                                , 'HPOOrderEntryID': "0"
+                                , 'HPOOrderBillNo': ""
 
-                            , '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].婧愬崟鍗曞彿 : ""
-                        }
-                    );
+                                , '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].婧愬崟鍗曞彿 : ""
+                            }
+                        );
+                    }
                 }
-                option.data = rowdata;
+                else {
+                    //瀛愯〃  璧嬪��
+                    var rowdataEntry = [];
+                    for (var i = 0; i < dataArray.length; i++) {
+                        rowdataEntry.push(
+                            {
+                                "HMaterID": dataArray[i].hmaterid
+                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                , "HUnitID": dataArray[i].hunitid
+                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
+                                , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                , 'HDiscountRate': "0"                                                     //
+                                , 'HRelTaxPrice': "0"
+                                , "HTaxRate": dataArray[i].绋庣巼
+                                , 'HTaxMoney': "0"                                                         //
+                                , "HMoney": dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环, 2)
+                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环 * dataArray[0].姹囩巼, 2)
+                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环, 2)
+                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环 * dataArray[0].姹囩巼, 2)
+                                , "HRemark": ""
+
+                                , "HSourceInterID": dataArray[i].hmainid
+                                , "HSourceEntryID": dataArray[i].hsubid
+                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HSourceBillType": dataArray[i].HBillType
+                                , "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 = 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[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.splice(j, 1);
+                            j = j - 1;
+                        }
+                    }
+                }
+                set_InitGridHaveSource();
+                option.data = rowdataEntry;
+                haveSource = true;
                 table.render(option);
             }
             //#endregion

--
Gitblit v1.9.1