duhe
2025-09-02 cecb8de03f83f8e5b3cd32d3ac7eb09196ed5cf4
WebTM/views/ÏúÊÛ¹ÜÀí/·¢»õ֪ͨµ¥/Add_Edit_Xs_SeOutStockBillList.html
@@ -45,8 +45,11 @@
                <form class="layui-form" lay-filter="component-form-group" action="">
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="set_AddNew" id="set_AddNew">新增</button>
                            <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                            <button type="button" id="check-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">审核</button>
                            <button type="button" id="print-btn" class="layui-btn layui-btn-normal layui-btn-radius layui-btn-disabled" lay-submit="" lay-filter="get_PrintReport" disabled>打印</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_SelectMainBill">选整单</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius " lay-submit="" lay-filter="Exit">退出</button>
                        </div>
                    </div>
@@ -54,7 +57,9 @@
                        <h1 style="text-align: center; padding: 10px 0;"><b>发货通知单</b></h1>
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
                            <li lay-id="2" style="padding:1px;">制单信息</li>
                            <li lay-id="2" style="padding:1px;">其他信息</li>
                            <li lay-id="3" style="padding:1px;">制单信息</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--基本信息-->
@@ -64,7 +69,7 @@
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-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" value="0">
                                            </div>
@@ -109,14 +114,6 @@
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">交货地点</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HAddress" id="HAddress" autocomplete="off">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">部门<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float:left;width:150px;">
@@ -126,32 +123,8 @@
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">币别<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HCurID" id="HCurID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCurList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">汇率<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">销售订单号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HSeOrderBillNo_M" id="HSeOrderBillNo_M" autocomplete="off">
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">主管<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
@@ -162,58 +135,6 @@
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">源单类型</label>
                                            <div class="layui-input-inline">
                                                <select name="HSourceBillType" id="HSourceBillType" lay-verify="HSourceBillType">
                                                    <!--动态渲染源单类型-->
                                                </select>
                                            </div>
                                        </div>
                                        <!--<div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">运费</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HConveyMoney" id="HConveyMoney" autocomplete="off" value="0">
                                            </div>
                                        </div>-->
                                        <!--<div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">源单类型</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HSourceBillType" id="HSourceBillType" value="0">
                                            </div>
                                        </div>-->
                                    </div>
                                    <!--<div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">运输公司</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HConveyCompName" id="HConveyCompName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HConveyCompID" id="HConveyCompID" class="layui-input" value="0" style="float:left;width:150px;">
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">运输方式</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HConveyTypeName" id="HConveyTypeName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HConveyTypeID" id="HConveyTypeID" class="layui-input" value="0" style="float:left;width:150px;">
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">是否垫付</label>
                                            <div class="layui-input-inline">
                                                <input type="checkbox" name="checkboxHDFflag" id="checkboxHDFflag" lay-skin="primary" lay-filter="checkboxHDFflag" value="true" title="是否垫付">
                                                <input type="hidden" value="false" name="HDFflag" id="HDFflag">
                                            </div>
                                        </div>
                                    </div>-->
                                    <div class="layui-row">
                                        <!--<div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">选单号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="Box2" id="Box2" autocomplete="off">
                                            </div>
                                        </div>-->
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">联系人</label>
                                            <div class="layui-input-inline">
@@ -226,17 +147,7 @@
                                                <input class="layui-input" name="HLinkPhone" id="HLinkPhone" autocomplete="off">
                                            </div>
                                        </div>
                                         <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">选单号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="" id="" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;"   readonly>
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">备注</label>
@@ -261,6 +172,67 @@
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--其他信息-->
                            <div class="layui-tab-item">
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">交货地点</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HAddress" id="HAddress" autocomplete="off">
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">币别<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HCurID" id="HCurID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCurList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">汇率<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="1">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">销售订单号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HSeOrderBillNo_M" id="HSeOrderBillNo_M" autocomplete="off">
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">源单类型</label>
                                            <div class="layui-input-inline">
                                                <select name="HSourceBillType" id="HSourceBillType" lay-verify="HSourceBillType">
                                                    <!--动态渲染源单类型-->
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">选单号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSourceBillNo" id="HSourceBillNo" class="layui-input" value="" style="float: left; width: 150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">结算方式<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
@@ -274,7 +246,6 @@
                                    </div>
                                </div>
                            </div>
                            <!--制单信息-->
                            <div class="layui-tab-item">
@@ -349,6 +320,8 @@
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
@@ -375,6 +348,12 @@
    </script>
    <script>
        //#region æ–‡æœ¬æ¡†è¾“入搜索相关数据-变量
        var childPage = null;                       //获取子窗口对象,用于操作子窗口的变量和方法
        var currRowIndex = 0;                       //用于定位子窗口当前选中的行
        var childData = null;                       //用于获取子窗口返回的数据
        //#endregion
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
        layui.config({
@@ -398,7 +377,7 @@
            var shijian = year + "-" + month + "-" + day;
            var allVal;
            var topScroll = 0;//记录滚动条的位置
            var HModName = "Add_Edit_Xs_SeOutStockBillList";
            //#endregion
@@ -446,16 +425,26 @@
                layer.alert("未知操作类型!", { icon: 5 });
            }
            $("#HUSEORGID").val(sessionStorage["OrganizationID"]);
            //判断是否新增
            if (linterid == null || linterid == 0) {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '1402' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HInterID").val(d.data[0].HInterID);
                        $("#HMakeDate").val(shijian);
                        $("#HMaker").val(sessionStorage["HUserName"]);
                    }
                });
            }
            //#endregion
            var rowdata = [{
                "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "",
                "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
            }];
            // åˆå§‹åŒ–界
            set_InitGrid();
