From a005e2e61fe87c43436febfd6103bba21b232a7e Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 26 四月 2024 14:20:01 +0800
Subject: [PATCH] 计划平台优化

---
 WebTM/views/验收入库/外购入库/Add_Edit_Kf_POStockInBillList.html | 1061 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 854 insertions(+), 207 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 e321a93..bd92cde 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,8 @@
                 <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="Exit">閫�鍑�</button>
                         </div>
                     </div>
@@ -100,7 +102,7 @@
                                         <div class="layui-col-xs4 layui-inline">
                                             <label class="layui-form-label">涓氬姟鍛�</label>
                                             <div class="layui-input-inline">
-                                                <input type="text" name="HEmpName" id="HEmpName"  class="layui-input" value="" style="float:left;width:150px;">
+                                                <input type="text" name="HEmpName" id="HEmpName" class="layui-input" value="" style="float:left;width:150px;">
                                                 <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value=0 style="float:left;width:150px;">
                                                 <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                     <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -165,15 +167,15 @@
                                             <label class="layui-form-label">閫夊崟鍙�</label>
                                             <div class="layui-input-inline">
                                                 <input type="text" name="" id="" class="layui-input" value="" style="float:left;width:150px;">
-                                                
+
                                                 <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>
                                             <!--<label class="layui-form-label">閫夊崟鍙�</label>
-                                            <div class="layui-input-inline">
-                                                <input class="layui-input" name="Box2" id="Box2" autocomplete="off">
-                                            </div>-->
+            <div class="layui-input-inline">
+                <input class="layui-input" name="Box2" id="Box2" autocomplete="off">
+            </div>-->
                                         </div>
                                         <div class="layui-col-xs4 layui-inline">
                                             <label class="layui-form-label">璐熻矗浜�</label>
@@ -189,20 +191,52 @@
 
                                     </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">
+                                            <label class="layui-form-label">鍙戠エ缂栧彿</label>
+                                            <div class="layui-input-inline">
+                                                <input class="layui-input" name="HInvoiceBillNo" id="HInvoiceBillNo" autocomplete="off">
+                                            </div>
+                                        </div>
+                                        <div class="layui-col-xs4 layui-inline">
+                                            <label class="layui-form-label">椤圭洰缂栫爜</label>
+                                            <div class="layui-input-inline">
+                                                <input type="text" name="HProjectNumber" id="HProjectNumber" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
+                                                <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">
+                                            <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">
+
+        <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 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">
                                             </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-inline">
+                                        <label class="layui-form-label" style="width: 85px;">缁勭粐</label>
+                                        <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
+                                            <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
+                                                <!--鍔ㄦ�佹覆鏌撶粍缁�-->
+                                            </select>
                                         </div>
                                     </div>
                                 </div>
@@ -259,7 +293,7 @@
                                                 <input type="text" class="layui-input" name="HCheckDate" id="HCheckDate" style="background-color:#efefef4d;" readonly>
                                             </div>
                                         </div>
-                                        <div class="layui-inline" >
+                                        <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="HCloseDate" id="HCloseDate" style="background-color:#efefef4d;" readonly>
@@ -331,98 +365,104 @@
 
 
             //#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]];//婧愬崟绫诲瀷
             }
 
- 
-            //鍒ゆ柇鎿嶄綔绫诲瀷
-            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);
+
                 //缂栬緫鐘舵�佹椂锛屾牴鎹唴鐮侊紝鑾峰彇淇℃伅骞跺啓鍏ョ晫闈�
                 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": "", "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, 
+                "HSourceBillNo": 0, "HSourceBillType": 0, "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": "", "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
                 };
                 switch (obj.event) {
                     case 'btn-AddLine':
@@ -466,6 +506,10 @@
                 Pub_Close(1);
             })
 
+           //#region 瀹℃牳鎸夐挳
+            form.on('submit(set_CheckBill)', function (data) {
+                set_CheckBill(0);
+            });
             //閫夋嫨涓氬姟鍛樻寜閽�
             form.on('submit(HEmpList)', function () {
                 get_checkEmp();
@@ -474,6 +518,11 @@
             form.on('submit(HSupList)', function () {
                 get_checkSup();
             });
+            //閫夋嫨宸ョ▼椤圭洰
+            form.on('submit(btnHProjectID)', function () {
+                get_btnHProjectID();
+            });
+
             //閫夋嫨閮ㄩ棬鎸夐挳
             form.on('submit(HWHList)', function () {
                 get_checkWH();
@@ -494,12 +543,6 @@
             //閫夋嫨涓荤鎸夐挳
             form.on('submit(HManagerList)', function () {
                 get_checkManager();
-            });
-
-
-            //淇濆瓨鎸夐挳
-            form.on('submit(set_SaveBill)', function (data) {
-                set_SaveBill(data);
             });
 
             //琛屽唴浜嬩欢
@@ -561,14 +604,27 @@
                         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 = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
 
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
                             , HPrice: HPrice
                             , HMoney: HMoney
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
                         });
                         /* table.render(option);*/
                         break;
@@ -590,13 +646,27 @@
                         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 = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
 
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
                             , HPrice: HPrice
                             , HMoney: HMoney
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HlineTotal: HlineTotal
                         });
                         break;
                     case "HMoney":                                         //閲戦
@@ -617,16 +687,76 @@
                         var HQty = obj.data.HQty * 1;                   //鏁伴噺
                         var HMoney = value * 1;
                         var HPrice = (HMoney / HQty).toFixed(2);       //鍗曚环=閲戦/鏁伴噺
+                        var HTaxRate = value * 0.01;                       //绋庣巼
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        HQty = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
 
 
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
                             , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
                             , HMoney: HMoney
+                            , HlineTotal: HlineTotal
                         });
                         break;
                         table.render(option);
+                    case "HTaxRate":                                                       //鏁伴噺
+                        //鏁版嵁鏍煎紡鏍¢獙
+                        temp = value + "";
+                        if (!ref.test(temp)) {
+                            //鎭㈠鏁版嵁鍒扮紪杈戝墠
+                            obj.update({
+                                HTaxRate: oldText
+                            });
+                            table.render(option);
+
+                            layer.msg("绋庣巼璇疯緭鍏ヤ笉灏忎簬0鐨勬暟瀛�!");
+                            return;
+                        }
+
+
+                        //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                        var HQty = obj.data.HQty * 1;                   //鏁伴噺
+                        var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                        var HTaxRate = value * 0.01;                       //绋庣巼
+                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //鎶樻墸鐜�*/
+                        var HTaxPrice = HPrice * (1 + HTaxRate);        //鍚◣鍗曚环=鍗曚环*(1+绋庣巼)
+                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //瀹為檯鍚◣鍗曚环=鍚◣鍗曚环*鎶樻墸鐜�*/
+                        //鎶樻墸棰� = 鍚◣鍗曚环 * (1 - 鎶樻墸鐜�) * 鏁伴噺
+                        var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                        var HTaxMoney = HMoney * HTaxRate;              //绋庨=閲戦*绋庣巼
+                        var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
+
+                        //璁剧疆鏁版嵁灏忔暟浣嶆暟
+                        HQty = dealDoubleToFixed(HQty, 1);
+                        HPrice = dealDoubleToFixed(HPrice, 3);
+                        HTaxRate = HTaxRate;
+                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
+                        HMoney = dealDoubleToFixed(HMoney, 2);
+                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
+
+                        //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
+                        obj.update({
+                            HQty: HQty
+                            , HPrice: HPrice
+                            , HTaxRate: HTaxRate * 100
+                            , HTaxPrice: HTaxPrice
+                            , HMoney: HMoney
+                            , HlineTotal: HlineTotal
+                        });
+                        //table.render(option);
+                        break;
                     default:
                 }
             });
@@ -648,27 +778,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) {
@@ -693,30 +824,32 @@
                     , limit: 500
                     , height: 500
                     , loading: false
+                    , totalRow: true
                     , cols: [[ //瀛愯〃
                         { type: 'checkbox', totalRowText: '鍚堣琛�' }
-                        , { type: 'numbers', title: '搴忓彿', width: 100, totalRow: true }
+                        , { type: 'numbers', title: '搴忓彿', width: 100 }
                         , { type: 'HSourceBillNo', title: '婧愬崟鍙�', width: 100, hide: true }//婧愬崟鍙�
                         , { field: 'HSourceBillType', title: '婧愬崟绫诲瀷', width: 100, hide: true }//婧愬崟绫诲瀷
                         , { type: '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: 'HQtyMust', title: '搴旀敹鏁伴噺', width: 150, edit: 'text', totalRow: true}
+                        , { field: 'HQty', title: '瀹炴敹鏁伴噺', width: 150, edit: 'text', totalRow: true}
                         , { field: 'HPrice', title: '鍗曚环', width: 100, edit: 'text' }
-                        , { field: 'HMoney', title: '閲戦', width: 100, edit: 'text' }
-                        , { field: 'HOrderPrice', title: '閲囪喘閲戦', width: 100, edit: 'text' }
+                        , { field: 'HMoney', title: '閲戦', width: 100, edit: 'text', totalRow: true }
+                        , { field: 'HOrderPrice', title: '閲囪喘閲戦', width: 100, edit: 'text', 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, edit: 'text' }
+                        , { field: 'HTaxPrice', title: '鍚◣鍗曚环', width: 100, edit: 'text' }
+                        , { 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 }
@@ -750,7 +883,7 @@
                                 , "HEmpID": data.HEmpID
                                 , "HEmpName": data.涓氬姟鍛�
                                 , "HWHID": data.HWHID
-                                , "HWHName": data.鏀舵枡浠撳簱
+                                , "HWHName": data.涓昏〃浠撳簱
                                 , "HSecManagerID": data.HSecManagerID
                                 , "HSecManagerName": data.楠屾敹鍛�
                                 , "HKeeperID": data.HKeeperID
@@ -761,6 +894,11 @@
                                 , "HManagerID": data.HManagerID
                                 , "HManagerName": data.璐熻矗浜�
                                 , "HExRate": data.姹囩巼
+                                , "HProjectID": data.HProjectID
+                                , "HProjectNumber": data.椤圭洰浠g爜
+                                , "HProjectName": data.椤圭洰鍚嶇О
+                                , "HInvoiceBillNo": data.鍙戠エ缂栧彿
+                                , "HExplanation ":data.鎽樿
                                 //, "Box2": ""
                                 , "HRemark": data.琛ㄥご澶囨敞
                                 , "HMaker": data.鍒跺崟浜�
@@ -771,7 +909,7 @@
                                 , "HCloseDate": data.鍏抽棴鏃ユ湡
                                 , "HUpDateDate": data.淇敼鏃ユ湡
                                 , "HDeleteDate": data.浣滃簾鏃ユ湡
-                   
+
                             });
                             //瀛愯〃  璧嬪��
                             subdata=result.data
@@ -779,13 +917,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].鎵规,
                                         "HSourceBillNo": subdata[i].婧愬崟鍗曞彿,    //婧愬崟鍙�
                                         "HSourceBillType": subdata[i].婧愬崟绫诲瀷,   //婧愬崟绫诲瀷
                                         "HSourceInterID": subdata[i].婧愬崟涓诲唴鐮�,   //婧愬崟涓诲唴鐮�
-                                        "HSourceEntryID": subdata[i].婧愬崟瀛愬唴鐮�     //婧愬崟瀛愬唴鐮�
+                                        "HSourceEntryID": subdata[i].婧愬崟瀛愬唴鐮�,     //婧愬崟瀛愬唴鐮�
+                                        "HTaxRate": subdata[i].绋庣巼, "HTaxPrice": subdata[i].鍚◣鍗曚环, "HlineTotal": subdata[i].鍚◣閲戦
                                     }
                                 )
                             }
