Browse Source

[feat] 品质管理

按照万材要求,品质管理客诉通知单新增导出功能,支持部分行和全部行导出,导出更多数据
新增导出所有和选择导出后端接口
新增 导出品质管理客诉通知单明细方法
新增根据品质管理客诉通知单集合方法
新增导出品质管理客诉通知单明细
修复,品质管理客诉通知单分页查询多余的异常抛出问题
dev
liuxiaoxu 1 day ago
parent
commit
2fb5545e0c
  1. 11
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AftersalesComplaintNotice.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesComplaintNoticeService.java
  3. 63
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java
  4. 20
      ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityComplaintNoticeController.java
  5. 154
      ruoyi-admin/src/main/resources/templates/quality/complaintNotice/complaintNotice.html
  6. 314
      ruoyi-admin/src/main/resources/templates/quality/complaintNotice/detail.html

11
ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AftersalesComplaintNotice.java

@ -68,7 +68,7 @@ public class AftersalesComplaintNotice extends BaseEntity
private Integer enterpriseSum; private Integer enterpriseSum;
private String emergencyDegree;
private List<AftersalesComplaintNoticeDetail> noticeDetailList; private List<AftersalesComplaintNoticeDetail> noticeDetailList;
@ -203,6 +203,14 @@ public class AftersalesComplaintNotice extends BaseEntity
this.snCode = snCode; this.snCode = snCode;
} }
public String getEmergencyDegree() {
return emergencyDegree;
}
public void setEmergencyDegree(String emergencyDegree) {
this.emergencyDegree = emergencyDegree;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -216,6 +224,7 @@ public class AftersalesComplaintNotice extends BaseEntity
.append("materialName", getMaterialName()) .append("materialName", getMaterialName())
.append("materialSum", getMaterialSum()) .append("materialSum", getMaterialSum())
.append("enterpriseSum", getEnterpriseSum()) .append("enterpriseSum", getEnterpriseSum())
.append("emergencyDegree", getEmergencyDegree())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())

7
ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesComplaintNoticeService.java

@ -2,7 +2,7 @@ package com.ruoyi.aftersales.service;
import java.util.List; import java.util.List;
import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice;
import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; import com.ruoyi.aftersales.domain.vo.AftersalesComplaintExportVO;
import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO;
import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeOrder;
@ -94,4 +94,9 @@ public interface IAftersalesComplaintNoticeService
* 根据客诉单号查找售后客诉通知单 * 根据客诉单号查找售后客诉通知单
* */ * */
List<AftersalesComplaintNotice> selectAftersalesComplaintNoticeListByCodes(String[] complaintNoticeCodes); List<AftersalesComplaintNotice> selectAftersalesComplaintNoticeListByCodes(String[] complaintNoticeCodes);
/**
* 导出售后客诉通知单
* */
List<AftersalesComplaintExportVO> exportAfterComplaintExportList(List<AftersalesComplaintNotice> list);
} }

63
ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesComplaintNoticeServiceImpl.java

@ -1,15 +1,14 @@
package com.ruoyi.aftersales.service.impl; package com.ruoyi.aftersales.service.impl;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail;
import com.ruoyi.aftersales.domain.vo.AftersalesComplaintExportVO;
import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO;
import com.ruoyi.aftersales.mapper.AftersalesComplaintNoticeDetailMapper; import com.ruoyi.aftersales.mapper.AftersalesComplaintNoticeDetailMapper;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
@ -18,15 +17,12 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeOrder;
import com.ruoyi.system.domain.SysMakeorderBom;
import com.ruoyi.system.domain.SysSalesOrder; import com.ruoyi.system.domain.SysSalesOrder;
import com.ruoyi.system.domain.SysSalesOrderChild; import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.mapper.SysMakeOrderMapper; import com.ruoyi.system.mapper.SysMakeOrderMapper;
import com.ruoyi.system.mapper.SysMakeorderBomMapper; import com.ruoyi.system.mapper.SysMakeorderBomMapper;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper; import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.mapper.SysSalesOrderMapper; import com.ruoyi.system.mapper.SysSalesOrderMapper;
import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail;
import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper;
import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper; import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -50,6 +46,7 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain
@Autowired @Autowired
private AftersalesComplaintNoticeMapper aftersalesComplaintNoticeMapper; private AftersalesComplaintNoticeMapper aftersalesComplaintNoticeMapper;
@Autowired @Autowired
private SysMakeOrderMapper sysMakeOrderMapper; private SysMakeOrderMapper sysMakeOrderMapper;
@ -297,4 +294,54 @@ public class AftersalesComplaintNoticeServiceImpl implements IAftersalesComplain
String newCode = df.format(Integer.parseInt(roundCode)); String newCode = df.format(Integer.parseInt(roundCode));
return newCode; return newCode;
} }
/**
* 导出客诉单明细
* */
@Override
public List<AftersalesComplaintExportVO> exportAfterComplaintExportList(List<AftersalesComplaintNotice> list) {
// 获取所有的客诉单号
List<String> collectNoticeCodes = list.stream()
.map(AftersalesComplaintNotice::getComplaintNoticeCode)
.collect(Collectors.toList());
// 根据客诉单号查询对应的客诉详情列表
List<AftersalesComplaintNoticeDetail> noticeDetails = noticeDetailMapper.selectAftersalesComplaintNoticeDetailListByCodeList(collectNoticeCodes);
// 创建一个 AftersalesComplaintNotice 的 Map,键为客诉单号
Map<String, AftersalesComplaintNotice> aftersalesComplaintNoticeMap = list.stream()
.collect(Collectors.toMap(AftersalesComplaintNotice::getComplaintNoticeCode, Function.identity()));
// 初始化导出列表
List<AftersalesComplaintExportVO> aftersalesComplaintExportVOS = new ArrayList<>();
for (AftersalesComplaintNoticeDetail detail : noticeDetails) {
AftersalesComplaintExportVO exportVo = new AftersalesComplaintExportVO();
// 从 AftersalesComplaintNoticeDetail 填充数据
exportVo.setComplaintProblem(detail.getComplaintProblem());
exportVo.setEmergencyDegree(detail.getEmergencyDegree());
// 从 AftersalesComplaintNotice 填充数据,通过客诉单号进行关联
AftersalesComplaintNotice notice = aftersalesComplaintNoticeMap.get(detail.getComplaintNoticeCode());
if (notice != null) {
exportVo.setSnCode(notice.getSnCode());
exportVo.setComplaintNoticeCode(notice.getComplaintNoticeCode());
exportVo.setSalesOrderCode(notice.getSalesOrderCode());
exportVo.setCustomerName(notice.getCustomerName());
exportVo.setMakeNo(notice.getMakeNo());
exportVo.setMaterialNo(notice.getMaterialNo());
exportVo.setMaterialName(notice.getMaterialName());
exportVo.setMaterialBrand(notice.getMaterialBrand());
exportVo.setMaterialModelCode(notice.getMaterialModelCode());
exportVo.setClosingProcedures(notice.getClosingProcedures());
}
// 添加到结果列表
aftersalesComplaintExportVOS.add(exportVo);
}
return aftersalesComplaintExportVOS;
}
} }

