Browse Source
退换货 新增确认收货-入库前退货beforeConfirmDelivery.html页面 新增 确认收货-入库前退货按钮 新增 确认收货-入库前退货查询接口 新增确认收货-入库前退货修改保存接口 beforeConfirmDelivery.html新增收货状态字段 退换货新增收货状态字段 退换货详情收货状态字段 数据字典新增退换货收货状态quality_delivery_statusdev
liuxiaoxu
5 months ago
9 changed files with 382 additions and 7 deletions
@ -0,0 +1,275 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<head> |
|||
<th:block th:include="include :: header('确认收货-入库前退货')" /> |
|||
<th:block th:include="include :: datetimepicker-css" /> |
|||
<style> |
|||
|
|||
.supplier-value span { |
|||
margin-right: 10px; |
|||
} |
|||
|
|||
</style> |
|||
</head> |
|||
<body class="white-bg"> |
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|||
<form class="form-horizontal m" id="form-beforeConfirmDelivery-edit" th:object="${qualityRefundsExchanges}"> |
|||
<input name="refundsExchangesId" th:field="*{refundsExchangesId}" type="hidden"> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">退换货单号:</label> |
|||
<div class="col-sm-8"> |
|||
<input name="refundsExchangesCode" th:field="*{refundsExchangesCode}" class="form-control" type="text" disabled> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">关联单号:</label> |
|||
<div class="col-sm-8"> |
|||
<input name="relatedOrderCode" th:field="*{relatedOrderCode}" class="form-control" type="text" disabled> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">品质备注:</label> |
|||
<div class="col-sm-8"> |
|||
<input name="qualityRemark" th:field="*{qualityRemark}" class="form-control" type="text" disabled> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="container"> |
|||
<!--供应商物料相关--> |
|||
<div class="row"> |
|||
<div class="col-sm-12" id="tablesContainer"> |
|||
<!-- 表格将在这里动态生成 --> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<th:block th:include="include :: footer" /> |
|||
<th:block th:include="include :: datetimepicker-js" /> |
|||
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|||
<script th:inline="javascript"> |
|||
|
|||
var refundsExchangesCode = [[${qualityRefundsExchanges.refundsExchangesCode}]] |
|||
|
|||
var qualityDeliveryStatusDatas = [[${@dict.getType('quality_delivery_status')}]]; |
|||
var prefix = ctx + "quality/refundsExchanges"; |
|||
$("#form-beforeConfirmDelivery-edit").validate({ |
|||
focusCleanup: true |
|||
}); |
|||
//生成的不同table的id集合 |
|||
var tableDatas = []; |
|||
|
|||
function submitHandler() { |
|||
const storageOrderData = $("#form-beforeConfirmDelivery-edit").serializeArray().reduce((obj, item) => { |
|||
obj[item.name] = item.value; |
|||
return obj; |
|||
}, {}); |
|||
// 初始化一个数组用于存放所有表格的数据 |
|||
let allMaterialDataList = []; |
|||
for(let i in tableDatas){ |
|||
$('#' + tableDatas[i]).each(function() { |
|||
const tableData = $(this).bootstrapTable('getData'); |
|||
console.log(JSON.stringify(tableData)); |
|||
// 将表数据转换成与qualityReportData格式一致的数组 |
|||
var materialDataList = tableData.map(function (item) { |
|||
// 根据实际字段名调整 |
|||
return { |
|||
"refundsExchangesDetailId":item.refundsExchangesDetailId, |
|||
"supplierCode": item.supplierCode, |
|||
"materialNo": item.materialNo, |
|||
"materialName": item.materialName, |
|||
"materialType": item.materialType, |
|||
"materialPhotourl": item.materialPhotourl, |
|||
"materialDescribe": item.materialDescribe, |
|||
"materialBrand": item.materialBrand, |
|||
"materialUnit": item.materialUnit, |
|||
"materialProcessMethod": item.materialProcessMethod, |
|||
"makeTotal": item.makeTotal, |
|||
"qualityHasqualifiedNum": item.qualityHasqualifiedNum, |
|||
"thisArrivedNum": item.thisArrivedNum, |
|||
"qualityUnqualifiedNum": item.qualityUnqualifiedNum, |
|||
"qualityDeliveryStatus": item.qualityDeliveryStatus, |
|||
// ...其他字段 |
|||
}; |
|||
}); |
|||
allMaterialDataList = allMaterialDataList.concat(materialDataList); |
|||
}); |
|||
} |
|||
|
|||
const combinedData = Object.assign({}, storageOrderData, { |
|||
refundsExchangesDetails: allMaterialDataList |
|||
}); |
|||
// 合并表单数据和表格数据 |
|||
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData); |
|||
console.log(combinedData) |
|||
// 使用 JSON.stringify() 序列化数据 |
|||
const jsonData = JSON.stringify(combinedData); |
|||
// 发送 AJAX 请求到后端接口 |
|||
$.operate.saveJson(prefix + "/beforeConfirmDelivery", jsonData); |
|||
} |
|||
|
|||
$(function() { |
|||
// 假设refundsExchangesCode已经定义或者可以通过某种方式获取到 |
|||
var refundsExchangesCode = [[${qualityRefundsExchanges.refundsExchangesCode}]]; // 这里需要实际赋值,比如从前端某个地方读取 |
|||
|
|||
$.getJSON(prefix + "/detailListGroupedBySupplier?refundsExchangesCode=" + refundsExchangesCode, function(data) { |
|||
for (var supplierCode in data) { |
|||
if (data.hasOwnProperty(supplierCode)) { |
|||
var supplierData = data[supplierCode]; |
|||
createTableForSupplier(supplierCode, supplierData); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
function createTableForSupplier(supplierCode, supplierData) { |
|||
var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase(); |
|||
tableDatas.push(tableId); |
|||
var $tableWrapper = $('<div class="table-responsive mt-3"></div>'); |
|||
|
|||
// 确保supplierData至少有一条记录,并从中提取供应商详细信息 |
|||
var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在 |
|||
|
|||
// 构建含有额外供应商信息的标题字符串 |
|||
var headerTitle ='供应商'+'</br>'+supplierCode + ' - ' + (supplierInfo.supplierName || 'N/A') + |
|||
' </br> ' + (supplierInfo.customerContact || 'N/A') + |
|||
' - ' + (supplierInfo.contactNumber || 'N/A') + |
|||
' - ' + (supplierInfo.supplierAddress || 'N/A'); |
|||
|
|||
var $header = $('<h4>' + headerTitle + '</h4>'); |
|||
var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>'); |
|||
|
|||
$table.bootstrapTable({ |
|||
data: supplierData, |
|||
columns: [{ |
|||
checkbox: true |
|||
}, |
|||
{ |
|||
title: '供应商ID', |
|||
field: 'supplierCode', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '退换货详情ID', |
|||
field: 'refundsExchangesDetailId', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '料号', |
|||
field: 'materialNo' |
|||
}, { |
|||
title: '物料名称', |
|||
field: 'materialName' |
|||
}, |
|||
{ |
|||
title: '物料类型', |
|||
field: 'materialType', |
|||
}, |
|||
{ |
|||
title: '物料图片地址', |
|||
field: 'materialPhotourl', |
|||
}, |
|||
{ |
|||
title: '物料描述', |
|||
field: 'materialDescribe', |
|||
}, |
|||
{ |
|||
title: '物料品牌', |
|||
field: 'materialBrand', |
|||
}, |
|||
{ |
|||
title: '物料单位', |
|||
field: 'materialUnit', |
|||
}, |
|||
{ |
|||
title: '物料加工方式', |
|||
field: 'materialProcessMethod', |
|||
}, |
|||
{ |
|||
title: '订单数', |
|||
field: 'makeTotal', |
|||
}, |
|||
{ |
|||
title: '品质已合格数', |
|||
field: 'qualityHasqualifiedNum', |
|||
}, |
|||
{ |
|||
title: '本次到货数', |
|||
field: 'thisArrivedNum', |
|||
}, |
|||
{ |
|||
title: '品质报告', |
|||
align: 'center', |
|||
formatter: function(value, row, index) { |
|||
// 这里直接使用row对象获取supplierCode,假设它是存在的 |
|||
var actions = []; |
|||
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="qualityReport(\'' + row.materialNo + '\', \'' + row.supplierCode + '\')"><i class="fa fa-plus"></i>报告</a> '); |
|||
return actions.join(''); |
|||
} |
|||
}, |
|||
{ |
|||
title: '品质不合格数', |
|||
field: 'qualityUnqualifiedNum', |
|||
}, |
|||
{title: '收货状态',field: 'qualityDeliveryStatus', |
|||
formatter:function (value, row, index) { |
|||
return qualityDeliveryStatusFormatter(value,row,index); |
|||
} |
|||
}, |
|||
] |
|||
}); |
|||
|
|||
$tableWrapper.append($header).append($table); |
|||
$('#tablesContainer').append($tableWrapper); |
|||
$table.on('change', '.form-control', onQualityDeliveryStatus); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/*品质报告*/ |
|||
function qualityReport(materialNo, supplierCode) { |
|||
var queryParams = new URLSearchParams(); |
|||
queryParams.append('materialNo', materialNo); |
|||
queryParams.append('supplierCode', encodeURIComponent(supplierCode)); |
|||
|
|||
var url = ctx + 'quality/qualityOrder/qualityReport?' + queryParams.toString(); |
|||
$.modal.open("品质报告", url); |
|||
} |
|||
|
|||
// 列中获取收货状态下拉改变数据 |
|||
function onQualityDeliveryStatus(event) { |
|||
var selectElement = event.target; // 直接从事件对象获取select元素 |
|||
var rowIndex = $(selectElement).closest('tr').index(); // 获取当前行索引 |
|||
var table = $(selectElement).closest('.table'); // 获取最近的.table父元素,即当前表格 |
|||
var tableId = table.attr('id'); // 获取当前表格的ID |
|||
var qualityDeliveryStatusValue = $(selectElement).val(); |
|||
|
|||
// 确保tableId在tableDatas中,然后根据tableId和rowIndex更新数据 |
|||
if (tableDatas.includes(tableId)) { |
|||
var tableData = table.bootstrapTable('getData'); |
|||
var newRow = tableData[rowIndex]; |
|||
newRow.qualityDeliveryStatus = qualityDeliveryStatusValue; |
|||
table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|||
} else { |
|||
console.error("Table ID not found in tableDatas array."); |
|||
} |
|||
} |
|||
|
|||
// 自定义收货状态的格式化函数 |
|||
function qualityDeliveryStatusFormatter(value, row, index) { |
|||
var selectHtml = '<select class="form-control" onchange="onQualityDeliveryStatus(this, ' + index + ')">'; |
|||
|
|||
// 添加默认选项 |
|||
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>'; |
|||
|
|||
qualityDeliveryStatusDatas.forEach(function (child) { |
|||
selectHtml += '<option value="' + child.dictValue + '"' + (value === child.dictValue ? ' selected' : '') + '>' + child.dictLabel + '</option>'; |
|||
}); |
|||
|
|||
selectHtml += '</select>'; |
|||
return selectHtml; |
|||
} |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue