1
yangle
2024-12-12 19dd6d8b638faffa073fb4b40f825f049aa93bdd
WebTM/views/²É¹º¹ÜÀí/Ó¦¸¶µ¥/Cg_PayableBill.html
@@ -1642,8 +1642,8 @@
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID"}//f7
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, edit: 'text'}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPrice', title: '单价', width: 100, event: "HPrice", style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, edit: 'text' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text', event: "HTaxPrice" }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 100, style: 'background-color:#efefef4d;' }
@@ -1760,52 +1760,12 @@
                table.render(optionEntry);
            }
            function set_InitGridHaveSource() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , totalRow: true
                    , limit: 500
                    , height: 500
                    , loading: false
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100 }
                        , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '物料代码', title: '物料代码', width: 150, edit: 'text', event: "HMaterID" }//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, style: 'background-color:#efefef4d;' }
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID" }//f7
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text', event: "HTaxPrice" }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
                        , { field: 'HTaxMoney', title: '税额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoneyBB', title: '本位币金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotalBB', title: '本位币价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
                        , { field: 'HSourceInterID', title: '源单内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSourceEntryID', title: '源单子内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSourceBillNo', title: '源单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSourceBillType', title: '源单类型', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelationQty', title: '关联数量', width: 100, totalRow: true, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelationMoney', title: '关联金额', width: 100, totalRow: true, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPOOrderInterID', title: '采购订单内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPOOrderEntryID', title: '采购订单子内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPOOrderBillNo', title: '采购订单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderTaxPrice', title: '订单含税单价', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderInterID', title: '销售订单内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderEntryID', title: '销售订单子内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderBillNo', title: '销售订单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                //选中源单后数量不可编辑
                for (var i = 0; i < option.cols[0].length; i++) {
                    if (option.cols[0][i]["field"] == "HQty") {
                       option.cols[0][i]["edit"] = false;
                    }
                }
            }
            //#endregion
@@ -1815,6 +1775,7 @@
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                var temp = "";
                var Dec = getDecByMaterID(obj.data.HMaterID) //获取精度
                var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
@@ -1831,14 +1792,23 @@
                    case "HQty":                                         //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("数量请输入大于0的数字!");
                            layer.msg("数量请输入不为0的数字!");
                            return;
                        } else if (temp * 1 == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("数量请输入不为0的数字!");
                            return;
                        }
@@ -1871,7 +1841,7 @@
                            , HlineTotalBB: HlineTotalBB
                            , HMoneyBB: HMoneyBB
                        });
                        table.render(option);
                        //table.render(option);
                        break;
                    case "HPrice":                                         //单价
                        //数据格式校验
@@ -1921,7 +1891,7 @@
                            , HlineTotalBB: HlineTotalBB
                            , HMoneyBB: HMoneyBB
                        });
                        table.render(option);
                        //table.render(option);
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
@@ -1975,7 +1945,7 @@
                            , HlineTotalBB: HlineTotalBB
                            , HMoneyBB: HMoneyBB
                        });
                        table.render(option);
                        //table.render(option);
                        break;
                    case "HDiscountRate":                                                       //数量
                        //数据格式校验
@@ -2019,7 +1989,7 @@
                            , HDiscountRate: HDiscountRate
                            , HRelTaxPrice: HRelTaxPrice
                        });
                        table.render(option);
                        //table.render(option);
                        break;
                    case "HTaxPrice":                                         //单价
                        //数据格式校验  
@@ -2070,7 +2040,65 @@
                            , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                            , HMoneyBB: HMoneyBB
                        });
                        table.render(option);
                        //table.render(option);
                        break;
                    case "HMoney":                                         //金额
                        //数据格式校验
                        temp = value + "";
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HMoney: oldText
                            });
                            table.render(option);
                            layer.msg("金额或数量请输入大于0的数字!");
                            return;
                        } else if (temp * 1 == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HMoney: oldText
                            });
                            table.render(option);
                            layer.msg("金额或数量请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HMoney = value * 1;                     //金额=数量*单价
                        var HPrice = HMoney / HQty;
                        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));     //本位币价税合计=(税额+金额)*汇率
                        var HMoneyBB = HMoney * HExRate;
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                            , HlineTotal: HlineTotal
                            , HTaxPrice, HTaxPrice
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                            , HMoneyBB: HMoneyBB
                        });
                        //table.render(option);
                        break;
                    default:
                }
@@ -2484,6 +2512,7 @@
            function AllowLoadData(data) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                var temp = "";
                //#region è¡¨å¤´æ•°æ®æ£€éªŒ
@@ -2550,13 +2579,13 @@
                        return false;
                    }
                    //实发数量格式校验
                    //数量格式校验
                    temp = option.data[i]["HQty"] + "";
                    if (temp == "0") {
                        layer.msg("第" + (i + 1) + "行:实收数量不能为0!");
                    if (!ref1.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:数量请输入不为0的数字!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:实收数量请输入大于0的数字!");
                    } else if (temp * 1 == 0) {
                        layer.msg("第" + (i + 1) + "行:数量请输入不为0的数字!");
                        return false;
                    }
@@ -2587,26 +2616,26 @@
                        return false;
                    }
                    //金额格式校验
                    temp = option.data[i]["HMoney"] + "";
                    if (temp == "0") {
                        layer.msg("第" + (i + 1) + "行:金额不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:金额请输入大于0的数字!");
                        return false;
                    }
                    //价税合计格式校验
                    temp = option.data[i]["HTaxMoney"] + "";
                    ////金额格式校验
                    //temp = option.data[i]["HMoney"] + "";
                    //if (temp == "0") {
                    //    layer.msg("第" + (i + 1) + "行:价税合计不能为0!");
                    //    layer.msg("第" + (i + 1) + "行:金额不能为0!");
                    //    return false;
                    //} else
                    if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:税额请输入大于0的数字!");
                        return false;
                    }
                    //} else if (!ref.test(temp)) {
                    //    layer.msg("第" + (i + 1) + "行:金额请输入大于0的数字!");
                    //    return false;
                    //}
                    ////价税合计格式校验
                    //temp = option.data[i]["HTaxMoney"] + "";
                    ////if (temp == "0") {
                    ////    layer.msg("第" + (i + 1) + "行:价税合计不能为0!");
                    ////    return false;
                    ////} else
                    //if (!ref.test(temp)) {
                    //    layer.msg("第" + (i + 1) + "行:税额请输入大于0的数字!");
                    //    return false;
                    //}
                }
                //#endregion
                return true;