Browse Source
销售估价新增采购添加详情页面 销售估价新增采购添加详情按钮,新增打开采购添加详情js方法 销售估价Controller层:新增销售估价-采购详情后端接口;新增保存销售估价-采购详情后端接口dev
liuxiaoxu
4 months ago
3 changed files with 466 additions and 1 deletions
@ -0,0 +1,426 @@ |
|||
<!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-purchaseAddDetail" th:object="${salesEstimate}"> |
|||
<input name="salesEstimateId" th:field="*{salesEstimateId}" type="hidden"> |
|||
<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" disabled> |
|||
<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" readonly> |
|||
</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" th:field="*{materialSum}" id="materialSum_add" type="number" readonly/> |
|||
<label class=" col-sm-2">数量合计:</label><input class="col-sm-4" name="enterpriseSum" th:field="*{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="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}]]; |
|||
var salesEstimate = [[${salesEstimate}]]; |
|||
|
|||
$("#form-estimate-purchaseAddDetail").validate({ |
|||
focusCleanup: true |
|||
}); |
|||
|
|||
function submitHandler() { |
|||
var data = $("#form-estimate-purchaseAddDetail").serialize(); |
|||
$.operate.save(prefix + "/purchaseAddDetail", data) |
|||
} |
|||
|
|||
$("input[name='pricingDate']").datetimepicker({ |
|||
format: "yyyy-mm-dd", |
|||
minView: "month", |
|||
autoclose: true |
|||
}); |
|||
|
|||
|
|||
|
|||
$(function() { |
|||
var options = { |
|||
url: prefix + "/getEstimateDetailList", |
|||
id:'bootstrap-table', |
|||
queryParams:queryParams, |
|||
showSearch: false, |
|||
showRefresh: false, |
|||
showToggle: false, |
|||
showColumns: false, |
|||
modalName: "销售估价详情", |
|||
detailView: true, |
|||
onExpandRow : function(index, row, $detail) { |
|||
initChildTable(index, row, $detail); |
|||
}, |
|||
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: '料号档位', |
|||
field: 'materialGearPosition', |
|||
formatter: function(value, row, index) { |
|||
return $.table.selectDictLabel(materialGearPositionDatas, value); |
|||
} |
|||
}, |
|||
{ |
|||
title: '物料数量', |
|||
field: 'materialNum', |
|||
}, |
|||
{ |
|||
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 |
|||
}], |
|||
onEditableSave:function(field, row, oldValue, $el){ |
|||
// 确保getTotalAmount函数存在且正确引用 |
|||
getTotalAmount(); |
|||
}, |
|||
|
|||
}; |
|||
$.table.init(options); |
|||
}); |
|||
|
|||
|
|||
initChildTable = function(index, row, $detail) { |
|||
var parentRow = row; |
|||
var childTableId = 'child_table_'+index; |
|||
$detail.html('<table id="'+childTableId+'"></table>'); |
|||
$('#'+childTableId).bootstrapTable({ |
|||
url: prefix + "/getEstimateDetailMaterialList", |
|||
method: 'post', |
|||
sidePagination: "server", |
|||
contentType: "application/x-www-form-urlencoded", |
|||
queryParams : { |
|||
estimateDetailId:parentRow.estimateDetailId |
|||
}, |
|||
columns: [ |
|||
{ |
|||
title: '销售估价详情物料ID', |
|||
field: 'estimateDetailMaterialId', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '销售估价详情ID', |
|||
field: 'estimateDetailId', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '不含税开发成本', |
|||
field: 'noTaxDevelopCosts', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '不含税运输成本', |
|||
field: 'noTaxShippingCosts', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '不含税服务成本', |
|||
field: 'noTaxServiceCosts', |
|||
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: '不含税采购单价(RMB)', |
|||
field: 'noTaxPurchaseRmb', |
|||
}, |
|||
{ |
|||
title: '含税采购单价(RMB)', |
|||
field: 'taxPurchaseRmb', |
|||
} |
|||
], |
|||
|
|||
onLoadSuccess: function(data) { |
|||
// 初始化成本数据为一个空对象 |
|||
var costs = {}; |
|||
|
|||
// 如果 data 是一个对象,将其转换为单元素数组 |
|||
if (typeof data === 'object' && !Array.isArray(data)) { |
|||
data = [data]; |
|||
} |
|||
|
|||
// 检查数据是否有效 |
|||
if (data.length > 0 && data[0].rows && data[0].rows.length > 0) { |
|||
// 使用第一条数据 |
|||
var firstRow = data[0].rows[0]; |
|||
costs.noTaxDevelopCosts = firstRow.noTaxDevelopCosts || ''; |
|||
costs.noTaxShippingCosts = firstRow.noTaxShippingCosts || ''; |
|||
costs.noTaxServiceCosts = firstRow.noTaxServiceCosts || ''; |
|||
} else { |
|||
// 如果没有数据,设置所有成本字段为空字符串 |
|||
costs.noTaxDevelopCosts = ''; |
|||
costs.noTaxShippingCosts = ''; |
|||
costs.noTaxServiceCosts = ''; |
|||
} |
|||
|
|||
// 动态生成 form 表单 |
|||
var formHtml = '<form class="form-inline" data-index="' + index + '">'; |
|||
formHtml += '<h3>运输、服务、开发成本</h3>'; |
|||
formHtml += '<div class="form-group">'; |
|||
formHtml += '<label for="noTaxDevelopCosts' + index + '">不含税开发成本(RMB):</label>'; |
|||
formHtml += '<input type="text" class="form-control" id="noTaxDevelopCosts' + index + '" name="noTaxDevelopCosts' + index + '" value="' + costs.noTaxDevelopCosts + '">'; |
|||
formHtml += '</div>'; |
|||
formHtml += '<div class="form-group">'; |
|||
formHtml += '<label for="noTaxShippingCosts' + index + '">不含税运输成本(RMB):</label>'; |
|||
formHtml += '<input type="text" class="form-control" id="noTaxShippingCosts' + index + '" name="noTaxShippingCosts' + index + '" value="' + costs.noTaxShippingCosts + '">'; |
|||
formHtml += '</div>'; |
|||
formHtml += '<div class="form-group">'; |
|||
formHtml += '<label for="noTaxServiceCosts' + index + '">不含税服务成本(RMB):</label>'; |
|||
formHtml += '<input type="text" class="form-control" id="noTaxServiceCosts' + index + '" name="noTaxServiceCosts' + index + '" value="' + costs.noTaxServiceCosts + '">'; |
|||
formHtml += '</div>'; |
|||
formHtml += '</form>'; |
|||
|
|||
// 将 form 表单添加到子表下面 |
|||
$detail.append(formHtml); |
|||
} |
|||
}); |
|||
|
|||
}; |
|||
|
|||
|
|||
|
|||
function queryParams(params) { |
|||
var curParams = { |
|||
// 传递参数查询参数 |
|||
salesEstimateCode: salesEstimate.salesEstimateCode |
|||
}; |
|||
return curParams; |
|||
} |
|||
|
|||
|
|||
|
|||
//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); |
|||
|
|||
} |
|||
|
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue