yangle
16 小时以前 76824fbc74817dc6a87cef54c2ab18705490356e
WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥/Add_Edit_Xs_SeOrderBillList.html
@@ -77,7 +77,7 @@
                                        <div class="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">
                                            </div>
@@ -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;">
                                                <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,15 @@
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">产品类型</label>
                                            <div class="layui-input-inline">
                                                <select name="HProductType" id="HProductType" lay-filter="HProductType" style="width: 180px; ">
                                                    <option style="color:blue;" selected="selected" value="非样品">非样品</option>
                                                    <option style="color:blue;" value="样品">样品</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">结算方式<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
@@ -166,7 +175,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>
@@ -221,6 +230,34 @@
                                            <label class="layui-form-label">需求金额<i class="layui-icon layui-icon-tips" id="tips-HBillMoney"></i></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HBillMoney" id="HBillMoney" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row" style="display:none;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">项目代码</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" lay-verify="HProjectNumber" name="HProjectNumber" id="HProjectNumber" value="" style="background-color: #efefef4d;float: left; width: 150px;" readonly>
                                                <input type="hidden" name="HProjectID" id="HProjectID" lay-verify="HProjectID" value="0">
                                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearchHProNumber" id="btnSearchHProNumber" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">项目名称</label>
                                            <div class="layui-input-block">
                                                <input type="text" class="layui-input" lay-verify="HProjectName" name="HProjectName" id="HProjectName" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <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;">
                                                <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>
                                            </div>
                                        </div>
                                    </div>
@@ -384,6 +421,9 @@
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                            <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>
@@ -406,13 +446,23 @@
        </select>
    </script>
    <script>
        //#region æ–‡æœ¬æ¡†è¾“入搜索相关数据-变量
        var childPage = null;                       //获取子窗口对象,用于操作子窗口的变量和方法
        var currRowIndex = 0;                       //用于定位子窗口当前选中的行
        var childData = null;                       //用于获取子窗口返回的数据
        //#endregion
        //#region æŠ˜å æ³¨é‡Š
        var HDataEmp = {};
        //#endregion
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
        }).use(['index', 'form', 'laydate', 'table', 'element', 'tableSelect'], function () {
            //#region å…¬ç”¨å˜é‡
            var $ = layui.$
@@ -421,10 +471,13 @@
                , table = layui.table
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
                , element = layui.element
                , tableSelect = layui.tableSelect;
            //子表渲染参数
            var option = {};
            window.option = {};
            var topScroll = 0;//记录滚动条的位置
            var titleData = ["HMaterID", "HUnitID", "折扣率", "实际含税单价", "税额", "本位币价税合计", "出库数量", "开票数量", "HOrderLevID", "订单等级代码", "销售出库数量", "销售出库审核数量", "销售出库审核金额", "生产数量", "销售退库数量", "销售退库审核数量"];//不需要显示的字段 å¯æ‰©å±•
            //记录组织的值
            var HOrgIDBar = 0;
@@ -438,11 +491,16 @@
            var params = get_UrlVars();
            var OperationType = params[params[0]]; //从参数中获取 æ•°æ®ç±»åž‹  1添加 ä¿å­˜  2复制  3 ç¼–辑
            var linterid = params[params[1]]; //从参数中获取 å•据内码
            //需要批量删除的列表
            var btnBatchDeleteList = [];
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //检测是否具备查看金额权限,设置隐藏列
            checkRight_Money();
            //#region åˆ¤æ–­æ˜¯å¦ç™»å½• æœªç™»å½•则跳到登录页
            get_LoginIs();
@@ -464,14 +522,7 @@
                set_InitGrid();
                //加载表体和表体数据
                RoadBillMain(linterid);
                //根据销售订单类型设置子表是否取库存选项
                setHisStockGoodsByHBillSubType_For_RoadBillMain();
                //根据是否取库存获取定金比例
                setHEarnestRateByHisStockGoods();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
                //生成并设置主表的内码和单据号
                createBillNo();
@@ -489,14 +540,6 @@
                set_InitGrid();
                //加载表体和表体数据
                RoadBillMain(linterid);
                //根据销售订单类型设置子表是否取库存选项
                setHisStockGoodsByHBillSubType_For_RoadBillMain();
                //根据是否取库存获取定金比例
                setHEarnestRateByHisStockGoods();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
            }
            //#endregion
@@ -509,7 +552,7 @@
            //#endregion
            //#region åˆ—设置:子表1
            //DisPlay_HideColumn();
            DisPlay_HideColumn();
            //#endregion
            //#endregion
@@ -560,6 +603,113 @@
            //#region é€‰æ‹©ç»“算方按钮
            form.on('submit(HPayCusList)', function () {
                get_checkPayCus();
            });
            //#endregion
            //#region é€‰æ‹©é¡¹ç›®ä»£ç æŒ‰é’®
            form.on('submit(btnSearchHProNumber)', function () {
                get_checkSearchHProNumber();
            });
            //#endregion
            //#region é€‰æ‹©ä»“库按钮
            form.on('submit(HWHList)', function () {
                get_checkWH();
            });
             //#endregion
            //#endregion
            //#region è¡¨å¤´åŸºç¡€èµ„料选择弹窗
            //#region æ–‡æœ¬æ¡†ç›‘听
            $(document).ready(function () {
                //#region é”€å”®å‘˜åŸºç¡€èµ„料筛选弹窗
                $("#HEmpName").on('keydown', function (data) {
                    var errKeys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Enter"];
                    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 = $("#HEmpName").val().replace(/'/g, "");                                  //获取文本框最新值
                                        currRowIndex = 0;
                                        var tableView = "h_v_IF_EmployeeList";
                                        var childSWhere = "select top(10) HItemID,职员名称 from " + tableView + " where 1=1 and ç»„织名称 = '" + sessionStorage["Organization"] + "' and (职员代码 like '%" + value + "%' or èŒå‘˜åç§° like '%" + value + "%') order by èŒå‘˜ä»£ç ";
                                        childPage.getData(childSWhere, tableView);
                                    }, 200);
                                }
                                , end: function () {
                                    childPage = null;
                                    currRowIndex = 0;
                                    if (childData != null) {
                                        $("#HEmpName").val(childData.职员名称);
                                        $("#HEmpID").val(childData.HItemID);
                                        getEmpInfoByHEmpID(childData.HItemID);
                                        childData = null;
                                    }
                                }
                            });
                        } else {
                            setTimeout(function () {
                                var value = $("#HEmpName").val().replace(/'/g,"");                                  //获取文本框最新值
                                currRowIndex = 0;
                                var tableView = "h_v_IF_EmployeeList";
                                var childSWhere = "select top(10) HItemID,职员名称 from " + tableView + " where 1=1 and ç»„织名称 = '" + sessionStorage["Organization"] + "' and (职员代码 like '%" + value + "%' or èŒå‘˜åç§° like '%" + value + "%') order by èŒå‘˜ä»£ç ";
                                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 ($("#HEmpName").val() == "") {
                                $("#HEmpName").val("");
                                $("#HEmpID").val("0");
                                $("#HDeptID").val("0");
                                $("#HDeptName").val("");
                            } else {
                                $("#HEmpName").val(childData.职员名称);
                                $("#HEmpID").val(childData.HItemID);
                                getEmpInfoByHEmpID(childData.HItemID);
                            }
                            childPage = null;
                            currRowIndex = 0;
                            childData = null;
                        }
                    }
                });
                //#endregion
            });
            //#endregion
            //#endregion
