|
|
@ -356,27 +356,38 @@ |
|
|
|
$.table.init(options); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//逻辑新增一行物料数据 |
|
|
|
function estimateDoSubmit(index, layero, uniqueId) { |
|
|
|
console.log(uniqueId); |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var rowData = iframeWin.$('#bootstrap-estimateMaterialSelect-table').bootstrapTable('getSelections')[0]; |
|
|
|
|
|
|
|
//判断是否重复 |
|
|
|
var rows = $("#bootstrap-table").bootstrapTable('getData').length; |
|
|
|
for(var i=0;i<rows;i++){ |
|
|
|
var data = $("#bootstrap-table").bootstrapTable('getData')[i]; |
|
|
|
var selectedRows = iframeWin.$('#bootstrap-estimateMaterialSelect-table').bootstrapTable('getSelections'); |
|
|
|
|
|
|
|
if(data.materialNo == rowData.materialNo){ |
|
|
|
$.modal.alertError("不能选择已添加过的相同物料"); |
|
|
|
if (selectedRows.length === 0) { |
|
|
|
$.modal.alertError("请选择至少一条物料信息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var existingData = $("#bootstrap-table").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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log("rowData: "+rowData); |
|
|
|
$("#bootstrap-table").bootstrapTable('insertRow', { |
|
|
|
index:1, |
|
|
|
row: { |
|
|
|
if (!isDuplicate) { |
|
|
|
// 如果不存在,则准备插入新行 |
|
|
|
newRows.push({ |
|
|
|
materialNo: rowData.materialNo, |
|
|
|
materialPhotourl: rowData.photoUrl, |
|
|
|
materialName: rowData.materialName, |
|
|
@ -387,8 +398,20 @@ |
|
|
|
materialProcessMethod: rowData.processMethod, |
|
|
|
materialDeptType: rowData.warehouseDept, |
|
|
|
materialNum: 0 |
|
|
|
}); |
|
|
|
} else { |
|
|
|
$.modal.alertError("不能选择已添加过的相同物料"); |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// 批量插入新行 |
|
|
|
if (newRows.length > 0) { |
|
|
|
$("#bootstrap-table").bootstrapTable('insertRow', { index: 1, row: newRows[0] }); |
|
|
|
for (var k = 1; k < newRows.length; k++) { |
|
|
|
$("#bootstrap-table").bootstrapTable('insertRow', { index: 1, row: newRows[k] }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
getTotalAmount(); |
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|