@@ -468,7 +457,7 @@
                //新增行表格数据
                var NewRow = {
                    "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                    "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "",
                    "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "","HInventoryQty":0,
                    "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                };
                switch (obj.event) {
@@ -512,6 +501,25 @@
            });
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region æ–°å¢ž
            form.on('submit(set_AddNew)', function (data) {
                const url = new URL(location.href);
                location.href = url.origin + url.pathname;
            });
            //#endregion
            //#region å®¡æ ¸æŒ‰é’®
            form.on('submit(set_CheckBill)', function (data) {
                set_CheckBill(0);
            });
            //#endregion
            //#region é€‰æ•´å•
            form.on('submit(set_SelectMainBill)', function (data) {
                set_SelectMainBill();
            });
            //#endregion
            //退出按钮
            form.on('submit(Exit)', function () {
@@ -591,15 +599,98 @@
                }
            });
            //#region å›žè½¦é€‰æ‹©æºå•
            $('#HSourceBillNo').on('keydown', function (event) {
                var HSourceBillNo = $('#HSourceBillNo').val();//(源单单据号)
                if (event.keyCode == 13) {
                    var ajaxLoad = layer.load();
                    //判断文本框是否有数据    new
                    if (HSourceBillNo == "") {
                        layer.close(ajaxLoad);
                        return;
                    }
                    $.ajax({
                        url: GetWEBURL() + '/Xs_SeOrderBill/PushList',
                        type: "GET",
                        data: { "HBillNo": HSourceBillNo, "user": sessionStorage["HUserName"] },
                        success: function (result) {
                            if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                var checkStatus = result;
                                if ($("#HSourceBillType").val() == "1401") {
                                    option.data = [];//清空子表
                                    $("#HProjectID").val(checkStatus.data[0].HProjectID ? checkStatus.data[0].HProjectID : 0);
                                    $("#HProjectNumber").val(checkStatus.data[0].项目编码);
                                    $("#HProjectName").val(checkStatus.data[0].项目名称);
                                    $("#HCusID").val(checkStatus.data[0].HCusID);
                                    $("#HCusName").val(checkStatus.data[0].客户);
                                    $("#HDeptID").val(checkStatus.data[0].HDeptID);
                                    $("#HDeptName").val(checkStatus.data[0].部门);
                                    $("#HManagerID").val(checkStatus.data[0].HManagerID);
                                    $("#HManagerName").val(checkStatus.data[0].主管);
                                    $("#HEmpID").val(checkStatus.data[0].HEmpID);
                                    $("#HEmpName").val(checkStatus.data[0].业务员);
                                    $("#HCurID").val(checkStatus.data[0].HCurID);
                                    $("#HCurName").val(checkStatus.data[0].币别);
                                    $("#HExRate").val(checkStatus.data[0].汇率);
                                    $("#HWHID").val(checkStatus.data[0].主仓库id);
                                    $("#HWHName").val(checkStatus.data[0].主仓库);
                                    var j = 0;
                                    for (var i = 0; i < result.data.length; i++) {
                                        var HQty = checkStatus.data[i].数量 - checkStatus.data[i].关联数量;                           //数量
                                        var HPrice = checkStatus.data[i].单价;               //单价
                                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                                        option.data.push({
                                            "HMaterID": checkStatus.data[i].HMaterID
                                            , "物料代码": checkStatus.data[i].物料代码
                                            , "物料名称": checkStatus.data[i].物料名称
                                            , "规格型号": checkStatus.data[i].规格型号
                                            , "HUnitID": checkStatus.data[i].HUnitID
                                            , "计量单位": checkStatus.data[i].计量单位
                                            , "HWHID": checkStatus.data[i].HWhID
                                            , "发货仓库": checkStatus.data[i].子仓库
                                            , "HQty": HQty,
                                             "HPrice": checkStatus.data[i].单价,
                                             "HMoney": HMoney
                                            , "HRemark": ""
                                            , "HSourceBillNo": checkStatus.data[i].单据号
                                            , "HSourceBillType": checkStatus.data[i].HBillType
                                            , "HSourceInterID": checkStatus.data[i].hmainid
                                            , "HSourceEntryID": checkStatus.data[i].hsubid
                                        })
                                        j++;
                                    }
                                    table.render(option);
                                    //设置当前库存
                                    SetAllInventoryByMaterID();
                                    layer.close(ajaxLoad);
                                    layer.msg("查询成功", { time: 1 * 1000, icon: 1 });
                                }
                            } else {
                                layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                                layer.close(ajaxLoad);
                            }
                        }, error: function () {
                            layer.alert(result.Message + "发生错误!", { icon: 5 });
                            layer.close(ajaxLoad);
                        }
                    });
                }
            });
            //#endregion
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                var temp = "";
                var Dec = getDecByMaterID(obj.data.HMaterID) //获取精度
                var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                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 //得到修改后的值
