cwjbxqmz
2023-11-27 9a385066c973be605c57c9466b91d3eecc80bae4
WebTM/views/²É¹º¹ÜÀí/²É¹º¶©µ¥/Cg_POOrderBillEdit.html
@@ -481,6 +481,214 @@
            //#endregion
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var temp = "";
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
                //#endregion
                switch (field) {
                    case "HQty":                                         //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("数量请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = value * 1;                           //数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));      //本位币价税合计=(税额+金额)*汇率
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                            , HlineTotal: HlineTotal
                            , HlineTotalBB: HlineTotalBB
                        });
                        break;
                    case "HPrice":                                         //单价
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HPrice: oldText
                            });
                            layer.msg("单价请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = value * 1;
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                        var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //实际含税单价=含税单价*折扣率
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //本位币价税合计=(税额+金额)*汇率
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                            , HlineTotal: HlineTotal
                            , HTaxPrice, HTaxPrice
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                        });
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HTaxRate: oldText
                            });
                            layer.msg("税率请输入不小于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = obj.data.HPrice * 1;
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                        var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //实际含税单价=含税单价*折扣率
                        var HExRate = $("#HExRate").val();                       //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));       //本位币价税合计=(税额+金额)*汇率
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxRate: HTaxRate * 100
                            , HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                            , HTaxPrice: HTaxPrice
                            , HlineTotal: HlineTotal
                            , HTaxPrice, HTaxPrice
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                        });
                        break;
                    case "HDiscountRate":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HDiscountRate: oldText
                            });
                            layer.msg("折扣率请输入不小于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = obj.data.HPrice * 1;
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                        var HDiscountRate = obj.data.HDiscountRate * 1;     //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //实际含税单价=含税单价*折扣率
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxRate: HTaxRate * 100
                            , HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                            , HTaxPrice: HTaxPrice
                            , HDiscountRate: HDiscountRate
                            , HRelTaxPrice: HRelTaxPrice
                        });
                        break;
                        table.render(option);
                    default:
                }
            });
            //#endregion
            //#endregion
            //#endregion
            //#region æ–‡æœ¬æ¡†ç›‘听
            $(document).ready(function () {
                //#region æ±‡çŽ‡å¤±ç„¦äº‹ä»¶
                var oldHExRate = "";                          //修改前的值
                var newHExRate = "";                          //修改后的值
                $("#HExRate").on('focus', function (data) {
                    oldHExRate = $("#HExRate").val() * 1;   //汇率文本框获取焦点时获取修改前的值
                }).on('blur', function (data) {
                    newHExRate = $("#HExRate").val();       //汇率文本框失焦时获取修改后的值
                    //判断输入的汇率是否合法
                    var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                    if (!ref.test(newHExRate)) {
                        layer.msg("汇率请输入不小于0的数字!");
                        $("#HExRate").val(oldHExRate);
                        return false;
                    }
                    //输入的汇率合法,重算
                    var HExRate = newHExRate * 1;                       //汇率
                    $("#HExRate").val(HExRate);
                    for (var i = 0; i < option.data.length; i++) {
                        var HMoney = option.data[i].HMoney;
                        var HTaxMoney = option.data[i].HTaxMoney;
                        option.data[i].HlineTotalBB = (option.data[i].HMoney + option.data[i].HTaxMoney) * HExRate;
                    }
                    table.render(option);
                });
                //#endregion
            });
            //#endregion
            //#region æœ¬é¡µé¢æ‰€æœ‰è¢«è°ƒç”¨çš„æ–¹æ³•
            //#region åˆ¤æ–­æ˜¯å¦ç™»å½• æœªç™»å½•则跳到登录页
@@ -523,9 +731,9 @@
                        , { field: '规格型号', title: '规格型号', width: 100, }
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true }
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID" }//f7
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text' }
                        , { field: 'HPrice', title: '不含税单价', width: 100, edit: 'text', hide: true }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text' }
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text'}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text'}
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text'}
                        , { field: 'HMoney', title: '金额', width: 100 }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 110, }
@@ -743,17 +951,6 @@
                                        option.data[rowIndex + i].规格型号 = resultData.HMaterModel;
                                        option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                        option.data[rowIndex + i].计量单位 = resultData.HUnitName;
                                        ////更新表格缓存的数据
                                        //obj.update({
                                        //    "HMaterID": checkStatus.data[0].HItemID
                                        //    , "物料代码": checkStatus.data[0].HNumber
                                        //    , "物料名称": checkStatus.data[0].HName
                                        //    , "规格型号": checkStatus.data[0].HModel
                                        //    , "HUnitID": checkStatus.data[0].HUnitID
                                        //    , "计量单位": checkStatus.data[0].HUnitName
                                        //})
                                        //layer.close(index);//关闭弹窗
                                    }
                                    table.render(option);
@@ -1045,4 +1242,4 @@
    </script>
</body>
</html>
</html>