From cb2fc709d4e2aec6bbea3e6f4e8ccc24f3d27756 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期日, 06 十月 2024 17:27:08 +0800
Subject: [PATCH] 工艺路线工价

---
 WebTM/views/销售管理/销售合同/Add_Edit_Xs_ContractBillList.html |  375 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 339 insertions(+), 36 deletions(-)

diff --git "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\345\220\210\345\220\214/Add_Edit_Xs_ContractBillList.html" "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\345\220\210\345\220\214/Add_Edit_Xs_ContractBillList.html"
index a142d58..2db280f 100644
--- "a/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\345\220\210\345\220\214/Add_Edit_Xs_ContractBillList.html"
+++ "b/WebTM/views/\351\224\200\345\224\256\347\256\241\347\220\206/\351\224\200\345\224\256\345\220\210\345\220\214/Add_Edit_Xs_ContractBillList.html"
@@ -260,6 +260,8 @@
                                     <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="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>搴撳瓨鏌ヨ</button>
+                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>鍑哄叆搴撹褰曟煡璇�</button>
                                         <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>鍒楄缃�</button>
                                     </div>
                                 </script>
@@ -436,6 +438,12 @@
                             //checkRefresh();
                         }
                         break;
+                    //搴撳瓨鏌ヨ
+                    case 'get_Inventory': get_Inventory();
+                        break;
+                    //鍑哄叆搴撹褰曟煡璇�
+                    case 'get_InOutSum': get_InOutSum();
+                        break;
                     //鍒楄缃�
                     //case 'set_hidecolumn':
                     //    get_hidecolumn();
@@ -570,7 +578,10 @@
                 //鏁板�兼牸寮忔牎楠屽伐鍏�
                 var ref = /^\d+(\.\d+)?$/;          //闈炶礋鏁版鍒欒〃杈惧紡
                 var temp = "";
-
+                var Dec = getDecByMaterID(obj.data.HMaterID) //鑾峰彇绮惧害
+                var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //鏁伴噺绮惧害
+                var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //鍗曚环绮惧害
+                var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //閲戦绮惧害
                 // 鍗曞厓鏍肩紪杈戜箣鍓嶇殑鍊�
                 var oldText = $(this).prev().text();
                 var value = obj.value //寰楀埌淇敼鍚庣殑鍊�
@@ -598,7 +609,12 @@
                         var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
                         var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
                         var HExRate = $("#HExRate").val();                      //姹囩巼
-
+                        //鏁板瓧绮惧害
+                        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));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
@@ -607,6 +623,7 @@
                             , HTaxMoney: HTaxMoney
                             , HlineTotal: HlineTotal
                         });
+                        table.render(option)
                         break;
                     case "HPrice":                                         //鍗曚环
                         //鏁版嵁鏍煎紡鏍¢獙
@@ -616,7 +633,7 @@
                             obj.update({
                                 HPrice: oldText
                             });
-
+                            table.render(option);
                             layer.msg("鍗曚环璇疯緭鍏ュぇ浜�0鐨勬暟瀛�!");
                             return;
                         }
@@ -629,7 +646,12 @@
                         var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
                         var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
                         var HExRate = $("#HExRate").val();                      //姹囩巼
-
+                        //鏁板瓧绮惧害
+                        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));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HQty: HQty
@@ -638,6 +660,7 @@
                             , HTaxMoney: HTaxMoney
                             , HlineTotal: HlineTotal
                         });
+                        table.render(option)
                         break;
                     case "HTaxRate":                                                       //鏁伴噺
                         //鏁版嵁鏍煎紡鏍¢獙
@@ -661,7 +684,12 @@
                         var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
                         var HlineTotal = HMoney + HTaxMoney;            //浠风◣鍚堣=閲戦+绋庨
                         var HExRate = $("#HExRate").val();                       //姹囩巼
-
+                        //鏁板瓧绮惧害
+                        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));
                         //鍚屾鏇存柊琛ㄦ牸鍜岀紦瀛樺搴旂殑鍊�
                         obj.update({
                             HTaxRate: HTaxRate * 100
@@ -1001,31 +1029,35 @@
                                     //    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爜": "", "鐗╂枡鍚嶇О": "", "瑙勬牸鍨嬪彿": "", "HUnitID": 0, "璁¢噺鍗曚綅": "", "HWHID": 0, "HWHName": "", "鏁伴噺": "", "HRemark": ""
-                                                , "HPrice": "0", "HTaxPrice": "0", "HMoney": "0", "HDiscountRate": "1", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0", "HDate": Format(new Date, "yyyy- MM - dd")
-                                            };
+                                    var TaxRate = getHTaxRateByHSupID();
 
-                                            table.cache["mainTable"].push(NewRow);
-                                            option.data = table.cache["mainTable"];
+                                    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, "璁¢噺鍗曚綅": "", "HWHID": 0, "HWHName": "", "鏁伴噺": "", "HRemark": ""
+                                                    , "HPrice": "0", "HTaxPrice": "0", "HMoney": "0", "HDiscountRate": "1", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0", "HDate": Format(new Date, "yyyy- MM - dd")
+                                                };
 
-                                            table.render(option);
+                                                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;
                                         }
-
-                                        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;
-
+                                        table.render(option);
                                     }
-                                    table.render(option);
                                     layer.closeAll();
                                     //layer.close(layer.index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
                                 }
@@ -1034,14 +1066,64 @@
                                     //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
                                 },
                                 end: function () {
-                                    obj.update({
-                                        "HMaterID": OptionData.HItemID
-                                        , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
-                                        , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
-                                        , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
-                                        , "HUnitID": OptionData.HUnitID
-                                        , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
-                                    })
+                                    //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                                    var HSupID = $("#HCusID").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_Customer/xg",
+                                            //url: "http://localhost:12761/Gy_Supplier/xg",
+                                            type: "GET",
+                                            data: {
+                                                "HInterID": HSupID
+                                            },
+                                            success: function (d) {
+                                                var HTaxRate = parseInt(d.data[0].澧炲�肩◣鐜�) * 0.01;
+                                                var HExRate = $("#HExRate").val();                      //姹囩巼
+                                                //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                                                var HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                                var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                                var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                                var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
+                                                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));
+
+                                                obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                                    "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                                    , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                                    , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                                    , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                                    , "HUnitID": OptionData.HUnitID
+                                                    , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                                    , "HTaxRate": HTaxRate * 100
+                                                    , HQty: HQty                               //鏇存柊HQty瀛楁锛孒Qty
+                                                    , HPrice: HPrice                         //鏇存柊HPrice瀛楁锛孒Price
+                                                    , HMoney: HMoney                      //鏇存柊HMoney瀛楁锛孒Money
+                                                    , HTaxMoney: HTaxMoney                  //鏇存柊HTaxMoney瀛楁锛孒TaxMoney
+                                                    , HlineTotal: HlineTotal             //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                                })
+                                            }
+                                        });
+                                    } else if (typeof (OptionData.HItemID) != "undefined") {
+                                        obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                            "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                            , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                            , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                            , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                            , "HUnitID": OptionData.HUnitID
+                                            , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                        })
+                                    }
+
                                 }
                             });
                         }
@@ -1081,8 +1163,7 @@
                                 }
                             })
                         }
-                        //璐у竵(TODO 鏈塨ug鍦ㄥ脊鍑烘鎺掑簭浠ュ悗纭畾锛岄�変腑鍏冪礌杩樻槸鍘熸潵浣嶇疆鐨勶紙闇�瑕佸湪璐у竵璧勬枡涓庤閲忓崟浣嶈祫鏂欎腑璁剧疆鎺掑簭浠g爜濡傜墿鏂欓〉闈級)
-                        //TODO 涓庤揣甯佸拰璁¢噺鍗曚綅鍘熼〉闈㈤渶瑕佽缃弻鍑讳簨浠�
+                        //璐у竵
                         if (obj.event == "HCurID") {
                             layer.open({
                                 type: 2//寮圭獥绫诲瀷
@@ -1121,7 +1202,180 @@
                     }
 
                 })
