Browse Source

[feat] 销售管理

新增销售估价物料详情添加子表物料数据前端页面
工程添加物料页面新增添加物料按钮
销售估价Controller新增 新增销售估价  销售估价详情数据集合展示 后端接口;新增 加载新增销售估价-工程 子表物料选择弹窗后端接口;新增 销售估价添加Bom-工程 新增保存物料后端接口;
销售估价详情实体类新增 销售估价详情物料子表集合
销售估价详情新增 根据估价编号查询估价详情集合后端接口
销售估价详情物料新增 批量新增销售估价详情物料价格后端接口
dev
liuxiaoxu 4 months ago
parent
commit
ae34090d88
  1. 56
      ruoyi-admin/src/main/java/com/ruoyi/sales/controller/SalesEstimateController.java
  2. 14
      ruoyi-admin/src/main/java/com/ruoyi/sales/domain/SalesEstimateDetail.java
  3. 7
      ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMapper.java
  4. 10
      ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMaterialMapper.java
  5. 9
      ruoyi-admin/src/main/java/com/ruoyi/sales/service/ISalesEstimateDetailMaterialService.java
  6. 7
      ruoyi-admin/src/main/java/com/ruoyi/sales/service/ISalesEstimateDetailService.java
  7. 21
      ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateDetailMaterialServiceImpl.java
  8. 13
      ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateDetailServiceImpl.java
  9. 7
      ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMapper.xml
  10. 47
      ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMaterialMapper.xml
  11. 249
      ruoyi-admin/src/main/resources/templates/sales/estimate/addChildMaterial.html
  12. 233
      ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html

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

@ -2,10 +2,15 @@ package com.ruoyi.sales.controller;
import java.util.List;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.erp.domain.ErpMaterialVo;
import com.ruoyi.erp.service.IErpMaterialService;
import com.ruoyi.sales.domain.SalesEstimateDetail;
import com.ruoyi.sales.domain.SalesEstimateDetailMaterial;
import com.ruoyi.sales.domain.SalesEstimateTemplate;
import com.ruoyi.sales.domain.VO.SalesEstimateDetailVo;
import com.ruoyi.sales.service.ISalesEstimateDetailMaterialService;
import com.ruoyi.sales.service.ISalesEstimateDetailService;
import com.ruoyi.sales.service.ISalesEstimateTemplateService;
import com.ruoyi.system.domain.SysMakeOrder;
import com.ruoyi.system.domain.SysSalesOrderChild;
@ -45,6 +50,12 @@ public class SalesEstimateController extends BaseController
@Autowired
private ISalesEstimateTemplateService estimateTemplateService;
@Autowired
private ISalesEstimateDetailService estimateDetailService;
@Autowired
private ISalesEstimateDetailMaterialService estimateDetailMaterialService;
@RequiresPermissions("sales:estimate:view")
@GetMapping()
public String estimate()
@ -132,6 +143,47 @@ public class SalesEstimateController extends BaseController
/**
* 新增销售估价 销售估价详情数据集合展示
*/
@ResponseBody
@PostMapping("/getEstimateDetailList")
public TableDataInfo getEstimateDetailList(@RequestParam("salesEstimateCode") String salesEstimateCode )
{
startPage();
List<SalesEstimateDetail> list = estimateDetailService.getEstimateDetailListByCode(salesEstimateCode);
return getDataTable(list);
}
/**
* 加载新增销售估价-工程 子表物料选择弹窗
*/
@GetMapping("/addChildMaterial/{estimateDetailId}")
public String addChildMaterial(@PathVariable("estimateDetailId") Long estimateDetailId, ModelMap map)
{
SalesEstimateDetail salesEstimateDetail = estimateDetailService.selectSalesEstimateDetailById(estimateDetailId);
map.put("salesEstimateDetail",salesEstimateDetail);
map.put("estimateDetailId",estimateDetailId);
return prefix + "/addChildMaterial";
}
/**
* 销售估价添加Bom-工程 新增保存物料
*/
@Log(title = "销售估价", businessType = BusinessType.INSERT)
@PostMapping("/addChildMaterialSave")
@ResponseBody
public AjaxResult addChildMaterialSave(@RequestBody SalesEstimateDetail salesEstimateDetail)
{
return toAjax(estimateDetailMaterialService.insertEstimateDetailMaterialList(salesEstimateDetail));
}
/**
* 加载新增销售估价 物料选择弹窗
*/
@ -141,6 +193,10 @@ public class SalesEstimateController extends BaseController
return prefix + "/estimateMaterialSelect";
}
/**
* 新增销售估价 物料选择
*/

