Browse Source

[fix]售后管理:

售后客诉通知
新增售后通知详情页面
新增售后通知详情按钮
dev
liuxiaoxu 5 months ago
parent
commit
be6f17b6bc
  1. 12
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesComplaintNoticeController.java
  2. 17
      ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/complaintNotice.html
  3. 336
      ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/detail.html

12
ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesComplaintNoticeController.java

@ -121,6 +121,18 @@ public class AftersalesComplaintNoticeController extends BaseController
return toAjax(complaintNoticeDetailService.updateAftersalesComplaintNoticeDetail(aftersalesComplaintNoticeDetail));
}
/**
* 售后客诉通知单详情
*/
@GetMapping("/detail/{complaintNoticeId}")
public String detail(@PathVariable("complaintNoticeId") Long complaintNoticeId, ModelMap mmap)
{
AftersalesComplaintNotice aftersalesComplaintNotice = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeById(complaintNoticeId);
mmap.put("aftersalesComplaintNotice", aftersalesComplaintNotice);
return prefix + "/detail";
}
/**
* 删除售后客诉通知单
*/

17
ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/complaintNotice.html

@ -71,6 +71,7 @@
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('aftersales:complaintNotice:edit')}]];
var detailFlag = [[${@permission.hasPermi('aftersales:complaintNotice:detail')}]];
var removeFlag = [[${@permission.hasPermi('aftersales:complaintNotice:remove')}]];
var cancelFlag = [[${@permission.hasPermi('aftersales:complaintNotice:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('aftersales:complaintNotice:restore')}]];
@ -150,7 +151,7 @@
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.complaintNoticeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-success btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.complaintNoticeId + '\')"><i class="fa fa-edit"></i>详情</a> ');
return actions.join('');
}
}]
@ -159,13 +160,13 @@
});
/*详情*/
// function detail(aftersalesOrderId) {
// // 在这里编写派单操作的逻辑,使用传入的aftersalesOrderId参数
// // 示例逻辑:
// var url = ctx + 'aftersales/aftersalesOrder/detail/'+aftersalesOrderId;
// console.log(url);
// $.modal.open("上传报告",url);
// }
function detail(complaintNoticeId) {
// 在这里编写派单操作的逻辑,使用传入的aftersalesOrderId参数
// 示例逻辑:
var url = ctx + 'aftersales/complaintNotice/detail/'+complaintNoticeId;
console.log(url);
$.modal.open("客诉通知单详情",url);
}
</script>
</body>

336
ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/detail.html

@ -0,0 +1,336 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改售后客诉通知单')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-complaintNotice-edit" th:object="${aftersalesComplaintNotice}">
<input name="complaintNoticeCode" th:field="*{complaintNoticeCode}" type="hidden">
<div class="form-group">
<label class="col-sm-4 control-label">客户编号:</label>
<div class="col-sm-8">
<select class="form-control" id="customerId" name="customerId" th:field="*{customerId}" onchange="loadMakeNos()" readonly>
<!-- 这里动态生成客户编号选项 -->
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">客户名称:</label>
<div class="col-sm-8">
<input name="customerName" th:field="*{customerName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">生产单号:</label>
<div class="col-sm-8">
<select class="form-control" id="makeNo" name="makeNo" th:field="*{makeNo}" readonly>
<!-- 这里动态生成生产单号选项 -->
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">紧急程度:</label>
<div class="col-sm-8">
<select name="emergencyDegree" class="form-control m-b" th:with="type=${@dict.getType('aftersales_emergency_degree')}" readonly>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{emergencyDegree}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">备注信息:</label>
<div class="col-sm-8">
<input name="remark" th:field="*{remark}" class="form-control" type="text" readonly>
</div>
</div>
</form>
<div class="container">
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<!--用于可以修改列表字段的插件-->
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript">
var removeFlag = [[${@permission.hasPermi('aftersales:complaintNotice:remove')}]];
var aftersalesComplaintNotice = [[${aftersalesComplaintNotice}]];
var prefix = ctx + "aftersales/complaintNotice"
var customerId = [[${aftersalesComplaintNotice.customerId}]]
var makeNo = [[${aftersalesComplaintNotice.makeNo}]]
$("#form-complaintNotice-edit").validate({
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 {
console.error('Data is not an array or is empty.');
}
},
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() {
var options = {
url: ctx + "aftersales/complaintNotice/getMaterialListByNoticeCode",
queryParams: queryParams,
modalName: "选择物料",
columns: [{
checkbox: true
},
{
title: '料号',
field: 'materialNo',
},
{
title: '图片',
field: 'materialPhotourl',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '物料类型',
field: 'materialType',
},
{
title: '单位',
field: 'materialUnit',
},
{
title: '品牌',
field: 'materialBrand',
},
{
title: '描述',
field: 'materialDescribe',
},
{
title: 'SN号',
field: 'snCode'
},
{
title: '客诉问题',
field: 'complaintProblem'
},
{
title: '售后问题',
field: 'adverseReportUrl'
},
]
};
$.table.init(options);
})
function queryParams(params) {
var curParams = {
// 传递参数查询参数
complaintNoticeCode: aftersalesComplaintNotice.complaintNoticeCode
};
console.log(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>
</body>
</html>
Loading…
Cancel
Save