yxj
2024-08-26 de7931bdf73d57ca79eeb0cd48ea3a0ea5453e0e
WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥/Add_Edit_Xs_SeOrderBillList.html
@@ -91,7 +91,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售员</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="text" name="HEmpName" id="HEmpName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -145,6 +145,8 @@
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售订单类型</label>
                                            <div class="layui-input-inline">
@@ -154,8 +156,6 @@
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">结算方式<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
@@ -166,7 +166,7 @@
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                        <div class="layui-inline" style="display:none;">
                                            <label class="layui-form-label">销售方式</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
@@ -224,7 +224,7 @@
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                    <div class="layui-row" style="display:none;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">项目代码</label>
                                            <div class="layui-input-inline">
@@ -245,7 +245,7 @@
                                            <label class="layui-form-label">仓库</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HWHName" id="HWHName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HWHID" id="HWHID" class="layui-input" value=0 style="float:left;width:150px;">
                                                <input type="hidden" name="HWHID" id="HWHID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HWHList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
@@ -413,6 +413,8 @@
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>上移</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>下移</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-batchDelete"><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>
@@ -498,14 +500,7 @@
                set_InitGrid();
                //加载表体和表体数据
                RoadBillMain(linterid);
                //根据销售订单类型设置子表是否取库存选项
                setHisStockGoodsByHBillSubType_For_RoadBillMain();
                //根据是否取库存获取定金比例
                setHEarnestRateByHisStockGoods();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
                //生成并设置主表的内码和单据号
                createBillNo();
@@ -523,14 +518,6 @@
                set_InitGrid();
                //加载表体和表体数据
                RoadBillMain(linterid);
                //根据销售订单类型设置子表是否取库存选项
                setHisStockGoodsByHBillSubType_For_RoadBillMain();
                //根据是否取库存获取定金比例
                setHEarnestRateByHisStockGoods();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
            }
            //#endregion
@@ -543,7 +530,7 @@
            //#endregion
            //#region åˆ—设置:子表1
            //DisPlay_HideColumn();
            DisPlay_HideColumn();
            //#endregion
            //#endregion
@@ -664,7 +651,7 @@
                    "规格型号": "",
                    "HUnitID": "0",
                    "计量单位": "",
                    "HWHID": "",
                    "HWHID": "0",
                    "仓库":"",
                    "HQty": "0",
                    "HPrice": "0",
@@ -680,6 +667,8 @@
                    "HisStockGoods": "false",
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark_TL": "",
                    "HRemark_SJG": "",
                    "HRemark": "",
                    "HCusMaterNumber": "",
                    "HCusModel": "",
@@ -717,6 +706,12 @@
                    case 'set_HideColumn':
                        get_HideColumn();
                        break;
                    //库存查询
                    case 'get_Inventory': get_Inventory();
                        break;
                    //出入库记录查询
                    case 'get_InOutSum': get_InOutSum();
                        break;
                }
            });
            //#endregion
@@ -749,7 +744,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 //得到修改后的值
@@ -788,13 +786,12 @@
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -805,7 +802,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -872,13 +869,12 @@
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -889,7 +885,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -927,13 +923,12 @@
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -944,7 +939,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -1012,13 +1007,12 @@
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -1029,7 +1023,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -1241,7 +1235,9 @@
                        , { 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, style: 'background-color:#efefef4d;' }//f7
                        , { field: '计量单位', title: '计量单位', width: 100, style: 'background-color:#efefef4d;', edit: 'text', event:"HUnitID" }//f7
                        , { field: 'HRemark_TL', title: '投料', width: 100, edit: 'text', event: "HRemark_TL" }
                        , { field: 'HRemark_SJG', title: '深加工', width: 100, edit: 'text', event: "HRemark_SJG" }
                        , { field: 'HWHID ', title: 'HWHID ', width: 100, hide: true }
                        , { field: '仓库', title: '仓库', width: 100, style: 'background-color:#efefef4d;' ,edit: 'text' ,event: "HWHID" }//f7
                        , { field: 'HisStockGoods', title: '是否取库存', width: 120, templet: '#HisStockGoods' }
@@ -1297,7 +1293,7 @@
                    "规格型号": "",
                    "HUnitID": "0",
                    "计量单位": "",
                    "HWHID": "",
                    "HWHID": "0",
                    "仓库":"",
                    "HQty": "0",
                    "HPrice": "0",
@@ -1313,6 +1309,8 @@
                    "HisStockGoods": "false",
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark_TL": "",
                    "HRemark_SJG": "",
                    "HRemark": "",
                    "HCusMaterNumber": "",
                    "HCusModel": "",
@@ -1449,7 +1447,7 @@
                                        "仓库": result.data[i]["子仓库"],
                                        "HQty": dealDoubleToFixed(result.data[i]["数量"], 1),
                                        "HPrice": dealDoubleToFixed(result.data[i]["单价"], 3),
                                        "HTaxPrice": dealDoubleToFixed(result.data[i]["含税单价"], 3),
                                        "HTaxPrice": dealDoubleToFixed(result.data[i]["HTaxPrice"], 3),
                                        "HMoney": dealDoubleToFixed(result.data[i]["金额"],2),
                                        "HDiscountRate": result.data[i]["折扣率"],
                                        "HRelTaxPrice": result.data[i]["实际含税单价"],
@@ -1461,6 +1459,8 @@
                                        "HDate": formatDate(result.data[i]["交货日期"]),
                                        "HOutStockQty": result.data[i]["出库数量"],
                                        "HInvoiceQty": result.data[i]["开票数量"],
                                        "HRemark_TL": result.data[i]["投料"],
                                        "HRemark_SJG": result.data[i]["深加工"],
                                        "HRemark": result.data[i]["表体备注"],
                                        "HCusMaterNumber": result.data[i]["客户物料编码"],
                                        "HCusModel": result.data[i]["客户规格型号"],