@@ -619,6 +769,8 @@
                    "规格型号": "",
                    "HUnitID": "0",
                    "计量单位": "",
                    "HWHID": "0",
                    "仓库":"",
                    "HQty": "0",
                    "HPrice": "0",
                    "HTaxPrice": "0",
@@ -633,6 +785,8 @@
                    "HisStockGoods": "false",
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark_TL": "",
                    "HRemark_SJG": "",
                    "HRemark": "",
                    "HCusMaterNumber": "",
                    "HCusModel": "",
@@ -663,9 +817,18 @@
                    //下移
                    case 'btn-Under': btn_under();
                        break;
                    //批量删除
                    case 'btn-batchDelete': btn_batchDelete();
                        break;
                    //列设置
                    case 'set_HideColumn':
                        get_HideColumn();
                        break;
                    //库存查询
                    case 'get_Inventory': get_Inventory();
                        break;
                    //出入库记录查询
                    case 'get_InOutSum': get_InOutSum();
                        break;
                }
            });
@@ -699,7 +862,11 @@
                //数值格式校验工具
                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"];  //金额精度
                topScroll = $('#mainTable').next('.layui-table-view').find('.layui-table-body').scrollTop();//获取滚动条位置
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -738,13 +905,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({
@@ -755,7 +921,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -822,13 +988,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(HTaxPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -839,7 +1004,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -877,13 +1042,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(HTaxPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -894,7 +1058,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -962,13 +1126,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(HTaxPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
@@ -979,7 +1142,7 @@
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        //table.render(option);
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
@@ -989,6 +1152,32 @@
                        break;
                    default:
                }
            });
            //#endregion
            //#region ç›‘听复选框选中事件
            table.on('checkbox(mainTable)', function (obj) {
                //获取选中行的索引列表
                var rowIndex = $(obj.tr).attr("data-index");
                if (typeof (rowIndex) == "undefined") {
                    if (btnBatchDeleteList.length == option.data.length) {
                        btnBatchDeleteList = [];
                    } else {
                        btnBatchDeleteList = [];
                        for (var i = 0; i < option.data.length; i++) {
                            btnBatchDeleteList.push(i + "");
                        }
                    }
                } else {
                    if ($.inArray(rowIndex, btnBatchDeleteList) > -1) {
                        var btnBatchDeleteList_New = btnBatchDeleteList.filter(item => item !== rowIndex);
                        btnBatchDeleteList = btnBatchDeleteList_New;
                    } else {
                        btnBatchDeleteList.push(rowIndex);
                    }
                }
                console.log(btnBatchDeleteList);
            });
            //#endregion
            //#endregion
@@ -1165,7 +1354,11 @@
                        , { 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' }
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, edit: 'text', event: "HQty" }
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
@@ -1206,6 +1399,7 @@
                                }
                            });
                        });
                        $(".layui-table-main").scrollTop(topScroll);
                    }
                }
