|
|
@ -46,8 +46,9 @@ |
|
|
|
<script th:inline="javascript"> |
|
|
|
var prefix = ctx + "quality/refundsExchanges" |
|
|
|
var refundsExchangesCode = /*[[${refundsExchangesCode}]]*/ ''; |
|
|
|
|
|
|
|
|
|
|
|
var processMethodDatas = [[${@dict.getType('processMethod')}]]; |
|
|
|
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; |
|
|
|
var materialUnqualifiedList = []; |
|
|
|
$("#form-refundsExchanges-add").validate({ |
|
|
|
focusCleanup: true |
|
|
|
}); |
|
|
@ -85,6 +86,14 @@ |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
materialDataList.forEach(function (material){ |
|
|
|
var key = 'unqualifiedDataList' + material.materialNo; |
|
|
|
var dataString = sessionStorage.getItem(key); |
|
|
|
if(dataString){ |
|
|
|
var refundsExchangesUnqualifieds = JSON.parse(dataString); |
|
|
|
material.refundsExchangesUnqualifieds = refundsExchangesUnqualifieds; |
|
|
|
} |
|
|
|
}) |
|
|
|
// 将全局变量 refundsExchangesCode 添加到要提交的数据中 |
|
|
|
const combinedData = Object.assign({}, refundsExchangesData, { |
|
|
|
refundsExchangesDetails: materialDataList, |
|
|
@ -132,6 +141,9 @@ |
|
|
|
{ |
|
|
|
title: '图片', |
|
|
|
field: 'materialPhotourl', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.imageView(value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料名称', |
|
|
@ -140,6 +152,9 @@ |
|
|
|
{ |
|
|
|
title: '物料类型', |
|
|
|
field: 'materialType', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '描述', |
|
|
@ -156,6 +171,9 @@ |
|
|
|
{ |
|
|
|
title: '物料加工方式', |
|
|
|
field: 'materialProcessMethod', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectDictLabel(processMethodDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '品质报告', |
|
|
@ -163,7 +181,7 @@ |
|
|
|
formatter: function(value, row, index) { |
|
|
|
// 这里直接使用row对象获取refundsExchangesCode,假设它是存在的 |
|
|
|
var actions = []; |
|
|
|
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="qualityReport(\'' + row.materialNo + '\', \'' + refundsExchangesCode + '\')"><i class="fa fa-plus"></i>报告</a> '); |
|
|
|
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="qualityReport(\'' + row.materialNo + '\', \'' + refundsExchangesCode + '\', \'' + row.hasQualifiedReport + '\')"><i class="fa fa-plus"></i>报告</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
@ -171,6 +189,11 @@ |
|
|
|
title: '退换数', |
|
|
|
field: 'refundsExchangesNum', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '是否含品质报告数据', |
|
|
|
field: 'hasQuolifiedReport', |
|
|
|
visible: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
align: 'center', |
|
|
@ -209,11 +232,13 @@ |
|
|
|
materialPhotourl:rowData.materialPhotourl, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
materialDescribe: rowData.materialDescribe, |
|
|
|
materialBrand: rowData.materialBrand, |
|
|
|
materialUnit: rowData.materialUnit, |
|
|
|
materialProcessMethod: rowData.materialProcessMethod, |
|
|
|
makeTotal:rowData.makeTotal |
|
|
|
materialDescribe: rowData.describe, |
|
|
|
materialBrand: rowData.brand, |
|
|
|
materialUnit: rowData.unit, |
|
|
|
materialProcessMethod: rowData.processMethod, |
|
|
|
makeTotal:rowData.makeTotal, |
|
|
|
refundsExchangesNum: '', |
|
|
|
hasQualifiedReport: 0, |
|
|
|
} |
|
|
|
}) |
|
|
|
layer.close(index); |
|
|
@ -225,17 +250,97 @@ |
|
|
|
field: 'materialNo', |
|
|
|
values: materialNo |
|
|
|
}) |
|
|
|
// 删除该物料品质报告数据 |
|
|
|
var key = 'unqualifiedDataList' + materialNo; |
|
|
|
if (sessionStorage.getItem(key)) { |
|
|
|
sessionStorage.removeItem(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 按料号查找更新表格数据 |
|
|
|
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); // 合并新旧数据 |
|
|
|
console.log(rows[i]); |
|
|
|
$('#bootstrap-table').bootstrapTable('updateRow', { |
|
|
|
index: i, |
|
|
|
row: rows[i] |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 处理品质报告子页面数据 |
|
|
|
function handleQualityReportData(index, layero){ |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var materialNo = iframeWin.$('#materialNo').val(); |
|
|
|
var inspectionTime = iframeWin.$('input[name="inspectionTime"]').val(); |
|
|
|
var remark = iframeWin.$('#remark').val(); |
|
|
|
var refundsExchangesNum = 0; |
|
|
|
|
|
|
|
var table = iframeWin.$('#bootstrap-unqualified-table').bootstrapTable('getData'); |
|
|
|
// 检查表格数据是否为空 |
|
|
|
if (table.length===0){ |
|
|
|
$.modal.alertWarning("请至少添加一条不合格数再保存!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 将表数据转换成与qualityReportData格式一致的数组 |
|
|
|
var unqualifiedDataList = table.map(function(item) { |
|
|
|
// 根据实际字段名调整 |
|
|
|
return { |
|
|
|
"qualityOrderReportId": item.qualityOrderReportId, |
|
|
|
"processBadClassification": item.processBadClassification, |
|
|
|
"processBadGrade": item.processBadGrade, |
|
|
|
"processBadNum": item.processBadNum, |
|
|
|
"unqualifiedReportUrl": item.unqualifiedReportUrl |
|
|
|
// ...其他字段 |
|
|
|
}; |
|
|
|
}); |
|
|
|
unqualifiedDataList.forEach(function (index){ |
|
|
|
index.inspectionTime = inspectionTime; |
|
|
|
index.remark = remark; |
|
|
|
processBadNum = Number(index.processBadNum); |
|
|
|
if (!isNaN(processBadNum) ) { |
|
|
|
refundsExchangesNum += processBadNum; |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
var key = 'unqualifiedDataList' + materialNo; |
|
|
|
if (sessionStorage.getItem(key)) { |
|
|
|
sessionStorage.removeItem(key); |
|
|
|
} |
|
|
|
sessionStorage.setItem(key,JSON.stringify(unqualifiedDataList)); |
|
|
|
var newData = { |
|
|
|
refundsExchangesNum: refundsExchangesNum, |
|
|
|
hasQualifiedReport: '1' |
|
|
|
}; |
|
|
|
updateRowByMaterialNo(materialNo,newData); |
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|
|
|
|
|
/*品质报告*/ |
|
|
|
function qualityReport(materialNo, refundsExchangesCode) { |
|
|
|
function qualityReport(materialNo, refundsExchangesCode, hasQualifiedReport) { |
|
|
|
var queryParams = new URLSearchParams(); |
|
|
|
queryParams.append('materialNo', materialNo); |
|
|
|
queryParams.append('refundsExchangesCode', encodeURIComponent(refundsExchangesCode)); |
|
|
|
|
|
|
|
if(hasQualifiedReport === "0"){ |
|
|
|
// 删除该物料品质报告数据 |
|
|
|
var key = 'unqualifiedDataList' + materialNo; |
|
|
|
if (sessionStorage.getItem(key)) { |
|
|
|
sessionStorage.removeItem(key); |
|
|
|
} |
|
|
|
} |
|
|
|
var url = ctx + 'quality/refundsExchanges/qualityReport?' + queryParams.toString(); |
|
|
|
$.modal.open("品质报告", url); |
|
|
|
var options = { |
|
|
|
title: '品质报告', |
|
|
|
url: url, |
|
|
|
callBack: handleQualityReportData |
|
|
|
}; |
|
|
|
$.modal.openOptions(options); |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|