|
|
@ -12,47 +12,43 @@ |
|
|
|
<input id="purchasePlanCodes" th:value="${purchasePlanCodes}" name="purchasePlanCode" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12" id="material"> |
|
|
|
<div class="container" id="material"> |
|
|
|
|
|
|
|
</div> |
|
|
|
<div class="container"> |
|
|
|
<div class="form-row"><h4 class="card-header">公司地址:</h4></div> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputWarehouseID" class="col-sm-3 col-form-label">仓库ID:</label> |
|
|
|
<div class="col-sm-6"> |
|
|
|
<input type="text" class="form-control" id="inputWarehouseID" placeholder="请输入仓库ID"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputWarehouseName" class="col-sm-3 form-label">仓库名称:</label> |
|
|
|
<div class="col-sm-6"> |
|
|
|
<input type="text" class="form-control" id="inputWarehouseName" placeholder="请输入仓库名称"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</form> |
|
|
|
<div class="container"> |
|
|
|
<div class="row"><h4 class="card-header">公司地址:</h4></div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputWarehouseID" class="col-sm-2 col-form-label">仓库ID:</label> |
|
|
|
<div class="col-sm-4"> |
|
|
|
<input type="text" class="form-control" id="inputWarehouseID" placeholder="请输入仓库ID"> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputReceiver" class="col-sm-3 form-label">收货人:</label> |
|
|
|
<div class="col-sm-6"> |
|
|
|
<input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputPhone" class="col-sm-3 form-label">收货电话:</label> |
|
|
|
<div class="col-sm-6"> |
|
|
|
<input type="text" class="form-control" id="inputPhone" placeholder="请输入收货电话"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputWarehouseName" class="col-sm-2 control-label">仓库名称:</label> |
|
|
|
<div class="col-sm-4"> |
|
|
|
<input type="text" class="form-control" id="inputWarehouseName" placeholder="请输入仓库名称"> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputAddressDetails" class="col-sm-3 form-label">详细地址:</label> |
|
|
|
<div class="col-sm-6"> |
|
|
|
<textarea class="form-control" id="inputAddressDetails"></textarea> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputReceiver" class="col-sm-2 control-label">收货人:</label> |
|
|
|
<div class="col-sm-4"> |
|
|
|
<input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</form> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputPhone" class="col-sm-2 control-label">收货电话:</label> |
|
|
|
<div class="col-sm-4"> |
|
|
|
<input type="text" class="form-control" id="inputPhone" placeholder="请输入收货电话"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label for="inputAddressDetails" class="col-sm-2 control-label">详细地址:</label> |
|
|
|
<div class="col-sm-4"> |
|
|
|
<textarea class="form-control" id="inputAddressDetails"></textarea> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<th:block th:include="include :: footer" /> |
|
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
|
@ -81,50 +77,51 @@ |
|
|
|
// 初始化表格 |
|
|
|
// 假设purchasePlanChildList已定义并包含了需要处理的数据 |
|
|
|
purchasePlanChildList.forEach(function (material, index) { |
|
|
|
var tableId = 'materialCode_' + index; |
|
|
|
var materialTable = "bootstrap_table-" + tableId; |
|
|
|
tableIdList.push(materialList); |
|
|
|
var tableId = 'materialCode-' + index; |
|
|
|
var materialTable = "bootstrap-table_" + tableId; |
|
|
|
tableIdList.push(tableId); |
|
|
|
// 创建物料信息的容器 |
|
|
|
var $tableWrapper = $('<div id="material-' + tableId + '""></div>'); |
|
|
|
// 添加关联销售订单号信息 |
|
|
|
var $headerDiv = |
|
|
|
$('<div class="row">' + |
|
|
|
'<div class="form-row"><strong>物料 ' + index + ': </strong> ' + '<strong>关联订单号: </strong>' + '<span id="correlateion-' + tableId + ' ">' + material.correlationCodes + '</span></div>' + |
|
|
|
'<div class="form-row">' + |
|
|
|
'<div class="col-sm-12 select-table table-striped">' + |
|
|
|
'<table class="table table-hover table-striped table-materialCode" id="' + materialTable + '">' + '<br />' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' |
|
|
|
); |
|
|
|
'<div class="col-xs-12">' + |
|
|
|
'<div class="row">' + |
|
|
|
'<span><strong>物料 ' + index + ': </strong> ' + '<strong>关联订单号: </strong></span>' + '<span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.correlationCodes + '</span>' + |
|
|
|
'</div>' + |
|
|
|
'<div class="col-sm-12">' + |
|
|
|
'<table class="table-materialCode" id="' + materialTable + '">' + '<br />' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'</div>'); |
|
|
|
$tableWrapper.append($headerDiv); |
|
|
|
// 创建表格的容器 |
|
|
|
// 循环处理每个供应商的信息 |
|
|
|
material.purchaseSupplierList.forEach(function (supplier, supplierIndex) { |
|
|
|
var $supplierInfo = $('<div class="card mt-12"></div>'); // 卡片样式容器,用于包裹每个供应商的信息 |
|
|
|
var $supplierInfo = $('<div class="card mt-12 supplier-card" ></div>'); // 卡片样式容器,用于包裹每个供应商的信息 |
|
|
|
// 构建供应商信息头部 |
|
|
|
var $headerContent = |
|
|
|
$('<div class="card-header">' + |
|
|
|
'<h3 class="card-title">供应商 ' + supplierIndex + ': ' + '</h3>' + |
|
|
|
'<p class="card-text">' + '<span>' + supplier.supplierCode + '</span>' + '-' + '<span>' + supplier.supplierName + '</span>' + '-最新不含税采购价: ' + supplier.materialNoRmb + ' RMB ' + ' 最新含税采购价: ' + supplier.materialRmb + ' RMB </p>' + |
|
|
|
'<div class="card-body">' + |
|
|
|
'<div class="form-group">' + |
|
|
|
'<label class="col-sm-3" for="actualPurchaseNum_' + tableId + '"> 实际采购数: </label>' + |
|
|
|
'<div class ="col-sm-8">' + |
|
|
|
'<input type="text" name="materialNum" class="form-control" id="actualPurchaseNum_' + tableId + '">' + |
|
|
|
'</div>' + |
|
|
|
$('<div class="card-header" id = "supplier-' + tableId + '>' + |
|
|
|
'<h3 class="card-title">' + '供应商 ' + supplierIndex + ': ' + '</h3>' + |
|
|
|
'<p class="card-text ">' + '<span class="supplierCode"">' + supplier.supplierCode + '</span>' + '-' + '<span class="supplierName">' + supplier.supplierName + '</span>' + '-最新不含税采购价: ' + '<span class="supplierMaterialNoRmb">' + supplier.materialNoRmb + '</span>' + ' RMB ' + ' 最新含税采购价: ' + '<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB </p>' + |
|
|
|
'<div class="card-body">' + |
|
|
|
'<div class="form-group">' + |
|
|
|
'<label class="col-sm-3"> 实际采购数: </label>' + |
|
|
|
'<div class ="col-sm-8">' + |
|
|
|
'<input type="text" name="materialNum" class="form-control supplierMaterialNum" id="actualPurchaseNum_' + tableId + '">' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'<div class="form-group">' + |
|
|
|
'<label class="col-sm-3" for="actualPurchaseNum_' + tableId + '">计划交付时间:</label>' + |
|
|
|
'<div class ="col-sm-8">' + |
|
|
|
'<div class="input-group date"> ' + |
|
|
|
'<input type="text" name="deliveryTime" class="form-control" id="deliveryTime_' + tableId + '">' + |
|
|
|
' <span class="input-group-addon"><i class="fa fa-calendar"></i></span>' + |
|
|
|
'</div> ' + |
|
|
|
'</div>' + |
|
|
|
'<label class="col-sm-3">计划交付时间:</label>' + |
|
|
|
'<div class ="col-sm-8">' + |
|
|
|
'<div class="input-group date"> ' + |
|
|
|
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' + |
|
|
|
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' + |
|
|
|
'</div> ' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'</div>'); |
|
|
|
'</div>' + |
|
|
|
'</div>'); |
|
|
|
$supplierInfo.append($headerContent); |
|
|
|
// 构建供应商信息下的输入表单 |
|
|
|
$supplierForm = $('<div class="card-body" id="card_body_' + tableId + '"></div>'); |
|
|
@ -153,22 +150,28 @@ |
|
|
|
}); |
|
|
|
|
|
|
|
function tableSetup(element, tableId) { |
|
|
|
var $totalSection = $('<div class="card mt-8">' + |
|
|
|
'<div class="card-header">' + |
|
|
|
'<h5 class="card-title">实际采购合计</h5>' + |
|
|
|
'</div>' + |
|
|
|
'<div class="card-body">' + |
|
|
|
'<div class="form-row">' + |
|
|
|
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' + |
|
|
|
'</div>' + |
|
|
|
'<div class="form-row">' + |
|
|
|
'<label for="actualPurchaseTotalTax" class="col-sm-3">含税采购总价:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input type="number" name="materialRmbSum" class="form-control" id="materialRmbSum_' + tableId + '" readonly>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
var $totalSection = $( |
|
|
|
'<div class="card mt-8">' + |
|
|
|
'<div class="card-body" class="supplierTotal_' + tableId + '">' + |
|
|
|
'<div class="form-row">' + |
|
|
|
'<label for="actualPurchaseTotal" class="col-sm-3">实际采购数合计:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input type="number" name="materialAmountSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'<div class="form-row">' + |
|
|
|
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'<div class="form-row">' + |
|
|
|
'<label for="actualPurchaseTotalTax" class="col-sm-3">含税采购总价:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input type="number" name="materialRmbSum" class="form-control" id="materialRmbSum_' + tableId + '" readonly>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' + |
|
|
|
'</div>'+ |
|
|
|
'</div>'); |
|
|
|
element.append($totalSection); |
|
|
|
} |
|
|
@ -183,7 +186,7 @@ |
|
|
|
showColumns: false, |
|
|
|
showToggle: false, |
|
|
|
data: data, |
|
|
|
height: 60, |
|
|
|
height: 25, |
|
|
|
columns: [ |
|
|
|
{checkbox: false}, |
|
|
|
{title: '料号', field: 'materialCode'}, |
|
|
@ -219,50 +222,71 @@ |
|
|
|
}); |
|
|
|
function submitHandler() { |
|
|
|
if ($.validate.form()) { |
|
|
|
var allMaterialsData = { |
|
|
|
purchaseOrder: { |
|
|
|
purchaseOrderChildList: [], // 采购订单下的所有物料信息数组 |
|
|
|
}, |
|
|
|
var purchaseOrder = { |
|
|
|
purchaseOrderCode: "", // 这里可能需要生成一个临时的或预设的订单号,实际生产环境应由后端生成 |
|
|
|
supplierNum: 0, |
|
|
|
materialNum: 0, |
|
|
|
materialNoRmbSum: 0, |
|
|
|
materialRmbSum: 0, |
|
|
|
purchaseOrderChildList: [] |
|
|
|
}; |
|
|
|
// 存储所有物料的汇总信息 |
|
|
|
|
|
|
|
// 遍历每个物料容器 |
|
|
|
var materialData = {}; |
|
|
|
$('.table-materialCode').each(function (index, tableElement) { |
|
|
|
for (tableId in tableIdList) { |
|
|
|
var material = materialList[tableId]; |
|
|
|
materialData = { |
|
|
|
materialCode: '', // 物料编码,需要从对应物料信息中获取 |
|
|
|
materialNum: $('#' + 'actualPurchaseNum_' + tableId).val(), // 实际采购数 |
|
|
|
purchaseQuoteChildList: [], // 该物料下的供应商信息数组 |
|
|
|
materialNoRmbSum: $('#' + 'materialNoRmbSum_' + tableId).val(), // 不含税总价 |
|
|
|
materialRmbSum: $('#' + 'materialRmbSum_' + tableId).val(), // 含税总价 |
|
|
|
}; |
|
|
|
var $supplierForm = $('#card_body_' + tableId); |
|
|
|
$supplierForm.find('.card').each(function (index, element) { |
|
|
|
if (index > 0) { // 跳过第一个card,因为它应该是物料头信息 |
|
|
|
var supplier = { |
|
|
|
supplierCode: $(element).find('.card-header span:first').text().trim(), |
|
|
|
supplierName: $(element).find('.card-header span:eq(1)').text().trim(), |
|
|
|
materialNoRmb: parseFloat($(supplierCard).find('.card-header').text().match(/最新不含税采购价: (\d+(\.\d+)?) RMB/)[1]), |
|
|
|
materialRmb: parseFloat($(supplierCard).find('.card-header').text().match(/最新含税采购价: (\d+(\.\d+)?) RMB/)[1]), |
|
|
|
materialRmbSum: $(element).find('input[name="materialRmbSum"]').val(), |
|
|
|
materialNoRmbSum: $(element).find('input[name="materialNoRmbSum"]').val(), |
|
|
|
deliveryTime: $(element).find('input[name="deliveryTime"]').val(), |
|
|
|
materialNum: $(element).find('input[name="materialNum"]').val(), |
|
|
|
}; |
|
|
|
materialData.purchaseOrder.purchaseOrderChildList.purchaseQuoteChildList.push(supplier); |
|
|
|
} |
|
|
|
}) |
|
|
|
$('.table-materialCode').each(function(index, tableElement) { |
|
|
|
console.log(tableElement); |
|
|
|
var tableId = tableIdList[index]; // 从table ID中提取tableId |
|
|
|
var materialData = { |
|
|
|
materialCode: , // 确保能正确获取物料编码 |
|
|
|
materialNum: 0, |
|
|
|
materialNoRmbSum: 0, |
|
|
|
materialRmbSum: 0, |
|
|
|
purchaseQuoteChildList: [] |
|
|
|
}; |
|
|
|
var materialActualNum = $('#' + 'actualPurchaseNum_' + tableId).val(); |
|
|
|
var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val(); |
|
|
|
var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val(); |
|
|
|
materialData.materialNum = parseInt(materialActualNum); |
|
|
|
materialData.materialNoRmbSum = materialNoRmbTotal; |
|
|
|
materialData.materialRmbSum = materialRmbTotal; |
|
|
|
// 遍历该物料下的供应商信息 |
|
|
|
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { |
|
|
|
var supplierQuote = { |
|
|
|
supplierCode: $(supplierCard).find('.supplierCode').text().trim(), |
|
|
|
supplierName: $(supplierCard).find('.supplierName').text().trim(), |
|
|
|
materialNoRmb: parseFloat($(supplierCard).find('.supplierMaterialNoRmb').text().trim()), |
|
|
|
materialRmb: parseFloat($(supplierCard).find('.supplierMaterialRmb').text().trim()), |
|
|
|
materialNum: $(supplierCard).find('.supplierMaterialNum').val().trim(), |
|
|
|
deliveryTime: $(supplierCard).find('.supplierDeliveryTime').val() |
|
|
|
}; |
|
|
|
materialData.purchaseQuoteChildList.push(supplierQuote); |
|
|
|
purchaseOrder.supplierNum += 1; // 累加供应商数量 |
|
|
|
}); |
|
|
|
purchaseOrder.materialNoRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); |
|
|
|
purchaseOrder.materialRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); // 累加含税总价 |
|
|
|
purchaseOrder.purchaseOrderChildList.push(materialData); |
|
|
|
}); |
|
|
|
|
|
|
|
// 发送数据到后端API |
|
|
|
$.ajax({ |
|
|
|
type: "POST", |
|
|
|
url: prefix + "/add", // 这里的prefix应该是之前定义的context路径 |
|
|
|
data: JSON.stringify(purchaseOrder), // 将构造好的对象转换为JSON字符串 |
|
|
|
contentType: "application/json; charset=utf-8", |
|
|
|
dataType: "json", |
|
|
|
success: function (response) { |
|
|
|
if (response.code === 200) { |
|
|
|
alert("采购订单添加成功!"); |
|
|
|
// 可以在这里添加更多成功的处理逻辑,如页面跳转等 |
|
|
|
} else { |
|
|
|
alert("采购订单添加失败:" + response.msg); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function (error) { |
|
|
|
console.error("请求失败:", error); |
|
|
|
alert("提交过程中发生错误,请重试。"); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 根据实际情况获取物料编码等其他必要信息,这里假设可以从某个地方获取 |
|
|
|
// 例如:materialData.materialCode = ...; |
|
|
|
allMaterialsData.purchaseOrder.purchaseOrderChildList.push(materialData); |
|
|
|
} |
|
|
|
// 将收集到的所有物料信息转换为JSON,准备发送 |
|
|
|
var jsonData = JSON.stringify(allMaterialsData); |
|
|
|
// 发送数据到后端API |
|
|
|
$.operate.saveJson(prefix + "/add", jsonData); |
|
|
|
} |
|
|
|
</script> |
|
|
|
</body> |
|
|
|