|
|
@ -3,7 +3,30 @@ |
|
|
|
<head> |
|
|
|
<th:block th:include="include :: header('新增品质管理制程检验')" /> |
|
|
|
<th:block th:include="include :: datetimepicker-css" /> |
|
|
|
<th:block th:include="include :: bootstrap-editable-css" /> |
|
|
|
</head> |
|
|
|
<style> |
|
|
|
.fixed-table-container { |
|
|
|
border: 0px solid #ddd; |
|
|
|
min-height: 140px; |
|
|
|
} |
|
|
|
.table-striped-two{ |
|
|
|
overflow: hidden; |
|
|
|
scroll: auto; |
|
|
|
} |
|
|
|
.bordered-container { |
|
|
|
/* 自动高度,根据内容自动调整 */ |
|
|
|
min-height: 0; /* 确保高度能收缩至内容高度 */ |
|
|
|
/* 自动宽度,对于块级元素已经是默认行为,但如果你想强调这一点或针对特定情况,可以显式声明 */ |
|
|
|
width: auto; |
|
|
|
height: auto; |
|
|
|
border: 1px dashed blue; /* 灰色边框,可根据需要调整颜色 */ |
|
|
|
/* 以下可选,根据需要添加,用于控制内外边距和布局 */ |
|
|
|
padding: 1rem; |
|
|
|
box-sizing: border-box; /* 包含边框和内边距在宽度计算中 */ |
|
|
|
margin-bottom: 20px; |
|
|
|
} |
|
|
|
</style> |
|
|
|
<body class="white-bg"> |
|
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|
|
|
<form class="form-horizontal m" id="form-manufacturingCheckout-add"> |
|
|
@ -28,19 +51,29 @@ |
|
|
|
|
|
|
|
<div class="container"> |
|
|
|
<div class="form-row"> |
|
|
|
<div class="btn-group-sm" id="toolbar" role="group"> |
|
|
|
<span>选择物料</span> |
|
|
|
<a class="btn btn-success" onclick="insertRow()"> |
|
|
|
<i class="fa fa-plus"></i> 选择物料 |
|
|
|
</a> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
|
<table id="bootstrap-table"></table> |
|
|
|
<table id="bootstrap-material-table"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="container mt-5"> |
|
|
|
<div class="btn-group-sm" style="margin-top: 10px;margin-bottom: 10px;"> |
|
|
|
<span>选择制程工序</span> |
|
|
|
<a class="btn btn-success" onclick="insertCheckProcess()"> |
|
|
|
<i class="fa fa-plus"></i> 添加制程工序 |
|
|
|
</a> |
|
|
|
</div> |
|
|
|
<div id="contentArea" class="mt-3"> |
|
|
|
<!-- 初始内容可以在这里,例如一个列表项和一个表单 --> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<th:block th:include="include :: footer" /> |
|
|
|
<th:block th:include="include :: datetimepicker-js" /> |
|
|
@ -50,7 +83,15 @@ |
|
|
|
var prefix = ctx + "quality/manufacturingCheckout"; |
|
|
|
var checkoutProcessList = []; |
|
|
|
var materialProcessList = []; |
|
|
|
var uniqueIdList = []; |
|
|
|
var processMethodDatas = [[${@dict.getType('processMethod')}]]; |
|
|
|
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; |
|
|
|
var manufacturingProcessNameDatas = [[${@dict.getType('manufacturing_process_name')}]]; |
|
|
|
var processBadClassificationDatas = [[${@dict.getType('process_bad_classification')}]]; |
|
|
|
var processBadGradeDatas = [[${@dict.getType('process_bad_grade')}]]; |
|
|
|
var manufacturingProcessList = []; |
|
|
|
var processNameList = []; |
|
|
|
var curIndex = 0; |
|
|
|
$("#form-manufacturingCheckout-add").validate({ |
|
|
|
focusCleanup: true |
|
|
|
}); |
|
|
@ -62,48 +103,54 @@ |
|
|
|
obj[item.name] = item.value; |
|
|
|
return obj; |
|
|
|
}, {}); |
|
|
|
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 |
|
|
|
var table = $('#bootstrap-table').bootstrapTable('getData'); |
|
|
|
var table = $('#bootstrap-material-table').bootstrapTable('getData'); |
|
|
|
|
|
|
|
// 检查表格数据是否为空 |
|
|
|
if (table.length===0){ |
|
|
|
$.modal.alertWarning("请至少添加一条物料数据后再保存!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
// console.log(table); |
|
|
|
// 将表数据转换成与complaintNoticeData格式一致的数组 |
|
|
|
var materialDataList = table.map(function(item) { |
|
|
|
// 根据实际字段名调整 |
|
|
|
return { |
|
|
|
"materialNo": item.materialNo, // 假设id对应materialId |
|
|
|
"materialPhotourl": item.materialPhotourl, // 假设quantity是物料数量字段 |
|
|
|
"materialName": item.materialName, |
|
|
|
"materialType": item.materialType, |
|
|
|
"materialUnit": item.materialUnit, |
|
|
|
"materialBrand": item.materialBrand, |
|
|
|
"materialDescribe": item.materialDescribe, |
|
|
|
"materialProcessMethod": item.materialProcessMethod, |
|
|
|
"makeTotal": item.makeTotal, |
|
|
|
"checkedNum": item.checkedNum, |
|
|
|
"currentCheckoutNum": item.currentCheckoutNum, |
|
|
|
"processQualifiedNum":item.processQualifiedNum, |
|
|
|
"processUnqualifiedNum":item.processUnqualifiedNum |
|
|
|
// ...其他字段 |
|
|
|
}; |
|
|
|
}); |
|
|
|
materialDataList.forEach(function(item) { |
|
|
|
item.materialProcessList = []; |
|
|
|
materialProcessList.forEach(function (process){ |
|
|
|
if(process.materialNo === item.materialNo){ |
|
|
|
item.materialProcessList.push(process); |
|
|
|
var checkOutNum = table[0].currentCheckoutNum; |
|
|
|
//未检验数 |
|
|
|
var unCheckNum = Number(table[0].makeTotal)-Number(table[0].checkedNum); |
|
|
|
if(checkOutNum == ''||checkOutNum == null |
|
|
|
||checkOutNum == undefined||checkOutNum === 0){ |
|
|
|
$.modal.alertWarning("物料本次检验数为空!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
if(checkOutNum > unCheckNum){ |
|
|
|
$.modal.alertWarning("物料本次检验数超出未检验数,请检查!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
var checkOutMaterial = table[0]; |
|
|
|
var qualityManufacturingCheckout = { |
|
|
|
makeNo: $("#makeNo").val(), |
|
|
|
checkoutTime: $("input[name='checkoutTime']").val(), |
|
|
|
materialNo: table[0].materialNo, |
|
|
|
materialName: table[0].materialName |
|
|
|
} |
|
|
|
|
|
|
|
$(".bordered-container").each(function (index,container){ |
|
|
|
var tableId = "bootstrap-manufacturingProcess-table-"+uniqueIdList[index]; |
|
|
|
var unqualifiedTableId = "bootstrap-unqualifiedClass-table-"+uniqueIdList[index]; |
|
|
|
var processDatas = $("#"+tableId).bootstrapTable("getData")[0]; |
|
|
|
|
|
|
|
var okAcceptedNum = $(container).find("input[name='okAcceptedNum']").val(); |
|
|
|
var specialConcessionsNum = $(container).find("input[name='specialConcessionsNum']").val(); |
|
|
|
processDatas.okAcceptedNum = okAcceptedNum; |
|
|
|
processDatas.specialConcessionsNum = specialConcessionsNum; |
|
|
|
var unqualifiedClassList = $("#"+unqualifiedTableId).bootstrapTable("getData"); |
|
|
|
if(unqualifiedClassList <= 0){ |
|
|
|
$.modal.alertWarning("工序"+processDatas.manufacturingProcessCode+"不合格分类为空,请检查!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
processDatas.unqualifiedClassList = unqualifiedClassList; |
|
|
|
materialProcessList.push(processDatas); |
|
|
|
}) |
|
|
|
}); |
|
|
|
const combinedData = Object.assign({}, manufacturingCheckoutData, { checkoutMaterialList: materialDataList }); |
|
|
|
// 合并表单数据和表格数据 |
|
|
|
console.log(combinedData) |
|
|
|
// 使用 JSON.stringify() 序列化数据 |
|
|
|
const jsonData = JSON.stringify(combinedData); |
|
|
|
checkOutMaterial.materialProcessList = materialProcessList; |
|
|
|
qualityManufacturingCheckout.checkoutMaterial = checkOutMaterial; |
|
|
|
|
|
|
|
const jsonData = JSON.stringify(qualityManufacturingCheckout); |
|
|
|
// 发送 AJAX 请求到后端接口 |
|
|
|
$.operate.saveJson(prefix + "/add", jsonData); |
|
|
|
} |
|
|
@ -114,8 +161,6 @@ |
|
|
|
autoclose: true |
|
|
|
}); |
|
|
|
|
|
|
|
/*加载所有的关联生产单号*/ |
|
|
|
loadAllMakeNos(); |
|
|
|
/*加载所有的关联生产单号*/ |
|
|
|
function loadAllMakeNos(){ |
|
|
|
var url = ctx + 'system/makeorder/getAllMakeNos'; |
|
|
@ -126,9 +171,7 @@ |
|
|
|
success: function (data){ |
|
|
|
if (data && Array.isArray(data)){ |
|
|
|
var selectElement = $('#makeNo'); //获取生产编号下拉框元素 |
|
|
|
//清空下拉框现有选项 |
|
|
|
selectElement.empty(); |
|
|
|
// 添加默认选项(如果需要) |
|
|
|
selectElement.append('<option value="">请选择关联生产单号</option>'); |
|
|
|
//遍历返回的数据,添加下拉框的选项 |
|
|
|
$.each(data,function (index,item){ |
|
|
@ -144,46 +187,63 @@ |
|
|
|
|
|
|
|
//物料信息展示列表 |
|
|
|
$(function() { |
|
|
|
loadAllMakeNos(); |
|
|
|
var options = { |
|
|
|
id: "bootstrap-material-table", |
|
|
|
modalName: "选择物料", |
|
|
|
showSearch: false, |
|
|
|
showRefresh: false, |
|
|
|
showToggle: false, |
|
|
|
showColumns: false, |
|
|
|
height: 40, |
|
|
|
pagination: false, // 设置不分页 |
|
|
|
columns: [{ |
|
|
|
checkbox: true |
|
|
|
}, |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
title: '料号', |
|
|
|
field: 'materialNo', |
|
|
|
align: 'center', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '图片', |
|
|
|
align: 'center', |
|
|
|
field: 'materialPhotourl', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料名称', |
|
|
|
align: 'center', |
|
|
|
field: 'materialName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料类型', |
|
|
|
align: 'center', |
|
|
|
field: 'materialType', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料型号', |
|
|
|
align: 'center', |
|
|
|
field: 'materialModel', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '描述', |
|
|
|
align: 'center', |
|
|
|
field: 'materialDescribe', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '品牌', |
|
|
|
align: 'center', |
|
|
|
field: 'materialBrand', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '单位', |
|
|
|
align: 'center', |
|
|
|
field: 'materialUnit', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料加工方式', |
|
|
|
title: '加工方式', |
|
|
|
align: 'center', |
|
|
|
field: 'materialProcessMethod', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectDictLabel(processMethodDatas, value); |
|
|
@ -191,34 +251,37 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '订单数', |
|
|
|
align: 'center', |
|
|
|
field: 'makeTotal', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '已检验数', |
|
|
|
align: 'center', |
|
|
|
field: 'checkedNum', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '本次检验数', |
|
|
|
align: 'center', |
|
|
|
field: 'currentCheckoutNum', |
|
|
|
editable: { |
|
|
|
type:'text' |
|
|
|
type:'text', |
|
|
|
mode:'inline', |
|
|
|
validate: function (v) { |
|
|
|
if (!v) return '数量不能为空'; |
|
|
|
if (isNaN(v)) return '数量必须是数字'; |
|
|
|
var checkNum = parseInt(v); |
|
|
|
if (checkNum < 0) return '数量必须是正整数'; |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '制程检验报告', |
|
|
|
align: 'center', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
var actions = []; |
|
|
|
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="checkoutReport(\'' + row.materialNo + '\')"><i class="fa fa-plus"></i>检验报告</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '工序合格数', |
|
|
|
align: 'center', |
|
|
|
field: 'processQualifiedNum', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '工序不合格数', |
|
|
|
align: 'center', |
|
|
|
field: 'processUnqualifiedNum', |
|
|
|
}, |
|
|
|
{ |
|
|
@ -233,13 +296,19 @@ |
|
|
|
] |
|
|
|
}; |
|
|
|
$.table.init(options); |
|
|
|
}) |
|
|
|
selectProcessCode(); |
|
|
|
}); |
|
|
|
|
|
|
|
/*选择物料按钮*/ |
|
|
|
function insertRow() { |
|
|
|
var material = $("#bootstrap-material-table").bootstrapTable("getData"); |
|
|
|
if(material.length>0){ |
|
|
|
$.modal.msgError("每次只能添加一个物料,请先删除当前物料"); |
|
|
|
return; |
|
|
|
} |
|
|
|
var selectedMakeNo = $("#makeNo").val(); |
|
|
|
if (!selectedMakeNo) { |
|
|
|
$.modal.alertWarning("请先选择生产单号。"); |
|
|
|
$.modal.alertWarning("请先选择生产单号"); |
|
|
|
return; |
|
|
|
} |
|
|
|
var encodedMakeNo = encodeURIComponent(selectedMakeNo); |
|
|
@ -254,11 +323,9 @@ |
|
|
|
|
|
|
|
|
|
|
|
function doSubmit(index, layero,uniqueId){ |
|
|
|
console.log(uniqueId); |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var rowData = iframeWin.$('#bootstrap-materialSelect-table').bootstrapTable('getSelections')[0]; |
|
|
|
console.log("rowData: "+rowData); |
|
|
|
$("#bootstrap-table").bootstrapTable('insertRow', { |
|
|
|
$("#bootstrap-material-table").bootstrapTable('insertRow', { |
|
|
|
index:1, |
|
|
|
row: { |
|
|
|
materialNo:rowData.materialNo, |
|
|
@ -268,9 +335,13 @@ |
|
|
|
materialDescribe: rowData.materialDescribe, |
|
|
|
materialBrand: rowData.materialBrand, |
|
|
|
materialUnit: rowData.materialUnit, |
|
|
|
materialModel: rowData.materialModel, |
|
|
|
materialProcessMethod: rowData.materialProcessMethod, |
|
|
|
makeTotal:rowData.makeTotal, |
|
|
|
currentCheckoutNum: "" |
|
|
|
checkedNum: rowData.checkedNum, |
|
|
|
currentCheckoutNum: "", |
|
|
|
processQualifiedNum: 0, |
|
|
|
processUnqualifiedNum: 0, |
|
|
|
} |
|
|
|
}) |
|
|
|
layer.close(index); |
|
|
@ -291,102 +362,509 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 逻辑删除前端的一行数据 |
|
|
|
function removeRow(materialNo){ |
|
|
|
$("#bootstrap-table").bootstrapTable('remove', { |
|
|
|
field: 'materialNo', |
|
|
|
values: materialNo |
|
|
|
}) |
|
|
|
|
|
|
|
//新增制程工序模块 |
|
|
|
function insertCheckProcess() { |
|
|
|
|
|
|
|
var material = $("#bootstrap-material-table").bootstrapTable("getData"); |
|
|
|
if(material.length == 0){ |
|
|
|
$.modal.msgError("物料表格为空,请先选择物料"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 在父页面中定义处理函数 |
|
|
|
function handleCheckoutReportData(index, layero){ |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var processQualifiedNum = 0; |
|
|
|
var processUnqualifiedNum = 0; |
|
|
|
var materialNo = iframeWin.$('#form-checkoutReport-add').find('input[name="materialNo"]').val(); |
|
|
|
var materialName = iframeWin.$('#form-checkoutReport-add').find('input[name="materialName"]').val(); |
|
|
|
var uniqueIdString = iframeWin.$('#uniqueIdList').val(); |
|
|
|
var uniqueIdList = uniqueIdString.split(','); |
|
|
|
console.log(uniqueIdList); |
|
|
|
iframeWin.$('.container.bordered-container').each(function(index, tableElement) { |
|
|
|
var tableId = uniqueIdList[index]; |
|
|
|
var $processTable = iframeWin.$('#bootstrap-manufacturingProcess-table-'+tableId); |
|
|
|
var rows = $processTable.bootstrapTable('getData'); |
|
|
|
var manufacturingProcessCode = $processTable.find('select[name="manufacturingProcessCode"]').val(); |
|
|
|
curIndex ++; |
|
|
|
var uniqueId = "unique_" + curIndex; |
|
|
|
uniqueIdList.push(uniqueId); |
|
|
|
|
|
|
|
var okAcceptedNum = iframeWin.$('#form-manfa-'+tableId).find('input[name="okAcceptedNum"]').val(); |
|
|
|
okAcceptedNum = Number(okAcceptedNum); |
|
|
|
var specialConcessionsNum = iframeWin.$('#form-manfa-'+tableId).find('input[name="specialConcessionsNum"]').val(); |
|
|
|
specialConcessionsNum = Number(specialConcessionsNum); |
|
|
|
if (!isNaN(processQualifiedNum) && !isNaN(okAcceptedNum) && !isNaN(specialConcessionsNum)) { |
|
|
|
processQualifiedNum = processQualifiedNum + okAcceptedNum + specialConcessionsNum; |
|
|
|
console.log(processQualifiedNum); |
|
|
|
} else { |
|
|
|
console.log("One or more variables is not a valid number."); |
|
|
|
} |
|
|
|
var materialProcess = { |
|
|
|
materialNo: materialNo, |
|
|
|
materialName: materialName, |
|
|
|
manufacturingProcessCode: manufacturingProcessCode, |
|
|
|
manufacturingProcessName: rows[0].manufacturingProcessName, |
|
|
|
deviceName: rows[0].deviceName, |
|
|
|
deviceModelCode: rows[0].deviceModelCode, |
|
|
|
processSequence: rows[0].processSequence, |
|
|
|
workshopName: rows[0].workshopName, |
|
|
|
modName: rows[0].modName, |
|
|
|
processInspectionItem: rows[0].processInspectionItem, |
|
|
|
okAcceptedNum: okAcceptedNum, |
|
|
|
specialConcessionsNum: specialConcessionsNum, |
|
|
|
unqualifiedClassList: [] |
|
|
|
var newItem = |
|
|
|
'<div class="container bordered-container" id="div_'+ uniqueId +'">' + |
|
|
|
"<div class='col-sm-12 my-3'>" + |
|
|
|
`<h5>制程工序${curIndex}</h5>` + |
|
|
|
"<div class='col-sm-12 select-table table-striped'>" + |
|
|
|
'<table class="table-container checkoutMaterial-edit-table" id="bootstrap-manufacturingProcess-table-'+uniqueId+'"></table>' + |
|
|
|
"</div>" + |
|
|
|
"</div>" + |
|
|
|
"<div class='col-sm-12 move-right'>" + |
|
|
|
"<h3>合格数</h3>\n" + |
|
|
|
" <div class='row'>" + |
|
|
|
" <div class='form-group col-sm-6'>" + |
|
|
|
" <label class='col-sm-4 control-label is-required'>ok允收数:</label>" + |
|
|
|
" <div class='col-sm-8'>" + |
|
|
|
" <input id='okAcceptedNum' name='okAcceptedNum' oninput='okAcceptedHandler()' class='form-control' type='number' value='0' required>" + |
|
|
|
" </div>" + |
|
|
|
" </div>" + |
|
|
|
" <div class='form-group col-sm-6'>" + |
|
|
|
" <label class='col-sm-4 control-label'>ok报告图片:</label>" + |
|
|
|
" <div class='col-sm-8'>" + |
|
|
|
" <input name='okReportUrl' class='form-control' type='text'>" + |
|
|
|
" </div>" + |
|
|
|
" </div>" + |
|
|
|
" </div>" + |
|
|
|
" <div class='row'>" + |
|
|
|
" <div class='form-group col-sm-6'>" + |
|
|
|
" <label class='col-sm-4 control-label is-required'>特采/让步数:</label>" + |
|
|
|
" <div class='col-sm-8'>" + |
|
|
|
" <input id='specialConcessionsNum' name='specialConcessionsNum' oninput='okAcceptedHandler()' class='form-control' type='number' value='0' required>" + |
|
|
|
" </div>" + |
|
|
|
" </div>" + |
|
|
|
" <div class='form-group col-sm-6'>" + |
|
|
|
" <label class='col-sm-4 control-label'>特采报告图片:</label>" + |
|
|
|
" <div class='col-sm-8'>" + |
|
|
|
" <input name='specialReportUrl' class='form-control' type='text'>" + |
|
|
|
" </div>\n" + |
|
|
|
" </div>\n" + |
|
|
|
" </div>"+ |
|
|
|
"</form>"+ |
|
|
|
"</div>" + |
|
|
|
"<div class='col-sm-12 my-3'>" + |
|
|
|
"<h5>不合格数</h5>" + |
|
|
|
"<div class='form-row'> " + |
|
|
|
"<a class='btn btn-success' onclick='insertUnqualifiedRow(\"#bootstrap-unqualifiedClass-table-" + uniqueId + "\")'>"+ |
|
|
|
"<i class='fa fa-plus'></i> 添加 " +"</a>" + |
|
|
|
"</div>" + |
|
|
|
'<div class="col-sm-12 select-table table-striped-two" id="unqualified_'+uniqueId+'">' + |
|
|
|
'<table class="table-container checkoutMaterial-edit-table" id="bootstrap-unqualifiedClass-table-' + uniqueId + '"></table>' + |
|
|
|
"</div>" + |
|
|
|
"</div>" + |
|
|
|
"</div>"; |
|
|
|
$("#contentArea").append(newItem); |
|
|
|
var bootstarpId = "bootstrap-manufacturingProcess-table-" + uniqueId; |
|
|
|
var options1 = { |
|
|
|
id:bootstarpId, |
|
|
|
showSearch: false, |
|
|
|
showRefresh: false, |
|
|
|
showToggle: false, |
|
|
|
showColumns: false, |
|
|
|
pagination: false, // 设置不分页 |
|
|
|
modalName: "选择制程工序", |
|
|
|
height:30, |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
title: '制程工序编号', |
|
|
|
field: 'manufacturingProcessCode', |
|
|
|
align: 'center', |
|
|
|
formatter: function (value, row, index) { |
|
|
|
var tableId = bootstarpId; |
|
|
|
return initProcessCodeSelector(value,row,index,tableId); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '制程工序名称', |
|
|
|
align: 'center', |
|
|
|
field: 'manufacturingProcessName', |
|
|
|
formatter:function (value, row, index) { |
|
|
|
var tableId = bootstarpId; |
|
|
|
return manufacturingProcessNameFormatter(value,row,index,tableId); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备名称', |
|
|
|
align: 'center', |
|
|
|
field: 'deviceName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '设备型号', |
|
|
|
align: 'center', |
|
|
|
field: 'deviceModelCode', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '工序顺序', |
|
|
|
align: 'center', |
|
|
|
field: 'processSequence', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '车间名称', |
|
|
|
align: 'center', |
|
|
|
field: 'workshopName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '零件名称', |
|
|
|
align: 'center', |
|
|
|
field: 'modName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '工序检验项目', |
|
|
|
align: 'center', |
|
|
|
field: 'processInspectionItem', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
align: 'center', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
var actions = []; |
|
|
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeProcess(\'' + uniqueId + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
|
], |
|
|
|
}; |
|
|
|
$.table.init(options1); |
|
|
|
//初始化不合格分类表格 |
|
|
|
var unqualifiedTableId = 'bootstrap-unqualifiedClass-table-' + uniqueId; |
|
|
|
var options2 = { |
|
|
|
id:'bootstrap-unqualifiedClass-table-' + uniqueId, |
|
|
|
showSearch: false, |
|
|
|
showRefresh: false, |
|
|
|
showToggle: false, |
|
|
|
showColumns: false, |
|
|
|
height: 40, |
|
|
|
pagination: false, // 设置不分页 |
|
|
|
modalName: "添加不合格分类", |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
title: '不合格分类Id', |
|
|
|
field: 'unqualifiedClassId', |
|
|
|
visible: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不良分类', |
|
|
|
align: 'center', |
|
|
|
field: 'processBadClassification', |
|
|
|
formatter:function (value, row, index) { |
|
|
|
return processBadClassificationFormatter(value,row,index,unqualifiedTableId); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不良等级', |
|
|
|
align: 'center', |
|
|
|
field: 'processBadGrade', |
|
|
|
formatter:function (value, row, index) { |
|
|
|
return processBadGradeFormatter(value,row,index,unqualifiedTableId); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不良数量', |
|
|
|
align: 'center', |
|
|
|
field: 'processBadNum', |
|
|
|
editable: { |
|
|
|
type:'text', |
|
|
|
mode:'inline', |
|
|
|
validate: function (v) { |
|
|
|
if (!v) return '数量不能为空'; |
|
|
|
if (isNaN(v)) return '数量必须是数字'; |
|
|
|
var checkNum = parseInt(v); |
|
|
|
if (checkNum < 0) return '数量必须是正整数'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '报告', |
|
|
|
align: 'center', |
|
|
|
field: 'processBadPhotourl', |
|
|
|
editable:true |
|
|
|
// formatter: function(value, row, index) { |
|
|
|
// var actions = []; |
|
|
|
// actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" ><i class="fa fa-plus"></i>上传</a> '); |
|
|
|
// return actions.join(''); |
|
|
|
// } |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
align: 'center', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
var actions = []; |
|
|
|
actions.push(`<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeUnqualifiedClassRow('${row.unqualifiedClassId}', '${options2.id}','${row.processBadNum}')"><i class="fa fa-remove"></i>删除</a> `); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
|
], |
|
|
|
onEditableSave: function (field, row, oldValue, $el) { |
|
|
|
updateUnqualifiedNum(); |
|
|
|
} |
|
|
|
}; |
|
|
|
$.table.init(options2); |
|
|
|
$(".fixed-table-container","#unqualified_" + uniqueId).css("min-height","200px"); |
|
|
|
$("#bootstrap-manufacturingProcess-table-" +uniqueId ).bootstrapTable('insertRow', { |
|
|
|
index: 1, |
|
|
|
row: { |
|
|
|
manufacturingProcessCode: '', |
|
|
|
manufacturingProcessName: '', |
|
|
|
deviceName: '', |
|
|
|
deviceModelCode: '', |
|
|
|
processSequence: '', |
|
|
|
workshopName: '', |
|
|
|
modName: '' |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
function insertUnqualifiedRow(tableId) { |
|
|
|
var $table = $(tableId); // 使用传入的ID获取表格实例 |
|
|
|
var newRow = { |
|
|
|
unqualifiedClassId: 'UC_' + new Date().getTime(), // 示例生成唯一ID |
|
|
|
processBadClassification: '', |
|
|
|
processBadGrade: '', |
|
|
|
processBadNum: '', |
|
|
|
processBadPhotourl: '', |
|
|
|
}; |
|
|
|
$table.bootstrapTable('append', newRow); |
|
|
|
} |
|
|
|
//查询所有的制程工序编号 |
|
|
|
function selectProcessCode(){ |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'quality/manufacturingCheckout/getProcessCodeList', |
|
|
|
type: "post", |
|
|
|
dataType: "json", |
|
|
|
success: function (res) { |
|
|
|
if (res.rows.length > 0) { |
|
|
|
var processData = res.rows; |
|
|
|
processData.forEach(function (process){ |
|
|
|
manufacturingProcessList.push(process.manufacturingProcessCode); |
|
|
|
processNameList.push(process.manufacturingProcessName); |
|
|
|
}) |
|
|
|
}else { |
|
|
|
$.modal.error("数据为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// 重新初始化下拉框列表 |
|
|
|
function initProcessCodeSelector(value, row, index,tableId) { |
|
|
|
var selectHtml = `<select class="form-control" onchange="handleManufacturingProcessChange(this, ${index}, '${tableId}')">`; |
|
|
|
selectHtml += '<option value=""' + (value === undefined || value === '' || value === null ? ' selected' : '') + '>所有</option>'; |
|
|
|
manufacturingProcessList.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child + '"' + (value === child ? ' selected' : '') + '>' + child + '</option>'; |
|
|
|
}); |
|
|
|
selectHtml += '</select>'; |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
|
|
|
|
var unqualifiedRows = iframeWin.$('#bootstrap-unqualifiedClass-table-'+tableId).bootstrapTable('getData'); |
|
|
|
for (var i = 0; i < unqualifiedRows.length; i++) { |
|
|
|
var row = unqualifiedRows[i]; |
|
|
|
// 获取 '不良分类' 列的 <select> 元素的当前值 |
|
|
|
var processBadClassificationValue = iframeWin.$('#bootstrap-unqualifiedClass-table-' + tableId + ' tbody tr:eq(' + i + ') select[name="processBadClassification"]').val(); |
|
|
|
var processBadGradeValue = iframeWin.$('#bootstrap-unqualifiedClass-table-' + tableId + ' tbody tr:eq(' + i + ') select[name="processBadGrade"]').val(); |
|
|
|
|
|
|
|
// 更新原始数据对象 |
|
|
|
row.processBadClassification = processBadClassificationValue; |
|
|
|
row.processBadGrade = processBadGradeValue; |
|
|
|
function handleManufacturingProcessChange(selectElement,index, tableId) { |
|
|
|
var selectedValue = $(selectElement).val(); |
|
|
|
if(checkCodeUnique(selectedValue)){ |
|
|
|
$.modal.msgError("该工序已添加,请重新选择"); |
|
|
|
clearProcessTable(index,tableId); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (selectedValue) { |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'quality/manufacturingProcess/getProcessByCode/' + selectedValue, |
|
|
|
method: 'GET', |
|
|
|
dataType: 'json', |
|
|
|
success: function (response) { |
|
|
|
if (response.data) { |
|
|
|
var newData = response.data; |
|
|
|
var newRowData = { |
|
|
|
manufacturingProcessCode: selectedValue || '', |
|
|
|
manufacturingProcessName: newData.manufacturingProcessName || '', |
|
|
|
deviceName: newData.deviceName || '', |
|
|
|
deviceModelCode: newData.deviceModelCode || '', |
|
|
|
processSequence: newData.processSequence || '', |
|
|
|
workshopName: newData.workshopName || '', |
|
|
|
modName: newData.modName || '', |
|
|
|
processInspectionItem: newData.processInspectionItem || '', |
|
|
|
}; |
|
|
|
// 使用Bootstrap Table的updateRow方法更新表格数据,注意这里使用传入的索引 |
|
|
|
$('#' + tableId).bootstrapTable('updateRow', { |
|
|
|
index: index, // 使用传递进来的索引 |
|
|
|
row: newRowData |
|
|
|
}); |
|
|
|
} else { |
|
|
|
$.modal.msgError('后端请求数据为空'); |
|
|
|
console.error('后端请求数据为空'); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function (xhr, status, error) { |
|
|
|
console.error('请求出错:', status, ", ", error); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
// 删除物料的一行数据 |
|
|
|
function removeRow(materialNo){ |
|
|
|
$("#bootstrap-material-table").bootstrapTable('remove', { |
|
|
|
field: 'materialNo', |
|
|
|
values: materialNo |
|
|
|
}) |
|
|
|
} |
|
|
|
//刪除制程检验工序 |
|
|
|
function removeProcess(uniqueId){ |
|
|
|
$("#div_"+uniqueId).remove(); |
|
|
|
// 从 uniqueIdList 中移除 uniqueId |
|
|
|
var index = uniqueIdList.indexOf(uniqueId); |
|
|
|
if (index > -1) { |
|
|
|
uniqueIdList.splice(index, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
//删除不良分类 |
|
|
|
function removeUnqualifiedClassRow(unqualifiedClassId,tableId,processBadNum) { |
|
|
|
$("#"+tableId).bootstrapTable('remove', { |
|
|
|
field: 'unqualifiedClassId', |
|
|
|
values: unqualifiedClassId |
|
|
|
}); |
|
|
|
//物料主表减去不良数 |
|
|
|
updateUnqualifiedNum(); |
|
|
|
} |
|
|
|
|
|
|
|
var unquilifiedClass = { |
|
|
|
processBadClassification: row.processBadClassification, |
|
|
|
processBadGrade: row.processBadGrade, |
|
|
|
processBadNum: row.processBadNum, |
|
|
|
//自定义制程检验名称的初始化函数 |
|
|
|
function manufacturingProcessNameFormatter(value, row, index,tableId){ |
|
|
|
var selectHtml = `<select class="form-control" onchange="onManufacturingProcessName(this, ${index}, '${tableId}')">`; |
|
|
|
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>'; |
|
|
|
processNameList.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child + '"' + (value === child ? ' selected' : '') + '>' + child + '</option>'; |
|
|
|
}); |
|
|
|
selectHtml += '</select>'; |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
var processBadNum = Number(row.processBadNum); |
|
|
|
if(!isNaN(processBadNum)){ |
|
|
|
processUnqualifiedNum += processBadNum; |
|
|
|
function onManufacturingProcessName(selectElement, rowIndex,tableId) { |
|
|
|
var manufacturingProcessNameValue = $(selectElement).val(); |
|
|
|
if(checkNameUnique(manufacturingProcessNameValue)){ |
|
|
|
$.modal.msgError("该工序已添加,请重新选择"); |
|
|
|
clearProcessTable(rowIndex,tableId); |
|
|
|
return; |
|
|
|
} |
|
|
|
materialProcess.unqualifiedClassList.push(unquilifiedClass); |
|
|
|
console.log(materialProcess); |
|
|
|
if (manufacturingProcessNameValue) { |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'quality/manufacturingProcess/getProcessByName', |
|
|
|
method: 'GET', |
|
|
|
dataType: 'json', |
|
|
|
data:{manufacturingProcessName: manufacturingProcessNameValue}, |
|
|
|
success: function(response) { |
|
|
|
if (response.data) { |
|
|
|
var newData = response.data; |
|
|
|
var newRowData = { |
|
|
|
manufacturingProcessCode: newData.manufacturingProcessCode || '', |
|
|
|
manufacturingProcessName: manufacturingProcessNameValue || '', |
|
|
|
deviceName: newData.deviceName || '', |
|
|
|
deviceModelCode: newData.deviceModelCode || '', |
|
|
|
processSequence: newData.processSequence || '', |
|
|
|
workshopName: newData.workshopName || '', |
|
|
|
modName: newData.modName || '', |
|
|
|
processInspectionItem: newData.processInspectionItem || '', |
|
|
|
}; |
|
|
|
// 使用Bootstrap Table的updateRow方法更新表格数据,注意这里使用传入的索引 |
|
|
|
$('#' + tableId).bootstrapTable('updateRow', { |
|
|
|
index: rowIndex, // 使用传递进来的索引 |
|
|
|
row: newRowData |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('后端请求数据为空'); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, status, error) { |
|
|
|
console.error('请求出错:', status, ", ", error); |
|
|
|
} |
|
|
|
materialProcessList.push(materialProcess); |
|
|
|
}); |
|
|
|
// console.log("processQualifiedNum: "+processQualifiedNum); |
|
|
|
// console.log("processUnqualifiedNum: "+processUnqualifiedNum); |
|
|
|
var newData = { |
|
|
|
processQualifiedNum: processQualifiedNum, |
|
|
|
processUnqualifiedNum: processUnqualifiedNum, |
|
|
|
} |
|
|
|
updateRowByMaterialNo(materialNo,newData); |
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|
// 自定义不良分类的初始化函数 |
|
|
|
function processBadClassificationFormatter(value, row, index,tableId) { |
|
|
|
var selectHtml = `<select class="form-control" onchange="onProcessBadClassification(this, ${index}, '${tableId}')">`; |
|
|
|
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>'; |
|
|
|
processBadClassificationDatas.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child.dictValue + '"' + (value === child.dictValue ? ' selected' : '') + '>' + child.dictLabel + '</option>'; |
|
|
|
}); |
|
|
|
selectHtml += '</select>'; |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
// 列中获取不良分类的下拉改变数据 |
|
|
|
function onProcessBadClassification(selectElement, rowIndex, tableId) { |
|
|
|
var processBadClassificationValue = $(selectElement).val(); |
|
|
|
var tableData = $("#"+tableId).bootstrapTable('getData'); |
|
|
|
var newRow = tableData[rowIndex]; // 获取当前行数据 |
|
|
|
// 更新行数据 |
|
|
|
newRow.processBadClassification = processBadClassificationValue; |
|
|
|
$("#"+tableId).bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
} |
|
|
|
// 自定义不良等级的格式化函数 |
|
|
|
function processBadGradeFormatter(value, row, index, tableId) { |
|
|
|
var selectHtml = `<select class="form-control" onchange="onProcessBadGrade(this, ${index}, '${tableId}')">`; |
|
|
|
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>'; |
|
|
|
processBadGradeDatas.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child.dictValue + '"' + (value === child.dictValue ? ' selected' : '') + '>' + child.dictLabel + '</option>'; |
|
|
|
}); |
|
|
|
selectHtml += '</select>'; |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
// 列中获取不良等级的下拉改变数据 |
|
|
|
function onProcessBadGrade(selectElement, rowIndex,tableId) { |
|
|
|
var processBadGradeValue = $(selectElement).val(); |
|
|
|
var tableData = $("#"+tableId).bootstrapTable('getData'); |
|
|
|
var newRow = tableData[rowIndex]; // 获取当前行数据 |
|
|
|
// 重新渲染成本小类的设备名称列 |
|
|
|
// 更新行数据 |
|
|
|
newRow.processBadGrade = processBadGradeValue; |
|
|
|
$("#"+tableId).bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
} |
|
|
|
|
|
|
|
/*检验报告*/ |
|
|
|
function checkoutReport(materialNo){ |
|
|
|
var makeNo = $('#makeNo').val(); //获取生产编号下拉框元素 |
|
|
|
var url = ctx + 'quality/manufacturingCheckout/checkoutReport/' + materialNo+'/'+makeNo; |
|
|
|
var options = { |
|
|
|
title: '制程检验报告', |
|
|
|
url: url, |
|
|
|
callBack: handleCheckoutReportData |
|
|
|
//特采让步数监听函数 |
|
|
|
//OK允收数监听函数 |
|
|
|
function okAcceptedHandler(){ |
|
|
|
var tableId = "bootstrap-material-table"; |
|
|
|
const okInputs = $("input[name='okAcceptedNum']"); |
|
|
|
const specialInputs = $("input[name='specialConcessionsNum']"); |
|
|
|
let sum = 0; |
|
|
|
// 遍历所有输入框 |
|
|
|
for (let i = 0; i < okInputs.length; i++) { |
|
|
|
const value = parseInt(okInputs[i].value); |
|
|
|
const specialValue = parseInt(specialInputs[i].value); |
|
|
|
if (!isNaN(value)&&!isNaN(specialValue)) { |
|
|
|
sum = sum + value + specialValue; |
|
|
|
} |
|
|
|
} |
|
|
|
var tableData = $("#"+tableId).bootstrapTable('getData')[0]; |
|
|
|
tableData.processQualifiedNum = sum; |
|
|
|
$("#"+tableId).bootstrapTable('updateRow', {index: 0, row: tableData}); |
|
|
|
} |
|
|
|
|
|
|
|
//校验工序编号是否唯一 |
|
|
|
function checkCodeUnique(selectedCode){ |
|
|
|
var processCodeList = []; |
|
|
|
$(".bordered-container").each(function (index,container){ |
|
|
|
var tableId = "bootstrap-manufacturingProcess-table-"+uniqueIdList[index]; |
|
|
|
var processDatas = $("#"+tableId).bootstrapTable("getData")[0]; |
|
|
|
processCodeList.push(processDatas.manufacturingProcessCode); |
|
|
|
}) |
|
|
|
return processCodeList.includes(selectedCode); |
|
|
|
} |
|
|
|
//校验工序名称是否唯一 |
|
|
|
function checkNameUnique(selectedName){ |
|
|
|
var processNameList = []; |
|
|
|
$(".bordered-container").each(function (index,container){ |
|
|
|
var tableId = "bootstrap-manufacturingProcess-table-"+uniqueIdList[index]; |
|
|
|
var processDatas = $("#"+tableId).bootstrapTable("getData")[0]; |
|
|
|
processNameList.push(processDatas.manufacturingProcessName); |
|
|
|
}) |
|
|
|
return processNameList.includes(selectedName); |
|
|
|
} |
|
|
|
//清空检验工序表格 |
|
|
|
function clearProcessTable(rowIndex,tableId){ |
|
|
|
var newRowData = { |
|
|
|
manufacturingProcessCode: '', |
|
|
|
manufacturingProcessName: '', |
|
|
|
deviceName: '', |
|
|
|
deviceModelCode: '', |
|
|
|
processSequence: '', |
|
|
|
workshopName: '', |
|
|
|
modName: '', |
|
|
|
processInspectionItem: '', |
|
|
|
}; |
|
|
|
$.modal.openOptions(options); |
|
|
|
$('#' + tableId).bootstrapTable('updateRow', { |
|
|
|
index: rowIndex, |
|
|
|
row: newRowData |
|
|
|
}); |
|
|
|
} |
|
|
|
//更新物料表格工序不合格数 |
|
|
|
function updateUnqualifiedNum(){ |
|
|
|
var unqualifiedNum = 0; |
|
|
|
uniqueIdList.forEach(function (uniqueId){ |
|
|
|
var unqualifiedTableId = "bootstrap-unqualifiedClass-table-" + uniqueId; |
|
|
|
var unqualifyList = $("#"+unqualifiedTableId).bootstrapTable("getData"); |
|
|
|
if(unqualifyList.length>0){ |
|
|
|
unqualifyList.forEach(function (unqualify){ |
|
|
|
unqualifiedNum += Number(unqualify.processBadNum == ''?0:unqualify.processBadNum); |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
var newRow = { |
|
|
|
processUnqualifiedNum: unqualifiedNum, |
|
|
|
} |
|
|
|
$('#bootstrap-material-table').bootstrapTable('updateRow', { |
|
|
|
index: 0, |
|
|
|
row: newRow |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |