|
@ -12,47 +12,43 @@ |
|
|
<input id="purchasePlanCodes" th:value="${purchasePlanCodes}" name="purchasePlanCode" class="form-control" type="text"> |
|
|
<input id="purchasePlanCodes" th:value="${purchasePlanCodes}" name="purchasePlanCode" class="form-control" type="text"> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="col-xs-12" id="material"> |
|
|
<div class="container" id="material"> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<div class="container"> |
|
|
</form> |
|
|
<div class="form-row"><h4 class="card-header">公司地址:</h4></div> |
|
|
<div class="container"> |
|
|
<div class="col-xs-12 form-row"> |
|
|
<div class="row"><h4 class="card-header">公司地址:</h4></div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label for="inputWarehouseID" class="col-sm-3 col-form-label">仓库ID:</label> |
|
|
<label for="inputWarehouseID" class="col-sm-2 col-form-label">仓库ID:</label> |
|
|
<div class="col-sm-6"> |
|
|
<div class="col-sm-4"> |
|
|
<input type="text" class="form-control" id="inputWarehouseID" placeholder="请输入仓库ID"> |
|
|
<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> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<div class="col-xs-12 form-row"> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label for="inputReceiver" class="col-sm-3 form-label">收货人:</label> |
|
|
<label for="inputWarehouseName" class="col-sm-2 control-label">仓库名称:</label> |
|
|
<div class="col-sm-6"> |
|
|
<div class="col-sm-4"> |
|
|
<input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人"> |
|
|
<input type="text" class="form-control" id="inputWarehouseName" 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> |
|
|
<div class="form-group"> |
|
|
</div> |
|
|
<label for="inputAddressDetails" class="col-sm-3 form-label">详细地址:</label> |
|
|
<div class="form-group"> |
|
|
<div class="col-sm-6"> |
|
|
<label for="inputReceiver" class="col-sm-2 control-label">收货人:</label> |
|
|
<textarea class="form-control" id="inputAddressDetails"></textarea> |
|
|
<div class="col-sm-4"> |
|
|
</div> |
|
|
<input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人"> |
|
|
</div> |
|
|
</div> |
|
|
</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> |
|
|
</div> |
|
|
<th:block th:include="include :: footer" /> |
|
|
<th:block th:include="include :: footer" /> |
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
@ -81,50 +77,51 @@ |
|
|
// 初始化表格 |
|
|
// 初始化表格 |
|
|
// 假设purchasePlanChildList已定义并包含了需要处理的数据 |
|
|
// 假设purchasePlanChildList已定义并包含了需要处理的数据 |
|
|
purchasePlanChildList.forEach(function (material, index) { |
|
|
purchasePlanChildList.forEach(function (material, index) { |
|
|
var tableId = 'materialCode_' + index; |
|
|
var tableId = 'materialCode-' + index; |
|
|
var materialTable = "bootstrap_table-" + tableId; |
|
|
var materialTable = "bootstrap-table_" + tableId; |
|
|
tableIdList.push(materialList); |
|
|
tableIdList.push(tableId); |
|
|
// 创建物料信息的容器 |
|
|
// 创建物料信息的容器 |
|
|
var $tableWrapper = $('<div id="material-' + tableId + '""></div>'); |
|
|
var $tableWrapper = $('<div id="material-' + tableId + '""></div>'); |
|
|
// 添加关联销售订单号信息 |
|
|
// 添加关联销售订单号信息 |
|
|
var $headerDiv = |
|
|
var $headerDiv = |
|
|
$('<div class="row">' + |
|
|
$('<div class="row">' + |
|
|
'<div class="form-row"><strong>物料 ' + index + ': </strong> ' + '<strong>关联订单号: </strong>' + '<span id="correlateion-' + tableId + ' ">' + material.correlationCodes + '</span></div>' + |
|
|
'<div class="col-xs-12">' + |
|
|
'<div class="form-row">' + |
|
|
'<div class="row">' + |
|
|
'<div class="col-sm-12 select-table table-striped">' + |
|
|
'<span><strong>物料 ' + index + ': </strong> ' + '<strong>关联订单号: </strong></span>' + '<span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.correlationCodes + '</span>' + |
|
|
'<table class="table table-hover table-striped table-materialCode" id="' + materialTable + '">' + '<br />' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'<div class="col-sm-12">' + |
|
|
'</div>' + |
|
|
'<table class="table-materialCode" id="' + materialTable + '">' + '<br />' + |
|
|
'</div>' |
|
|
'</div>' + |
|
|
); |
|
|
'</div>' + |
|
|
|
|
|
'</div>'); |
|
|
$tableWrapper.append($headerDiv); |
|
|
$tableWrapper.append($headerDiv); |
|
|
// 创建表格的容器 |
|
|
// 创建表格的容器 |
|
|
// 循环处理每个供应商的信息 |
|
|
// 循环处理每个供应商的信息 |
|
|
material.purchaseSupplierList.forEach(function (supplier, supplierIndex) { |
|
|
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 = |
|
|
var $headerContent = |
|
|
$('<div class="card-header">' + |
|
|
$('<div class="card-header" id = "supplier-' + tableId + '>' + |
|
|
'<h3 class="card-title">供应商 ' + supplierIndex + ': ' + '</h3>' + |
|
|
'<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>' + |
|
|
'<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="card-body">' + |
|
|
'<div class="form-group">' + |
|
|
'<div class="form-group">' + |
|
|
'<label class="col-sm-3" for="actualPurchaseNum_' + tableId + '"> 实际采购数: </label>' + |
|
|
'<label class="col-sm-3"> 实际采购数: </label>' + |
|
|
'<div class ="col-sm-8">' + |
|
|
'<div class ="col-sm-8">' + |
|
|
'<input type="text" name="materialNum" class="form-control" id="actualPurchaseNum_' + tableId + '">' + |
|
|
'<input type="text" name="materialNum" class="form-control supplierMaterialNum" id="actualPurchaseNum_' + tableId + '">' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'<div class="form-group">' + |
|
|
'<div class="form-group">' + |
|
|
'<label class="col-sm-3" for="actualPurchaseNum_' + tableId + '">计划交付时间:</label>' + |
|
|
'<label class="col-sm-3">计划交付时间:</label>' + |
|
|
'<div class ="col-sm-8">' + |
|
|
'<div class ="col-sm-8">' + |
|
|
'<div class="input-group date"> ' + |
|
|
'<div class="input-group date"> ' + |
|
|
'<input type="text" name="deliveryTime" class="form-control" id="deliveryTime_' + tableId + '">' + |
|
|
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" 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>'); |
|
|
'</div>'); |
|
|
$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>'); |
|
@ -153,22 +150,28 @@ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function tableSetup(element, tableId) { |
|
|
function tableSetup(element, tableId) { |
|
|
var $totalSection = $('<div class="card mt-8">' + |
|
|
var $totalSection = $( |
|
|
'<div class="card-header">' + |
|
|
'<div class="card mt-8">' + |
|
|
'<h5 class="card-title">实际采购合计</h5>' + |
|
|
'<div class="card-body" class="supplierTotal_' + tableId + '">' + |
|
|
'</div>' + |
|
|
'<div class="form-row">' + |
|
|
'<div class="card-body">' + |
|
|
'<label for="actualPurchaseTotal" class="col-sm-3">实际采购数合计:</label>' + |
|
|
'<div class="form-row">' + |
|
|
'<div class="col-sm-8">' + |
|
|
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' + |
|
|
'<input type="number" name="materialAmountSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' + |
|
|
'<div class="col-sm-8">' + |
|
|
'</div>' + |
|
|
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'<div class="form-row">' + |
|
|
'<div class="form-row">' + |
|
|
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' + |
|
|
'<label for="actualPurchaseTotalTax" class="col-sm-3">含税采购总价:</label>' + |
|
|
'<div class="col-sm-8">' + |
|
|
'<div class="col-sm-8">' + |
|
|
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' + |
|
|
'<input type="number" name="materialRmbSum" class="form-control" id="materialRmbSum_' + tableId + '" readonly>' + |
|
|
'</div>' + |
|
|
'</div>' + |
|
|
'</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>'); |
|
|
'</div>'); |
|
|
element.append($totalSection); |
|
|
element.append($totalSection); |
|
|
} |
|
|
} |
|
@ -183,7 +186,7 @@ |
|
|
showColumns: false, |
|
|
showColumns: false, |
|
|
showToggle: false, |
|
|
showToggle: false, |
|
|
data: data, |
|
|
data: data, |
|
|
height: 60, |
|
|
height: 25, |
|
|
columns: [ |
|
|
columns: [ |
|
|
{checkbox: false}, |
|
|
{checkbox: false}, |
|
|
{title: '料号', field: 'materialCode'}, |
|
|
{title: '料号', field: 'materialCode'}, |
|
@ -219,50 +222,71 @@ |
|
|
}); |
|
|
}); |
|
|
function submitHandler() { |
|
|
function submitHandler() { |
|
|
if ($.validate.form()) { |
|
|
if ($.validate.form()) { |
|
|
var allMaterialsData = { |
|
|
var purchaseOrder = { |
|
|
purchaseOrder: { |
|
|
purchaseOrderCode: "", // 这里可能需要生成一个临时的或预设的订单号,实际生产环境应由后端生成 |
|
|
purchaseOrderChildList: [], // 采购订单下的所有物料信息数组 |
|
|
supplierNum: 0, |
|
|
}, |
|
|
materialNum: 0, |
|
|
|
|
|
materialNoRmbSum: 0, |
|
|
|
|
|
materialRmbSum: 0, |
|
|
|
|
|
purchaseOrderChildList: [] |
|
|
}; |
|
|
}; |
|
|
// 存储所有物料的汇总信息 |
|
|
|
|
|
// 遍历每个物料容器 |
|
|
// 遍历每个物料容器 |
|
|
var materialData = {}; |
|
|
$('.table-materialCode').each(function(index, tableElement) { |
|
|
$('.table-materialCode').each(function (index, tableElement) { |
|
|
console.log(tableElement); |
|
|
for (tableId in tableIdList) { |
|
|
var tableId = tableIdList[index]; // 从table ID中提取tableId |
|
|
var material = materialList[tableId]; |
|
|
var materialData = { |
|
|
materialData = { |
|
|
materialCode: , // 确保能正确获取物料编码 |
|
|
materialCode: '', // 物料编码,需要从对应物料信息中获取 |
|
|
materialNum: 0, |
|
|
materialNum: $('#' + 'actualPurchaseNum_' + tableId).val(), // 实际采购数 |
|
|
materialNoRmbSum: 0, |
|
|
purchaseQuoteChildList: [], // 该物料下的供应商信息数组 |
|
|
materialRmbSum: 0, |
|
|
materialNoRmbSum: $('#' + 'materialNoRmbSum_' + tableId).val(), // 不含税总价 |
|
|
purchaseQuoteChildList: [] |
|
|
materialRmbSum: $('#' + 'materialRmbSum_' + tableId).val(), // 含税总价 |
|
|
}; |
|
|
}; |
|
|
var materialActualNum = $('#' + 'actualPurchaseNum_' + tableId).val(); |
|
|
var $supplierForm = $('#card_body_' + tableId); |
|
|
var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val(); |
|
|
$supplierForm.find('.card').each(function (index, element) { |
|
|
var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val(); |
|
|
if (index > 0) { // 跳过第一个card,因为它应该是物料头信息 |
|
|
materialData.materialNum = parseInt(materialActualNum); |
|
|
var supplier = { |
|
|
materialData.materialNoRmbSum = materialNoRmbTotal; |
|
|
supplierCode: $(element).find('.card-header span:first').text().trim(), |
|
|
materialData.materialRmbSum = materialRmbTotal; |
|
|
supplierName: $(element).find('.card-header span:eq(1)').text().trim(), |
|
|
// 遍历该物料下的供应商信息 |
|
|
materialNoRmb: parseFloat($(supplierCard).find('.card-header').text().match(/最新不含税采购价: (\d+(\.\d+)?) RMB/)[1]), |
|
|
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { |
|
|
materialRmb: parseFloat($(supplierCard).find('.card-header').text().match(/最新含税采购价: (\d+(\.\d+)?) RMB/)[1]), |
|
|
var supplierQuote = { |
|
|
materialRmbSum: $(element).find('input[name="materialRmbSum"]').val(), |
|
|
supplierCode: $(supplierCard).find('.supplierCode').text().trim(), |
|
|
materialNoRmbSum: $(element).find('input[name="materialNoRmbSum"]').val(), |
|
|
supplierName: $(supplierCard).find('.supplierName').text().trim(), |
|
|
deliveryTime: $(element).find('input[name="deliveryTime"]').val(), |
|
|
materialNoRmb: parseFloat($(supplierCard).find('.supplierMaterialNoRmb').text().trim()), |
|
|
materialNum: $(element).find('input[name="materialNum"]').val(), |
|
|
materialRmb: parseFloat($(supplierCard).find('.supplierMaterialRmb').text().trim()), |
|
|
}; |
|
|
materialNum: $(supplierCard).find('.supplierMaterialNum').val().trim(), |
|
|
materialData.purchaseOrder.purchaseOrderChildList.purchaseQuoteChildList.push(supplier); |
|
|
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> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|