wtt
2024-08-09 11395a9d3223177c044ae557286a64412e119079
WebTM/views/²É¹º¹ÜÀí/²É¹ººÏͬ/Add_Edit_Cg_ContractBillList.html
@@ -598,7 +598,6 @@
                                HQty: oldText  //将hqty字段恢复到保存单元格的值
                            });
                            table.render(option);  //重新渲染表格
                            layer.msg("数量请输入大于0的数字!");   //提示请输入大于0数字
                            return; 
                        }
@@ -628,7 +627,7 @@
                            obj.update({     //使用obj.update方法更新表格中某一行的数据
                                HPrice: oldText    //将HPrice字段恢复到保存单元格的值
                            });
                            table.render(option);  //重新渲染表格
                            layer.msg("单价请输入大于0的数字!");  //提示 å•价请输入大于0的数字!
                            return;
                        }
@@ -660,6 +659,7 @@
                                HTaxRate: oldText
                            });
                            layer.msg("税率请输入不小于0的数字!");
                            table.render(option);  //重新渲染表格
                            return;
                        }
@@ -683,7 +683,6 @@
                            , HlineTotal: HlineTotal
                        });
                        break;
                        table.render(option);
                    default:
                }
            });
@@ -1091,31 +1090,33 @@
                                    //    return layer.msg("请选择一条数据");
                                    //}
                                    OptionData = checkStatus.data[0];
                                    var rowIndex = $(obj.tr).attr("data-index") * 1;
                                    for (var i = 0; i < checkStatus.data.length; i++) {
                                        if (rowIndex + i >= option.data.length) {
                                            var NewRow = {
                                                "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": 0, "HWHName": "", "数量": "", "HRemark": ""
                                                , "HPrice": "0", "HTaxPrice": "0", "HMoney": "0", "HDiscountRate": "1", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0", "HDate": Format(new Date, "yyyy- MM - dd")
                                            };
                                    if (checkStatus.data.length > 1) {
                                        var rowIndex = $(obj.tr).attr("data-index") * 1;
                                        for (var i = 0; i < checkStatus.data.length; i++) {
                                            if (rowIndex + i >= option.data.length) {
                                                var NewRow = {
                                                    "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": 0, "HWHName": "", "数量": "", "HRemark": ""
                                                    , "HPrice": "0", "HTaxPrice": "0", "HMoney": "0", "HDiscountRate": "1", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0", "HDate": Format(new Date, "yyyy- MM - dd")
                                                };
                                            table.cache["mainTable"].push(NewRow);
                                            option.data = table.cache["mainTable"];
                                                table.cache["mainTable"].push(NewRow);
                                                option.data = table.cache["mainTable"];
                                            table.render(option);
                                                table.render(option);
                                            }
                                            var HMaterID = checkStatus.data[i].HItemID;
                                            var resultData = getMaterialByMaterID(HMaterID);
                                            option.data[rowIndex + i].HMaterID = resultData.HMaterID;
                                            option.data[rowIndex + i].物料代码 = resultData.HMaterNumber;
                                            option.data[rowIndex + i].物料名称 = resultData.HMaterName;
                                            option.data[rowIndex + i].规格型号 = resultData.HMaterModel;
                                            option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                            option.data[rowIndex + i].计量单位 = resultData.HUnitName;
                                        }
                                        var HMaterID = checkStatus.data[i].HItemID;
                                        var resultData = getMaterialByMaterID(HMaterID);
                                        option.data[rowIndex + i].HMaterID = resultData.HMaterID;
                                        option.data[rowIndex + i].物料代码 = resultData.HMaterNumber;
                                        option.data[rowIndex + i].物料名称 = resultData.HMaterName;
                                        option.data[rowIndex + i].规格型号 = resultData.HMaterModel;
                                        option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                        option.data[rowIndex + i].计量单位 = resultData.HUnitName;
                                        table.render(option);
                                    }
                                    table.render(option);
                                    layer.closeAll();
                                    //layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
@@ -1124,14 +1125,50 @@
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                    obj.update({
                                        "HMaterID": OptionData.HItemID
                                        , "物料代码": OptionData.物料代码
                                        , "物料名称": OptionData.物料名称
                                        , "规格型号": OptionData.规格型号
                                        , "HUnitID": OptionData.HUnitID
                                        , "计量单位": OptionData.计量单位名称
                                    })
                                    //通过供应商id获取税率
                                    var HSupID = $("#HSupID").val();
                                    if (HSupID != 0) {
                                        $.ajax({
                                            url: GetWEBURL() + "/Gy_Supplier/xg",
                                            //url: "http://localhost:12761/Gy_Supplier/xg",
                                            type: "GET",
                                            data: {
                                                "HInterID": HSupID
                                            },
                                            success: function (d) {
                                                var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                                //数据校验合格,重算记录
                                                var HQty = obj.data.HQty * 1;                           //数量
                                                var HPrice = obj.data.HPrice * 1;               //单价
                                                var HMoney = HQty * HPrice;                     //金额=数量*单价
                                                var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                                                var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                                obj.update({ //更新表格数据
                                                    "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                    , "物料代码": OptionData.物料代码
                                                    , "物料名称": OptionData.物料名称
                                                    , "规格型号": OptionData.规格型号
                                                    , "HUnitID": OptionData.HUnitID
                                                    , "计量单位": OptionData.计量单位名称
                                                    , "HTaxRate": HTaxRate * 100
                                                    , HQty: HQty                               //更新HQty字段,HQty
                                                    , HPrice: HPrice                         //更新HPrice字段,HPrice
                                                    , HMoney: HMoney                      //更新HMoney字段,HMoney
                                                    , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                                    , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                                })
                                            }
                                        });
                                    } else {
                                        obj.update({ //更新表格数据
                                            "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                        })
                                    }
                                }
                            });
                        }
