@ -7,9 +7,9 @@
< th:block th:include = "include :: bootstrap-editable-css" / >
< / head >
< style >
.col-sm-12.material-table{
height: 75px;
}
/* .col-sm-12.material-table{*/
/* height: 200px;*/
/* }*/
.hr-line-dashed {
border-top: 1px dashed #ddd;
margin-top: 20px; /* 调整间距 */
@ -73,16 +73,19 @@
< th:block th:include = "include :: bootstrap-table-editable-js" / >
< script th:inline = "javascript" >
var prefix = ctx + "system/outsource_requisition";
var planPrefix = ctx + "system/outsource_plan";
$("#form-order-outsourceRequisition-add").validate({focusCleanup: true});
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var levelDatas = [[${@dict.getType('bomLevel')}]];
var outsourcePlanDetailList = [];
// var chargeUnitDatas = [[${@dict.getType("charge_unit")}]]
// var formId = "form-plan-outsourceOrder-add";
var outsourcePlanCode = '';
var outsoutceOrderNo = '';
var materialList = [];
var tableIdList = [];
var supplier List = [];
var childTable List = [];
var $processContent;
var $supplierheaderContent;
var materials;
@ -92,11 +95,8 @@
var originMaterial = []
$(function() {
// console.log(outsourceOrderList);
originMaterial = outsourceOrderList[0].materials;
outsoutceOrderNo = outsourceOrderList[0].outsourceOrderNo;
$("input[name='outsourcePlanCode']").val(outsourceOrderList[0].outsourcePlanCode);
// 根据料号去重
materials = mergeRecords(originMaterial);
@ -105,6 +105,8 @@
materials.forEach(function (material, index) {
var tableId = 'materialNo-' + (index+1);
var materialTable = "bootstrap-table_" + tableId;
var childTableId = "material_child_" + tableId;
childTableList.push(childTableId);
tableIdList.push(tableId);
// 创建物料信息的容器
var $tableWrapper = $('< div id = "material-' + tableId + '" > < / div > ');
@ -140,6 +142,7 @@
unit: material.unit,
brand: material.brand,
processMethod: material.processMethod,
planDetailId: material.planDetailId,
correlationCodes: material.correlationCodes,
actualOutsourceAmount: material.orderDetails[0].actualOutsourceAmount,
alreadyRequisitionAmount: 0,
@ -147,10 +150,10 @@
};
var materialData = [materialObj]; // Bootstrap Table需要一个数组作为数据源
materialList.push(material);
tables(materialTable, materialData);
tables(materialTable,childTableId, materialData);
var $MaterialNumDiv =
$('< div class = "row" style = "margin-top: 20 px;margin-left: 10px;" > ' +
$('< div class = "row" style = "margin-top: 5 px;margin-left: 10px;" > ' +
'< div class = "col-xs-12" > ' +
'< h3 > ' +
'< span > < strong > 供应商< / strong > < / span > ' +
@ -244,7 +247,7 @@
});
});
function tables(tableId, data) {
function tables(tableId,childTableId, data) {
$('#' + tableId).bootstrapTable({
showExport: false,
showFooter: false,
@ -252,8 +255,15 @@
showRefresh: false,
showColumns: false,
showToggle: false,
height: 200,
data: data,
detailView: true,
onExpandRow : function(index,row,$detail){
$detail.html('< table class = "table-container" id = "'+childTableId+'" > < / table > ').find('table');
initChildTable(index,row,$detail,childTableId);
},
columns: [
{title: '计划详情id', field: 'planDetailId',visible:false,},
{title: '料号', field: 'materialNo'},
{title: '图片', field: 'materialPhotourl', formatter: function (value, row, index) {
return $.table.imageView(value);
@ -273,20 +283,86 @@
},
{title: '计划委外数', field: 'plannedOutsourceAmount'},
{title: '实际委外数', field: 'actualOutsourceAmount'},
{title: '已委外领料数', field: 'alreadyRequisitionAmount'},
// {title: '已委外领料数', field: 'alreadyRequisitionAmount'},
// {
// title: '< span class = "is-required" > 本次领料数< / span > ',
// field: 'nowRequisitionAmount',
// formatter: function(value, row, index) {
// var html = $.common.sprintf("< input class = 'form-control' type = 'number' name = 'nowRequisitionAmount' id = 'nowRequisitionAmount_"+tableId+"' > ", index, value);
// return html;
// }
// },
],
});
$("#"+tableId).bootstrapTable('expandRow', 0);
};
initChildTable = function(index, row, $detail,childTableId) {
var parentRow = row;
$("#"+childTableId).bootstrapTable({
url: planPrefix + "/getRequisitionMaterial",
method: 'post',
id: childTableId,
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
parentId: parentRow.planDetailId,
outsoutceOrderNo: outsoutceOrderNo,
},
columns: [
{
title: '阶层',
field: 'level',
formatter: function(value, row, index) {
return $.table.selectDictLabel(levelDatas, value);
}
},
{title: '委外计划详情id', field: 'outsourcePlanDetailId',visible:false,},
{title: '料号', field: 'materialNo'},
{title: '图片', field: 'materialPhotourl', formatter: function (value, row, index) {
return $.table.imageView(value);
}
},
{title: '物料类型',field: 'materialType',
formatter: function(value, row, index) {return $.table.selectCategoryLabel(materialTypeDatas, value);}
},
{title: '物料名称', field: 'materialName'},
{title: '物料描述', field: 'description'},
{title: '品牌', field: 'brand'},
{title: '单位', field: 'unit', align: 'center', },
{title: '加工方式', field: 'processMethod', align: 'center',
formatter: function (value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{title: '计划委外数', field: 'plannedOutsourceAmount',
formatter: function (value, row, index) {
if(value === null || value === ''||value === undefined){
value = parentRow.plannedOutsourceAmount;
}
return value;
}
},
{title: '实际委外数', field: 'actualOutsourceAmount',
formatter: function (value, row, index) {
if(value === null || value === ''||value === undefined){
value = parentRow.actualOutsourceAmount;
}
return value;
}
},
{title: '已委外领料数', field: 'pickedNum'},
{
title: '< span class = "is-required" > 本次领料数< / span > ',
field: 'nowRequisitionAmount',
field: 'pickingNum ',
formatter: function(value, row, index) {
var html = $.common.sprintf("< input class = 'form-control' type = 'number' name = 'nowRequisitionAmount' id = 'nowRequisitionAmount_"+tableId+"' > ", index, value);
var html = $.common.sprintf("< input class = 'form-control' type = 'number' oninput = 'calculateTotal()' name = 'nowRequisitionAmount' id = 'pickNum_"+ childTableId +"_"+ index +"' > ", index, value);
return html;
}
},
],
});
$('input[name="nowRequisitionAmount"]').on('input', function() {
calculateTotal();
});
};
// 计算总领料数
function calculateTotal() {
@ -297,7 +373,6 @@
var value = parseFloat($(this).val()) || 0; // 将输入框的值转换为数字,默认为0
total += value;
});
// console.log("总领料数:" + total);
$("#outsourceMaterialAmount").val(total);
};
// 函数用于合并重复的material的记录
@ -323,6 +398,7 @@
unit: current.unit,
brand: current.brand,
processMethod: current.processMethod,
planDetailId: current.planDetailId,
// correlationCodes: current.correlationCodes,
plannedOutsourceAmount: current.plannedOutsourceAmount,
orderDetails: [
@ -347,60 +423,87 @@
$('.table-materialNo').each(function(index, tableElement) {
var tableId = tableIdList[index];
let materialObj = materialList[index];
var childTableId = childTableList[index];
var childDatas = $("#"+childTableId).bootstrapTable("getData");
if(childDatas.length < = 0) return;
if (typeof materialObj === 'undefined') return;
var rows = $("#" + "bootstrap-table_" + tableId).bootstrapTable('getData').length;
if(rows != 0) {
var data = $("#" + "bootstrap-table_" + tableId).bootstrapTable('getData')[0];
var amountId = "nowRequisitionAmount_bootstrap-table_" + tableId;
if($('[id^="' + amountId + '"]').val() === ""){
return;
}else{
hasValue = true;
materialAmount++;
let value = Number($('[id^="' + amountId + '"]').val());
if (!isNaN(value)) {
var hasReValue = Number(data.alreadyRequisitionAmount);
if(hasReValue + value>data.actualOutsourceAmount){
hasError = true;
}
requisitionSum += value;
}
var correlationCodes = $("#correlationCodes-" + tableId).text().trim();
$('#' + 'material-' + tableId).find('.process_card').each(function(processIndex, processCard) {
// console.log("1111");
var processNo = $(processCard).find('.processNo').text().trim();
var processName = $(processCard).find('.processName').text().trim();
var chargeUnitInfo = $(processCard).find('.chargeUnitInfo').text().trim();
var singleMaterialInfo = $(processCard).find('.singleMaterialInfo').text().trim();
var supplierCode = $(processCard).find('.supplierCode').text().trim();
var supplierName = $(processCard).find('.supplierName').text().trim();
var processInfo = processNo + '-' + processName;
var supplierInfo = supplierCode + '--' + supplierName;
var deliveryTimeInfo = $(processCard).find("input[name='deliveryTime']").val();
var correlationCodes = $("#correlationCodes-" + tableId).text().trim();
$('#' + 'material-' + tableId).find('.process_card').each(function(processIndex, processCard) {
var processNo = $(processCard).find('.processNo').text().trim();
var processName = $(processCard).find('.processName').text().trim();
var chargeUnitInfo = $(processCard).find('.chargeUnitInfo').text().trim();
var singleMaterialInfo = $(processCard).find('.singleMaterialInfo').text().trim();
var supplierCode = $(processCard).find('.supplierCode').text().trim();
var supplierName = $(processCard).find('.supplierName').text().trim();
var processInfo = processNo + '-' + processName;
var supplierInfo = supplierCode + '--' + supplierName;
var deliveryTimeInfo = $(processCard).find("input[name='deliveryTime']").val();
var requisitionDetail = {
materialNo: data.materialNo,
planDetailId: data.planDetailId,
materialPhotourl: data.materialPhotourl,
materialName: data.materialName,
description: data.description,
brand: data.brand,
unit: data.unit,
processMethod: data.processMethod,
materialType: data.materialType,
level: 0,
plannedOutsourceAmount: data.plannedOutsourceAmount,
actualOutsourceAmount: data.actualOutsourceAmount,
outsourceOrderNo: outsourceRequisition.outsourceOrderNo,
outsourceProcessInfo: processInfo,
chargeUnitInfo: chargeUnitInfo,
singleMaterialInfo: singleMaterialInfo,
supplierInfo: supplierInfo,
deliveryTimeInfo: deliveryTimeInfo,
correlationCodes: correlationCodes,
};
outsourceRequisition.outsourceRequisitionDetailList.push(requisitionDetail);
});
childDatas.forEach(function (material,index){
var inputId = "pickNum_" + childTableId + "_" + index;
if($("#"+inputId).val() === ""||$("#"+inputId).val() === "0"){
return;
}else{
hasValue = true;
materialAmount++;
let value = Number($("#"+inputId).val());
if (!isNaN(value)) {
var hasReValue = Number(material.alreadyRequisitionAmount);
if(hasReValue + value>material.actualOutsourceAmount){
hasError = true;
}
requisitionSum += value;
};
var requisitionDetail = {
materialNo: data.materialNo,
materialPhotourl: data.materialPhotourl,
materialName: data.materialName,
description: data.description,
brand: data.brand,
unit: data.unit,
processMethod: data.processMethod,
materialType: data.materialType,
materialNo: material.materialNo,
planDetailId: material.outsourcePlanDetailId,
materialPhotourl: material.materialPhotourl,
materialName: material.materialName,
description: material.description,
brand: material.brand,
unit: material.unit,
level: 1,
processMethod: material.processMethod,
materialType: material.materialType,
plannedOutsourceAmount: data.plannedOutsourceAmount,
actualOutsourceAmount: data.actualOutsourceAmount,
outsourceOrderNo: outsourceRequisition.outsourceOrderNo,
takenMaterial:data.alreadyRequisitionAmount,
takenMaterial:material.pickedNum ,
takingMaterial: value,
outsourceProcessInfo: processInfo,
chargeUnitInfo: chargeUnitInfo,
singleMaterialInfo: singleMaterialInfo,
supplierInfo: supplierInfo,
deliveryTimeInfo: deliveryTimeInfo,
correlationCodes: correlationCodes,
};
outsourceRequisition.outsourceRequisitionDetailList.push(requisitionDetail);
});
}
}
});
}
outsourceRequisition.materialAmount = materialAmount;
});