From 07cf94734c36d4eae6ddbc4dd338bf5af81a2193 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期一, 28 十月 2024 16:11:39 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-LayUI

---
 WebTM/views/采购管理/应付单/Cg_PayableBill.html | 1569 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 1,275 insertions(+), 294 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 5c6541a..b5bf9ff 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"
@@ -54,7 +54,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 +83,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 +94,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; ">
                                                 <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,90 +102,77 @@
                                         </div>
                                     </div>
                                     <div class="layui-row">
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">閲囪喘閮ㄩ棬</label>
+                                        <div class="layui-inline" >
+                                            <label class="layui-form-label">渚涘簲鍟�<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
+                                                <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>-->
+                                            </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="HDeptName" id="HDeptName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px; " readonly>
                                                 <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="hdeptlist" style="width:40px;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>-->
+                                                </button>
                                             </div>
                                         </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label">涓氬姟鍛�</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HEmpName" id="HEmpName"  class="layui-input" value="" style="background-color:#efefef4d;" readonly>
+                                                <input type="text" name="HEmpName" id="HEmpName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" readonly>
                                                 <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>-->
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">涓荤</label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HMangerName" id="HMangerName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
-                                                <input type="hidden" name="HMangerID" id="HMangerID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
-                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>-->
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">渚涘簲鍟�<label 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;" 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>-->
-                                            </div>
-                                        </div>
-                                    </div>
-                                    <div class="layui-row">
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">甯佸埆</label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="background-color:#efefef4d;" 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>
+                                                </button>
                                             </div>
                                         </div>
                                         <div class="layui-inline">
                                             <label class="layui-form-label">閲囪喘鏂瑰紡</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HPSStyleName" id="HPSStyleName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
+                                                <input type="text" name="HPSStyleName" id="HPSStyleName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" readonly>
                                                 <input type="hidden" name="HPSStyleID" id="HPSStyleID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="hsellslist" style="width:40px;">
-                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                </button>-->
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label">缁撶畻鏂瑰紡<label style="color:red"> * </label></label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
-                                                <input type="hidden" name="HSSID" id="HSSID" class="layui-input" value="0" style="float:left;width:150px;">
-                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HSSList" style="width:40px;">
-                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                </button>-->
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HPSStyleList" 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-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="HMangerName" id="HMangerName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" readonly>
+                                                <input type="hidden" name="HMangerID" id="HMangerID" class="layui-input" value="0" style="float:left;width:150px;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
+                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+                                                </button>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline" 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>
+                                            <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 +181,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 +206,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>
                             <!--鍒跺崟淇℃伅-->
@@ -305,20 +337,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="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>
@@ -330,6 +380,8 @@
     <script>
         //#region 鎶樺彔娉ㄩ噴
         //#endregion
+        //鏄惁鏈夋簮鍗�
+        var haveSource = false;
         layui.config({
             base: '../../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
         }).extend({
@@ -350,10 +402,11 @@
             //璁板綍缁勭粐鐨勫��
             var HOrgIDBar = 0;
 
+
             //瀛愯〃娓叉煋鍙傛暟
             var option = {};
+            var optionEntry = {};
             //#endregion
-
 
             //#region 杩涘叆椤甸潰鍗冲姞杞�
 
@@ -498,9 +551,9 @@
                 }
                 //#endregion
 
-                //if (AllowLoadData(data)) {
+                if (AllowLoadData(data)) {
                     set_SaveBill(data);
-                //}
+                }
             });
             //#endregion
             //#endregion
@@ -554,6 +607,250 @@
             });
             //#endregion
 
+            //#region 鍥炶溅閫夋嫨婧愬崟
+            $('#HMainSourceBillNo').on('keydown', function (event) {
+                var HSourceBillNo = $('#HMainSourceBillNo').val();//锛堟簮鍗曞崟鎹彿锛�
+                if (event.keyCode == 13) {
+                    var ajaxLoad = layer.load();
+                    var url;
+                    //鍒ゆ柇鏂囨湰妗嗘槸鍚︽湁鏁版嵁    new
+                    if (HSourceBillNo == "") {
+                        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 = 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[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 = 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[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 澶嶉�夋鐘舵�佸彉鏇�
@@ -575,7 +872,7 @@
                     , "HQty": "0"
                     , "HPrice": "0"
                     , "HTaxPrice": "0"
-                    , 'HDiscountRate': "0"
+                    , 'HDiscountRate': "1"
                     , 'HRelTaxPrice': "0"
                     , "HTaxRate": "0"
                     , 'HTaxMoney': "0"
@@ -618,6 +915,12 @@
                     //涓嬬Щ
                     case 'btn-Under': btn_under();
                         break;
+                    //搴撳瓨鏌ヨ
+                    case 'get_Inventory': get_Inventory();
+                        break;
+                    //鍑哄叆搴撹褰曟煡璇�
+                    case 'get_InOutSum': get_InOutSum();
+                        break;
                     //鍒楄缃�
                     case 'set_HideColumn':
                         get_HideColumn();
@@ -633,19 +936,6 @@
             });
             //#endregion
 
-            //#region 鐩戝惉鍗曞厓鏍肩紪杈�  鍗曞厓鏍肩紪杈戝悗 鍙樻洿
-            table.on('edit(mainTable)', function (obj) {
-                //鏁板�兼牸寮忔牎楠屽伐鍏�
-                var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
-                var temp = "";
-
-                // 鍗曞厓鏍肩紪杈戜箣鍓嶇殑鍊�
-                var oldText = $(this).prev().text();
-                var value = obj.value //寰楀埌淇敼鍚庣殑鍊�
-                    , data = obj.data //寰楀埌鎵�鍦ㄨ鎵�鏈夐敭鍊�
-                    , field = obj.field; //寰楀埌瀛楁
-            });
-            //#endregion
             //#endregion
 
             //#endregion
@@ -759,44 +1049,83 @@
                     }
                 });
             }
-            ////#endregion
+            //#endregion
 
             //#region 寮圭獥閫夋嫨鏂规硶
             //#region 閫夋嫨閲囪喘閮ㄩ棬
             function get_checkDept() {
+                var HOrgName = $('select[name="HOrgID"] option:selected').text();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '閲囪喘閮ㄩ棬鍒楄〃'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_DepartmentList.html', 'yes']
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_DepartmentList.html?Type=2&HOrgName=' + HOrgName, 'yes']
+                    , btn: ['纭畾', '鍙栨秷']
+                    , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
+                        var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//鑾峰彇table鐨別lem:"#test"
+                        if (checkStatus.data.length === 0) {
+                            return layer.msg('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HDeptName").val(checkStatus.data[0].閮ㄩ棬鍚嶇О);
+                        $("#HDeptID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
             //#endregion
 
             //#region 閫夋嫨閲囪喘涓荤
             function get_checkManager() {
+                var HOrgID = $("#HOrgID").val();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '閲囪喘涓荤鍒楄〃'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_EmployeeList.html?Type=HManager', 'yes']
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_EmployeeList.html?Type=HManager&HOrgID=' + HOrgID, 'yes']
+                    , btn: ['纭畾', '鍙栨秷']
+                    , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
+                        var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//鑾峰彇table鐨別lem:"#test"
+                        if (checkStatus.data.length === 0) {
+                            return layer.msg('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HMangerName").val(checkStatus.data[0].鑱屽憳鍚嶇О);
+                        $("#HMangerID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
             //#endregion
 
             //#region 閫夋嫨涓氬姟鍛�
             function get_checkEmp() {
+                var HOrgID = $("#HOrgID").val();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '涓氬姟鍛樺垪琛�'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_EmployeeList.html?Type=HEmp', 'yes']
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_EmployeeList.html?Type=HEmp&HOrgID=' + HOrgID, 'yes']
+                    , btn: ['纭畾', '鍙栨秷']
+                    , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
+                        var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//鑾峰彇table鐨別lem:"#test"
+                        if (checkStatus.data.length === 0) {
+                            return layer.msg('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HEmpName").val(checkStatus.data[0].鑱屽憳鍚嶇О);
+                        $("#HEmpID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
             //#endregion
@@ -816,26 +1145,14 @@
 
             //#region 閫夋嫨閲囪喘鏂瑰紡
             function get_checkSellS() {
+                var HOrgName = $('select[name="HOrgID"] option:selected').text();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '閲囪喘鏂瑰紡鍒楄〃'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_PoStockStyle.html', 'yes']
-                })
-            }
-            //#endregion
-
-            //#region 缁撶畻鏂瑰紡閫夋嫨椤甸潰
-            function get_checkSS() {
-                layer.open({
-                    type: 2//寮圭獥绫诲瀷
-                    , skin: 'layui-layer-rim' //鍔犱笂杈规
-                    , area: ['90%', '90%']//澶у皬
-                    , title: '缁撶畻鏂瑰紡鍒楄〃'//鏍囬
-                    , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_SettleStyle.html', 'yes']
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_PoStockStyle.html?Type=2&HOrgName=' + HOrgName, 'yes']
                     , btn: ['纭畾', '鍙栨秷']
                     , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
                         var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
@@ -843,7 +1160,34 @@
                         if (checkStatus.data.length === 0) {
                             return layer.msg('璇烽�夋嫨鏁版嵁');
                         }
-                        $("#HSSName").val(checkStatus.data[0].HName);
+                    
+                        $("#HPSStyleName").val(checkStatus.data[0].閲囪喘鏂瑰紡鍚嶇О);
+                        $("#HPSStyleID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
+                })
+            }
+            //#endregion
+
+            //#region 缁撶畻鏂瑰紡閫夋嫨椤甸潰
+            function get_checkSS() {
+                var HOrgName = $('select[name="HOrgID"] option:selected').text();
+                layer.open({
+                    type: 2//寮圭獥绫诲瀷
+                    , skin: 'layui-layer-rim' //鍔犱笂杈规
+                    , area: ['90%', '90%']//澶у皬
+                    , title: '缁撶畻鏂瑰紡鍒楄〃'//鏍囬
+                    , shift: 2//寮瑰嚭鍔ㄧ敾
+                    , content: ['../../鍩虹璧勬枡/鍩虹璧勬枡/Gy_SettleStyle.html?Type=2&HOrgName=' + HOrgName, 'yes']
+                    , btn: ['纭畾', '鍙栨秷']
+                    , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
+                        var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//鑾峰彇table鐨別lem:"#test"
+                        if (checkStatus.data.length === 0) {
+                            return layer.msg('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HSSName").val(checkStatus.data[0].缁撶畻鏂瑰紡鍚嶇О);
                         $("#HSSID").val(checkStatus.data[0].HItemID);
                         layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
                     }
@@ -860,7 +1204,7 @@
                     , area: ['90%', '90%']//澶у皬
                     , title: '閲囪喘甯佸埆鍒楄〃'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Currency.html', 'yes']
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Currency.html?Type=2', 'yes']
                     , btn: ['纭畾', '鍙栨秷']
                     , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
                         var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
@@ -934,7 +1278,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);
                         }
@@ -962,7 +1316,7 @@
                     , loading: false
                     , cols: [[ //瀛愯〃
                         { type: 'checkbox', totalRowText: '鍚堣琛�' }
-                        , { type: 'numbers', title: '搴忓彿', width: 100 }
+                        , { type: 'numbers', field: '搴忓彿', 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;' }
@@ -970,6 +1324,141 @@
                         , { 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: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, edit: 'text', event: "HTaxPrice" }
+                        , { field: 'HDiscountRate', title: '鎶樻墸鐜�', width: 100, edit: 'text' }
+                        , { field: 'HRelTaxPrice', title: '瀹為檯鍚◣鍗曚环', width: 100, style: 'background-color:#efefef4d;' }
+                        , { 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 }
+                    ]]
+                }
+                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爜": ""
+                    , "鐗╂枡鍚嶇О": ""
+                    , "瑙勬牸鍨嬪彿": ""
+                    , "HUnitID": "0"
+                    , "璁¢噺鍗曚綅": ""
+                    , "HQty": "0"
+                    , "HPrice": "0"
+                    , "HTaxPrice": "0"
+                    , 'HDiscountRate': "1"
+                    , 'HRelTaxPrice': "0"
+                    , "HTaxRate": "0"
+                    , 'HTaxMoney': "0"
+                    , "HMoney": "0"
+                    , 'HMoneyBB': "0"
+                    , 'HlineTotal': "0"
+                    , 'HlineTotalBB': "0"
+                    , "HRemark": ""
+
+                    , "HSourceInterID": "0"
+                    , "HSourceEntryID": "0"
+                    , "HSourceBillNo": ""
+                    , "HSourceBillType": ""
+                    , "HRelationQty": "0"
+                    , "HRelationMoney": "0"
+
+                    , 'HPOOrderInterID': "0"
+                    , 'HPOOrderEntryID': "0"
+                    , 'HPOOrderBillNo': ""
+
+                    , 'HSeOrderTaxPrice': "0"
+                    , "HSeOrderInterID": "0"
+                    , "HSeOrderEntryID": "0"
+                    , "HSeOrderBillNo": ""
+                }];
+
+                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" }
@@ -1000,46 +1489,6 @@
                         , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 70 }
                     ]]
                 }
-
-                var rowdata = [{
-                    "HMaterID": "0"
-                    , "鐗╂枡浠g爜": ""
-                    , "鐗╂枡鍚嶇О": ""
-                    , "瑙勬牸鍨嬪彿": ""
-                    , "HUnitID": "0"
-                    , "璁¢噺鍗曚綅": ""
-                    , "HQty": "0"
-                    , "HPrice": "0"
-                    , "HTaxPrice": "0"
-                    , 'HDiscountRate': "0"
-                    , 'HRelTaxPrice': "0"
-                    , "HTaxRate": "0"
-                    , 'HTaxMoney': "0"
-                    , "HMoney": "0"
-                    , 'HMoneyBB': "0"
-                    , 'HlineTotal': "0"
-                    , 'HlineTotalBB': "0"
-                    , "HRemark": ""
-
-                    , "HSourceInterID": "0"
-                    , "HSourceEntryID": "0"
-                    , "HSourceBillNo": ""
-                    , "HSourceBillType": ""
-                    , "HRelationQty": "0"
-                    , "HRelationMoney": "0"
-
-                    , 'HPOOrderInterID': "0"
-                    , 'HPOOrderEntryID': "0"
-                    , 'HPOOrderBillNo': ""
-
-                    , 'HSeOrderTaxPrice': "0"
-                    , "HSeOrderInterID": "0"
-                    , "HSeOrderEntryID": "0"
-                    , "HSeOrderBillNo": ""
-                }];
-
-                option.data = rowdata;
-                table.render(option);
             }
             //#endregion
 
@@ -1049,7 +1498,10 @@
                 //鏁板�兼牸寮忔牎楠屽伐鍏�
                 var ref = /^\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"];  //閲戦绮惧害
                 // 鍗曞厓鏍肩紪杈戜箣鍓嶇殑鍊�
                 var oldText = $(this).prev().text();
                 var value = obj.value //寰楀埌淇敼鍚庣殑鍊�
@@ -1078,11 +1530,19 @@
                         var HPrice = obj.data.HPrice * 1;               //鍗曚环
                         var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
                         var HTaxRate = obj.data.HTaxRate * 0.01;           //绋庣巼 
-                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
+                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
                         var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
                         var HExRate = $("#HExRate").val();                      //姹囩巼
-                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+                        var HMoneyBB = HMoney * HExRate;
 
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
+                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
@@ -1091,7 +1551,9 @@
                             , HTaxMoney: HTaxMoney
                             , HlineTotal: HlineTotal
                             , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
+                        table.render(option);
                         break;
                     case "HPrice":                                         //鍗曚环
                         //鏁版嵁鏍煎紡鏍¢獙
@@ -1101,7 +1563,7 @@
                             obj.update({
                                 HPrice: oldText
                             });
-
+                            table.render(option);
                             layer.msg("鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
                             return;
                         }
@@ -1118,7 +1580,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(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
@@ -1129,7 +1601,9 @@
                             , HTaxPrice, HTaxPrice
                             , HRelTaxPrice: HRelTaxPrice
                             , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
+                        table.render(option);
                         break;
                     case "HTaxRate":                                                       //鏁伴噺
                         //鏁版嵁鏍煎紡鏍¢獙
@@ -1139,7 +1613,7 @@
                             obj.update({
                                 HTaxRate: oldText
                             });
-
+                            table.render(option);
                             layer.msg("绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛�!");
                             return;
                         }
@@ -1158,7 +1632,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(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
@@ -1171,7 +1655,9 @@
                             , HTaxPrice, HTaxPrice
                             , HRelTaxPrice: HRelTaxPrice
                             , HlineTotalBB: HlineTotalBB
+                            , HMoneyBB: HMoneyBB
                         });
+                        table.render(option);
                         break;
                     case "HDiscountRate":                                                       //鏁伴噺
                         //鏁版嵁鏍煎紡鏍¢獙
@@ -1181,7 +1667,7 @@
                             obj.update({
                                 HDiscountRate: oldText
                             });
-
+                            table.render(option);
                             layer.msg("鎶樻墸鐜囪杈撳叆涓嶅皬浜�0鐨勬暟瀛�!");
                             return;
                         }
@@ -1192,12 +1678,18 @@
                         var HQty = obj.data.HQty * 1;                   //鏁伴噺
                         var HPrice = obj.data.HPrice * 1;
                         var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
-                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
-                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
                         var HDiscountRate = obj.data.HDiscountRate * 1;     //鎶樻墸鐜�
-                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
+                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
 
-
+                        //鏁板瓧绮惧害
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
+                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HTaxRate: HTaxRate * 100
@@ -1209,8 +1701,59 @@
                             , HDiscountRate: HDiscountRate
                             , HRelTaxPrice: HRelTaxPrice
                         });
-                        break;
                         table.render(option);
+                        break;
+                    case "HTaxPrice":                                         //鍗曚环
+                        //鏁版嵁鏍煎紡鏍¢獙  
+                        temp = value + "";     //淇敼鍚庣殑鍊� 杞负瀛楃涓� 璧嬪�肩粰  鍙橀噺temp
+                        // ref寰堝彲鑳芥槸涓�涓鍒欒〃杈惧紡瀵硅薄锛岀敤浜庡尮閰嶇壒瀹氱殑瀛楃涓叉ā寮忋�俽ef.test(temp)浼氭鏌ュ彉閲弔emp锛堝嵆杞崲鍚庣殑鍗曚环瀛楃涓诧級鏄惁绗﹀悎ref瀹氫箟鐨勬ā寮忋�傚鏋渢est鏂规硶杩斿洖false
+                        if (!ref.test(temp)) { //妫�鏌ュ崟浠峰瓧绗︿覆鏄惁绗﹀悎棰勬湡鐨勬牸寮�                        
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({            //鏇存柊琛ㄦ牸鏌愪竴琛屾暟鎹�
+                                HTaxPrice: oldText     //灏唄price瀛楁鎭㈠鍒颁繚瀛樺墠鐨勫��
+                            });
+                            table.render(option);
+                            layer.msg("鍚◣鍗曚环璇疯緭鍏ユ暟瀛�!");   //璇疯緭鍏ュ崟浠风殑鏁板��
+                            return;
+                        }
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HTaxPrice = value * 1;                    //鍚◣鍗曚环
+                        var HTaxRate = obj.data.HTaxRate * 0.01;           //绋庣巼 
+                        var HPrice = Number((HTaxPrice / (1 + HTaxRate)).toFixed(4));                         //鍗曚环 = 鍚◣鍗曚环/(1+绋庣巼)
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                        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));
+                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+                        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
+                            , HPrice: HPrice                         //鏇存柊HPrice瀛楁锛孒Price
+                            , HMoney: HMoney                      //鏇存柊HMoney瀛楁锛孒Money
+                            , HTaxMoney: HTaxMoney                  //鏇存柊HTaxMoney瀛楁锛孒TaxMoney
+                            , HlineTotal: HlineTotal             //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                            , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                            , HRelTaxPrice: HRelTaxPrice            //鏇存柊HRelTaxPrice瀛楁锛屽叾鍊兼潵鑷彉閲廐RelTaxPrice
+                            , HlineTotalBB: HlineTotalBB              //鏇存柊HlineTotalBB瀛楁锛屽叾鍊兼潵鑷彉閲廐lineTotalBB
+                            , HMoneyBB: HMoneyBB
+                        });
+                        table.render(option);
+                        break;
                     default:
                 }
             });
@@ -1263,6 +1806,11 @@
                                 , "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")
                                 , "HUpDater": data.淇敼浜�
@@ -1274,6 +1822,10 @@
                                 , "HDeleteMan": data.浣滃簾浜�
                                 , "HDeleteDate": data.浣滃簾鏃ユ湡 == null ? "" : Format(new Date(data.浣滃簾鏃ユ湡), "yyyy-MM-dd HH:mm:ss")
                             });
+
+                            if (data.HMainSourceBillType != "") {
+                                haveSource = true;
+                            }
 
                             HOrgIDBar = 0;
 
@@ -1321,6 +1873,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);
@@ -1387,6 +1946,9 @@
                         , "HSSName": dataArray[0].缁撶畻鏂瑰紡
                         , "HPSStyleID": dataArray[0].HPSStyleID
                         , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                        , "HProjectID": dataArray[0].HProjectID
+                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
                     });
 
                     //瀛愯〃  璧嬪��
@@ -1404,7 +1966,7 @@
                                 , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
                                 , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
                                 , 'HDiscountRate': dataArray[i].鎶樻墸鐜�                                                       //
-                                , 'HRelTaxPrice': dataArray[i].瀹為檯鍚◣鍗曚环     
+                                , 'HRelTaxPrice': dataArray[i].瀹為檯鍚◣鍗曚环 
                                 , "HTaxRate": dataArray[i].绋庣巼
                                 , 'HTaxMoney': dataArray[i].绋庨                                                             //
                                 , "HMoney": dealDoubleToFixed(dataArray[i].閲戦, 2)
@@ -1466,6 +2028,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].鍙戠エ缂栧彿
                     });
 
                     //瀛愯〃  璧嬪��
@@ -1481,7 +2047,7 @@
                                 , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
                                 , "HQty": dealDoubleToFixed(dataArray[i].瀹炴敹鏁伴噺, 1)
                                 , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
-                                , "HTaxPrice": dataArray[i].鍚◣鍗曚环
+                                , "HTaxPrice": dataArray[i].鍚◣鍗曚环 
                                 , 'HDiscountRate': dataArray[i].鎶樻墸鐜�                                               //
                                 , 'HRelTaxPrice': "0"
                                 , "HTaxRate": dataArray[i].绋庣巼
@@ -1540,7 +2106,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) {
@@ -1550,7 +2129,7 @@
                     refSav = "Update";
                 }
 
-                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ';' + sessionStorage["HUserName"];
+                var sMainSub = sMainStr + ';' + sSubStr + ';' + sSubStr2 + ';'+ refSav + ';' + sessionStorage["HUserName"];
 
                 $.ajax({
                     type: "POST",
@@ -1561,6 +2140,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();
@@ -1594,28 +2178,50 @@
                     layer.msg("鏃ユ湡涓嶈兘涓虹┖!");
                     return false;
                 }
-                if ($("#HSupID").val() == "0") {
-                    layer.msg("渚涘簲鍟嗘湭閫夋嫨!");
-                    return false;
+                //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 ($("#HSupID").val() == 0) {
+                    layer.msg("璇烽�夋嫨渚涘簲鍟嗭紒");
+                    return;
                 }
+                //if ($("#HPSStyleID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨閲囪喘鏂瑰紡锛�");
+                //    return;
+                //}
+                //if ($("#HSSID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨缁撶畻鏂瑰紡锛�");
+                //    return;
+                //}
 
-                if ($("#HCurID").val() == "0") {
-                    layer.msg("甯佸埆鏈�夋嫨!");
-                    return false;
-                }
-
-                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 瀛愯〃 鏁版嵁妫�楠�
                 for (var i = 0; i < option.data.length; i++) {
+                    if (typeof option.data[i] !== 'object' || option.data[i] === null || Array.isArray(option.data[i])) {
+                        continue; // 璺宠繃闈炲璞¢」锛堝绌烘暟缁勶級  
+                    }
                     if (option.data[i]["HMaterID"] == "0") {
                         layer.msg("绗�" + (i+1) + "琛岋細鐗╂枡鏈�夋嫨锛�");
                         return false;
@@ -1675,17 +2281,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鐨勬暟瀛楋紒");
-                        return false;
-                    }
-
-                    //鍙戣揣浠撳簱闈炵┖楠岃瘉
-                    if (option.data[i]["HWHID"] == "0") {
-                        layer.msg("绗�" + (i + 1) + "琛岋細鍙戣揣浠撳簱鏈�夋嫨锛�");
+                    //if (temp == "0") {
+                    //    layer.msg("绗�" + (i + 1) + "琛岋細浠风◣鍚堣涓嶈兘涓�0锛�");
+                    //    return false;
+                    //} else 
+                    if (!ref.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細绋庨璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
                         return false;
                     }
                 }
@@ -1700,7 +2301,7 @@
                     if (event.key == "F7") {
                         //鐗╂枡
                         if (obj.event == "HMaterID") {
-                                var HOrgID = $("#HOrgID").val();
+                            var HOrgID = $("#HOrgID").val();  //鑾峰彇id="HOrgID"鐨勫厓绱犱腑鑾峰彇鍏跺�硷紝骞跺皢璇ュ�煎瓨鍌ㄥ湪鍙橀噺HOrgID涓�
                             layer.open({
                                 type: 2
                                 , skin: "layui-layer-rim" //鍔犱笂杈规
@@ -1720,31 +2321,81 @@
                                         return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
                                     }
                                     OptionData = checkStatus.data[0];
-                                    //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
-                                    obj.update({
-                                        "HMaterID": checkStatus.data[0].HItemID
-                                        , "鐗╂枡浠g爜": checkStatus.data[0].HNumber
-                                        , "鐗╂枡鍚嶇О": checkStatus.data[0].HName
-                                        , "瑙勬牸鍨嬪彿": checkStatus.data[0].HModel
-                                        , "HUnitID": checkStatus.data[0].HUnitID
-                                        , "璁¢噺鍗曚綅": checkStatus.data[0].HUnitName
-                                    })
                                     layer.close(index);//鍏抽棴寮圭獥
                                 }
-                               , end: function () {
-                                obj.update({
-                                   "HMaterID" :OptionData.HMaterID
-                                        ,"鐗╂枡浠g爜" : OptionData.鐗╂枡浠g爜
-                                       , "鐗╂枡鍚嶇О" :OptionData.鐗╂枡鍚嶇О
-                                        ,"瑙勬牸鍨嬪彿" : OptionData.瑙勬牸鍨嬪彿
-                                        ,"HUnitID" :OptionData.HUnitID
-                                        ,"璁¢噺鍗曚綅" : OptionData.璁¢噺鍗曚綅鍚嶇О
-                                })
-                            }
+                                , end: function () {
+                                    //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                                    var HSupID = $("#HSupID").val();
+                                    if (HSupID != 0 && typeof (OptionData.HItemID) != "undefined") {
+                                        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"];  //閲戦绮惧害
+                                        $.ajax({
+                                            url: GetWEBURL() + "/Gy_Supplier/xg",
+                                            //url: "http://localhost:12761/Gy_Supplier/xg",
+                                            type: "GET",
+                                            data: {
+                                                "HInterID": HSupID
+                                            },
+                                            success: function (d) {
+                                                var HTaxRate = parseInt(d.data[0].澧炲�肩◣鐜�) * 0.01;
+                                                var HExRate = $("#HExRate").val();                      //姹囩巼
+                                                //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                                                var HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                                var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                                var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                                var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                                var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                                var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                                                var HDiscountRate = obj.data.HDiscountRate * 1;   //鎶樻墸鐜�
+                                                var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
+                                                var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+
+                                                //鏁板瓧绮惧害
+                                                HQty = Number(HQty.toFixed(HQtyDec));
+                                                HPrice = Number(HPrice.toFixed(HPriceDec));
+                                                HMoney = Number(HMoney.toFixed(HMoneyDec));
+                                                HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                                                HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+                                                HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                                                HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
+                                                HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
+                                                obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                                    "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                                    , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                                    , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                                    , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                                    , "HUnitID": OptionData.HUnitID
+                                                    , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                                    , "HTaxRate": HTaxRate * 100
+                                                    , HQty: HQty                               //鏇存柊HQty瀛楁锛孒Qty
+                                                    , HPrice: HPrice                         //鏇存柊HPrice瀛楁锛孒Price
+                                                    , HMoney: HMoney                      //鏇存柊HMoney瀛楁锛孒Money
+                                                    , HTaxMoney: HTaxMoney                  //鏇存柊HTaxMoney瀛楁锛孒TaxMoney
+                                                    , HlineTotal: HlineTotal             //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                                    , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                                                    , HRelTaxPrice: HRelTaxPrice            //鏇存柊HRelTaxPrice瀛楁锛屽叾鍊兼潵鑷彉閲廐RelTaxPrice
+                                                    , HlineTotalBB: HlineTotalBB              //鏇存柊HlineTotalBB瀛楁锛屽叾鍊兼潵鑷彉閲廐lineTotalBB
+                                                })
+                                            }
+                                        });
+                                    } else if (typeof (OptionData.HItemID) != "undefined") {
+                                        obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                            "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                            , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                            , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                            , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                            , "HUnitID": OptionData.HUnitID
+                                            , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                        })
+                                    }
+                                }
                             })
                         }
                         //璁¢噺鍗曚綅
                         if (obj.event == "HUnitID") {
+                            var HOrgName = $('select[name="HOrgID"] option:selected').text();
                             layer.open({
                                 type: 2
                                 , skin: "layui-layer-rim" //鍔犱笂杈规
@@ -1753,37 +2404,132 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Unit.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Unit.html?Type=2&HOrgName=' + HOrgName, 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
-                                //鎸夐挳涓�  鐨勫洖璋�
-                                var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
-                                var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
+                                    //鎸夐挳涓�  鐨勫洖璋�
+                                    var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
+                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
 
-                                if (checkStatus.data.length != 1) {
-                                    return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                                    if (checkStatus.data.length != 1) {
+                                        return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                                    }
+                                    OptionData = checkStatus.data[0];
+                                    //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
+                                    obj.update({
+                                        "HUnitID": checkStatus.data[0].HItemID
+                                        , "璁¢噺鍗曚綅": checkStatus.data[0].璁¢噺鍗曚綅鍚嶇О
+                                    })
+                                    layer.close(index);//鍏抽棴寮圭獥
                                 }
-                                OptionData = checkStatus.data[0];
-                                //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
-                                obj.update({
-                                    "HUnitID": checkStatus.data[0].HItemID
-                                    , "璁¢噺鍗曚綅": checkStatus.data[0].璁¢噺鍗曚綅鍚嶇О
-                                })
-                                layer.close(index);//鍏抽棴寮圭獥
-                            }
-                            , end: function () {
-                                obj.update({
-                                    "HUnitID": OptionData.HItemID
-                                    , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
-                                })
-                            }
+                                , end: function () {
+                                    obj.update({
+                                        "HUnitID": OptionData.HItemID
+                                        , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                    })
+                                }
                         })
                     }
                     obj.event = "";
                     return false;
                 }
 
-            })
+                })
+
+                //鍙屽嚮
+                $('.layui-table-box tbody td[data-field="鐗╂枡浠g爜"]').off('dblclick').on('dblclick', function () {
+                    var HOrgID = $("#HOrgID").val();  //鑾峰彇id="HOrgID"鐨勫厓绱犱腑鑾峰彇鍏跺�硷紝骞跺皢璇ュ�煎瓨鍌ㄥ湪鍙橀噺HOrgID涓�
+                    layer.open({
+                        type: 2
+                        , skin: "layui-layer-rim" //鍔犱笂杈规
+                        , title: "鐗╂枡鍒楄〃"  //鏍囬
+                        , closeBtn: 1  //绐椾綋鍙充笂瑙掑叧闂� 鐨� 鏍峰紡
+                        , shift: 2 //寮瑰嚭鍔ㄧ敾
+                        , area: ["90%", "90%"] //绐椾綋澶у皬
+                        , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
+                        , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Material.html?openType=2&HOrgID=' + HOrgID, 'yes']
+                        , btn: ["纭畾", "鍙栨秷"]
+                        , btn1: function (index, laero) {
+                            //鎸夐挳涓�  鐨勫洖璋�
+                            var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
+                            var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
+
+                            if (checkStatus.data.length != 1) {
+                                return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                            }
+                            OptionData = checkStatus.data[0];
+                            layer.close(index);//鍏抽棴寮圭獥
+                        }
+                        , end: function () {
+                            //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                            var HSupID = $("#HSupID").val();
+                            if (HSupID != 0 && typeof (OptionData.HItemID) != "undefined") {
+                                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"];  //閲戦绮惧害
+                                $.ajax({
+                                    url: GetWEBURL() + "/Gy_Supplier/xg",
+                                    //url: "http://localhost:12761/Gy_Supplier/xg",
+                                    type: "GET",
+                                    data: {
+                                        "HInterID": HSupID
+                                    },
+                                    success: function (d) {
+                                        var HTaxRate = parseInt(d.data[0].澧炲�肩◣鐜�) * 0.01;
+                                        var HExRate = $("#HExRate").val();                      //姹囩巼
+                                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                                        var HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                                        var HDiscountRate = obj.data.HDiscountRate * 1;   //鎶樻墸鐜�
+                                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�
+                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //鏈綅甯佷环绋庡悎璁�=(绋庨+閲戦)*姹囩巼
+
+                                        //鏁板瓧绮惧害
+                                        HQty = Number(HQty.toFixed(HQtyDec));
+                                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
+                                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+                                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
+                                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
+                                        obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                            "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                            , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                            , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                            , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                            , "HUnitID": OptionData.HUnitID
+                                            , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                            , "HTaxRate": HTaxRate * 100
+                                            , HQty: HQty                               //鏇存柊HQty瀛楁锛孒Qty
+                                            , HPrice: HPrice                         //鏇存柊HPrice瀛楁锛孒Price
+                                            , HMoney: HMoney                      //鏇存柊HMoney瀛楁锛孒Money
+                                            , HTaxMoney: HTaxMoney                  //鏇存柊HTaxMoney瀛楁锛孒TaxMoney
+                                            , HlineTotal: HlineTotal             //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                            , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                                            , HRelTaxPrice: HRelTaxPrice            //鏇存柊HRelTaxPrice瀛楁锛屽叾鍊兼潵鑷彉閲廐RelTaxPrice
+                                            , HlineTotalBB: HlineTotalBB              //鏇存柊HlineTotalBB瀛楁锛屽叾鍊兼潵鑷彉閲廐lineTotalBB
+                                        })
+                                    }
+                                });
+                            } else if (typeof (OptionData.HItemID) != "undefined"){
+                                obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                    "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                    , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                    , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                    , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                    , "HUnitID": OptionData.HUnitID
+                                    , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                })
+                            }
+                        }
+                    })
+                });
         }
             //#endregion
 
