From 02af6ea33f505e4e06dc91785154898a801b267d Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期一, 14 四月 2025 12:21:56 +0800
Subject: [PATCH] 修复出站单  第三个自定义过滤没有数据显示,完善生产质量汇报单  复制一行不显示,修复不良原因查询在其他页面打开报错,性能散点报表 增加生产资源过滤,设备工艺参数点检表 完善 初始化点检人 id未赋值

---
 WebTM/views/验收入库/外购入库/Add_Edit_Kf_POStockInBillList.html | 2814 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 2,473 insertions(+), 341 deletions(-)

diff --git "a/WebTM/views/\351\252\214\346\224\266\345\205\245\345\272\223/\345\244\226\350\264\255\345\205\245\345\272\223/Add_Edit_Kf_POStockInBillList.html" "b/WebTM/views/\351\252\214\346\224\266\345\205\245\345\272\223/\345\244\226\350\264\255\345\205\245\345\272\223/Add_Edit_Kf_POStockInBillList.html"
index dc61b11..4b6edd9 100644
--- "a/WebTM/views/\351\252\214\346\224\266\345\205\245\345\272\223/\345\244\226\350\264\255\345\205\245\345\272\223/Add_Edit_Kf_POStockInBillList.html"
+++ "b/WebTM/views/\351\252\214\346\224\266\345\205\245\345\272\223/\345\244\226\350\264\255\345\205\245\345\272\223/Add_Edit_Kf_POStockInBillList.html"
@@ -15,6 +15,7 @@
     <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
     <script src="../../../layuiadmin/PubCustom.js"></script>
     <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
+    <script src="../../../layuiadmin/PageTitle.js"></script>
     <style type="text/css">
         /*begin 姝ゆ牱寮忕敤浜庢秷闄よ鍏冪礌涓竷灞�瀹藉害涓嶅鐨勯棶棰�*/
         .layui-form-item .layui-inline {
@@ -48,7 +49,10 @@
                 <form class="layui-form" lay-filter="component-form-group" action="">
                     <div class="layui-card-header">
                         <div class="layui-btn-group">
-                            <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_SaveBill">淇濆瓨</button>
+                            <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">淇濆瓨</button>
+                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">瀹℃牳</button>
+                            <!--<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_SelectMainBill">閫夋暣鍗�</button>-->
+                            <button type="button" id="print-btn" class="layui-btn layui-btn-normal layui-btn-radius layui-btn-disabled" lay-submit="" lay-filter="get_PrintReport" disabled>鎵撳嵃</button>
                             <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">閫�鍑�</button>
                         </div>
                     </div>
@@ -56,7 +60,8 @@
                         <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;display:none;">鍏朵粬淇℃伅</li>
+                            <li lay-id="3" style="padding:1px;">鍒跺崟淇℃伅</li>
                         </ul>
                         <div class="layui-tab-content">
                             <!--鍩烘湰淇℃伅-->
@@ -64,140 +69,189 @@
                                 <div class="layui-form-item" style="padding-top: 10px;">
                                     <div class="layui-row">
                                         <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">鍗曟嵁鍙�</label>
+                                            <label class="layui-form-label">鍗曟嵁鍙�<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
                                                 <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                 <input type="hidden" name="HInterID" id="HInterID" value="0">
                                                 <input type="hidden" name="HSTOCKORGID" id="HSTOCKORGID" lay-verify="HSTOCKORGID" value=0>
+                                                <input type="hidden" name="HBillSubType" id="HBillSubType" value="">
                                             </div>
                                         </div>
                                         <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">鏃ユ湡</label>
+                                            <label class="layui-form-label">鏃ユ湡<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input class="layui-input" name="HDate" id="HDate" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd" placeholder="yyyy-MM-dd">
+                                                <input type="date" class="layui-input" name="HDate" id="HDate" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd" placeholder="yyyy-MM-dd">
                                             </div>
                                         </div>
                                         <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">鍐呴儴鍗曟嵁鍙�</label>
+                                            <label class="layui-form-label">涓氬姟鍛�<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" autocomplete="off">
+                                                <input type="text" name="HEmpName" id="HEmpName" class="layui-input" value="" style="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;display:none;">
+                                                    <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-col-xs4 layui-inline">
-                                            <label class="layui-form-label">渚涘簲鍟�</label>
+                                            <label class="layui-form-label">閮ㄩ棬<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HSupName" id="HSupName" class="layui-input" value="" style="float:left;width:150px;">
-                                                <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;">
+                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="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;display:none;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                 </button>
                                             </div>
                                         </div>
                                         <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">涓氬姟鍛�</label>
+                                            <label class="layui-form-label">渚涘簲鍟�<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HEmpName" id="HEmpName"  class="layui-input" value="" style="float:left;width:150px;">
-                                                <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;">
+                                                <input type="text" name="HSupName" id="HSupName" class="layui-input" value="" style="float:left;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;display:none;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                 </button>
                                             </div>
                                         </div>
+                                        <div class="layui-col-xs4 layui-inline">
+                                            <label class="layui-form-label">鍙戠エ缂栧彿</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HInvoiceBillNo" id="HInvoiceBillNo" autocomplete="off">
+                                            </div>
+                                        </div>
+
+                                    </div>
+                                    <div class="layui-row">
                                         <div class="layui-col-xs4 layui-inline">
                                             <label class="layui-form-label">浠撳簱</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HWHName" id="HWHName" class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HWHName" id="HWHName" class="layui-input" value="" style="float:left;width:150px;" readonly>
                                                 <input type="hidden" name="HWHID" id="HWHID" class="layui-input" value=0 style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HWHList" 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-col-xs4 layui-inline">
-                                            <label class="layui-form-label">楠屾敹鍛�</label>
+                                            <label class="layui-form-label">楠屾敹鍛�<label style="color:red"> * </label></label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HSecManagerName" id="HSecManagerName" class="layui-input" value="" style="float:left;width:150px;">
-                                                <input type="hidden" name="HSecManagerID" id="HSecManagerID" class="layui-input" value=0 style="float:left;width:150px;">
+                                                <input type="text" name="HSecManagerName" id="HSecManagerName" class="layui-input" value="" style="float:left;width:150px;" readonly>
+                                                <input type="hidden" name="HSecManagerID" id="HSecManagerID" class="layui-input" value="0" style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HSecManagerList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                 </button>
                                             </div>
                                         </div>
-                                        <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">淇濈鍛�</label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HKeeperName" id="HKeeperName" class="layui-input" value="" style="float:left;width:150px;">
-                                                <input type="hidden" name="HKeeperID" id="HKeeperID" class="layui-input" value=0 style="float:left;width:150px;">
-                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HKeeperList" style="width:40px;">
-                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>
-                                            </div>
-                                        </div>
-                                        <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">閮ㄩ棬</label>
-                                            <div class="layui-input-inline">
-                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float:left;width:150px;">
-                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value=0 style="float:left;width:150px;">
-                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
-                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
-                                                </button>
-                                            </div>
-                                        </div>
+                                        <!--<label class="layui-form-label">閫夊崟鍙�</label>
+        <div class="layui-input-inline">
+            <input class="layui-input" name="Box2" id="Box2" autocomplete="off">
+        </div>-->
                                     </div>
-
-                                    <div class="layui-row">
-                                        <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">婧愬崟绫诲瀷</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="HSourceBillType" id="HSourceBillType" value="0">
-                                            </div>
-                                        </div>
-                                        <div class="layui-col-xs4 layui-inline">
-                                            <label class="layui-form-label">閫夊崟鍙�</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="Box2" id="Box2" autocomplete="off">
-                                            </div>
-                                        </div>
-                                        <div class="layui-col-xs4 layui-inline">
+                                    <div class="layui-row" style="display:none;">
+                                        <div class="layui-col-xs4 layui-inline" style="display:none;">
                                             <label class="layui-form-label">璐熻矗浜�</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float:left;width:150px;" readonly>
                                                 <input type="hidden" name="HManagerID" id="HManagerID" class="layui-input" value=0 style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                 </button>
                                             </div>
                                         </div>
-
-
-                                    </div>
-                                    <div class="layui-row">
-
-                                        <div class="layui-col-xs7 layui-inline">
-                                            <label class="layui-form-label">鎽樿</label>
-                                            <div class="layui-input-block">
-                                                <input class="layui-input" name="HExplanation" id="HExplanation" autocomplete="off">
+                                        <div class="layui-col-xs4 layui-inline" style="display:none;">
+                                            <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>
+                                                <input type="hidden" name="HProjectID" id="HProjectID" class="layui-input" value="0" style="float: left; width: 150px; background-color: #efefef4d;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="btnHProjectID" style="width:40px;">
+                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+                                                </button>
                                             </div>
                                         </div>
+                                        <div class="layui-col-xs4 layui-inline" style="display:none;">
+                                            <label class="layui-form-label">椤圭洰鍚嶇О</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HProjectName" id="HProjectName" style="background-color:#efefef4d;" readonly autocomplete="off">
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row" style="display:none;">
+                                        <div class="layui-col-xs4 layui-inline" style="display:none;">
+                                            <label class="layui-form-label">淇濈鍛�</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HKeeperName" id="HKeeperName" class="layui-input" value="" style="float:left;width:150px;" readonly>
+                                                <input type="hidden" name="HKeeperID" id="HKeeperID" class="layui-input" value="0" style="float:left;width:150px;">
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HKeeperList" style="width:40px;">
+                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+                                                </button>
+                                            </div>
+                                        </div>
+                                        <div class="layui-col-xs4 layui-inline" style="display:none;">
+                                            <label class="layui-form-label">婧愬崟绫诲瀷</label>
+                                            <div class="layui-input-inline">
+                                                <select name="HSourceBillType" id="HSourceBillType" lay-verify="HSourceBillType">
+                                                    <!--鍔ㄦ�佹覆鏌撴簮鍗曠被鍨�-->
+                                                </select>
+                                            </div>
+                                        </div>
+                                        <div class="layui-col-xs4 layui-inline" style="display:none;">
+                                            <label class="layui-form-label">閫夊崟鍙�</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HSourceBillNo" id="HSourceBillNo" class="layui-input" value="" style="float:left;width:150px;" readonly>
+
+                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
+                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
+                                                </button>
+                                            </div>
+                                        </div>
+                                        <!--<div class="layui-row">
+                                            <div class="layui-col-xs7 layui-inline">
+                                                <label class="layui-form-label">鎽樿</label>
+                                                <div class="layui-input-block">
+                                                    <input class="layui-input" name="hexplanation" id="hexplanation" autocomplete="off">
+                                                </div>
+                                            </div>
+                                        </div>-->
                                     </div>
                                     <div class="layui-row">
                                         <div class="layui-col-xs7 layui-inline">
                                             <label class="layui-form-label">澶囨敞</label>
                                             <div class="layui-input-block">
-                                                <input class="layui-input" name="HRemark" id="HRemark" autocomplete="off">
+                                                <input class="layui-input" name="HRemark" id="HRemark" autocomplete="off" style="width:800px;">
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row">
+                                        <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: 800px;">
+                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
+                                                    <!--鍔ㄦ�佹覆鏌撶粍缁�-->
+                                                </select>
                                             </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-col-xs4 layui-inline">
+                                            <label class="layui-form-label">鍐呴儴鍗曟嵁鍙�</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" autocomplete="off">
+                                            </div>
+                                        </div>
+                                        
+                                    </div>
+                                    
+                                </div>
+                            </div>
 
                             <!--鍒跺崟淇℃伅-->
                             <div class="layui-tab-item">
@@ -224,20 +278,6 @@
                                     </div>
                                     <div class="layui-row">
                                         <div class="layui-inline">
-                                            <label class="layui-form-label" style="width: 85px;">淇敼浜�</label>
-                                            <div class="layui-input-block" style="margin-left: 120px;">
-                                                <input type="text" class="layui-input" name="HUpDater" id="HUpDater" style="background-color:#efefef4d;" readonly>
-                                            </div>
-                                        </div>
-                                        <div class="layui-inline">
-                                            <label class="layui-form-label" style="width: 85px;">浣滃簾浜�</label>
-                                            <div class="layui-input-block" style="margin-left: 120px;">
-                                                <input type="text" class="layui-input" name="HDeleteMan " id="HDeleteMan " style="background-color:#efefef4d;" readonly>
-                                            </div>
-                                        </div>
-                                    </div>
-                                    <div class="layui-row">
-                                        <div class="layui-inline">
                                             <label class="layui-form-label" style="width: 85px;">鍒跺崟鏃ユ湡</label>
                                             <div class="layui-input-block" style="margin-left: 120px;">
                                                 <input type="text" class="layui-input" name="HMakeDate" id="HMakeDate" style="background-color:#efefef4d;" readonly>
@@ -255,18 +295,32 @@
                                                 <input type="text" class="layui-input" name="HCloseDate" id="HCloseDate" style="background-color:#efefef4d;" readonly>
                                             </div>
                                         </div>
+                                    </div>
+                                    <div class="layui-row">
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label" style="width: 85px;">淇敼浜�</label>
+                                            <div class="layui-input-block" style="margin-left: 120px;">
+                                                <input type="text" class="layui-input" name="HUpDater" id="HUpDater" style="background-color:#efefef4d;" readonly>
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label" style="width: 85px;">浣滃簾浜�</label>
+                                            <div class="layui-input-block" style="margin-left: 120px;">
+                                                <input type="text" class="layui-input" name="HDeleteMan" id="HDeleteMan" style="background-color:#efefef4d;" readonly>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-row">
                                         <div class="layui-inline">
                                             <label class="layui-form-label" style="width: 85px;">淇敼鏃ユ湡</label>
                                             <div class="layui-input-block" style="margin-left: 120px;">
                                                 <input type="text" class="layui-input" name="HUpDateDate" id="HUpDateDate" style="background-color:#efefef4d;" readonly>
                                             </div>
                                         </div>
-                                        <div class="layui-row">
-                                            <div class="layui-inline">
-                                                <label class="layui-form-label" style="width: 85px;">浣滃簾鏃ユ湡</label>
-                                                <div class="layui-input-block" style="margin-left: 120px;">
-                                                    <input type="text" class="layui-input" name="HDeleteDate" id="HDeleteDate" style="background-color:#efefef4d;" readonly>
-                                                </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label" style="width: 85px;">浣滃簾鏃ユ湡</label>
+                                            <div class="layui-input-block" style="margin-left: 120px;">
+                                                <input type="text" class="layui-input" name="HDeleteDate" id="HDeleteDate" style="background-color:#efefef4d;" readonly>
                                             </div>
                                         </div>
                                     </div>
@@ -278,9 +332,11 @@
                     <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-CopyLine"><i class="layui-icon layui-icon-form"></i>澶嶅埗涓�琛�</button>
+                            <!--<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-CopyLine"><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>
+                            <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>-->
                         </div>
                     </script>
                     <script type="text/html" id="xuhao">
@@ -294,6 +350,12 @@
         <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">鍒犻櫎</a>
     </script>
     <script>
+        //#region 鏂囨湰妗嗚緭鍏ユ悳绱㈢浉鍏虫暟鎹�-鍙橀噺
+        var childPage = null;                       //鑾峰彇瀛愮獥鍙e璞★紝鐢ㄤ簬鎿嶄綔瀛愮獥鍙g殑鍙橀噺鍜屾柟娉�
+        var currRowIndex = 0;                       //鐢ㄤ簬瀹氫綅瀛愮獥鍙e綋鍓嶉�変腑鐨勮
+        var childData = null;                       //鐢ㄤ簬鑾峰彇瀛愮獥鍙h繑鍥炵殑鏁版嵁
+        //#endregion
+
         //#region 鎶樺彔娉ㄩ噴
         //#endregion
         layui.config({
@@ -315,102 +377,119 @@
             var month = date.getMonth() + 1;
             var year = date.getFullYear();
             var shijian = year + "-" + month + "-" + day;
-
+            var topScroll = 0;//璁板綍婊氬姩鏉$殑浣嶇疆
             var allVal;
             //#endregion
-
+            var HModName = "Add_Edit_Kf_POStockInBillList"
 
             //#region 杩涘叆椤甸潰鍗冲姞杞�
-
             //鍒ゆ柇鏄惁鐧诲綍 鏈櫥褰曞垯璺冲埌鐧诲綍椤�
             get_LoginIs();
+
+            //#region 銆愬姩鎬佽幏鍙栨ā鍧楀悕绉般��
+            var HModuleType = "1201";
+            //閫氳繃鍗曟嵁绫诲瀷锛屼粠鏁版嵁搴撳姩鎬佽幏鍙栧崟鎹ā鍧楀懡鍚�,寮曠敤js鏂囦欢 PageTitle.js
+            var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
+            $("h1").html('<b>' + HPageTitle + '</b>');
+            //#endregion
+
             Organ();//鏄剧ず缁勭粐
-            //鑾峰彇椤甸潰璺宠浆鍙傛暟
+            //鑾峰彇婧愬崟绫诲瀷
+            HSourceBillType();
+        
+
+          //鑾峰彇椤甸潰璺宠浆鍙傛暟
             var params = get_UrlVars();
-            var OperationType = params[params[0]]; //浠庡弬鏁颁腑鑾峰彇 鏁版嵁绫诲瀷  1娣诲姞 淇濆瓨  2澶嶅埗  3 缂栬緫
-            var linterid = params[params[1]]; //浠庡弬鏁颁腑鑾峰彇 鍗曟嵁鍐呯爜
             if (typeof (params[params[0]]) == "undefined") {
                 OperationType = 1;//鎿嶄綔绫诲瀷
             } else {
-                OperationType = params[params[0]];//鎿嶄綔绫诲瀷
-                linterid = params[params[1]];//婧愬崟id
+                var OperationType = params[params[0]];//鎿嶄綔绫诲瀷
+                var linterid = params[params[1]];//婧愬崟id
+                var HSouceBillType = params[params[2]];//婧愬崟绫诲瀷
             }
+            var HBillSubType = getParams("HBillSubType") == "" ? "1201" : getParams("HBillSubType");//鍗曟嵁瀛愮被鍨�
+            $("#HBillSubType").val(HBillSubType);
 
- 
-            //鍒ゆ柇鎿嶄綔绫诲瀷
-            if (OperationType == 1) {//鏃犳簮鍗曟柊澧�
-                $("#HItemID").val(0);
-                //绂佺敤缁勭粐閫夐」
-                $("#HUSEORGID").attr("disabled", true);
+
+           //#region 鑾峰彇鏈�澶у崟鎹彿
+            function get_MAXNum() {
+                $("#HInterID").val("0");
+                $("#HBillNo").val("");
+                $.ajax({
+                    url: GetWEBURL() + "/WEBSController/GetMaxBillNoAndID_Json",
+                    type: "GET",
+                    data: { "HBillType": '1201' },
+                    success: function (d) {
+                        $("#HBillNo").val(d.data[0].HBillNo);
+                        $("#HInterID").val(d.data[0].HInterID);
+                    }
+                });
             }
-            else if (OperationType == 3) {//缂栬緫
-                //绂佺敤缁勭粐閫夐」
-                $("#HUSEORGID").attr("disabled", true);
-                $("#HItemID").val(linterid);//淇敼鏃朵富琛↖D
+            //#endregion
+
+          // 鍒濆鍖栫晫
+            set_InitGrid();
+
+         //#region 鍒ゆ柇鎿嶄綔绫诲瀷骞跺垵濮嬪寲鐣岄潰
+            if (OperationType == 1) {                                                   //鏃犳簮鍗曟柊澧�
+               /* $("#HItemID").val(0);*/
+
+                //鐢熸垚鍗曟嵁鍙峰拰鍐呯爜
+               get_MAXNum();
+                //鍒濆鍖栨棩鏈熴�佸垱寤轰汉銆佸垱寤烘椂闂�
+                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
+                $("#HReceiveDate").val(Format(new Date(), "yyyy-MM-dd"));
+                $("#HMaker").val(sessionStorage["HUserName"]);
+                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));
+            }
+            else if (OperationType == 3) {                                              //缂栬緫
+                //淇敼鏃朵富琛↖D
+                $("#HInterID").val(linterid);
+                $('#print-btn').prop('disabled', false).removeClass('layui-btn-disabled');
                 //缂栬緫鐘舵�佹椂锛屾牴鎹唴鐮侊紝鑾峰彇淇℃伅骞跺啓鍏ョ晫闈�
                 RoadBillMain(linterid);
             }
-            else if (OperationType == 4) {//娴忚
-                $("#HItemID").val(linterid);//
-                //缂栬緫鐘舵�佹椂锛屾牴鎹唴鐮侊紝鑾峰彇淇℃伅骞跺啓鍏ョ晫闈�
-                RoadBillMain(linterid);
-                $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);//淇濆瓨鍚庡姞杞芥暟鎹椂淇濆瓨鎸夐挳绂佺敤
+            else if (OperationType == 4) {                     //涓嬫帹
+                setInit_PushBill();
             }
             else {
                 layer.alert("鏈煡鎿嶄綔绫诲瀷锛�", { icon: 5 });
             }
-
             //#endregion
 
-
-
-
-            //鍒ゆ柇鏄惁鏂板
-            if (linterid == null || linterid == 0) {
-                //鑾峰彇鏈�澶у崟鎹彿 new
-                $("#HMaker").val(sessionStorage["HUserName"]);
-                $("#HInterID").val("0");
-                $("#HBillNo").val("");
-                $.ajax({
-                    url: GetWEBURL() + "/Web/GetMAXNum",
-                    type: "GET",
-                    data: { "HBillType": '1201' },
-                    success: function (d) {
-                        //console.log(d.data);
-                        $("#HBillNo").val(d.data[0].HBillNo);
-                        $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
-                        $("#HInterID").val(d.data[0].HInterID);
-                        $("#HSSDate").val(Format(new Date(), "yyyy-MM-dd")); //缁撶畻鏂瑰紡
-                    }
-                });
-            } else {//濡傛灉淇敼鍒欒蛋涓嬮潰 new
-                $("#HInterID").val(linterid);
-                RoadBillMain(linterid);
-            }
-            //#endregion
+          
+           
             //#endregion
 
             var rowdata = [{
-                "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HAuxPropID": 0, "鐗╂枡杈呭姪灞炴��": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "", "HQty": "", "HRemark": "",
+                "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "0", "HQty": "0", "HRemark": "",
                 "HPrice": "0", "HMoney": "0", "HOrderPrice": "0", "HWHID": 0, "鏀舵枡浠撳簱": "",
                 "HSPID": 0, "浠撲綅鍚嶇О": "", "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
-                "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": ""
+                "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                "HSourceBillNo": "", "HSourceBillType": "", "HSourceInterID": 0, "HSourceEntryID": 0,
+                "HTaxRate": 0, "HTaxPrice": 0, "HlineTotal": 0
             }];
-            // 鍒濆鍖栫晫
-            set_InitGrid();
-
+          
             //澶村伐鍏锋爮浜嬩欢
             table.on('toolbar(mainTable)', function (obj) {
                 var checkStatus = table.checkStatus('mainTable')
                     , data = checkStatus.data;
                 //鏂板琛岃〃鏍兼暟鎹�
                 var NewRow = {
-                    "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HAuxPropID": 0, "鐗╂枡杈呭姪灞炴��": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "", "HQty": "", "HRemark": "",
+                    "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "0", "HQty": "0", "HRemark": "",
                     "HPrice": "0", "HMoney": "0", "HOrderPrice": "0", "HWHID": 0, "鏀舵枡浠撳簱": "",
                     "HSPID": 0, "浠撲綅鍚嶇О": "", "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
-                    "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": ""
+                    "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                    "HSourceBillNo": "", "HSourceBillType": "", "HSourceInterID": 0, "HSourceEntryID": 0,
+                    "HTaxRate": 0, "HTaxPrice": 0, "HlineTotal": 0
                 };
                 switch (obj.event) {
+                    //搴撳瓨鏌ヨ
+                    case 'get_Inventory': get_Inventory();
+                        break;
+                    //鍑哄叆搴撹褰曟煡璇�
+                    case 'get_InOutSum': get_InOutSum();
+                        break;
                     case 'btn-AddLine':
                         table.cache["mainTable"].push(NewRow);
                         option.data = table.cache["mainTable"];
@@ -437,10 +516,10 @@
                             //checkRefresh();
                         }
                         break;
-                    ////鍒楄缃�
-                    //case 'set_HideColumn':
-                    //    get_HideColumn();
-                    //    break;
+                    //鍒楄缃�
+                    case 'set_HideColumn':
+                        get_HideColumn();
+                        break;
                 }
             });
 
@@ -452,6 +531,20 @@
                 Pub_Close(1);
             })
 