@@ -1219,6 +1413,8 @@
                    "规格型号": "",
                    "HUnitID": "0",
                    "计量单位": "",
                    "HWHID": "0",
                    "仓库":"",
                    "HQty": "0",
                    "HPrice": "0",
                    "HTaxPrice": "0",
@@ -1233,6 +1429,8 @@
                    "HisStockGoods": "false",
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark_TL": "",
                    "HRemark_SJG": "",
                    "HRemark": "",
                    "HCusMaterNumber": "",
                    "HCusModel": "",
@@ -1325,6 +1523,12 @@
                                , "HLinkMan": data.联系人
                                , "HExplanation": data.摘要
                                , "HLinkPhone": data.联系电话
                                , "HProjectID": data.HProjectID
                                , "HProjectNumber": data.项目编码
                                , "HProjectName": data.项目名称
                                , "HWHID": data.主仓库id
                                , "HWHName": data.主仓库
                                , "HProductType": data.产品类型
                                , "HCreditRating_Now": data.HCreditRating_Now
                                , "HRemark": data.表头备注
                                , "HMaker": data.制单人
@@ -1360,9 +1564,11 @@
                                        "规格型号": result.data[i]["规格型号"],
                                        "HUnitID": result.data[i]["HUnitID"],
                                        "计量单位": result.data[i]["计量单位"],
                                        "HWHID": result.data[i]["HWhID"],
                                        "仓库": 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]["实际含税单价"],
@@ -1374,6 +1580,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]["客户规格型号"],
@@ -1389,20 +1597,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);
@@ -1428,7 +1634,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售员列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_EmployeeList.html?Type=HEmp', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?Type=HEmp', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1436,7 +1642,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].HName);
                        $("#HEmpName").val(checkStatus.data[0].职员名称);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        getEmpInfoByHEmpID(checkStatus.data[0].HItemID);