@@ -805,7 +944,7 @@
                 });
             }
             //#endregion
-       
+
             //閫�鍑�
             form.on('submit(Exit)', function (data) {
                 if (linterid == undefined) {
@@ -818,15 +957,293 @@
                 }
             });
 
-           
-           
+      //#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) {
+                                        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) {
+                                        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].閮ㄩ棬
+                        , "HMangerID": dataArray[0].HManagerID
+                        , "HMangerName": 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].閲囪喘鏂瑰紡
+                    });
+
+                    //瀛愯〃  璧嬪��
+                    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
+                        , "HMangerName": dataArray[0].涓荤
+                        , "HEmpID": dataArray[0].HEmpID
+                        , "HEmpName": dataArray[0].涓氬姟鍛�
+                        , "HSupID": dataArray[0].HSupID
+                        , "HSupName": dataArray[0].渚涘簲鍟�
+                        , "HCurID": dataArray[0].HCurID
+                        , "HCurName": dataArray[0].甯佸埆
+                        , "HExRate": dataArray[0].姹囩巼
+                        , "HSSID": "0"
+                        , "HSSName": ""
+                        , "HPSStyleID": dataArray[0].HPSStyleID
+                        , "HPSStyleSName": 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].鏁伴噺 * 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 ($("#HDeptName").val() == 0) {
                     layer.msg("璇烽�夋嫨閮ㄩ棬锛�", { icon: 5, btn: ['纭'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "娓╅Θ鎻愮ず" });
                     return;
@@ -873,8 +1290,8 @@
 
                     message += '锛岃鍒犻櫎鍏朵腑涓�琛�';
                     layer.alert(message);
-                } 
-                
+                }
+
 
                 var sMainStr = JSON.stringify(data.field);
                 var sSubStr = JSON.stringify(num);
@@ -908,7 +1325,7 @@
                 });
             }
             //#endregion
-          
+
             ////#endregion
 
             function get_checkEmp() {
@@ -918,19 +1335,19 @@
                     , 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', '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() {
@@ -940,7 +1357,7 @@
                     , area: ['90%', '90%']//澶у皬
                     , title: '渚涘簲鍟嗗垪琛�'//鏍囬
                     , shift: 2//寮瑰嚭鍔ㄧ敾
-                    , content: ['../../鍩虹璧勬枡/閲囪喘鍩虹璧勬枡/Gy_Supplier.html', 'yes']
+                    , content: ['../../鍩虹璧勬枡/閲囪喘鍩虹璧勬枡/Gy_Supplier.html?Type=HSup', 'yes']
                     , btn: ['纭畾', '鍙栨秷']
                     , btn1: function (index, layero) {//鎸夐挳銆愭寜閽竴銆戠殑鍥炶皟
                         var iframeWindow = window['layui-layer-iframe' + index]  //鑾峰彇寮规椤甸潰
@@ -955,6 +1372,30 @@
                     , btn2: function (index, layero) { }
                 })
             }
