mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-01-25 16:50:55 +08:00
采购单新增单价和金额修改功能
This commit is contained in:
parent
44483ee3b5
commit
f71d5f65ba
6 changed files with 88 additions and 39 deletions
|
@ -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.普通子件
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'});
|
||||
}
|
||||
|
||||
//删除行
|
||||
|
|
|
@ -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'});
|
||||
}
|
||||
|
||||
//删除行
|
||||
|
|
|
@ -95,9 +95,9 @@
|
|||
<td><select id="{{materialId}}" lay-filter="selectMaterialProperty" lay-search win-verify="required"></select></td>
|
||||
<td><select id="{{unitId}}" lay-filter="selectUnitProperty" lay-search win-verify="required"></select></td>
|
||||
<td id="{{currentTock}}"></td>
|
||||
<td><input type="text" class="layui-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
|
||||
<td id="{{unitPrice}}"></td>
|
||||
<td id="{{amountOfMoney}}"></td>
|
||||
<td><input type="text" class="layui-input change-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
|
||||
<td><input type="text" class="layui-input change-input unitPrice" id="{{unitPrice}}" win-verify="required|money"/></td>
|
||||
<td><input type="text" class="layui-input change-input amountOfMoney" id="{{amountOfMoney}}" win-verify="required|money"/></td>
|
||||
<td><input type="text" class="layui-input" id="{{remark}}"/></td>
|
||||
</tr>
|
||||
</script>
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
<td><select id="{{materialId}}" lay-filter="selectMaterialProperty" lay-search win-verify="required"></select></td>
|
||||
<td><select id="{{unitId}}" lay-filter="selectUnitProperty" lay-search win-verify="required"></select></td>
|
||||
<td id="{{currentTock}}"></td>
|
||||
<td><input type="text" class="layui-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
|
||||
<td id="{{unitPrice}}"></td>
|
||||
<td id="{{amountOfMoney}}"></td>
|
||||
<td><input type="text" class="layui-input change-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
|
||||
<td><input type="text" class="layui-input change-input unitPrice" id="{{unitPrice}}" win-verify="required|money"/></td>
|
||||
<td><input type="text" class="layui-input change-input amountOfMoney" id="{{amountOfMoney}}" win-verify="required|money"/></td>
|
||||
<td><input type="text" class="layui-input" id="{{remark}}"/></td>
|
||||
</tr>
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue