Browse Source

[feat]

品质管理 制程检验
修改添加制程检验页面,检验报告跳转方法新增回调函数;
新增处理子页面提交数据拼接方法;
新增按料号查找更新表格数据方法;
修改页面提交函数,新增物料工序拼接语句;
制程检验报告
新增制程检验报告页面表单元素记录工序表ID列表;
补全制程工序表格内缺少字段;
修改制程工序编号下拉框监听函数;
新增重新初始化下拉框列表方法;
修改根据下拉框选择填充制程工序表格数据方法;
dev
王晓迪 3 months ago
parent
commit
cade08d55d
  1. 121
      ruoyi-admin/src/main/resources/templates/quality/manufacturingCheckout/add.html
  2. 145
      ruoyi-admin/src/main/resources/templates/quality/manufacturingCheckout/checkoutReport.html

121
ruoyi-admin/src/main/resources/templates/quality/manufacturingCheckout/add.html

@ -47,7 +47,10 @@
<!--用于可以修改列表字段的插件--> <!--用于可以修改列表字段的插件-->
<th:block th:include="include :: bootstrap-table-editable-js" /> <th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "quality/manufacturingCheckout" var prefix = ctx + "quality/manufacturingCheckout";
var checkoutProcessList = [];
var materialProcessList = [];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
$("#form-manufacturingCheckout-add").validate({ $("#form-manufacturingCheckout-add").validate({
focusCleanup: true focusCleanup: true
}); });
@ -67,7 +70,7 @@
$.modal.alertWarning("请至少添加一条物料数据后再保存!"); $.modal.alertWarning("请至少添加一条物料数据后再保存!");
return; return;
} }
console.log(table); // console.log(table);
// 将表数据转换成与complaintNoticeData格式一致的数组 // 将表数据转换成与complaintNoticeData格式一致的数组
var materialDataList = table.map(function(item) { var materialDataList = table.map(function(item) {
// 根据实际字段名调整 // 根据实际字段名调整
@ -79,6 +82,7 @@
"materialUnit": item.materialUnit, "materialUnit": item.materialUnit,
"materialBrand": item.materialBrand, "materialBrand": item.materialBrand,
"materialDescribe": item.materialDescribe, "materialDescribe": item.materialDescribe,
"materialProcessMethod": item.materialProcessMethod,
"makeTotal": item.makeTotal, "makeTotal": item.makeTotal,
"checkedNum": item.checkedNum, "checkedNum": item.checkedNum,
"currentCheckoutNum": item.currentCheckoutNum, "currentCheckoutNum": item.currentCheckoutNum,
@ -87,7 +91,14 @@
// ...其他字段 // ...其他字段
}; };
}); });
materialDataList.forEach(function(item) {
item.materialProcessList = [];
materialProcessList.forEach(function (process){
if(process.materialNo === item.materialNo){
item.materialProcessList.push(process);
}
})
});
const combinedData = Object.assign({}, manufacturingCheckoutData, { checkoutMaterialList: materialDataList }); const combinedData = Object.assign({}, manufacturingCheckoutData, { checkoutMaterialList: materialDataList });
// 合并表单数据和表格数据 // 合并表单数据和表格数据
console.log(combinedData) console.log(combinedData)
@ -174,6 +185,9 @@
{ {
title: '物料加工方式', title: '物料加工方式',
field: 'materialProcessMethod', field: 'materialProcessMethod',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
}, },
{ {
title: '订单数', title: '订单数',
@ -255,12 +269,28 @@
materialBrand: rowData.materialBrand, materialBrand: rowData.materialBrand,
materialUnit: rowData.materialUnit, materialUnit: rowData.materialUnit,
materialProcessMethod: rowData.materialProcessMethod, materialProcessMethod: rowData.materialProcessMethod,
makeTotal:rowData.makeTotal makeTotal:rowData.makeTotal,
currentCheckoutNum: ""
} }
}) })
layer.close(index); layer.close(index);
} }
// 按料号查找更新表格数据
function updateRowByMaterialNo(materialNo, newData) {
// 获取所有行的数据
var rows = $('#bootstrap-table').bootstrapTable('getData');
for (var i = 0; i < rows.length; i++) {
if (rows[i].materialNo === materialNo) {
rows[i] = Object.assign({}, rows[i], newData); // 合并新旧数据
$('#bootstrap-table').bootstrapTable('updateRow', {
index: i,
row: rows[i]
});
}
}
}
// 逻辑删除前端的一行数据 // 逻辑删除前端的一行数据
function removeRow(materialNo){ function removeRow(materialNo){
$("#bootstrap-table").bootstrapTable('remove', { $("#bootstrap-table").bootstrapTable('remove', {
@ -269,12 +299,93 @@
}) })
} }
// 在父页面中定义处理函数
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();
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 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;
var unquilifiedClass = {
processBadClassification: row.processBadClassification,
processBadGrade: row.processBadGrade,
processBadNum: row.processBadNum,
}
var processBadNum = Number(row.processBadNum);
if(!isNaN(processBadNum)){
processUnqualifiedNum += processBadNum;
}
materialProcess.unqualifiedClassList.push(unquilifiedClass);
console.log(materialProcess);
}
materialProcessList.push(materialProcess);
});
// console.log("processQualifiedNum: "+processQualifiedNum);
// console.log("processUnqualifiedNum: "+processUnqualifiedNum);
var newData = {
processQualifiedNum: processQualifiedNum,
processUnqualifiedNum: processUnqualifiedNum,
}
updateRowByMaterialNo(materialNo,newData);
layer.close(index);
}
/*检验报告*/ /*检验报告*/
function checkoutReport(materialNo){ function checkoutReport(materialNo){
var makeNo = $('#makeNo').val(); //获取生产编号下拉框元素 var makeNo = $('#makeNo').val(); //获取生产编号下拉框元素
var url = ctx + 'quality/manufacturingCheckout/checkoutReport/' + materialNo+'/'+makeNo; var url = ctx + 'quality/manufacturingCheckout/checkoutReport/' + materialNo+'/'+makeNo;
$.modal.open("制程检验报告",url); var options = {
title: '制程检验报告',
url: url,
callBack: handleCheckoutReportData
};
$.modal.openOptions(options);
} }
</script> </script>
</body> </body>

145
ruoyi-admin/src/main/resources/templates/quality/manufacturingCheckout/checkoutReport.html

@ -30,7 +30,7 @@
</head> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-checkoutMaterial-edit" th:object="${qualityManufacturingCheckoutMaterial}"> <form class="form-horizontal m" id="form-checkoutReport-add" th:object="${qualityManufacturingCheckoutMaterial}">
<input name="manufacturingCheckoutMaterialId" th:field="*{manufacturingCheckoutMaterialId}" type="hidden"> <input name="manufacturingCheckoutMaterialId" th:field="*{manufacturingCheckoutMaterialId}" type="hidden">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">料号:</label> <label class="col-sm-3 control-label">料号:</label>
@ -57,6 +57,10 @@
</div> </div>
</div> </div>
<div class="form-group" hidden="hidden">
<input id="uniqueIdList" name="uniqueIdList" class="form-control" type="text">
</div>
<div class="container mt-5"> <div class="container mt-5">
<div class="btn-group-sm"> <div class="btn-group-sm">
<span>选择制程工序</span> <span>选择制程工序</span>
@ -78,36 +82,20 @@
var manufacturingProcessNameDatas = [[${@dict.getType('manufacturing_process_name')}]]; var manufacturingProcessNameDatas = [[${@dict.getType('manufacturing_process_name')}]];
var processBadClassificationDatas = [[${@dict.getType('process_bad_classification')}]]; var processBadClassificationDatas = [[${@dict.getType('process_bad_classification')}]];
var processBadGradeDatas = [[${@dict.getType('process_bad_grade')}]]; var processBadGradeDatas = [[${@dict.getType('process_bad_grade')}]];
var prefix = ctx + "quality/checkoutMaterial"; var prefix = ctx + "quality/manufacturingCheckout";
var uniqueIdList = [];
var manufacturingProcessList = [];
var materialProcessList = [];
$("#form-checkoutMaterial-edit").validate({focusCleanup: true}); $("#form-checkoutReport-add").validate({focusCleanup: true});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-checkoutMaterial-edit').serialize());
}
}
$("input[name='checkoutTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
$("input[name='checkoutCompletionTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
function insertRow() { function insertRow() {
var currentTimeStamp = new Date().getTime(); // 获取当前时间的时间戳 var currentTimeStamp = new Date().getTime(); // 获取当前时间的时间戳
var uniqueId = "ID_" + currentTimeStamp; // 为ID添加前缀并使用时间戳 var uniqueId = "ID_" + currentTimeStamp; // 为ID添加前缀并使用时间戳
console.log(uniqueId); uniqueIdList.push(uniqueId);
$('#uniqueIdList').val(uniqueIdList);
// console.log(uniqueId);
var newItem = var newItem =
"<div class='container bordered-container'>" + "<div class='container bordered-container'>" +
"<div class='col-sm-12 my-3'>" + "<div class='col-sm-12 my-3'>" +
@ -121,11 +109,11 @@
'<form id="form-manfa-'+ uniqueId +'"> ' + '<form id="form-manfa-'+ uniqueId +'"> ' +
"<div class='form-group'> "+ "<div class='form-group'> "+
"<label for='okAcceptedNum'>OK允收数:</label>" + "<label for='okAcceptedNum'>OK允收数:</label>" +
"<input type='text' class='form-control' id='okAcceptedNum'>"+ "<input type='text' class='form-control' id='okAcceptedNum' name='okAcceptedNum'>"+
"</div>"+ "</div>"+
" <div class='form-group'> "+ " <div class='form-group'> "+
"<label for='qualifiedNum'>特采/让步数:</label>" + "<label for='qualifiedNum'>特采/让步数:</label>" +
"<input type='text' class='form-control' id='specialConcessionsNum' >"+ "<input type='text' class='form-control' id='specialConcessionsNum' name='specialConcessionsNum'>"+
"</div>"+ "</div>"+
"</form>"+ "</form>"+
"</div>" + "</div>" +
@ -161,7 +149,7 @@
formatter: function (value, row, index) { formatter: function (value, row, index) {
var tableId = bootstarpId; var tableId = bootstarpId;
var selectId = 'select-manufacturingProcess-' + uniqueId; var selectId = 'select-manufacturingProcess-' + uniqueId;
var td = '<select onchange="handleManufacturingProcessChange(this, \'' + tableId + '\',\'' + selectId + '\',\'' + row + '\',\'' + index + '\')" name="manufacturingProcessCode" id="' + selectId + '"></select>'; var td = '<select class="form-control" onchange="handleManufacturingProcessChange(this, \'' + tableId + '\',\'' + selectId + '\',\'' + index + '\')" name="manufacturingProcessCode" id="' + selectId + '"></select>';
// 这里不需要直接调用selectProcess,而是在用户交互时由事件处理 // 这里不需要直接调用selectProcess,而是在用户交互时由事件处理
return td; return td;
} }
@ -169,7 +157,9 @@
{ {
title: '制程工序名称', title: '制程工序名称',
field: 'manufacturingProcessName', field: 'manufacturingProcessName',
formatter:function (index,row,value){
return $.common.dictToSelect(manufacturingProcessNameDatas,value,'manufacturingProcessName');
}
}, },
{ {
title: '设备名称', title: '设备名称',
@ -191,7 +181,10 @@
title: '零件名称', title: '零件名称',
field: 'modName', field: 'modName',
}, },
{
title: '工序检验项目',
field: 'processInspectionItem',
},
{ {
title: '操作', title: '操作',
align: 'center', align: 'center',
@ -264,7 +257,7 @@
modName: '' modName: ''
} }
}); });
selectProcessCode(); selectProcessCode(bootstarpId);
}; };
// 新增 insertUnqualifiedRow 函数 // 新增 insertUnqualifiedRow 函数
function insertUnqualifiedRow(tableId) { function insertUnqualifiedRow(tableId) {
@ -282,18 +275,23 @@
} }
//查询所有的制程工序编号 //查询所有的制程工序编号
function selectProcessCode(){ function selectProcessCode(tableId){
$.ajax({ $.ajax({
url: ctx + 'quality/manufacturingCheckout/getProcessCodeList', url: ctx + 'quality/manufacturingCheckout/getProcessCodeList',
type: "post", type: "post",
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
console.log(res); // console.log(res);
var $select = $('#' + tableId).find('select[name="manufacturingProcessCode"]');
$select.empty();
$select.append(
"<option value=''>" + '请选择' + "</option>");
if (res.rows.length > 0) { if (res.rows.length > 0) {
var usertData = res.rows; var usertData = res.rows;
for (let i in usertData) { for (let i in usertData) {
$("select[name='manufacturingProcessCode']").append( $select.append(
"<option value='" + usertData[i].manufacturingProcessCode + "'>" + usertData[i].manufacturingProcessCode + "</option>"); "<option value='" + usertData[i].manufacturingProcessCode + "'>" + usertData[i].manufacturingProcessCode + "</option>");
manufacturingProcessList.push(usertData[i].manufacturingProcessCode);
} }
}else { }else {
$.modal.error("数据为空"); $.modal.error("数据为空");
@ -301,7 +299,17 @@
} }
}); });
} }
// 重新初始化下拉框列表
function initSelector(tableId) {
var $select = $('#' + tableId).find('select[name="manufacturingProcessCode"]');
console.log($select);
$select.empty();
$select.append("<option value=''>" + '请选择' + "</option>");
for (let i in manufacturingProcessList) {
$select.append(
"<option value='" + manufacturingProcessList[i] + "'>" + manufacturingProcessList[i] + "</option>");
}
}
// 新增一个处理制程工序编号下拉改变的函数 // 新增一个处理制程工序编号下拉改变的函数
// function handleManufacturingProcessChange(selectElement, tableId,selectId,row) { // function handleManufacturingProcessChange(selectElement, tableId,selectId,row) {
@ -317,7 +325,7 @@
// } // }
function handleManufacturingProcessChange(selectElement, tableId, selectId, row,index) { function handleManufacturingProcessChange(selectElement, tableId, selectId, index) {
var selectedValue = $(selectElement).val(); var selectedValue = $(selectElement).val();
if (selectedValue) { if (selectedValue) {
$.ajax({ $.ajax({
@ -334,15 +342,21 @@
deviceModelCode: newData.deviceModelCode || '', deviceModelCode: newData.deviceModelCode || '',
processSequence: newData.processSequence || '', processSequence: newData.processSequence || '',
workshopName: newData.workshopName || '', workshopName: newData.workshopName || '',
modName: newData.modName || '' modName: newData.modName || '',
processInspectionItem: newData.processInspectionItem || '',
}; };
var processName = newData.manufacturingProcessName;
// 使用Bootstrap Table的updateRow方法更新表格数据,注意这里使用传入的索引 // 使用Bootstrap Table的updateRow方法更新表格数据,注意这里使用传入的索引
$('#' + tableId).bootstrapTable('updateRow', { $('#' + tableId).bootstrapTable('updateRow', {
index: index, // 使用传递进来的索引 index: index, // 使用传递进来的索引
row: newRowData row: newRowData
}); });
// $('#' + tableId).find('select[name="manufacturingProcessCode"]').val(selectedValue); // 重新初始化下拉框
initSelector(tableId);
// 下拉框赋值
$('#' + tableId).find('select[name="manufacturingProcessCode"]').val(selectedValue);
$('#' + tableId).find('select[name="manufacturingProcessName"]').val(processName);
} else { } else {
console.error('后端请求数据为空'); console.error('后端请求数据为空');
} }
@ -365,12 +379,63 @@
function removeUnqualifiedClassRow(id) { function removeUnqualifiedClassRow(id) {
alert("实施删除不合格分类行操作,id: " + id); // 实现删除逻辑 alert("实施删除不合格分类行操作,id: " + id); // 实现删除逻辑
} }
function selectProcess(tableId,selectId){ function selectProcess(tableId,selectId){
console.log(tableId); console.log(tableId);
console.log(selectId); console.log(selectId);
} }
// function submitHandler() {
// var materialNo = $('#form-checkoutReport-add').find('input[name="materialNo"]').val();
// var materialName = $('#form-checkoutReport-add').find('input[name="materialName"]').val();
// $('.container.bordered-container').each(function(index, tableElement) {
// var tableId = uniqueIdList[index];
// var $processTable = $('#bootstrap-manufacturingProcess-table-'+tableId);
// var rows = $processTable.bootstrapTable('getData');
// var manufacturingProcessCode = $processTable.find('select[name="manufacturingProcessCode"]').val();
//
// var okAcceptedNum = $('#form-manfa-'+tableId).find('input[name="okAcceptedNum"]').val();
// var specialConcessionsNum = $('#form-manfa-'+tableId).find('input[name="specialConcessionsNum"]').val();
// 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,
// okAcceptedNum: okAcceptedNum,
// specialConcessionsNum: specialConcessionsNum,
// unqualifiedClassList: []
// };
// // console.log("okAcceptedNum:"+okAcceptedNum+"specialConcessionsNum:"+specialConcessionsNum);
//
// var unqualifiedRows = $('#bootstrap-unqualifiedClass-table-'+tableId).bootstrapTable('getData');
// for (var i = 0; i < unqualifiedRows.length; i++) {
// var row = unqualifiedRows[i];
// // 获取 '不良分类' 列的 <select> 元素的当前值
// var processBadClassificationValue = $('#bootstrap-unqualifiedClass-table-' + tableId + ' tbody tr:eq(' + i + ') select[name="processBadClassification"]').val();
// var processBadGradeValue = $('#bootstrap-unqualifiedClass-table-' + tableId + ' tbody tr:eq(' + i + ') select[name="processBadGrade"]').val();
//
// // 更新原始数据对象
// row.processBadClassification = processBadClassificationValue;
// row.processBadGrade = processBadGradeValue;
//
// var unquilifiedClass = {
// processBadClassification: row.processBadClassification,
// processBadGrade: row.processBadGrade,
// processBadNum: row.processBadNum,
// }
// materialProcess.unqualifiedClassList.push(unquilifiedClass);
// }
// materialProcessList.push(materialProcess);
// });
// localStorage.setItem('materialProcessList'+materialNo,JSON.stringify(materialProcessList));
// // $.operate.saveJson(prefix + '/checkoutReport',JSON.stringify(materialProcessList));
// }
</script> </script>
</body> </body>
</html> </html>

Loading…
Cancel
Save