Browse Source

[fix]委外加工

修改委外报价编辑前端页面表格数据加载方法
修改前端页面整合数据的方法
修改委外报价实体类字段类型
修改接收编辑保存页面对象为OutsourceQuote类
[feat]委外加工 委外报价 新增前端页面表格内输入框下拉框动态数据的获取方法getunit、getnormb、getrmb
新增mapper按报价编号批量删除子表信息的方法
dev
王晓迪 4 months ago
parent
commit
cd97fc698d
  1. 20
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceQuoteController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceQuote.java
  3. 12
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceQuoteMapper.java
  4. 5
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceQuoteServiceImpl.java
  5. 8
      ruoyi-admin/src/main/resources/mapper/system/OutsourceQuoteMapper.xml
  6. 216
      ruoyi-admin/src/main/resources/templates/system/outsource_quote/edit.html

20
ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceQuoteController.java

@ -131,22 +131,16 @@ public class OutsourceQuoteController extends BaseController
@Log(title = "委外报价", businessType = BusinessType.UPDATE) @Log(title = "委外报价", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(@RequestBody OutsourceQuoteVO childVO) public AjaxResult editSave(@RequestBody OutsourceQuote outsourceQuote)
{ {
System.out.println(childVO.toString()); List<OutsourceQuoteChild> children = outsourceQuote.getOutsourceQuoteChildList();
List<OutsourceQuoteChild> children = childVO.getOutsourceQuoteChildList();
for (OutsourceQuoteChild child:children) { for (OutsourceQuoteChild child:children) {
child.setOutsourceQuoteCode(childVO.getOutsourceQuoteCode()); child.setOutsourceQuoteCode(outsourceQuote.getOutsourceQuoteCode());
child.setSupplierCode(childVO.getSupplierQuoteCode()); child.setSupplierCode(outsourceQuote.getSupplierQuoteCode());
child.setSupplierName(childVO.getSupplierName()); child.setSupplierName(outsourceQuote.getSupplierName());
child.setTaxRate(childVO.getTaxRate()); child.setTaxRate(outsourceQuote.getTaxRate());
} }
OutsourceQuote outsourceQuote = new OutsourceQuote(); // System.out.println(children);
outsourceQuote.setPricingDate(childVO.getPricingDate());
outsourceQuote.setProcessAmount(children.size());
outsourceQuote.setSupplierQuoteCode(childVO.getSupplierQuoteCode());
outsourceQuote.setSupplierName(childVO.getSupplierName());
outsourceQuote.setOutsourceQuoteChildList(children);
return toAjax(outsourceQuoteService.updateOutsourceQuote(outsourceQuote)); return toAjax(outsourceQuoteService.updateOutsourceQuote(outsourceQuote));
} }

7
ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceQuote.java

@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import java.math.BigDecimal;
/** /**
* 委外报价对象 outsource_quote * 委外报价对象 outsource_quote
@ -38,7 +39,7 @@ public class OutsourceQuote extends BaseEntity
/** 税率 */ /** 税率 */
@Excel(name = "税率") @Excel(name = "税率")
private Long taxRate; private BigDecimal taxRate;
/** 定价日期 */ /** 定价日期 */
@Excel(name = "定价日期") @Excel(name = "定价日期")
@ -102,12 +103,12 @@ public class OutsourceQuote extends BaseEntity
return processAmount; return processAmount;
} }
public void setTaxRate(Long taxRate) public void setTaxRate(BigDecimal taxRate)
{ {
this.taxRate = taxRate; this.taxRate = taxRate;
} }
public Long getTaxRate() public BigDecimal getTaxRate()
{ {
return taxRate; return taxRate;
} }

12
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceQuoteMapper.java

