Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev
王晓迪 4 months ago
parent
commit
49556f97a8
  1. 12
      ruoyi-admin/src/main/java/com/ruoyi/sales/controller/SalesEstimateController.java
  2. 6
      ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMaterialMapper.java
  3. 20
      ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateDetailMaterialServiceImpl.java
  4. 6
      ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMaterialMapper.xml
  5. 6
      ruoyi-admin/src/main/resources/templates/sales/estimate/add.html
  6. 40
      ruoyi-admin/src/main/resources/templates/sales/estimate/addChildMaterial.html
  7. 44
      ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html

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

@ -246,6 +246,18 @@ public class SalesEstimateController extends BaseController
}
/**
* 销售估价添加Bom-工程 删除物料
*/
@Log(title = "销售估价", businessType = BusinessType.DELETE)
@PostMapping("/removeEstimateDetailMaterial")
@ResponseBody
public AjaxResult removeEstimateDetailMaterial(Long estimateDetailMaterialId)
{
return toAjax(estimateDetailMaterialService.deleteSalesEstimateDetailMaterialById(estimateDetailMaterialId));
}
/**
* 新增采购成本 销售估价-采购

6
ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMaterialMapper.java

@ -108,4 +108,10 @@ public interface SalesEstimateDetailMaterialMapper
*/
List<SalesEstimateDetailMaterial> selectDetailMaterialListByEstimateDetailIds(List<Long> estimateDetailIds);
/**
* 通过物料名称查询详情物料的唯一性
*
* @return 结果
*/
int checkMaterialNameUnique(SalesEstimateDetailMaterial salesEstimateDetailMaterial);
}

20
ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateDetailMaterialServiceImpl.java

@ -3,6 +3,8 @@ package com.ruoyi.sales.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.sales.domain.SalesEstimateDetail;
@ -145,6 +147,10 @@ public class SalesEstimateDetailMaterialServiceImpl implements ISalesEstimateDet
String loginName = ShiroUtils.getLoginName();
List<SalesEstimateDetailMaterial> salesEstimateDetailMaterialList = salesEstimateDetail.getSalesEstimateDetailMaterialList();
for (SalesEstimateDetailMaterial salesEstimateDetailMaterial : salesEstimateDetailMaterialList) {
boolean isUnique = checkMaterialNameUnique(salesEstimateDetailMaterial);
if (isUnique){
throw new BusinessException("物料名:"+salesEstimateDetailMaterial.getMaterialName()+"已存在,请勿重复添加");
}
salesEstimateDetailMaterial.setCreateBy(loginName);
salesEstimateDetailMaterial.setCreateTime(new Date());
salesEstimateDetailMaterial.setEstimateDetailId(salesEstimateDetail.getEstimateDetailId());
@ -152,6 +158,20 @@ public class SalesEstimateDetailMaterialServiceImpl implements ISalesEstimateDet
return salesEstimateDetailMaterialMapper.insertSalesEstimateDetailMaterialBatch(salesEstimateDetailMaterialList);
}
/**
* 检查物料名称是否唯一
*
* @param salesEstimateDetailMaterial 销售估价详情物料价格
* @return 结果
*/
public boolean checkMaterialNameUnique(SalesEstimateDetailMaterial salesEstimateDetailMaterial) {
int result = salesEstimateDetailMaterialMapper.checkMaterialNameUnique(salesEstimateDetailMaterial);
if (result > 0){
return true;
}
return false;
}
/**
* 删除销售估价详情物料价格对象

6
ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMaterialMapper.xml

@ -58,6 +58,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</select>
<select id="checkMaterialNameUnique" parameterType="SalesEstimateDetailMaterial" resultType="Integer">
select count(1) from sales_estimate_detail_material
where
material_name = #{materialName}
</select>
<insert id="insertSalesEstimateDetailMaterial" parameterType="SalesEstimateDetailMaterial" useGeneratedKeys="true" keyProperty="estimateDetailMaterialId">
insert into sales_estimate_detail_material
<trim prefix="(" suffix=")" suffixOverrides=",">

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

@ -95,9 +95,9 @@
<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>
<!-- <a class="btn btn-success" onclick="insertNoMaterialRow()">-->
<!-- <i class="fa fa-plus"></i> 添加无料号物料-->
<!-- </a>-->
</div>
</div>
<div class="row">

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

@ -72,8 +72,12 @@
title: '物料类型',
field: 'materialType',
formatter: function(value, row, index) {
var data = [{ index: index, type: value }];
return $("#materialType").tmpl(data).html();
var $template = $("#materialType").tmpl({ index: index, type: value });
var $select = $template.find('select');
$select.change(function() {
// 这里可以做一些额外的操作,例如验证等
}).trigger('change'); // 触发 change 事件以设置初始值
return $select.prop('outerHTML');
}
},
{
@ -152,6 +156,19 @@
$.modal.alertWarning("请填写完整信息");
return;
}
// 获取当前行的下拉列表元素
var materialTypeSelect = $('#materialType-' + i);
// 获取选中的值
var selectedMaterialType = materialTypeSelect.val();
if (!selectedMaterialType) {
$.modal.alertWarning("请选择物料类型");
return;
}
// 更新表单数据
addChildMaterialTable[i].materialType = selectedMaterialType;
}
//将表数据转换成与complaintNoticeData格式一致的数组
@ -210,13 +227,18 @@
<!-- 物料类型下拉框模板-->
<script id="materialType" type="text/x-jquery-tmpl">
<div>
<select name='salesEstimateDetailMaterialList[${index}].materialType' class="form-control m-b select2-multiple" th:with="childList=${@category.getChildByCode('materialType')}" required>
<optgroup th:each="child: ${childList}" th:label="${child.name}">
<option th:each="childSon: ${child.children}" th:value="${childSon.code}" th:text="${#strings.concat(child.name,'-',childSon.name)}"></option>
</optgroup>
</select>
</div>
<div>
<select data-id='salesEstimateDetailMaterialList[${index}].materialType'
name='salesEstimateDetailMaterialList[${index}].materialType'
class="form-control"
th:with="childList=${@category.getChildByCode('materialType')}"
required
id="materialType-${index}">
<optgroup th:each="child: ${childList}" th:label="${child.name}">
<option th:each="childSon: ${child.children}" th:value="${childSon.code}" th:text="${#strings.concat(child.name,'-',childSon.name)}"></option>
</optgroup>
</select>
</div>
</script>

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

@ -320,7 +320,8 @@
$.table.init(options);
});
// 存储子表的状态
var childTableStates = {};
initChildTable = function(index, row, $detail) {
var parentRow = row;
var childTableId = 'child_table_'+index;
@ -339,6 +340,11 @@
field: 'estimateDetailId',
visible: false
},
{
title: '销售估价详情物料ID',
field: 'estimateDetailMaterialId',
visible: false
},
{
title: '物料名称',
field: 'materialName',
@ -366,12 +372,13 @@
title: '操作',
align: 'center',
formatter: function (value, row, index) {
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="deleteRow(\'' + row.shippingDeviceId + '\')"><i class="fa fa-remove"></i>删除</a>';
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeDetailMaterialRow(\'' + row.estimateDetailMaterialId + '\')"><i class="fa fa-remove"></i>删除</a>';
}
}
],
});
// 设置子表的初始状态为展开
childTableStates[index] = true;
// 动态生成 form 表单
var formHtml = '<form class="form-inline" data-index="' + index + '">';
formHtml += '<h3>运输、服务、开发成本</h3>';
@ -421,6 +428,37 @@ function queryParams(params) {
}
//删除子表物料的数据
function removeDetailMaterialRow(estimateDetailMaterialId) {
$.modal.confirm("确定删除该条销售估价详情物料信息吗?", function() {
var url = prefix + "/removeEstimateDetailMaterial";
var data = { "estimateDetailMaterialId": estimateDetailMaterialId };
$.operate.submit(url, "post", "json", data, function(result) {
if (result.success) {
$.modal.msgSuccess(result.msg);
// 获取子表的实例
var childTableId = 'child_table_' + index;
var $childTable = $('#' + childTableId);
// 刷新子表
$childTable.bootstrapTable('refresh');
// 检查子表是否有数据
if ($childTable.bootstrapTable('getData').length === 0) {
// 如果没有数据则收起子表
$childTable.closest('.detail-row').find('.detail-icon').click();
childTableStates[index] = false; // 更新子表状态
}
} else {
$.modal.msgError(result.msg);
}
});
});
}
//form计算模块
function getTotalAmount(){
let getData = $('#bootstrap-table').bootstrapTable('getData');

Loading…
Cancel
Save