@@ -1796,7 +2542,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);
@@ -1814,6 +2563,56 @@
                 table.render(option);
                 //rows++;
                 layer.msg('澧炲姞涓�琛屾寜閽紒')
+            }
+            //#endregion
+
+            //#region 搴撳瓨鏌ヨ
+            function get_Inventory() {
+                var checkStatus = table.checkStatus('mainTable')
+                    , data = checkStatus.data;
+                if (checkStatus.data.length === 1 && data[0].HMaterID != 0) {
+                    var HMaterID = data[0].HMaterID.toString();
+                    //寮圭獥鏂规硶
+                    layer.open({
+                        type: 2//寮圭獥绫诲瀷
+                        , skin: 'layui-layer-rim' //鍔犱笂杈规
+                        , area: ['90%', '90%']//澶у皬
+                        , title: '搴撳瓨鏌ヨ鍒楄〃'//鏍囬
+                        , shift: 2//寮瑰嚭鍔ㄧ敾
+                        , content: ['../../浠撳瓨绠$悊/鏉$爜鎶ヨ〃/Kf_ICinventoryQueryReport.html?Type=1&HMaterID=' + HMaterID, 'yes']
+                        , btn: ['鍙栨秷']
+                        , btn1: function (index, layero) {
+                            layer.close(index);
+                        }
+                    })
+                }
+                else {
+                    layer.msg('璇烽�夋嫨涓�琛屾湁鐗╂枡鏁版嵁鏌ヨ锛�');
+                }
+            }
+            //#endregion
+            //#region 鍑哄叆搴撹褰曟煡璇�
+            function get_InOutSum() {
+                var checkStatus = table.checkStatus('mainTable')
+                    , data = checkStatus.data;
+                if (checkStatus.data.length === 1 && data[0].HMaterID != 0) {
+                    var HMaterID = data[0].HMaterID.toString();
+                    layer.open({
+                        type: 2//寮圭獥绫诲瀷
+                        , skin: 'layui-layer-rim' //鍔犱笂杈规
+                        , area: ['90%', '90%']//澶у皬
+                        , title: '鍑哄叆搴撹褰曞垪琛�'//鏍囬
+                        , shift: 2//寮瑰嚭鍔ㄧ敾
+                        , content: ['../../浠撳瓨绠$悊/鏉$爜鎶ヨ〃/Kf_StockInOutSumQueryReport.html?Type=1&HMaterID=' + HMaterID, 'yes']
+                        , btn: ['鍙栨秷']
+                        , btn1: function (index, layero) {
+                            layer.close(index);
+                        }
+                    })
+                }
+                else {
+                    layer.msg('璇烽�夋嫨涓�琛屾湁鐗╂枡鏁版嵁鏌ヨ锛�');
+                }
             }
             //#endregion
 
@@ -1926,7 +2725,11 @@
                 var colName = "";
                 var contentUrl = "";
                 for (var i = 1; i < option.cols[0].length - 1; i++) {
-                    colName += option.cols[0][i]["title"] + ",";
+                    colName += option.cols[0][i]["field"] + ",";
+                }
+                var colTitleName = "";
+                for (var i = 1; i < option.cols[0].length - 1; i++) {
+                    colTitleName += option.cols[0][i]["title"] + ",";
                 }
                 var urlStr = window.document.location.pathname;//鑾峰彇鏂囦欢璺緞
                 var urlLen = urlStr.split('/');
@@ -1935,7 +2738,7 @@
                 }
                 colName = encodeURI(colName.substring(0, colName.length - 1));//瀵� URI 杩涜缂栫爜
 
-                contentUrl += '鍩虹璧勬枡/闅愯棌鍒楄缃�/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
+                contentUrl += '鍩虹璧勬枡/闅愯棌鍒楄缃�/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName + '&colTitleName = ' + colTitleName;
 
                 layer.open({
                     type: 2
@@ -2008,6 +2811,10 @@
                                     case "R":
                                         option.cols[0][i + 1]["align"] = "right";
                                         break;
+                                }
+                                //璁剧疆琛ㄦ牸title灞炴�ф樉绀哄埆鍚�
+                                if (dataCols[4] != null && dataCols[4] != "") {
+                                    option.cols[0][i + 1]["title"] = dataCols[4];
                                 }
                             }
 
@@ -2085,30 +2892,42 @@
                     , "HSSName": dataArray[0].缁撶畻鏂瑰紡
                     , "HPSStyleID": dataArray[0].HPSStyleID
                     , "HPSStyleName": dataArray[0].閲囪喘鏂瑰紡
+                    , "HProjectID": dataArray[0].HProjectID
+                    , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                    , "HProjectNumber": dataArray[0].椤圭洰浠g爜
                 });
 
-                //瀛愯〃  璧嬪��
-                var rowdata = [];
+                //瀛愯〃Entry  璧嬪��
+                var rowdataEntry = [];
                 for (var i = 0; i < dataArray.length; i++) {
-                    rowdata.push(
+                    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
+                            "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(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
@@ -2129,7 +2948,29 @@
                         }
                     );
                 }
-                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[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);
             }
             //#endregion
@@ -2156,6 +2997,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"
@@ -2171,19 +3018,32 @@
                     , "HEmpName": dataArray[0].涓氬姟鍛�
                     , "HSupID": dataArray[0].HSupID
                     , "HSupName": dataArray[0].渚涘簲鍟�
-                    , "HCurID": dataArray[0].HCurID
-                    , "HCurName": dataArray[0].甯佸埆
-                    , "HExRate": 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].鍙戠エ缂栧彿
                 });
 
-                //瀛愯〃  璧嬪��
-                var rowdata = [];
+                //瀛愯〃Entry  璧嬪��
+                var rowdataEntry = [];
                 for (var i = 0; i < dataArray.length; i++) {
-                    rowdata.push(
+                    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爜
@@ -2191,13 +3051,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)
-                            , 'HDiscountRate': "0"                                                     //
-                            , 'HRelTaxPrice': "0"
+                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                            , '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
@@ -2211,15 +3075,37 @@
                             , '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[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);
+                
             }
             //#endregion
 
@@ -2277,6 +3163,32 @@
             }
             //#endregion
 
+            //#region 鏍规嵁鐗╂枡ID鑾峰彇绮惧害
+            function getDecByMaterID(HMaterID) {
+                var resultData = {};
+                $.ajax({  // 寮傛璇锋眰
+                    url: GetWEBURL() + "Gy_Material/getDecByID",  //璇锋眰鍦板潃
+                    async: false,   //鏄惁寮�鍚紓姝�
+                    type: "GET",   //璇锋眰绫诲瀷
+                    data: {   //瀹氫箟鍙戦�佸埌鏈嶅姟鍣ㄧ殑鏁版嵁
+                        "HMaterID": HMaterID     //  灏唄materid浣滀负璇锋眰鍙傛暟鍙戦��
+                    },
+                    success: function (result) {   // 褰撹姹傛垚鍔熸椂锛屾墽琛岃繖涓嚱鏁�
+                        if (result.code == 1) { // 濡傛灉鏈嶅姟鍣ㄨ繑鍥炵殑鏁版嵁涓殑`code瀛楁绛変簬1锛岃繖鍙兘琛ㄧず瀹℃牳鎿嶄綔鎴愬姛鎵ц
+                            var data = result.data; //澹版槑data鍙橀噺锛屽苟灏嗗叾璧嬪�间负result瀵硅薄涓殑data灞炴��
+                            resultData = data[0];   //灏哾ata鏁扮粍锛堟垨绫绘暟缁勫璞★級鐨勭涓�涓厓绱犺祴鍊肩粰鍙橀噺resultData
+                        }
+                        //else {
+                        //    layer.alert(result.Message, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' }); //result.msg瀵硅薄锛屾彁绀哄脊绐� 绫诲瀷涓�5锛� 鎸夐挳锛屽拰鎸夐挳鐨勫悕绉颁负閫�鍑�  鏃堕棿 涓�100绉掞紝浠ュ強鍋忕Щ閲忥紙`offset: 't'
+                        //}
+                    }, error: function () {
+                        layer.alert("鍙戠敓閿欒!", { icon: 5 });  //鎻愮ず寮圭獥 鍙戠敓閿欒 锛岃绀烘爣蹇椾负5鐨�
+                    }
+                });
+                return resultData;
+            }
+            //#endregion
+
             //#region 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栨簮鍗曢噰璐叆搴撳崟鏁版嵁
             function getPushSource_POStockInBillInit(HSourceInterID, HSourceEntryID) {
                 var res = "none";
@@ -2303,15 +3215,84 @@
                 return res;
             }
             //#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
 
 
             //浠ヤ笂鏄痩ayui妯″潡
         });
+        //鍙屽嚮杩斿洖璐у竵
+        function GetGyCur(data) {
+            OptionData = data
+        }
         // 鍩虹璧勬枡杩斿洖鏁版嵁
         function GetHEmpValue(obj)  //杩斿洖涓氬姟鍛�
         {
-            $("#HEmpName").val(obj[0].HName);
+            $("#HEmpName").val(obj[0].鑱屽憳鍚嶇О);
             $("#HEmpID").val(obj[0].HItemID);
         }
 
@@ -2323,25 +3304,25 @@
 
         function GetHManagerValue(obj)  //杩斿洖涓荤
         {
-            $("#HMangerName").val(obj[0].HName);
+            $("#HMangerName").val(obj[0].鑱屽憳鍚嶇О);
             $("#HMangerID").val(obj[0].HItemID);
         }
 
         function GetHDeptNameValue(obj)  //杩斿洖閮ㄩ棬
         {
-            $("#HDeptName").val(obj[0].HName);
+            $("#HDeptName").val(obj[0].閮ㄩ棬鍚嶇О);
             $("#HDeptID").val(obj[0].HItemID);
         }
 
-        function GetHPSStyleValue(obj)  //杩斿洖閲囪喘鏂瑰紡
+        function GetHPSStyleNameValue(obj)  //杩斿洖閲囪喘鏂瑰紡
         {
-            $("#HSellSName").val(obj[0].HName);
-            $("#HSellSID").val(obj[0].HItemID);
+            $("#HPSStyleName").val(obj[0].閲囪喘鏂瑰紡鍚嶇О);
+            $("#HPSStyleID").val(obj[0].HItemID);
         }
 
         function GetSettleStyleValue(obj)           //杩斿洖缁撶畻鏂瑰紡
         {
-            $("#HSSName").val(obj[0].HName);
+            $("#HSSName").val(obj[0].缁撶畻鏂瑰紡鍚嶇О);
             $("#HSSID").val(obj[0].HItemID);
         }
 
@@ -2383,8 +3364,8 @@
 
 
         //鍙屽嚮杩斿洖璁¢噺鍗曚綅
-         function GetGyUnit(data) {
-             OptionData = data
+        function GetUnitValue(data) {
+             OptionData = data[0]
          }
 
             //鍙屽嚮杩斿洖鐗╂枡

--
Gitblit v1.9.1