|
|
@ -464,46 +464,73 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function doSubmit(index, layero,uniqueId){ |
|
|
|
function doSubmit(index, layero, uniqueId) { |
|
|
|
console.log(uniqueId); |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var rowData = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections')[0]; |
|
|
|
var selectedRows = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections'); |
|
|
|
|
|
|
|
if($("#materialNo").val()==rowData.materialNo){ |
|
|
|
$.modal.alertError("不能选择与主体bom相同的料号"); |
|
|
|
if (selectedRows.length === 0) { |
|
|
|
$.modal.alertError("请选择至少一条物料信息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
//判断是否重复 |
|
|
|
var rows = $("#bootstrap-sub-table-1").bootstrapTable('getData').length; |
|
|
|
for(var i=0;i<rows;i++){ |
|
|
|
var data = $("#bootstrap-sub-table-1").bootstrapTable('getData')[i]; |
|
|
|
if(data.materialNo==rowData.materialNo){ |
|
|
|
|
|
|
|
var existingData = $("#bootstrap-sub-table-1").bootstrapTable('getData'); |
|
|
|
|
|
|
|
// 存储要插入的新行 |
|
|
|
var newRows = []; |
|
|
|
|
|
|
|
// 遍历选中的每一行物料信息 |
|
|
|
for (var i = 0; i < selectedRows.length; i++) { |
|
|
|
var rowData = selectedRows[i]; |
|
|
|
|
|
|
|
// 检查是否已经存在相同的物料 |
|
|
|
var isDuplicate = false; |
|
|
|
for (var j = 0; j < existingData.length; j++) { |
|
|
|
if (existingData[j].materialNo === rowData.materialNo) { |
|
|
|
isDuplicate = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!isDuplicate && $("#materialNo").val() !== rowData.materialNo) { |
|
|
|
// 如果不存在,并且不与主体BOM相同,则准备插入新行 |
|
|
|
newRows.push({ |
|
|
|
id: rowData.id, |
|
|
|
bomNo: rowData.bomNo, |
|
|
|
materialNo: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
describe: rowData.describe, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
unit: rowData.unit, |
|
|
|
brand: rowData.brand, |
|
|
|
warehouseDept: rowData.warehouseDept, |
|
|
|
level: "1", |
|
|
|
useNum: '', |
|
|
|
lossRate: '' |
|
|
|
}); |
|
|
|
} else if ($("#materialNo").val() === rowData.materialNo) { |
|
|
|
$.modal.alertError("不能选择与主体BOM相同的料号"); |
|
|
|
} else { |
|
|
|
$.modal.alertError("不能选择已添加过的相同料号"); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var totalNum = $("#bootstrap-sub-table-1").bootstrapTable('getData').length; |
|
|
|
console.log("rowData: "+rowData); |
|
|
|
$("#bootstrap-sub-table-1").bootstrapTable('insertRow',{ |
|
|
|
index: 1, |
|
|
|
row: { |
|
|
|
id:rowData.id, |
|
|
|
bomNo:rowData.bomNo, |
|
|
|
materialNo: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
describe: rowData.describe, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
unit: rowData.unit, |
|
|
|
brand: rowData.brand, |
|
|
|
warehouseDept: rowData.warehouseDept, |
|
|
|
level: "1", |
|
|
|
useNum:'', |
|
|
|
lossRate:'' |
|
|
|
|
|
|
|
// 批量插入新行 |
|
|
|
if (newRows.length > 0) { |
|
|
|
// 插入第一行 |
|
|
|
$("#bootstrap-sub-table-1").bootstrapTable('insertRow', { index: 1, row: newRows[0] }); |
|
|
|
|
|
|
|
// 插入剩余行 |
|
|
|
for (var k = 1; k < newRows.length; k++) { |
|
|
|
$("#bootstrap-sub-table-1").bootstrapTable('insertRow', { index: 1, row: newRows[k] }); |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* 新增表格行 */ |
|
|
|
function insertRow(){ |
|
|
|
var url = ctx + "erp/material/select"; |
|
|
|