+           //#region 鎸夐挳
+            form.on('submit(set_CheckBill)', function (data) {
+                set_CheckBill(0);
+            });
+            //#region 鎵撳嵃
+            form.on('submit(get_PrintReport)', function (data) {
+                get_PrintReport();
+            });
+            //#endregion
+            //#region 閫夋暣鍗�
+            form.on('submit(set_SelectMainBill)', function (data) {
+                set_SelectMainBill();
+            });
+            //#endregion
             //閫夋嫨涓氬姟鍛樻寜閽�
             form.on('submit(HEmpList)', function () {
                 get_checkEmp();
@@ -460,6 +553,11 @@
             form.on('submit(HSupList)', function () {
                 get_checkSup();
             });
+            //閫夋嫨宸ョ▼椤圭洰
+            form.on('submit(btnHProjectID)', function () {
+                get_btnHProjectID();
+            });
+
             //閫夋嫨閮ㄩ棬鎸夐挳
             form.on('submit(HWHList)', function () {
                 get_checkWH();
@@ -480,12 +578,6 @@
             //閫夋嫨涓荤鎸夐挳
             form.on('submit(HManagerList)', function () {
                 get_checkManager();
-            });
-
-
-            //淇濆瓨鎸夐挳
-            form.on('submit(set_SaveBill)', function (data) {
-                set_SaveBill(data);
             });
 
             //琛屽唴浜嬩欢
@@ -511,11 +603,462 @@
                 }
             });
 
+            //#region 鍥炶溅閫夋嫨婧愬崟
+            $('#HSourceBillNo').on('keydown', function (event) {
+                var HSourceBillNo = $('#HSourceBillNo').val();//锛堟簮鍗曞崟鎹彿锛�
+                if (event.keyCode == 13) {
+                    var ajaxLoad = layer.load();
+                    var url;
+                    //鍒ゆ柇鏂囨湰妗嗘槸鍚︽湁鏁版嵁    new
+                    if (HSourceBillNo == "") {
+                        layer.close(ajaxLoad);
+                        return;
+                    }
+                    if ($("#HSourceBillType").val() == "1102") {
+                        //婧愬崟绫诲瀷鏄噰璐鍗�
+                        url = "/Cg_POOrderBill/PushList";
+                    } else if ($("#HSourceBillType").val() == "1103") {
+                        //婧愬崟绫诲瀷鏄敹鏂欓�氱煡鍗�
+                        url = "/Cg_POInStockBill/PushList";
+                    }
+                    $.ajax({
+                        url: GetWEBURL() + url,
+                        type: "GET",
+                        data: { "HBillNo": HSourceBillNo, "user": sessionStorage["HUserName"] },
+                        success: function (result) {
+                            if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                                var checkStatus = result;
+                                if ($("#HSourceBillType").val() == "1102") {
+                                    option.data = [];//娓呯┖瀛愯〃
+                                    $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                                    $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                                    $("#HProjectID").val(checkStatus.data[0].HProjectID);
 
+                                    $("#HDeptID").val(checkStatus.data[0].HDeptID);
+                                    $("#HDeptName").val(checkStatus.data[0].閮ㄩ棬);
+                                    $("#HWHID").val(checkStatus.data[0].HWHID);
+                                    $("#HWHName").val(checkStatus.data[0].浠撳簱);
+                                    $("#HSupID").val(checkStatus.data[0].HSupID);
+                                    $("#HSupName").val(checkStatus.data[0].渚涘簲鍟�);
+                                    $("#HEmpID").val(checkStatus.data[0].HEmpID);
+                                    $("#HEmpName").val(checkStatus.data[0].涓氬姟鍛�);
+                                    $("#HManagerID").val(checkStatus.data[0].HManagerID);
+                                    $("#HManagerName").val(checkStatus.data[0].涓荤);
+                                    $("#HInvoiceBillNo").val(checkStatus.data[0].鍙戠エ缂栧彿);
+                                    $("#HInnerBillNo").val(checkStatus.data[0].鍐呴儴鍗曟嵁鍙�);
+
+                                    var j = 0;
+                                    for (var i = 0; i < result.data.length; i++) {
+                                        var HNewQty = checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺//鏁伴噺
+                                        var HNewMoney = checkStatus.data[j].閲戦 - checkStatus.data[j].鍏宠仈鏁伴噺 * checkStatus.data[j].鍗曚环//鍑忓皯鍏宠仈鏁伴噺鐨勯噾棰�
+                                        var HNewTaxMoney = HNewMoney * checkStatus.data[j].绋庣巼 * 0.01
+                                        var HNewlineTotal = HNewMoney + HNewTaxMoney;
+                                        option.data.push({
+                                            "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
+                                            "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HWHID": checkStatus.data[j].HWHIDSub, "鏀舵枡浠撳簱": checkStatus.data[j].浠撳簱鍚嶇О,
+                                            "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О, "HQtyMust": checkStatus.data[j].鏁伴噺,
+                                            "HQty": HNewQty, "HPrice": checkStatus.data[j].鍗曚环, "HMoney": HNewMoney,"HOrderPrice": checkStatus.data[j].閲戦,
+                                            "HSourceBillNo": checkStatus.data[j].鍗曟嵁鍙�, "HSourceBillType": checkStatus.data[j].HBillType, "HSourceInterID": checkStatus.data[j].hmainid, "HSourceEntryID": checkStatus.data[j].hsubid,
+                                            "HTaxRate": checkStatus.data[j].绋庣巼, "HTaxPrice": checkStatus.data[j].鍚◣鍗曚环, "HlineTotal": HNewlineTotal
+                                        })
+                                        j++;
+                                    }
+
+                                } else if ($("#HSourceBillType").val() == "1103") {
+                                    option.data = [];//娓呯┖瀛愯〃
+                                    $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                                    $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                                    $("#HProjectID").val(checkStatus.data[0].HProjectID);
+                                    $("#HDeptID").val(checkStatus.data[0].HDeptID);
+                                    $("#HDeptName").val(checkStatus.data[0].閮ㄩ棬);
+                                    $("#HWHID").val(checkStatus.data[0].涓昏〃浠撳簱ID);
+                                    $("#HWHName").val(checkStatus.data[0].涓昏〃浠撳簱);
+                                    $("#HSupID").val(checkStatus.data[0].HSupID);
+                                    $("#HSupName").val(checkStatus.data[0].渚涘簲鍟�);
+                                    $("#HEmpID").val(checkStatus.data[0].HEmpID);
+                                    $("#HEmpName").val(checkStatus.data[0].涓氬姟鍛�);
+                                    $("#HManagerID").val(checkStatus.data[0].HManagerID);
+                                    $("#HManagerName").val(checkStatus.data[0].涓荤);
+                                    $("#HInvoiceBillNo").val(checkStatus.data[0].鍙戠エ缂栧彿);
+                                    $("#HInnerBillNo").val(checkStatus.data[0].鍐呴儴鍗曟嵁鍙�);
+                                    var j = 0;
+                                    for (var i = 0; i < result.data.length; i++) {
+                                        var HNewQty = checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺//鏁伴噺
+                                        var HNewMoney = checkStatus.data[j].閲戦 - checkStatus.data[j].鍏宠仈鏁伴噺 * checkStatus.data[j].鍗曚环//鍑忓皯鍏宠仈鏁伴噺鐨勯噾棰�
+                                        var HNewTaxMoney = HNewMoney * checkStatus.data[j].绋庣巼 * 0.01
+                                        var HNewlineTotal = HNewMoney + HNewTaxMoney;
+                                        option.data.push({
+                                            "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
+                                            "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HQtyMust": checkStatus.data[j].鏁伴噺, "HQty": checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺, "HRemark": "",
+                                            "HPrice": checkStatus.data[j].鍗曚环, "HMoney": HNewMoney, "HOrderPrice": checkStatus.data[j].閲戦, "HWHID": checkStatus.data[j].HWHID, "鏀舵枡浠撳簱": checkStatus.data[j].鏀舵枡浠撳簱,
+                                            "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О, "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
+                                            "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                                            "HSourceBillNo": checkStatus.data[j].鍗曟嵁鍙�, "HSourceBillType": checkStatus.data[j].HBillType, "HSourceInterID": checkStatus.data[j].hmainid, "HSourceEntryID": checkStatus.data[j].hsubid,
+                                            "HTaxRate": checkStatus.data[j].绋庣巼, "HTaxPrice": checkStatus.data[j].鍚◣鍗曚环, "HlineTotal": HNewlineTotal
+                                        })
+                                        j++;
+                                    }
+                                }
+                                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 搴撳瓨鏌ヨ
+            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
+            //#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 鐩戝惉鍗曞厓鏍肩紪杈�  鍗曞厓鏍肩紪杈戝悗 鍙樻洿
+            table.on('edit(mainTable)', function (obj) {
+                //鏁板�兼牸寮忔牎楠屽伐鍏�
+                var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
+                var ref1 = /^-?\d+(\.\d+)?$/;          //鍒ゆ柇瀛楃涓叉槸鍚︿负鏁板瓧(鍖呭惈鏁存暟銆佹诞鐐规暟)锛屾鍒欒〃杈惧紡
+                var temp = "";
+                var Dec = getDecByMaterID(obj.data.HMaterID) //鑾峰彇绮惧害
+                var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //鏁伴噺绮惧害
+                var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //鍗曚环绮惧害
+                var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //閲戦绮惧害
+                topScroll = $('#mainTable').next('.layui-table-view').find('.layui-table-body').scrollTop();//鑾峰彇婊氬姩鏉′綅缃�
+                // 鍗曞厓鏍肩紪杈戜箣鍓嶇殑鍊�
+                var oldText = $(this).prev().text();
+                var value = obj.value //寰楀埌淇敼鍚庣殑鍊�
+                    , data = obj.data //寰楀埌鎵�鍦ㄨ鎵�鏈夐敭鍊�
+                    , field = obj.field; //寰楀埌瀛楁
+
+                switch (field) {
+                    case "HQty":                                         //鏁伴噺
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref1.test(temp)) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HQty: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛�!");
+                            return;
+                        } else if (temp * 1 == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HQty: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛�!");
+                            return;
+                        }
+
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = value * 1;                           //鏁伴噺
+                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxRate = obj.data.HTaxRate * 0.01;           //绋庣巼
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HMoney: HMoney
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HlineTotal: HlineTotal
+                        });
+                         table.render(option);
+                        break;
+                    case "HPrice":                                         //鍗曚环
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp) || temp == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HPrice: oldText
+                            });
+                             table.render(option);
+
+                            layer.msg("鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
+                            return;
+                        }
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HPrice = value * 1;
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxRate = obj.data.HTaxRate * 0.01;        //绋庣巼
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HMoney: HMoney
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HlineTotal: HlineTotal
+                        });
+                        table.render(option)
+                        break;
+                    case "HMoney":                                         //閲戦
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp) || temp == 0) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HMoney: oldText
+                            });
+                             table.render(option);
+
+                            layer.msg("閲戦璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
+                            return;
+                        }
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HMoney = value * 1;
+                        var HPrice = (HMoney / HQty);       //鍗曚环=閲戦/鏁伴噺
+                        var HTaxRate = obj.data.HTaxRate * 0.01;                       //绋庣巼
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
+                        });
+                        table.render(option);
+                        break;
+                    case "HTaxRate":                                                       //鏁伴噺
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp)) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HTaxRate: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛�!");
+                            return;
+                        }
+
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                        var HTaxRate = value * 0.01;                       //绋庣巼
+                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //鎶樻墸鐜�*/
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
+                        });
+                        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;            //浠风◣鍚堣=閲戦+绋庨
+
+
+                        HQty = Number(HQty.toFixed(HQtyDec));
+                        HPrice = Number(HPrice.toFixed(HPriceDec));
+                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
+                        HMoney = Number(HMoney.toFixed(HMoneyDec));
+                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({                    //鏇存柊琛ㄦ牸鏁版嵁                鏂规硶鏄瀵硅薄鎻愪緵鐨勪竴涓柟娉曪紝鐢ㄤ簬鏇存柊鍏跺唴閮ㄧ姸鎬佹垨涓庝箣鍏宠仈鐨勬暟鎹簮
+                            HQty: HQty                               //鏇存柊HQty瀛楁锛孒Qty
+                            , HPrice: HPrice                         //鏇存柊HPrice瀛楁锛孒Price
+                            , HMoney: HMoney                      //鏇存柊HMoney瀛楁锛孒Money
+                            , HlineTotal: HlineTotal                  //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                            , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                        });
+                        table.render(option)
+                        break;
+                    default:
+                }
+            });
+            //#endregion
+            //#endregion
             //#endregion
 
 
             //#region 鏈〉闈㈡墍鏈夎璋冪敤鐨勬柟娉�
+
+            //#region 鎵撳嵃
+            function get_PrintReport() {
+                var temp = $("#HInterID").val();
+                if (typeof (temp) != "undefined" && temp != null && temp != "") {
+                    linterid = temp;
+                }
+
+                layer.open({
+                    type: 2
+                    , area: ['50%', '50%']
+                    , title: '鎵撳嵃妯$増閫夋嫨'
+                    , shade: 0.6 //閬僵閫忔槑搴�
+                    , maxmin: false //鍏佽鍏ㄥ睆鏈�灏忓寲
+                    , anim: 0 //0-6鐨勫姩鐢诲舰寮忥紝-1涓嶅紑鍚�
+                    , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + linterid.toString() + '&MyMsg=' + linterid.toString() + '&Type=HPOStockInBillByID', 'yes']
+                    , resize: false
+                })
+            }
+            //#endregion
+
 
             //#region 鍒ゆ柇鏄惁鐧诲綍 鏈櫥褰曞垯璺冲埌鐧诲綍椤�
             function get_LoginIs() {
@@ -528,27 +1071,28 @@
             //#endregion
 
 
-            //鑾峰彇缁勭粐
+          //鑾峰彇缁勭粐
             function Organ() {
                 //鑾峰彇鐧诲綍椤电粍缁囧垪
-                var Organization = '';
                 $.ajax({
                     type: "get",
                     url: GetWEBURL() + "/Web/GetOrganizations",
                     success: function (result) {
+                        var Organization = "";
                         if (result.count == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
                             var data = result.data;
                             for (var i = 0; i < data.length; i++) {
                                 Organization += '<option  style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
                             }
-                            $("#HUSEORGID").append(Organization);
-                            $("#HUSEORGID").val(sessionStorage["OrganizationID"])
+                            $("#HOrgID").append(Organization);
+                            $("#HOrgID").val(sessionStorage["OrganizationID"])
                             form.render('select');
                         }
                         layer.closeAll("loading");
                     }
                 })
             }
+
 
             //鏃ユ湡鏍煎紡鍖�
             function formatDate(date) {
@@ -564,7 +1108,7 @@
             }
 
 
-
+            //瀛愯〃
 
             function set_InitGrid() {
                 option = {
@@ -573,34 +1117,45 @@
                     , limit: 500
                     , height: 500
                     , loading: false
+                    , totalRow: true
                     , cols: [[ //瀛愯〃
                         { type: 'checkbox', totalRowText: '鍚堣琛�' }
-                        , { type: 'numbers', title: '搴忓彿', width: 100, totalRow: true }
+                        , { type: 'numbers',field: '搴忓彿', title: '搴忓彿', width: 100 }
+                        , { field: 'HSourceBillNo', title: '婧愬崟鍙�', width: 100, hide: true }//婧愬崟鍙�
+                        , { field: 'HSourceBillType', title: '婧愬崟绫诲瀷', width: 100, hide: true }//婧愬崟绫诲瀷
+                        , { field: 'HSourceInterID', title: '婧愬崟涓诲唴鐮�', width: 100, hide: true }//婧愬崟涓诲唴鐮�
+                        , { field: 'HSourceEntryID', title: '婧愬崟瀛愬唴鐮�', width: 100, hide: true }//婧愬崟瀛愬唴鐮�
                         , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true }
                         , { field: '鐗╂枡浠g爜', title: '鐗╂枡浠g爜', width: 150, edit: 'text', event: "HMaterID" }//f7
-                        , { field: '鐗╂枡鍚嶇О', title: '鐗╂枡鍚嶇О', width: 150, }
-                        , { field: '瑙勬牸鍨嬪彿', title: '瑙勬牸鍨嬪彿', width: 100, }
-                        , { field: 'HAuxPropID', title: 'HAuxPropID', width: 100, hide: true }
-                        , { field: '鐗╂枡杈呭姪灞炴��', title: '鐗╂枡杈呭姪灞炴��', width: 150, edit: 'text'}//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 }
-                        , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100, edit: 'text', event: "HUnitID" }//f7
-                        , { field: 'HQtyMust', title: '搴旀敹鏁伴噺', width: 150, edit: 'text'}
-                        , { field: 'HQty', title: '瀹炴敹鏁伴噺', width: 150, edit: 'text'}
-                        , { field: 'HPrice', title: '鍗曚环', width: 100, edit: 'text' }
-                        , { field: 'HMoney', title: '閲戦', width: 100, edit: 'text' }
-                        , { field: 'HOrderPrice', title: '閲囪喘閲戦', width: 100, edit: 'text' }
-                        , { field: 'HWHID ', title: 'HWHID ', width: 100, hide: true }
+                        , { field: '璁¢噺鍗曚綅', title: '璁¢噺鍗曚綅', width: 100, event: "HUnitID" }//f7
+                        , { field: 'HQtyMust', title: '搴旀敹鏁伴噺', width: 150,  totalRow: true}
+                        , { field: 'HQty', title: '瀹炴敹鏁伴噺', width: 150, edit: 'text', totalRow: true}
+                        , { field: 'HPrice', title: '鍗曚环', width: 100 }
+                        , { field: 'HMoney', title: '閲戦', width: 100, totalRow: true }
+                        , { field: 'HOrderPrice', title: '閲囪喘閲戦', width: 100, totalRow: true}
+                        , { field: 'HWHID', title: 'HWHID', width: 100, hide: true }
                         , { field: '鏀舵枡浠撳簱', title: '鏀舵枡浠撳簱', width: 100, edit: 'text', event: "HWHID" }//f7
                         , { field: 'HSPID', title: 'HSPID', width: 100, hide: true }
                         , { field: '浠撲綅鍚嶇О', title: '浠撲綅鍚嶇О', width: 100, edit: 'text', event: "HSPID" }//f7
+                        , { field: 'HTaxRate', title: '绋庣巼', width: 100}
+                        , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100}
+                        , { field: 'HlineTotal', title: '鍚◣閲戦', width: 100, style: 'background-color:#efefef4d;' }
                         , { field: 'HBatchNo', title: '鎵规', width: 150, edit: 'text' }
                         , { field: 'HRemark', title: '澶囨敞', width: 100, edit: 'text' }
                         , { fixed: 'right', title: '鎿嶄綔', toolbar: '#barDemo', width: 70 }
                     ]]
+                    , done: function (res, curr, count) {
+                        $(".layui-table-main").scrollTop(topScroll);
+                    }
                 }
 
-                option.data = rowdata;
+                option.data = [];
                 table.render(option);
+                DisPlay_HideColumn();
+
             }
 
             //#region 鍔犺浇琛ㄥご
@@ -615,8 +1170,10 @@
                     },
                     success: function (result) {
                         if (result.code == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+
                             var data = result.data[0];
                             allVal = result.data[0];
+                            HBillSubType = data.HBillSubType;
                             form.val("component-form-group", { //formTest 鍗� class="layui-form" 鎵�鍦ㄥ厓绱犲睘鎬� lay-filter="" 瀵瑰簲鐨勫��
                                 "HBillNo": data.鍗曟嵁鍙�
                                 , "HDate": formatDate(data.鏃ユ湡)
@@ -625,8 +1182,8 @@
                                 , "HSupName": data.渚涘簲鍟�
                                 , "HEmpID": data.HEmpID
                                 , "HEmpName": data.涓氬姟鍛�
-                                , "HWHID": data.HWHID
-                                , "HWHName": data.鏀舵枡浠撳簱
+                                , "HWHID": data.涓昏〃浠撳簱ID
+                                , "HWHName": data.涓昏〃浠撳簱
                                 , "HSecManagerID": data.HSecManagerID
                                 , "HSecManagerName": data.楠屾敹鍛�
                                 , "HKeeperID": data.HKeeperID
@@ -637,17 +1194,24 @@
                                 , "HManagerID": data.HManagerID
                                 , "HManagerName": data.璐熻矗浜�
                                 , "HExRate": data.姹囩巼
-                                , "Box2": ""
+                                , "HProjectID": data.HProjectID
+                                , "HProjectNumber": data.椤圭洰浠g爜
+                                , "HProjectName": data.椤圭洰鍚嶇О
+                                , "HInvoiceBillNo": data.鍙戠エ缂栧彿
+                                , "HExplanation ":data.鎽樿
+                                //, "Box2": ""
                                 , "HRemark": data.琛ㄥご澶囨敞
                                 , "HMaker": data.鍒跺崟浜�
                                 , "HChecker": data.瀹℃牳浜�
                                 , "HCloseMan": data.鍏抽棴浜�
-                                , "HMakeDate": data.鍒跺崟鏃ユ湡
-                                , "HCheckDate": data.瀹℃牳鏃ユ湡
-                                , "HCloseDate": data.鍏抽棴鏃ユ湡
-                                , "HUpDateDate": data.淇敼鏃ユ湡
-                                , "HDeleteDate": data.浣滃簾鏃ユ湡
-                   
+                                , "HUpDater": data.淇敼浜�
+                                , "HDeleteMan": data.浣滃簾浜�
+                                , "HMakeDate": data.鍒跺崟鏃ユ湡 == null ? "" : Pub_Format(data.鍒跺崟鏃ユ湡, "yyyy-MM-dd hh:mm:ss")
+                                , "HCheckDate": data.瀹℃牳鏃ユ湡 == null ? "" : Pub_Format(data.瀹℃牳鏃ユ湡, "yyyy-MM-dd hh:mm:ss")
+                                , "HCloseDate": data.鍏抽棴鏃ユ湡 == null ? "" : Pub_Format(data.鍏抽棴鏃ユ湡, "yyyy-MM-dd hh:mm:ss")
+                                , "HUpDateDate": data.淇敼鏃ユ湡 == null ? "" : Pub_Format(data.淇敼鏃ユ湡, "yyyy-MM-dd hh:mm:ss")
+                                , "HDeleteDate": data.浣滃簾鏃ユ湡 == null ? "" : Pub_Format(data.浣滃簾鏃ユ湡, "yyyy-MM-dd hh:mm:ss")
+
                             });
                             //瀛愯〃  璧嬪��
                             subdata=result.data
@@ -655,9 +1219,14 @@
                             for (var i = 0; i < subdata.length; i++) {
                                 rowdata.push(
                                     {
-                                        "HMaterID": subdata[i].HMaterID, "鐗╂枡浠g爜": subdata[i].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": subdata[i].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": subdata[i].瑙勬牸鍨嬪彿, "HAuxPropID": subdata[i].HAuxPropID, "鐗╂枡杈呭姪灞炴��": subdata[i].鐗╂枡杈呭姪灞炴��, "HUnitID": subdata[i].HUnitID, "璁¢噺鍗曚綅": subdata[i].璁¢噺鍗曚綅,
+                                        "HMaterID": subdata[i].HMaterID, "鐗╂枡浠g爜": subdata[i].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": subdata[i].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": subdata[i].瑙勬牸鍨嬪彿, "HUnitID": subdata[i].HUnitID, "璁¢噺鍗曚綅": subdata[i].璁¢噺鍗曚綅,
                                         "HQtyMust": subdata[i].搴旀敹鏁伴噺, "HQty": subdata[i].瀹炴敹鏁伴噺, "HRemark": subdata[i].琛ㄤ綋澶囨敞, "HPrice": subdata[i].鍗曚环, "HMoney": subdata[i].閲戦, "HOrderPrice": subdata[i].閲囪喘閲戦, "HWHID": subdata[i].HWHID, "鏀舵枡浠撳簱": subdata[i].鏀舵枡浠撳簱, "HSPID": subdata[i].HSPID, "浠撲綅鍚嶇О": subdata[i].浠撲綅鍚嶇О,
-                                        "HBatchNo": subdata[i].鎵规
+                                        "HBatchNo": subdata[i].鎵规,
+                                        "HSourceBillNo": subdata[i].婧愬崟鍗曞彿,    //婧愬崟鍙�
+                                        "HSourceBillType": subdata[i].婧愬崟绫诲瀷,   //婧愬崟绫诲瀷
+                                        "HSourceInterID": subdata[i].婧愬崟涓诲唴鐮�,   //婧愬崟涓诲唴鐮�
+                                        "HSourceEntryID": subdata[i].婧愬崟瀛愬唴鐮�,     //婧愬崟瀛愬唴鐮�
+                                        "HTaxRate": subdata[i].绋庣巼, "HTaxPrice": subdata[i].鍚◣鍗曚环, "HlineTotal": subdata[i].鍚◣閲戦
                                     }
                                 )
                             }
@@ -677,7 +1246,7 @@
                 });
             }
             //#endregion
-       
+
             //閫�鍑�
             form.on('submit(Exit)', function (data) {
                 if (linterid == undefined) {
@@ -690,15 +1259,311 @@
                 }
             });
 
-           
-           
+            //#region 淇濆瓨鎸夐挳
+            form.on('submit(Saver)', function (data) {
+                //#region 鍒ゆ柇婧愬崟鐘舵��
+                if (OperationType == 1 || OperationType == 4) {
+                    
+                    if ($("#HSourceBillType").val() == "1102") {
+                        for (var i = 0; i < option.data.length; i++) {
+                            if (option.data[i] != []) {
+                                var HSourceBillData = "";
+                                var HSourceBillData = getPushSource_POOrderBillInit(option.data[i].HSourceInterID, option.data[i].HSourceEntryID);            //鑾峰彇婧愬崟鏁版嵁
+                                if (HSourceBillData != "none") {
+                                    if (HSourceBillData == null) {
+                                        if (option.data[i].HSourceInterID!=0) {
+                                            layer.alert("淇濆瓨澶辫触!绗�" + (i + 1) + "琛岋細鏈煡璇㈠埌婧愬崟鍗曟嵁!", { icon: 5 });
+                                            return;
+                                        }
+                                        
+                                    } else if (HSourceBillData.鐘舵�� != "宸插鏍�") {
+                                        var err = "淇濆瓨澶辫触!鍘熷洜锛氱" + (i + 1) + "琛�-婧愬崟鍗曟嵁鐘舵�佷负鈥�" + HSourceBillData.鐘舵�� + "鈥濓紝涓嶅厑璁镐繚瀛橈紒";
+                                        layer.alert(err, { icon: 5 });
+                                        return;
+                                    } else if (HSourceBillData.琛岀姸鎬� == "宸插叧闂�") {
+                                        layer.alert("淇濆瓨澶辫触!绗�" + (i + 1) + "琛岋細璇ヨ璁板綍琛岀姸鎬佷负'宸插叧闂�'鐘舵��!", { icon: 5 });
+                                        return;
+                                    }
+                                } else {
+                                    return;
+                                }
+                            }
+                        }
+                    }
+                    else if ($("#HSourceBillType").val() == "1103") {
+                        for (var i = 0; i < option.data.length; i++) {
+                            if (option.data[i] != []) {
+                                var HSourceBillData = "";
+                                var HSourceBillData = getPushSource_POInStockBillInit(option.data[i].HSourceInterID, option.data[i].HSourceEntryID);            //鑾峰彇婧愬崟鏁版嵁
+                                if (HSourceBillData != "none") {
+                                    if (HSourceBillData == null) {
+                                        if (option.data[i].HSourceInterID != 0) {
+                                            layer.alert("淇濆瓨澶辫触!绗�" + (i + 1) + "琛岋細鏈煡璇㈠埌婧愬崟鍗曟嵁!", { icon: 5 });
+                                            return;
+                                        }
+                                    } else if (HSourceBillData.鐘舵�� != "宸插鏍�") {
+                                        var err = "淇濆瓨澶辫触!鍘熷洜锛氱" + (i + 1) + "琛�-婧愬崟鍗曟嵁鐘舵�佷负鈥�" + HSourceBillData.鐘舵�� + "鈥濓紝涓嶅厑璁镐繚瀛橈紒";
+                                        layer.alert(err, { icon: 5 });
+                                        return;
+                                    } else if (HSourceBillData.琛岀姸鎬� == "宸插叧闂�") {
+                                        layer.alert("淇濆瓨澶辫触!绗�" + (i + 1) + "琛岋細璇ヨ璁板綍琛岀姸鎬佷负'宸插叧闂�'鐘舵��!", { icon: 5 });
+                                        return;
+                                    }
+                                } else {
+                                    return;
+                                }
+                            }
+                        }
+                    }
+                    else {
+                        return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟锛侊紒');
+                    }
+                }
+                //#endregion
+
+                if (AllowLoadData(data)) {
+                    set_SaveBill(data);
+                }
+            });
+            //#endregion
+
+
+          //#region 鑾峰彇鍙傛暟_浼犻�掔殑JSON鏍煎紡鍙傛暟
+            function getUrlVars_JSON() {
+                var datajson;
+                var str = window.location.search; //鑾峰彇閾炬帴涓紶閫掔殑鍙傛暟
+                var arr = str.substring(str.lastIndexOf("=")+1);
+                datajson = $.parseJSON(decodeURI(arr));
+                return datajson;
+            }
+            //#endregion
+
+         //#region 涓嬫帹椤甸潰鍒濆鍖�
+            function setInit_PushBill() {
+                 //鐢熸垚鍗曟嵁鍙峰拰鍐呯爜
+               get_MAXNum();
+
+                //鍒濆鍖栨棩鏈熴�佸埗鍗曚汉銆佸埗鍗曟棩鏈�
+                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
+                $("#HReceiveDate").val(Format(new Date(), "yyyy-MM-dd"));
+                $("#HMaker").val(sessionStorage["HUserName"]);
+                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));
+
+                //璁剧疆婧愬崟绫诲瀷
+                $("#HSourceBillType").val(HSouceBillType);
+                 
+                //绂佺敤缁勭粐閫夐」
+                $("#HOrgID").attr("disabled", true);
+
+            
+
+               if ($("#HSourceBillType").val() == "1102") {
+                    //鑾峰彇 閿�鍞鍗�
+                    var data = getUrlVars_JSON().data;
+                    var dataArray = [];
+                    for (var i = 0; i < data.length; i++) {
+                        var temp = getPushSource_POOrderBillInit(data[i].hmainid, data[i].hsubid);
+                        if (temp != "none") {
+                            dataArray.push(temp);
+                        } else {
+                            return;
+                        }
+                    }
+
+                    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].閮ㄩ棬
+                        , "HManagerID": dataArray[0].HManagerID
+                        , "HManagerName": dataArray[0].涓荤
+                        , "HWHID": dataArray[0].HWHID
+                        , "HWHName": dataArray[0].浠撳簱
+                        , "HEmpID": dataArray[0].HEmpID
+                        , "HEmpName": dataArray[0].涓氬姟鍛�
+                        , "HSecManagerID": dataArray[0].HSecManagerID
+                        , "HSecManagerName": dataArray[0].楠屾敹鍛�
+                        , "HKeeperID": dataArray[0].HKeeperID
+                        , "HKeeperName": 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
+                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                        , "HInvoiceBillNo": dataArray[0].鍙戠エ缂栧彿
+                        , "HInnerBillNo": dataArray[0].鍐呴儴鍗曟嵁鍙�
+                    });
+
+                    //瀛愯〃  璧嬪��
+                    var rowdata = [];
+                    for (var i = 0; i < dataArray.length; i++) {
+                        rowdata.push(
+                            {
+                                "HMaterID": dataArray[i].HMaterID
+                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                , "HUnitID": dataArray[i].HUnitID
+                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 1)
+                                , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                , 'HDiscountRate': "0"                                                     //
+                                , 'HRelTaxPrice': "0"
+                                , "HTaxRate": dataArray[i].绋庣巼
+                                , 'HTaxMoney': "0"                                                         //
+                                , "HMoney": dealDoubleToFixed(dataArray[i].閲戦, 2)
+                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].閲戦 * dataArray[0].姹囩巼, 2)
+                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].浠风◣鍚堣, 2)
+                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].浠风◣鍚堣 * dataArray[0].姹囩巼, 2)
+                                , "HRemark": ""
+                                , "HWHID": dataArray[i].HWHID
+                                , "鏀舵枡浠撳簱": dataArray[i].鏀舵枡浠撳簱
+                                , "HSPID": dataArray[i].HSPID    
+                                , "浠撲綅鍚嶇О": dataArray[i].浠撲綅鍚嶇О
+                               // 锛�"HBatchNo": dataArray[i].鎵规
+
+                                , "HSourceInterID": dataArray[i].hmainid
+                                , "HSourceEntryID": dataArray[i].hsubid
+                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HSourceBillType": dataArray[i].HBillType
+                                , "HRelationQty": "0"
+                                , "HRelationMoney": "0"
+
+                                , 'HPOOrderInterID': "0"
+                                , 'HPOOrderEntryID': "0"
+                                , 'HPOOrderBillNo': ""
+
+                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                , "HSeOrderInterID": dataArray[i].hmainid
+                                , "HSeOrderEntryID": dataArray[i].hsubid
+                                , "HSeOrderBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HTaxRate": 0
+                                , "HTaxPrice": 0
+                                , "HlineTotal": 0
+                            }
+                        );
+                    }
+                    option.data = rowdata;
+                    table.render(option);
+                }
+          else if ($("#HSourceBillType").val() == "1103") {
+                    //鑾峰彇  鏀舵枡閫氱煡鍗�
+                    var data = getUrlVars_JSON().data;
+                    var dataArray = [];
+                    for (var i = 0; i < data.length; i++) {
+                        var temp = getPushSource_POInStockBillInit(data[i].hmainid, data[i].hsubid);
+                        if (temp != "none") {
+                            dataArray.push(temp);
+                        } else {
+                            return;
+                        }
+                    }
+
+                    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].閮ㄩ棬
+                        , "HManagerID": dataArray[0].HManagerID
+                        , "HManagerName": 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].姹囩巼
+                        , "HWHName": dataArray[0].涓昏〃浠撳簱
+                        , "HWHID": dataArray[0].涓昏〃浠撳簱ID
+                        , "HSSID": "0"
+                        , "HSSName": ""
+                        , "HProjectID": dataArray[0].HProjectID
+                        , "HProjectNumber": dataArray[0].椤圭洰浠g爜
+                        , "HProjectName": dataArray[0].椤圭洰鍚嶇О
+                        , "HInvoiceBillNo": dataArray[0].鍙戠エ缂栧彿
+                        , "HInnerBillNo": dataArray[0].鍐呴儴鍗曟嵁鍙�
+                    });
+
+                    //瀛愯〃  璧嬪��
+                   var rowdata = [];
+                   
+                    for (var i = 0; i < dataArray.length; i++) {
+                        rowdata.push(
+                            {
+                                "HMaterID": dataArray[i].HMaterID
+                                , "鐗╂枡浠g爜": dataArray[i].鐗╂枡浠g爜
+                                , "鐗╂枡鍚嶇О": dataArray[i].鐗╂枡鍚嶇О
+                                , "瑙勬牸鍨嬪彿": dataArray[i].瑙勬牸鍨嬪彿
+                                , "HUnitID": dataArray[i].HUnitID
+                                , "璁¢噺鍗曚綅": dataArray[i].璁¢噺鍗曚綅
+                                , "HQty": dealDoubleToFixed(dataArray[i].鏁伴噺, 2)
+                                , "HPrice": dealDoubleToFixed(dataArray[i].鍗曚环, 3)
+                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                , "HQtyMust": dealDoubleToFixed(dataArray[i].鏁伴噺, 2)
+                                , "HOrderPrice": dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环, 2)
+                                , 'HDiscountRate': "0"                                                     //
+                                , 'HRelTaxPrice': "0"
+                                , "HTaxRate": dataArray[i].绋庣巼
+                                , 'HTaxMoney': "0"                                                         //
+                                , "HMoney": dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环, 2)
+                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍗曚环 * dataArray[0].姹囩巼, 2)
+                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环, 2)
+                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].鏁伴噺 * dataArray[i].鍚◣鍗曚环 * dataArray[0].姹囩巼, 2)
+                                , "HRemark": ""
+                                , "HWHID": dataArray[i].HWHID
+                                , "鏀舵枡浠撳簱": dataArray[i].鏀舵枡浠撳簱
+                                , "HSPID": dataArray[i].HSPID    
+                                , "浠撲綅鍚嶇О": dataArray[i].浠撲綅鍚嶇О
+
+                                , "HSourceInterID": dataArray[i].hmainid
+                                , "HSourceEntryID": dataArray[i].hsubid
+                                , "HSourceBillNo": dataArray[i].鍗曟嵁鍙�
+                                , "HSourceBillType": dataArray[i].HBillType
+                                , "HRelationQty": "0"
+                                , "HRelationMoney": "0"
+
+                                , 'HPOOrderInterID': "0"
+                                , 'HPOOrderEntryID': "0"
+                                , 'HPOOrderBillNo': ""
+
+                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].鍚◣鍗曚环, 3)
+                                , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID : "0"
+                                , "HSeOrderEntryID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceEntryID : "0"
+                                , "HSeOrderBillNo": dataArray[i].HSourceBillType == "1401" ? dataArray[i].婧愬崟鍗曞彿 : ""
+                            }
+                        );
+                    }
+                    option.data = rowdata;
+                    table.render(option);
+                }
+                else
+                {
+                    return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟涓嬫帹锛侊紒');
+                }
+            }
+        
+            //#endregion
             //#region 淇濆瓨鏂规硶
             function set_SaveBill(data) {
-                if ($("#HEmpName").val() == 0) {
-                    layer.msg("璇烽�夋嫨涓氬姟鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
-                    return;
-                }
-               
+                //if ($("#HEmpName").val() == 0) {
+                //    layer.msg("璇烽�夋嫨涓氬姟鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+
                 if ($("#HDeptName").val() == 0) {
                     layer.msg("璇烽�夋嫨閮ㄩ棬锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
                     return;
@@ -711,14 +1576,15 @@
                     layer.msg("璇烽�夋嫨浠撳簱锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
                     return;
                 }
-                if ($("#HKeeperID").val() == 0) {
-                    layer.msg("璇烽�夋嫨淇濈鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
-                    return;
-                }
-                if ($("#HSecManagerID").val() == 0) {
-                    layer.msg("璇烽�夋嫨楠屾敹鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
-                    return;
-                }
+                //if ($("#HKeeperID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨淇濈鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+                //if ($("#HSecManagerID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨楠屾敹鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+
 
                 var num = [];
                 for (var i = 0; i < table.cache["mainTable"].length; i++) {
@@ -727,6 +1593,25 @@
                         num.push(table.cache["mainTable"][i])
                     }
                 }
+
+                checkDuplicateData(num);
+                const duplicateRows = checkDuplicateData(num);
+                if (duplicateRows.length > 0) {
+                    let message = '琛ㄦ牸涓瓨鍦ㄩ噸澶嶆暟鎹紝閲嶅琛屾暟涓猴細';
+
+                    for (let i = 0; i < duplicateRows.length; i++) {
+                        const { row1, row2 } = duplicateRows[i];
+                        message += `绗�${row1}琛屼笌绗�${row2}琛岀浉鍚宍;
+
+                        if (i !== duplicateRows.length - 1) {
+                            message += '锛�';
+                        }
+                    }
+
+                    message += '锛岃鍒犻櫎鍏朵腑涓�琛�';
+                    layer.alert(message);
+                }
+
 
                 var sMainStr = JSON.stringify(data.field);
                 var sSubStr = JSON.stringify(num);
@@ -743,10 +1628,15 @@
                     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); //瀹℃牳
+                            }
                             $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                             //淇濆瓨鍚庢祻瑙�
                             //ReRoadBillMain();
+                            $('#print-btn').prop('disabled', false).removeClass('layui-btn-disabled');
                         }
                         else {
                             layer.alert(data.Message, { icon: 5 });
@@ -760,39 +1650,41 @@
                 });
             }
             //#endregion
-          
+
             ////#endregion
 
             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']
-                    //, 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].HName);
-                    //    $("#HEmpID").val(checkStatus.data[0].HItemID);
-                    //    layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
-                    //}
-                    //, btn2: function (index, layero) { }
+                    , 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) { }
                 })
             }
             function get_checkSup() {
+                var HOrgName = $('select[name="HOrgID"] option:selected').text();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '渚涘簲鍟嗗垪琛�'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../鍩虹璧勬枡/閲囪喘鍩虹璧勬枡/Gy_Supplier.html', 'yes']
+                    , content: ['../../鍩虹璧勬枡/閲囪喘鍩虹璧勬枡/Gy_Supplier.html?Type=HSup&HOrgName=' + HOrgName, 'yes']
                     , btn: ['纭畾', '鍙栨秷']
                     , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
                         var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
@@ -807,125 +1699,395 @@
                     , btn2: function (index, layero) { }
                 })
             }
+            //宸ョ▼椤圭洰
+            function get_btnHProjectID() {
+                var HOrgID = $("#HOrgID").val();
+                layer.open({
+                    type: 2//寮圭獥绫诲瀷
+                    , skin: 'layui-layer-rim' //鍔犱笂杈规
+                    , area: ['90%', '90%']//澶у皬
+                    , title: '椤圭洰鍒楄〃'//鏍囬
+                    , shift: 2//寮瑰嚭鍔ㄧ敾
+                    , content: ['../../椤圭洰绠$悊/宸ョ▼椤圭洰/PM_ProjectBillList.html?Type=2&HOrgID=' + HOrgID + "&HBillSubType=" + HBillSubType, '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('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                        $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                        $("#HProjectID").val(checkStatus.data[0].HInterID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
+                })
+            }
             function get_checkWH() {
+                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_WarehouseList.html?Type=HWHID', '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('璇烽�夋嫨鏁版嵁');
-                    //    }
-                    //    $("#HWHName").val(checkStatus.data[0].HName);
-                    //    $("#HWHID").val(checkStatus.data[0].HItemID);
-                    //    layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
-                    //}
-                    //, btn2: function (index, layero) { }
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Warehouse.html?Type=HWH&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('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HWHName").val(checkStatus.data[0].浠撳簱鍚嶇О);
+                        $("#HWHID").val(checkStatus.data[0].HItemID);
+
+                        if (option.data.length > 0) {
+                            for (var i = 0; i < option.data.length; i++) {
+                                if (option.data[i]["HWHID"] == 0) {
+                                    option.data[i]["HWHID"] = checkStatus.data[0].HItemID;
+                                    option.data[i]["鏀舵枡浠撳簱"] = checkStatus.data[0].浠撳簱鍚嶇О;
+                                }
+                            }
+                        }
+                        table.render(option);
+
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
             function get_checkSecManager() {
+                var HOrgID = $("#HOrgID").val();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '楠屾敹鍛樺垪琛�'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_EmployeeList.html?Type=HSecManager', '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('璇烽�夋嫨鏁版嵁');
-                    //    }
-                    //    $("#HSecManagerName").val(checkStatus.data[0].HName);
-                    //    $("#HSecManagerID").val(checkStatus.data[0].HItemID);
-                    //    layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
-                    //}
-                    //, btn2: function (index, layero) { }
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_EmployeeList.html?Type=HSecManager&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('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HSecManagerName").val(checkStatus.data[0].鑱屽憳鍚嶇О);
+                        $("#HSecManagerID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
             function get_checkKeeper() {
+                var HOrgID = $("#HOrgID").val();
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
                     , skin: 'layui-layer-rim' //鍔犱笂杈规
                     , area: ['90%', '90%']//澶у皬
                     , title: '淇濈鍛樺垪琛�'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../Baseset/鍩虹璧勬枡/Gy_EmployeeList.html?Type=HKeeper', '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('璇烽�夋嫨鏁版嵁');
-                    //    }
-                    //    $("#HKeeperName").val(checkStatus.data[0].HName);
-                    //    $("#HKeeperID").val(checkStatus.data[0].HItemID);
-                    //    layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
-                    //}
-                    //, btn2: function (index, layero) { }
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_EmployeeList.html?Type=HKeeper&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('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HKeeperName").val(checkStatus.data[0].鑱屽憳鍚嶇О);
+                        $("#HKeeperID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
             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']
-                    //, 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].HName);
-                    //    $("#HDeptID").val(checkStatus.data[0].HItemID);
-                    //    layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
-                    //}
-                    //, btn2: function (index, layero) { }
+                    , 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) { }
                 })
             }
 
             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=HWorker', '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('璇烽�夋嫨鏁版嵁');
-                    //    }
-                    //    $("#HManagerName").val(checkStatus.data[0].HName);
-                    //    $("#HManagerID").val(checkStatus.data[0].HItemID);
-                    //    layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
-                    //}
-                    //, btn2: function (index, layero) { }
+                    , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_EmployeeList.html?Type=HWorker&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('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#HManagerName").val(checkStatus.data[0].鑱屽憳鍚嶇О);
+                        $("#HManagerID").val(checkStatus.data[0].HItemID);
+                        layer.close(index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                    }
+                    , btn2: function (index, layero) { }
                 })
             }
 
+         //#region 鍙嶅鏍�/瀹℃牳鏁版嵁
+            function set_CheckBill(num) {
+                var InterID = $("#HInterID").val();
+                //閫昏緫瀹℃牳鏂规硶
+                $.ajax({
+                    type: "GET",
+                    url: GetWEBURL() + "/Kf_POStockInBill/AuditKf_POStockInBill", //鏂规硶鎵�鍦ㄩ〉闈㈠拰鏂规硶鍚�
+                    data: { "HInterID": InterID, "IsAudit": num, "CurUserName": sessionStorage["HUserName"] },
+                    success: function (result) {
+                        if (result.count == 1) {
+                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
+                                // 寰楀埌frame绱㈠紩
+                                var index = layer.getFrameIndex(window.name);
+                                //鍏抽棴褰撳墠frame
+                                layer.close(index);
+                            });
+
+                        } else {
+                            layer.alert(result.code + result.Message, { icon: 5 });
+                        }
+                    }, error: function () {
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                    }
+                });
+            }
+            //#endregion
 
             //琛屽唴蹇嵎閿瓫閫�
             function set_GridCellCheck(obj) {
                 $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
+                    //#region 瀛愯〃鏂囨湰妗嗚緭鍏ュ悗妫�绱㈡暟鎹�
+                    if (event.key != "F7") {
+                        var errKeys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Enter"];
+                        if (obj.event == "HMaterID") {                           //瀹氫綅褰撳墠姝e湪杈撳叆鐨勬枃鏈鐨勫垪鍚�
+                            if ($.inArray(event.key, errKeys) == -1) {              //濡傛灉鎸変笅鐨勯敭浣嶄笉鏄� 鏂瑰悜閿紝鍒欏埛鏂板脊绐椾腑鐨勬暟鎹�
+                                if (childPage == null) {                            //鍒ゆ柇褰撳墠瀛愮獥鍙f槸鍚﹀凡缁忔墦寮�锛岃嫢鏈墦鍗★紝鍒欐墦寮�椤甸潰锛屽苟鑾峰彇瀛愮獥鍙g殑瀵硅薄
+                                    var offset = $(this).offset();                  //鑾峰彇瑙﹀彂浜嬩欢鐨勫厓绱犵殑浣嶇疆锛岀敤浜庡畾浣嶅瓙绐楀彛鎵撳紑鐨勪綅缃�
+                                    var innerHeight = window.innerHeight;
+                                    var top = offset.top + 0.05 * innerHeight;
+                                    var left = offset.left;
+                                    if (top + 0.05 * innerHeight + 0.3 * innerHeight > innerHeight) {
+                                        top = top - 0.3 * innerHeight - 0.05 * innerHeight;
+                                    }
+                                    layer.open({
+                                        type: 2                                                                                     //寮圭獥绫诲瀷
+                                        , skin: 'layui-layer-rim'                                                                   //鍔犱笂杈规
+                                        , area: ['25%', '30%']                                                                      //澶у皬
+                                        , shadeClose: true                                                                          //鐐瑰嚮閬僵鏃跺叧闂脊绐�
+                                        , offset: [top, left]
+                                        , title: false                                                                              //涓嶆樉绀烘爣棰樻爮
+                                        //, title: '椤圭洰璐圭敤鍒楄〃'                                                                     //鏍囬
+                                        , shift: 2                                                                                  //寮瑰嚭鍔ㄧ敾
+                                        , closeBtn: 0                                                                               //绂佺敤鍏抽棴鎸夐挳
+                                        , content: ["../../鍩虹璧勬枡/閫氱敤鍩虹璧勬枡/Gy_CommonBaseData.html?OperationType=2", "yes"]
+                                        , success: function (layero, index) {
+                                            setTimeout(function () {
+                                                var value = $(e.currentTarget).val().replace("'", "");                                  //鑾峰彇鏂囨湰妗嗘渶鏂板��
+                                                currRowIndex = 0;
+                                                var tableView = "h_v_Gy_MaterialList";
+                                                var childSWhere = "select top(10) HItemID,鐗╂枡浠g爜,鐗╂枡鍚嶇О,瑙勬牸鍨嬪彿,HUnitID,璁¢噺鍗曚綅鍚嶇О from " + tableView + " where 1=1 and 缁勭粐鍚嶇О = '" + sessionStorage["Organization"] + "' and (鐗╂枡浠g爜 like '%" + value + "%' or 鐗╂枡鍚嶇О like '%" + value + "%') order by 鐗╂枡浠g爜 desc";
+                                                childPage.getData(childSWhere, tableView);
+                                            }, 200);
+                                        }
+                                        , end: function () {
+                                            obj.event = "";
+                                            childPage = null;
+                                            currRowIndex = 0;
+                                            if (childData != null) {
+                                                OptionData = childData;
+
+                                                //閫氳繃渚涘簲鍟唅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 HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                                            var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                                            var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                                            var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                                            var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                                                            var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                                            //鏁板瓧绮惧害
+                                                            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));
+                                                            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
+                                                                , "HlineTotal": HlineTotal                  //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                                                , "HTaxPrice": HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                                                            })
+                                                        }
+                                                    });
+                                                } else if (typeof (OptionData.HItemID) != "undefined") {
+                                                    obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                                        "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                                        , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                                        , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                                        , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                                        , "HUnitID": OptionData.HUnitID
+                                                        , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                                    })
+                                                }
+
+                                                OptionData = {};
+
+                                                childData = null;
+                                            }
+                                        }
+                                    });
+                                } else {
+                                    setTimeout(function () {
+                                        var value = $(e.currentTarget).val().replace("'", "");                                  //鑾峰彇鏂囨湰妗嗘渶鏂板��
+                                        currRowIndex = 0;
+                                        var tableView = "h_v_Gy_MaterialList";
+                                        var childSWhere = "select top(10) HItemID,鐗╂枡浠g爜,鐗╂枡鍚嶇О,瑙勬牸鍨嬪彿,HUnitID,璁¢噺鍗曚綅鍚嶇О from " + tableView + " where 1=1 and 缁勭粐鍚嶇О = '" + sessionStorage["Organization"] + "' and (鐗╂枡浠g爜 like '%" + value + "%' or 鐗╂枡鍚嶇О like '%" + value + "%')  order by 鐗╂枡浠g爜 desc";
+                                        childPage.getData(childSWhere, tableView);
+                                    }, 200);
+                                }
+                            } else {                                                    //濡傛灉鎸変笅鐨勯敭浣嶆槸 鏂瑰悜閿紝鍒欒皟鏁寸獥鍙d腑 閫変腑琛� 鐨勪綅缃�
+                                if (event.key == "ArrowUp") {
+                                    currRowIndex--;
+                                    childPage.setSelectedRow(currRowIndex);
+                                } else if (event.key == "ArrowDown") {
+                                    currRowIndex++;
+                                    childPage.setSelectedRow(currRowIndex);
+                                } else if (event.key == "Enter") {
+                                    //鎵嬪姩澶辩劍
+                                    var element = document.getElementById("HBillNo");
+                                    element.focus();
+
+                                    childPage.getSelectedData(currRowIndex);
+
+                                    if (childData != null) {
+                                        OptionData = childData;
+
+                                        //閫氳繃渚涘簲鍟唅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 HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                                    var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                                    var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                                    var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                                    var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                                                    var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                                    //鏁板瓧绮惧害
+                                                    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));
+                                                    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
+                                                        , "HlineTotal": HlineTotal                  //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                                        , "HTaxPrice": HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                                                    })
+                                                }
+                                            });
+                                        } else if (typeof (OptionData.HItemID) != "undefined") {
+                                            obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                                "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                                , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                                , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                                , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                                , "HUnitID": OptionData.HUnitID
+                                                , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                            })
+                                        }
+
+                                        OptionData = {};
+                                        childData = null;
+                                    }
+                                   
+
+                                    childPage = null;
+                                    currRowIndex = 0;
+                                    childData = null;
+                                    obj.event = "";
+                                }
+                            }
+                        }
+
+                    }
+                    //#endregion
+
                     if (event.key == "F7") {
                         //鐗╂枡
                         if (obj.event == "HMaterID") {
+                                var HOrgID = $("#HOrgID").val();
                             layer.open({
                                 type: 2
                                 , skin: "layui-layer-rim" //鍔犱笂杈规
@@ -934,7 +2096,7 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_MaterialList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Material.html?openType=2&HOrgID=' + HOrgID, 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -945,45 +2107,50 @@
                                     //    return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
                                     //}
 
+                                    OptionData = checkStatus.data[0];
+                                    if (checkStatus.data.length > 1) {
+                                        var rowIndex = $(obj.tr).attr("data-index") * 1;
+                                        for (var i = 0; i < checkStatus.data.length; i++) {
+                                            if (rowIndex + i >= option.data.length) {
+                                                var NewRow = {
+                                                    "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "0", "HQty": "", "HRemark": "",
+                                                    "HPrice": "0", "HMoney": "0", "HOrderPrice": "0", "HWHID": 0, "鏀舵枡浠撳簱": "",
+                                                    "HSPID": 0, "浠撲綅鍚嶇О": "", "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
+                                                    "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                                                    "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
+                                                    "HTaxRate": 0, "HTaxPrice": 0, "HlineTotal": 0
+                                                };
 
-                                    var rowIndex = $(obj.tr).attr("data-index") * 1;
-                                    for (var i = 0; i < checkStatus.data.length; i++) {
-                                        if (rowIndex + i >= option.data.length) {
-                                            var NewRow = {
-                                                "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HAuxPropID": 0, "鐗╂枡杈呭姪灞炴��": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "", "HQty": "", "HRemark": "",
-                                                "HPrice": "0", "HMoney": "0", "HOrderPrice": "0", "HWHID": 0, "鏀舵枡浠撳簱": "",
-                                                "HSPID": 0, "浠撲綅鍚嶇О": "", "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
-                                                "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": ""
-                                            };
+                                                table.cache["mainTable"].push(NewRow);
+                                                option.data = table.cache["mainTable"];
 
-                                            table.cache["mainTable"].push(NewRow);
-                                            option.data = table.cache["mainTable"];
+                                                table.render(option);
+                                            }
 
-                                            table.render(option);
+
+
+                                            var HMaterID = checkStatus.data[i].HItemID;
+                                            var resultData = getMaterialByMaterID(HMaterID);
+                                            option.data[rowIndex + i].HMaterID = resultData.HMaterID;
+                                            option.data[rowIndex + i].鐗╂枡浠g爜 = resultData.HMaterNumber;
+                                            option.data[rowIndex + i].鐗╂枡鍚嶇О = resultData.HMaterName;
+                                            option.data[rowIndex + i].瑙勬牸鍨嬪彿 = resultData.HMaterModel;
+                                            option.data[rowIndex + i].HUnitID = resultData.HUnitID;
+                                            option.data[rowIndex + i].璁¢噺鍗曚綅 = resultData.HUnitName;
+                                            ////鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
+                                            //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);//鍏抽棴寮圭獥
                                         }
-
-
-
-                                        var HMaterID = checkStatus.data[i].HItemID;
-                                        var resultData = getMaterialByMaterID(HMaterID);
-                                        option.data[rowIndex + i].HMaterID = resultData.HMaterID;
-                                        option.data[rowIndex + i].鐗╂枡浠g爜 = resultData.HMaterNumber;
-                                        option.data[rowIndex + i].鐗╂枡鍚嶇О = resultData.HMaterName;
-                                        option.data[rowIndex + i].瑙勬牸鍨嬪彿 = resultData.HMaterModel;
-                                        option.data[rowIndex + i].HUnitID = resultData.HUnitID;
-                                        option.data[rowIndex + i].璁¢噺鍗曚綅 = resultData.HUnitName;
-                                        ////鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
-                                        //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);//鍏抽棴寮圭獥
+                                        table.render(option);
                                     }
-                                    table.render(option);
+                                    
                                     layer.closeAll();
                                     //layer.close(layer.index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
                                 }
@@ -992,11 +2159,57 @@
                                     //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
                                 },
                                 end: function () {
+                                    //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                                    var HSupID = $("#HSupID").val();
+                                    if (HSupID != 0) {
+                                        $.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 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 HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                                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
+                                                    , HlineTotal: HlineTotal                  //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                                    , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                                                })
+                                            }
+                                        });
+                                    } else {
+                                        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" //鍔犱笂杈规
@@ -1005,7 +2218,7 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_UnitList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Unit.html?Type=2&HOrgName=' + HOrgName, 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1017,15 +2230,22 @@
                                     }
                                     //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
                                     obj.update({
-                                        "璁¢噺鍗曚綅": checkStatus.data[0].HName
+                                        "璁¢噺鍗曚綅": checkStatus.data[0].璁¢噺鍗曚綅鍚嶇О
                                         , "HUnitID": checkStatus.data[0].HItemID
                                     })
                                     layer.close(index);//鍏抽棴寮圭獥
                                 }
+                               , end: function () {
+                                obj.update({
+                                    "HUnitID": OptionData.HItemID
+                                    , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                })
+                            }
                             })
                         }
                         //鏀舵枡浠撳簱
                         if (obj.event == "HWHID") {
+                            var HOrgName = $('select[name="HOrgID"] option:selected').text();
                             layer.open({
                                 type: 2
                                 , skin: "layui-layer-rim" //鍔犱笂杈规
@@ -1034,7 +2254,7 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_WarehouseList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Warehouse.html?type=Warehouse&HOrgName=' + HOrgName, 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1044,16 +2264,23 @@
                                     if (checkStatus.data.length != 1) {
                                         return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
                                     }
+                                    OptionData = checkStatus.data[0];
                                     //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
                                     obj.update({
-                                        "鏀舵枡浠撳簱": checkStatus.data[0].HName
+                                        "鏀舵枡浠撳簱": checkStatus.data[0].浠撳簱鍚嶇О
                                         , "HWHID": checkStatus.data[0].HItemID
                                     })
                                     layer.close(index);//鍏抽棴寮圭獥
                                 }
+                             , end: function () {
+                                obj.update({
+                                    "HWHID": OptionData.HItemID
+                                    , "鏀舵枡浠撳簱": OptionData.浠撳簱鍚嶇О
+                                })
+                            }
                             })
                         }
-                        //渚涘簲鍟�
+                        //浠撲綅
                         if (obj.event == "HSPID") {
                             layer.open({
                                 type: 2
@@ -1063,7 +2290,7 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_StockPlaceList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_StockPlace_List.html', 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1075,31 +2302,511 @@
                                     }
                                     //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
                                     obj.update({
-                                        "浠撲綅鍚嶇О": checkStatus.data[0].HName
-                                        , "HSPID": checkStatus.data[0].HItemID
+                                        "浠撲綅鍚嶇О": checkStatus.data[0].浠撲綅鍚嶇О
+                                        , "HSPID": checkStatus.data[0].HMainID
                                     })
                                     layer.close(index);//鍏抽棴寮圭獥
                                 }
+                              , end: function () {
+                                obj.update({
+                                    "HSPID": OptionData.HMainID
+                                    , "浠撲綅鍚嶇О": OptionData.浠撲綅鍚嶇О
+                                })
+                            }
                             })
                         }
+                        obj.event = "";
+                        return false;
                     }
                 })
-            }
-                 
+                $('.layui-table-box tbody td[data-field="鐗╂枡浠g爜"]').off('dblclick').on('dblclick', function () {
+                    //鎵嬪姩澶辩劍
+                    var element = document.getElementById("HBillNo");
+                    element.focus();
 
+                    var HOrgID = $("#HOrgID").val();
+                    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");//鑾峰彇閫変腑鐨勬暟鎹�
+                            var TaxRate = getHTaxRateByHSupID();
+                            //if (checkStatus.data.length != 1) {
+                            //    return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                            //}
+
+                            OptionData = checkStatus.data[0];
+                            if (checkStatus.data.length > 1) {
+                                var rowIndex = $(obj.tr).attr("data-index") * 1;
+                                for (var i = 0; i < checkStatus.data.length; i++) {
+                                    if (rowIndex + i >= option.data.length) {
+                                        var NewRow = {
+                                            "HMaterID": 0, "鐗╂枡浠g爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HQtyMust": "0", "HQty": "", "HRemark": "",
+                                            "HPrice": "0", "HMoney": "0", "HOrderPrice": "0", "HWHID": 0, "鏀舵枡浠撳簱": "",
+                                            "HSPID": 0, "浠撲綅鍚嶇О": "", "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
+                                            "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                                            "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
+                                            "HTaxRate": 0, "HTaxPrice": 0, "HlineTotal": 0
+                                        };
+
+                                        table.cache["mainTable"].push(NewRow);
+                                        option.data = table.cache["mainTable"];
+
+                                        table.render(option);
+                                    }
+
+
+
+                                    var HMaterID = checkStatus.data[i].HItemID;
+                                    var resultData = getMaterialByMaterID(HMaterID);
+                                    option.data[rowIndex + i].HMaterID = resultData.HMaterID;
+                                    option.data[rowIndex + i].鐗╂枡浠g爜 = resultData.HMaterNumber;
+                                    option.data[rowIndex + i].鐗╂枡鍚嶇О = resultData.HMaterName;
+                                    option.data[rowIndex + i].瑙勬牸鍨嬪彿 = resultData.HMaterModel;
+                                    option.data[rowIndex + i].HUnitID = resultData.HUnitID;
+                                    option.data[rowIndex + i].璁¢噺鍗曚綅 = resultData.HUnitName;
+                                    option.data[rowIndex + i].HTaxRate = TaxRate;
+                                    ////鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
+                                    //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);//鍏抽棴寮圭獥
+                                }
+                                table.render(option);
+                            }
+
+                            layer.closeAll();
+                            //layer.close(layer.index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                        }
+                        , btn2: function (index, layero) {
+                            //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
+                            //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
+                        },
+                        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 HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                        var HTaxMoney = Number((HMoney * HTaxRate));         //绋庨=閲戦*绋庣巼
+                                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+                                        //鏁板瓧绮惧害
+                                        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));
+                                        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
+                                            , HlineTotal: HlineTotal                  //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                            , HTaxPrice, HTaxPrice                   //鏇存柊HTaxPrice瀛楁锛孒TaxPrice
+                                        })
+                                    }
+                                });
+                            } else if (typeof (OptionData.HItemID) != "undefined"){
+                                obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                    "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                    , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                    , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                    , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                    , "HUnitID": OptionData.HUnitID
+                                    , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                })
+                            }
+                        }
+                    });
+
+                    obj.event = "";
+                });
+            }
+
+            //琛屽唴浜嬩欢
+            table.on('tool(mainTable)', function (obj) {
+                set_GridDelete(obj);   //琛屽唴鍒犻櫎
+                set_GridCellCheck(obj); //琛屽唴蹇嵎閿瓫閫�
+
+            });
+
+            //鍔ㄦ�佸脊鍑洪〉闈�
+            function getSupType() {
+                var type = $("#HSourceBillType").val();
+                switch (type) {
+                    case '1102':
+                        return { url: "../../閲囪喘绠$悊/閲囪喘璁㈠崟/Cg_POOrderBillList.html", name: "閲囪喘璁㈠崟" };
+                        break;
+                    case '1103':
+                        return { url: "../../閲囪喘绠$悊/鏀舵枡閫氱煡鍗�/Cg_POInStockBillList.html", name: "鏀舵枡閫氱煡鍗�" };
+                        break;
+                }
+            }
+
+            //#region 閫夋暣鍗�
+            function set_SelectMainBill() {
+                var url;
+                if ($("#HSourceBillType").val() == "1102") {
+                    url = "../../閲囪喘绠$悊/閲囪喘璁㈠崟/Cg_POOrderBillQuery.html?openType=2&HOrgID=" + HOrgID;
+                } else if ($("#HSourceBillType").val() == "1103") {
+                    url = "../../閲囪喘绠$悊/鏀舵枡閫氱煡鍗�/Cg_POInStockBillQuery.html?openType=2&HOrgID=" + HOrgID;
+                } else {
+                    return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟閫夋嫨锛侊紒');
+                }
+                //椤甸潰灞�-鑷畾涔�
+                layer.open({
+                    type: 2
+                    , skin: "layui-layer-rim" //鍔犱笂杈规
+                    , title: '' + getSupType().name + '鍒楄〃'  //鏍囬
+                    , closeBtn: 1  //绐椾綋鍙充笂瑙掑叧闂� 鐨� 鏍峰紡
+                    , shift: 2 //寮瑰嚭鍔ㄧ敾
+                    , area: ["90%", "90%"] //绐椾綋澶у皬
+                    , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
+                    , content: [url, "yes"]
+                    , btn: ["纭畾", "鍙栨秷"]
+                    , btn1: function (index, laero) {
+                        //鎸夐挳涓�  鐨勫洖璋�
+                        var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
+
+                        if (checkStatus.data.length == 0) {
+                            return layer.msg("璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�!");
+                        }
+                        var HSupID = $("#HSupID").val();//鍒ゆ柇渚涘簲鍟�
+                        if (HSupID == 0 || HSupID == '') {
+                            HSupID = checkStatus.data[0]["HSupID"];
+                        }
+                        //鑾峰彇渚涘簲鍟嗕唬鐮�,璁剧疆鏉′欢
+                        var sMainWhere = " and hmainid in(";
+                        for (var i = 0; i < checkStatus.data.length; i++) {
+                            if (checkStatus.data[i]["HSupID"] != HSupID) {
+                                layer.msg("涓嬫帹澶辫触!宸茬粡閫変腑鐨勮褰曚腑瀛樺湪涓嶅悓渚涘簲鍟�!");
+                                layer.close(index);//鍏抽棴寮圭獥
+                                return;
+                            }
+                            sMainWhere += checkStatus.data[i]["hmainid"]
+                            if (i != checkStatus.data.length - 1) {
+                                sMainWhere += ",";
+                            } else {
+                                sMainWhere += ") ";
+                            }
+                        }
+                        getSeletMainInfo(sMainWhere);
+                        layer.close(index);//鍏抽棴寮圭獥
+                     }
+                });
+            }
+            //#endregion
+
+            //#region 鏁村崟淇℃伅鑾峰彇鏂规硶
+            function getSeletMainInfo(sMainWhere) {
+                var ajaxLoad = layer.load();
+                if ($("#HSourceBillType").val() == "1102") {
+                    $.ajax({
+                        url: GetWEBURL() + '/Cg_POOrderBill/list',
+                        async: false,
+                        type: "GET",
+                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
+                        success: function (data1) {
+                            if (data1.count == 1) {
+                                var checkStatus = data1;
+                                option.data = [];//娓呯┖瀛愯〃
+                                $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                                $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                                $("#HProjectID").val(checkStatus.data[0].HProjectID);
+
+                                $("#HDeptID").val(checkStatus.data[0].HDeptID);
+                                $("#HDeptName").val(checkStatus.data[0].閮ㄩ棬);
+                                $("#HWHID").val(checkStatus.data[0].HWHID);
+                                $("#HWHName").val(checkStatus.data[0].浠撳簱);
+                                $("#HSupID").val(checkStatus.data[0].HSupID);
+                                $("#HSupName").val(checkStatus.data[0].渚涘簲鍟�);
+                                $("#HEmpID").val(checkStatus.data[0].HEmpID);
+                                $("#HEmpName").val(checkStatus.data[0].涓氬姟鍛�);
+                                $("#HManagerID").val(checkStatus.data[0].HManagerID);
+                                $("#HManagerName").val(checkStatus.data[0].涓荤);
+                                $("#HInvoiceBillNo").val(checkStatus.data[0].鍙戠エ缂栧彿);
+                                $("#HInnerBillNo").val(checkStatus.data[0].鍐呴儴鍗曟嵁鍙�);
+                                for (var j = 0; j < checkStatus.data.length; j++) {
+                                    var HNewQty = checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺//鏁伴噺
+                                    var HNewMoney = checkStatus.data[j].閲戦 - checkStatus.data[j].鍏宠仈鏁伴噺 * checkStatus.data[j].鍗曚环//鍑忓皯鍏宠仈鏁伴噺鐨勯噾棰�
+                                    var HNewTaxMoney = HNewMoney * checkStatus.data[j].绋庣巼 * 0.01
+                                    var HNewlineTotal = HNewMoney + HNewTaxMoney;
+                                    option.data.push({
+                                        "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
+                                        "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HWHID": checkStatus.data[j].HWHIDSub, "鏀舵枡浠撳簱": checkStatus.data[j].浠撳簱鍚嶇О,
+                                        "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О, "HQtyMust": checkStatus.data[j].鏁伴噺,
+                                        "HQty": HNewQty, "HPrice": checkStatus.data[j].鍗曚环, "HMoney": HNewMoney, "HOrderPrice": checkStatus.data[j].閲戦,
+                                        "HSourceBillNo": checkStatus.data[j].鍗曟嵁鍙�, "HSourceBillType": checkStatus.data[j].HBillType, "HSourceInterID": checkStatus.data[j].hmainid, "HSourceEntryID": checkStatus.data[j].hsubid,
+                                        "HTaxRate": checkStatus.data[j].绋庣巼, "HTaxPrice": checkStatus.data[j].鍚◣鍗曚环, "HlineTotal": HNewlineTotal
+                                    })
+                                }
+                                table.render(option);
+                                layer.close(ajaxLoad);
+                                //layer.alert("鏌ヨ鎴愬姛", { icon: 1 });
+                            } else {
+                                layer.close(ajaxLoad);
+                                layer.alert(data1.code + data1.Message, { icon: 5 });
+                                return;
+                            }
+                        }, error: function () {
+                            layer.close(ajaxLoad);
+                            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                            return;
+                        }
+                    });
+                    
+                } else if ($("#HSourceBillType").val() == "1103") {
+                    $.ajax({
+                        url: GetWEBURL() + '/Cg_POInStockBill/list',
+                        type: "GET",
+                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
+                        success: function (data1) {
+                            if (data1.count == 1) {
+                                checkStatus = data1;
+                                option.data = [];//娓呯┖瀛愯〃
+                                $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                                $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                                $("#HProjectID").val(checkStatus.data[0].HProjectID);
+                                $("#HDeptID").val(checkStatus.data[0].HDeptID);
+                                $("#HDeptName").val(checkStatus.data[0].閮ㄩ棬);
+                                $("#HWHID").val(checkStatus.data[0].涓昏〃浠撳簱ID);
+                                $("#HWHName").val(checkStatus.data[0].涓昏〃浠撳簱);
+                                $("#HSupID").val(checkStatus.data[0].HSupID);
+                                $("#HSupName").val(checkStatus.data[0].渚涘簲鍟�);
+                                $("#HEmpID").val(checkStatus.data[0].HEmpID);
+                                $("#HEmpName").val(checkStatus.data[0].涓氬姟鍛�);
+                                $("#HManagerID").val(checkStatus.data[0].HManagerID);
+                                $("#HManagerName").val(checkStatus.data[0].涓荤);
+                                $("#HInvoiceBillNo").val(checkStatus.data[0].鍙戠エ缂栧彿);
+                                $("#HInnerBillNo").val(checkStatus.data[0].鍐呴儴鍗曟嵁鍙�);
+                                for (var j = 0; j < checkStatus.data.length; j++) {
+                                    var HNewQty = checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺//鏁伴噺
+                                    var HNewMoney = checkStatus.data[j].閲戦 - checkStatus.data[j].鍏宠仈鏁伴噺 * checkStatus.data[j].鍗曚环//鍑忓皯鍏宠仈鏁伴噺鐨勯噾棰�
+                                    var HNewTaxMoney = HNewMoney * checkStatus.data[j].绋庣巼 * 0.01
+                                    var HNewlineTotal = HNewMoney + HNewTaxMoney;
+                                    option.data.push({
+                                        "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
+                                        "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HQtyMust": checkStatus.data[j].鏁伴噺, "HQty": HNewQty, "HRemark": "",
+                                        "HPrice": checkStatus.data[j].鍗曚环, "HMoney": HNewMoney, "HOrderPrice": checkStatus.data[j].閲戦, "HWHID": checkStatus.data[j].HWHID, "鏀舵枡浠撳簱": checkStatus.data[j].鏀舵枡浠撳簱,
+                                        "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О, "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
+                                        "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                                        "HSourceBillNo": checkStatus.data[j].鍗曟嵁鍙�, "HSourceBillType": checkStatus.data[j].HBillType, "HSourceInterID": checkStatus.data[j].hmainid, "HSourceEntryID": checkStatus.data[j].hsubid,
+                                        "HTaxRate": checkStatus.data[j].绋庣巼, "HTaxPrice": checkStatus.data[j].鍚◣鍗曚环, "HlineTotal": HNewlineTotal
+                                    })
+                                }
+                                table.render(option);
+                                layer.close(ajaxLoad);
+                            } else {
+                                layer.close(ajaxLoad);
+                                layer.alert(data1.code + data1.Message, { icon: 5 });
+                                return;
+                            }
+                        }, error: function () {
+                            layer.close(ajaxLoad);
+                            layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                            return;
+                        }
+                    });
+                } else {
+                    return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟閫夋嫨锛侊紒');
+                }
+            }
+            //#endregion
+
+            //琛ㄥご淇℃伅閫夋嫨鍗曟嵁寮圭獥
+            form.on('submit(XDHList)', function () {
+            var HOrgID = $("#HOrgID").val();
+                var url = "";
+                if ($("#HSourceBillType").val() == "1102") {
+                    url = "../../閲囪喘绠$悊/閲囪喘璁㈠崟/Cg_POOrderBillList.html?openType=2&HOrgID=" + HOrgID;
+                } else if ($("#HSourceBillType").val() == "1103") {
+                    url = "../../閲囪喘绠$悊/鏀舵枡閫氱煡鍗�/Cg_POInStockBillList.html?openType=2&HOrgID=" + HOrgID;
+                }else{
+                    return layer.msg('褰撳墠涓嶆敮鎸佽婧愬崟閫夋嫨锛侊紒');
+                }
+
+                //椤甸潰灞�-鑷畾涔�
+                layer.open({
+                    type: 2
+                    , skin: "layui-layer-rim" //鍔犱笂杈规
+                    , title: '' + getSupType().name + '鍒楄〃'  //鏍囬
+                    , closeBtn: 1  //绐椾綋鍙充笂瑙掑叧闂� 鐨� 鏍峰紡
+                    , shift: 2 //寮瑰嚭鍔ㄧ敾
+                    , area: ["90%", "90%"] //绐椾綋澶у皬
+                    , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
+                    , content: [url, "yes"]
+                    , btn: ["纭畾", "鍙栨秷"]
+                    , btn1: function (index, laero) {
+                        //鎸夐挳涓�  鐨勫洖璋�
+                        var iframeWindow = window["layui-layer-iframe" + index];//鑾峰彇寮规椤甸潰
+                        var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//鑾峰彇閫変腑鐨勬暟鎹�
+
+                        if (checkStatus.data.length == 0) {
+                            return layer.msg("璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹�!");
+                        }
+                        var HSupID = $("#HSupID").val();//鍒ゆ柇渚涘簲鍟�
+                        if (HSupID == 0 || HSupID == '') {
+                            HSupID = checkStatus.data[0]["HSupID"];
+                        }
+                        //鑾峰彇鏀舵枡閫氱煡鍗曚唬鐮�
+                        var ProcessNumber = [];
+                        for (var i = 0; i < checkStatus.data.length; i++) {
+                            if (checkStatus.data[i]["HSupID"] != HSupID) {
+                                layer.msg("涓嬫帹澶辫触!宸茬粡閫変腑鐨勮褰曚腑瀛樺湪涓嶅悓渚涘簲鍟�!");
+                                layer.close(index);//鍏抽棴寮圭獥
+                                return;
+                            }
+                            ProcessNumber.push(checkStatus.data[i]);
+                        }
+
+                        //鑾峰彇褰撳墠浣嶇疆鎵�鍦ㄨ鏁�
+                        var NowNum = 0;
+                        NowNum = option.data.length;
+
+                        $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                        $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                        $("#HProjectID").val(checkStatus.data[0].HProjectID);
+
+                        $("#HDeptID").val(checkStatus.data[0].HDeptID);
+                        $("#HDeptName").val(checkStatus.data[0].閮ㄩ棬);
+                        //涓よ竟鏄剧ず鐨勫瓧娈典笉涓�鏍锋墍浠ョ敤鍒ゆ柇鍘昏祴鍊�
+                        if ($("#HSourceBillType").val() == "1102") {  //閲囪喘璁㈠崟
+                            $("#HWHID").val(checkStatus.data[0].HWHID);
+                            $("#HWHName").val(checkStatus.data[0].浠撳簱);
+                        } else if ($("#HSourceBillType").val() == "1103") {  //鏀惰揣閫氱煡鍗�
+                            $("#HWHID").val(checkStatus.data[0].涓昏〃浠撳簱ID);
+                            $("#HWHName").val(checkStatus.data[0].涓昏〃浠撳簱);
+                        }
+                      
+                        $("#HSupID").val(checkStatus.data[0].HSupID);
+                        $("#HSupName").val(checkStatus.data[0].渚涘簲鍟�);
+                        $("#HEmpID").val(checkStatus.data[0].HEmpID);
+                        $("#HEmpName").val(checkStatus.data[0].涓氬姟鍛�);
+                        $("#HManagerID").val(checkStatus.data[0].HManagerID);
+                        $("#HManagerName").val(checkStatus.data[0].涓荤);
+                        $("#HInvoiceBillNo").val(checkStatus.data[0].鍙戠エ缂栧彿);
+                        $("#HInnerBillNo").val(checkStatus.data[0].鍐呴儴鍗曟嵁鍙�);
+                        if ($("#HSourceBillType").val() == "1102") {
+                           
+                            var j = 0;
+                            for (var i = 0; i < checkStatus.data.length; i++) {
+                                var HNewQty = checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺//鏁伴噺
+                                var HNewMoney = checkStatus.data[j].閲戦 - checkStatus.data[j].鍏宠仈鏁伴噺 * checkStatus.data[j].鍗曚环//鍑忓皯鍏宠仈鏁伴噺鐨勯噾棰�
+                                var HNewTaxMoney = HNewMoney * checkStatus.data[j].绋庣巼 * 0.01
+                                var HNewlineTotal = HNewMoney + HNewTaxMoney;
+                                option.data.push({
+                                    "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
+                                    "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HWHID": checkStatus.data[j].HWHIDSub, "鏀舵枡浠撳簱": checkStatus.data[j].浠撳簱鍚嶇О,
+                                    "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О, "HQtyMust": checkStatus.data[j].鏁伴噺,
+                                    "HQty": HNewQty, "HPrice": checkStatus.data[j].鍗曚环, "HMoney": HNewMoney, "HOrderPrice": checkStatus.data[j].閲戦,
+                                    "HSourceBillNo": checkStatus.data[j].鍗曟嵁鍙�, "HSourceBillType": checkStatus.data[j].HBillType, "HSourceInterID": checkStatus.data[j].hmainid, "HSourceEntryID": checkStatus.data[j].hsubid,
+                                    "HTaxRate": checkStatus.data[j].绋庣巼, "HTaxPrice": checkStatus.data[j].鍚◣鍗曚环, "HlineTotal": HNewlineTotal
+                                })
+                                j++;
+                            }
+                            table.render(option);
+                            layer.close(index);
+                        } else if ($("#HSourceBillType").val() == "1103") {
+                         
+                            var j = 0;
+                            for (var i = 0; i < ProcessNumber.length; i++) {
+                                var HNewQty = checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺//鏁伴噺
+                                var HNewMoney = checkStatus.data[j].閲戦 - checkStatus.data[j].鍏宠仈鏁伴噺 * checkStatus.data[j].鍗曚环//鍑忓皯鍏宠仈鏁伴噺鐨勯噾棰�
+                                var HNewTaxMoney = HNewMoney * checkStatus.data[j].绋庣巼 * 0.01
+                                var HNewlineTotal = HNewMoney + HNewTaxMoney;
+                                option.data.push({
+                                    "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
+                                    "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HQtyMust": checkStatus.data[j].鏁伴噺, "HQty": checkStatus.data[j].鏁伴噺 - checkStatus.data[j].鍏宠仈鏁伴噺, "HRemark": "",
+                                    "HPrice": checkStatus.data[j].鍗曚环, "HMoney": HNewMoney, "HOrderPrice": checkStatus.data[j].閲戦, "HWHID": checkStatus.data[j].HWHID, "鏀舵枡浠撳簱": checkStatus.data[j].鏀舵枡浠撳簱,
+                                    "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О, "HBatchNo": "", "HPOOrderInterID": 0, "HPOOrderEntryID": 0,
+                                    "HPOOrderBillNo": "", "HSeOrderInterID": 0, "HSeOrderEntryID": 0, "HSeOrderBillNo": "",
+                                    "HSourceBillNo": checkStatus.data[j].鍗曟嵁鍙�, "HSourceBillType": checkStatus.data[j].HBillType, "HSourceInterID": checkStatus.data[j].hmainid, "HSourceEntryID": checkStatus.data[j].hsubid,
+                                    "HTaxRate": checkStatus.data[j].绋庣巼, "HTaxPrice": checkStatus.data[j].鍚◣鍗曚环, "HlineTotal": HNewlineTotal
+                                })
+                                j++;
+                            }
+                            table.render(option);
+                            layer.close(index);//鍏抽棴寮圭獥
+                        }
+
+                    }
+
+                });
+            });
+            //鍒ゆ柇鎵�閫夌潃涓庤〃鏍兼槸鍚︽湁閲嶅鏁版嵁
+            function checkDuplicateData(data) {
+                const duplicates = [];
+
+                for (let i = 0; i < data.length; i++) {
+                    const currentItem = data[i];
+                    let isDuplicate = false;
+
+                    for (let j = i + 1; j < data.length; j++) {
+                        const compareItem = data[j];
+
+                        if (currentItem.HSourceInterID === compareItem.HSourceInterID && currentItem.HSourceEntryID === compareItem.HSourceEntryID) {
+                            isDuplicate = true;
+                            duplicates.push({ row1: i + 1, row2: j + 1 }); // 璁板綍閲嶅鏁版嵁鎵�鍦ㄨ鏁�
+                        }
+                    }
+                    if (isDuplicate && !duplicates.some(item => item.row1 === i + 1)) {
+                        duplicates.push({ row1: i + 1, row2: -1 }); // 璁板綍閲嶅鏁版嵁鎵�鍦ㄨ鏁帮紝-1 琛ㄧず鏈壘鍒颁笌褰撳墠琛岄噸澶嶇殑琛�
+                    }
+                }
+                return duplicates;
+            }
             //琛屽唴鍒犻櫎
             function set_GridDelete(obj) {
                 var data = obj.data;
-                var rowIndex = $(obj.tr).attr("data-index");
+                var rowIndex = $(obj.tr).attr("data-index");//鑾峰彇琛岀储寮�
                 if (obj.event === 'del') {
                     layer.confirm('鐪熺殑鍒犻櫎琛屽悧锛�', function (index) {
                         console.log("绱㈠紩涓�:" + rowIndex);
-                        if (rowIndex === '0') {
+                        if (rowIndex === '0' && table.cache["mainTable"].length == 1) {
                             layer.msg('棣栬鏃犳硶鍒犻櫎锛侊紒锛�');
                         } else {
-                            obj.del();
+                            obj.del();//鍋囧垹闄�
+                            table.cache["mainTable"].splice(rowIndex, 1);  //鈶″交搴曠Щ闄ゅ厓绱狅紝浠庣紦瀛橀噷绉婚櫎杩欎竴琛�
                             option.data = table.cache["mainTable"];//灏嗘暟鎹粦瀹氬埌data涓�
-                            table.reload(option);
+                            table.render(option);
                             layer.close(index);
                         }
                     });
@@ -1138,53 +2845,478 @@
             }
             //#endregion
 
+            //#region 鑾峰彇婧愬崟绫诲瀷
+            function HSourceBillType() {
+                var HName = '閲囪喘鍏ュ簱鍗�';
+                //鑾峰彇鐧诲綍椤电粍缁囧垪
+                $.ajax({
+                    type: "get",
+                    async: false,
+                    data: { "HName": HName, "Num": 2 },       //0钃濆崟 1绾㈠崟 2涓嶅垎绾㈣摑鍗�
+                    url: GetWEBURL() + "/Web/GetHSourceBillType",
+                    success: function (result) {
+                        var HSourceBillTypes = "";
+                        if (result.count == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                            var data = result.data;
+                            for (var i = 0; i < data.length; i++) {
+                                HSourceBillTypes += '<option  style="color:blue;" value="' + data[i].HSourceBillType + '">' + data[i].HSourceBillTypeName + '</option>';
+                            }
+                            $("#HSourceBillType").append(HSourceBillTypes);
+                            form.render('select');
+                        }
+                    }
+                })
+            }
             //#endregion
 
+
+            //#region 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栨簮鍗曢噰璐鍗曟暟鎹�
+            function getPushSource_POOrderBillInit(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];
+                        } else {
+                            res = result.data;
+                            //layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                        }
+                    }, error: function (err) {
+                        res = "none";
+                        layer.alert("鍙戠敓閿欒!"+err, { icon: 5 });
+                    }
+                });
+                return res;
+            }
+            //#endregion
+
+            //#region 閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+            function getHTaxRateByHSupID() {
+                var HTaxRate;
+                //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                var HSupID = $("#HSupID").val();
+                if (HSupID != 0) {
+                    $.ajax({
+                        url: GetWEBURL() + "/Gy_Supplier/xg",
+                        type: "GET",
+                        async: false,
+                        data: {
+                            "HInterID": HSupID
+                        },
+                        success: function (d) {
+                            HTaxRate = parseInt(d.data[0].澧炲�肩◣鐜�);
+                        }
+                    });
+                } else {
+                    HTaxRate = 0;
+                }
+                return HTaxRate;
+            }
+            //#endregion
+
+            //#region 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栨簮鍗曟敹鏂欓�氱煡鍗曟暟鎹�
+            function getPushSource_POInStockBillInit(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];
+                        } else {
+                            res = result.data;
+                            //layer.alert(result.msg, { icon: 5, btn: ['閫�鍑�'], time: 100000, offset: 't' });
+                        }
+                    }, error: function (err) {
+                        res = "none";
+                        layer.alert("鍙戠敓閿欒!" + err, { icon: 5 });
+                    }
+                });
+                return res;
+            }
+            //#endregion
+            //#region 鍒楄缃�
+            //闅愯棌鍒楄缃�
+            function get_HideColumn() {
+                var colName = "";
+                for (var i = 1; i < option.cols[0].length - 1; i++) {
+                    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"] + ",";
+                }
+                colName = encodeURI(colName.substring(0, colName.length - 1));//瀵� URI 杩涜缂栫爜
+                layer.open({
+                    type: 2
+                    , skin: "layui-layer-rim" //鍔犱笂杈规
+                    , title: "闅愯棌鍒楄缃�"  //鏍囬
+                    , closeBtn: 1  //绐椾綋鍙充笂瑙掑叧闂� 鐨� 鏍峰紡
+                    , shift: 2 //寮瑰嚭鍔ㄧ敾
+                    , area: ["50%", "90%"] //绐椾綋澶у皬
+                    , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
+                    , content: ['../../鍩虹璧勬枡/闅愯棌鍒楄缃�/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName + '&colTitleName = ' + colTitleName, "yes"]
+                    , btn: ["纭畾", "鍙栨秷"]
+                    , btn1: function (index, laero) {
+                        //鍒锋柊琛ㄦ牸鏁版嵁
+                        DisPlay_HideColumn();
+                        //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
+                        layer.close(index);//鍏抽棴寮圭獥
+                    }
+                })
+            }
+
+            //鏄剧ず鍒楁暟鎹�
+            function DisPlay_HideColumn() {
+                $.ajax({
+                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
+                    type: "GET",
+                    async: false,
+                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
+                    success: function (data1) {
+                        if (data1.data.length != 0) {
+
+                            var dataCol = [];//鏁版嵁搴撴煡璇㈠嚭鐨勫垪鏁版嵁
+                            var titleData = [];//涓嶉渶瑕佹樉绀虹殑瀛楁 鍙墿灞�
+
+                            dataCol = data1.data[0].HGridString.split(',');
+
+                            for (var i = 0; i < option.cols[0].length - 2; i++) {
+                                var dataCols = dataCol[i].split('|');
+                                //闅愯棌鍒�
+                                if (dataCols[1] == 1) {
+                                    option.cols[0][i + 1]["hide"] = true;
+                                }
+                                //璁剧疆鍐呭瀛椾綋澶у皬
+                                if (data1.data[0].HFontSize != 0) {
+                                    option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
+                                } else {
+                                    option.cols[0][i + 1]["style"] = "font-size:100%";
+                                }
+                                //璁剧疆鍒楀
+                                if (dataCols[3] > 0) {
+                                    option.cols[0][i + 1]["width"] = dataCols[3];
+                                }
+                                //鏄剧ず鍒�
+                                if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
+                                    option.cols[0][i + 1]["hide"] = false;
+                                }
+                                //瀛椾綋鎵�鍦ㄤ綅缃�(宸� 灞呬腑 鍙�)
+                                switch (dataCols[2]) {
+                                    case "L":
+                                        option.cols[0][i + 1]["align"] = "left";
+                                        break;
+                                    case "M":
+                                        option.cols[0][i + 1]["align"] = "center";
+                                        break;
+                                    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];
+                                }
+                            }
+                            //鍙栨秷鍐荤粨鍒�
+                            for (var i = 1; i < option.cols[0].length - 1; i++) {
+                                if (option.cols[0][i]["fixed"] != null) {
+                                    option.cols[0][i]["fixed"] = null;
+                                }
+                                else {
+                                    break;
+                                }
+                            }
+                            //鍐荤粨鍒�
+                            if (data1.data[0].HFixCols != 0) {
+                                for (var i = 0; i < data1.data[0].HFixCols; i++) {
+                                    if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
+                                        data1.data[0].HFixCols += 1;
+                                    }
+                                    option.cols[0][i + 1]["fixed"] = "left";
+                                }
+                            }
+                            table.render(option);
+                        } else {
+                            table.render(option);
+                        }
+                    }, error: function () {
+                        layer.alert("鎺ュ彛璇锋眰澶辫触!", { icon: 5 });
+                    }
+                })
+            }
+            //#endregion
+            //#region 淇濆瓨鏂规硶鏍¢獙
+            function AllowLoadData(data) {
+
+                var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
+                var ref1 = /^-?\d+(\.\d+)?$/;          //鍒ゆ柇瀛楃涓叉槸鍚︿负鏁板瓧(鍖呭惈鏁存暟銆佹诞鐐规暟)锛屾鍒欒〃杈惧紡
+                var temp = "";
+
+                if ($("#HBillNo").val() == "") {
+                    layer.msg("鍗曟嵁鍙锋湭璁剧疆锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                    return;
+                }
+
+                if ($("#HDate").val() == "") {
+                    layer.msg("鏃ユ湡鏈缃紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                    return;
+                }
+
+                //if ($("#HWHID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨浠撳簱锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+                //if ($("#HManagerID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨璐熻矗浜猴紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+                if ($("#HEmpID").val() == 0 || $("#HEmpID").val() == "" ) {
+                    layer.msg("璇烽�夋嫨涓氬姟鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                    return;
+                }
+                //if ($("#HKeeperID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨淇濈鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+                if ($("#HSecManagerID").val() == 0 || $("#HSecManagerID").val()=="") {
+                    layer.msg("璇烽�夋嫨楠屾敹鍛橈紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                    return;
+                }
+                if ($("#HDeptID").val() == 0 || $("#HDeptID").val() == "") {
+                    layer.msg("璇烽�夋嫨閮ㄩ棬锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                    return;
+                }
+                if ($("#HSupID").val() == 0 || $("#HSupID").val()=="") {
+                    layer.msg("璇烽�夋嫨渚涘簲鍟嗭紒", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                    return;
+                }
+                //if ($("#HPSStyleID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨閲囪喘鏂瑰紡锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+                //if ($("#HSSID").val() == 0) {
+                //    layer.msg("璇烽�夋嫨缁撶畻鏂瑰紡锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
+                //    return;
+                //}
+                //#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;
+                    }
+
+                    if (option.data[i]["HUnitID"] == "0") {
+                        layer.msg("绗�" + (i + 1) + "琛岋細璁¢噺鍗曚綅鏈�夋嫨锛�");
+                        return false;
+                    }
+
+                    //瀹炲彂鏁伴噺鏍煎紡鏍¢獙
+                    temp = option.data[i]["HQty"] + "";
+                    if (!ref1.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細瀹炲彂鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛楋紒");
+                        return false;
+                    } else if (temp * 1 == 0) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細瀹炲彂鏁伴噺璇疯緭鍏ヤ笉涓�0鐨勬暟瀛楋紒");
+                        return false;
+                    }
+
+                    //鍗曚环鏍煎紡鏍¢獙
+                    temp = option.data[i]["HPrice"] + "";
+                    if (temp == "0") {
+                        //layer.msg("绗�" + (i + 1) + "琛岋細鍗曚环涓嶈兘涓�0锛�");
+                        //return false;
+                    } else if (!ref.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                        return false;
+                    }
+
+                    //鍚◣鍗曚环鏍煎紡鏍¢獙
+                    temp = option.data[i]["HTaxPrice"] + "";
+                    if (temp == "0") {
+                        //layer.msg("绗�" + (i + 1) + "琛岋細鍚◣鍗曚环涓嶈兘涓�0锛�");
+                        //return false;
+                    } else if (!ref.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細鍚◣鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                        return false;
+                    }
+
+                    //绋庣巼鏍煎紡鏍¢獙
+                    temp = option.data[i]["HTaxRate"] + "";
+                    if (!ref.test(temp)) {
+                        layer.msg("绗�" + (i + 1) + "琛岋細绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛楋紒");
+                        return false;
+                    }
+
+                    ////閲戦鏍煎紡鏍¢獙
+                    //temp = option.data[i]["HMoney"] + "";
+                    //if (temp == "0") {
+                    //    //layer.msg("绗�" + (i + 1) + "琛岋細閲戦涓嶈兘涓�0锛�");
+                    //    //return false;
+                    //} else if (!ref.test(temp)) {
+                    //    layer.msg("绗�" + (i + 1) + "琛岋細閲戦璇疯緭鍏ュぇ浜�0鐨勬暟瀛楋紒");
+                    //    return false;
+                    //}
+                    //鏀舵枡浠撳簱闈炵┖楠岃瘉
+                    if (option.data[i]["HWHID"] == "0") {
+                        layer.msg("绗�" + (i + 1) + "琛岋細鏀舵枡浠撳簱鏈�夋嫨锛�");
+                        return false;
+                    }
+                }
+                //#endregion
+                return true;
+            }
+
+            //endregion
+
+            //#endregion
+
+            //灏唘rl鍙傛暟涓殑涓枃涔辩爜閲嶆柊杞崲鎴愪腑鏂�
+            function getParams(key) {
+                var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
+                //濡傛灉鍦板潃鏍忎腑鍑虹幇涓枃鍒欒繘琛岀紪鐮�    
+                var r = encodeURI(window.location.search).substr(1).match(reg);
+                if (r != null) {
+                    //灏嗕腑鏂囩紪鐮佺殑瀛楃閲嶆柊鍙樻垚涓枃
+                    return decodeURI(unescape(r[2]));
+                }
+                return "";
+            };
 
             //浠ヤ笂鏄痩ayui妯″潡
         });
         // 鍩虹璧勬枡杩斿洖鏁版嵁
         function GetHEmpValue(obj)  //杩斿洖涓氬姟鍛�
         {
-            $("#HEmpName").val(obj[0].HName);
+            $("#HEmpName").val(obj[0].鑱屽憳鍚嶇О);
             $("#HEmpID").val(obj[0].HItemID);
         }
 
-        function GetHSupValue(obj)  //杩斿洖渚涘簲鍟�
+        function GetHSupNameValue(obj)  //杩斿洖渚涘簲鍟�
         {
-            $("#HSupName").val(obj[0].HName);
+            $("#HSupName").val(obj[0].渚涘簲鍟嗗悕绉�);
             $("#HSupID").val(obj[0].HItemID);
         }
 
         function GetHWHValue(obj)  //杩斿洖浠撳簱
         {
-            $("#HWHName").val(obj[0].HName);
+            $("#HWHName").val(obj[0].浠撳簱鍚嶇О);
             $("#HWHID").val(obj[0].HItemID);
+
+            if (option.data.length > 0) {
+                for (var i = 0; i < option.data.length; i++) {
+                    if (option.data[i]["HWHID"] == 0 || option.data[i]["鏀舵枡浠撳簱"] == undefined) {
+                        option.data[i]["HWHID"] = obj[0].HItemID;
+                        option.data[i]["鏀舵枡浠撳簱"] = obj[0].浠撳簱鍚嶇О;
+                    }
+                }
+            }
+            layui.table.render(option);
         }
 
         function GetHDeptNameValue(obj)  //杩斿洖閮ㄩ棬
         {
-            $("#HDeptName").val(obj[0].HName);
+            $("#HDeptName").val(obj[0].閮ㄩ棬鍚嶇О);
             $("#HDeptID").val(obj[0].HItemID);
+        }
+
+        //椤圭洰
+        function GetProjectBillValue(data) {
+            $("#HProjectName").val(data[0].椤圭洰鍚嶇О);
+            $("#HProjectNumber").val(data[0].椤圭洰浠g爜);
+            $("#HProjectID").val(data[0].HInterID);
         }
 
         function GetHSecManagerValue(obj)  //杩斿洖楠屾敹鍛�
         {
-            $("#HSecManagerName").val(obj[0].HName);
+            $("#HSecManagerName").val(obj[0].鑱屽憳鍚嶇О);
             $("#HSecManagerID").val(obj[0].HItemID);
         }
 
         function GetHKeeperValue(obj)  //杩斿洖淇濈鍛�
         {
-            $("#HKeeperName").val(obj[0].HName);
+            $("#HKeeperName").val(obj[0].鑱屽憳鍚嶇О);
             $("#HKeeperID").val(obj[0].HItemID);
         }
 
         function GetHWorkerValue(obj)  //杩斿洖璐熻矗浜�
         {
-            $("#HManagerName").val(obj[0].HName);
+            $("#HManagerName").val(obj[0].鑱屽憳鍚嶇О);
             $("#HManagerID").val(obj[0].HItemID);
         }
+
+          //鍙屽嚮杩斿洖鐗╂枡
+         function GetGyMaterial(data) {
+             OptionData = data
+         }
+           //鍙屽嚮杩斿洖璁¢噺鍗曚綅
+        function GetUnitValue(data) {
+            OptionData = data[0]
+         }
+
+           //鍙屽嚮杩斿洖鏀舵枡浠撳簱
+         function GetGyWarehouse(data) {
+             OptionData = data[0]
+         } 
+
+
+        //鍙屽嚮杩斿洖鏀舵枡浠撲綅
+         function GetGyStockPlace(data) {
+             OptionData = data
+         } 
+
+        //#region 澶勭悊灏忔暟鏄剧ず浣嶆暟锛坉ata锛氶渶瑕佸鐞嗙殑鏁版嵁锛沶um锛氭暟鎹殑绫诲瀷(濡�1:鏁伴噺锛�2:閲戦锛�3:鍗曚环)锛�
+        function dealDoubleToFixed(data, num) {
+            //鐢ㄤ簬璁剧疆灏忔暟浣嶆暟
+            var dotLength = 0;
+
+            if (num == 1) {                                    //褰撴暟鎹负鏁伴噺鏃讹紝鏈�澶氫繚鐣�6浣嶅皬鏁�
+                //璁剧疆鏈�澶氫繚鐣�6浣嶅皬鏁�
+                dotLength = 6;
+            } else if (num == 2) {                             //褰撴暟鎹负閲戦鏃讹紝鏈�澶氫繚鐣�2浣嶅皬鏁�
+                //璁剧疆鏈�澶氫繚鐣�2浣嶅皬鏁�
+                dotLength = 2;
+            } else if (num == 3) {                             //褰撴暟鎹负鍗曚环鏃讹紝鏈�澶氫繚鐣�4浣嶅皬鏁�
+                //璁剧疆鏈�澶氫繚鐣�4浣嶅皬鏁�
+                dotLength = 4;
+            }
+
+            //鍒ゆ柇鏄惁瀛樺湪灏忔暟鐐瑰強鍏剁储寮曚綅缃�
+            data = data + "";
+            var index = data.indexOf(".");
+
+            //澶勭悊鏁版嵁骞惰繑鍥�
+            if (index < 0) {
+                return data * 1;
+            } else {
+                //鑾峰彇灏忔暟浣嶆暟
+                var length = data.length - index - 1;
+                if (length <= dotLength) {
+                    return data * 1;
+                } else {
+                    data = data * 1;
+                    return data.toFixed(dotLength);
+                }
+            }
+        }
+            //#endregion
     </script>
 </body>
 </html>
\ No newline at end of file

--
Gitblit v1.9.1