From f71d5f65ba1d413bab49fb5e86031e91e01831ef Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Fri, 18 Oct 2019 16:30:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8D=95=E4=BB=B7=E5=92=8C=E9=87=91=E9=A2=9D=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PurchaseOrderServiceImpl.java | 6 +- .../dbmapper/erp/PurchaseOrderMapper.xml | 1 - .../js/purchaseorder/purchaseorderadd.js | 52 ++++++++++++----- .../js/purchaseorder/purchaseorderedit.js | 56 +++++++++++++------ .../tpl/purchaseorder/purchaseorderadd.html | 6 +- .../tpl/purchaseorder/purchaseorderedit.html | 6 +- 6 files changed, 88 insertions(+), 39 deletions(-) diff --git a/erp-modular/src/main/java/com/skyeye/service/impl/PurchaseOrderServiceImpl.java b/erp-modular/src/main/java/com/skyeye/service/impl/PurchaseOrderServiceImpl.java index 246a60d2..af237892 100644 --- a/erp-modular/src/main/java/com/skyeye/service/impl/PurchaseOrderServiceImpl.java +++ b/erp-modular/src/main/java/com/skyeye/service/impl/PurchaseOrderServiceImpl.java @@ -73,13 +73,14 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService{ entity = purchaseOrderDao.queryMaterialsById(bean); if(entity != null && !entity.isEmpty()){ //获取单价 - itemAllPrice = new BigDecimal(entity.get("estimatePurchasePrice").toString()); + itemAllPrice = new BigDecimal(bean.get("estimatePurchasePrice").toString()); entity.put("id", ToolUtil.getSurFaceId()); entity.put("headerId", useId);//单据主表id entity.put("operNumber", bean.get("rkNum"));//数量 //计算子单总价:单价*数量 itemAllPrice = itemAllPrice.multiply(new BigDecimal(bean.get("rkNum").toString())); entity.put("allPrice", itemAllPrice);//单据子表总价 + entity.put("estimatePurchasePrice", bean.get("estimatePurchasePrice"));//单价 entity.put("remark", bean.get("remark"));//备注 entity.put("depotId", bean.get("depotId"));//仓库 entity.put("mType", 0);//商品类型 0.普通 1.组合件 2.普通子件 @@ -195,13 +196,14 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService{ entity = purchaseOrderDao.queryMaterialsById(bean); if(entity != null && !entity.isEmpty()){ //获取单价 - itemAllPrice = new BigDecimal(entity.get("estimatePurchasePrice").toString()); + itemAllPrice = new BigDecimal(bean.get("estimatePurchasePrice").toString()); entity.put("id", ToolUtil.getSurFaceId()); entity.put("headerId", useId);//单据主表id entity.put("operNumber", bean.get("rkNum"));//数量 //计算子单总价:单价*数量 itemAllPrice = itemAllPrice.multiply(new BigDecimal(bean.get("rkNum").toString())); entity.put("allPrice", itemAllPrice);//单据子表总价 + entity.put("estimatePurchasePrice", bean.get("estimatePurchasePrice"));//单价 entity.put("remark", bean.get("remark"));//备注 entity.put("depotId", bean.get("depotId"));//仓库 entity.put("mType", 0);//商品类型 0.普通 1.组合件 2.普通子件 diff --git a/erp-modular/src/main/resources/dbmapper/erp/PurchaseOrderMapper.xml b/erp-modular/src/main/resources/dbmapper/erp/PurchaseOrderMapper.xml index 0bcd9d12..0ac02a7d 100644 --- a/erp-modular/src/main/resources/dbmapper/erp/PurchaseOrderMapper.xml +++ b/erp-modular/src/main/resources/dbmapper/erp/PurchaseOrderMapper.xml @@ -39,7 +39,6 @@ a.`name` materialName, a.model materialModel, b.id mUnitId, - b.estimate_purchase_price estimatePurchasePrice, IFNULL(c.`name`, a.unit_name) unitName, IFNULL(c.number, '1') baseNumber, #{depotId} depotId diff --git a/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderadd.js b/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderadd.js index 18323110..9c284c14 100644 --- a/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderadd.js +++ b/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderadd.js @@ -107,16 +107,16 @@ layui.config({ $.each(item.unitList, function(j, bean) { if(item.firstInUnit == bean.unitId){ $("#unitId" + thisRowNum).val(bean.id); - $("#unitPrice" + thisRowNum).html(bean.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 return false; } }); }else{//不是多单位 var firstItem = item.unitList[0]; $("#unitId" + thisRowNum).val(firstItem.id); - $("#unitPrice" + thisRowNum).html(firstItem.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(firstItem.estimatePurchasePrice)).toFixed(2));//金额 + $("#unitPrice" + thisRowNum).val(firstItem.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(firstItem.estimatePurchasePrice)).toFixed(2));//金额 } form.render('select'); return false; @@ -145,8 +145,8 @@ layui.config({ if(thisRowValue == bean.id){//获取规格 //获取当前行数量 var rkNum = parseInt($("#rkNum" + thisRowNum).val()); - $("#unitPrice" + thisRowNum).html(bean.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 return false; } }); @@ -154,8 +154,8 @@ layui.config({ } }); } else { - $("#unitPrice" + thisRowNum).html("");//重置单价为空 - $("#amountOfMoney" + thisRowNum).html("");//重置金额为空 + $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 + $("#amountOfMoney" + thisRowNum).val("0.00");//重置金额为空 } //加载库存 loadTockByDepotAndMUnit(thisRowNum); @@ -208,11 +208,22 @@ layui.config({ } } + var showTdByEdit = 'rkNum';//根据那一列的值进行变化,默认根据数量 //数量变化 - $("body").on("input", ".rkNum", function() { + $("body").on("input", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } calculatedTotalPrice(); }); - $("body").on("change", ".rkNum", function() { + $("body").on("change", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } calculatedTotalPrice(); }); @@ -226,10 +237,20 @@ layui.config({ //获取数量 var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? "0" : $("#rkNum" + rowNum).val()); //获取单价 - var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).html()) ? "0" : $("#unitPrice" + rowNum).html()); - //输出金额 - $("#amountOfMoney" + rowNum).html((rkNum * unitPrice).toFixed(2)); - allPrice += rkNum * unitPrice; + var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).val()) ? "0" : $("#unitPrice" + rowNum).val()); + //获取单价 + var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + rowNum).val()) ? "0" : $("#amountOfMoney" + rowNum).val()); + if("rkNum" === showTdByEdit){//数量 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("unitPrice" === showTdByEdit){//单价 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("amountOfMoney" === showTdByEdit){//金额 + //输出单价 + $("#unitPrice" + rowNum).val((amountOfMoney / rkNum).toFixed(2)); + } + allPrice += parseFloat($("#amountOfMoney" + rowNum).val()); }); $("#allPrice").html(allPrice.toFixed(2)); } @@ -267,6 +288,7 @@ layui.config({ materialId: $("#materialId" + rowNum).val(), mUnitId: $("#unitId" + rowNum).val(), rkNum: $("#rkNum" + rowNum).val(), + estimatePurchasePrice: $("#unitPrice" + rowNum).val(), remark: $("#remark" + rowNum).val() }; tableData.push(row); @@ -339,6 +361,8 @@ layui.config({ form.render('select'); form.render('checkbox'); rowNum++; + //设置根据某列变化的颜色 + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); } //删除行 diff --git a/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderedit.js b/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderedit.js index d7150684..f8863cd3 100644 --- a/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderedit.js +++ b/erp-modular/src/main/resources/template/js/purchaseorder/purchaseorderedit.js @@ -116,8 +116,8 @@ layui.config({ $("#materialId" + (rowNum - 1)).val(item.materialId);//产品回显 $("#currentTock" + (rowNum - 1)).html(item.currentTock);//库存回显 $("#rkNum" + (rowNum - 1)).val(item.operNum);//数量回显 - $("#unitPrice" + (rowNum - 1)).html(item.unitPrice.toFixed(2));//单价回显 - $("#amountOfMoney" + (rowNum - 1)).html(item.allPrice.toFixed(2));//金额回显 + $("#unitPrice" + (rowNum - 1)).val(item.unitPrice.toFixed(2));//单价回显 + $("#amountOfMoney" + (rowNum - 1)).val(item.allPrice.toFixed(2));//金额回显 $("#remark" + (rowNum - 1)).val(item.remark);//备注回显 //设置标识 $("tr[trcusid='tr" + (rowNum - 1) + "']").attr("thisid", item.id); @@ -147,16 +147,16 @@ layui.config({ $.each(item.unitList, function(j, bean) { if(item.firstInUnit == bean.unitId){ $("#unitId" + thisRowNum).val(bean.id); - $("#unitPrice" + thisRowNum).html(bean.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 return false; } }); }else{//不是多单位 var firstItem = item.unitList[0]; $("#unitId" + thisRowNum).val(firstItem.id); - $("#unitPrice" + thisRowNum).html(firstItem.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(firstItem.estimatePurchasePrice)).toFixed(2));//金额 + $("#unitPrice" + thisRowNum).val(firstItem.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(firstItem.estimatePurchasePrice)).toFixed(2));//金额 } form.render('select'); return false; @@ -185,8 +185,8 @@ layui.config({ if(thisRowValue == bean.id){//获取规格 //获取当前行数量 var rkNum = parseInt($("#rkNum" + thisRowNum).val()); - $("#unitPrice" + thisRowNum).html(bean.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 return false; } }); @@ -194,8 +194,8 @@ layui.config({ } }); } else { - $("#unitPrice" + thisRowNum).html("");//重置单价为空 - $("#amountOfMoney" + thisRowNum).html("");//重置金额为空 + $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 + $("#amountOfMoney" + thisRowNum).val("0.00");//重置金额为空 } //加载库存 loadTockByDepotAndMUnit(thisRowNum); @@ -248,11 +248,22 @@ layui.config({ } } + var showTdByEdit = 'rkNum';//根据那一列的值进行变化,默认根据数量 //数量变化 - $("body").on("input", ".rkNum", function() { + $("body").on("input", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } calculatedTotalPrice(); }); - $("body").on("change", ".rkNum", function() { + $("body").on("change", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } calculatedTotalPrice(); }); @@ -266,10 +277,20 @@ layui.config({ //获取数量 var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? "0" : $("#rkNum" + rowNum).val()); //获取单价 - var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).html()) ? "0" : $("#unitPrice" + rowNum).html()); - //输出金额 - $("#amountOfMoney" + rowNum).html((rkNum * unitPrice).toFixed(2)); - allPrice += rkNum * unitPrice; + var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).val()) ? "0" : $("#unitPrice" + rowNum).val()); + //获取单价 + var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + rowNum).val()) ? "0" : $("#amountOfMoney" + rowNum).val()); + if("rkNum" === showTdByEdit){//数量 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("unitPrice" === showTdByEdit){//单价 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("amountOfMoney" === showTdByEdit){//金额 + //输出单价 + $("#unitPrice" + rowNum).val((amountOfMoney / rkNum).toFixed(2)); + } + allPrice += parseFloat($("#amountOfMoney" + rowNum).val()); }); $("#allPrice").html(allPrice.toFixed(2)); } @@ -307,6 +328,7 @@ layui.config({ materialId: $("#materialId" + rowNum).val(), mUnitId: $("#unitId" + rowNum).val(), rkNum: $("#rkNum" + rowNum).val(), + estimatePurchasePrice: $("#unitPrice" + rowNum).val(), thisId: isNull($(item).attr("thisid")) ? "" : $(item).attr("thisid"), remark: $("#remark" + rowNum).val() }; @@ -381,6 +403,8 @@ layui.config({ form.render('select'); form.render('checkbox'); rowNum++; + //设置根据某列变化的颜色 + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); } //删除行 diff --git a/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html b/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html index 374e477e..b0ee5a9b 100644 --- a/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html +++ b/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html @@ -95,9 +95,9 @@ - - - + + + diff --git a/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderedit.html b/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderedit.html index c16a65e6..771d9ba7 100644 --- a/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderedit.html +++ b/erp-modular/src/main/resources/template/tpl/purchaseorder/purchaseorderedit.html @@ -22,9 +22,9 @@ - - - + + +