@@ -1446,12 +1652,14 @@
                        $("#HEmpName").val("");
                        $("#HEmpID").val("0");
                        getEmpInfoByHEmpID("0");
                        $("#HDeptID").val("0");
                        $("#HDeptName").val("");
                    }
                })
            }
            //#endregion
            //#region å®¢æˆ·é€‰æ‹©é¡µé¢
            //#region å®¢æˆ·é€‰æ‹©é¡µé¢
            function get_checkCus() {
                var HEmpID = $("#HEmpID").val();
@@ -1478,6 +1686,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 ç»“算方选择页面
@@ -1539,7 +1776,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售部门列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_DepartmentList.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1547,7 +1784,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        $("#HDeptName").val(checkStatus.data[0].部门名称);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -1589,7 +1826,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_SellStyle.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_SellStyle.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1597,7 +1834,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSellSName").val(checkStatus.data[0].HName);
                        $("#HSellSName").val(checkStatus.data[0].销售方式名称);
                        $("#HSellSID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -1614,7 +1851,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '结算方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_SettleStyle.html', 'yes']
                    , content: ['../../基础资料/基础资料/Gy_SettleStyle.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1622,7 +1859,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSSName").val(checkStatus.data[0].HName);
                        $("#HSSName").val(checkStatus.data[0].结算方式名称);
                        $("#HSSID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -1630,6 +1867,83 @@
                })
            }
            //#endregion
            //#region é¡¹ç›®ä»£ç é€‰æ‹©é¡µé¢
            function get_checkSearchHProNumber() {
                var HOrgID = $("#HOrgID").val();
                //打开工程项目小窗体
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim"                           //加上边框
                    , title: "工程项目列表"                             //标题
                    , closeBtn: 1                                       //窗体右上角关闭 çš„ æ ·å¼
                    , shift: 2                                          //弹出动画
                    , area: ["90%", "90%"]                              //窗体大小
                    , maxmin: true                                      //设置最大最小按钮是否显示
                    , content: ["../../项目管理/工程项目/PM_ProjectBillList.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");//获取选中的数据
                        if (checkStatus.data.length != 1) {
                            return layer.msg("请选择一条数据");
                        }
                        //判断项目是否关闭
                        if (checkStatus.data[0].关闭人 == null || checkStatus.data[0].关闭人 == "") {
                            $("#HProjectID").val(checkStatus.data[0].HInterID);
                            $("#HProjectNumber").val(checkStatus.data[0].项目代码);//工程项目代码
                            $("#HProjectName").val(checkStatus.data[0].项目名称);//工程项目代码
                        } else {
                            layer.msg("该项目已关闭,不可选择!");
                        }
                        layer.close(index);//关闭弹窗
                    }
                    , btn2: function (index, layero) { }
                    , end: function () { }
                })
            }
            //#endregion
            //#region ä»“库
            function get_checkWH() {
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '仓库列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../基础资料/公用基础资料/Gy_Warehouse.html?Type=HWH', '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('请选择数据');
                        }
                        $("#HWHName").val(checkStatus.data[0].仓库名称);
                        $("#HWHID").val(checkStatus.data[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]["HWHID"] = checkStatus.data[0].HItemID;
                                    option.data[i]["仓库"] = checkStatus.data[0].仓库名称;
                                }
                            }
                        }
                        table.render(option);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
            //#endregion
            //#region ä¿å­˜æ–¹æ³•
@@ -1670,6 +1984,11 @@
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { icon: 1 });
                            if (data.Verify == "Y") //自动审核
                            {
                                $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                                set_CheckBill(0); //审核
                            }
                            $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                            layer.close(index);
                        }
@@ -1768,11 +2087,13 @@
                //#endregion
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
                var RowCount = 0;
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HMaterID"] == "0") {
                        layer.msg("第" + i + "行:物料未选择!");
                        return false;
                        continue;
                    }
                    RowCount++;
                    if (option.data[i]["HUnitID"] == "0") {
                        layer.msg("第" + i + "行:计量单位未选择!");
@@ -1811,6 +2132,11 @@
                    temp = option.data[i]["HTaxRate"] + "";
                    if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入不小于0的数字!");
                        return false;
                    }
                    if (temp != "0" && option.data[i]["HTaxPrice"] == option.data[i]["HPrice"]) {
                        layer.msg("第" + i + "行:当前税率不为0,单价与含税单价一致,请检查数据是否正确!");
                        return false;
                    }
@@ -1935,18 +2261,22 @@
                    //    return false;
                    //}
                }
                if (RowCount == 0) {
                    layer.msg("保存失败,子表至少需要存在一行记录选择了物料!");
                    return false;
                }
                //#endregion
                //#region å­è¡¨ å…³é”®å­—重复校验
                var num = [];
                for (var i = 0; i < option.data.length; i++) {
                    if ($.inArray(option.data[i]["HMaterID"], num) == -1) {
                        num.push(option.data[i]["HMaterID"]);
                    } else {
                        layer.msg("第" + (i + 1) + "行,物料:" + option.data[i]["HMaterID"] + "重复!");
                        return false;
                    }
                }
                //var num = [];
                //for (var i = 0; i < option.data.length; i++) {
                //    if ($.inArray(option.data[i]["HMaterID"], num) == -1) {
                //        num.push(option.data[i]["HMaterID"]);
                //    } else {
                //        layer.msg("第" + (i + 1) + "行,物料:" + option.data[i]["HMaterID"] + "重复!");
                //        return false;
                //    }
                //}
                //#endregion
                return true;
            }
@@ -2005,6 +2335,8 @@
                                        "规格型号": "",
                                        "HUnitID": "0",
                                        "计量单位": "",
                                        "HWHID": "0",
                                        "仓库": "",
                                        "HQty": "0",
                                        "HPrice": "0",
                                        "HTaxPrice": "0",
@@ -2019,6 +2351,8 @@
                                        "HisStockGoods": "false",
                                        "HOutStockQty": "0",
                                        "HInvoiceQty": "0",
                                        "HRemark_TL": "",
                                        "HRemark_SJG": "",
                                        "HRemark": "",
                                        "HCusMaterNumber": "",
                                        "HCusModel": "",
