duhe
2025-09-02 cecb8de03f83f8e5b3cd32d3ac7eb09196ed5cf4
WebTM/views/ÏúÊÛ¹ÜÀí/·¢»õ֪ͨµ¥/Add_Edit_Xs_SeOutStockBillList.html
@@ -45,9 +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>
@@ -375,7 +377,7 @@
            var shijian = year + "-" + month + "-" + day;
            var allVal;
            var topScroll = 0;//记录滚动条的位置
            var HModName = "Add_Edit_Xs_SeOutStockBillList";
            //#endregion
@@ -423,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();
@@ -445,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) {
@@ -490,9 +502,22 @@
            //#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
@@ -581,6 +606,7 @@
                    var ajaxLoad = layer.load();
                    //判断文本框是否有数据    new
                    if (HSourceBillNo == "") {
                        layer.close(ajaxLoad);
                        return;
                    }
                    $.ajax({
@@ -636,6 +662,8 @@
                                        j++;
                                    }
                                    table.render(option);
                                    //设置当前库存
                                    SetAllInventoryByMaterID();
                                    layer.close(ajaxLoad);
                                    layer.msg("查询成功", { time: 1 * 1000, icon: 1 });
                                }
@@ -655,13 +683,14 @@
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                //var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                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 //得到修改后的值
@@ -673,7 +702,7 @@
                    case "HQty":                                                       //实发数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
@@ -721,15 +750,6 @@
                            table.render(option);
                            layer.msg("单价请输入大于0的数字!");
                            return;
                        } else if (temp * 1 == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("单价请输入不为0的数字!");
                            return;
                        }
@@ -863,6 +883,8 @@
                        $("#HWHName").val(checkStatus.data[0].主仓库);
                        table.render(option);
                        //设置当前库存
                        SetAllInventoryByMaterID();
                        layer.close(index);//关闭弹窗
                    }
@@ -871,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);
@@ -909,6 +1060,7 @@
                    , limit: 500
                    , height: 500
                    , loading: false
                    , totalRow:true
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true }
@@ -924,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();
@@ -958,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
@@ -1007,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].源单主内码,   //源单主内码
@@ -1017,6 +1178,8 @@
                            }
                            option.data = rowdata;
                            table.render(option);
                            //设置当前库存
                            SetAllInventoryByMaterID();
                            form.render('select');
                            layer.close(ajaxLoad);
@@ -1031,51 +1194,6 @@
                });
            }
            //#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) {
@@ -1270,6 +1388,8 @@
                                            if (childData != null) {
                                                //更新表格缓存的数据
                                                OptionData = childData;
                                                //获取当前库存
                                                var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                                obj.update({
                                                    "HMaterID": OptionData.HItemID
                                                    , "物料代码": OptionData.物料代码
@@ -1278,7 +1398,9 @@
                                                    , "HUnitID": OptionData.HUnitID
                                                    , "计量单位": OptionData.计量单位名称
                                                    , "HQty": 1
                                                    , "HInventoryQty": HInventoryQty
                                                })
                                                OptionData = {};
                                                childData = null;
@@ -1311,6 +1433,7 @@
                                    if (childData != null) {
                                        //更新表格缓存的数据
                                        OptionData = childData;
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
                                            , "物料代码": OptionData.物料代码
@@ -1319,6 +1442,7 @@
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = {};
@@ -1357,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
@@ -1366,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);//关闭弹窗
                                    }
@@ -1387,6 +1530,7 @@
                                }
                                , end: function () {
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
@@ -1396,6 +1540,7 @@
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = [];
                                    }
@@ -1461,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 = [];
                                    }
@@ -1486,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" //加上边框
@@ -1504,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
@@ -1512,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);//关闭弹窗
                            }
@@ -1533,6 +1705,7 @@
                        }
                        , end: function () {
                            if (typeof (OptionData.HItemID) != "undefined") {
                                var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": OptionData.HItemID
@@ -1542,11 +1715,14 @@
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                    , "HQty": 1
                                    , "HInventoryQty": HInventoryQty
                                })
                                OptionData = [];
                            }
                        }
                    })
                    obj.event = "";
                });
            }
@@ -1600,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 = "";
@@ -1652,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) {
@@ -1732,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);
                        }
                    });