|
@ -2,6 +2,8 @@ |
|
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|
|
<head> |
|
|
<head> |
|
|
<th:block th:include="include :: header('新增采购计划单')" /> |
|
|
<th:block th:include="include :: header('新增采购计划单')" /> |
|
|
|
|
|
<th:block th:include="include :: datetimepicker-css" /> |
|
|
|
|
|
<th:block th:include="include :: select2-css" /> |
|
|
</head> |
|
|
</head> |
|
|
<body class="white-bg"> |
|
|
<body class="white-bg"> |
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|
@ -78,6 +80,8 @@ |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<th:block th:include="include :: footer" /> |
|
|
<th:block th:include="include :: footer" /> |
|
|
|
|
|
<th:block th:include="include :: datetimepicker-js" /> |
|
|
|
|
|
<th:block th:include="include :: select2-js" /> |
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
|
<script th:inline="javascript"> |
|
|
<script th:inline="javascript"> |
|
|
var prefix = ctx + "purchase/purchaseOrder"; |
|
|
var prefix = ctx + "purchase/purchaseOrder"; |
|
@ -149,67 +153,73 @@ |
|
|
if (material.purchaseSupplierList.size == 0) { |
|
|
if (material.purchaseSupplierList.size == 0) { |
|
|
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); |
|
|
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); |
|
|
$tableWrapper.append($noSupplierDiv); |
|
|
$tableWrapper.append($noSupplierDiv); |
|
|
}else{ |
|
|
} |
|
|
|
|
|
else{ |
|
|
material.purchaseSupplierList.forEach(supplier => { |
|
|
material.purchaseSupplierList.forEach(supplier => { |
|
|
const key = `${supplier.supplierCode}_${supplier.materialCode}`; |
|
|
const key = `${supplier.supplierCode}_${supplier.materialCode}`; |
|
|
|
|
|
$supplierInfo = $('<div class="card supplier-card" id="supplierInfo-' + tableId + '"></div>'); |
|
|
if (!uniqueSuppliers.map(s => `${s.supplierCode}_${s.materialCode}`).includes(key)) { |
|
|
if (!uniqueSuppliers.map(s => `${s.supplierCode}_${s.materialCode}`).includes(key)) { |
|
|
uniqueSuppliers.push(supplier); |
|
|
uniqueSuppliers.push(supplier); |
|
|
|
|
|
}else{ |
|
|
|
|
|
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); |
|
|
|
|
|
$supplierInfo.append($noSupplierDiv); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
// 循环处理每个供应商的信息 |
|
|
// 循环处理每个供应商的信息 |
|
|
uniqueSuppliers.forEach(function (supplier, supplierIndex) { |
|
|
uniqueSuppliers.forEach(function (supplier, supplierIndex) { |
|
|
//如果供应商相同,则不需要再次添加供应商信息 |
|
|
//如果供应商相同,则不需要再次添加供应商信息 |
|
|
$supplierInfo = $('<div class="card supplier-card" id="supplierInfo-' + tableId +'-'+ supplierIndex + '"></div>'); |
|
|
|
|
|
// 卡片样式容器,用于包裹每个供应商的信息 |
|
|
// 卡片样式容器,用于包裹每个供应商的信息 |
|
|
// 构建供应商信息头部 |
|
|
// 构建供应商信息头部 |
|
|
var $headerContent = |
|
|
var $headerContent = |
|
|
$('<div class="card-header" id = "supplier-' + tableId + '">' + |
|
|
$('<div class="card-header" id = "supplier-' + tableId + '_' + supplierIndex + '">' + |
|
|
'<div class="row">' + |
|
|
'<div class="row">' + |
|
|
'<div class="crad-text">'+ |
|
|
'<div class="crad-text">'+ |
|
|
'<h4>供应商 ' + supplierIndex + ':' + '</h4>' + |
|
|
'<h4>供应商 ' + supplierIndex + ':' + '</h4>' + |
|
|
'<span class="supplierCode"">' + supplier.supplierCode + '</span>' + '-' + |
|
|
'<span class="supplierCode_'+ supplierIndex +'">' + supplier.supplierCode + '</span>' + '-' + |
|
|
'<span class="supplierName">' + supplier.supplierName + '</span>' + |
|
|
'<span class="supplierName_'+ supplierIndex +'">' + supplier.supplierName + '</span>' + |
|
|
'-最新不含税采购价: ' + |
|
|
'-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb_'+ supplierIndex +'">' + supplier.materialNoRmb +'</span>'+ |
|
|
'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb">' + supplier.materialNoRmb + |
|
|
' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb_'+ supplierIndex +'">' + supplier.materialRmb + '</span> RMB ' + |
|
|
'</span>'+ ' RMB 最新含税采购价: ' + |
|
|
'<span class="supplierPurchasePlanCode_'+ supplierIndex +'" hidden="hidden" >' + material.planCodes + '</span>' + |
|
|
'<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB ' + |
|
|
'<span class="supplierCorrelationCode_'+ supplierIndex +'" hidden="hidden" >' + material.correlationCodes + '</span>' + |
|
|
'<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' + |
|
|
'<span class="supplierPurchaseQuoteCode_'+ supplierIndex +'" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' + |
|
|
'<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCodes + '</span>' + |
|
|
|
|
|
'<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' + |
|
|
|
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'<div class="row">' + |
|
|
'<div class="row">' + |
|
|
'<div class="form-row">' + |
|
|
'<div class="form-row">' + |
|
|
'<label class="col-sm-2"> 实际采购数: </label>' + |
|
|
'<label class="col-sm-2"> 实际采购数: </label>' + |
|
|
'<div class ="col-sm-4">' + |
|
|
'<div class ="col-sm-4">' + |
|
|
'<input type="text" name="materialNum" class="form-control supplierMaterialNum" id="actualPurchaseNum_' + tableId + '">' + |
|
|
'<input type="text" name="materialNum" class="form-control supplierMaterialNum_'+ supplierIndex +'"" id="actualPurchaseNum_' + tableId + '">' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'<div class="form-row">' + |
|
|
'<div class="form-row">' + |
|
|
'<label class="col-sm-2">计划交付时间: </label>' + |
|
|
'<label class="col-sm-2">计划交付时间: </label>' + |
|
|
'<div class ="col-sm-4">' + |
|
|
'<div class ="col-sm-4">' + |
|
|
'<div class="input-group date"> ' + |
|
|
'<div class="input-group date"> ' + |
|
|
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' + |
|
|
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime_'+ supplierIndex +'"" id="deliveryTime_' + tableId + '">' + |
|
|
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' + |
|
|
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' + |
|
|
'</div> ' + |
|
|
'</div> ' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
|
|
|
'</div>' + |
|
|
'</div>'); |
|
|
'</div>'); |
|
|
$tableWrapper.append($supplierInfo); |
|
|
if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) { |
|
|
$supplierInfo.append($headerContent); |
|
|
$supplierInfo.append($headerContent); |
|
|
// 构建供应商信息下的输入表单 |
|
|
// 构建供应商信息下的输入表单 |
|
|
$supplierForm = $('<div class="card-body" id="card_body_' + tableId + '"></div>'); |
|
|
$supplierForm = $('<div class="card-body" id="card_body_' + tableId + '"></div>'); |
|
|
// 实际采购数输入框 |
|
|
// 实际采购数输入框 |
|
|
// 其他表单项可以根据需要类似添加 |
|
|
// 其他表单项可以根据需要类似添加 |
|
|
$supplierInfo.append($supplierForm); |
|
|
$supplierInfo.append($supplierForm); |
|
|
|
|
|
}else{ |
|
|
|
|
|
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); |
|
|
|
|
|
$supplierInfo.append($noSupplierDiv); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
tableSetup($supplierInfo, tableId); |
|
|
$tableWrapper.append($supplierInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
tableSetup($supplierInfo, tableId); |
|
|
}); |
|
|
}); |
|
|
// 给实际采购数的输入框绑定事件处理器 |
|
|
// 给实际采购数的输入框绑定事件处理器 |
|
|
$('.supplierMaterialNum').off('keyup').on('keyup', function(event,element) { |
|
|
$('.supplierMaterialNum').off('keyup').on('keyup', function(event,element) { |
|
|
console.log(event); |
|
|
|
|
|
console.log(element); |
|
|
|
|
|
var tableId = $(element).closest('.table-materialCode').attr('id'); |
|
|
var tableId = $(element).closest('.table-materialCode').attr('id'); |
|
|
if (event.keyCode === 13) { |
|
|
if (event.keyCode === 13) { |
|
|
// 获取当前供应商的采购数量 |
|
|
// 获取当前供应商的采购数量 |
|
@ -233,6 +243,7 @@ |
|
|
} |
|
|
} |
|
|
recalculateTotals(tableId); // 重新计算当前物料的合计 |
|
|
recalculateTotals(tableId); // 重新计算当前物料的合计 |
|
|
}); |
|
|
}); |
|
|
|
|
|
getWarehouseInfo(); |
|
|
}); |
|
|
}); |
|
|
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价 |
|
|
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价 |
|
|
function recalculateTotals(tableId) { |
|
|
function recalculateTotals(tableId) { |
|
@ -339,6 +350,22 @@ |
|
|
], |
|
|
], |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
function selectSupplierQuote(){ |
|
|
|
|
|
$('.table-materialCode').each(function(index, tableElement) { |
|
|
|
|
|
var tableId = tableIdList[index]; |
|
|
|
|
|
let materialObj = materialList[index]; |
|
|
|
|
|
if (typeof materialObj === 'undefined') return; |
|
|
|
|
|
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { |
|
|
|
|
|
var supplierCode = $(supplierCard).find('.supplierCode').text().trim(); |
|
|
|
|
|
var supplierName = $(supplierCard).find('.supplierName').text().trim(); |
|
|
|
|
|
var materialRealNum = parseInt($(supplierCard).find('.supplierMaterialNum').val(), 10) || 0; |
|
|
|
|
|
var materialRealRmb = parseInt($(supplierCard).find('.supplierMaterialRmb').val(), 10) || 0; |
|
|
|
|
|
var materialRealNoRmb = parseInt($(supplierCard).find('.supplierMaterialNoRmb').val(), 10) || 0; |
|
|
|
|
|
//计划供应商下面的采购数量 |
|
|
|
|
|
purchaseOrder.purchaseOrderChildList.push(materialData); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
function submitHandler() { |
|
|
function submitHandler() { |
|
|
if ($.validate.form()) { |
|
|
if ($.validate.form()) { |
|
|
var purchaseOrder = { |
|
|
var purchaseOrder = { |
|
@ -356,15 +383,17 @@ |
|
|
let materialObj = materialList[index]; |
|
|
let materialObj = materialList[index]; |
|
|
if (typeof materialObj === 'undefined') return; |
|
|
if (typeof materialObj === 'undefined') return; |
|
|
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { |
|
|
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { |
|
|
var supplierCode = $(supplierCard).find('.supplierCode').text().trim(); |
|
|
var supplierCode = $(supplierCard).find('.supplierCode_'+ supplierIndex ).text().trim(); |
|
|
var supplierName = $(supplierCard).find('.supplierName').text().trim(); |
|
|
var supplierName = $(supplierCard).find('.supplierName_'+ supplierIndex).text().trim(); |
|
|
var materialRealNum = parseInt($(supplierCard).find('.supplierMaterialNum').val(), 10) || 0; |
|
|
var materialRealNum = parseInt($(supplierCard).find('.supplierMaterialNum_'+ supplierIndex ).val(), 10) || 0; |
|
|
var materialRealRmb = parseInt($(supplierCard).find('.supplierMaterialRmb').val(), 10) || 0; |
|
|
var materialRealRmb = parseFloat($(supplierCard).find('.supplierMaterialRmb_'+ supplierIndex).text(), 10) || 0; |
|
|
var materialRealNoRmb = parseInt($(supplierCard).find('.supplierMaterialNoRmb').val(), 10) || 0; |
|
|
var materialRealNoRmb = parseFloat($(supplierCard).find('.supplierMaterialNoRmb_'+ supplierIndex ).text(), 10) || 0; |
|
|
var deliveryTime = $(supplierCard).find('.supplierDeliveryTime').val(); |
|
|
var deliveryTime = $(supplierCard).find('.supplierDeliveryTime_'+ supplierIndex ).val(); |
|
|
var purchasePlanCode = $(supplierCard).find('.supplierPurchasePlanCode').text().trim(); |
|
|
var purchasePlanCode = $(supplierCard).find('.supplierPurchasePlanCode_'+ supplierIndex).text().trim(); |
|
|
var correlationCode = $(supplierCard).find('.supplierCorrelationCode').text().trim(); |
|
|
var correlationCode = $(supplierCard).find('.supplierCorrelationCode_'+ supplierIndex ).text().trim(); |
|
|
var purchaseQuoteCode = $(supplierCard).find('.supplierPurchaseQuoteCode').text().trim(); |
|
|
var purchaseQuoteCode = $(supplierCard).find('.supplierPurchaseQuoteCode_'+ supplierIndex ).text().trim(); |
|
|
|
|
|
var materialRealRmbSum = parseFloat(materialRealRmb) * parseFloat(materialRealNum); |
|
|
|
|
|
var materialRealNoRmbSum = parseFloat(materialRealNoRmb) * parseFloat(materialRealNum); |
|
|
var materialData = { |
|
|
var materialData = { |
|
|
materialCode: materialObj.materialCode, |
|
|
materialCode: materialObj.materialCode, |
|
|
materialName: materialObj.materialName, |
|
|
materialName: materialObj.materialName, |
|
@ -378,11 +407,13 @@ |
|
|
materialNum: materialObj.materialNum, |
|
|
materialNum: materialObj.materialNum, |
|
|
supplierCode: supplierCode, |
|
|
supplierCode: supplierCode, |
|
|
supplierName: supplierName, |
|
|
supplierName: supplierName, |
|
|
|
|
|
materialNoRmb: materialObj.materialNoRmb, |
|
|
|
|
|
materialRmb: materialObj.materialRmb, |
|
|
materialRealNum: materialRealNum, |
|
|
materialRealNum: materialRealNum, |
|
|
materialRealRmb: materialRealRmb, |
|
|
materialRealRmb: materialRealRmb, |
|
|
materialRealNoRmb: materialRealNoRmb, |
|
|
materialRealNoRmb: materialRealNoRmb, |
|
|
materialRealRmbSum: materialRealRmb * materialRealNum, |
|
|
materialRealRmbSum: materialRealRmbSum, |
|
|
materialRealNoRmbSum: materialRealNoRmb * materialRealNum, |
|
|
materialRealNoRmbSum: materialRealNoRmbSum, |
|
|
deliveryTime: deliveryTime, |
|
|
deliveryTime: deliveryTime, |
|
|
purchasePlanCode:purchasePlanCode, |
|
|
purchasePlanCode:purchasePlanCode, |
|
|
correlationCode:correlationCode, |
|
|
correlationCode:correlationCode, |
|
@ -414,32 +445,33 @@ |
|
|
$("#stockNo").select2({ |
|
|
$("#stockNo").select2({ |
|
|
theme: "bootstrap", |
|
|
theme: "bootstrap", |
|
|
allowClear: true, |
|
|
allowClear: true, |
|
|
placeholder: "请选择供应商", |
|
|
placeholder: "请选择仓库", |
|
|
ajax: { |
|
|
ajax: { |
|
|
url: ctx + "stock/stockInfo/list", |
|
|
url: ctx + "stock/stockInfo/getAllWarehouseCode", |
|
|
type: "post", |
|
|
type: "get", |
|
|
dataType: "json", |
|
|
dataType: "json", |
|
|
delay: 250, |
|
|
delay: 250, |
|
|
processResults: function (res, params) { |
|
|
processResults: function (data) { |
|
|
var resultList = res.rows; |
|
|
var resultList = data; |
|
|
var options = []; |
|
|
var options = []; |
|
|
for (let i in resultList) { |
|
|
for (var i = 0; i < resultList.length; i++) { |
|
|
var option = resultList[i]; |
|
|
var result = resultList[i]; |
|
|
option.id = resultList[i]["StockNo"]; |
|
|
options.push({id: result.stockNo, text: result.stockNo}); |
|
|
option.text = resultList[i]["StockNo"]; |
|
|
} |
|
|
option.title = resultList[i]["StockName"]; |
|
|
return { |
|
|
options.push(option); |
|
|
results: options, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return {results: options,} |
|
|
|
|
|
}, |
|
|
}, |
|
|
escapeMarkup: function (markup) {return markup;}, |
|
|
escapeMarkup: function (markup) {return markup;}, |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
} |
|
|
$("#stockNo").on("select2:select", function (e) { |
|
|
$("#stockNo").on("select2:select", function (e) { |
|
|
var data = e.params.data; |
|
|
var data = e.params.data; |
|
|
$("#stockName").val(data.StockName); |
|
|
$("#stockName").val(data.stockName); |
|
|
|
|
|
$("#stockAddress").val(data.stockAddr); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
</script> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
</html> |
|
|
</html> |