+                //鍙屽嚮
+                $('.layui-table-box tbody td[data-field="鐗╂枡浠g爜"]').off('dblclick').on('dblclick', function () {
+                    //鐗╂枡
+                    if (obj.event == "HMaterID") {
+                        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");//鑾峰彇閫変腑鐨勬暟鎹�
+
+                                //if (checkStatus.data.length != 1) {
+                                //    return layer.msg("璇烽�夋嫨涓�鏉℃暟鎹�");
+                                //}
+                                OptionData = checkStatus.data[0];
+                                var TaxRate = getHTaxRateByHSupID();
+                                
+                                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, "璁¢噺鍗曚綅": "", "HWHID": 0, "HWHName": "", "鏁伴噺": "", "HRemark": ""
+                                                , "HPrice": "0", "HTaxPrice": "0", "HMoney": "0", "HDiscountRate": "1", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0", "HDate": Format(new Date, "yyyy- MM - dd")
+                                            };
+
+                                            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;
+                                    }
+                                    table.render(option);
+                                }
+                                layer.closeAll();
+                                //layer.close(layer.index); //瀹冭幏鍙栫殑濮嬬粓鏄渶鏂板脊鍑虹殑鏌愪釜灞傦紝鍊兼槸鐢眑ayer鍐呴儴鍔ㄦ�侀�掑璁$畻鐨�
+                            }
+                            , btn2: function (index, layero) {
+                                //鎸夐挳銆愭寜閽簩銆戠殑鍥炶皟
+                                //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴
+                            },
+                            end: function () {
+                                //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                                var HSupID = $("#HCusID").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_Customer/xg",
+                                        //url: "http://localhost:12761/Gy_Supplier/xg",
+                                        type: "GET",
+                                        data: {
+                                            "HInterID": HSupID
+                                        },
+                                        success: function (d) {
+                                            var HTaxRate = parseInt(d.data[0].澧炲�肩◣鐜�) * 0.01;
+                                            var HExRate = $("#HExRate").val();                      //姹囩巼
+                                            //鏁版嵁鏍¢獙鍚堟牸锛岄噸绠楄褰�
+                                            var HQty = obj.data.HQty * 1;                           //鏁伴噺
+                                            var HPrice = obj.data.HPrice * 1;               //鍗曚环
+                                            var HMoney = HQty * HPrice;                     //閲戦=鏁伴噺*鍗曚环
+                                            var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //绋庨=閲戦*绋庣巼
+                                            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));
+
+                                            obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                                "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                                , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                                , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                                , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                                , "HUnitID": OptionData.HUnitID
+                                                , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                                , "HTaxRate": HTaxRate * 100
+                                                , HQty: HQty                               //鏇存柊HQty瀛楁锛孒Qty
+                                                , HPrice: HPrice                         //鏇存柊HPrice瀛楁锛孒Price
+                                                , HMoney: HMoney                      //鏇存柊HMoney瀛楁锛孒Money
+                                                , HTaxMoney: HTaxMoney                  //鏇存柊HTaxMoney瀛楁锛孒TaxMoney
+                                                , HlineTotal: HlineTotal             //鏇存柊HlineTotal瀛楁锛孒lineTotal
+                                            })
+                                        }
+                                    });
+                                } else if (typeof (OptionData.HItemID) != "undefined"){
+                                    obj.update({ //鏇存柊琛ㄦ牸鏁版嵁
+                                        "HMaterID": OptionData.HItemID             //璁剧疆HItemID鐨勫�间负鈥淗BillNo鈥濆瓧娈电殑鍊糎ItemID`鐨勫��
+                                        , "鐗╂枡浠g爜": OptionData.鐗╂枡浠g爜
+                                        , "鐗╂枡鍚嶇О": OptionData.鐗╂枡鍚嶇О
+                                        , "瑙勬牸鍨嬪彿": OptionData.瑙勬牸鍨嬪彿
+                                        , "HUnitID": OptionData.HUnitID
+                                        , "璁¢噺鍗曚綅": OptionData.璁¢噺鍗曚綅鍚嶇О
+                                    })
+                                }
+
+                            }
+                        });
+                    }
+                });
             }
+
+            //#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
 
             //琛屽唴鍒犻櫎
             function set_GridDelete(obj) {
@@ -1290,6 +1544,55 @@
             }
             //#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 閫氳繃瀹㈡埛id鑾峰彇绋庣巼
+            function getHTaxRateByHSupID() {
+                var HTaxRate;
+                //閫氳繃渚涘簲鍟唅d鑾峰彇绋庣巼
+                var HSupID = $("#HCusID").val();
+                if (HSupID != 0) {
+                    $.ajax({
+                        url: GetWEBURL() + "/Gy_Customer/xg",
+                        type: "GET",
+                        async: false,
+                        data: {
+                            "HInterID": HSupID
+                        },
+                        success: function (d) {
+                            HTaxRate = parseInt(d.data[0].澧炲�肩◣鐜�);
+                        }
+                    });
+                } else {
+                    HTaxRate = 0;
+                }
+                return HTaxRate;
+            }
+            //#endregion
 
             //#region 淇濆瓨鍚庢祻瑙堟柟娉�
             function ReRoadBillMain() {

--
Gitblit v1.9.1