@@ -1476,20 +1476,18 @@
                            }
                            option.data = rowdata;
                            //出库数量、开票数量不可编辑
                            //option.cols[0][22].edit = null;
                            //option.cols[0][23].edit = null;
                            table.render(option);
                            //获取临时定金比例
                            HEarnestRateTemp = data.定金比例 + "" == "0" ? "50" : data.定金比例 + "";
                            HEarnestRateTemp = data.定金比例;
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //根据销售订单类型设置子表是否取库存选项
                            setHisStockGoodsByHBillSubType_For_RoadBillMain();
                            //根据是否取库存获取定金比例
                            setHEarnestRateByHisStockGoods();
                            $("#HEarnestRate").val(data.定金比例);
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
@@ -1541,6 +1539,7 @@
            //#endregion
            //#region å®¢æˆ·é€‰æ‹©é¡µé¢
            //#region å®¢æˆ·é€‰æ‹©é¡µé¢
            function get_checkCus() {
                var HEmpID = $("#HEmpID").val();
                layer.open({
@@ -1566,6 +1565,35 @@
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
            //#region å®¢æˆ·é€‰æ‹©é¡µé¢-基础资料
            //function get_checkCus() {
            //    var HEmpID = $("#HEmpID").val();
            //    layer.open({
            //        type: 2//弹窗类型
            //        , skin: 'layui-layer-rim' //加上边框
            //        , area: ['90%', '90%']//大小
            //        , title: '客户列表'//标题
            //        , shift: 2//弹出动画
            //        , content: ['../../基础资料/销售基础资料/Gy_Customer.html', 'yes']
            //        , btn: ['确定', '取消']
            //        , btn1: function (index, layero) {//按钮【按钮一】的回调
            //            var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
            //            var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
            //            if (checkStatus.data.length === 0) {
            //                return layer.msg('请选择数据');
            //            }
            //            getCustomerByCusID(checkStatus.data[0].HItemID);
            //            //根据客户获取客户余额
            //            getCustomerBalance(checkStatus.data[0].HItemID);
            //            layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
            //        }
            //        , btn2: function (index, layero) { }
            //    })
            //}
            //#endregion
            //#endregion
            //#region ç»“算方选择页面
@@ -1935,6 +1963,7 @@
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
                var RowCount = 0;
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HMaterID"] == "0") {
                        continue;
                    }
@@ -2175,7 +2204,7 @@
                                        "规格型号": "",
                                        "HUnitID": "0",
                                        "计量单位": "",
                                        "HWHID": "",
                                        "HWHID": "0",
                                        "仓库": "",
                                        "HQty": "0",
                                        "HPrice": "0",
@@ -2191,6 +2220,8 @@
                                        "HisStockGoods": "false",
                                        "HOutStockQty": "0",
                                        "HInvoiceQty": "0",
                                        "HRemark_TL": "",
                                        "HRemark_SJG": "",
                                        "HRemark": "",
                                        "HCusMaterNumber": "",
                                        "HCusModel": "",
@@ -2236,7 +2267,7 @@
                                    "规格型号": "",
                                    "HUnitID": "0",
                                    "计量单位": "",
                                    "HWHID": "",
                                    "HWHID": "0",
                                    "仓库": "",
                                    "HQty": "0",
                                    "HPrice": "0",
@@ -2252,6 +2283,8 @@
                                    "HisStockGoods": "false",
                                    "HOutStockQty": "0",
                                    "HInvoiceQty": "0",
                                    "HRemark_TL": "",
                                    "HRemark_SJG": "",
                                    "HRemark": "",
                                    "HCusMaterNumber": "",
                                    "HCusModel": "",
@@ -2540,18 +2573,18 @@
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    //if (checkStatus.data.length != 1) {
                                    //    return layer.msg("请选择一条数据");
                                    //}
                                    var rowIndex = $(obj.tr).attr("data-index") * 1;
                                    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"];  //金额精度
                                    for (var i = 0; i < checkStatus.data.length; i++) {
                                        if (rowIndex + i >= option.data.length) {
                                            var NewRow = {
                                                "HMaterID": "0", "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": "0", "计量单位": "", "HQty": "0", "HPrice": "0", "HTaxPrice": "0"
                                                , "HMoney": "0", "HDiscountRate": "0", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0"
                                                , "HDate": Format(new Date(), 'yyyy-MM-dd'), "HOutStockQty": "0", "HInvoiceQty": "0", "HRemark": "", "HCusMaterNumber": "",
                                                "HCusModel": "","HCusMaterName": ""
                                                "HCusModel": "", "HCusMaterName": ""
                                            }
                                            btnAddLine(NewRow);
                                        }
@@ -2574,8 +2607,8 @@
                                        }
                                        //数据校验合格,重算记录
                                        var HQty = option.data[rowIndex + i].HQty;                  //数量
                                        var HPrice = option.data[rowIndex + i].HPrice;              //单价
                                        var HQty = option.data[rowIndex + i].HQty * 1;                  //数量
                                        var HPrice = option.data[rowIndex + i].HPrice * 1;              //单价
                                        var HTaxRate = value * 0.01;                                //税率
                                        /*var HDiscountRate = obj.data.HDiscountRate * 1;           //折扣率*/
                                        var HTaxPrice = HPrice * (1 + HTaxRate);                    //含税单价=单价*(1+税率)
@@ -2584,7 +2617,13 @@
                                        var HMoney = HQty * HPrice;                                 //金额=数量*单价
                                        var HTaxMoney = HMoney * HTaxRate;                          //税额=金额*税率
                                        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));
                                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                        option.data[rowIndex + i].HMaterID = resultData.HItemID;
                                        option.data[rowIndex + i].物料代码 = resultData.物料代码;