14
ruoyi-admin/src/main/java/com/ruoyi/sales/domain/SalesEstimateDetail.java

@ -1,6 +1,8 @@
package com.ruoyi.sales.domain;
import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -133,6 +135,9 @@ public class SalesEstimateDetail extends BaseEntity
/** 含税经营成本(RMB) */
private BigDecimal taxOperatingCosts;
/** 销售估价详情物料子表集合 */
private List<SalesEstimateDetailMaterial> salesEstimateDetailMaterialList;
public void setEstimateDetailId(Long estimateDetailId)
{
this.estimateDetailId = estimateDetailId;
@ -422,6 +427,15 @@ public class SalesEstimateDetail extends BaseEntity
return taxOperatingCosts;
}
public List<SalesEstimateDetailMaterial> getSalesEstimateDetailMaterialList() {
return salesEstimateDetailMaterialList;
}
public void setSalesEstimateDetailMaterialList(List<SalesEstimateDetailMaterial> salesEstimateDetailMaterialList) {
this.salesEstimateDetailMaterialList = salesEstimateDetailMaterialList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

7
ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMapper.java

@ -83,4 +83,11 @@ public interface SalesEstimateDetailMapper
* @return 结果
*/
public int restoreSalesEstimateDetailById(Long estimateDetailId);
/**
* 根据估价编号查询估价详情集合
* @param salesEstimateCode
* @return
*/
List<SalesEstimateDetail> selectEstimateDetailListByCode(String salesEstimateCode);
}

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

@ -35,6 +35,16 @@ public interface SalesEstimateDetailMaterialMapper
*/
public int insertSalesEstimateDetailMaterial(SalesEstimateDetailMaterial salesEstimateDetailMaterial);
/**
* 批量新增销售估价详情物料价格
*
* @param salesEstimateDetailMaterialList 销售估价详情物料价格集合
* @return 结果
*/
public int insertSalesEstimateDetailMaterialBatch(List<SalesEstimateDetailMaterial> salesEstimateDetailMaterialList);
/**
* 修改销售估价详情物料价格
*

9
ruoyi-admin/src/main/java/com/ruoyi/sales/service/ISalesEstimateDetailMaterialService.java

@ -1,6 +1,8 @@
package com.ruoyi.sales.service;
import java.util.List;
import com.ruoyi.sales.domain.SalesEstimateDetail;
import com.ruoyi.sales.domain.SalesEstimateDetailMaterial;
/**
@ -72,4 +74,11 @@ public interface ISalesEstimateDetailMaterialService
* @return
*/
int restoreSalesEstimateDetailMaterialById(Long estimateDetailMaterialId);
/**
* 批量新增销售估价详情物料价格
* @param salesEstimateDetail 销售估价详情集合
* @return
*/
int insertEstimateDetailMaterialList(SalesEstimateDetail salesEstimateDetail);
}

7
ruoyi-admin/src/main/java/com/ruoyi/sales/service/ISalesEstimateDetailService.java

@ -72,4 +72,11 @@ public interface ISalesEstimateDetailService
* @return
*/
int restoreSalesEstimateDetailById(Long estimateDetailId);
/**
* 根据估价编号查询估价详情集合
* @param salesEstimateCode
* @return
*/
List<SalesEstimateDetail> getEstimateDetailListByCode(String salesEstimateCode);
}

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