@@ -2064,6 +2398,8 @@
                                    "规格型号": "",
                                    "HUnitID": "0",
                                    "计量单位": "",
                                    "HWHID": "0",
                                    "仓库": "",
                                    "HQty": "0",
                                    "HPrice": "0",
                                    "HTaxPrice": "0",
@@ -2078,6 +2414,8 @@
                                    "HisStockGoods": "false",
                                    "HOutStockQty": "0",
                                    "HInvoiceQty": "0",
                                    "HRemark_TL": "",
                                    "HRemark_SJG": "",
                                    "HRemark": "",
                                    "HCusMaterNumber": "",
                                    "HCusModel": "",
@@ -2259,6 +2597,30 @@
            }
            //#endregion
            //#region æ‰¹é‡åˆ é™¤
            function btn_batchDelete() {
                var data = [];
                for (var i = 0; i < option.data.length; i++) {
                    if ($.inArray(i+"", btnBatchDeleteList) == -1) {
                        data.push(option.data[i]);
                    }
                }
                option.data = data;
                table.render(option);
                btnBatchDeleteList = [];
                //刷新表格同时根据option中HisStockGoods值设置下拉列表
                setSelectHisStockGoodsByTableRender();
                //根据是否取库存获取定金比例
                //setHEarnestRateByHisStockGoods();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
            }
            //#endregion
            //#region è¡¨æ ¼è¡Œå†…事件删除
            function set_GridDelete(obj) {
                var data = obj.data;
@@ -2266,7 +2628,7 @@
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                        if (rowIndex === '0' && table.cache["mainTable"].length == 1) {
                            layer.msg('首行无法删除!!!');
                        } else {
                            //obj.del();
@@ -2275,6 +2637,15 @@
                            oldData.splice(obj.tr.data('index'), 1);
                            option.data = oldData;
                            table.render(option);
                            //更新批量删除索引列表
                            var btnBatchDeleteList_New = btnBatchDeleteList.filter(item => item !== rowIndex);
                            btnBatchDeleteList = btnBatchDeleteList_New;
                            for (var i = 0; i < btnBatchDeleteList.length; i++) {
                                if (btnBatchDeleteList[i] * 1 > rowIndex * 1) {
                                    btnBatchDeleteList[i] = (btnBatchDeleteList[i] * 1 - 1) + "";
                                }
                            }
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
@@ -2313,6 +2684,203 @@
            //#region è¡Œå†…快捷键筛选
            function set_GridCellCheck(obj) {
                $(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"];
                    //    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("'", "");                                  //获取文本框最新值
                    //                            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) {
                    //                            var rowIndex = $(obj.tr).attr("data-index") * 1;
                    //                            var Dec = getDecByMaterID(childData.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"];  //金额精度
                    //                            //数值格式校验工具
                    //                            var ref = /^\d+(\.\d+)?$/;                                  //非负数正则表达式
                    //                            var temp = "";
                    //                            //获取选择物料前后的税率
                    //                            var value_TaxRate = subHTaxRate;                                    //选择物料后根据客户得到的税率
                    //                            var oldText = option.data[rowIndex].HTaxRate;           //该记录中原有的税率
                    //                            //税率数据格式校验,若根据客户获取的税率不合法,则使用记录中原有的税率,并提示
                    //                            temp = value_TaxRate + "";
                    //                            if (!ref.test(temp)) {
                    //                                value_TaxRate = oldText;
                    //                                layer.msg("获取到的税率不合法,已自动变更为原有税率!");
                    //                            }
                    //                            //数据校验合格,重算记录
                    //                            var HQty = option.data[rowIndex].HQty * 1;                  //数量
                    //                            var HPrice = option.data[rowIndex].HPrice * 1;              //单价
                    //                            var HTaxRate = value_TaxRate * 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].HMaterID = childData.HItemID;
                    //                            option.data[rowIndex].物料代码 = childData.物料代码;
                    //                            option.data[rowIndex].物料名称 = childData.物料名称;
                    //                            option.data[rowIndex].规格型号 = childData.规格型号;
                    //                            option.data[rowIndex].HUnitID = childData.HUnitID;
                    //                            option.data[rowIndex].计量单位 = childData.计量单位名称;
                    //                            option.data[rowIndex].HQty = HQty;
                    //                            option.data[rowIndex].HPrice = HPrice;
                    //                            option.data[rowIndex].HTaxRate = HTaxRate * 100;
                    //                            option.data[rowIndex].HTaxPrice = HTaxPrice;
                    //                            option.data[rowIndex].HMoney = HMoney;
                    //                            option.data[rowIndex].HlineTotal = HlineTotal;
                    //                            table.render(option);
                    //                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                    //                            setSelectHisStockGoodsByTableRender();
                    //                            //设置表头所需金额
                    //                            set_HBillMoney($("#HEarnestRate").val() * 1);
                    //                            childData = null;
                    //                        }
                    //                    }
                    //                });
                    //            } else {
                    //                setTimeout(function () {
                    //                    var value = $(e.currentTarget).val().replace("'", "");                                  //获取文本框最新值
                    //                    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);
                    //                var Dec = getDecByMaterID(childData.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"];  //金额精度
                    //                //数值格式校验工具
                    //                var ref = /^\d+(\.\d+)?$/;                                  //非负数正则表达式
                    //                var temp = "";
                    //                //获取选择物料前后的税率
                    //                var value_TaxRate = subHTaxRate;                                    //选择物料后根据客户得到的税率
                    //                var oldText = option.data[rowIndex].HTaxRate;           //该记录中原有的税率
                    //                //税率数据格式校验,若根据客户获取的税率不合法,则使用记录中原有的税率,并提示
                    //                temp = value_TaxRate + "";
                    //                if (!ref.test(temp)) {
                    //                    value_TaxRate = oldText;
                    //                    layer.msg("获取到的税率不合法,已自动变更为原有税率!");
                    //                }
                    //                //数据校验合格,重算记录
                    //                var HQty = option.data[rowIndex].HQty * 1;                  //数量
                    //                var HPrice = option.data[rowIndex].HPrice * 1;              //单价
                    //                var HTaxRate = value_TaxRate * 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].HMaterID = childData.HItemID;
                    //                option.data[rowIndex].物料代码 = childData.物料代码;
                    //                option.data[rowIndex].物料名称 = childData.物料名称;
                    //                option.data[rowIndex].规格型号 = childData.规格型号;
                    //                option.data[rowIndex].HUnitID = childData.HUnitID;
                    //                option.data[rowIndex].计量单位 = childData.计量单位名称;
                    //                option.data[rowIndex].HQty = HQty;
                    //                option.data[rowIndex].HPrice = HPrice;
                    //                option.data[rowIndex].HTaxRate = HTaxRate * 100;
                    //                option.data[rowIndex].HTaxPrice = HTaxPrice;
                    //                option.data[rowIndex].HMoney = HMoney;
                    //                option.data[rowIndex].HlineTotal = HlineTotal;
                    //                table.render(option);
                    //                //刷新表格同时根据option中HisStockGoods值设置下拉列表
                    //                setSelectHisStockGoodsByTableRender();
                    //                //设置表头所需金额
                    //                set_HBillMoney($("#HEarnestRate").val() * 1);
                    //                childPage = null;
                    //                currRowIndex = 0;
                    //                childData = null;
                    //                obj.event = "";
                    //            }
                    //        }
                    //    }
                    //}
                    //#endregion
                    if (event.key == "F7") {
                        //物料
                        if (obj.event == "HMaterID") {
@@ -2326,25 +2894,25 @@
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../基础资料/公用基础资料/Gy_Material.html?openType=2&HOrgID=' + HOrgID, 'yes']
                                , content: ['../../基础资料/公用基础资料/Gy_Material.html?openType=2&HOrgID=' + HOrgID + '&openType2=SeOrder', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    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);
                                        }
@@ -2367,8 +2935,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+税率)
@@ -2377,7 +2945,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.物料代码;
@@ -2405,6 +2979,56 @@
                                    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 = {};
                                    }
                                }
                            })
                        }
                        //计量单位