@@ -2614,6 +2653,42 @@
                                }
                                , end: function () {
                                    if (typeof (HDataEmp.HItemID) != "undefined") {
                                        var value = subHTaxRate;
                                        //数值格式校验工具
                                        var ref = /^\d+(\.\d+)?$/;
                                        //税率数据格式校验,若根据客户获取的税率不合法,则使用记录中原有的税率,并提示
                                        temp = value + "";
                                        if (ref.test(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 HQty = obj.data.HQty * 1;                           //数量
                                            var HPrice = obj.data.HPrice * 1;               //单价
                                            var HTaxRate = value * 0.01;           //税率
                                            var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                                            var HMoney = HQty * HPrice;                     //金额=数量*单价
                                            var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                                            var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                            //数字精度
                                            HQty = Number(HQty.toFixed(HQtyDec));
                                            HPrice = Number(HPrice.toFixed(HPriceDec));
                                            HMoney = Number(HMoney.toFixed(HMoneyDec));
                                            HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                            HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                                            //同步更新表格和缓存对应的值
                                            obj.update({
                                                HQty: HQty
                                                , HPrice: HPrice
                                                , HTaxRate: HTaxRate * 100
                                                , HTaxPrice: HTaxPrice
                                                , HMoney: HMoney
                                                , HlineTotal: HlineTotal
                                            });
                                        }
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": HDataEmp.HItemID
@@ -2638,7 +2713,7 @@
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../基础资料/公用基础资料/Gy_Unit.html', 'yes']
                                , content: ['../../基础资料/公用基础资料/Gy_Unit.html?type=AuxiliaryUnit', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
@@ -2696,10 +2771,14 @@
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                    obj.update({
                                        "HWHID": OptionData.HItemID
                                        , "仓库": OptionData.仓库名称
                                    })
                                    if (typeof (HDataEmp.HItemID) != "undefined") {
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HWHID": HDataEmp.HItemID
                                            , "仓库": HDataEmp.仓库名称
                                        })
                                        HDataEmp = {};
                                    }
                                }
                            })