@ -1,8 +1,10 @@
package com.ruoyi.sales.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.sales.domain.SalesEstimateDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sales.mapper.SalesEstimateDetailMaterialMapper;
@ -76,6 +78,25 @@ public class SalesEstimateDetailMaterialServiceImpl implements ISalesEstimateDet
return salesEstimateDetailMaterialMapper.updateSalesEstimateDetailMaterial(salesEstimateDetailMaterial);
}
/**
* 批量新增销售估价详情物料价格
*
* @param salesEstimateDetail 销售估价详情
* @return 结果
*/
@Override
public int insertEstimateDetailMaterialList(SalesEstimateDetail salesEstimateDetail) {
String loginName = ShiroUtils.getLoginName();
List<SalesEstimateDetailMaterial> salesEstimateDetailMaterialList = salesEstimateDetail.getSalesEstimateDetailMaterialList();
for (SalesEstimateDetailMaterial salesEstimateDetailMaterial : salesEstimateDetailMaterialList) {
salesEstimateDetailMaterial.setCreateBy(loginName);
salesEstimateDetailMaterial.setCreateTime(new Date());
salesEstimateDetailMaterial.setEstimateDetailId(salesEstimateDetail.getEstimateDetailId());
}
return salesEstimateDetailMaterialMapper.insertSalesEstimateDetailMaterialBatch(salesEstimateDetailMaterialList);
}
/**
* 删除销售估价详情物料价格对象
*

13
ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateDetailServiceImpl.java

@ -58,6 +58,8 @@ public class SalesEstimateDetailServiceImpl implements ISalesEstimateDetailServi
String loginName = ShiroUtils.getLoginName();
salesEstimateDetail.setCreateBy(loginName);
salesEstimateDetail.setCreateTime(DateUtils.getNowDate());
return salesEstimateDetailMapper.insertSalesEstimateDetail(salesEstimateDetail);
}
@ -123,4 +125,15 @@ public class SalesEstimateDetailServiceImpl implements ISalesEstimateDetailServi
{
return salesEstimateDetailMapper.restoreSalesEstimateDetailById(estimateDetailId);
}
/**
* 根据估价编号查询估价详情集合
* @param salesEstimateCode
* @return
*/
@Override
public List<SalesEstimateDetail> getEstimateDetailListByCode(String salesEstimateCode)
{
return salesEstimateDetailMapper.selectEstimateDetailListByCode(salesEstimateCode);
}
}

7
ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMapper.xml

@ -58,7 +58,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSalesEstimateDetailVo"/>
where estimate_detail_id = #{estimateDetailId}
</select>
<select id="selectEstimateDetailListByCode" parameterType="String" resultMap="SalesEstimateDetailResult">
<include refid="selectSalesEstimateDetailVo"/>
where sales_estimate_code = #{salesEstimateCode}
</select>
<insert id="insertSalesEstimateDetail" parameterType="SalesEstimateDetail" useGeneratedKeys="true" keyProperty="estimateDetailId">
insert into sales_estimate_detail
<trim prefix="(" suffix=")" suffixOverrides=",">

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

@ -85,6 +85,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="insertSalesEstimateDetailMaterialBatch" parameterType="SalesEstimateDetailMaterial" useGeneratedKeys="true" keyProperty="estimateDetailMaterialId">
insert into sales_estimate_detail_material
(
estimate_detail_id,
material_name,
material_type,
material_photo_url,
material_unit,
material_brand,
material_describe,
material_process_method,
use_num,
no_tax_purchase_rmb,
tax_purchase_rmb,
create_by,
create_time,
update_by,
update_time,
remark
)
values
<foreach collection="list" item="item" separator=",">
(
#{item.estimateDetailId},
#{item.materialName},
#{item.materialType},
#{item.materialPhotoUrl},
#{item.materialUnit},
#{item.materialBrand},
#{item.materialDescribe},
#{item.materialProcessMethod},
#{item.useNum},
#{item.noTaxPurchaseRmb},
#{item.taxPurchaseRmb},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
#{item.remark}
)
</foreach>
</insert>
<update id="updateSalesEstimateDetailMaterial" parameterType="SalesEstimateDetailMaterial">
update sales_estimate_detail_material
<trim prefix="SET" suffixOverrides=",">

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

@ -0,0 +1,249 @@
<!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">
<div class="container">
<div class="row">
<div class="col-sm-12 d-flex align-items-center">
<span style="font-weight: bold; font-family: Arial, sans-serif; font-size: 15px;">物料信息列表</span>
<a class="btn btn-success ml-auto" onclick="addChildMaterial()">
<i class="fa fa-plus"></i> 添加物料
</a>
</div>
</div>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-addChildMaterial-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
var prefix = ctx + "sales/estimate";
var estimateDetailId = [[${estimateDetailId}]];
var salesEstimateDetail = [[${salesEstimateDetail}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var $table = $("#bootstrap-addChildMaterial-table");
$(function() {
var options = {
id: 'bootstrap-addChildMaterial-table',
showColumns: false,
pagination: false,
showToggle: false,
showRefresh:false,
showSearch:false,
modalName: "物料信息",
columns: [{
checkbox: true
},
{
field: 'index',
align: 'center',
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
var columnId = $.common.sprintf("<input type='hidden' name='salesEstimateDetailMaterialList[%s].id' value='%s'>", index, row.id);
return columnIndex + $.table.serialNumber(index) + columnId;
}
},
{
title: '估价详情物料子表Id',
field: 'estimateDetailMaterialId',
visible: false
},
{
title: '物料名称',
field: 'materialName',
editable: true,
},
{
title: '物料类型',
field: 'materialType',
formatter: function(value, row, index) {
var data = [{ index: index, type: value }];
return $("#materialType").tmpl(data).html();
}
},
{
title: '物料单位',
field: 'materialUnit',
formatter:function (value, row, index) {
return materialUnitFormatter(value,row,index);
}
},
{
title: '物料描述',
field: 'materialDescribe',
editable: true,
},
{
title: '用量',
field: 'useNum',
editable: true,
},
{
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.estimateDetailMaterialId + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}
]
};
$.table.init(options);
});
//添加收款明细
function addChildMaterial() {
// 生成一个简单的唯一标识,这里使用时间戳作为示例
var uniqueId = new Date().getTime();
// 创建一个新行数据模板,这里仅为示例,具体根据表格列来定义
var newRow = {
estimateDetailMaterialId:uniqueId,
materialName: "",
materialType:"",
materialUnit: "",
materialDescribe: "",
useNum: "",
};
// 使用Bootstrap Table的API插入新行
$('#bootstrap-addChildMaterial-table').bootstrapTable('append', newRow);
}
// 逻辑物料子表前端的一行数据
function removeRow(estimateDetailMaterialId){
console.log(estimateDetailMaterialId);
// 直接使用 estimateDetailMaterialId 值进行删除操作
$("#bootstrap-addChildMaterial-table").bootstrapTable('remove', {
field: 'estimateDetailMaterialId',
values: estimateDetailMaterialId
});
}
function submitHandler() {
var addChildMaterialTable = $('#bootstrap-addChildMaterial-table').bootstrapTable('getData')
if(addChildMaterialTable.length == 0){
$.modal.alertWarning("请添加物料信息");
return;
}
console.log(JSON.stringify(addChildMaterialTable))
for(var i=0;i<addChildMaterialTable.length;i++){
if(addChildMaterialTable[i].materialName == "" || addChildMaterialTable[i].materialUnit == "" || addChildMaterialTable[i].materialDescribe == "" || addChildMaterialTable[i].useNum == ""){
$.modal.alertWarning("请填写完整信息");
return;
}
}
//将表数据转换成与complaintNoticeData格式一致的数组
var addChildMaterialList = addChildMaterialTable.map(function(item) {
// 根据实际字段名调整
return {
"materialName": item.materialName,
"materialType": item.materialType,
"materialUnit": item.materialUnit,
"materialDescribe": item.materialDescribe,
"useNum": item.useNum,
// ...其他字段
};
});
const combinedData = Object.assign({},salesEstimateDetail ,{ salesEstimateDetailMaterialList: addChildMaterialList });
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/addChildMaterialSave", jsonData);
}
// 列中获取不良等级的下拉改变数据
function onMaterialUnit(selectElement, rowIndex) {
var materialUnitValue = $(selectElement).val();
var tableData = $table.bootstrapTable('getData');
var newRow = tableData[rowIndex]; // 获取当前行数据
// 重新渲染成本小类的设备名称列
// 更新行数据
newRow.materialUnit = materialUnitValue;
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow});
}
// 自定义不良等级的格式化函数
function materialUnitFormatter(value, row, index) {
var selectHtml = '<select class="form-control" onchange="onMaterialUnit(this, ' + index + ')">';
// 添加默认选项
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>';
sysUnitClassDatas.forEach(function (child) {
selectHtml += '<option value="' + child.dictValue + '"' + (value === child.dictValue ? ' selected' : '') + '>' + child.dictLabel + '</option>';
});
selectHtml += '</select>';
return selectHtml;
}
</script>
</body>
</html>
<!-- 物料类型下拉框模板-->
<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>
</script>
<!--<script id="materialUnit" type="text/x-jquery-tmpl">-->
<!--<div>-->
<!--<select name="materialUnit" class="form-control m-b" th:with="type=${@dict.getType('sys_unit_class')}">-->
<!-- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--</select>-->
<!--</div>-->
<!--</script>-->
<!--<script id="materialName" type="text/x-jquery-tmpl">-->
<!--<div>-->
<!--<input type="text" class="form-control" name='salesEstimateDetailMaterialList[%s].materialName' value='%s' required>-->
<!--</div>-->
<!--</script>-->
<!--<script id="materialDescribe" type="text/x-jquery-tmpl">-->
<!--<div>-->
<!--<input type="text" class="form-control" name="materialDescribe" required>-->
<!--</div>-->
<!--</script>-->
<!--<script id="useNum" type="text/x-jquery-tmpl">-->
<!--<div>-->
<!--<input type="text" class="form-control" name="useNum" required>-->
<!--</div>-->
<!--</script>-->

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

