@ -60,12 +60,15 @@
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var levelDatas = [[${@dict.getType('bomLevel')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var makeNo = [[${sysMakeOrder.makeNo}]];
var makeOrderBom = {};
// var subTableFormArray = [];
$(function(){
sessionStorage.clear();
var options = {
url: ctx + "system/orderChild/l ist",
url: ctx + "system/makeorderbom/selectedL ist",
id: 'bootstrap-sub-table-1',
showSearch: false,
showRefresh: false,
@ -102,7 +105,7 @@
visible: false
},
{
field: 'materialCode ',
field: 'materialNo ',
align: 'center',
title: '料号'
},
@ -132,6 +135,11 @@
align: 'center',
title: '品牌'
},
{
field: 'materialModel',
align: 'center',
title: '型号'
},
{
field: 'describe',
align: 'center',
@ -140,7 +148,7 @@
{
field: 'processMethod',
align: 'center',
title: '半成品类型 ',
title: '加工方式 ',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
@ -151,7 +159,7 @@
title: '客户期望交付时间'
},
{
field: 'material Num',
field: 'order Num',
align: 'center',
title: '订单数量'
},
@ -166,7 +174,16 @@
align: 'center',
title: '审核状态',
visible: false
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('< a class = "btn btn-success btn-xs " href = "javascript:void(0)" onclick = "editMakeOrderBom(\'' + index + '\',\'' +row.materialNo + '\')" > 编辑生产bom< / a > ');
return actions.join('');
}
},
]
};
$.table.init(options);
@ -182,15 +199,13 @@
$detail.html('< table id = "'+childTableId+'" > < / table > < table id = "'+childFormTableId+'" > < / table > ');
// BOM展示
$('#'+childTableId).bootstrapTable({
url: ctx + "erp/bom/otherOrderAllLevelL ist",
url: ctx + "system/makeorderbom/l ist",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
parentId: parentRow.bomId,
useStatus:parentRow.useStatus,
auditStatus:parentRow.auditStatus,
// materialNo: parentRow.materialCode
salesOrderMaterialNo: parentRow.materialNo,
makeNo: makeNo,
},
columns: [{
field: 'id',
@ -200,12 +215,14 @@
{
field: 'level',
title: '阶层',
align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(levelDatas, value);
}
},
{
field: 'bomNo',
align: 'center',
title: 'BOM号',
formatter:function (value,row,index){
if (value == null || value == ''){
@ -217,6 +234,7 @@
},
{
field: 'materialNo',
align: 'center',
title: '料号',
formatter: function (value,row,index){
if (value == null || value == ''){
@ -228,6 +246,7 @@
},
{
field: 'photoUrl',
align: 'center',
title: '图片',
formatter: function(value, row, index) {
return $.table.imageView(value);
@ -235,6 +254,7 @@
},
{
field: 'materialName',
align: 'center',
title: '物料名称',
formatter: function (value,row,index){
if (value == null || value == ''){
@ -246,13 +266,20 @@
},
{
field: 'materialType',
align: 'center',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
field: 'materialModel',
align: 'center',
title: '型号'
},
{
field: 'describe',
align: 'center',
title: '描述',
formatter: function (value,row,index){
if (value == null || value == ''){
@ -264,6 +291,7 @@
},
{
field: 'brand',
align: 'center',
title: '品牌',
formatter: function (value,row,index){
if (value == null || value == ''){
@ -275,6 +303,7 @@
},
{
field: 'unit',
align: 'center',
title: '单位',
formatter: function (value,row,index){
if (value == null || value == ''){
@ -287,13 +316,15 @@
{
field: 'processMethod',
title: '半成品类型',
align: 'center',
title: '加工方式',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
field: 'useNum',
align: 'center',
title: '用量',
formatter: function (value,row,index){
if (value == null || value == ''){
@ -305,6 +336,7 @@
},
{
field: 'lossRate',
align: 'center',
title: '损耗率',
// formatter: function (value,row,index){
// if (value == null || value == ''){
@ -316,9 +348,10 @@
},
{
field: 'materialNum',
align: 'center',
title: '订单用量',
formatter: function (value,row,index){
return parentRow.material Num * row.useNum;
return parentRow.order Num * row.useNum;
}
},
{
@ -333,170 +366,171 @@
}],
// 当所有数据被加载时触发
onLoadSuccess: function(data) {
},
});
// 预审部门展示
$('#'+childFormTableId).bootstrapTable({
url: ctx + "system/makeorderdept/list",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
makeNo: $("#makeNo").val(),
materialNo: parentRow.materialCode
},
columns: [
{
field : 'id',
title : '生产订单部门ID',
formatter: function (value, row, index) {
var curIndex = parentRowIndex*6+index;
return '< input disabled class = "form-control" data-id = "id_'+curIndex+'" name = "orderDepts['+curIndex+'].id" value = "'+value+'" > < / input > ';
var key = "all_level_" + childTableId;
var rowData = sessionStorage.getItem(key);
if(rowData){
var tableData = JSON.parse(rowData);
$("#"+childTableId).bootstrapTable('load',tableData);
}
},
{
field : 'makeNo',
title : '生产订单号',
visible: false,
formatter: function (value, row, index) {
var curIndex = parentRowIndex*6+index;
return '< input disabled class = "form-control" data-id = "id_'+curIndex+'" name = "orderDepts['+curIndex+'].makeNo" value = "'+value+'" > ';
}
},
{
field : 'materialNo',
title : '料号',
visible: false,
formatter: function (value, row, index) {
var curIndex = parentRowIndex*6+index;
return '< input disabled class = "form-control" data-id = "id_'+curIndex+'" name = "orderDepts['+curIndex+'].materialNo" value = "'+value+'" > ';
}
},
{
field : 'deptName',
title : '部门名称',
visible: false
},
{
field : 'planFinishDays',
title : '计划完成天数',
visible: false
},
{
field : 'actualFinishStartTime',
title : '实际完成开始时间',
visible: false
},
{
field : 'actualFinishEndTime',
title : '实际完成结束时间',
visible: false
},
{
field : 'deptNumber',
title : '部门',
formatter: function (value, row, index) {
/*if(subTableFormArray[parentRowIndex]){
value = subTableFormArray[parentRowIndex].deptName?subTableFormArray[parentRowIndex].deptName:value;
}*/
var curIndex = parentRowIndex*6+index;
return '< input disabled class = "form-control" data-id = "deptName_'+curIndex+'" name = "orderDepts['+curIndex+'].deptName" value = "'+row.deptName+'" > < input disabled class = "form-control hidden" data-id = "deptNumber_'+curIndex+'" name = "orderDepts['+curIndex+'].deptNumber" value = "'+value+'" > ';
}
},
{
field: 'planFinishDate',
title: '计划完成时间',
formatter: function(value, row, index) {
var curIndex = parentRowIndex*6+index;
var endDateName = 'planFinishEndDate_'+parentRowIndex;
var startDateName = 'planFinishStartDate_'+parentRowIndex;
var html;
// 业务部门
if(row.deptNumber=='GMD'){
html = '< div class = "input-daterange input-group" > ' +
'< input disabled type = "text" class = "form-control" data-id = "'+startDateName+'" name = "orderDepts['+curIndex+'].planFinishStartDate" placeholder = "开始时间" value = "'+row.planFinishStartDate+'" / > \n' +
'< span class = "input-group-addon" > -< / span > \n' +
'< input disabled type = "text" class = "form-control" data-id = "'+endDateName+'" name = "orderDepts['+curIndex+'].planFinishEndDate" placeholder = "结束时间" value = "'+row.planFinishEndDate+'" / > < / div > '
}else{
html = '< input disabled class = "form-control" data-id = "planFinishDays_'+curIndex+'" name = "orderDepts['+curIndex+'].planFinishDays" value = "'+row.planFinishDays+'" > ';
}
return html;
}
},
{
field : 'deptLeaderConfirmStatus',
title : '部门主管确认',
formatter: function(value, row, index) {
var curIndex = parentRowIndex*6+index;
var html = '< select disabled class = "form-control" name = "orderDepts['+curIndex+'].deptLeaderConfirmStatus" > ' +
'< option value = "0" ' + ( value = ='0'?'selected':"")+' > 待确认< / option > ' +
'< option value = "1" ' + ( value = ='1'?'selected':"")+' > 已确认< / option > ' +
'< / select > ';
return html;
}
},
{
field: 'actualFinishTime',
title: '实际完成时间',
formatter: function(value, row, index) {
if (row.actualFinishStartTime == null || row.actualFinishStartTime == ''){
return '';
}else if(row.actualFinishStartTime){
return row.actualFinishStartTime
}else if(row.actualFinishStartTime & & row.actualFinishEndTime){
return row.actualFinishStartTime + '-' + row.actualFinishEndTime
}
}
}
],
// 当所有数据被加载时触发
onLoadSuccess: function(data) {
for (let i = 0; i < data.rows.length ; i + + ) {
var curIndex = parentRowIndex*6+i;
var startDateIndex = 'planFinishStartDate_'+i;
var endDateIndex = 'planFinishEndDate_'+i;
$('[data-id="'+startDateIndex+'"]').datetimepicker({
format: 'yyyy-mm-dd',
minView: "month",
todayBtn: true,
autoclose: true,
}).on('changeDate', function(event) {
event.preventDefault();
event.stopPropagation();
var startTime = event.date;
$('[data-id="'+endDateIndex+'"]').datetimepicker('setStartDate', startTime);
});
$('[data-id="'+endDateIndex+'"]').datetimepicker({
format: 'yyyy-mm-dd',
minView: "month",
todayBtn: true,
autoclose: true,
}).on('changeDate', function(event) {
event.preventDefault();
event.stopPropagation();
var endTime = event.date;
$('[data-id="'+startDateIndex+'"]').datetimepicker('setEndDate', endTime);
});
}
},
});
// 预审部门展示
// $('#'+childFormTableId).bootstrapTable({
// url: ctx + "system/makeorderdept/list",
// method: 'post',
// sidePagination: "server",
// contentType: "application/x-www-form-urlencoded",
// queryParams : {
// makeNo: $("#makeNo").val(),
// materialNo: parentRow.materialCode
// },
// columns: [
// {
// field : 'id',
// title : '生产订单部门ID',
// formatter: function (value, row, index) {
// var curIndex = parentRowIndex*6+index;
// return '< input disabled class = "form-control" data-id = "id_'+curIndex+'" name = "orderDepts['+curIndex+'].id" value = "'+value+'" > < / input > ';
// }
// },
// {
// field : 'makeNo',
// title : '生产订单号',
// visible: false,
// formatter: function (value, row, index) {
// var curIndex = parentRowIndex*6+index;
// return '< input disabled class = "form-control" data-id = "id_'+curIndex+'" name = "orderDepts['+curIndex+'].makeNo" value = "'+value+'" > ';
// }
// },
// {
// field : 'materialNo',
// title : '料号',
// visible: false,
// formatter: function (value, row, index) {
// var curIndex = parentRowIndex*6+index;
// return '< input disabled class = "form-control" data-id = "id_'+curIndex+'" name = "orderDepts['+curIndex+'].materialNo" value = "'+value+'" > ';
// }
// },
// {
// field : 'deptName',
// title : '部门名称',
// visible: false
// },
// {
// field : 'planFinishDays',
// title : '计划完成天数',
// visible: false
// },
// {
// field : 'actualFinishStartTime',
// title : '实际完成开始时间',
// visible: false
// },
// {
// field : 'actualFinishEndTime',
// title : '实际完成结束时间',
// visible: false
// },
// {
// field : 'deptNumber',
// title : '部门',
// formatter: function (value, row, index) {
// /*if(subTableFormArray[parentRowIndex]){
// value = subTableFormArray[parentRowIndex].deptName?subTableFormArray[parentRowIndex].deptName:value;
// }*/
// var curIndex = parentRowIndex*6+index;
// return '< input disabled class = "form-control" data-id = "deptName_'+curIndex+'" name = "orderDepts['+curIndex+'].deptName" value = "'+row.deptName+'" > < input disabled class = "form-control hidden" data-id = "deptNumber_'+curIndex+'" name = "orderDepts['+curIndex+'].deptNumber" value = "'+value+'" > ';
// }
// },
// {
// field: 'planFinishDate',
// title: '计划完成时间',
// formatter: function(value, row, index) {
// var curIndex = parentRowIndex*6+index;
// var endDateName = 'planFinishEndDate_'+parentRowIndex;
// var startDateName = 'planFinishStartDate_'+parentRowIndex;
// var html;
// // 业务部门
// if(row.deptNumber=='GMD'){
// html = '< div class = "input-daterange input-group" > ' +
// '< input disabled type = "text" class = "form-control" data-id = "'+startDateName+'" name = "orderDepts['+curIndex+'].planFinishStartDate" placeholder = "开始时间" value = "'+row.planFinishStartDate+'" / > \n' +
// '< span class = "input-group-addon" > -< / span > \n' +
// '< input disabled type = "text" class = "form-control" data-id = "'+endDateName+'" name = "orderDepts['+curIndex+'].planFinishEndDate" placeholder = "结束时间" value = "'+row.planFinishEndDate+'" / > < / div > '
// }else{
// html = '< input disabled class = "form-control" data-id = "planFinishDays_'+curIndex+'" name = "orderDepts['+curIndex+'].planFinishDays" value = "'+row.planFinishDays+'" > ';
// }
// return html;
// }
// },
// {
// field : 'deptLeaderConfirmStatus',
// title : '部门主管确认',
// formatter: function(value, row, index) {
// var curIndex = parentRowIndex*6+index;
// var html = '< select disabled class = "form-control" name = "orderDepts['+curIndex+'].deptLeaderConfirmStatus" > ' +
// '< option value = "0" ' + ( value = ='0'?'selected':"")+' > 待确认< / option > ' +
// '< option value = "1" ' + ( value = ='1'?'selected':"")+' > 已确认< / option > ' +
// '< / select > ';
// return html;
// }
// },
// {
// field: 'actualFinishTime',
// title: '实际完成时间',
// formatter: function(value, row, index) {
// if (row.actualFinishStartTime == null || row.actualFinishStartTime == ''){
// return '';
// }else if(row.actualFinishStartTime){
// return row.actualFinishStartTime
// }else if(row.actualFinishStartTime & & row.actualFinishEndTime){
// return row.actualFinishStartTime + '-' + row.actualFinishEndTime
// }
// }
// }
// ],
// // 当所有数据被加载时触发
// onLoadSuccess: function(data) {
// for (let i = 0; i < data.rows.length ; i + + ) {
// var curIndex = parentRowIndex*6+i;
// var startDateIndex = 'planFinishStartDate_'+i;
// var endDateIndex = 'planFinishEndDate_'+i;
//
// $('[data-id="'+startDateIndex+'"]').datetimepicker({
// format: 'yyyy-mm-dd',
// minView: "month",
// todayBtn: true,
// autoclose: true,
// }).on('changeDate', function(event) {
// event.preventDefault();
// event.stopPropagation();
// var startTime = event.date;
// $('[data-id="'+endDateIndex+'"]').datetimepicker('setStartDate', startTime);
// });
// $('[data-id="'+endDateIndex+'"]').datetimepicker({
// format: 'yyyy-mm-dd',
// minView: "month",
// todayBtn: true,
// autoclose: true,
// }).on('changeDate', function(event) {
// event.preventDefault();
// event.stopPropagation();
// var endTime = event.date;
// $('[data-id="'+startDateIndex+'"]').datetimepicker('setEndDate', endTime);
// });
//
// }
//
// },
// });
};
function queryParams(params) {
var curParams = {
// 传递参数查询参数
// pageSize: params.limit,
// pageNum: params.offset / params.limit + 1,
// searchValue: params.search,
// orderByColumn: params.sort,
// isAsc: params.order
};
// 额外传参
curParams.quoteId = $("#saleNo").val();
curParams.makeNo = $("#makeNo").val();
curParams.level = 0;
return curParams;
}
@ -505,13 +539,106 @@
});
function submitHandler() {
debugger
// debugger
// var data = $("#form-makeorder-edit").serializeArray();
var data = {
makeNo:$("#makeNo").val(),
saleNo:$("#saleNo").val()
var saleNo = $("#saleNo").val();
var makeNo = $("#makeNo").val();
let makeOrderBomList = [];
var keyPre = 'all_level_child_table_';
const length = sessionStorage.length;
for (let i = 0; i < length ; i + + ) {
const key = sessionStorage.key(i);
if (key.startsWith(keyPre)) {
var rows = sessionStorage.getItem(key);
var rowData = JSON.parse(rows);
rowData.forEach(function (value){
makeOrderBomList.push(value);
})
}
}
var sysMakeOrder = {
makeNo: makeNo,
saleNo: saleNo,
sysMakeorderBomList: makeOrderBomList,
}
$.operate.saveJson(prefix + "/gcReview", JSON.stringify(sysMakeOrder));
}
function editMakeOrderBom(curIndex,materialNo){
var url = ctx + "system/makeorderbom/editMakeorderBom?materialNo=" + materialNo+"&curIndex="+curIndex+"&makeNo="+makeNo;
var options = {
title: '编辑生产bom',
url: url,
callBack: handleMakeOrderBomData
};
$.operate.save(prefix + "/gcReview", data);
$.modal.openOptions(options);
}
function handleMakeOrderBomData(index, layero){
var iframeWin = window[layero.find('iframe')[0]['name']];
iframeWin.$('#materialNo').removeAttr("disabled");
var materialNo = iframeWin.$('#materialNo').val();
var curIndex = iframeWin.$('#curIndex').val();
var saleNo = $("#saleNo").val();
var makeNo = $("#makeNo").val();
var tableData = iframeWin.$('#bootstrap-sub-table-1').bootstrapTable('getData');
if (tableData.length===0){
$.modal.alertWarning("请至少添加一条bom信息再保存!");
return;
}
var bomData = [];
var oneLevelKey = "one_level_child_table_"+curIndex;
var allLevelKey = "all_level_child_table_"+curIndex;
var formData = [];
for(var i=0;i< tableData.length ; i + + ) {
tableData[i].salesOrderMaterialNo = materialNo;
tableData[i].makeNo = makeNo;
tableData[i].salesOrderCode = saleNo;
if(tableData[i].useNum == null || tableData[i].useNum == ''){
$.modal.alertWarning("子表数据用量不能为空!");
return;
}
formData.push(tableData[i].materialNo);
}
materialNos = JSON.stringify(formData);
// 创建一个 bomData 对象,用于快速查找
var bomData = {};
for (var i = 0; i < formData.length ; i + + ) {
bomData[formData[i]] = tableData[i];
}
//根据修改页面返回的一阶bom,后台查找所有阶bom,如果bom表中没有,说明该物料未被添加为bom
//则返回一个只有料号数据的一阶bom空对象,页面做对比将后端返回数组中的一阶bom替换成修改页面返回的一阶bom
$.ajax({
url: ctx + "erp/bom/makeOrderAllList",
cache: false,
data: materialNos,
contentType: "application/json",
processData: false,
type: 'POST',
success: function (result) {
var rowData = result.rows;
// 遍历 result 数组,替换匹配的料号
for (var j = 0; j < rowData.length ; j + + ) {
rowData[j].salesOrderMaterialNo = materialNo;
rowData[j].makeNo = makeNo;
rowData[j].salesOrderCode = saleNo;
//替换一阶物料
if (bomData[rowData[j].materialNo] & & rowData[j].level == '1') {
rowData[j] = bomData[rowData[j].materialNo];
}
}
$("#child_table_"+curIndex).bootstrapTable('load',result.rows);
sessionStorage.setItem(allLevelKey,JSON.stringify(result.rows));
}
});
sessionStorage.setItem(oneLevelKey,JSON.stringify(tableData));
layer.close(index);
}
< / script >