@@ -3066,14 +3145,254 @@
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                        }
                        //投料
                        if (obj.event == "HRemark_TL") {
                            var oldText = table.cache["mainTable"][rowIndex].HRemark_TL;
                            var value = e.target.value; //得到修改后的值
                            //数据校验合格,重算记录
                            for (var i = rowIndex * 1; i < option.data.length; i++) {
                                option.data[i].HRemark_TL = value;
                            }
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                        }
                        //深加工
                        if (obj.event == "HRemark_SJG") {
                            var oldText = table.cache["mainTable"][rowIndex].HRemark_SJG;
                            var value = e.target.value; //得到修改后的值
                            //数据校验合格,重算记录
                            for (var i = rowIndex * 1; i < option.data.length; i++) {
                                option.data[i].HRemark_SJG = value;
                            }
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                        }
                        obj.event = "";
                        return false;
                    }
                    //#endregion
                })
                //双击
                $('.layui-table-box tbody td[data-field="物料代码"]').off('dblclick').on('dblclick', function () {
                    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");//获取选中的数据
                            var rowIndex = $(obj.tr).attr("data-index") * 1;
                            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"];  //金额精度
                            for (var i = 0; i < checkStatus.data.length; i++) {
                                if (rowIndex + i >= option.data.length) {
                                    var NewRow = {
                                        "HMaterID": "0", "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": "0", "计量单位": "", "HQty": "0", "HPrice": "0", "HTaxPrice": "0"
                                        , "HMoney": "0", "HDiscountRate": "0", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0"
                                        , "HDate": Format(new Date(), 'yyyy-MM-dd'), "HOutStockQty": "0", "HInvoiceQty": "0", "HRemark": "", "HCusMaterNumber": "",
                                        "HCusModel": "", "HCusMaterName": ""
                                    }
                                    btnAddLine(NewRow);
                                }
                                //获取选中的物料信息
                                var resultData = checkStatus.data[i];
                                //数值格式校验工具
                                var ref = /^\d+(\.\d+)?$/;                                  //非负数正则表达式
                                var temp = "";
                                //获取选择物料前后的税率
                                var value = subHTaxRate;                                    //选择物料后根据客户得到的税率
                                var oldText = option.data[rowIndex + i].HTaxRate;           //该记录中原有的税率
                                //税率数据格式校验,若根据客户获取的税率不合法,则使用记录中原有的税率,并提示
                                temp = value + "";
                                if (!ref.test(temp)) {
                                    value = oldText;
                                    layer.msg("获取到的税率不合法,已自动变更为原有税率!");
                                }
                                //数据校验合格,重算记录
                                var HQty = option.data[rowIndex + i].HQty * 1;                  //数量
                                var HPrice = option.data[rowIndex + i].HPrice * 1;              //单价
                                var HTaxRate = value * 0.01;                                //税率
                                /*var HDiscountRate = obj.data.HDiscountRate * 1;           //折扣率*/
                                var HTaxPrice = HPrice * (1 + HTaxRate);                    //含税单价=单价*(1+税率)
                                /*var HRelTaxPrice = HTaxPrice * HDiscountRate;             //实际含税单价=含税单价*折扣率*/
                                //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                                var HMoney = HQty * HPrice;                                 //金额=数量*单价
                                var HTaxMoney = HMoney * HTaxRate;                          //税额=金额*税率
                                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));
                                HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                option.data[rowIndex + i].HMaterID = resultData.HItemID;
                                option.data[rowIndex + i].物料代码 = resultData.物料代码;
                                option.data[rowIndex + i].物料名称 = resultData.物料名称;
                                option.data[rowIndex + i].规格型号 = resultData.规格型号;
                                option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                option.data[rowIndex + i].计量单位 = resultData.计量单位名称;
                                option.data[rowIndex + i].HQty = HQty;
                                option.data[rowIndex + i].HPrice = HPrice;
                                option.data[rowIndex + i].HTaxRate = HTaxRate * 100;
                                option.data[rowIndex + i].HTaxPrice = HTaxPrice;
                                option.data[rowIndex + i].HMoney = HMoney;
                                option.data[rowIndex + i].HlineTotal = HlineTotal;
                            }
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                            layer.close(index);//关闭弹窗
                        }
                        , end: function () {
                            if (typeof (HDataEmp.HItemID) != "undefined") {
                                var value = subHTaxRate;
                                //数值格式校验工具
                                var ref = /^\d+(\.\d+)?$/;
                                //税率数据格式校验,若根据客户获取的税率不合法,则使用记录中原有的税率,并提示
                                temp = value + "";
                                if (ref.test(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 HQty = obj.data.HQty * 1;                           //数量
                                    var HPrice = obj.data.HPrice * 1;               //单价
                                    var HTaxRate = value * 0.01;           //税率
                                    var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                                    var HMoney = HQty * HPrice;                     //金额=数量*单价
                                    var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                                    var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                    //数字精度
                                    HQty = Number(HQty.toFixed(HQtyDec));
                                    HPrice = Number(HPrice.toFixed(HPriceDec));
                                    HMoney = Number(HMoney.toFixed(HMoneyDec));
                                    HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                    HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HQty: HQty
                                        , HPrice: HPrice
                                        , HTaxRate: HTaxRate * 100
                                        , HTaxPrice: HTaxPrice
                                        , HMoney: HMoney
                                        , HlineTotal: HlineTotal
                                    });
                                }
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": HDataEmp.HItemID
                                    , "物料代码": HDataEmp.物料代码
                                    , "物料名称": HDataEmp.物料名称
                                    , "规格型号": HDataEmp.规格型号
                                    , "HUnitID": HDataEmp.HUnitID
                                    , "计量单位": HDataEmp.计量单位名称
                                })
                                HDataEmp = {};
                            }
                        }
                    })
                });
            }
            //#endregion
            //#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
            //#region å­è¡¨1:隐藏列设置
            function get_HideColumn() {
@@ -3422,6 +3741,32 @@
            }
            //#endregion
            //#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 åˆ·æ–°è¡¨æ ¼åŒæ—¶æ ¹æ®option中HisStockGoods值设置下拉列表
            function setSelectHisStockGoodsByTableRender() {
                for (var i = 1; i <= option.data.length; i++) {
@@ -3447,6 +3792,16 @@
            getEmpInfoByHEmpID(obj[0].HItemID)
        }
        function GetHCusNameValue(obj)  //返回客户
        {
            //$("#HCusName").val(obj[0].HName);
            //$("#HCusID").val(obj[0].HItemID);
            //根据客户获取相关信息
            getCustomerByCusID(obj[0].HItemID);
            //根据客户获取客户余额
            getCustomerBalance(obj[0].HItemID);
        }
        function GetHSupValue(obj)  //返回客户
        {
            //$("#HCusName").val(obj[0].HName);
@@ -3459,7 +3814,7 @@
        function GetHManagerValue(obj)  //返回主管
        {
            $("#HManagerName").val(obj[0].HName);
            $("#HManagerName").val(obj[0].职员名称);
            $("#HManagerID").val(obj[0].HItemID);
        }
@@ -3481,12 +3836,12 @@
            $("#HSellSID").val(obj[0].HItemID);
        }
        function GetMaterValue(obj)           //物料名称
        function GetGyMaterial(obj)           //物料名称
        {
            HDataEmp = obj[0];
            HDataEmp = obj;
        }
        function GetUnitValue(obj)           //计量单位
        function GetAuxiliaryUnitValue(obj)           //计量单位
        {
            HDataEmp = obj[0];
        }
@@ -3495,6 +3850,39 @@
        {
            HDataEmp = obj[0];
        }
        //项目代码
        function GetProjectBillValue(obj) {
            if (obj[0].关闭人 == null || obj[0].关闭人 == "") {
                $("#HProjectID").val(obj[0].HInterID);
                $("#HProjectNumber").val(obj[0].项目代码);//工程项目代码
                $("#HProjectName").val(obj[0].项目名称);//工程项目代码
            } else {
                layer.msg("该项目已关闭,不可选择!");
            }
        }
        //双击返回仓库
        function GetHWHSubValue(data) {
            HDataEmp = data[0]
        }
        function GetHWHValue(obj)  //返回仓库
        {
            $("#HWHName").val(obj[0].仓库名称);
            $("#HWHID").val(obj[0].HItemID);
            if (option.data.length > 0) {
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HWHID"] == 0 || option.data[i]["仓库"] == undefined) {
                        option.data[i]["HWHID"] = obj[0].HItemID;
                        option.data[i]["仓库"] = obj[0].仓库名称;
                    }
                }
            }
            layui.table.render(option);
        }
        //#region æ ¹æ®å®¢æˆ·èŽ·å–å¸åˆ«ã€æ±‡çŽ‡ã€ç»“ç®—æ–¹å¼ã€å®¢æˆ·ä¿¡ç”¨é¢åº¦ã€è”ç³»äººã€è”ç³»ç”µè¯
        function getCustomerByCusID(HCusID) {
@@ -3547,7 +3935,7 @@
                        subHTaxRate = data.HTaxRate;
                    } else {
                        layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                    }
                }, error: function () {
                    layer.alert("发生错误!", { icon: 5 });
@@ -3614,38 +4002,7 @@
        }
        //#endregion
        //项目代码
        function GetProjectBillValue(obj) {
            if (obj[0].关闭人 == null || obj[0].关闭人 == "") {
                $("#HProjectID").val(obj[0].HInterID);
                $("#HProjectNumber").val(obj[0].项目代码);//工程项目代码
                $("#HProjectName").val(obj[0].项目名称);//工程项目代码
            } else {
                layer.msg("该项目已关闭,不可选择!");
            }
        }
        //双击返回仓库
        function GetHWHSubValue(data) {
            OptionData = data[0]
        }
        function GetHWHValue(obj)  //返回仓库
        {
            $("#HWHName").val(obj[0].仓库名称);
            $("#HWHID").val(obj[0].HItemID);
            if (option.data.length > 0) {
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HWHID"] == 0 || option.data[i]["仓库"] == undefined) {
                        option.data[i]["HWHID"] = obj[0].HItemID;
                        option.data[i]["仓库"] = obj[0].仓库名称;
                    }
                }
            }
            layui.table.render(option);
        }
        //#region å¤„理小数显示位数(data:需要处理的数据;num:数据的类型(如1:数量;2:金额;3:单价))
        function dealDoubleToFixed(data, num) {
            //用于设置小数位数