WebTM/views/²É¹º¹ÜÀí/²É¹º¶©µ¥/Cg_POOrderBillEdit.html
@@ -46,6 +46,7 @@
                    <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="check-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">审核</button>
                            <button type="button" id="print-btn" class="layui-btn layui-btn-normal layui-btn-radius layui-btn-disabled" lay-submit="" lay-filter="get_PrintReport" disabled>打印</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
                        </div>
@@ -65,7 +66,7 @@
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">单据号<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;">
                                                <input type="hidden" name="HInterID" id="HInterID" value="0">
                                                <input type="hidden" name="HSTOCKORGID" id="HSTOCKORGID" lay-verify="HSTOCKORGID" value="0">
                                            </div>
@@ -355,6 +356,12 @@
    </script>
    <script>
        //#region æ–‡æœ¬æ¡†è¾“入搜索相关数据-变量
        var childPage = null;                       //获取子窗口对象,用于操作子窗口的变量和方法
        var currRowIndex = 0;                       //用于定位子窗口当前选中的行
        var childData = null;                       //用于获取子窗口返回的数据
        //#endregion
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
        layui.config({
@@ -432,7 +439,10 @@
                })
            }
            //#endregion
            //判断页面打开方式
            if (OperationType == null || OperationType == "" || typeof (params[params[0]]) == "undefined") {
                OperationType = 1;//操作类型初始化
            }
            //判断是否新增
            if (linterid == null || linterid == 0) {    //判断 linterid å˜é‡æ˜¯å¦ä¸ºç©ºæˆ–者等于0
@@ -543,6 +553,12 @@
            });
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region å®¡æ ¸æŒ‰é’®
            form.on('submit(set_CheckBill)', function (data) {
                set_CheckBill(0);
            });
            //#endregion
            //退出按钮
            form.on('submit(Exit)', function () {
@@ -1236,7 +1252,7 @@
                                    //关闭当前frame
                                    layer.close(index);
                                });
                                $('#check-btn').addClass("layui-btn-disabled").attr("disabled", true);// ç¦ç”¨å®¡æ ¸æŒ‰é’®
                            } else {
                                layer.alert(result.code + result.Message, { icon: 5 });
                            }
