|
@ -1,46 +1,67 @@ |
|
|
<!DOCTYPE html> |
|
|
<!DOCTYPE html> |
|
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|
|
<head> |
|
|
<head> |
|
|
<th:block th:include="include :: header('修改售后客诉通知单')" /> |
|
|
<th:block th:include="include :: header('品质客诉通知单')" /> |
|
|
</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-complaintNotice-edit" th:object="${aftersalesComplaintNotice}"> |
|
|
<form class="form-horizontal m" id="form-complaintNotice-edit" th:object="${aftersalesComplaintNotice}"> |
|
|
<input name="complaintNoticeCode" th:field="*{complaintNoticeCode}" type="hidden"> |
|
|
<input name="complaintNoticeCode" th:field="*{complaintNoticeCode}" type="hidden"> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-4 control-label">客户编号:</label> |
|
|
<label class="col-sm-4 control-label is-required">SN号:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<select class="form-control" id="customerId" name="customerId" th:field="*{customerId}" onchange="loadMakeNos()" readonly> |
|
|
<input id="snCode" th:field="*{snCode}" name="snCode" class="form-control" type="text" readonly> |
|
|
<!-- 这里动态生成客户编号选项 --> |
|
|
|
|
|
</select> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-4 control-label">客户名称:</label> |
|
|
<label class="col-sm-4 control-label is-required">客户名称:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<input name="customerName" th:field="*{customerName}" class="form-control" type="text" readonly> |
|
|
<input id="customerName" th:field="*{customerName}" name="customerName" class="form-control" type="text" readonly> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-4 control-label">生产单号:</label> |
|
|
<label class="col-sm-4 control-label is-required">生产单号:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<select class="form-control" id="makeNo" name="makeNo" th:field="*{makeNo}" readonly> |
|
|
<input class="form-control" th:field="*{makeNo}" id="makeNo" name="makeNo" readonly> |
|
|
<!-- 这里动态生成生产单号选项 --> |
|
|
|
|
|
</select> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-4 control-label">紧急程度:</label> |
|
|
<label class="col-sm-4 control-label is-required">销售单号:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<select name="emergencyDegree" class="form-control m-b" th:with="type=${@dict.getType('aftersales_emergency_degree')}" readonly> |
|
|
<input class="form-control" th:field="*{salesOrderCode}" id="salesOrderCode" name="salesOrderCode" readonly> |
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{emergencyDegree}"></option> |
|
|
|
|
|
</select> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-4 control-label">备注信息:</label> |
|
|
<label class="col-sm-4 control-label is-required">料号:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<input name="remark" th:field="*{remark}" class="form-control" type="text" readonly> |
|
|
<input class="form-control" th:field="*{materialNo}" id="materialNo" name="materialNo" readonly> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="form-group"> |
|
|
|
|
|
<label class="col-sm-4 control-label is-required">物料名称:</label> |
|
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
|
<input class="form-control" th:field="*{materialName}" id="materialName" name="materialName" readonly> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
|
|
<label class="col-sm-4 control-label is-required">型号:</label> |
|
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
|
<input id="materialModelCode" th:field="*{materialModelCode}" name="materialModelCode" class="form-control" type="text" required readonly/> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
|
|
<label class="col-sm-4 control-label is-required">品牌:</label> |
|
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
|
<input id="materialBrand" th:field="*{materialBrand}" name="materialBrand" class="form-control" type="text" required readonly/> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
|
|
<label class="col-sm-4 control-label">备注:</label> |
|
|
|
|
|
<div class="col-sm-8"> |
|
|
|
|
|
<textarea name="remark" class="form-control" th:text="*{remark}" readonly></textarea> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</form> |
|
|
</form> |
|
@ -60,229 +81,41 @@ |
|
|
var aftersalesComplaintNotice = [[${aftersalesComplaintNotice}]]; |
|
|
var aftersalesComplaintNotice = [[${aftersalesComplaintNotice}]]; |
|
|
var prefix = ctx + "aftersales/complaintNotice" |
|
|
var prefix = ctx + "aftersales/complaintNotice" |
|
|
var customerId = [[${aftersalesComplaintNotice.customerId}]] |
|
|
var customerId = [[${aftersalesComplaintNotice.customerId}]] |
|
|
var makeNo = [[${aftersalesComplaintNotice.makeNo}]] |
|
|
var makeNo = [[${aftersalesComplaintNotice.makeNo}]]; |
|
|
|
|
|
var emergencyDegreeDatas = [[${@dict.getType('aftersales_emergency_degree')}]]; |
|
|
$("#form-complaintNotice-edit").validate({ |
|
|
$("#form-complaintNotice-edit").validate({ |
|
|
focusCleanup: true |
|
|
focusCleanup: true |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 新增提交 |
|
|
|
|
|
function submitHandler() { |
|
|
|
|
|
// 获取表单数据 |
|
|
|
|
|
// const complaintNoticeData = $("#form-complaintNotice-edit").serializeArray(); |
|
|
|
|
|
// 获取表单数据 |
|
|
|
|
|
const complaintNoticeData = $("#form-complaintNotice-edit").serializeArray().reduce((obj, item) => { |
|
|
|
|
|
obj[item.name] = item.value; |
|
|
|
|
|
return obj; |
|
|
|
|
|
}, {}); |
|
|
|
|
|
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 |
|
|
|
|
|
var table = $('#bootstrap-table').bootstrapTable('getData'); |
|
|
|
|
|
|
|
|
|
|
|
// 将表数据转换成与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, |
|
|
|
|
|
"snCode": item.snCode, |
|
|
|
|
|
"complaintProblem": item.complaintProblem, |
|
|
|
|
|
// "emergencyDegree": item.emergencyDegree, |
|
|
|
|
|
"adverseReportUrl": item.adverseReportUrl, |
|
|
|
|
|
// ...其他字段 |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 合并表单数据和表格数据 |
|
|
|
|
|
//const combinedData = Object.assign({}, ...complaintNoticeData.map(item => ({ [item.name]: item.value })), ...materialData); |
|
|
|
|
|
const combinedData = Object.assign({}, complaintNoticeData, { aftersalesMaterialVOs: materialDataList }); |
|
|
|
|
|
|
|
|
|
|
|
console.log(combinedData) |
|
|
|
|
|
// 使用 JSON.stringify() 序列化数据 |
|
|
|
|
|
const jsonData = JSON.stringify(combinedData); |
|
|
|
|
|
// 发送 AJAX 请求到后端接口 |
|
|
|
|
|
$.operate.saveJson(prefix + "/edit", jsonData); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取客户信息 |
|
|
|
|
|
$(document).ready(function() { |
|
|
|
|
|
// 初始化时默认加载客户编号列表 |
|
|
|
|
|
loadCustomerIds(); |
|
|
|
|
|
|
|
|
|
|
|
// 监听客户编号下拉框的变化 |
|
|
|
|
|
$('#customerId').on('change', function() { |
|
|
|
|
|
var selectedCustomerId = $(this).val(); // 获取选中的客户ID |
|
|
|
|
|
if (selectedCustomerId) { |
|
|
|
|
|
// 发起Ajax请求获取客户名称 |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
type: 'GET', |
|
|
|
|
|
url: ctx +'system/customer/getCustomerNameByEnterpriseCode/' + selectedCustomerId, // 替换为你的实际API路径 |
|
|
|
|
|
dataType: 'json', // 假设返回的数据格式是JSON |
|
|
|
|
|
success: function(data) { |
|
|
|
|
|
console.log(data); |
|
|
|
|
|
// 将获取到的客户名称填充到输入框 |
|
|
|
|
|
if(data.data == null){ |
|
|
|
|
|
// 如果返回的数据有问题,可以给出提示或处理 |
|
|
|
|
|
alert('未能获取到客户名称!'); |
|
|
|
|
|
} |
|
|
|
|
|
$('input[name="customerName"]').val(data.data.customerName); |
|
|
|
|
|
}, |
|
|
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
|
|
console.error('Error:', textStatus, errorThrown); |
|
|
|
|
|
alert('查询客户名称时发生错误!'); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果没有选择客户ID,清空客户名称输入框 |
|
|
|
|
|
$('input[name="customerName"]').val(''); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取已经选择客户Id相关的生产单号 |
|
|
|
|
|
function loadMakeNos() { |
|
|
|
|
|
var selectedCustomerId = $('#customerId').val(); // 获取选中的客户ID |
|
|
|
|
|
if (!selectedCustomerId) { |
|
|
|
|
|
// 如果没有选中客户,则清空生产单号下拉框并可添加提示信息 |
|
|
|
|
|
$('#makeNo').empty().append('<option value="">请选择客户编号后加载生产单号</option>'); |
|
|
|
|
|
return; // 直接返回,不发起请求 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var makeNoUrl = ctx + 'aftersales/complaintNotice/getMakeNosByCustomerId/' + selectedCustomerId; // 假定的后端接口URL,根据实际调整 |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
type: 'GET', |
|
|
|
|
|
url: makeNoUrl, |
|
|
|
|
|
dataType: 'json', |
|
|
|
|
|
success: function(data) { |
|
|
|
|
|
console.log(data); |
|
|
|
|
|
if (data && Array.isArray(data)) { |
|
|
|
|
|
var selectElement = $('#makeNo'); // 获取生产单号下拉框元素 |
|
|
|
|
|
selectElement.empty(); // 清空现有选项 |
|
|
|
|
|
|
|
|
|
|
|
// 添加默认选项(如果需要) |
|
|
|
|
|
// selectElement.append('<option value="">请选择生产单号</option>'); |
|
|
|
|
|
|
|
|
|
|
|
// 遍历返回的数据,添加为下拉框的选项 |
|
|
|
|
|
$.each(data, function(index, item) { |
|
|
|
|
|
// 假设item有makeNo属性,代表生产单号 |
|
|
|
|
|
selectElement.append('<option value="' + item.makeNo + '">' + item.makeNo + '</option>'); |
|
|
|
|
|
}); |
|
|
|
|
|
$("#makeNo").val(makeNo); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.error('数据为空.'); |
|
|
|
|
|
// 可能还需要处理UI显示,比如提示无相关生产单号 |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
|
|
console.error('Failed to fetch make numbers: ' + textStatus + ', ' + errorThrown); |
|
|
|
|
|
// 同样考虑UI反馈,如提示加载失败 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
// 假设的加载客户编号列表函数 |
|
|
|
|
|
function loadCustomerIds() { |
|
|
|
|
|
var url = ctx + 'system/customer/getCustomers'; |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
type: 'GET', // 请求类型 |
|
|
|
|
|
url: url, // 后端接口URL |
|
|
|
|
|
dataType: 'json', // 预期服务器返回的数据类型 |
|
|
|
|
|
success: function(data) { |
|
|
|
|
|
if (data && Array.isArray(data)) { |
|
|
|
|
|
var selectElement = $('#customerId'); // 获取客户编号下拉框元素 |
|
|
|
|
|
// 清空下拉框现有选项 |
|
|
|
|
|
selectElement.empty(); |
|
|
|
|
|
|
|
|
|
|
|
// // 添加默认选项(如果需要)编辑时不需要添加默认选项 |
|
|
|
|
|
// selectElement.append('<option value="">请选择客户编号</option>'); |
|
|
|
|
|
|
|
|
|
|
|
// 遍历返回的数据,添加为下拉框的选项 |
|
|
|
|
|
$.each(data, function(index, item) { |
|
|
|
|
|
// 假设item有id和name两个属性,分别代表客户ID和客户编号 |
|
|
|
|
|
selectElement.append('<option value="' + item.customerId + '">' + item.customerId + '</option>'); |
|
|
|
|
|
}); |
|
|
|
|
|
$('#customerId').val(customerId); |
|
|
|
|
|
loadMakeNos(); |
|
|
|
|
|
} else { |
|
|
|
|
|
$.modal.errMsg("数据为空"); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
|
|
// console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown); |
|
|
|
|
|
// } |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 点击选择物料按钮 |
|
|
|
|
|
function insertRow() { |
|
|
|
|
|
var selectedMakeNo = $("#makeNo").val(); |
|
|
|
|
|
if (!selectedMakeNo) { |
|
|
|
|
|
alert("请先选择生产单号。"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
var encodedMakeNo = encodeURIComponent(selectedMakeNo); |
|
|
|
|
|
var url = ctx + 'aftersales/complaintNotice/materialSelect?makeNo=' + encodedMakeNo; |
|
|
|
|
|
var options = { |
|
|
|
|
|
title: '选择物料', |
|
|
|
|
|
url: url, |
|
|
|
|
|
callBack: doSubmit |
|
|
|
|
|
}; |
|
|
|
|
|
$.modal.openOptions(options); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//物料信息展示列表 |
|
|
//物料信息展示列表 |
|
|
$(function() { |
|
|
$(function() { |
|
|
var options = { |
|
|
var options = { |
|
|
url: ctx + "aftersales/complaintNotice/getMaterialListByNoticeCode", |
|
|
url: ctx + "aftersales/complaintNotice/getDetailListByNoticeCode", |
|
|
queryParams: queryParams, |
|
|
queryParams: queryParams, |
|
|
modalName: "选择物料", |
|
|
modalName: "选择物料", |
|
|
columns: [{ |
|
|
columns: [ |
|
|
checkbox: true |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '料号', |
|
|
|
|
|
field: 'materialNo', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
{ |
|
|
title: '图片', |
|
|
title: 'detailId', |
|
|
field: 'materialPhotourl', |
|
|
field: 'complaintNoticeDetailId', |
|
|
|
|
|
visible: false, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '物料名称', |
|
|
title: '客诉问题', |
|
|
field: 'materialName', |
|
|
field: 'complaintProblem', |
|
|
}, |
|
|
align: 'center', |
|
|
{ |
|
|
|
|
|
title: '物料类型', |
|
|
|
|
|
field: 'materialType', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '单位', |
|
|
|
|
|
field: 'materialUnit', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '品牌', |
|
|
|
|
|
field: 'materialBrand', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '描述', |
|
|
|
|
|
field: 'materialDescribe', |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: 'SN号', |
|
|
title: '紧急程度', |
|
|
field: 'snCode' |
|
|
align: 'center', |
|
|
}, |
|
|
field: 'emergencyDegree', |
|
|
|
|
|
formatter: function(value, row, index) { |
|
|
{ |
|
|
return $.table.selectDictLabel(emergencyDegreeDatas, value); |
|
|
title: '客诉问题', |
|
|
} |
|
|
field: 'complaintProblem' |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '售后问题', |
|
|
title: '不良报告', |
|
|
field: 'adverseReportUrl' |
|
|
align: 'center', |
|
|
|
|
|
field: 'adverseReportUrl', |
|
|
}, |
|
|
}, |
|
|
] |
|
|
] |
|
|
}; |
|
|
}; |
|
@ -298,39 +131,6 @@ |
|
|
return curParams; |
|
|
return curParams; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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', { |
|
|
|
|
|
index:1, |
|
|
|
|
|
row: { |
|
|
|
|
|
materialNo:rowData.materialNo, |
|
|
|
|
|
materialPhotourl:rowData.materialPhotourl, |
|
|
|
|
|
materialName: rowData.materialName, |
|
|
|
|
|
materialType: rowData.materialType, |
|
|
|
|
|
materialDescribe: rowData.materialDescribe, |
|
|
|
|
|
materialBrand: rowData.materialBrand, |
|
|
|
|
|
materialUnit: rowData.materialUnit, |
|
|
|
|
|
materialProcessMethod: rowData.materialProcessMethod, |
|
|
|
|
|
shippedGoodsSum: rowData.shippedGoodsSum, |
|
|
|
|
|
snCode:"", |
|
|
|
|
|
complaintProblem:"", |
|
|
|
|
|
adverseReportUrl:"", |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
layer.close(index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 逻辑删除前端的一行数据 |
|
|
|
|
|
function removeRow(materialNo){ |
|
|
|
|
|
$("#bootstrap-table").bootstrapTable('remove', { |
|
|
|
|
|
field: 'materialNo', |
|
|
|
|
|
values: materialNo |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
</html> |
|
|
</html> |