1
pzy
2024-08-13 4f4a5a073bed3688ddead42557829fc8610db86b
WebTM/views/ÏúÊÛ¹ÜÀí/ÍË»õ֪ͨµ¥/Xs_SeOutStockBackBill.html
@@ -538,14 +538,97 @@
                        }
                    });
                }
                else if (obj.event == 'HQtyMust' || obj.event == 'HQty' || obj.event == 'HQty_Full' || obj.event == 'HQty_Empty' || obj.event == 'HQty_Back' || obj.event == 'HPrice' || obj.event == 'HMoney' || obj.event == 'HCostPrice' || obj.event == 'HCostMoney' || obj.event == 'HSalePrice') {
                    $(obj.tr).find(".layui-table-edit").keyup(function () {
                        var $input = $(this), val = $input.val();
                        if (!val) val = "0";
                        $input.val(parseInt(val.replace(/[^\d*\.?\d*]/g, '')));
                    });
                //else if (obj.event == 'HQtyMust' || obj.event == 'HQty' || obj.event == 'HQty_Full' || obj.event == 'HQty_Empty' || obj.event == 'HQty_Back' || obj.event == 'HPrice' || obj.event == 'HMoney' || obj.event == 'HCostPrice' || obj.event == 'HCostMoney' || obj.event == 'HSalePrice') {
                //    $(obj.tr).find(".layui-table-edit").keyup(function () {
                //        var $input = $(this), val = $input.val();
                //        if (!val) val = "0";
                //        $input.val(parseInt(val.replace(/[^\d*\.?\d*]/g, '')));
                //    });
                //}
            });
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                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 //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
                //layer.msg('[ID: ' + data.id + '] ' + field + ' å­—段更改为:' + value);
                switch (field) {
                    case "HQty":                                                       //实发数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("实发数量请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = value * 1;                           //实发数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HMoney = HQty * HPrice;                     //金额=实发数量*单价
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                        });
                        table.render(option);
                        break;
                    case "HPrice":                                                       //单价
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HPrice: oldText
                            });
                            table.render(option);
                            layer.msg("单价请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //实发数量
                        var HPrice = value * 1;                         //单价
                        var HMoney = HQty * HPrice;                     //金额=实发数量*单价
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                        });
                        table.render(option);
                        break;
                    default:
                }
            });
            //#endregion
            //动态弹出页面
            function getSupType() {
@@ -877,6 +960,19 @@
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                        })
                                    }
                                }
                            })
                        }
                        //计量单位
@@ -1010,6 +1106,19 @@
                                , "计量单位": checkStatus.data[0].计量单位名称
                            })
                            layer.close(index);//关闭弹窗
                        }
                        , end: function () {
                            if (typeof (OptionData.HItemID) != "undefined") {
                                obj.update({
                                    "HMaterID": OptionData.HItemID
                                    , "物料代码": OptionData.物料代码
                                    , "物料名称": OptionData.物料名称
                                    , "规格型号": OptionData.规格型号
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                })
                            }
                        }
                    })
                });
@@ -1335,6 +1444,32 @@
                })
            }
            //#region æ ¹æ®ç‰©æ–™ID获取精度
            function getDecByMaterID(HMaterID) {
                var resultData = {};
                $.ajax({  // å¼‚步请求
                    url: GetWEBURL() + "Gy_Material/getDecByID",  //请求地址
                    async: false,   //是否开启异步
                    type: "GET",   //请求类型
                    data: {   //定义发送到服务器的数据
                        "HMaterID": HMaterID     //  å°†hmaterid作为请求参数发送
                    },
                    success: function (result) {   // å½“请求成功时,执行这个函数
                        if (result.code == 1) { // å¦‚果服务器返回的数据中的`code字段等于1,这可能表示审核操作成功执行
                            var data = result.data; //声明data变量,并将其赋值为result对象中的data属性
                            resultData = data[0];   //将data数组(或类数组对象)的第一个元素赋值给变量resultData
                        }
                        //else {
                        //    layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' }); //result.msg对象,提示弹窗 ç±»åž‹ä¸º5, æŒ‰é’®ï¼Œå’ŒæŒ‰é’®çš„名称为退出  æ—¶é—´ ä¸º100秒,以及偏移量(`offset: 't'
                        //}
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });  //提示弹窗 å‘生错误 ï¼Œè­¦ç¤ºæ ‡å¿—为5的
                    }
                });
                return resultData;
            }
            //#endregion
            //#region ä¿å­˜åŽæµè§ˆæ–¹æ³•
            function ReRoadBillMain() {
                location.replace('Add_Edit_Xs_SeOutStockBillList.html?OperationType=4&linterid=' + linterid + '&HSouceBillType=');
@@ -1450,7 +1585,10 @@
        function GetHWHSubValue(data) {
            OptionData = data[0]
        }
        //双击返回物料
        function GetGyMaterial(data) {
            OptionData = data
        }
        function GetHWHValue(obj)  //返回仓库
        {
            $("#HWHName").val(obj[0].仓库名称);