WebTM/views/ÏúÊÛ¹ÜÀí/·¢»õ֪ͨµ¥/Add_Edit_Xs_SeOutStockBillList.html
@@ -376,7 +376,7 @@
            var shijian = year + "-" + month + "-" + day;
            var allVal;
            var topScroll = 0;//记录滚动条的位置
            var HModName = "Add_Edit_Xs_SeOutStockBillList";
            //#endregion
@@ -445,14 +445,6 @@
            }
            //#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();
            //获取源单类型
@@ -464,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) {
@@ -662,6 +654,8 @@
                                        j++;
                                    }
                                    table.render(option);
                                    //设置当前库存
                                    SetAllInventoryByMaterID();
                                    layer.close(ajaxLoad);
                                    layer.msg("查询成功", { time: 1 * 1000, icon: 1 });
                                }
@@ -688,6 +682,7 @@
                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 //得到修改后的值
@@ -880,6 +875,8 @@
                        $("#HWHName").val(checkStatus.data[0].主仓库);
                        table.render(option);
                        //设置当前库存
                        SetAllInventoryByMaterID();
                        layer.close(index);//关闭弹窗
                    }
@@ -940,6 +937,8 @@
                            }
                        }
                        getSeletMainInfo(sMainWhere);
                        //设置当前库存
                        SetAllInventoryByMaterID();
                        layer.close(index);//关闭弹窗
                    }
                });
@@ -1053,6 +1052,7 @@
                    , limit: 500
                    , height: 500
                    , loading: false
                    , totalRow:true
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true }
@@ -1068,15 +1068,23 @@
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID" }//f7
                        , { field: 'HWHID', title: 'HWHID', width: 100, hide: true }
                        , { field: '发货仓库', title: '发货仓库', width: 100, edit: 'text', event: "HWHID" }//f7
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text' }
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text', totalRow: true  }
                        , { field: 'HInventoryQty', title: '当前库存', width: 100}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text' }
                        , { field: 'HMoney', title: '金额', width: 100 }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true  }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                    , done: function (res, curr, count) {
                        $(".layui-table-main").scrollTop(topScroll);
                    }
                }
                option.data = [];
                option.data = [{
                        "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                        "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "", "HInventoryQty": 0,
                        "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                    }];
                table.render(option);
                DisPlay_HideColumn();
@@ -1102,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
@@ -1151,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].源单主内码,   //源单主内码
@@ -1161,6 +1170,8 @@
                            }
                            option.data = rowdata;
                            table.render(option);
                            //设置当前库存
                            SetAllInventoryByMaterID();
                            form.render('select');
                            layer.close(ajaxLoad);