@@ -1301,6 +1317,233 @@
            function set_GridCellCheck(obj) {       //定义了一个名为set_GridCellCheck的函数,它接受一个参数obj    
                //使用$(document).off('keydown', ".layui-table-edit")来移除(如果存在的话)之前绑定到文档中所有.layui-table-edit类元素上的keydown事件监听器
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {  
                    //#region å­è¡¨æ–‡æœ¬æ¡†è¾“入后检索数据
                    if (event.key != "F7") {
                        var errKeys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Enter"];
                        //根据子表设置的event,触发相应弹窗=================================================================================================
                        if (obj.event == "HMaterID") {                           //定位当前正在输入的文本框的列名
                        //==========================================================================================================
                            if ($.inArray(event.key, errKeys) == -1) {              //如果按下的键位不是 æ–¹å‘键,则刷新弹窗中的数据
                                if (childPage == null) {                            //判断当前子窗口是否已经打开,若未打卡,则打开页面,并获取子窗口的对象
                                    var offset = $(this).offset();                  //获取触发事件的元素的位置,用于定位子窗口打开的位置
                                    var innerHeight = window.innerHeight;
                                    var top = offset.top + 0.05 * innerHeight;
                                    var left = offset.left;
                                    if (top + 0.05 * innerHeight + 0.3 * innerHeight > innerHeight) {
                                        top = top - 0.3 * innerHeight - 0.05 * innerHeight;
                                    }
                                    layer.open({
                                        type: 2                                                                                     //弹窗类型
                                        , skin: 'layui-layer-rim'                                                                   //加上边框
                                        , area: ['25%', '30%']                                                                      //大小
                                        , shadeClose: true                                                                          //点击遮罩时关闭弹窗
                                        , offset: [top, left]
                                        , title: false                                                                              //不显示标题栏
                                        //, title: '项目费用列表'                                                                     //标题
                                        , shift: 2                                                                                  //弹出动画
                                        , closeBtn: 0                                                                               //禁用关闭按钮
                                        , content: ["../../基础资料/通用基础资料/Gy_CommonBaseData.html?OperationType=2", "yes"]
                                        , success: function (layero, index) {
                                            setTimeout(function () {
                                                //修改,根据文本框数据,编写查询语句=========================================================================================================
                                                var value = $(e.currentTarget).val().replace(/'/g, "");                                  //获取文本框最新值
                                                currRowIndex = 0;
                                                var tableView = "h_v_Gy_MaterialList";
                                                var childSWhere = "select top(10) HItemID,物料代码,物料名称,规格型号,HUnitID,计量单位名称 from " + tableView + " where 1=1 and ç»„织名称 = '" + sessionStorage["Organization"] + "' and (物料代码 like '%" + value + "%' or ç‰©æ–™åç§° like '%" + value + "%') order by ç‰©æ–™ä»£ç  desc";
                                                childPage.getData(childSWhere, tableView);
                                                //====================================================================================================================================
                                            }, 200);
                                        }
                                        , end: function () {
                                            obj.event = "";
                                            childPage = null;
                                            currRowIndex = 0;
                                            //===========================================================================================================================
                                            if (childData != null) {
                                                OptionData = childData;                             //把选中数据赋值给OptionData变量
                                                //通过供应商id获取税率
                                                var HSupID = $("#HSupID").val();
                                                if (HSupID != 0 && typeof (OptionData.HItemID) != "undefined") {
                                                    var Dec = getDecByMaterID(OptionData.HItemID) //获取精度
                                                    var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                                                    var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //单价精度
                                                    var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //金额精度
                                                    $.ajax({
                                                        url: GetWEBURL() + "/Gy_Supplier/xg",
                                                        //url: "http://localhost:12761/Gy_Supplier/xg",
                                                        type: "GET",
                                                        data: {
                                                            "HInterID": HSupID
                                                        },
                                                        success: function (d) {
                                                            var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                                            var HExRate = $("#HExRate").val();                      //汇率
                                                            //数据校验合格,重算记录
                                                            var HQty = obj.data.HQty * 1;                           //数量
                                                            var HPrice = obj.data.HPrice * 1;                       //单价
                                                            var HMoney = HQty * HPrice;                             //金额=数量*单价
                                                            var HTaxMoney = Number((HMoney * HTaxRate));            //税额=金额*税率
                                                            var HlineTotal = HMoney + HTaxMoney;                    //价税合计=金额+税额
                                                            var HTaxPrice = Number((HPrice * (1 + HTaxRate)));      //含税单价=单价*(1+税率)
                                                            var HDiscountRate = obj.data.HDiscountRate * 1;         //折扣率
                                                            var HRelTaxPrice = Number((HTaxPrice * HDiscountRate)); //实际含税单价=含税单价*折扣率
                                                            var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));  //本位币价税合计=(税额+金额)*汇率
                                                            //数字精度
                                                            HQty = Number(HQty.toFixed(HQtyDec));
                                                            HPrice = Number(HPrice.toFixed(HPriceDec));
                                                            HMoney = Number(HMoney.toFixed(HMoneyDec));
                                                            HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                                                            HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                                            HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                                            HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                                                            HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                                                            obj.update({ //更新表格数据
                                                                "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                                , "物料代码": OptionData.物料代码
                                                                , "物料名称": OptionData.物料名称
                                                                , "规格型号": OptionData.规格型号
                                                                , "HUnitID": OptionData.HUnitID
                                                                , "计量单位": OptionData.计量单位名称
                                                                , "HTaxRate": HTaxRate * 100
                                                                , "HQty": HQty                               //更新HQty字段,HQty
                                                                , "HPrice": HPrice                         //更新HPrice字段,HPrice
                                                                , "HMoney": HMoney                      //更新HMoney字段,HMoney
                                                                , "HTaxMoney": HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                                                , "HlineTotal": HlineTotal             //更新HlineTotal字段,HlineTotal
                                                                , "HTaxPrice": HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                                                , "HRelTaxPrice": HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                                                , "HlineTotalBB": HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                                            })
                                                        }
                                                    });
                                                } else {
                                                    obj.update({ //更新表格数据
                                                        "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                        , "物料代码": OptionData.物料代码
                                                        , "物料名称": OptionData.物料名称
                                                        , "规格型号": OptionData.规格型号
                                                        , "HUnitID": OptionData.HUnitID
                                                        , "计量单位": OptionData.计量单位名称
                                                    })
                                                }
                                                OptionData = {};
                                                childData = null;
                                            }
                                            //============================================================================================================================
                                        }
                                    });
                                } else {
                                    setTimeout(function () {
                                        //修改,根据文本框数据,编写查询语句=========================================================================================================
                                        var value = $(e.currentTarget).val().replace(/'/g, "");                                  //获取文本框最新值
                                        currRowIndex = 0;
                                        var tableView = "h_v_Gy_MaterialList";
                                        var childSWhere = "select top(10) HItemID,物料代码,物料名称,规格型号,HUnitID,计量单位名称 from " + tableView + " where 1=1 and ç»„织名称 = '" + sessionStorage["Organization"] + "' and (物料代码 like '%" + value + "%' or ç‰©æ–™åç§° like '%" + value + "%')  order by ç‰©æ–™ä»£ç  desc";
                                        childPage.getData(childSWhere, tableView);
                                        //=============================================================================================================================================
                                    }, 200);
                                }
                            } else {                                                    //如果按下的键位是 æ–¹å‘键,则调整窗口中 é€‰ä¸­è¡Œ çš„位置
                                if (event.key == "ArrowUp") {
                                    currRowIndex--;
                                    childPage.setSelectedRow(currRowIndex);
                                } else if (event.key == "ArrowDown") {
                                    currRowIndex++;
                                    childPage.setSelectedRow(currRowIndex);
                                } else if (event.key == "Enter") {
                                    //手动失焦
                                    var element = document.getElementById("HBillNo");
                                    element.focus();
                                    childPage.getSelectedData(currRowIndex);
                                    //=============================================================================================================
                                    if (childData != null) {
                                        OptionData = childData;                             //把选中数据赋值给OptionData变量
                                        //通过供应商id获取税率
                                        var HSupID = $("#HSupID").val();
                                        if (HSupID != 0 && typeof (OptionData.HItemID) != "undefined") {
                                            var Dec = getDecByMaterID(OptionData.HItemID) //获取精度
                                            var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                                            var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //单价精度
                                            var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //金额精度
                                            $.ajax({
                                                url: GetWEBURL() + "/Gy_Supplier/xg",
                                                //url: "http://localhost:12761/Gy_Supplier/xg",
                                                type: "GET",
                                                data: {
                                                    "HInterID": HSupID
                                                },
                                                success: function (d) {
                                                    var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                                    var HExRate = $("#HExRate").val();                      //汇率
                                                    //数据校验合格,重算记录
                                                    var HQty = obj.data.HQty * 1;                           //数量
                                                    var HPrice = obj.data.HPrice * 1;                       //单价
                                                    var HMoney = HQty * HPrice;                             //金额=数量*单价
                                                    var HTaxMoney = Number((HMoney * HTaxRate));            //税额=金额*税率
                                                    var HlineTotal = HMoney + HTaxMoney;                    //价税合计=金额+税额
                                                    var HTaxPrice = Number((HPrice * (1 + HTaxRate)));      //含税单价=单价*(1+税率)
                                                    var HDiscountRate = obj.data.HDiscountRate * 1;         //折扣率
                                                    var HRelTaxPrice = Number((HTaxPrice * HDiscountRate)); //实际含税单价=含税单价*折扣率
                                                    var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));  //本位币价税合计=(税额+金额)*汇率
                                                    //数字精度
                                                    HQty = Number(HQty.toFixed(HQtyDec));
                                                    HPrice = Number(HPrice.toFixed(HPriceDec));
                                                    HMoney = Number(HMoney.toFixed(HMoneyDec));
                                                    HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                                                    HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                                    HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                                    HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                                                    HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                                                    obj.update({ //更新表格数据
                                                        "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                        , "物料代码": OptionData.物料代码
                                                        , "物料名称": OptionData.物料名称
                                                        , "规格型号": OptionData.规格型号
                                                        , "HUnitID": OptionData.HUnitID
                                                        , "计量单位": OptionData.计量单位名称
                                                        , "HTaxRate": HTaxRate * 100
                                                        , "HQty": HQty                               //更新HQty字段,HQty
                                                        , "HPrice": HPrice                         //更新HPrice字段,HPrice
                                                        , "HMoney": HMoney                      //更新HMoney字段,HMoney
                                                        , "HTaxMoney": HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                                        , "HlineTotal": HlineTotal             //更新HlineTotal字段,HlineTotal
                                                        , "HTaxPrice": HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                                        , "HRelTaxPrice": HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                                        , "HlineTotalBB": HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                                    })
                                                }
                                            });
                                        } else {
                                            obj.update({ //更新表格数据
                                                "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                , "物料代码": OptionData.物料代码
                                                , "物料名称": OptionData.物料名称
                                                , "规格型号": OptionData.规格型号
                                                , "HUnitID": OptionData.HUnitID
                                                , "计量单位": OptionData.计量单位名称
                                            })
                                        }
                                        OptionData = {};
                                        childData = null;
                                    }
                                    //=========================================================================================================================================
                                    childPage = null;
                                    currRowIndex = 0;
                                    childData = null;
                                    obj.event = "";
                                }
                            }
                        }
                    }
                    //#endregion
                    if (event.key == "F7") {//检查触发事件的键盘按键是否是F7键
                        //物料
                        if (obj.event == "HMaterID") {//判断传入的obj对象的event属性是否等于字符串"HMaterID"
@@ -1373,7 +1616,7 @@
                                                "HInterID": HSupID
                                            },
                                            success: function (d) {
                                                var HTaxRate = parseInt(d.data[0].增值税率)*0.01;
                                                var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                                var HExRate = $("#HExRate").val();                      //汇率
                                                //数据校验合格,重算记录
                                                var HQty = obj.data.HQty * 1;                           //数量
@@ -1401,7 +1644,7 @@
                                                    , "规格型号": OptionData.规格型号
                                                    , "HUnitID": OptionData.HUnitID
                                                    , "计量单位": OptionData.计量单位名称
                                                    , "HTaxRate": HTaxRate*100
                                                    , "HTaxRate": HTaxRate * 100
                                                    , HQty: HQty                               //更新HQty字段,HQty
                                                    , HPrice: HPrice                         //更新HPrice字段,HPrice
                                                    , HMoney: HMoney                      //更新HMoney字段,HMoney
@@ -1423,8 +1666,8 @@
                                            , "计量单位": OptionData.计量单位名称
                                        })
                                    }
                                    }
                                });
                                }
                            });
                        }
                        //计量单位
                        if (obj.event == "HUnitID") {  //判断  obj.event事件 æ˜¯å¦ç­‰äºŽå­—符串 'HUnitID'。如果等于,则执行if循环
@@ -1507,6 +1750,10 @@
                })
                //双击
                $('.layui-table-box tbody td[data-field="物料代码"]').off('dblclick').on('dblclick', function () {
                    //手动失焦
                    var element = document.getElementById("HBillNo");
                    element.focus();
                    var HOrgID = $("#HOrgID").val();  //获取id="HOrgID"的元素中获取其值,并将该值存储在变量HOrgID中
                    layer.open({  //打开层
                        type: 2         // //表示弹出层的内容是一个 iframe       ç±»åž‹ä¸º2
@@ -1628,6 +1875,8 @@
                            }
                        }
                    });
                    obj.event = "";
                });
        }
@@ -2179,6 +2428,8 @@
            $("#HProjectName").val(data[0].项目名称);
            $("#HProjectNumber").val(data[0].项目代码);
            $("#HProjectID").val(data[0].HInterID);
            $("#HLinkMan").val(data[0].联系人);
            $("#HLinkPhone").val(data[0].联系人电话);
        }
        //双击返回仓库
        function GetHWHValue(data) {