+            //宸ョ▼椤圭洰
+            function get_btnHProjectID() {
+                layer.open({
+                    type: 2//寮圭獥绫诲瀷
+                    , skin: 'layui-layer-rim' //鍔犱笂杈规
+                    , area: ['90%', '90%']//澶у皬
+                    , title: '椤圭洰鍒楄〃'//鏍囬
+                    , shift: 2//寮瑰嚭鍔ㄧ敾
+                    , content: ['../../椤圭洰绠$悊/宸ョ▼椤圭洰/PM_ProjectBillList.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('璇烽�夋嫨鏁版嵁');
+                        }
+                        $("#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() {
                 layer.open({
                     type: 2//寮圭獥绫诲瀷
@@ -962,19 +1403,30 @@
                     , 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', '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() {
@@ -984,19 +1436,19 @@
                     , 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', '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() {
@@ -1006,19 +1458,19 @@
                     , 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', '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() {
@@ -1028,19 +1480,19 @@
                     , 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', '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) { }
                 })
             }
 
@@ -1051,22 +1503,48 @@
                     , 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', '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) {
@@ -1074,6 +1552,7 @@
                     if (event.key == "F7") {
                         //鐗╂枡
                         if (obj.event == "HMaterID") {
+                                var HOrgID = $("#HOrgID").val();
                             layer.open({
                                 type: 2
                                 , skin: "layui-layer-rim" //鍔犱笂杈规
@@ -1082,7 +1561,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) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1093,16 +1572,17 @@
                                     //    return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
                                     //}
 
-
+                                    OptionData = checkStatus.data[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": "",
+                                                "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);
@@ -1141,6 +1621,14 @@
                                     //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
                                 },
                                 end: function () {
+                                    obj.update({
+                                        "HMaterID": OptionData.HItemID
+                                        ,"鐗╂枡浠g爜" : OptionData.鐗╂枡浠g爜
+                                       , "鐗╂枡鍚嶇О" :OptionData.鐗╂枡鍚嶇О
+                                        ,"瑙勬牸鍨嬪彿" : OptionData.瑙勬牸鍨嬪彿
+                                        ,"HUnitID" :OptionData.HUnitID
+                                        ,"璁¢噺鍗曚綅" : OptionData.璁¢噺鍗曚綅鍚嶇О
+                                })
                                 }
                                 });
                         }
@@ -1154,7 +1642,7 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_UnitList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Unit.html', 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1166,11 +1654,17 @@
                                     }
                                     //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
                                     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.璁¢噺鍗曚綅鍚嶇О
+                                })
+                            }
                             })
                         }
                         //鏀舵枡浠撳簱
@@ -1183,7 +1677,7 @@
                                 , shift: 2 //寮瑰嚭鍔ㄧ敾
                                 , area: ["90%", "90%"] //绐椾綋澶у皬
                                 , maxmin: true //璁剧疆鏈�澶ф渶灏忔寜閽槸鍚︽樉绀�
-                                , content: ['../../Baseset/鍩虹璧勬枡/Gy_WarehouseList.html', 'yes']
+                                , content: ['../../鍩虹璧勬枡/鍏敤鍩虹璧勬枡/Gy_Warehouse.html?type=Warehouse', 'yes']
                                 , btn: ["纭畾", "鍙栨秷"]
                                 , btn1: function (index, laero) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1193,16 +1687,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
@@ -1212,7 +1713,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) {
                                     //鎸夐挳涓�  鐨勫洖璋�
@@ -1224,11 +1725,17 @@
                                     }
                                     //鏇存柊琛ㄦ牸缂撳瓨鐨勬暟鎹�
                                     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.浠撲綅鍚嶇О
+                                })
+                            }
                             })
                         }
                     }