@@ -1369,6 +1380,8 @@
                                            if (childData != null) {
                                                //更新表格缓存的数据
                                                OptionData = childData;
                                                //获取当前库存
                                                var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                                obj.update({
                                                    "HMaterID": OptionData.HItemID
                                                    , "物料代码": OptionData.物料代码
@@ -1377,7 +1390,9 @@
                                                    , "HUnitID": OptionData.HUnitID
                                                    , "计量单位": OptionData.计量单位名称
                                                    , "HQty": 1
                                                    , "HInventoryQty": HInventoryQty
                                                })
                                                OptionData = {};
                                                childData = null;
@@ -1410,6 +1425,7 @@
                                    if (childData != null) {
                                        //更新表格缓存的数据
                                        OptionData = childData;
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
                                            , "物料代码": OptionData.物料代码
@@ -1418,6 +1434,7 @@
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = {};
@@ -1456,7 +1473,9 @@
                                    if (checkStatus.data.length == 0) {
                                        return layer.msg("请选择数据");
                                    }else if (checkStatus.data.length == 1) {
                                    } else if (checkStatus.data.length == 1) {
                                        //获取当前库存
                                        var HInventoryQty = GetInventoryByMaterID(checkStatus.data[0].HItemID, obj.data["HWHID"]);
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": checkStatus.data[0].HItemID
@@ -1465,20 +1484,37 @@
                                            , "规格型号": checkStatus.data[0].规格型号
                                            , "HUnitID": checkStatus.data[0].HUnitID
                                            , "计量单位": checkStatus.data[0].计量单位名称
                                            , "HInventoryQty": HInventoryQty
                                            ,"HQty": 1
                                        })
                                        layer.close(index);//关闭弹窗
                                    } else {
                                        table.cache["mainTable"].splice(0, 1);
                                        for (var rowData of checkStatus.data) {
                                            var NewRow = {
                                                "HMaterID": rowData.HItemID, "物料代码": rowData.物料代码, "物料名称": rowData.物料名称, "规格型号": rowData.规格型号, "HUnitID": rowData.HUnitID, "计量单位": rowData.计量单位名称, "HWHID": "0", "发货仓库": "",
                                                "HQty": "1", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                                "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                            };
                                            table.cache["mainTable"].push(NewRow);
                                        var rowIndex = $(obj.tr).attr("data-index") * 1;  //attr("data-index")用于获取该tr元素上data-index属性的值*1转换类型然后赋值给rowIndex
                                        for (var i = 0; i < checkStatus.data.length; i++) {  //判断选中的数据的长度  ç”¨äºŽéåކcheckStatus.data数组中的每个元素
                                            if (rowIndex + i >= option.data.length) {           //判断rowIndex + i的索引超出了option.data数组的长度,说明option.data数组需要扩展以包含更多行
                                                //新增行表格数据
                                                var NewRow = {
                                                    "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                                                    "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                                    "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                                };
                                                table.cache["mainTable"].push(NewRow);    //创建新的包含数组  ä¼ å…¥table.cache["mainTable"]数组
                                                option.data = table.cache["mainTable"];  //把传入 table.cache["mainTable"]数组的值赋值给option.data çš„属性
                                                table.render(option);//渲染界面
                                            }
                                            //获取当前库存
                                            var HInventoryQty = GetInventoryByMaterID(checkStatus.data[i].HItemID, option.data[rowIndex + i].HWHID);
                                            option.data[rowIndex + i].HMaterID = checkStatus.data[i].HItemID;  //将option.data数组中对应行的HMaterID属性更新为从resultData对象中获取的物料ID
                                            option.data[rowIndex + i].物料代码 = checkStatus.data[i].物料代码; //将option.data数组中对应行的 ç‰©æ–™ä»£ç  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].物料名称 = checkStatus.data[i].物料名称; //将option.data数组中对应行的  ç‰©æ–™åç§°  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].规格型号 = checkStatus.data[i].规格型号; //将option.data数组中对应行的  è§„格型号  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].HUnitID = checkStatus.data[i].HUnitID; //将option.data数组中对应行的 HUnitID å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                            option.data[rowIndex + i].计量单位 = checkStatus.data[i].计量单位名称; //将option.data数组中对应行的 è®¡é‡å•位 å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID   æ›´æ–°è®¡é‡å•位属性
                                            option.data[rowIndex + i].HQty = 1;  //将对应行的HQty属性(可能代表数量)设置为1。这表示对于每个选中的物料,其默认数量被设置为1
                                            option.data[rowIndex + i].HInventoryQty = HInventoryQty;  //当前库存
                                        }
                                        option.data = table.cache["mainTable"];
                                        table.render(option);
                                        layer.close(index);//关闭弹窗
                                    }
@@ -1486,6 +1522,7 @@
                                }
                                , end: function () {
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HMaterID": OptionData.HItemID
@@ -1495,6 +1532,7 @@
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HQty": 1
                                            , "HInventoryQty": HInventoryQty
                                        })
                                        OptionData = [];
                                    }
@@ -1560,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 = [];
                                    }