@@ -2417,7 +3041,7 @@
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../Baseset/基础资料/Gy_UnitList.html', 'yes']
                                , content: ['../../基础资料/公用基础资料/Gy_Unit.html?type=AuxiliaryUnit', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
@@ -2429,13 +3053,65 @@
                                    }
                                    //更新表格缓存的数据
                                    obj.update({
                                        "计量单位": checkStatus.data[0].HName
                                        "计量单位": checkStatus.data[0].计量单位名称
                                        , "HUnitID": checkStatus.data[0].HItemID
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                    if (typeof (HDataEmp.HItemID) != "undefined") {
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HUnitID": HDataEmp.HItemID
                                            , "计量单位": HDataEmp.计量单位名称
                                        })
                                        HDataEmp = {};
                                    }
                                }
                            })
                        }
                        //仓库
                        if (obj.event == "HWHID") {
                            layer.open({
                                type: 2
                                , skin: "layui-layer-rim" //加上边框
                                , title: "仓库列表"  //标题
                                , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../基础资料/公用基础资料/Gy_Warehouse.html?type=HWHSub', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HWHID": checkStatus.data[0].HItemID,
                                        "仓库": checkStatus.data[0].仓库名称
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                    if (typeof (HDataEmp.HItemID) != "undefined") {
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HWHID": HDataEmp.HItemID
                                            , "仓库": HDataEmp.仓库名称
                                        })
                                        HDataEmp = {};
                                    }
                                }
                            })
                        }
                        //订单等级
                        if (obj.event == "HOrderLevID") {
                            layer.open({
@@ -2463,6 +3139,16 @@
                                        , "HOrderLevID": checkStatus.data[0].HItemID
                                    })
                                    layer.close(index);//关闭弹窗
                                }, end: function () {
                                    if (typeof (HDataEmp.HItemID) != "undefined") {
                                        //更新表格缓存的数据
                                        obj.update({
                                            "订单等级名称": HDataEmp.订单等级
                                            , "订单等级代码": HDataEmp.订单等级代码
                                            , "HOrderLevID": HDataEmp.HItemID
                                        })
                                        HDataEmp = {};
                                    }
                                }
                            })
                        }