@@ -1210,6 +1247,110 @@
                    }
                })
                //双击
                $('.layui-table-box tbody td[data-field="物料代码"]').off('dblclick').on('dblclick', function () {
                    var HOrgID = $("#HOrgID").val();
                    layer.open({
                        type: 2
                        , skin: "layui-layer-rim" //加上边框
                        , title: "物料列表"  //标题
                        , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                        , shift: 2 //弹出动画
                        , area: ["90%", "90%"] //窗体大小
                        , maxmin: true //设置最大最小按钮是否显示
                        , content: ['../../基础资料/公用基础资料/Gy_Material.html?openType=2&HOrgID=' + HOrgID, 'yes']
                        , btn: ["确定", "取消"]
                        , btn1: function (index, laero) {
                            //按钮一  çš„回调
                            var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                            var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                            //if (checkStatus.data.length != 1) {
                            //    return layer.msg("请选择一条数据");
                            //}
                            OptionData = checkStatus.data[0];
                            if (checkStatus.data.length > 1) {
                                var rowIndex = $(obj.tr).attr("data-index") * 1;
                                for (var i = 0; i < checkStatus.data.length; i++) {
                                    if (rowIndex + i >= option.data.length) {
                                        var NewRow = {
                                            "HMaterID": 0, "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": 0, "计量单位": "", "HWHID": 0, "HWHName": "", "数量": "", "HRemark": ""
                                            , "HPrice": "0", "HTaxPrice": "0", "HMoney": "0", "HDiscountRate": "1", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0", "HDate": Format(new Date, "yyyy- MM - dd")
                                        };
                                        table.cache["mainTable"].push(NewRow);
                                        option.data = table.cache["mainTable"];
                                        table.render(option);
                                    }
                                    var HMaterID = checkStatus.data[i].HItemID;
                                    var resultData = getMaterialByMaterID(HMaterID);
                                    option.data[rowIndex + i].HMaterID = resultData.HMaterID;
                                    option.data[rowIndex + i].物料代码 = resultData.HMaterNumber;
                                    option.data[rowIndex + i].物料名称 = resultData.HMaterName;
                                    option.data[rowIndex + i].规格型号 = resultData.HMaterModel;
                                    option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                    option.data[rowIndex + i].计量单位 = resultData.HUnitName;
                                }
                                table.render(option);
                            }
                            layer.closeAll();
                            //layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                        }
                        , btn2: function (index, layero) {
                            //按钮【按钮二】的回调
                            //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                        },
                        end: function () {
                            //通过供应商id获取税率
                            var HSupID = $("#HSupID").val();
                            if (HSupID != 0) {
                                $.ajax({
                                    url: GetWEBURL() + "/Gy_Supplier/xg",
                                    //url: "http://localhost:12761/Gy_Supplier/xg",
                                    type: "GET",
                                    data: {
                                        "HInterID": HSupID
                                    },
                                    success: function (d) {
                                        var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                        //数据校验合格,重算记录
                                        var HQty = obj.data.HQty * 1;                           //数量
                                        var HPrice = obj.data.HPrice * 1;               //单价
                                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                        obj.update({ //更新表格数据
                                            "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HTaxRate": HTaxRate * 100
                                            , HQty: HQty                               //更新HQty字段,HQty
                                            , HPrice: HPrice                         //更新HPrice字段,HPrice
                                            , HMoney: HMoney                      //更新HMoney字段,HMoney
                                            , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                            , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                        })
                                    }
                                });
                            } else {
                                obj.update({ //更新表格数据
                                    "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                    , "物料代码": OptionData.物料代码
                                    , "物料名称": OptionData.物料名称
                                    , "规格型号": OptionData.规格型号
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                })
                            }
                        }
                    });
                });
            }
            //行内删除