@@ -1257,12 +1764,15 @@
 
             //琛ㄥご淇℃伅閫夋嫨鍗曟嵁寮圭獥
             form.on('submit(XDHList)', function () {
-
-                if ($("#HSourceBillType").val() == 0 || $("#HSourceBillType").val() == null) {
-                    return layer.msg('璇烽�夋嫨鍗曟嵁绫诲瀷');
+            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('褰撳墠涓嶆敮鎸佽婧愬崟閫夋嫨锛侊紒');
                 }
-                var url = getSupType().url;
-                url = encodeURI(url);
 
                 //椤甸潰灞�-鑷畾涔�
                 layer.open({
@@ -1294,39 +1804,48 @@
                         var NowNum = 0;
                         NowNum = option.data.length;
 
+                        $("#HProjectName").val(checkStatus.data[0].椤圭洰鍚嶇О);
+                        $("#HProjectNumber").val(checkStatus.data[0].椤圭洰浠g爜);
+                        $("#HProjectID").val(checkStatus.data[0].HProjectID);
+
                         if (getSupType().name == "閲囪喘璁㈠崟") {
+                           
                             var j = 0;
                             for (var i = 0; i < checkStatus.data.length; i++) {
                                 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].璁¢噺鍗曚綅,
-                                    "HQty": checkStatus.data[j].鏁伴噺, "HPrice": checkStatus.data[j].鍗曚环,
+                                    "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅,"HWHID": checkStatus.data[j].HWHID, "鏀舵枡浠撳簱": checkStatus.data[j].鏀舵枡浠撳簱,
+                                    "HSPID": checkStatus.data[j].HSPID, "浠撲綅鍚嶇О": checkStatus.data[j].浠撲綅鍚嶇О,
+                                    "HQty": checkStatus.data[j].鏁伴噺-checkStatus.data[j].鍏宠仈鏁伴噺, "HPrice": checkStatus.data[j].鍗曚环,
                                     "HMoney": 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": checkStatus.data[j].浠风◣鍚堣
                                 })
                                 j++;
                             }
                             table.render(option);
                             layer.close(index);
-                        } else if (getSupType().name =="鏀舵枡閫氱煡鍗�") {
+                        } else if (getSupType().name == "鏀舵枡閫氱煡鍗�") {
+                         
                             var j = 0;
                             for (var i = 0; i < ProcessNumber.length; i++) {
                                 option.data.push({
                                     "HMaterID": checkStatus.data[j].HMaterID, "鐗╂枡浠g爜": checkStatus.data[j].鐗╂枡浠g爜, "鐗╂枡鍚嶇О": checkStatus.data[j].鐗╂枡鍚嶇О, "瑙勬牸鍨嬪彿": checkStatus.data[j].瑙勬牸鍨嬪彿,
-                                    "   ": 0, "鐗╂枡杈呭姪灞炴��": "", "HUnitID": checkStatus.data[j].HUnitID, "璁¢噺鍗曚綅": checkStatus.data[j].璁¢噺鍗曚綅, "HQtyMust": "", "HQty": checkStatus.data[j].鏁伴噺, "HRemark": "",
+                                    "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": checkStatus.data[j].閲戦, "HOrderPrice": "0", "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": (checkStatus.data[j].閲戦 + (checkStatus.data[j].閲戦 * checkStatus.data[j].绋庣巼))
                                 })
                                 j++;
                             }
                             table.render(option);
                             layer.close(index);//鍏抽棴寮圭獥
                         }
-                        
+
                     }
-                       
+
                 });
             });
             //鍒ゆ柇鎵�閫夌潃涓庤〃鏍兼槸鍚︽湁閲嶅鏁版嵁
@@ -1409,7 +1928,7 @@
                 $.ajax({
                     type: "get",
                     async: false,
-                    data: { "HName": HName },
+                    data: { "HName": HName, "Num": 2 },       //0钃濆崟 1绾㈠崟 2涓嶅垎绾㈣摑鍗�
                     url: GetWEBURL() + "/Web/GetHSourceBillType",
                     success: function (result) {
                         var HSourceBillTypes = "";
@@ -1426,6 +1945,61 @@
             }
             //#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 () {
+                        res = "none";
+                        layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                    }
+                });
+                return res;
+            }
+            //#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 () {
+                        res = "none";
+                        layer.alert("鍙戠敓閿欒!", { icon: 5 });
+                    }
+                });
+                return res;
+            }
+            //#endregion
             //#endregion
 
 
@@ -1434,45 +2008,118 @@
         // 鍩虹璧勬枡杩斿洖鏁版嵁
         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 GetGyUnit(data) {
+             OptionData = data
+         }
+
+           //鍙屽嚮杩斿洖鏀舵枡浠撳簱
+         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