@@ -2787,14 +3473,362 @@
                            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 element = document.getElementById("HBillNo");
                    element.focus();
                    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 + '&openType2=SeOrder', '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 = {};
                            }
                        }
                    })
                    obj.event = "";
                });
                //物料表格下拉搜索框
                tableSelect.render({
                    elem: 'td[data-field="物料代码"] .layui-table-edit',
                    checkedKey: 'HItemID',
                    searchKey: '物料代码,物料名称',
                    sWhere: " and ç‰©æ–™å±žæ€§='自制'",//table搜索sWhere条件
                    table: {
                        url: GetWEBURL() + 'Gy_Material/page',
                        where: { user: sessionStorage["HUserName"], Organization: sessionStorage["Organization"] },
                        cols: [[
                            { type: 'checkbox', fixed: 'left' },
                            { field: 'HItemID', title: 'HItemID' },
                            { field: '物料代码', title: '物料代码' },
                            { field: '物料名称', title: '物料名称' },
                        ]],
                        page: true,
                        limit: 5,
                        limits: [5]
                    },
                    done: function (elem, data) {
                        if (data != []) {
                            checkStatus = data;
                            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);
                        }
                    }
                })
            }
            //#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() {
@@ -2835,13 +3869,14 @@
            function DisPlay_HideColumn() {
                $.ajax({
                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                    async: false,
                    type: "GET",
                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                    async: false,
                    success: function (data1) {
                        if (data1.data.length != 0) {
                            var dataCol = [];//数据库查询出的列数据
                            var titleData = ["HMaterID", "HUnitID", "折扣率", "实际含税单价", "税额", "本位币价税合计", "出库数量", "开票数量", "HOrderLevID","订单等级代码","销售出库数量","销售出库审核数量","销售出库审核金额","生产数量","销售退库数量","销售退库审核数量"];//不需要显示的字段 å¯æ‰©å±•
                            /*var titleData = ["HMaterID", "HUnitID", "折扣率", "实际含税单价", "税额", "本位币价税合计", "出库数量", "开票数量", "HOrderLevID","订单等级代码","销售出库数量","销售出库审核数量","销售出库审核金额","生产数量","销售退库数量","销售退库审核数量"];//不需要显示的字段 å¯æ‰©å±•*/
                            //titleData = [];
                            dataCol = data1.data[0].HGridString.split(',');
@@ -2872,6 +3907,10 @@
                                if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
                                    option.cols[0][i + 1]["hide"] = false;
                                }
                                if ($.inArray(option.cols[0][i + 1]["title"], titleData) > -1) {
                                    option.cols[0][i + 1]["hide"] = true;
                                }
                                //字体所在位置(å·¦ å±…中 å³)
                                switch (dataCols[2]) {
                                    case "L":
@@ -2883,6 +3922,11 @@
                                    case "R":
                                        option.cols[0][i + 1]["align"] = "right";
                                        break;
                                }
                                //设置表格title属性显示别名
                                if (dataCols[4] != null && dataCols[4] != "") {
                                    option.cols[0][i + 1]["title"] = dataCols[4];
                                }
                            }
@@ -3009,9 +4053,7 @@
            function set_HBillMoney(HEarnestRate) {
                var HBillMoney = 0;
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HisStockGoods"] == "false") {
                        HBillMoney += option.data[i]["HlineTotal"] * 1;
                    }
                    HBillMoney += option.data[i]["HlineTotal"] * 1;
                }
@@ -3024,9 +4066,15 @@
            function setHEarnestRateByHisStockGoods() {
                if (option.data.length > 0 && option.data[0]["HisStockGoods"] == "true") {
                    var HEarnestRateList = '<option  value="0" selected="selected" >0%</option>';
                    HEarnestRateList += '<option  value="100" >100%</option>';
                    $("#HEarnestRate").empty();
                    $("#HEarnestRate").append(HEarnestRateList);
                    //var HEarnestRateListArray = ["0", "100"];
                    //if ($.inArray(HEarnestRateTemp+"", HEarnestRateListArray) > -1) {
                    //    $("#HEarnestRate").val(HEarnestRateTemp);
                    //}
                    form.render('select');
                } else if (option.data.length > 0 && option.data[0]["HisStockGoods"] == "false") {
                    var HEarnestRateList = '<option  value="50" selected="selected" >50%</option>';
@@ -3035,7 +4083,7 @@
                    $("#HEarnestRate").empty();
                    $("#HEarnestRate").append(HEarnestRateList);
                    /*form.render('select');*/
                    $("#HEarnestRate").val(HEarnestRateTemp);
                    //$("#HEarnestRate").val(HEarnestRateTemp);
                    form.render('select');
                } else {
                    var HEarnestRateList = '<option  value="50" selected="selected" >50%</option>';
@@ -3044,7 +4092,7 @@
                    $("#HEarnestRate").empty();
                    $("#HEarnestRate").append(HEarnestRateList);
                    //form.render('select');
                    $("#HEarnestRate").val(HEarnestRateTemp);
                  /*  $("#HEarnestRate").val(HEarnestRateTemp);*/
                    form.render('select');
                }
            }
@@ -3139,6 +4187,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++) {
@@ -3147,6 +4221,30 @@
                form.render('select');
            }
            //#endregion
            //#region æŸ¥çœ‹æ˜¯å¦å…·å¤‡æŸ¥çœ‹é‡‘额权限,设置金额等字段是否需要隐藏
            function checkRight_Money() {
                $.ajax({
                    type: "GET",
                    async: false,
                    url: GetWEBURL() + "/Xs_SeOrderBill/CheckRight_Money", //方法所在页面和方法名
                    data: { "user": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                        } else {
                            var HideColumnList = ["剩余订金", "单价", "税率%", "含税单价", "金额", "价税合计"];
                            for (var i = 0; i < HideColumnList.length; i++) {
                                titleData.push(HideColumnList[i]);
                            }
                        }
                    }, error: function (err) {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#endregion
@@ -3158,10 +4256,20 @@
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
            $("#HEmpName").val(obj[0].HName);
            $("#HEmpName").val(obj[0].职员名称);
            $("#HEmpID").val(obj[0].HItemID);
            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)  //返回客户
@@ -3176,27 +4284,75 @@
        function GetHManagerValue(obj)  //返回主管
        {
            $("#HManagerName").val(obj[0].HName);
            $("#HManagerName").val(obj[0].职员名称);
            $("#HManagerID").val(obj[0].HItemID);
        }
        function GetHDeptNameValue(obj)  //返回部门
        {
            $("#HDeptName").val(obj[0].HName);
            $("#HDeptName").val(obj[0].部门名称);
            $("#HDeptID").val(obj[0].HItemID);
        }
        function GetSettleStyleValue(obj)           //返回结算方式
        {
            $("#HSSName").val(obj[0].HName);
            $("#HSSName").val(obj[0].结算方式名称);
            $("#HSSID").val(obj[0].HItemID);
        }
        function GetSellStyleValue(obj)           //返回销售方式
        {
            $("#HSellSName").val(obj[0].HName);
            $("#HSellSName").val(obj[0].销售方式名称);
            $("#HSellSID").val(obj[0].HItemID);
        }
        function GetGyMaterial(obj)           //物料名称
        {
            HDataEmp = obj;
        }
        function GetAuxiliaryUnitValue(obj)           //计量单位
        {
            HDataEmp = obj[0];
        }
        function GetOrderLevValue(obj)           //订单等级列表
        {
            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) {
@@ -3249,7 +4405,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 });
@@ -3316,6 +4472,7 @@
        }
        //#endregion
        //#region å¤„理小数显示位数(data:需要处理的数据;num:数据的类型(如1:数量;2:金额;3:单价))
        function dealDoubleToFixed(data, num) {
            //用于设置小数位数