chenhaozhe
2025-05-30 f025d969dcf4e664ef8f7f33ee2060e113c3adff
WebTM/views/ÏúÊÛ¹ÜÀí/·¢»õ֪ͨµ¥/Add_Edit_Xs_SeOutStockBillList.html
@@ -46,14 +46,19 @@
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</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>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <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">
                            <!--基本信息-->
@@ -63,7 +68,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>
@@ -108,14 +113,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;">
@@ -125,32 +122,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">
@@ -161,58 +134,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">
@@ -225,17 +146,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>
@@ -258,12 +169,82 @@
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HProjectName" id="HProjectName" autocomplete="off" readonly>
                                            </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">
                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HSSID" id="HSSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HSSList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--制单信息-->
                            <div class="layui-tab-item">
@@ -338,6 +319,8 @@
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
@@ -347,7 +330,9 @@
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>库存查询</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>出入库记录查询</button>
                        </div>
                    </script>
                    <script type="text/html" id="xuhao">
@@ -362,6 +347,12 @@
    </script>
    <script>
        //#region æ–‡æœ¬æ¡†è¾“入搜索相关数据-变量
        var childPage = null;                       //获取子窗口对象,用于操作子窗口的变量和方法
        var currRowIndex = 0;                       //用于定位子窗口当前选中的行
        var childData = null;                       //用于获取子窗口返回的数据
        //#endregion
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
        layui.config({
@@ -385,7 +376,8 @@
            var shijian = year + "-" + month + "-" + day;
            var allVal;
            var topScroll = 0;//记录滚动条的位置
            var HModName = "Add_Edit_Xs_SeOutStockBillList";
            //#endregion
@@ -418,6 +410,7 @@
            }
            else if (OperationType == 3) {//编辑
                $("#HItemID").val(linterid);//修改时主表ID
                $('#print-btn').prop('disabled', false).removeClass('layui-btn-disabled');
                //编辑状态时,根据内码,获取信息并写入界面
                RoadBillMain(linterid);
            }
@@ -431,14 +424,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();
@@ -451,7 +456,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) {
@@ -481,14 +486,32 @@
                            //checkRefresh();
                        }
                        break;
                    ////列设置
                    //case 'set_HideColumn':
                    //    get_HideColumn();
                    //    break;
                    //库存查询
                    case 'get_Inventory': get_Inventory();
                        break;
                    //出入库记录查询
                    case 'get_InOutSum': get_InOutSum();
                        break;
                    //列设置
                    case 'set_HideColumn':
                        get_HideColumn();
                        break;
                }
            });
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#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 () {
@@ -510,6 +533,10 @@
            //选择仓库按钮
            form.on('submit(HWHList)', function () {
                get_checkWH();
            });
            //选择结算按钮
            form.on('submit(HSSList)', function () {
                get_checkSS();
            });
            //选择币别按钮
            form.on('submit(HCurList)', function () {
@@ -537,7 +564,10 @@
            form.on('submit(Saver)', function (data) {
                set_SaveBill(data);
            });
            //打印
            form.on('submit(get_PrintReport)', function (data) {
                get_PrintReport(data);
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
@@ -561,12 +591,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 //得到修改后的值
@@ -578,14 +694,23 @@
                    case "HQty":                                                       //实发数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("实发数量请输入大于0的数字!");
                            layer.msg("实发数量请输入不为0的数字!");
                            return;
                        } else if (temp * 1 == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("实发数量请输入不为0的数字!");
                            return;
                        }
@@ -594,7 +719,10 @@
                        var HQty = value * 1;                           //实发数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HMoney = HQty * HPrice;                     //金额=实发数量*单价
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
@@ -606,7 +734,7 @@
                    case "HPrice":                                                       //单价
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HPrice: oldText
@@ -621,7 +749,10 @@
                        var HQty = obj.data.HQty * 1;                   //实发数量
                        var HPrice = value * 1;                         //单价
                        var HMoney = HQty * HPrice;                     //金额=实发数量*单价
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
@@ -688,12 +819,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].物料代码
@@ -703,10 +846,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
@@ -732,6 +875,8 @@
                        $("#HWHName").val(checkStatus.data[0].主仓库);
                        table.render(option);
                        //设置当前库存
                        SetAllInventoryByMaterID();
                        layer.close(index);//关闭弹窗
                    }
@@ -740,11 +885,156 @@
            //#endregion
            //#endregion
            //#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);
                layer.open({
                    type: 2
                    , area: ['50%', '50%']
                    , title: '打印模版选择'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: false //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + hmainid.toString() + '&MyMsg=' + hmainid.toString() + '&Type=HSeOutStockBillListByID', 'yes']
                    , resize: false
                })
            }
            //#endregion
            //#region åˆ¤æ–­æ˜¯å¦ç™»å½• æœªç™»å½•则跳到登录页
            function get_LoginIs() {
                if (sessionStorage.login != "login") {
@@ -762,6 +1052,7 @@
                    , limit: 500
                    , height: 500
                    , loading: false
                    , totalRow:true
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true }
@@ -777,16 +1068,26 @@
                        , { 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();
            }
            //#region åŠ è½½è¡¨å¤´
@@ -809,6 +1110,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
@@ -822,6 +1124,8 @@
                                , "HDeptID": data.HDeptID
                                , "HCurID": data.HCurID
                                , "HCurName": data.币别
                                , "HSSID": data.HSSID
                                , "HSSName": data.结算方式
                                , "HExRate": data.汇率
                                , "HManagerName": data.主管
                                , "HManagerID": data.HManagerID
@@ -856,7 +1160,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].源单主内码,   //源单主内码
@@ -866,6 +1170,8 @@
                            }
                            option.data = rowdata;
                            table.render(option);
                            //设置当前库存
                            SetAllInventoryByMaterID();
                            form.render('select');
                            layer.close(ajaxLoad);
@@ -880,72 +1186,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;
@@ -954,11 +1215,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] != "") {
@@ -982,6 +1257,11 @@
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { icon: 1 });
                            if (data.Verify == "Y") //自动审核
                            {
                                $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                                set_CheckBill(); //审核
                            }
                            $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                            //保存后浏览
                            //ReRoadBillMain();
@@ -994,6 +1274,33 @@
                    error: function (err) {
                        layer.alert("错误:" + err, { icon: 5 });
                        console.log("Reason" + sMainStr);
                    }
                });
            }
            //#endregion
            //#region å®¡æ ¸æ•°æ®
            function set_CheckBill() {
                var InterID = $("#HInterID").val();
                //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Xs_SeOutStockBill/CheckXs_SeOutStockBill", //方法所在页面和方法名
                    data: { "HInterID": InterID, "Type": 1, "user": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                // å¾—到frame索引
                                var index = layer.getFrameIndex(window.name);
                                //关闭当前frame
                                layer.close(index);
                            });
                            $('#check-btn').addClass("layui-btn-disabled").attr("disabled", true);// ç¦ç”¨å®¡æ ¸æŒ‰é’®
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
@@ -1017,18 +1324,135 @@
                            "sWhere": "and HItemID = '" + $("#HDeptID").val() + "'", "user": sessionStorage["HUserName"], "Organization": sessionStorage["Organization"]
                        },
                        success: function (result) {
                            $("#HManagerID").val(result.data[0].HEmpID);
                            $("#HManagerName").val(result.data[0].负责人);
                            if (result.code == 1 && result.data.length > 0) {
                                $("#HManagerID").val((result.data[0].HEmpID == undefined ? 0 : result.data[0].HEmpID) == null ? 0 : result.data[0].HEmpID);
                                $("#HManagerName").val(result.data[0].负责人);
                            } else {
                                layer.msg("根据当前登录用户的部门 èŽ·å– ä¸»ç®¡" + result.Message)
                            }
                        }, error: function () {
                            layer.alert("发生错误!", { icon: 5 });
                        }
                    });
                }
            }
            //行内快捷键筛选
            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") {
@@ -1047,23 +1471,58 @@
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    if (checkStatus.data.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
                                            , "物料代码": checkStatus.data[0].物料代码
                                            , "物料名称": checkStatus.data[0].物料名称
                                            , "规格型号": checkStatus.data[0].规格型号
                                            , "HUnitID": checkStatus.data[0].HUnitID
                                            , "计量单位": checkStatus.data[0].计量单位名称
                                            , "HInventoryQty": HInventoryQty
                                            ,"HQty": 1
                                        })
                                        layer.close(index);//关闭弹窗
                                    } else {
                                        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,
                                                };
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HMaterID": checkStatus.data[0].HItemID
                                        , "物料代码": checkStatus.data[0].物料代码
                                        , "物料名称": checkStatus.data[0].物料名称
                                        , "规格型号": checkStatus.data[0].规格型号
                                        , "HUnitID": checkStatus.data[0].HUnitID
                                        , "计量单位": checkStatus.data[0].计量单位名称
                                    })
                                    layer.close(index);//关闭弹窗
                                                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;  //当前库存
                                        }
                                        table.render(option);
                                        layer.close(index);//关闭弹窗
                                    }
                                }
                                , end: function () {
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
@@ -1072,6 +1531,8 @@
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = [];
                                    }
@@ -1137,19 +1598,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 = [];
                                    }
@@ -1160,7 +1625,307 @@
                        return false;
                    }
                })
                //双击
                $('.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" //加上边框
                        , title: "物料列表"  //标题
                        , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                        , shift: 2 //弹出动画
                        , area: ["90%", "90%"] //窗体大小
                        , maxmin: true //设置最大最小按钮是否显示
                        , content: ['../../基础资料/公用基础资料/Gy_Material.html', '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("请选择数据");
                            } else if (checkStatus.data.length == 1) {
                                //获取当前库存
                                var HInventoryQty = GetInventoryByMaterID(checkStatus.data[0].HItemID, obj.data["HWHID"]);
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": checkStatus.data[0].HItemID
                                    , "物料代码": checkStatus.data[0].物料代码
                                    , "物料名称": checkStatus.data[0].物料名称
                                    , "规格型号": checkStatus.data[0].规格型号
                                    , "HUnitID": checkStatus.data[0].HUnitID
                                    , "计量单位": checkStatus.data[0].计量单位名称
                                    , "HInventoryQty": HInventoryQty
                                    , "HQty": 1
                                })
                                layer.close(index);//关闭弹窗
                            } else {
                                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;  //当前库存
                                }
                                table.render(option);
                                layer.close(index);//关闭弹窗
                            }
                        }
                        , end: function () {
                            if (typeof (OptionData.HItemID) != "undefined") {
                                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 = [];
                            }
                        }
                    })
                    obj.event = "";
                });
            }
            //#region åº“存查询
            function get_Inventory() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1 && data[0].HMaterID != 0) {
                    var HMaterID = data[0].HMaterID.toString();
                    //弹窗方法
                    layer.open({
                        type: 2//弹窗类型
                        , skin: 'layui-layer-rim' //加上边框
                        , area: ['90%', '90%']//大小
                        , title: '库存查询列表'//标题
                        , shift: 2//弹出动画
                        , content: ['../../仓存管理/条码报表/Kf_ICinventoryQueryReport.html?Type=1&HMaterID=' + HMaterID, 'yes']
                        , btn: ['取消']
                        , btn1: function (index, layero) {
                            layer.close(index);
                        }
                    })
                }
                else {
                    layer.msg('请选择一行有物料数据查询!');
                }
            }
            //#endregion
            //#region å‡ºå…¥åº“记录查询
            function get_InOutSum() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1 && data[0].HMaterID != 0) {
                    var HMaterID = data[0].HMaterID.toString();
                    layer.open({
                        type: 2//弹窗类型
                        , skin: 'layui-layer-rim' //加上边框
                        , area: ['90%', '90%']//大小
                        , title: '出入库记录列表'//标题
                        , shift: 2//弹出动画
                        , content: ['../../仓存管理/条码报表/Kf_StockInOutSumQueryReport.html?Type=1&HMaterID=' + HMaterID, 'yes']
                        , btn: ['取消']
                        , btn1: function (index, layero) {
                            layer.close(index);
                        }
                    })
                }
                else {
                    layer.msg('请选择一行有物料数据查询!');
                }
            }
            //#endregion
            //#region åŠæ—¶åº“存查询
            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 = "";
                var contentUrl = "";
                for (var i = 1; i < option.cols[0].length - 1; i++) {
                    colName += option.cols[0][i]["title"] + ",";
                }
                var urlStr = window.document.location.pathname;//获取文件路径
                var urlLen = urlStr.split('/');
                for (var i = 0; i < urlLen.length - 4; i++) {
                    contentUrl += "../";
                }
                colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI è¿›è¡Œç¼–码
                contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: "隐藏列设置"  //标题
                    , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                    , shift: 2 //弹出动画
                    , area: ["50%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: [contentUrl, "yes"]
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //刷新表格数据
                        DisPlay_HideColumn();
                        //更新表格缓存的数据
                        layer.close(index);//关闭弹窗
                    }
                })
            }
            //#endregion
            //#region å­è¡¨1:显示列数据
            function DisPlay_HideColumn() {
                $.ajax({
                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                    async: false,
                    type: "GET",
                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                    async: false,
                    success: function (data1) {
                        if (data1.data.length != 0) {
                            var dataCol = [];//数据库查询出的列数据
                            var titleData = ["HMaterID", "HUnitID", "源单内码", "源单子内码", "源单号", "源单类型", "关联数量", "关联金额", "HQty_Old", "HQty_New"];//不需要显示的字段 å¯æ‰©å±•
                            titleData = [];
                            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) {
                                    option.cols[0][i + 1]["hide"] = true;
                                }
                                //设置列宽
                                if (dataCols[3] > 0) {
                                    option.cols[0][i + 1]["width"] = dataCols[3];
                                }
                                //设置内容字体大小
                                if (data1.data[0].HFontSize != 0) {
                                    option.cols[0][i + 1]["style"] += "font-size:" + data1.data[0].HFontSize + "px;";
                                } else {
                                    option.cols[0][i + 1]["style"] += "font-size:100%";
                                }
                                //设置列宽
                                //if (data1.data[0].HColumnWidth != 0) {
                                //    option.cols[0][i + 1]["width"] = data1.data[0].HColumnWidth + "px;";
                                //} else {
                                //    option.cols[0][i + 1]["width"] = "";
                                //}
                                //显示列
                                if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
                                    option.cols[0][i + 1]["hide"] = false;
                                }
                                //字体所在位置(å·¦ å±…中 å³)
                                switch (dataCols[2]) {
                                    case "L":
                                        option.cols[0][i + 1]["align"] = "left";
                                        break;
                                    case "M":
                                        option.cols[0][i + 1]["align"] = "center";
                                        break;
                                    case "R":
                                        option.cols[0][i + 1]["align"] = "right";
                                        break;
                                }
                                //设置表格title属性显示别名
                                if (dataCols[4] != null && dataCols[4] != "") {
                                    option.cols[0][i + 1]["title"] = dataCols[4];
                                }
                            }
                            //取消冻结列
                            for (var i = 1; i < option.cols[0].length - 1; i++) {
                                if (option.cols[0][i]["fixed"] != null) {
                                    option.cols[0][i]["fixed"] = null;
                                }
                                else {
                                    break;
                                }
                            }
                            //冻结列
                            if (data1.data[0].HFixCols != 0) {
                                for (var i = 0; i < data1.data[0].HFixCols; i++) {
                                    if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
                                        data1.data[0].HFixCols += 1;
                                    }
                                    option.cols[0][i + 1]["fixed"] = "left";
                                }
                            }
                            table.render(option);
                        } else {
                            table.render(option);
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                })
            }
            //#endregion
            //行内删除
            function set_GridDelete(obj) {
@@ -1169,12 +1934,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);
                        }
                    });
@@ -1220,9 +1986,13 @@
                        }
                        $("#HCusName").val(checkStatus.data[0].客户名称);
                        $("#HCusID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                    , end: function () {
                        getCustomerByCusID($("#HCusID").val());
                    }
                })
            }
            function get_checkWH() {
@@ -1325,7 +2095,29 @@
                    , btn2: function (index, layero) { }
                })
            }
            //结算方式
            function get_checkSS() {
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '结算方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../基础资料/基础资料/Gy_SettleStyle.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSSName").val(checkStatus.data[0].结算方式名称);
                        $("#HSSID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //项目代码
            function get_checkSearchHProNumber() {
                var HOrgID = sessionStorage["OrganizationID"];
@@ -1354,6 +2146,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("该项目已关闭,不可选择!");
                        }
@@ -1386,7 +2183,31 @@
                })
            }
            //#endregion
            //#region æ ¹æ®ç‰©æ–™ID获取精度
            function getDecByMaterID(HMaterID) {
                var resultData = {};
                $.ajax({  // å¼‚步请求
                    url: GetWEBURL() + "Gy_Material/getDecByID",  //请求地址
                    async: false,   //是否开启异步
                    type: "GET",   //请求类型
                    data: {   //定义发送到服务器的数据
                        "HMaterID": HMaterID     //  å°†hmaterid作为请求参数发送
                    },
                    success: function (result) {   // å½“请求成功时,执行这个函数
                        if (result.code == 1) { // å¦‚果服务器返回的数据中的`code字段等于1,这可能表示审核操作成功执行
                            var data = result.data; //声明data变量,并将其赋值为result对象中的data属性
                            resultData = data[0];   //将data数组(或类数组对象)的第一个元素赋值给变量resultData
                        }
                        //else {
                        //    layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' }); //result.msg对象,提示弹窗 ç±»åž‹ä¸º5, æŒ‰é’®ï¼Œå’ŒæŒ‰é’®çš„名称为退出  æ—¶é—´ ä¸º100秒,以及偏移量(`offset: 't'
                        //}
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });  //提示弹窗 å‘生错误 ï¼Œè­¦ç¤ºæ ‡å¿—为5的
                    }
                });
                return resultData;
            }
            //#endregion
            //#region ä¿å­˜åŽæµè§ˆæ–¹æ³•
            function ReRoadBillMain() {
                location.replace('Add_Edit_Xs_SeOutStockBillList.html?OperationType=4&linterid=' + linterid + '&HSouceBillType=');
@@ -1400,6 +2221,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)  //返回业务员
        {
@@ -1431,7 +2285,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("该项目已关闭,不可选择!");
            }
@@ -1451,7 +2309,11 @@
            }
            layui.table.render(option);
        }
        function GetSettleStyleValue(obj)  //返回结算方式
        {
            $("#HSSName").val(obj[0].结算方式名称);
            $("#HSSID").val(obj[0].HItemID);
        }
        //双击返回仓库
        function GetHWHSubValue(data) {
            OptionData = data[0]