liuxiaoxu
6 months ago
5 changed files with 1081 additions and 0 deletions
@ -0,0 +1,188 @@ |
|||
package com.ruoyi.quality.controller; |
|||
|
|||
import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; |
|||
import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; |
|||
import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; |
|||
import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeDetailService; |
|||
import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeService; |
|||
import com.ruoyi.common.annotation.Log; |
|||
import com.ruoyi.common.core.controller.BaseController; |
|||
import com.ruoyi.common.core.domain.AjaxResult; |
|||
import com.ruoyi.common.core.page.TableDataInfo; |
|||
import com.ruoyi.common.enums.BusinessType; |
|||
import com.ruoyi.common.utils.poi.ExcelUtil; |
|||
import com.ruoyi.system.domain.SysMakeOrder; |
|||
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.ModelMap; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 售后客诉通知单Controller |
|||
* |
|||
* @author 刘晓旭 |
|||
* @date 2024-05-22 |
|||
*/ |
|||
@Controller |
|||
@RequestMapping("/quality/complaintNotice") |
|||
public class QualityComplaintNoticeController extends BaseController { |
|||
|
|||
|
|||
private String prefix = "quality/complaintNotice"; |
|||
|
|||
@Autowired |
|||
private IAftersalesComplaintNoticeService aftersalesComplaintNoticeService; |
|||
|
|||
@Autowired |
|||
private IAftersalesComplaintNoticeDetailService complaintNoticeDetailService; |
|||
|
|||
@RequiresPermissions("quality:complaintNotice:view") |
|||
@GetMapping() |
|||
public String complaintNotice() |
|||
{ |
|||
return prefix + "/complaintNotice"; |
|||
} |
|||
|
|||
/** |
|||
* 查询售后客诉通知单列表 |
|||
*/ |
|||
@RequiresPermissions("quality:complaintNotice:list") |
|||
@PostMapping("/list") |
|||
@ResponseBody |
|||
public TableDataInfo list(AftersalesComplaintNotice complaintNotice) |
|||
{ |
|||
startPage(); |
|||
List<AftersalesComplaintNotice> list = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeList(complaintNotice); |
|||
return getDataTable(list); |
|||
} |
|||
|
|||
/** |
|||
* 导出售后客诉通知单列表 |
|||
*/ |
|||
@RequiresPermissions("quality:complaintNotice:export") |
|||
@Log(title = "售后客诉通知单", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
@ResponseBody |
|||
public AjaxResult export(AftersalesComplaintNoticeDetail aftersalesComplaintNoticeDetail) |
|||
{ |
|||
List<AftersalesComplaintNoticeDetail> complaintNoticeDetails = complaintNoticeDetailService.selectAftersalesComplaintNoticeDetailList(aftersalesComplaintNoticeDetail); |
|||
ExcelUtil<AftersalesComplaintNoticeDetail> util = new ExcelUtil<AftersalesComplaintNoticeDetail>(AftersalesComplaintNoticeDetail.class); |
|||
return util.exportExcel(complaintNoticeDetails, "售后客诉通知单数据"); |
|||
} |
|||
|
|||
/** |
|||
* 新增售后客诉通知单 |
|||
*/ |
|||
@GetMapping("/add") |
|||
public String add() |
|||
{ |
|||
return prefix + "/add"; |
|||
} |
|||
|
|||
/** |
|||
* 新增保存售后客诉通知单 |
|||
*/ |
|||
@RequiresPermissions("quality:complaintNotice:add") |
|||
@Log(title = "售后客诉通知单", businessType = BusinessType.INSERT) |
|||
@PostMapping("/add") |
|||
@ResponseBody |
|||
public AjaxResult addSave(@RequestBody AftersalesComplaintNoticeDetail complaintNoticeDetail) |
|||
{ |
|||
return toAjax(complaintNoticeDetailService.insertAftersalesComplaintNoticeDetail(complaintNoticeDetail)); |
|||
} |
|||
|
|||
/** |
|||
* 修改售后客诉通知单 |
|||
*/ |
|||
@GetMapping("/returnInspectionProcessing/{complaintNoticeId}") |
|||
public String edit(@PathVariable("complaintNoticeId") Long complaintNoticeId, ModelMap mmap) |
|||
{ |
|||
AftersalesComplaintNotice aftersalesComplaintNotice = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeById(complaintNoticeId); |
|||
mmap.put("aftersalesComplaintNotice", aftersalesComplaintNotice); |
|||
return prefix + "/returnInspectionProcessing"; |
|||
} |
|||
|
|||
/** |
|||
* 修改保存售后客诉通知单 |
|||
*/ |
|||
@RequiresPermissions("quality:complaintNotice:returnInspectionProcessing") |
|||
@Log(title = "售后客诉通知单", businessType = BusinessType.UPDATE) |
|||
@PostMapping("/edit") |
|||
@ResponseBody |
|||
public AjaxResult editSave(@RequestBody AftersalesComplaintNoticeDetail aftersalesComplaintNoticeDetail) |
|||
{ |
|||
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"; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 删除售后客诉通知单 |
|||
*/ |
|||
@RequiresPermissions("quality:complaintNotice:remove") |
|||
@Log(title = "售后客诉通知单", businessType = BusinessType.DELETE) |
|||
@PostMapping( "/remove") |
|||
@ResponseBody |
|||
public AjaxResult remove(String ids) |
|||
{ |
|||
return toAjax(aftersalesComplaintNoticeService.deleteAftersalesComplaintNoticeByIds(ids)); |
|||
} |
|||
|
|||
/** |
|||
* 查找与客户id关联的生产单号 |
|||
* */ |
|||
@ResponseBody |
|||
@GetMapping("/getMakeNosByCustomerId/{customerId}") |
|||
public List<SysMakeOrder> getCustomers(@PathVariable String customerId) { |
|||
List<SysMakeOrder> list = aftersalesComplaintNoticeService.selectMakeOrdersByCustomerId(customerId); |
|||
return list; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 查找与客户生产单号有关的物料信息 |
|||
*/ |
|||
@GetMapping("/materialSelect") |
|||
public String materialSelect(@RequestParam String makeNo,ModelMap modelMap) |
|||
{ |
|||
modelMap.put("makeNo",makeNo); |
|||
return prefix + "/materialSelect"; |
|||
} |
|||
|
|||
/** |
|||
* 查找与客户生产单号有关的物料信息 |
|||
* */ |
|||
@ResponseBody |
|||
@PostMapping("/getMaterialInfoByMakeNo") |
|||
public TableDataInfo getMaterialInfoByMakeNo(@RequestParam String makeNo){ |
|||
startPage(); |
|||
List<AftersalesMaterialVO> list = aftersalesComplaintNoticeService.selectMaterialInfoByMakeNo(makeNo); |
|||
return getDataTable(list); |
|||
} |
|||
|
|||
/** |
|||
* 编辑操作的时候查询数据库中已有的物料信息 |
|||
* */ |
|||
@ResponseBody |
|||
@PostMapping("/getMaterialListByNoticeCode") |
|||
public TableDataInfo getMaterialListByNoticeCode(AftersalesComplaintNoticeDetail complaintNoticeDetail){ |
|||
startPage(); |
|||
List<AftersalesMaterialVO> list = complaintNoticeDetailService.selectMaterialListByNoticeCode(complaintNoticeDetail.getComplaintNoticeCode()); |
|||
return getDataTable(list); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,174 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> |
|||
<head> |
|||
<th:block th:include="include :: header('售后客诉通知单列表')" /> |
|||
</head> |
|||
<body class="gray-bg"> |
|||
<div class="container-div"> |
|||
<div class="row"> |
|||
<div class="col-sm-12 search-collapse"> |
|||
<form id="formId"> |
|||
<div class="select-list"> |
|||
<ul> |
|||
<li> |
|||
<label>客诉单号:</label> |
|||
<input type="text" name="complaintNoticeCode"/> |
|||
</li> |
|||
<li> |
|||
<label>是否结案:</label> |
|||
<select name="closingProcedures" th:with="type=${@dict.getType('aftersales_closing_procedures')}"> |
|||
<option value="">所有</option> |
|||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|||
</select> |
|||
</li> |
|||
<li> |
|||
<label>紧急程度:</label> |
|||
<select name="emergencyDegree" th:with="type=${@dict.getType('aftersales_emergency_degree')}"> |
|||
<option value="">所有</option> |
|||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|||
</select> |
|||
</li> |
|||
<li> |
|||
<label>生产单号:</label> |
|||
<input type="text" name="makeNo"/> |
|||
</li> |
|||
<li> |
|||
<label>料号:</label> |
|||
<input type="text" name="materialNo"/> |
|||
</li> |
|||
<li> |
|||
<label>物料名称:</label> |
|||
<input type="text" name="materialName"/> |
|||
</li> |
|||
<li class="select-time"> |
|||
<label>录入时间:</label> |
|||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/> |
|||
<span>-</span> |
|||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/> |
|||
</li> |
|||
<li> |
|||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a> |
|||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
|
|||
<div class="btn-group-sm" id="toolbar" role="group"> |
|||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="aftersales:complaintNotice:export"> |
|||
<i class="fa fa-download"></i> 导出 |
|||
</a> |
|||
</div> |
|||
<div class="col-sm-12 select-table table-striped"> |
|||
<table id="bootstrap-table"></table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<th:block th:include="include :: footer" /> |
|||
<script th:inline="javascript"> |
|||
var returnInspectionFlag = [[${@permission.hasPermi('quality:complaintNotice:returnInspectionProcessing')}]]; |
|||
var detailFlag = [[${@permission.hasPermi('quality:complaintNotice:detail')}]]; |
|||
var removeFlag = [[${@permission.hasPermi('quality:complaintNotice:remove')}]]; |
|||
var emergencyDegreeDatas = [[${@dict.getType('aftersales_emergency_degree')}]]; |
|||
var closingProceduresDatas = [[${@dict.getType('aftersales_closing_procedures')}]]; |
|||
var prefix = ctx + "quality/complaintNotice"; |
|||
|
|||
$(function() { |
|||
var options = { |
|||
url: prefix + "/list", |
|||
createUrl: prefix + "/add", |
|||
updateUrl: prefix + "/edit/{id}", |
|||
removeUrl: prefix + "/remove", |
|||
exportUrl: prefix + "/export", |
|||
modalName: "售后客诉通知单", |
|||
columns: [{ |
|||
checkbox: true |
|||
}, |
|||
{ |
|||
title: '客诉通知详情ID', |
|||
field: 'complaintNoticeId', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '客诉单号', |
|||
field: 'complaintNoticeCode', |
|||
}, |
|||
{ |
|||
title: '是否结案', |
|||
field: 'closingProcedures', |
|||
formatter: function(value, row, index) { |
|||
return $.table.selectDictLabel(closingProceduresDatas, value); |
|||
} |
|||
}, |
|||
|
|||
{ |
|||
title: '关联生产单号', |
|||
field: 'makeNo', |
|||
}, |
|||
{ |
|||
title: '紧急程度', |
|||
field: 'emergencyDegree', |
|||
formatter: function(value, row, index) { |
|||
return $.table.selectDictLabel(emergencyDegreeDatas, value); |
|||
} |
|||
}, |
|||
|
|||
{ |
|||
title: '物料合计', |
|||
field: 'materialSum', |
|||
}, |
|||
{ |
|||
title: '数量合计', |
|||
field: 'enterpriseSum', |
|||
}, |
|||
{ |
|||
title: '录入人', |
|||
field: 'createBy', |
|||
}, |
|||
{ |
|||
title: '录入时间', |
|||
field: 'createTime', |
|||
}, |
|||
{ |
|||
title: '更新人', |
|||
field: 'updateBy', |
|||
}, |
|||
{ |
|||
title: '上次更新时间', |
|||
field: 'updateTime', |
|||
}, |
|||
{ |
|||
title: '操作', |
|||
align: 'center', |
|||
formatter: function(value, row, index) { |
|||
var actions = []; |
|||
if (row.closingProcedures !== '0') { |
|||
actions.push('<a class="btn btn-success btn-xs ' + returnInspectionFlag + '" href="javascript:void(0)" onclick="returnInspectionProcessing(\'' + 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(''); |
|||
} |
|||
}] |
|||
}; |
|||
$.table.init(options); |
|||
}); |
|||
|
|||
/*详情*/ |
|||
function detail(complaintNoticeId) { |
|||
// 在这里编写派单操作的逻辑,使用传入的aftersalesOrderId参数 |
|||
// 示例逻辑: |
|||
var url = ctx + 'quality/complaintNotice/detail/'+complaintNoticeId; |
|||
console.log(url); |
|||
$.modal.open("客诉通知单详情",url); |
|||
} |
|||
|
|||
/*退检处理*/ |
|||
function returnInspectionProcessing(complaintNoticeId){ |
|||
var url = ctx + 'quality/complaintNotice/returnInspectionProcessing/'+complaintNoticeId; |
|||
console.log(url); |
|||
$.modal.open("退检处理",url); |
|||
} |
|||
</script> |
|||
</body> |
|||
</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 { |
|||
$.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() { |
|||
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> |
@ -0,0 +1,382 @@ |
|||
<!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 is-required">客户编号:</label> |
|||
<div class="col-sm-8"> |
|||
<select class="form-control" id="customerId" name="customerId" th:field="*{customerId}" onchange="loadMakeNos()" required disabled> |
|||
<!-- 这里动态生成客户编号选项 --> |
|||
</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 is-required">生产单号:</label> |
|||
<div class="col-sm-8"> |
|||
<select class="form-control" id="makeNo" name="makeNo" th:field="*{makeNo}" required disabled> |
|||
<!-- 这里动态生成生产单号选项 --> |
|||
</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')}" disabled> |
|||
<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"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label class="col-sm-4 control-label">是否结案:</label> |
|||
<div class="col-sm-8"> |
|||
<div class="radio-box" th:each="dict : ${@dict.getType('aftersales_closing_procedures')}"> |
|||
<input type="radio" th:id="${'closingProcedures_' + dict.dictCode}" name="closingProcedures" th:value="${dict.dictValue}" th:field="*{closingProcedures}"> |
|||
<label th:for="${'closingProcedures_' + dict.dictCode}" th:text="${dict.dictLabel}"></label> |
|||
</div> |
|||
</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'); |
|||
// 检查表格数据是否为空 |
|||
if (table.length===0){ |
|||
$.modal.alertWarning("请至少保留一条物料数据后再保存!"); |
|||
return; |
|||
} |
|||
// 将表数据转换成与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){ |
|||
// 如果返回的数据有问题,可以给出提示或处理 |
|||
$.modal.alertWarning('未能获取到客户名称!'); |
|||
} |
|||
$('input[name="customerName"]').val(data.data.customerName); |
|||
}, |
|||
error: function(jqXHR, textStatus, errorThrown) { |
|||
console.error('Error:', textStatus, errorThrown); |
|||
$.modal.alertWarning('查询客户名称时发生错误!'); |
|||
} |
|||
}); |
|||
} 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 { |
|||
$.modal.errMsg("数据为空"); |
|||
// 可能还需要处理UI显示,比如提示无相关生产单号 |
|||
} |
|||
}, |
|||
error: function(jqXHR, textStatus, errorThrown) { |
|||
console.error('Failed to fetch make numbers: ' + textStatus + ', ' + errorThrown); |
|||
// 同样,如提示加载失败 |
|||
} |
|||
}); |
|||
} |
|||
// 假设的加载客户编号列表函数 |
|||
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() { |
|||
var options = { |
|||
url: ctx + "aftersales/complaintNotice/getMaterialListByNoticeCode", |
|||
showSearch: false, |
|||
showRefresh: false, |
|||
showToggle: false, |
|||
showColumns: false, |
|||
pagination: false, // 设置不分页 |
|||
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: '加工方式', |
|||
field: 'materialProcessMethod', |
|||
}, |
|||
{ |
|||
title: '出库数量', |
|||
field: 'shippedGoodsSum', |
|||
}, |
|||
{ |
|||
title: 'SN号', |
|||
field: 'snCode', |
|||
editable: { |
|||
type: 'text', // 表示该列可以被编辑为文本 |
|||
}, |
|||
}, |
|||
|
|||
{ |
|||
title: '客诉问题', |
|||
field: 'complaintProblem', |
|||
editable: { |
|||
type: 'text', // 表示该列可以被编辑为文本 |
|||
}, |
|||
}, |
|||
{ |
|||
title: '售后问题', |
|||
field: 'adverseReportUrl', |
|||
editable: { |
|||
type: 'text', // 表示该列可以被编辑为文本 |
|||
// 可以在这里定义更多编辑行为,比如验证、提交等 |
|||
}, |
|||
}, |
|||
{ |
|||
title: '操作', |
|||
align: 'center', |
|||
formatter: function(value, row, index) { |
|||
var actions = []; |
|||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.materialNo + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|||
return actions.join(''); |
|||
} |
|||
} |
|||
] |
|||
}; |
|||
$.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…
Reference in new issue