@@ -611,14 +702,23 @@
                    case "HQty":                                                       //实发数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("实发数量请输入大于0的数字!");
                            layer.msg("实发数量请输入不为0的数字!");
                            return;
                        } else if (temp * 1 == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("实发数量请输入不为0的数字!");
                            return;
                        }
@@ -727,12 +827,24 @@
                        if (checkStatus.data.length == 0) {
                            return layer.msg("请至少选择一条数据!");
                        }
                        var HCusID = $("#HCusID").val();//判断客户
                        if (HCusID == 0 || HCusID == '') {
                            HCusID = checkStatus.data[0]["HCusID"];
                        }
                        //获取销售订单代码
                        var ProcessNumber = [];
                        for (var i = 0; i < checkStatus.data.length; i++) {
                            if (checkStatus.data[i]["HCusID"] != HCusID) {
                                layer.msg("下推失败!已经选中的记录中存在不同客户!");
                                layer.close(index);
                                return;
                            }
                            ProcessNumber.push(checkStatus.data[i]);
                        }
                        for (var i = 0; i < ProcessNumber.length; i++) {
                            var HQty = checkStatus.data[i].数量 - checkStatus.data[i].关联数量;                           //数量
                            var HPrice = checkStatus.data[i].单价;               //单价
                            var HMoney = HQty * HPrice;                     //金额=数量*单价
                            option.data.push({
                                "HMaterID": checkStatus.data[i].HMaterID
                                , "物料代码": checkStatus.data[i].物料代码
@@ -742,10 +854,10 @@
                                , "计量单位": checkStatus.data[i].计量单位
                                , "HWHID": checkStatus.data[i].HWhID
                                , "发货仓库": checkStatus.data[i].子仓库
                                , "HQty": checkStatus.data[i].数量,
                                , "HQty": HQty,
                                "HPrice": checkStatus.data[i].单价,
                                "HMoney": checkStatus.data[i].金额, "HRemark": ""
                                "HMoney": HMoney
                                , "HRemark": ""
                                , "HSourceBillNo": checkStatus.data[i].单据号
                                , "HSourceBillType": checkStatus.data[i].HBillType
                                , "HSourceInterID": checkStatus.data[i].hmainid
@@ -771,6 +883,8 @@
                        $("#HWHName").val(checkStatus.data[0].主仓库);
                        table.render(option);
                        //设置当前库存
                        SetAllInventoryByMaterID();
                        layer.close(index);//关闭弹窗
                    }
@@ -779,12 +893,141 @@
            //#endregion
            //#endregion
            //#region æœ¬é¡µé¢æ‰€æœ‰è¢«è°ƒç”¨çš„æ–¹æ³•
            //#region打印
            //#region é€‰æ•´å•
            function set_SelectMainBill() {
                var url = "../../销售管理/销售订单/Xs_SeOrderBillQuery.html";
                if ($("#HSourceBillType").val() == 0 || $("#HSourceBillType").val() == null) {
                    return layer.msg('请选择单据类型');
                }
                //页面层-自定义
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: '' + getSupType().name + '列表'  //标题
                    , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                    , shift: 2 //弹出动画
                    , area: ["90%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: [url, "yes"]
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //按钮一  çš„回调
                        var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                        if (checkStatus.data.length == 0) {
                            return layer.msg("请至少选择一条数据!");
                        }
                        var HCusID = $("#HCusID").val();//判断客户
                        if (HCusID == 0 || HCusID == '') {
                            HCusID = checkStatus.data[0]["HCusID"];
                        }
                        //获取设置条件
                        var sMainWhere = " and hmainid in(";
                        for (var i = 0; i < checkStatus.data.length; i++) {
                            if (checkStatus.data[i]["HCusID"] != HCusID) {
                                layer.msg("下推失败!已经选中的记录中存在不同客户!");
                                layer.close(index);//关闭弹窗
                                return;
                            }
                            sMainWhere += checkStatus.data[i]["hmainid"]
                            if (i != checkStatus.data.length - 1) {
                                sMainWhere += ",";
                            } else {
                                sMainWhere += ") ";
                            }
                        }
                        getSeletMainInfo(sMainWhere);
                        //设置当前库存
                        SetAllInventoryByMaterID();
                        layer.close(index);//关闭弹窗
                    }
                });
            }
            //#endregion
            //#region æ•´å•信息获取方法
            function getSeletMainInfo(sMainWhere) {
                var ajaxLoad = layer.load();
                if ($("#HSourceBillType").val() == "1401") {
                    $.ajax({
                        url: GetWEBURL() + '/Xs_SeOrderBill/list',
                        async: false,
                        type: "GET",
                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
                        success: function (data1) {
                            if (data1.count == 1) {
                                var checkStatus = data1;
                                option.data = [];//清空子表
                                $("#HProjectID").val(checkStatus.data[0].HProjectID ? checkStatus.data[0].HProjectID : 0);
                                $("#HProjectNumber").val(checkStatus.data[0].项目编码);
                                $("#HProjectName").val(checkStatus.data[0].项目名称);
                                $("#HCusID").val(checkStatus.data[0].HCusID);
                                $("#HCusName").val(checkStatus.data[0].客户);
                                $("#HDeptID").val(checkStatus.data[0].HDeptID);
                                $("#HDeptName").val(checkStatus.data[0].部门);
                                $("#HManagerID").val(checkStatus.data[0].HManagerID);
                                $("#HManagerName").val(checkStatus.data[0].主管);
                                $("#HEmpID").val(checkStatus.data[0].HEmpID);
                                $("#HEmpName").val(checkStatus.data[0].业务员);
                                $("#HCurID").val(checkStatus.data[0].HCurID);
                                $("#HCurName").val(checkStatus.data[0].币别);
                                $("#HExRate").val(checkStatus.data[0].汇率);
                                $("#HWHID").val(checkStatus.data[0].主仓库id);
                                $("#HWHName").val(checkStatus.data[0].主仓库);
                                for (var i = 0; i < checkStatus.data.length; i++) {
                                    var HQty = checkStatus.data[i].数量 - checkStatus.data[i].关联数量;                           //数量
                                    var HPrice = checkStatus.data[i].单价;               //单价
                                    var HMoney = HQty * HPrice;                     //金额=数量*单价
                                    option.data.push({
                                        "HMaterID": checkStatus.data[i].HMaterID
                                        , "物料代码": checkStatus.data[i].物料代码
                                        , "物料名称": checkStatus.data[i].物料名称
                                        , "规格型号": checkStatus.data[i].规格型号
                                        , "HUnitID": checkStatus.data[i].HUnitID
                                        , "计量单位": checkStatus.data[i].计量单位
                                        , "HWHID": checkStatus.data[i].HWhID
                                        , "发货仓库": checkStatus.data[i].子仓库
                                        , "HQty": HQty,
                                        "HPrice": checkStatus.data[i].单价,
                                        "HMoney": HMoney
                                        , "HRemark": ""
                                        , "HSourceBillNo": checkStatus.data[i].单据号
                                        , "HSourceBillType": checkStatus.data[i].HBillType
                                        , "HSourceInterID": checkStatus.data[i].hmainid
                                        , "HSourceEntryID": checkStatus.data[i].hsubid
                                    })
                                }
                                table.render(option);
                                layer.close(ajaxLoad);
                                //layer.alert("查询成功", { icon: 1 });
                            } else {
                                layer.close(ajaxLoad);
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                                return;
                            }
                        }, error: function () {
                            layer.close(ajaxLoad);
                            layer.alert("接口请求失败!", { icon: 5 });
                            return;
                        }
                    });
                } else {
                    return layer.msg('当前不支持该源单选择!!');
                }
            }
            //#endregion
            //#region æ‰“印
            function get_PrintReport(data) {
                var hmainid = data.field["HInterID"];
                console.log(hmainid);
@@ -817,6 +1060,7 @@
                    , limit: 500
                    , height: 500
                    , loading: false
                    , totalRow:true
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true }
@@ -832,15 +1076,23 @@
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID" }//f7
                        , { field: 'HWHID', title: 'HWHID', width: 100, hide: true }
                        , { field: '发货仓库', title: '发货仓库', width: 100, edit: 'text', event: "HWHID" }//f7
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text' }
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text', totalRow: true  }
                        , { field: 'HInventoryQty', title: '当前库存', width: 100}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text' }
                        , { field: 'HMoney', title: '金额', width: 100 }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true  }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                    , done: function (res, curr, count) {
                        $(".layui-table-main").scrollTop(topScroll);
                    }
                }
                option.data = [];
                option.data = [{
                        "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                        "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "", "HInventoryQty": 0,
                        "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                    }];
                table.render(option);
                DisPlay_HideColumn();
@@ -866,6 +1118,7 @@
                            //}
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HInterID": data.hmainid
                                , "HDate": formatDate(data.日期)
                                , "HSeOrderBillNo_M": data.销售订单号
                                , "HEmpID": data.HEmpID
@@ -915,7 +1168,7 @@
                                rowdata.push(
                                    {
                                        "HMaterID": subdata[i].HMaterID, "物料代码": subdata[i].物料代码, "物料名称": subdata[i].物料名称, "规格型号": subdata[i].规格型号, "HUnitID": subdata[i].HUnitID, "计量单位": subdata[i].计量单位,
                                        "HWHID": subdata[i].HWHID, "发货仓库": subdata[i].发货仓库, "HQty": subdata[i].数量, "HPrice": subdata[i].单价, "HMoney": subdata[i].金额, "HRemark": subdata[i].表体备注
                                        "HWHID": subdata[i].HWHID, "发货仓库": subdata[i].发货仓库, "HQty": subdata[i].数量,"HPrice": subdata[i].单价, "HMoney": subdata[i].金额, "HRemark": subdata[i].表体备注
                                        , "HSourceBillNo": subdata[i].源单单号,    //源单号
                                        "HSourceBillType": subdata[i].源单类型,   //源单类型
                                        "HSourceInterID": subdata[i].源单主内码,   //源单主内码
@@ -925,6 +1178,8 @@
                            }
                            option.data = rowdata;
                            table.render(option);
                            //设置当前库存
                            SetAllInventoryByMaterID();
                            form.render('select');
                            layer.close(ajaxLoad);
@@ -939,72 +1194,27 @@
                });
            }
            //#endregion
            var date = new Date();
            var day = date.getDate();
            var month = date.getMonth() + 1;
            var year = date.getFullYear();
            var shijian = year + "-" + month + "-" + day;
            //判断是否新增
            if (linterid == null || linterid == 0) {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '1402' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HInterID").val(d.data[0].HInterID);
                        $("#HMakeDate").val(shijian);
                        $("#HMaker").val(sessionStorage["HUserName"]);
                    }
                });
                //页面初始化加载 ä¸šåŠ¡å‘˜ ä¸»ç®¡   éƒ¨é—¨
                get_DeptHManage();
            }
            else {//如果修改则走下面 new
                $("#HInterID").val(linterid);
                RoadBillMain(linterid);
                /* RoadBillSub(linterid);*/
            }
            //退出
            form.on('submit(Exit)', function (data) {
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
            //#region ä¿å­˜æ–¹æ³•
            function set_SaveBill(data) {
                if ($("#HWHID").val() == 0) {
                    layer.msg("请选择仓库!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                //if ($("#HWHID").val() == 0) {
                //    layer.msg("请选择仓库!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return;
                //}
              
                if ($("#HManagerID").val() == 0) {
                    layer.msg("请选择主管!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                //if ($("#HManagerID").val() == 0) {
                //    layer.msg("请选择主管!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return;
                //}
                if ($("#HCusID").val() == 0) {
                    layer.msg("请选择客户!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                if ($("#HEmpID").val() == 0) {
                    layer.msg("请选择业务员!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                //if ($("#HEmpID").val() == 0) {
                //    layer.msg("请选择业务员!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return;
                //}
                if ($("#HCurID ").val() == 0) {
                    layer.msg("请选择币别!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
@@ -1013,11 +1223,25 @@
                    layer.msg("汇率不能为0!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                if ($("#HDeptID").val() == 0) {
                    layer.msg("请选择部门!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                //if ($("#HDeptID").val() == 0) {
                //    layer.msg("请选择部门!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return;
                //}
                //子表数据检验简单表单验证
                //后续可用多个数组存储列名扩展
                for (var i = 0; i < option.data.length; i++) {//遍历option.data数组
                    //检查当前元素(option.data[i])是否不是对象、是否为null或是否为数组。                     è¿™æ˜¯å› ä¸ºä»£ç åŽç»­éƒ¨åˆ†å‡è®¾æ¯ä¸ªå…ƒç´ éƒ½æ˜¯ä¸€ä¸ªå¯¹è±¡ï¼Œç”¨äºŽæ£€æŸ¥å…¶å±žæ€§
                    if (typeof option.data[i] !== 'object' || option.data[i] === null || Array.isArray(option.data[i])) {
                        continue; // è·³è¿‡éžå¯¹è±¡é¡¹ï¼ˆå¦‚空数组)
                    }
                    var rowData = option.data[i];   //option.data[i]元素是一个有效的对象将其赋值给rowData变量
                    for (var col of Object.keys(rowData)) {  //遍历rowData对象的所有键  Object.keys(rowData)返回一个包含rowData所有自身属性键的数组
                        if (rowData[col] == "0" && (col == "HQty" || col == "HMaterID" || col == "HUnitID")) {  //检查当前属性的值是否等于"0",并且属性名不是"LAY_TABLE_INDEX"
                            layer.msg("第" + (i + 1) + "行:" + col + "不能为0!"); //提示第几行不能为0                          å¦‚果找到值为"0"的属性,并且该属性名不是"LAY_TABLE_INDEX",则通过layer.msg显示一个警告消息,指出哪个行和哪个列的值不能为0
                            return;
                        }
                    }
                }
                var num = [];
                for (var i = 0; i < table.cache["mainTable"].length; i++) {
                    if (table.cache["mainTable"][i] != "") {
@@ -1079,7 +1303,7 @@
                                //关闭当前frame
                                layer.close(index);
                            });
                            $('#check-btn').addClass("layui-btn-disabled").attr("disabled", true);// ç¦ç”¨å®¡æ ¸æŒ‰é’®
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
@@ -1120,36 +1344,123 @@
                    });
                }
            }
            //#region æ ¹æ®å®¢æˆ·èŽ·å–å¸åˆ«ã€æ±‡çŽ‡ã€ç»“ç®—æ–¹å¼ã€
            function getCustomerByCusID(HCusID) {
                $.ajax({
                    url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
                    async: false,
                    type: "GET",
                    data: {
                        "HCusID": HCusID
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data[0];
                            $("#HCurID").val(data.HCurID);
                            $("#HCurName").val(data.HCurName);
                            $("#HExRate").val(data.HExRate);
                            $("#HSSID").val(data.HSSID);
                            $("#HSSName").val(data.HSSName);
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
        //#endregion
            //行内快捷键筛选
            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) {
                                                //更新表格缓存的数据
                                                OptionData = childData;
                                                //获取当前库存
                                                var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                                obj.update({
                                                    "HMaterID": OptionData.HItemID
                                                    , "物料代码": OptionData.物料代码
                                                    , "物料名称": OptionData.物料名称
                                                    , "规格型号": OptionData.规格型号
                                                    , "HUnitID": OptionData.HUnitID
                                                    , "计量单位": OptionData.计量单位名称
                                                    , "HQty": 1
                                                    , "HInventoryQty": HInventoryQty
                                                })
                                                OptionData = {};
                                                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);
                                    if (childData != null) {
                                        //更新表格缓存的数据
                                        OptionData = childData;
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = {};
                                        childData = null;
                                    }
                                    childPage = null;
                                    currRowIndex = 0;
                                    childData = null;
                                    obj.event = "";
                                }
                            }
                        }
                    }
                    //#endregion
                    if (event.key == "F7") {
                        //物料
                        if (obj.event == "HMaterID") {
@@ -1170,7 +1481,9 @@
                                    if (checkStatus.data.length == 0) {
                                        return layer.msg("请选择数据");
                                    }else if (checkStatus.data.length == 1) {
                                    } else if (checkStatus.data.length == 1) {
                                        //获取当前库存
                                        var HInventoryQty = GetInventoryByMaterID(checkStatus.data[0].HItemID, obj.data["HWHID"]);
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": checkStatus.data[0].HItemID
@@ -1179,20 +1492,37 @@
                                            , "规格型号": checkStatus.data[0].规格型号
                                            , "HUnitID": checkStatus.data[0].HUnitID
                                            , "计量单位": checkStatus.data[0].计量单位名称
                                            , "HInventoryQty": HInventoryQty
                                            ,"HQty": 1
                                        })
                                        layer.close(index);//关闭弹窗
                                    } else {
                                        table.cache["mainTable"].splice(0, 1);
                                        for (var rowData of checkStatus.data) {
                                            var NewRow = {
                                                "HMaterID": rowData.HItemID, "物料代码": rowData.物料代码, "物料名称": rowData.物料名称, "规格型号": rowData.规格型号, "HUnitID": rowData.HUnitID, "计量单位": rowData.计量单位名称, "HWHID": "0", "发货仓库": "",
                                                "HQty": "1", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                                "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                            };
                                            table.cache["mainTable"].push(NewRow);
                                        var rowIndex = $(obj.tr).attr("data-index") * 1;  //attr("data-index")用于获取该tr元素上data-index属性的值*1转换类型然后赋值给rowIndex
                                        for (var i = 0; i < checkStatus.data.length; i++) {  //判断选中的数据的长度  ç”¨äºŽéåކcheckStatus.data数组中的每个元素
                                            if (rowIndex + i >= option.data.length) {           //判断rowIndex + i的索引超出了option.data数组的长度,说明option.data数组需要扩展以包含更多行
                                                //新增行表格数据
                                                var NewRow = {
                                                    "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                                                    "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                                    "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                                };
                                                table.cache["mainTable"].push(NewRow);    //创建新的包含数组  ä¼ å…¥table.cache["mainTable"]数组
                                                option.data = table.cache["mainTable"];  //把传入 table.cache["mainTable"]数组的值赋值给option.data çš„属性
                                                table.render(option);//渲染界面
                                            }
                                            //获取当前库存
                                            var HInventoryQty = GetInventoryByMaterID(checkStatus.data[i].HItemID, option.data[rowIndex + i].HWHID);
                                            option.data[rowIndex + i].HMaterID = checkStatus.data[i].HItemID;  //将option.data数组中对应行的HMaterID属性更新为从resultData对象中获取的物料ID
                                            option.data[rowIndex + i].物料代码 = checkStatus.data[i].物料代码; //将option.data数组中对应行的 ç‰©æ–™ä»£ç  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].物料名称 = checkStatus.data[i].物料名称; //将option.data数组中对应行的  ç‰©æ–™åç§°  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].规格型号 = checkStatus.data[i].规格型号; //将option.data数组中对应行的  è§„格型号  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].HUnitID = checkStatus.data[i].HUnitID; //将option.data数组中对应行的 HUnitID å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].计量单位 = checkStatus.data[i].计量单位名称; //将option.data数组中对应行的 è®¡é‡å•位 å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID   æ›´æ–°è®¡é‡å•位属性
                                            option.data[rowIndex + i].HQty = 1;  //将对应行的HQty属性(可能代表数量)设置为1。这表示对于每个选中的物料,其默认数量被设置为1
                                            option.data[rowIndex + i].HInventoryQty = HInventoryQty;  //当前库存
                                        }
                                        option.data = table.cache["mainTable"];
                                        table.render(option);
                                        layer.close(index);//关闭弹窗
                                    }
@@ -1200,6 +1530,7 @@
                                }
                                , end: function () {
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
@@ -1208,6 +1539,8 @@
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = [];
                                    }
@@ -1273,19 +1606,23 @@
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    var HInventoryQty = GetInventoryByMaterID(obj.data["HMaterID"], checkStatus.data[0].HItemID);
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HWHID": checkStatus.data[0].HItemID,
                                        "发货仓库": checkStatus.data[0].仓库名称
                                        "发货仓库": checkStatus.data[0].仓库名称,
                                        "HInventoryQty": HInventoryQty
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        var HInventoryQty = GetInventoryByMaterID(obj.data["HMaterID"],OptionData.HItemID);
                                        obj.update({
                                            "HWHID": OptionData.HItemID
                                            , "发货仓库": OptionData.仓库名称
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = [];
                                    }
@@ -1298,6 +1635,10 @@
                })
                //双击
                $('.layui-table-box tbody td[data-field="物料代码"]').off('dblclick').on('dblclick', function () {
                    //手动失焦
                    var element = document.getElementById("HBillNo");
                    element.focus();
                    layer.open({
                        type: 2
                        , skin: "layui-layer-rim" //加上边框
@@ -1316,6 +1657,8 @@
                            if (checkStatus.data.length == 0) {
                                return layer.msg("请选择数据");
                            } else if (checkStatus.data.length == 1) {
                                //获取当前库存
                                var HInventoryQty = GetInventoryByMaterID(checkStatus.data[0].HItemID, obj.data["HWHID"]);
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": checkStatus.data[0].HItemID
@@ -1324,20 +1667,37 @@
                                    , "规格型号": checkStatus.data[0].规格型号
                                    , "HUnitID": checkStatus.data[0].HUnitID
                                    , "计量单位": checkStatus.data[0].计量单位名称
                                    , "HInventoryQty": HInventoryQty
                                    , "HQty": 1
                                })
                                layer.close(index);//关闭弹窗
                            } else {
                                table.cache["mainTable"].splice(0, 1);
                                for (var rowData of checkStatus.data) {
                                    var NewRow = {
                                        "HMaterID": rowData.HItemID, "物料代码": rowData.物料代码, "物料名称": rowData.物料名称, "规格型号": rowData.规格型号, "HUnitID": rowData.HUnitID, "计量单位": rowData.计量单位名称, "HWHID": "0", "发货仓库": "",
                                        "HQty": "1", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                        "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                    };
                                    table.cache["mainTable"].push(NewRow);
                                var rowIndex = $(obj.tr).attr("data-index") * 1;  //attr("data-index")用于获取该tr元素上data-index属性的值*1转换类型然后赋值给rowIndex
                                for (var i = 0; i < checkStatus.data.length; i++) {  //判断选中的数据的长度  ç”¨äºŽéåކcheckStatus.data数组中的每个元素
                                    if (rowIndex + i >= option.data.length) {           //判断rowIndex + i的索引超出了option.data数组的长度,说明option.data数组需要扩展以包含更多行
                                        //新增行表格数据
                                        var NewRow = {
                                            "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                                            "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                            "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                        };
                                        table.cache["mainTable"].push(NewRow);    //创建新的包含数组  ä¼ å…¥table.cache["mainTable"]数组
                                        option.data = table.cache["mainTable"];  //把传入 table.cache["mainTable"]数组的值赋值给option.data çš„属性
                                        table.render(option);//渲染界面
                                    }
                                    //获取当前库存
                                    var HInventoryQty = GetInventoryByMaterID(checkStatus.data[i].HItemID, option.data[rowIndex + i].HWHID);
                                    option.data[rowIndex + i].HMaterID = checkStatus.data[i].HItemID;  //将option.data数组中对应行的HMaterID属性更新为从resultData对象中获取的物料ID
                                    option.data[rowIndex + i].物料代码 = checkStatus.data[i].物料代码; //将option.data数组中对应行的 ç‰©æ–™ä»£ç  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].物料名称 = checkStatus.data[i].物料名称; //将option.data数组中对应行的  ç‰©æ–™åç§°  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].规格型号 = checkStatus.data[i].规格型号; //将option.data数组中对应行的  è§„格型号  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].HUnitID = checkStatus.data[i].HUnitID; //将option.data数组中对应行的 HUnitID å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].计量单位 = checkStatus.data[i].计量单位名称; //将option.data数组中对应行的 è®¡é‡å•位 å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID   æ›´æ–°è®¡é‡å•位属性
                                    option.data[rowIndex + i].HQty = 1;  //将对应行的HQty属性(可能代表数量)设置为1。这表示对于每个选中的物料,其默认数量被设置为1
                                    option.data[rowIndex + i].HInventoryQty = HInventoryQty;  //当前库存
                                }
                                option.data = table.cache["mainTable"];
                                table.render(option);
                                layer.close(index);//关闭弹窗
                            }
@@ -1345,6 +1705,7 @@
                        }
                        , end: function () {
                            if (typeof (OptionData.HItemID) != "undefined") {
                                var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": OptionData.HItemID
@@ -1353,11 +1714,15 @@
                                    , "规格型号": OptionData.规格型号
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                    , "HQty": 1
                                    , "HInventoryQty": HInventoryQty
                                })
                                OptionData = [];
                            }
                        }
                    })
                    obj.event = "";
                });
            }
@@ -1411,6 +1776,37 @@
            }
            //#endregion
            //#region åŠæ—¶åº“存查询
            function GetInventoryByMaterID(HMaterID, HWHID) {
                var HInventoryQty = 0;
                $.ajax({
                    url: GetWEBURL() + '/Xs_SeOutStockBill/GetICInventory',
                    async: false,
                    type: "GET",
                    data: { "HMaterID": HMaterID, "HWHID": HWHID, "HORGID": sessionStorage["OrganizationID"] },
                    async: false,
                    success: function (data1) {
                        if (data1.count == 1) {
                            HInventoryQty = data1.data;
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                })
                return HInventoryQty;
            }
            //设置获取所有option的当前库存
            function SetAllInventoryByMaterID() {
                option.date = table.cache["mainTable"];
                for (var i = 0; i < table.cache["mainTable"].length; i++) {
                    var HInventoryQty = GetInventoryByMaterID(table.cache["mainTable"][i].HMaterID, table.cache["mainTable"][i].HWHID);
                    table.cache["mainTable"][i].HInventoryQty = HInventoryQty;
                }
                table.render(option);
            }
            //#endregion
            //#region å­è¡¨1:隐藏列设置
            function get_HideColumn() {
                var colName = "";
@@ -1463,6 +1859,9 @@
                            dataCol = data1.data[0].HGridString.split(',');
                            for (var i = 0; i < option.cols[0].length - 2; i++) {
                                if (dataCol.length <= i) {
                                    break;
                                }
                                var dataCols = dataCol[i].split('|');
                                //隐藏列
                                if (dataCols[1] == 1) {
@@ -1543,12 +1942,13 @@
                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();
                            obj.del();//假删除
                            table.cache["mainTable"].splice(rowIndex, 1);  //②彻底移除元素,从缓存里移除这一行
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.reload(option);
                            table.render(option);
                            layer.close(index);
                        }
                    });
@@ -1754,6 +2154,11 @@
                            $("#HProjectID").val(checkStatus.data[0].HInterID);
                            $("#HProjectNumber").val(checkStatus.data[0].项目代码);//工程项目代码
                            $("#HProjectName").val(checkStatus.data[0].项目名称);//工程项目代码
                            $("#HCusID").val(checkStatus.data[0].HCusID == null ? 0 : checkStatus.data[0].HCusID)
                            $("#HCusName").val(checkStatus.data[0].客户)
                            $("#HLinkMan").val(checkStatus.data[0].联系人);
                            $("#HLinkPhone").val(checkStatus.data[0].联系人电话);
                            getCustomerByCusID($("#HCusID").val());
                        } else {
                            layer.msg("该项目已关闭,不可选择!");
                        }
@@ -1824,6 +2229,39 @@
            //以上是layui模块
        });
        //#region æ ¹æ®å®¢æˆ·èŽ·å–å¸åˆ«ã€æ±‡çŽ‡ã€ç»“ç®—æ–¹å¼ã€
        function getCustomerByCusID(HCusID) {
            $.ajax({
                url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
                async: false,
                type: "GET",
                data: {
                    "HCusID": HCusID
                },
                success: function (result) {
                    if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var data = result.data[0];
                        $("#HCurID").val(data.HCurID);
                        $("#HCurName").val(data.HCurName);
                        $("#HExRate").val(data.HExRate);
                        $("#HSSID").val(data.HSSID);
                        $("#HSSName").val(data.HSSName);
                        //设置默认货币信息
                        if (data.HCurID == 0) {
                            $("#HCurID").val(1);
                            $("#HCurName").val("人民币");
                            $("#HExRate").val(1);
                        }
                    } else {
                        layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                    }
                }, error: function () {
                    layer.alert("发生错误!" + æœªæŸ¥è¯¢åˆ°å®¢æˆ·ä¿¡æ¯, { icon: 5 });
                }
            });
        }
        //#endregion
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
@@ -1855,7 +2293,11 @@
                $("#HProjectID").val(obj[0].HInterID);
                $("#HProjectNumber").val(obj[0].项目代码);//工程项目代码
                $("#HProjectName").val(obj[0].项目名称);//工程项目代码
                $("#HCusID").val(obj[0].HCusID == null ? 0 : obj[0].HCusID)
                $("#HCusName").val(obj[0].客户)
                $("#HLinkMan").val(obj[0].联系人);
                $("#HLinkPhone").val(obj[0].联系人电话);
                getCustomerByCusID($("#HCusID").val());
            } else {
                layer.msg("该项目已关闭,不可选择!");
            }