Browse Source
销售估价新增总经理添加详情页面 销售估价新增总经理添加详情按钮,新增打开总经理添加详情js方法 销售估价Controller层:新增销售估价-总经理详情后端接口;新增保存销售估价-总经理详情后端接口dev
3 changed files with 685 additions and 1 deletions
@ -0,0 +1,647 @@ |
|||||
|
<!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-ceoAddDetail" 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" th:field="*{materialSum}" name="materialSum" id="materialSum_add" type="number" readonly/> |
||||
|
<label class=" col-sm-2">数量合计:</label><input class="col-sm-4" th:field="*{enterpriseSum}" 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" th:field="*{noTaxRmb}" name="noTaxRmb" id="noTaxRmb_add" type="number" readonly/> |
||||
|
<label class="col-sm-2"> 不含税总价(RMB):</label><input placeholder="RMB" class="col-sm-4" th:field="*{allNoTaxRmb}" 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" th:field="*{taxRmb}" name="taxRmb" id="taxRmb_add" type="number" readonly/> |
||||
|
<label class="col-sm-2"> 含税总价(RMB):</label><input placeholder="RMB" class="col-sm-4" th:field="*{allTaxRmb}" 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" th:field="*{noTaxDollar}" name="noTaxDollar" id="noTaxDollar_add" type="number" readonly/> |
||||
|
<label class="col-sm-2">不含税总价(USD):</label><input placeholder="美元" class="col-sm-4" th:field="*{allNoTaxDollar}" 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" th:field="*{taxDollar}" name="taxDollar" id="taxDollar_add" type="number" readonly/> |
||||
|
<label class="col-sm-2">含税总价(USD):</label><input placeholder="美元" class="col-sm-4" th:field="*{allTaxDollar}" 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-ceoAddDetail").validate({ |
||||
|
focusCleanup: true |
||||
|
}); |
||||
|
|
||||
|
function submitHandler() { |
||||
|
var data = $("#form-estimate-ceoAddDetail").serialize(); |
||||
|
$.operate.save(prefix + "/ceoAddDetail", 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]; |
||||
|
} |
||||
|
console.log(data) |
||||
|
|
||||
|
// 检查数据是否有效 |
||||
|
if (data.length > 0 && data[0].rows && data[0].rows.length > 0) { |
||||
|
// 使用第一条数据 |
||||
|
var firstRow = data[0].rows[0]; |
||||
|
|
||||
|
// 从 `firstRow` 中获取成本信息 |
||||
|
const { |
||||
|
noTaxDevelopCosts = '', |
||||
|
noTaxShippingCosts = '', |
||||
|
noTaxServiceCosts = '', |
||||
|
noTaxPurchaseRmb = '', |
||||
|
taxPurchaseRmb = '' |
||||
|
} = firstRow || {}; |
||||
|
|
||||
|
// 从 `salesEstimateDetailVo` 中获取其他成本信息 |
||||
|
const { |
||||
|
noTaxLaborCosts = '', |
||||
|
noTaxPromotionalCosts = '', |
||||
|
noTaxBusinessCosts = '', |
||||
|
noTaxManagesCosts = '', |
||||
|
noTaxMaterialCosts = '' |
||||
|
} = salesEstimateDetailVo || {}; |
||||
|
|
||||
|
// 计算不含税总经营成本 |
||||
|
const noAllTaxOperatingCosts = ( |
||||
|
parseFloat(noTaxLaborCosts) + |
||||
|
parseFloat(noTaxBusinessCosts) + |
||||
|
parseFloat(noTaxManagesCosts) + |
||||
|
parseFloat(noTaxPromotionalCosts) |
||||
|
).toFixed(2) || ''; |
||||
|
|
||||
|
// 计算含税总经营成本,假设增值税率为 13% |
||||
|
const allTaxOperatingCosts = ( |
||||
|
parseFloat(noAllTaxOperatingCosts) * 1.13 |
||||
|
).toFixed(2) || ''; |
||||
|
//该料号的不含税经营成本 |
||||
|
const noTaxOperatingCosts = ( |
||||
|
(noTaxPurchaseRmb/noTaxMaterialCosts) * noAllTaxOperatingCosts |
||||
|
).toFixed(2) || ''; |
||||
|
// 该料号的含税经营成本 |
||||
|
const taxOperatingCosts = ( |
||||
|
(taxPurchaseRmb/noTaxMaterialCosts) * allTaxOperatingCosts |
||||
|
).toFixed(2) || ''; |
||||
|
// 根据 `parentRow.profitRate` 设置利润率 |
||||
|
let profitRateKey = 'aprofitRate'; |
||||
|
switch (parentRow.profitRate) { |
||||
|
case "1": |
||||
|
profitRateKey = 'bprofitRate'; |
||||
|
break; |
||||
|
case "2": |
||||
|
profitRateKey = 'cprofitRate'; |
||||
|
break; |
||||
|
case "3": |
||||
|
profitRateKey = 'dprofitRate'; |
||||
|
break; |
||||
|
case "4": |
||||
|
profitRateKey = 'eprofitRate'; |
||||
|
break; |
||||
|
case "5": |
||||
|
profitRateKey = 'fprofitRate'; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
// 使用解构赋值并设置默认值 |
||||
|
const profitRate = salesEstimateDetailVo[profitRateKey] || ''; |
||||
|
|
||||
|
// 更新 `costs` 对象 |
||||
|
costs = { |
||||
|
noTaxDevelopCosts, |
||||
|
noTaxShippingCosts, |
||||
|
noTaxServiceCosts, |
||||
|
noTaxLaborCosts, |
||||
|
noTaxPromotionalCosts, |
||||
|
noTaxBusinessCosts, |
||||
|
noTaxManagesCosts, |
||||
|
noTaxMaterialCosts, |
||||
|
noTaxOperatingCosts, |
||||
|
taxOperatingCosts, |
||||
|
profitRate, |
||||
|
noTaxPurchaseRmb, |
||||
|
taxPurchaseRmb, |
||||
|
|
||||
|
}; |
||||
|
} else { |
||||
|
// 如果没有数据,设置所有成本字段为空字符串 |
||||
|
costs = { |
||||
|
noTaxDevelopCosts: '', |
||||
|
noTaxShippingCosts: '', |
||||
|
noTaxServiceCosts: '', |
||||
|
noTaxLaborCosts: '', |
||||
|
noTaxPromotionalCosts: '', |
||||
|
noTaxBusinessCosts: '', |
||||
|
noTaxManagesCosts: '', |
||||
|
noTaxMaterialCosts: '', |
||||
|
noTaxOperatingCosts: '', |
||||
|
taxOperatingCosts: '', |
||||
|
profitRate: '' |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
// 动态生成 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 + '" readonly>'; |
||||
|
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 + '" readonly>'; |
||||
|
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 + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<h3>总经营成本</h3>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="noTaxLaborCosts' + index + '">不含税人工成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="noTaxLaborCosts' + index + '" name="noTaxLaborCosts' + index + '" value="' + costs.noTaxLaborCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="noTaxPromotionalCosts' + index + '">不含税推广成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="noTaxPromotionalCosts' + index + '" name="noTaxPromotionalCosts' + index + '" value="' + costs.noTaxPromotionalCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="noTaxBusinessCosts' + index + '">不含税业务成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="noTaxBusinessCosts' + index + '" name="noTaxBusinessCosts' + index + '" value="' + costs.noTaxBusinessCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="noTaxManagesCosts' + index + '">不含税管理成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="noTaxManagesCosts' + index + '" name="noTaxManagesCosts' + index + '" value="' + costs.noTaxManagesCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<h3>总物料成本</h3>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="noTaxMaterialCosts' + index + '">不含税总物料成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="noTaxMaterialCosts' + index + '" name="noTaxMaterialCosts' + index + '" value="' + costs.noTaxMaterialCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<h3>该料号经营成本</h3>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="noTaxOperatingCosts' + index + '">不含税经营成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="noTaxOperatingCosts' + index + '" name="noTaxOperatingCosts' + index + '" value="' + costs.noTaxOperatingCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="taxOperatingCosts' + index + '">含税经营成本(RMB):</label>'; |
||||
|
formHtml += '<input type="text" class="form-control" id="taxOperatingCosts' + index + '" name="taxOperatingCosts' + index + '" value="' + costs.taxOperatingCosts + '" readonly>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '<h3>利润率</h3>'; |
||||
|
formHtml += '<div class="form-group">'; |
||||
|
formHtml += '<label for="profitRate' + index + '">利润率:</label>'; |
||||
|
formHtml += '<div class="input-group">'; |
||||
|
formHtml += '<input type="text" class="form-control" id="profitRate' + index + '" name="profitRate' + index + '" value="' + (costs.profitRate || '') + '" readonly>'; |
||||
|
formHtml += '<span class="input-group-addon">%</span>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '</div>'; |
||||
|
formHtml += '</form>'; |
||||
|
// 将 form 表单添加到子表下面 |
||||
|
$detail.append(formHtml); |
||||
|
var $form = $detail.find('form[data-index="' + index + '"]'); |
||||
|
|
||||
|
// 使用事件委托监听 input 元素的变化 |
||||
|
$form.on('input', 'input[type="text"]', function() { |
||||
|
var $input = $(this); |
||||
|
var inputId = $input.attr('id'); |
||||
|
var inputName = $input.attr('name'); |
||||
|
var inputValue = parseFloat($input.val()); |
||||
|
|
||||
|
// 根据 input 的 id 或 name 进行相应的计算 |
||||
|
switch (inputId) { |
||||
|
case 'noTaxLaborCosts' + index: |
||||
|
calculateOperatingCosts(inputValue, 'noTaxLaborCosts'); |
||||
|
break; |
||||
|
case 'noTaxPromotionalCosts' + index: |
||||
|
calculateOperatingCosts(inputValue, 'noTaxPromotionalCosts'); |
||||
|
break; |
||||
|
case 'noTaxBusinessCosts' + index: |
||||
|
calculateOperatingCosts(inputValue, 'noTaxBusinessCosts'); |
||||
|
break; |
||||
|
case 'noTaxManagesCosts' + index: |
||||
|
calculateOperatingCosts(inputValue, 'noTaxManagesCosts'); |
||||
|
break; |
||||
|
case 'noTaxMaterialCosts' + index: |
||||
|
updateMaterialCosts(inputValue); |
||||
|
break; |
||||
|
// 添加更多 case 语句以处理其他 input 的变化 |
||||
|
default: |
||||
|
// 不做任何操作 |
||||
|
break; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
function calculateOperatingCosts(value, costType) { |
||||
|
var noAllTaxOperatingCosts = 0; |
||||
|
var allNoTaxPurchaseRmb = 0; |
||||
|
var allTaxPurchaseRmb = 0; |
||||
|
|
||||
|
// 获取所有相关的不含税成本 |
||||
|
['noTaxLaborCosts', 'noTaxPromotionalCosts', 'noTaxBusinessCosts', 'noTaxManagesCosts'].forEach(function(cost) { |
||||
|
var currentCost = parseFloat($form.find('#' + cost + index).val()); |
||||
|
noAllTaxOperatingCosts += currentCost; |
||||
|
}); |
||||
|
|
||||
|
// 更新不含税总经营成本 |
||||
|
$form.find('#noAllTaxOperatingCosts' + index).val(noAllTaxOperatingCosts.toFixed(2)); |
||||
|
|
||||
|
// 计算含税总经营成本 |
||||
|
var allTaxOperatingCosts = noAllTaxOperatingCosts * 1.13; |
||||
|
$form.find('#allTaxOperatingCosts' + index).val(allTaxOperatingCosts.toFixed(2)); |
||||
|
|
||||
|
// 遍历数据集计算不含税采购成本和含税采购成本 |
||||
|
data.forEach(function(item) { |
||||
|
item.rows.forEach(function(row) { |
||||
|
var noTaxPurchaseRmb = row.noTaxPurchaseRmb * row.useNum; |
||||
|
var taxPurchaseRmb = row.taxPurchaseRmb * row.useNum; |
||||
|
|
||||
|
allNoTaxPurchaseRmb += noTaxPurchaseRmb; |
||||
|
allTaxPurchaseRmb += taxPurchaseRmb; |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
// 该料号的不含税经营成本 |
||||
|
var noTaxMaterialCosts = parseFloat($form.find('#noTaxMaterialCosts' + index).val()); |
||||
|
var noTaxOperatingCosts = (allNoTaxPurchaseRmb / noTaxMaterialCosts) * noAllTaxOperatingCosts; |
||||
|
$form.find('#noTaxOperatingCosts' + index).val(noTaxOperatingCosts.toFixed(2)); |
||||
|
|
||||
|
// 该料号的含税经营成本 |
||||
|
var taxOperatingCosts = (allTaxPurchaseRmb / noTaxMaterialCosts) * allTaxOperatingCosts; |
||||
|
$form.find('#taxOperatingCosts' + index).val(taxOperatingCosts.toFixed(2)); |
||||
|
} |
||||
|
|
||||
|
function updateMaterialCosts(value) { |
||||
|
var allNoTaxPurchaseRmb = 0; |
||||
|
var allTaxPurchaseRmb = 0; |
||||
|
// 更新不含税总物料成本 |
||||
|
$form.find('#noTaxMaterialCosts' + index).val(value.toFixed(2)); |
||||
|
|
||||
|
// 遍历数据集计算不含税采购成本和含税采购成本 |
||||
|
data.forEach(function(item) { |
||||
|
item.rows.forEach(function(row) { |
||||
|
var noTaxPurchaseRmb = row.noTaxPurchaseRmb * row.useNum; |
||||
|
var taxPurchaseRmb = row.taxPurchaseRmb * row.useNum; |
||||
|
|
||||
|
allNoTaxPurchaseRmb += noTaxPurchaseRmb; |
||||
|
allTaxPurchaseRmb += taxPurchaseRmb; |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
// 更新不含税经营成本 |
||||
|
var noAllTaxOperatingCosts = parseFloat($form.find('#noAllTaxOperatingCosts' + index).val()); |
||||
|
var noTaxOperatingCosts = (noTaxPurchaseRmb / value) * noAllTaxOperatingCosts; |
||||
|
$form.find('#noTaxOperatingCosts' + index).val(noTaxOperatingCosts.toFixed(2)); |
||||
|
|
||||
|
// 更新含税经营成本 |
||||
|
var taxOperatingCosts = (taxPurchaseRmb / value) * noAllTaxOperatingCosts; |
||||
|
$form.find('#taxOperatingCosts' + index).val(taxOperatingCosts.toFixed(2)); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
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