@ -87,17 +87,6 @@
</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>
@ -115,6 +104,7 @@
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var salesEstimateDetailVo = [[${salesEstimateDetailVo}]];
var salesEstimate = [[${salesEstimate}]];
$("#form-estimate-add").validate({
focusCleanup: true
@ -192,28 +182,20 @@
// 点击选择物料按钮
function insertMaterialRow() {
var url = prefix + '/estimateMaterialSelect';
var options = {
title: '选择物料',
url: url,
callBack: estimateDoSubmit
};
$.modal.openOptions(options);
}
$(function() {
var options = {
url: prefix + "/getEstimateDetailList",
id:'bootstrap-table',
queryParams:queryParams,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
modalName: "销售估价详情",
editFiled:"noTaxRmb",
detailView: true,
onExpandRow : function(index, row, $detail) {
initChildTable(index, row, $detail);
},
columns: [
{
checkbox: true
@ -263,38 +245,14 @@
},
{
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;
return $.table.selectDictLabel(materialGearPositionDatas, value);
}
},
{
title: '物料数量',
field: 'materialNum',
editable: true,
},
{
title: '不含税单价',
@ -338,6 +296,7 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="addChildMaterial(\'' + row.estimateDetailId + '\')"><i class="fa fa-edit"></i>添加物料</a> ');
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('');
}
@ -352,41 +311,83 @@
});
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];
initChildTable = function(index, row, $detail) {
var parentRow = row;
var childTableId = 'child_table_'+index;
$detail.html('<table id="'+childTableId+'"></table>');
$('#'+childTableId).bootstrapTable({
url: prefix + "/showAftersalesShippingDeviceListTwo",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
// salesOrderCode: warehouseOutOrder.salesOrderCode,
materialNo: parentRow.materialNo,
salesOrderCode:warehouseOutOrder.salesOrderCode,
makeNo:warehouseOutOrder.makeNo
},
columns: [
{
title: '销售估价详情ID',
field: 'estimateDetailId',
visible: false
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '物料类型',
field: 'materialType',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
title: '物料单位',
field: 'materialUnit',
},
{
title: '物料描述',
field: 'materialDescribe',
},
{
title: '用量',
field: 'useNum',
},
{
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>';
}
}
],
});
// 动态生成 form 表单
var formHtml = '<form class="form-inline">';
formHtml += '<div class="form-group">';
formHtml += '<label for="additionalInput' + index + '">附加输入:</label>';
formHtml += '<input type="text" class="form-control" id="additionalInput' + index + '" placeholder="请输入附加信息">';
formHtml += '</div>';
formHtml += '</form>';
// 将 form 表单添加到子表下面
$detail.append(formHtml);
};
function queryParams(params) {
var curParams = {
// 传递参数查询参数
salesEstimateCode: salesEstimate.salesEstimateCode
};
return curParams;
}
//判断是否重复
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){
@ -398,29 +399,6 @@
}
// $(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');
@ -469,47 +447,10 @@
}
// 计算并更新所有其他总和
// 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);
// }
function addChildMaterial(estimateDetailId){
var url = prefix + "/addChildMaterial/" + estimateDetailId;
$.modal.open("添加物料",url);
}

Loading…
Cancel
Save