Browse Source

[feat] 销售管理

新增添加销售估价Bom-工程前端页面
销售估价列表新增添加Bom按钮,新增打开Bom-工程前端页面的js方法
新增 后端接口 打开新增Bom销售估价-工程弹窗
新增 后端接口 新增保存Bom销售估价-工程
dev
liuxiaoxu 4 months ago
parent
commit
ee72646d88
  1. 29
      ruoyi-admin/src/main/java/com/ruoyi/sales/controller/SalesEstimateController.java
  2. 518
      ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html
  3. 10
      ruoyi-admin/src/main/resources/templates/sales/estimate/estimate.html

29
ruoyi-admin/src/main/java/com/ruoyi/sales/controller/SalesEstimateController.java

@ -103,6 +103,35 @@ public class SalesEstimateController extends BaseController
}
/**
* 新增Bom销售估价-工程
*/
@GetMapping("/engineeringAdd/{salesEstimateId}")
public String engineeringAdd(@PathVariable("salesEstimateId") Long salesEstimateId, ModelMap map)
{
SalesEstimate salesEstimate = salesEstimateService.selectSalesEstimateById(salesEstimateId);
map.put("salesEstimate", salesEstimate);
SalesEstimateDetailVo salesEstimateDetailVo = salesEstimateService.getSalesEstimateDetailVo();
map.put("salesEstimateDetailVo",salesEstimateDetailVo);
return prefix + "/engineeringAdd";
}
/**
* 新增保存Bom销售估价-工程
*/
@RequiresPermissions("sales:estimate:engineeringAdd")
@Log(title = "销售估价", businessType = BusinessType.INSERT)
@PostMapping("/engineeringAdd")
@ResponseBody
public AjaxResult engineeringAddSave(@RequestBody SalesEstimate salesEstimate)
{
return toAjax(salesEstimateService.insertSalesEstimate(salesEstimate));
}
/**
* 加载新增销售估价 物料选择弹窗
*/

518
ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html

@ -0,0 +1,518 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('工程新增销售估价')" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-estimate-add" th:object="${salesEstimate}">
<div class="form-group">
<label class="col-sm-4 control-label">业务员:</label>
<div class="col-sm-8">
<input name="businessMembers" id="businessMembers" th:field="*{businessMembers}" 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">
<div class="input-group date">
<input name="pricingDate" th:value="${#dates.format(salesEstimate.pricingDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">客户ID:</label>
<div class="col-sm-8">
<input name="enterpriseCode" th:field="*{enterpriseCode}" 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">
<input name="enterpriseName" th:field="*{enterpriseName}" 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 name="commonCurrency" id="commonCurrency_add" class="form-control m-b" th:with="type=${@dict.getType('sys_common_currency')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" required></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label is-required">美元汇率:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="usdRate" th:field="*{usdRate}" id="usdRate_add" class="form-control" type="text" required readonly>
<span class="input-group-addon">%</span>
</div>
</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="container">
<h4 class="form-header h4">计算</h4>
<div class="col-xs-12 form-row">
<label class=" col-sm-2">物料合计:</label><input class="col-sm-4" name="materialSum" id="materialSum_add" type="number" readonly/>
<label class=" col-sm-2">数量合计:</label><input class="col-sm-4" name="enterpriseSum" id="enterpriseSum_add" type="number" readonly/>
</div>
<div class="col-xs-12 form-row">
<label class="col-sm-2"> 不含税单价(RMB):</label><input placeholder="RMB" class="col-sm-4" name="noTaxRmb" id="noTaxRmb_add" type="number" readonly/>
<label class="col-sm-2"> 不含税总价(RMB):</label><input placeholder="RMB" class="col-sm-4" name="allNoTaxRmb" id="allNoTaxRmb_add" type="number" readonly/>
</div>
<div class="col-xs-12 form-row">
<label class="col-sm-2"> 含税单价(RMB):</label><input placeholder="RMB" class="col-sm-4" name="taxRmb" id="taxRmb_add" type="number" readonly/>
<label class="col-sm-2"> 含税总价(RMB):</label><input placeholder="RMB" class="col-sm-4" name="allTaxRmb" id="allTaxRmb_add" type="number" readonly/>
</div>
<div class="col-xs-12">
<label class="col-sm-2">不含税单价(USD):</label><input placeholder="美元" class="col-sm-4" name="noTaxDollar" id="noTaxDollar_add" type="number" readonly/>
<label class="col-sm-2">不含税总价(USD):</label><input placeholder="美元" class="col-sm-4" name="allNoTaxDollar" id="allNoTaxDollar_add" type="number" readonly/>
</div>
<div class="col-xs-12 form-row">
<label class="col-sm-2">含税单价(USD):</label><input placeholder="美元" class="col-sm-4" name="taxDollar" id="taxDollar_add" type="number" readonly/>
<label class="col-sm-2">含税总价(USD):</label><input placeholder="美元" class="col-sm-4" name="allTaxDollar" id="allTaxDollar_add" type="number" readonly/>
</div>
</div>
</form>
<div class="container">
<div class="form-row">
<div class="btn-group-sm">
<span>选择报价信息</span>
<a class="btn btn-success" onclick="insertMaterialRow()">
<i class="fa fa-plus"></i> 添加物料
</a>
<a class="btn btn-success" onclick="insertNoMaterialRow()">
<i class="fa fa-plus"></i> 添加无料号物料
</a>
</div>
</div>
<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 :: datetimepicker-js" />
<th:block th:include="include::bootstrap-table-editable-js"/>
<script th:inline="javascript">
var prefix = ctx + "sales/estimate"
var materialGearPositionDatas = [[${@dict.getType('material_gear_position')}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var salesEstimateDetailVo = [[${salesEstimateDetailVo}]];
$("#form-estimate-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
// 获取表单数据
const estimateData = $("#form-estimate-add").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
// 销售估价物料
var estimateMaterialTable = $('#bootstrap-table').bootstrapTable('getData');
if (estimateMaterialTable.length === 0){
$.modal.alertWarning("请至少添加一条物料信息");
return;
}
// 将表数据转换成与estimateData格式一致的数组
var estimateMaterialDataList = estimateMaterialTable.map(function(item) {
// 根据实际字段名调整
return {
"materialNo": item.materialNo,
"materialName": item.materialName,
"materialType": item.materialType,
"materialPhotourl": item.materialPhotourl,
"materialDescribe": item.materialDescribe,
"materialBrand": item.materialBrand,
"materialUnit": item.materialUnit,
"materialProcessMethod": item.materialProcessMethod,
"materialGearPosition": item.materialGearPosition,
"materialNum":item.materialNum,
"noTaxRmb": item.noTaxRmb,
"taxRmb": item.taxRmb,
"allNoTaxRmb": item.allNoTaxRmb,
"allTaxRmb": item.allTaxRmb,
"noTaxDollar": item.noTaxDollar,
"taxDollar": item.taxDollar,
"allNoTaxDollar": item.allNoTaxDollar,
"allTaxDollar": item.allTaxDollar,
"warehouseDept": item.warehouseDept,
// ...其他字段
};
});
// 获取料号档位的最新值
$('.form-control[id^="materialGearPosition_"]').each(function() {
const index = $(this).attr('id').match(/materialGearPosition_(\d+)/)[1]; // 提取索引
const value = $(this).val(); // 获取下拉框的值
estimateMaterialDataList[index].materialGearPosition = value; // 更新料号档位
});
const combinedData = Object.assign({}, estimateData, {
salesEstimateDetailList: estimateMaterialDataList,
});
// 合并表单数据和表格数据
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/add", jsonData);
}
}
$("input[name='pricingDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
// 点击选择物料按钮
function insertMaterialRow() {
var url = prefix + '/estimateMaterialSelect';
var options = {
title: '选择物料',
url: url,
callBack: estimateDoSubmit
};
$.modal.openOptions(options);
}
$(function() {
var options = {
id:'bootstrap-table',
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
modalName: "销售估价详情",
editFiled:"noTaxRmb",
columns: [
{
checkbox: true
},
{
title: '销售估价详情ID',
field: 'estimateDetailId',
visible: false
},
{
title: '料号',
field: 'materialNo',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '物料类型',
field: 'materialType',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
title: '图片地址',
field: 'materialPhotoUrl',
},
{
title: '物料单位',
field: 'materialUnit',
},
{
title: '物料品牌',
field: 'materialBrand',
},
{
title: '物料描述',
field: 'materialDescribe',
},
{
title: '加工方式',
field: 'materialProcessMethod',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
title: '料号档位',
width: 100,
field: 'materialGearPosition',
formatter: function(value, row, index) {
// 为每个下拉框添加唯一的 id 和 name
var selectId = 'materialGearPosition_' + index;
var selectName = 'salesEstimateDetailList[' + index + '].materialGearPosition';
// 创建下拉框 HTML
var html = $.common.sprintf(
"<select class='form-control' id='%s' name='%s' required>" +
" <option value='0' %s>A</option>" +
" <option value='1' %s>B</option>" +
" <option value='2' %s>C</option>" +
" <option value='3' %s>D</option>" +
" <option value='4' %s>E</option>" +
" <option value='5' %s>F</option>" +
"</select>",
selectId, selectName,
value === '0' ? 'selected' : '',
value === '1' ? 'selected' : '',
value === '2' ? 'selected' : '',
value === '3' ? 'selected' : '',
value === '4' ? 'selected' : '',
value === '5' ? 'selected' : ''
);
return html;
}
},
{
title: '物料数量',
field: 'materialNum',
editable: true,
},
{
title: '不含税单价',
field: 'noTaxRmb',
},
{
title: '含税单价',
field: 'taxRmb',
},
{
title: '不含税总价',
field: 'allNoTaxRmb',
},
{
title: '含税总价',
field: 'allTaxRmb',
},
{
title: '含税单价',
field: 'taxDollar',
},
{
title: '不含税单价',
field: 'noTaxDollar',
},
{
title: '含税总价',
field: 'allTaxDollar',
},
{
title: '不含税总价',
field: 'allNoTaxDollar',
},
{
title: '入库部门',
field: 'warehouseDept',
visible:false
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeMaterialRow(\'' + row.materialNo + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}],
onEditableSave:function(field, row, oldValue, $el){
// 确保getTotalAmount函数存在且正确引用
getTotalAmount();
},
};
$.table.init(options);
});
function estimateDoSubmit(index, layero,uniqueId){
console.log(uniqueId);
var iframeWin = window[layero.find('iframe')[0]['name']];
var rowData = iframeWin.$('#bootstrap-estimateMaterialSelect-table').bootstrapTable('getSelections')[0];
//判断是否重复
var rows = $("#bootstrap-table").bootstrapTable('getData').length;
for(var i=0;i<rows;i++){
var data = $("#bootstrap-table").bootstrapTable('getData')[i];
if(data.materialNo == rowData.materialNo){
$.modal.alertError("不能选择已添加过的相同物料");
return;
}
}
console.log("rowData: "+rowData);
$("#bootstrap-table").bootstrapTable('insertRow', {
index:1,
row: {
materialNo:rowData.materialNo,
materialPhotourl:rowData.photoUrl,
materialName: rowData.materialName,
materialType: rowData.materialType,
materialDescribe: rowData.describe,
materialBrand: rowData.brand,
materialUnit: rowData.unit,
materialProcessMethod: rowData.processMethod,
materialDeptType: rowData.warehouseDept,
materialNum: 0
}
})
getTotalAmount();
layer.close(index);
}
// 逻辑删除前端的一行数据
function removeMaterialRow(materialNo){
$("#bootstrap-table").bootstrapTable('remove', {
field: 'materialNo',
values: materialNo
})
getTotalAmount();
}
// $(document).ready(function() {
// // 监听表格中的物料数量输入框的变化
// $('#bootstrap-table').on('input', '.material-num-input', function() {
// getTotalAmount();
// });
//
// // 初始加载时也计算一次
// getTotalAmount();
// });
//
// function getTotalAmount() {
// let getData = $('#bootstrap-table').bootstrapTable('getData');
// let enterpriseSum = 0;
//
// // 计算物料数量总和
// enterpriseSum = getData.reduce((sum, item) => sum + (parseInt(item.materialNum) || 0), 0);
//
// // 更新页面上的输入框
// $("#enterpriseSum_add").val(enterpriseSum);
// }
//form计算模块
function getTotalAmount(){
let getData = $('#bootstrap-table').bootstrapTable('getData');
var materialSum = 0;
var enterpriseSum = 0;
var noTaxRmb = 0;
var taxRmb = 0;
var allNoTaxRmb = 0;
var allTaxRmb = 0;
var noTaxDollar = 0;
var taxDollar = 0;
var allNoTaxDollar = 0;
var allTaxDollar = 0;
materialSum = getData.length;
enterpriseSum = getData.reduce((sum, item) => sum + (parseInt(item.materialNum) || 0), 0);
for(var i=0;i<getData.length;i++){
noTaxRmb += parseFloat(getData[i].noTaxRmb) || 0;
taxRmb += parseFloat(getData[i].taxRmb) || 0;
allNoTaxRmb += parseFloat(getData[i].allNoTaxRmb) || 0;
allTaxRmb += parseFloat(getData[i].allTaxRmb) || 0;
noTaxDollar += parseFloat(getData[i].noTaxDollar) || 0;
taxDollar += parseFloat(getData[i].taxDollar) || 0;
allNoTaxDollar += parseFloat(getData[i].allNoTaxDollar) || 0;
allTaxDollar += parseFloat(getData[i].allTaxDollar) || 0;
}
noTaxRmb = noTaxRmb.toFixed(2);
taxRmb = taxRmb.toFixed(2);
allNoTaxRmb = allNoTaxRmb.toFixed(2);
allTaxRmb = allTaxRmb.toFixed(2);
noTaxDollar = noTaxDollar.toFixed(2);
taxDollar = taxDollar.toFixed(2);
allNoTaxDollar = allNoTaxDollar.toFixed(2);
allTaxDollar = allTaxDollar.toFixed(2);
$("input[name='materialSum']").val(materialSum);
$("input[name='enterpriseSum']").val(enterpriseSum);
$("input[name='noTaxRmb']").val(noTaxRmb);
$("input[name='taxRmb']").val(taxRmb);
$("input[name='allNoTaxRmb']").val(allNoTaxRmb);
$("input[name='allTaxRmb']").val(allTaxRmb);
$("input[name='noTaxDollar']").val(noTaxDollar);
$("input[name='taxDollar']").val(taxDollar);
$("input[name='allNoTaxDollar']").val(allNoTaxDollar);
$("input[name='allTaxDollar']").val(allTaxDollar);
}
// 计算并更新所有其他总和
// function updateAllSums() {
// let getData = $('#bootstrap-table').bootstrapTable('getData');
// let noTaxRmb = 0;
// let taxRmb = 0;
// let allNoTaxRmb = 0;
// let allTaxRmb = 0;
// let noTaxDollar = 0;
// let taxDollar = 0;
// let allNoTaxDollar = 0;
// let allTaxDollar = 0;
//
// getData.forEach(item => {
// noTaxRmb += parseFloat(item.noTaxRmb) || 0;
// taxRmb += parseFloat(item.taxRmb) || 0;
// allNoTaxRmb += parseFloat(item.allNoTaxRmb) || 0;
// allTaxRmb += parseFloat(item.allTaxRmb) || 0;
// noTaxDollar += parseFloat(item.noTaxDollar) || 0;
// taxDollar += parseFloat(item.taxDollar) || 0;
// allNoTaxDollar += parseFloat(item.allNoTaxDollar) || 0;
// allTaxDollar += parseFloat(item.allTaxDollar) || 0;
// });
//
// noTaxRmb = noTaxRmb.toFixed(2);
// taxRmb = taxRmb.toFixed(2);
// allNoTaxRmb = allNoTaxRmb.toFixed(2);
// allTaxRmb = allTaxRmb.toFixed(2);
// noTaxDollar = noTaxDollar.toFixed(2);
// taxDollar = taxDollar.toFixed(2);
// allNoTaxDollar = allNoTaxDollar.toFixed(2);
// allTaxDollar = allTaxDollar.toFixed(2);
//
// $("input[name='noTaxRmb']").val(noTaxRmb);
// $("input[name='taxRmb']").val(taxRmb);
// $("input[name='allNoTaxRmb']").val(allNoTaxRmb);
// $("input[name='allTaxRmb']").val(allTaxRmb);
// $("input[name='noTaxDollar']").val(noTaxDollar);
// $("input[name='taxDollar']").val(taxDollar);
// $("input[name='allNoTaxDollar']").val(allNoTaxDollar);
// $("input[name='allTaxDollar']").val(allTaxDollar);
// }
</script>
</body>
</html>

10
ruoyi-admin/src/main/resources/templates/sales/estimate/estimate.html

@ -67,6 +67,8 @@
var removeFlag = [[${@permission.hasPermi('sales:estimate:remove')}]];
var cancelFlag = [[${@permission.hasPermi('sales:estimate:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('sales:estimate:restore')}]];
var engineeringAddFlag = [[${@permission.hasPermi('sales:estimate:engineeringAdd')}]];
var estimateStatusDatas = [[${@dict.getType('estimate_status')}]];
var commonCurrencyDatas = [[${@dict.getType('sys_common_currency')}]];
var prefix = ctx + "sales/estimate";
@ -166,6 +168,9 @@
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.salesEstimateId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.salesEstimateId + '\')"><i class="fa fa-remove"></i>删除</a> ');
if(row.estimateStatus == '0'){
actions.push('<a class="btn btn-success btn-xs ' + engineeringAddFlag + '" href="javascript:void(0)" onclick="engineeringAdd(\'' + row.salesEstimateId + '\')"><i class="fa fa-edit"></i>添加BOM</a> ');
}
if(row.delFlag == '0'){
actions.push('<a class="btn btn-danger btn-xs ' + cancelFlag + '" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a> ');
}else{
@ -185,6 +190,11 @@
$.modal.open("添加经营成本模板", url);
}
//工程 添加BOM
function engineeringAdd(salesEstimateId){
var url = prefix + "/engineeringAdd/" + salesEstimateId;
$.modal.open("添加BOM", url);
}
</script>
</body>
</html>
Loading…
Cancel
Save