@ -72,10 +72,18 @@ public interface OutsourceQuoteMapper
/** /**
* 批量删除委外报价工序信息 * 批量删除委外报价工序信息
* *
* @param outsourceQuoteIds 需要删除的数据主键集合 * @param outsourceProcessCodes 需要删除的数据主键集合
* @return 结果
*/
public int deleteOutsourceQuoteChildByOutsourceProcessCodes(String[] outsourceProcessCodes);
/**
* 通过委外报价主键删除委外报价工序信息
*
* @param outsourceQuoteCode 委外报价编号
* @return 结果 * @return 结果
*/ */
public int deleteOutsourceQuoteChildByOutsourceProcessCodes(String[] outsourceQuoteIds); public int deleteOutsourceQuoteChildByOutsourceQuoteCode(String outsourceQuoteCode);
/** /**
* 批量新增委外报价工序信息 * 批量新增委外报价工序信息

5
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceQuoteServiceImpl.java

@ -105,7 +105,7 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService
public int updateOutsourceQuote(OutsourceQuote outsourceQuote) public int updateOutsourceQuote(OutsourceQuote outsourceQuote)
{ {
outsourceQuote.setUpdateTime(DateUtils.getNowDate()); outsourceQuote.setUpdateTime(DateUtils.getNowDate());
outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceProcessCode(outsourceQuote.getOutsourceQuoteId()); outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceQuoteCode(outsourceQuote.getOutsourceQuoteCode());
insertOutsourceQuoteChild(outsourceQuote); insertOutsourceQuoteChild(outsourceQuote);
return outsourceQuoteMapper.updateOutsourceQuote(outsourceQuote); return outsourceQuoteMapper.updateOutsourceQuote(outsourceQuote);
} }
@ -134,7 +134,8 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService
@Override @Override
public int deleteOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId) public int deleteOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId)
{ {
outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceProcessCode(outsourceQuoteId); OutsourceQuote outsourceQuote = outsourceQuoteMapper.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId);
outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceQuoteCode(outsourceQuote.getOutsourceQuoteCode());
return outsourceQuoteMapper.deleteOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); return outsourceQuoteMapper.deleteOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId);
} }

8
ruoyi-admin/src/main/resources/mapper/system/OutsourceQuoteMapper.xml

@ -69,7 +69,7 @@
</select> </select>
<select id="selectOutsourceQuoteChildList" resultType="OutsourceQuoteChild" resultMap="OutsourceQuoteChildResult"> <select id="selectOutsourceQuoteChildList" resultType="OutsourceQuoteChild" resultMap="OutsourceQuoteChildResult">
select outsource_quote_child_id, outsource_quote_code, outsource_process_code, outsource_process_no, outsource_process_name, remark, tax_rate, material_rmb, material_noRmb, supplier_code, supplier_name, create_by, create_time, update_by, update_time, audit_status select outsource_quote_child_id, outsource_quote_code, outsource_process_code, outsource_process_no, outsource_process_name, remark, tax_rate, material_rmb, material_noRmb, supplier_code, supplier_name, create_by, create_time, update_by, update_time, audit_status,charge_unit
from outsource_quote_child from outsource_quote_child
where outsource_quote_code = #{outsource_quote_code} where outsource_quote_code = #{outsource_quote_code}
</select> </select>
@ -136,6 +136,8 @@
</foreach> </foreach>
</delete> </delete>
<delete id="deleteOutsourceQuoteChildByOutsourceProcessCode" parameterType="String"> <delete id="deleteOutsourceQuoteChildByOutsourceProcessCode" parameterType="String">
delete from outsource_quote_child where outsource_process_code in delete from outsource_quote_child where outsource_process_code in
<foreach item="outsourceProcessCode" collection="array" open="(" separator="," close=")"> <foreach item="outsourceProcessCode" collection="array" open="(" separator="," close=")">
@ -154,9 +156,9 @@
</delete> </delete>
<insert id="batchOutsourceQuoteChild"> <insert id="batchOutsourceQuoteChild">
insert into outsource_quote_child( outsource_quote_child_id, outsource_quote_code, outsource_process_code, outsource_process_no, outsource_process_name, remark, tax_rate, material_rmb, material_noRmb, supplier_code, supplier_name, create_by, create_time, update_by, update_time, audit_status) values insert into outsource_quote_child( outsource_quote_child_id, outsource_quote_code, outsource_process_code, charge_unit, outsource_process_no, outsource_process_name, remark, tax_rate, material_rmb, material_noRmb, supplier_code, supplier_name, create_by, create_time, update_by, update_time, audit_status) values
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
( #{item.outsourceQuoteChildId}, #{item.outsourceQuoteCode}, #{item.outsourceProcessCode}, #{item.outsourceProcessNo}, #{item.outsourceProcessName}, #{item.remark}, #{item.taxRate}, #{item.materialRmb}, #{item.materialNormb}, #{item.supplierCode}, #{item.supplierName}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.auditStatus}) ( #{item.outsourceQuoteChildId}, #{item.outsourceQuoteCode}, #{item.outsourceProcessCode},#{item.chargeUnit}, #{item.outsourceProcessNo}, #{item.outsourceProcessName}, #{item.remark}, #{item.taxRate}, #{item.materialRmb}, #{item.materialNormb}, #{item.supplierCode}, #{item.supplierName}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.auditStatus})
</foreach> </foreach>
</insert> </insert>

216
ruoyi-admin/src/main/resources/templates/system/outsource_quote/edit.html

@ -4,7 +4,7 @@
<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-outsource_quote-edit" th:object="${outsourceQuote}"> <form class="form-horizontal m" id="form-outsource_quote-edit" th:object="${outsourceQuote}">
<h4 class="form-header h4">委外报价信息</h4> <h4 class="form-header h4">委外报价信息</h4>
<input name="outsourceQuoteId" th:field="*{outsourceQuoteId}" type="hidden"> <input name="outsourceQuoteId" th:field="*{outsourceQuoteId}" type="hidden">
@ -80,14 +80,14 @@
<div class="col-sm-12"> <div class="col-sm-12">
<button type="button" class="btn btn-blue btn-sm" onclick="processadd()"><i class="fa fa-plus"> 增加</i></button> <button type="button" class="btn btn-blue btn-sm" onclick="processadd()"><i class="fa fa-plus"> 增加</i></button>
<div class="col-sm-12 select-table table-striped"> <div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table> <table id="bootstrap-table-process"></table>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "system/outsource_quote"; var prefix = ctx + "system/outsource_quote";
$("#form-outsource_quote-edit").validate({ $("#form-outsource_quote-edit").validate({
focusCleanup: true focusCleanup: true
@ -115,51 +115,58 @@
}; };
function submitHandler() { function submitHandler() {
if ($.validate.form()) {
var url = prefix + "/edit"; var url = prefix + "/edit";
var outsourceQuote = {
};
if ($.validate.form()) { if ($.validate.form()) {
var outsourceQuoteChildList = [];
// 获取表单数据 // 获取表单数据
const outsourceQuoteData = $("#form-outsource_quote-edit").serializeArray().reduce((obj, item) => { const outsourceQuoteData = $("#form-outsource_quote-edit").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value; obj[item.name] = item.value;
return obj; return obj;
}, {}); }, {});
// console.log(outsourceQuoteData); console.log(outsourceQuoteData);
outsourceQuote = {
outsourceQuoteId: outsourceQuoteData.outsourceQuoteId,
outsourceQuoteCode: outsourceQuoteData.outsourceQuoteCode,
supplierQuoteCode: outsourceQuoteData.supplierCode,
supplierName: outsourceQuoteData.supplierName,
pricingDate: outsourceQuoteData.pricingDate,
taxRate: outsourceQuoteData.taxRate,
remark: outsourceQuoteData.remark,
processAmount: 0,
outsourceQuoteChildList: []
}
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 // 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var rows = $('#bootstrap-table').bootstrapTable('getData'); var rows = $('#bootstrap-table-process').bootstrapTable('getData');
// console.log(JSON.stringify(rows));
// 检查表格数据是否为空 // 检查表格数据是否为空
if (rows.length === 0) { if (rows.length === 0) {
$.modal.alertWarning("请至少添加一条委外工序再保存!"); $.modal.alertWarning("请至少添加一条委外工序再保存!");
return; return;
} }else{
// 将表数据转换成与qualityReportData格式一致的数组 console.log(rows);
var outsourceQuoteChildList = rows.map(function (item) { outsourceQuote.processAmount = rows.length;
// 根据实际字段名调整 var unit = getUnit();
return { var noRmb = getNoRmb();
"outsourceProcessCode": item.outsourceProcessCode, var rmb = getRmb();
"outsourceProcessNo": item.outsourceProcessNo, for(var i=0;i<rows.length;i++){
"chargeUnit": item.chargeUnit, var quoteChild = {
"materialRmb": item.materialRmb, outsourceProcessCode: rows[i].outsourceProcessCode,
"materialNormb": item.materialNormb, outsourceProcessNo: rows[i].outsourceProcessNo,
outsourceProcessName: rows[i].outsourceProcessName,
// ...其他字段 chargeUnit:unit[i],
materialNormb: noRmb[i],
materialRmb: rmb[i],
}; };
}); outsourceQuote.outsourceQuoteChildList.push(quoteChild);
const combinedData = Object.assign({}, outsourceQuoteData,
{
outsourceQuoteChildList: outsourceQuoteChildList,
},
);
// 合并表单数据和表格数据
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData);
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
saveJson(prefix + "/edit", jsonData);
} }
console.log(outsourceQuote);
} }
}; saveJson(prefix + "/edit", JSON.stringify(outsourceQuote));
}
}
function processadd() { function processadd() {
var url = prefix + "/processadd"; var url = prefix + "/processadd";
var options = { var options = {
@ -175,61 +182,130 @@
// // 这里取到的是多行的 // // 这里取到的是多行的
var rowData = layero.find("iframe")[0].contentWindow.getSelections(); var rowData = layero.find("iframe")[0].contentWindow.getSelections();
//判断是否重复 //判断是否重复
var rows = $("#bootstrap-table").bootstrapTable('getData').length; var rows = $("#bootstrap-table-process").bootstrapTable('getData').length;
if(rows>0){ if(rows>0){
for(var i=0;i<rows;i++){ for(var i=0;i<rows;i++){
var data = $("#bootstrap-table").bootstrapTable('getData')[i]; var data = $("#bootstrap-table-process").bootstrapTable('getData')[i];
for(var j=0;j<rowData.length;j++){ for(var j=0;j<rowData.length;j++){
if(data.outsourceProcessCode==rowData[j].outsourceProcessCode){ if(data.outsourceProcessNo==rowData[j].outsourceProcessNo){
$.modal.alertError("不能选择已添加过的相同工序"); $.modal.alertError("不能选择已添加过的相同工序");
return; return;
} }
insertTable(rowData[i]);
} }
sub.addRow(rowData[i]);
}; };
}else{ }else{
for(i=0;i<rowData.length;i++){ for(i=0;i<rowData.length;i++){
sub.addRow(rowData[i]); insertTable(rowData[i]);
} }
} }
layer.closeAll(); layer.closeAll();
} }
function insertTable(rowData) {
$("#bootstrap-table-process").bootstrapTable('insertRow', {
index: 1,
row: {
outsourceProcessNo: rowData.outsourceProcessNo,
outsourceProcessCode: rowData.outsourceProcessCode,
outsourceProcessName: rowData.outsourceProcessName,
materialNoRmb: 0.00,
materialRmb: 0.00,
}
});
}
function getUnit(){
var selectElements = $('#bootstrap-table-process').find('select[id^="chargeUnit"]');
// 遍历每个下拉框
var unit = [];
selectElements.each(function() {
// 获取当前下拉框的值
var selectedValue = $(this).val();
unit.push(selectedValue);
});
console.log(unit);
return unit;
}
function getNoRmb(){
var selectElements = $('#bootstrap-table-process').find('input[id^="materialNormb"]');
// 遍历每个下拉框
var noRmb = [];
selectElements.each(function() {
// 获取当前下拉框的值
var selectedValue = $(this).val();
noRmb.push(selectedValue);
});
// console.log(noRmb);
return noRmb;
};
function getRmb(){
var selectElements = $('#bootstrap-table-process').find('input[id^="materialRmb"]');
// 遍历每个输入框
var rmb = [];
selectElements.each(function() {
// 获取当前输入框的值
var selectedValue = $(this).val();
rmb.push(selectedValue);
});
// console.log(rmb);
return rmb;
};
function initTable(data,index){
$("#bootstrap-table-process").bootstrapTable('insertRow', {
index:1,
row: {
outsourceProcessNo: data.outsourceProcessNo,
outsourceProcessCode: data.outsourceProcessCode,
outsourceProcessName: data.outsourceProcessName,
}
});
$('#bootstrap-table-process').find('select[id="chargeUnit'+index+'"]').val(data.chargeUnit);
$('#bootstrap-table-process').find('input[id="materialNormb'+index+'"]').val(data.materialNormb);
$('#bootstrap-table-process').find('input[id="materialRmb'+index+'"]').val(data.materialRmb);
};
$(function() { $(function() {
var options = { var options = {
data: [[${outsourceQuote.outsourceQuoteChildList}]], id: "bootstrap-table-process",
pagination: false, pagination: false,
showSearch: false, showSearch: false,
showRefresh: false, showRefresh: false,
showToggle: false, showToggle: false,
showColumns: false, showColumns: false,
sidePagination: "client", sidePagination: "client",
data: [[${outsourceQuote.outsourceQuoteChildList}]],
columns: [ columns: [
{ {
field: 'outsourceProcessId', field: 'outsourceProcessId',
align: 'center', align: 'center',
title: '委外工序主键', title: '委外工序主键',
visible: false, visible: false,
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' readonly='readonly' name='outsourceQuoteChildList[%s].outsourceProcessId' value='%s'>", index, value);
return html;
}
}, },
{ {
field: 'outsourceProcessNo', field: 'outsourceProcessNo',
align: 'center', align: 'center',
title: '委外工序编号', title: '委外工序编号',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='outsourceQuoteChildList[%s].outsourceProcessNo' value='%s'>", index, value);
return html;
}
}, },
{ {
field: 'outsourceProcessName', field: 'outsourceProcessName',
align: 'center', align: 'center',
title: '委外工序名称', title: '委外工序名称',
},
{
field: 'chargeUnit',
align: 'center',
title: '计价单位',
width: 120,
// overflow: visible,
formatter: function(value, row, index) { formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='outsourceQuoteChildList[%s].outsourceProcessName' value='%s'>", index, value); var html = $.common.sprintf("<select class='form-control' id='chargeUnit" + index + "' data-first-title= '请选择' > " +
"<option value=''>请选择</option>" +
"<option value='0'>按重量计</option>" +
"<option value='1'>按数量计</option>" +
"<option value='2'>按面积计</option>" +
"</select>", index, value);
return html; return html;
} }
}, },
@ -238,7 +314,7 @@
align: 'center', align: 'center',
title: '工序的不含税单价(RMB) ', title: '工序的不含税单价(RMB) ',
formatter: function(value, row, index) { formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='outsourceQuoteChildList[%s].materialNormb' value='%s'>", index, value); var html = $.common.sprintf("<input class='form-control' type='text' id='materialNormb" + index + "'>", index, value);
return html; return html;
} }
}, },
@ -247,7 +323,7 @@
align: 'center', align: 'center',
title: '工序的含税单价(RMB)', title: '工序的含税单价(RMB)',
formatter: function(value, row, index) { formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='outsourceQuoteChildList[%s].materialRmb' value='%s'>", index, value); var html = $.common.sprintf("<input class='form-control' type='text' id='materialRmb" + index + "'>", index, value);
return html; return html;
} }
}, },
@ -260,31 +336,21 @@
} }
}] }]
}; };
// console.log(options.data);
$.table.init(options); $.table.init(options);
var quoteDetail = options.data;
$.each(quoteDetail, function(index, item) {
// 设置下拉框的值
$('#chargeUnit' + index).val(item.chargeUnit);
// 设置不含税单价输入框的值
$('#materialNormb' + index).val(item.materialNormb);
// 设置含税单价输入框的值
$('#materialRmb' + index).val(item.materialRmb);
}); });
function addRow() { });
var count = $("#" + table.options.id).bootstrapTable('getData').length;
var row = { </script>
index: $.table.serialNumber(count),
outsourceQuoteCode: "",
outsourceProcessNo: "",
outsourceProcessName: "",
remark: "",
taxRate: "",
materialRmb: "",
materialNormb: "",
supplierCode: "",
supplierName: "",
createBy: "",
createTime: "",
updateBy: "",
updateTime: "",
auditStatus: "",
}
sub.addRow(row);
};
</script>
</body> </body>
</html> </html>
Loading…
Cancel
Save