@@ -1607,6 +1649,8 @@
                            if (checkStatus.data.length == 0) {
                                return layer.msg("请选择数据");
                            } else if (checkStatus.data.length == 1) {
                                //获取当前库存
                                var HInventoryQty = GetInventoryByMaterID(checkStatus.data[0].HItemID, obj.data["HWHID"]);
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": checkStatus.data[0].HItemID
@@ -1615,20 +1659,37 @@
                                    , "规格型号": checkStatus.data[0].规格型号
                                    , "HUnitID": checkStatus.data[0].HUnitID
                                    , "计量单位": checkStatus.data[0].计量单位名称
                                    , "HInventoryQty": HInventoryQty
                                    , "HQty": 1
                                })
                                layer.close(index);//关闭弹窗
                            } else {
                                table.cache["mainTable"].splice(0, 1);
                                for (var rowData of checkStatus.data) {
                                    var NewRow = {
                                        "HMaterID": rowData.HItemID, "物料代码": rowData.物料代码, "物料名称": rowData.物料名称, "规格型号": rowData.规格型号, "HUnitID": rowData.HUnitID, "计量单位": rowData.计量单位名称, "HWHID": "0", "发货仓库": "",
                                        "HQty": "1", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                        "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                    };
                                    table.cache["mainTable"].push(NewRow);
                                var rowIndex = $(obj.tr).attr("data-index") * 1;  //attr("data-index")用于获取该tr元素上data-index属性的值*1转换类型然后赋值给rowIndex
                                for (var i = 0; i < checkStatus.data.length; i++) {  //判断选中的数据的长度  ç”¨äºŽéåކcheckStatus.data数组中的每个元素
                                    if (rowIndex + i >= option.data.length) {           //判断rowIndex + i的索引超出了option.data数组的长度,说明option.data数组需要扩展以包含更多行
                                        //新增行表格数据
                                        var NewRow = {
                                            "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": "0", "发货仓库": "",
                                            "HQty": "0", "HPrice": "0", "HMoney": "0", "HRemark": "",
                                            "HSourceBillNo": 0, "HSourceBillType": 0, "HSourceInterID": 0, "HSourceEntryID": 0,
                                        };
                                        table.cache["mainTable"].push(NewRow);    //创建新的包含数组  ä¼ å…¥table.cache["mainTable"]数组
                                        option.data = table.cache["mainTable"];  //把传入 table.cache["mainTable"]数组的值赋值给option.data çš„属性
                                        table.render(option);//渲染界面
                                    }
                                    //获取当前库存
                                    var HInventoryQty = GetInventoryByMaterID(checkStatus.data[i].HItemID, option.data[rowIndex + i].HWHID);
                                    option.data[rowIndex + i].HMaterID = checkStatus.data[i].HItemID;  //将option.data数组中对应行的HMaterID属性更新为从resultData对象中获取的物料ID
                                    option.data[rowIndex + i].物料代码 = checkStatus.data[i].物料代码; //将option.data数组中对应行的 ç‰©æ–™ä»£ç  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].物料名称 = checkStatus.data[i].物料名称; //将option.data数组中对应行的  ç‰©æ–™åç§°  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].规格型号 = checkStatus.data[i].规格型号; //将option.data数组中对应行的  è§„格型号  å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].HUnitID = checkStatus.data[i].HUnitID; //将option.data数组中对应行的 HUnitID å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID
                                    option.data[rowIndex + i].计量单位 = checkStatus.data[i].计量单位名称; //将option.data数组中对应行的 è®¡é‡å•位 å±žæ€§æ›´æ–°ä¸ºä»ŽresultData对象中获取的物料ID   æ›´æ–°è®¡é‡å•位属性
                                    option.data[rowIndex + i].HQty = 1;  //将对应行的HQty属性(可能代表数量)设置为1。这表示对于每个选中的物料,其默认数量被设置为1
                                    option.data[rowIndex + i].HInventoryQty = HInventoryQty;  //当前库存
                                }
                                option.data = table.cache["mainTable"];
                                table.render(option);
                                layer.close(index);//关闭弹窗
                            }
@@ -1636,6 +1697,7 @@
                        }
                        , end: function () {
                            if (typeof (OptionData.HItemID) != "undefined") {
                                var HInventoryQty = GetInventoryByMaterID(OptionData.HItemID, obj.data["HWHID"]);
                                //更新表格缓存的数据
                                obj.update({
                                    "HMaterID": OptionData.HItemID
@@ -1645,11 +1707,14 @@
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                    , "HQty": 1
                                    , "HInventoryQty": HInventoryQty
                                })
                                OptionData = [];
                            }
                        }
                    })
                    obj.event = "";
                });
            }
@@ -1703,6 +1768,37 @@
            }
            //#endregion
            //#region åŠæ—¶åº“存查询
            function GetInventoryByMaterID(HMaterID, HWHID) {
                var HInventoryQty = 0;
                $.ajax({
                    url: GetWEBURL() + '/Xs_SeOutStockBill/GetICInventory',
                    async: false,
                    type: "GET",
                    data: { "HMaterID": HMaterID, "HWHID": HWHID, "HORGID": sessionStorage["OrganizationID"] },
                    async: false,
                    success: function (data1) {
                        if (data1.count == 1) {
                            HInventoryQty = data1.data;
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                })
                return HInventoryQty;
            }
            //设置获取所有option的当前库存
            function SetAllInventoryByMaterID() {
                option.date = table.cache["mainTable"];
                for (var i = 0; i < table.cache["mainTable"].length; i++) {
                    var HInventoryQty = GetInventoryByMaterID(table.cache["mainTable"][i].HMaterID, table.cache["mainTable"][i].HWHID);
                    table.cache["mainTable"][i].HInventoryQty = HInventoryQty;
                }
                table.render(option);
            }
            //#endregion
            //#region å­è¡¨1:隐藏列设置
            function get_HideColumn() {
                var colName = "";
@@ -1755,6 +1851,9 @@
                            dataCol = data1.data[0].HGridString.split(',');
                            for (var i = 0; i < option.cols[0].length - 2; i++) {
                                if (dataCol.length <= i) {
                                    break;
                                }
                                var dataCols = dataCol[i].split('|');
                                //隐藏列
                                if (dataCols[1] == 1) {
@@ -1835,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);
                        }
                    });