|
|
@ -72,13 +72,15 @@ |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label is-required">工程员:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select name="businessMembers" id="businessMembers_edit" class="form-control m-b" disabled required > |
|
|
|
</select> |
|
|
|
<input name="businessMembers" th:field="*{businessMembers}" id="businessMembers_edit" class="form-control m-b" disabled required > |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-2 control-label">照片:</label> |
|
|
|
<div class="col-sm-10"> |
|
|
|
|
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">照片:</label> |
|
|
|
<div class="col-sm-9"> |
|
|
|
<el-upload |
|
|
|
:action="fileUploadUrl" |
|
|
|
:on-success="uploadSuccess" |
|
|
@ -96,6 +98,17 @@ |
|
|
|
<input id="photoAttachId" name = "photoAttachId" hidden th:field="*{photoAttachId}" /> |
|
|
|
<input id="removeFileIdStr" type="text" name="removeFileIdStr" hidden /> |
|
|
|
</div> |
|
|
|
<div class="form-group" id="add-process-text"> |
|
|
|
<label class="col-sm-3 control-label is-required">委外工序:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<a class="btn btn-success" onclick="insertRowWai()" ><i class="fa fa-plus"></i> 添加委外工序</a> |
|
|
|
</div> |
|
|
|
<div class="col-xs-10" id="add-process" style="margin-left: 80px;"> |
|
|
|
<div class="col-sm-10 select-table table-striped"> |
|
|
|
<table id="bootstrap-table-process"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</form> |
|
|
|
</div> |
|
|
|
<th:block th:include="include :: footer" /> |
|
|
@ -127,9 +140,9 @@ |
|
|
|
|
|
|
|
var that = this; |
|
|
|
// 页面渲染完成,可以执行需要的操作 |
|
|
|
console.log('页面已渲染完成'); |
|
|
|
console.log($("#id").val()); |
|
|
|
console.log($("#photoAttachId").val()); |
|
|
|
// console.log('页面已渲染完成'); |
|
|
|
// console.log($("#id").val()); |
|
|
|
// console.log($("#photoAttachId").val()); |
|
|
|
var attachId = $("#photoAttachId").val(); |
|
|
|
if(attachId){ |
|
|
|
$.ajax({ |
|
|
@ -244,37 +257,197 @@ |
|
|
|
focusCleanup: true |
|
|
|
}); |
|
|
|
$(function(){ |
|
|
|
var materialNo = erpMaterial.materialNo; |
|
|
|
var options = { |
|
|
|
id: "bootstrap-table-process", |
|
|
|
url: prefix + "/processList", |
|
|
|
method: 'post', |
|
|
|
contentType: "application/x-www-form-urlencoded", |
|
|
|
queryParams : { |
|
|
|
materialNo: materialNo |
|
|
|
}, |
|
|
|
pagination: false, |
|
|
|
showSearch: false, |
|
|
|
showRefresh: false, |
|
|
|
showToggle: false, |
|
|
|
showColumns: false, |
|
|
|
striped: false, |
|
|
|
sidePagination: "client", |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
field: 'outsourceProcessId', |
|
|
|
align: 'center', |
|
|
|
title: '委外工序主键', |
|
|
|
visible: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'outsourceProcessCode', |
|
|
|
align: 'center', |
|
|
|
title: '委外工序ID', |
|
|
|
visible: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'outsourceProcessNo', |
|
|
|
align: 'center', |
|
|
|
title: '委外工序编号', |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'outsourceProcessName', |
|
|
|
align: 'center', |
|
|
|
title: '委外工序名称', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
align: 'center', |
|
|
|
formatter: function (value, row, index) { |
|
|
|
var actions = []; |
|
|
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.outsourceProcessNo + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}] |
|
|
|
}; |
|
|
|
$.table.init(options); |
|
|
|
var materialType = $("#materialType").val(); |
|
|
|
$("#selectMaterialType").val(materialType); |
|
|
|
engineer(); |
|
|
|
// engineer(); |
|
|
|
if (erpMaterial.processMethod === "2") { |
|
|
|
$("#add-process-text").show(); |
|
|
|
$("#add-process").show(); |
|
|
|
} else { |
|
|
|
$("#add-process-text").hide(); |
|
|
|
$("#add-process").hide(); |
|
|
|
} |
|
|
|
}) |
|
|
|
//获取工程员 |
|
|
|
function engineer() { |
|
|
|
var engineerSelect = $("#form-material-edit select[name='businessMembers']"); |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'erp/material/getEngineerList', |
|
|
|
type: 'get', |
|
|
|
success: function (res) { |
|
|
|
if (res.rows.length > 0) { |
|
|
|
var usertData = res.rows; |
|
|
|
for (let i in usertData) { |
|
|
|
engineerSelect.append( |
|
|
|
"<option value='" + usertData[i].loginName + "'>" + usertData[i].userName + "</option>"); |
|
|
|
// function engineer() { |
|
|
|
// var engineerSelect = $("#form-material-edit select[name='businessMembers']"); |
|
|
|
// $.ajax({ |
|
|
|
// url: ctx + 'erp/material/getEngineerList', |
|
|
|
// type: 'get', |
|
|
|
// success: function (res) { |
|
|
|
// if (res.rows.length > 0) { |
|
|
|
// var usertData = res.rows; |
|
|
|
// for (let i in usertData) { |
|
|
|
// engineerSelect.append( |
|
|
|
// "<option value='" + usertData[i].loginName + "'>" + usertData[i].userName + "</option>"); |
|
|
|
// } |
|
|
|
// engineerSelect.val(loginName); |
|
|
|
// } else { |
|
|
|
// $.modal.msgError(res.msg); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
|
|
|
|
function insertRowWai() { |
|
|
|
// var html = '<tr>' + |
|
|
|
// '<td><input type="text" name="weiwai" class="form-control" required></td>' + |
|
|
|
// '<td><a class="btn btn-danger" onclick="removeRowWai(this)">删除</a></td>' + |
|
|
|
// '</tr>'; |
|
|
|
// $(".bootstrap-table-sub-2").append(html); |
|
|
|
var url = "/system/outsource_quote/processadd"; |
|
|
|
var options = { |
|
|
|
title: '选择委外工序', |
|
|
|
height: "500", |
|
|
|
url: url, |
|
|
|
callBack: doSubmit |
|
|
|
}; |
|
|
|
$.modal.openOptions(options); |
|
|
|
} |
|
|
|
// 插入工序信息 |
|
|
|
function insertTable(rowData) { |
|
|
|
var newRow = { |
|
|
|
outsourceProcessNo: rowData.outsourceProcessNo, |
|
|
|
// outsourceProcessCode: rowData.outsourceProcessCode, |
|
|
|
outsourceProcessName: rowData.outsourceProcessName, |
|
|
|
}; |
|
|
|
// 将新行追加到表格末尾 |
|
|
|
$("#bootstrap-table-process").bootstrapTable('append', newRow); |
|
|
|
} |
|
|
|
/* 选择委外工序回调 */ |
|
|
|
function doSubmit(index, layero){ |
|
|
|
// // 这里取到的是多行的 |
|
|
|
var rowData = layero.find("iframe")[0].contentWindow.getSelections(); |
|
|
|
//判断是否重复 |
|
|
|
var data = $("#bootstrap-table-process").bootstrapTable('getData'); |
|
|
|
var rows = data.length; |
|
|
|
if(rows>0){ |
|
|
|
for(var i=0;i<rows;i++){ |
|
|
|
for(var j=0;j<rowData.length;j++){ |
|
|
|
if(data[i].outsourceProcessNo===rowData[j].outsourceProcessNo){ |
|
|
|
$.modal.alertError("不能选择已添加过的相同工序"); |
|
|
|
rowData.split(j,1); |
|
|
|
break; |
|
|
|
} |
|
|
|
engineerSelect.val(loginName); |
|
|
|
} else { |
|
|
|
$.modal.msgError(res.msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
} |
|
|
|
for(i=0;i<rowData.length;i++){ |
|
|
|
insertTable(rowData[i]); |
|
|
|
} |
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|
//获取供应商 |
|
|
|
function removeRow(outsourceProcessNo){ |
|
|
|
$("#bootstrap-table-process").bootstrapTable('remove', { |
|
|
|
field: 'outsourceProcessNo', |
|
|
|
values: outsourceProcessNo |
|
|
|
}) |
|
|
|
} |
|
|
|
$("select[name='processMethod']").on("select2:select", function (e) { |
|
|
|
data = e.params.data; |
|
|
|
// console.log(data); |
|
|
|
if (data.text == '委外加工') { |
|
|
|
$("#add-process-text").show(); |
|
|
|
$("#add-process").show(); |
|
|
|
} else { |
|
|
|
$("#add-process-text").hide(); |
|
|
|
$("#add-process").hide(); |
|
|
|
} |
|
|
|
}); |
|
|
|
function submitHandler() { |
|
|
|
if ($.validate.form()) { |
|
|
|
$("#businessMembers_edit").removeAttr("disabled"); |
|
|
|
$("input[name='materialNo']").removeAttr("disabled"); |
|
|
|
$("input[name='materialName']").removeAttr("disabled"); |
|
|
|
var materialType = $('#selectMaterialType').select2('val'); |
|
|
|
$('#materialType').val(materialType); |
|
|
|
$.operate.save(prefix + "/edit", $('#form-material-edit').serialize()); |
|
|
|
// 获取表单数据 |
|
|
|
const erpMaterialData = $("#form-material-edit").serializeArray().reduce((obj, item) => { |
|
|
|
obj[item.name] = item.value; |
|
|
|
return obj; |
|
|
|
}, {}); |
|
|
|
var erpMaterial = { |
|
|
|
id: erpMaterialData.id, |
|
|
|
materialNo: erpMaterialData.materialNo, |
|
|
|
materialName: erpMaterialData.materialName, |
|
|
|
materialType: erpMaterialData.materialType, |
|
|
|
processMethod: erpMaterialData.processMethod, |
|
|
|
unit: erpMaterialData.unit, |
|
|
|
brand: erpMaterialData.brand, |
|
|
|
describe: erpMaterialData.describe, |
|
|
|
warehouseDept: erpMaterialData.warehouseDept, |
|
|
|
businessMembers: erpMaterialData.businessMembers, |
|
|
|
fileIdStr: erpMaterialData.fileIdStr, |
|
|
|
processList:[] |
|
|
|
} |
|
|
|
if(erpMaterialData.processMethod === "2"){ |
|
|
|
var processDatas = $("#bootstrap-table-process").bootstrapTable('getData'); |
|
|
|
if(processDatas.length === 0){ |
|
|
|
$.modal.alertWarning("请至少添加一条委外工序再保存!"); |
|
|
|
return; |
|
|
|
}else{ |
|
|
|
for(var i = 0; i<processDatas.length; i++){ |
|
|
|
var process = { |
|
|
|
outsourceProcessNo: processDatas[i].outsourceProcessNo, |
|
|
|
outsourceProcessName: processDatas[i].outsourceProcessName, |
|
|
|
} |
|
|
|
erpMaterial.processList.push(process); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(erpMaterial); |
|
|
|
$.operate.saveJson(prefix + "/edit", JSON.stringify(erpMaterial)); |
|
|
|
// $.operate.save(prefix + "/edit", $('#form-material-edit').serialize()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|