20
ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityComplaintNoticeController.java

@ -2,6 +2,7 @@ package com.ruoyi.quality.controller;
import com.ruoyi.aftersales.domain.AftersalesComplaintNotice; import com.ruoyi.aftersales.domain.AftersalesComplaintNotice;
import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail; import com.ruoyi.aftersales.domain.AftersalesComplaintNoticeDetail;
import com.ruoyi.aftersales.domain.vo.AftersalesComplaintExportVO;
import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO; import com.ruoyi.aftersales.domain.vo.AftersalesMaterialVO;
import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeDetailService; import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeDetailService;
import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeService; import com.ruoyi.aftersales.service.IAftersalesComplaintNoticeService;
@ -10,6 +11,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeOrder;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -67,11 +69,21 @@ public class QualityComplaintNoticeController extends BaseController {
@Log(title = "售后客诉通知单", businessType = BusinessType.EXPORT) @Log(title = "售后客诉通知单", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(AftersalesComplaintNoticeDetail aftersalesComplaintNoticeDetail) public AjaxResult export(AftersalesComplaintNotice complaintNotice,String ids)
{ {
List<AftersalesComplaintNoticeDetail> complaintNoticeDetails = complaintNoticeDetailService.selectAftersalesComplaintNoticeDetailList(aftersalesComplaintNoticeDetail); if(StringUtils.isEmpty(ids)){
ExcelUtil<AftersalesComplaintNoticeDetail> util = new ExcelUtil<AftersalesComplaintNoticeDetail>(AftersalesComplaintNoticeDetail.class); List<AftersalesComplaintNotice> list = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeList(complaintNotice);
return util.exportExcel(complaintNoticeDetails, "售后客诉通知单数据"); List<AftersalesComplaintExportVO> exportAftersalesComplaintNoticeVos = aftersalesComplaintNoticeService.exportAfterComplaintExportList(list);
ExcelUtil<AftersalesComplaintExportVO> util = new ExcelUtil<AftersalesComplaintExportVO>(AftersalesComplaintExportVO.class);
return util.exportExcel(exportAftersalesComplaintNoticeVos, "售后客诉通知单数据");
}else{
String[] complaintNoticeCodes = ids.split(",");
List<AftersalesComplaintNotice> list = aftersalesComplaintNoticeService.selectAftersalesComplaintNoticeListByCodes(complaintNoticeCodes);
List<AftersalesComplaintExportVO> exportAftersalesComplaintNoticeVos = aftersalesComplaintNoticeService.exportAfterComplaintExportList(list);
ExcelUtil<AftersalesComplaintExportVO> util = new ExcelUtil<AftersalesComplaintExportVO>(AftersalesComplaintExportVO.class);
return util.exportExcel(exportAftersalesComplaintNoticeVos, "售后客诉通知单数据");
}
} }
/** /**

154
ruoyi-admin/src/main/resources/templates/quality/complaintNotice/complaintNotice.html

@ -10,6 +10,10 @@
<form id="formId"> <form id="formId">
<div class="select-list"> <div class="select-list">
<ul> <ul>
<li>
<label>SN号:</label>
<input type="text" name="snCode"/>
</li>
<li> <li>
<label>客诉单号:</label> <label>客诉单号:</label>
<input type="text" name="complaintNoticeCode"/> <input type="text" name="complaintNoticeCode"/>
@ -21,17 +25,14 @@
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select> </select>
</li> </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> <li>
<label>生产单号:</label> <label>生产单号:</label>
<input type="text" name="makeNo"/> <input type="text" name="makeNo"/>
</li> </li>
<li>
<label>销售订单号:</label>
<input type="text" name="salesOrderCode"/>
</li>
<li> <li>
<label>料号:</label> <label>料号:</label>
<input type="text" name="materialNo"/> <input type="text" name="materialNo"/>
@ -56,7 +57,7 @@
</div> </div>
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.table.exportExcel()" shiro:hasPermission="aftersales:complaintNotice:export"> <a class="btn btn-success" onclick="exportExcel()" shiro:hasPermission="aftersales:complaintNotice:export">
<i class="fa fa-download"></i> 导出 <i class="fa fa-download"></i> 导出
</a> </a>
</div> </div>
@ -70,7 +71,6 @@
var returnInspectionFlag = [[${@permission.hasPermi('quality:complaintNotice:returnInspectionProcessing')}]]; var returnInspectionFlag = [[${@permission.hasPermi('quality:complaintNotice:returnInspectionProcessing')}]];
var detailFlag = [[${@permission.hasPermi('quality:complaintNotice:detail')}]]; var detailFlag = [[${@permission.hasPermi('quality:complaintNotice:detail')}]];
var removeFlag = [[${@permission.hasPermi('quality:complaintNotice:remove')}]]; var removeFlag = [[${@permission.hasPermi('quality:complaintNotice:remove')}]];
var emergencyDegreeDatas = [[${@dict.getType('aftersales_emergency_degree')}]];
var closingProceduresDatas = [[${@dict.getType('aftersales_closing_procedures')}]]; var closingProceduresDatas = [[${@dict.getType('aftersales_closing_procedures')}]];
var prefix = ctx + "quality/complaintNotice"; var prefix = ctx + "quality/complaintNotice";
@ -85,58 +85,83 @@
columns: [{ columns: [{
checkbox: true checkbox: true
}, },
{ {
title: '客诉通知详情ID', title: '客诉通知详情ID',
field: 'complaintNoticeId', field: 'complaintNoticeId',
visible: false visible: false
}, },
{ {
title: '客诉单号', title: 'SN号',
field: 'complaintNoticeCode', field: 'snCode',
}, align: 'center',
},
{
title: '客诉单号',
field: 'complaintNoticeCode',
align: 'center',
},
{
title: '销售订单号',
field: 'salesOrderCode',
align: 'center',
},
{ {
title: '是否结案', title: '是否结案',
field: 'closingProcedures', field: 'closingProcedures',
align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(closingProceduresDatas, value); 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: '上次更新时间', title: '客户名称',
field: 'customerName',
align: 'center',
},
{
title: '关联生产单号',
field: 'makeNo',
align: 'center',
},
{
title: '料号',
field: 'materialNo',
align: 'center',
},
{
title: '物料名称',
field: 'materialName',
align: 'center',
},
{
title: '设备型号',
field: 'materialModelCode',
align: 'center',
},
{
title: '品牌',
field: 'materialBrand',
align: 'center',
},
{
title: '录入人',
field: 'createBy',
align: 'center',
},
{
title: '录入时间',
field: 'createTime',
align: 'center',
},
{
title: '更新人',
field: 'updateBy',
align: 'center',
},
{
title: '更新时间',
field: 'updateTime', field: 'updateTime',
align: 'center',
}, },
{ {
title: '操作', title: '操作',
@ -170,6 +195,31 @@
console.log(url); console.log(url);
$.modal.open("退检处理",url); $.modal.open("退检处理",url);
} }
// 导出
function exportExcel() {
var ids = $.table.selectColumns("complaintNoticeCode");
var dataParam = $("#formId").serializeArray();
let tipMsg = "确定导出当前所有数据吗?";
if ($.common.isNotEmpty(ids)) {
tipMsg = `确定导出 ${ids} 数据吗?`;
dataParam.push({ "name": "ids", "value": ids });
}
$.modal.confirm(tipMsg, function () {
$.modal.loading("正在导出数据,请稍后...");
$.post( prefix + "/export", dataParam, function (result) {
if (result.code === web_status.SUCCESS) {
window.location.href = ctx + "common/download?fileName="+ encodeURI(result.msg) + "&delete=" + true;
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
});
});
}
</script> </script>
</body> </body>
</html> </html>

314
ruoyi-admin/src/main/resources/templates/quality/complaintNotice/detail.html

@ -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: '图片',
field: 'materialPhotourl',
},
{ {
title: '物料名称', title: 'detailId',
field: 'materialName', field: 'complaintNoticeDetailId',
visible: false,
}, },
{ {
title: '物料类型', title: '客诉问题',
field: 'materialType', field: 'complaintProblem',
}, align: 'center',
{
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>
Loading…
Cancel
Save