重复代码提取

master
xxssyyyyssxx 2021-11-17 16:45:37 +08:00
parent 6b2c742f61
commit 33bcca7d67
5 changed files with 73 additions and 54 deletions

View File

@ -106,21 +106,24 @@ function updateCostData(data, returnData) {
$("input[name='costPurchaseOtherTaxInclude']").val(f2(otherTaxInclude));
$("input[name='costPurchaseOtherTaxExclude']").val(f2(otherTaxExclude));
var costOtherOtherTaxInclude = f2($("input[name='costOtherOtherTaxInclude']").val());
/* var costOtherOtherTaxInclude = f2($("input[name='costOtherOtherTaxInclude']").val());
var costOtherOtherTaxExclude = f2($("input[name='costOtherOtherTaxExclude']").val());
var costProjectManageTaxInclude = f2($("input[name='costProjectManageTaxInclude']").val());
var costProjectManageTaxExclude = f2($("input[name='costProjectManageTaxExclude']").val());
$("input[name='costTotalTaxInclude']").val(f2(deviceTaxInclude+buildTaxInclude+serviceTaxInclude+otherTaxInclude+costOtherOtherTaxInclude+costProjectManageTaxInclude));
$("input[name='costTotalTaxExclude']").val(f2(deviceTaxExclude+buildTaxExclude+serviceTaxExclude+otherTaxExclude+costOtherOtherTaxExclude+costProjectManageTaxExclude));
$("input[name='costTotalTaxExclude']").val(f2(deviceTaxExclude+buildTaxExclude+serviceTaxExclude+otherTaxExclude+costOtherOtherTaxExclude+costProjectManageTaxExclude));*/
calCostExclude();
calCostInclude();
updateProjectContributionProfitRate();
}
function bindOtherOtherChangeable() {
$("input[name='costOtherOtherTaxInclude']").change(function () {
var costPurchaseDeviceTaxInclude = f2($("input[name='costPurchaseDeviceTaxInclude']").val());
/*var costPurchaseDeviceTaxInclude = f2($("input[name='costPurchaseDeviceTaxInclude']").val());
var costPurchaseBuildTaxInclude = f2($("input[name='costPurchaseBuildTaxInclude']").val());
var costPurchaseServiceTaxInclude = f2($("input[name='costPurchaseServiceTaxInclude']").val());
var costPurchaseOtherTaxInclude = f2($("input[name='costPurchaseOtherTaxInclude']").val());
@ -128,14 +131,17 @@ function bindOtherOtherChangeable() {
var costProjectManageTaxInclude = f2($("input[name='costProjectManageTaxInclude']").val());
var costOtherOther = f2($(this).val());
$("input[name='costTotalTaxInclude']").val(f2(costPurchaseDeviceTaxInclude+costPurchaseBuildTaxInclude+costPurchaseServiceTaxInclude+costPurchaseOtherTaxInclude+costProjectManageTaxInclude+costOtherOther));
$("input[name='costTotalTaxInclude']").val(f2(costPurchaseDeviceTaxInclude+costPurchaseBuildTaxInclude
+costPurchaseServiceTaxInclude+costPurchaseOtherTaxInclude+costProjectManageTaxInclude+costOtherOther));*/
calCostInclude();
updateProjectContributionProfitRate();
});
$("input[name='costOtherOtherTaxExclude']").change(function () {
var costPurchaseDeviceTaxExclude = f2($("input[name='costPurchaseDeviceTaxExclude']").val());
/*var costPurchaseDeviceTaxExclude = f2($("input[name='costPurchaseDeviceTaxExclude']").val());
var costPurchaseBuildTaxExclude = f2($("input[name='costPurchaseBuildTaxExclude']").val());
var costPurchaseServiceTaxExclude = f2($("input[name='costPurchaseServiceTaxExclude']").val());
var costPurchaseOtherTaxExclude = f2($("input[name='costPurchaseOtherTaxExclude']").val());
@ -143,7 +149,10 @@ function bindOtherOtherChangeable() {
var costProjectManageTaxExclude = f2($("input[name='costProjectManageTaxExclude']").val());
var costOtherOther = f2($(this).val());
$("input[name='costTotalTaxExclude']").val(f2(costPurchaseDeviceTaxExclude+costPurchaseBuildTaxExclude+costPurchaseServiceTaxExclude+costPurchaseOtherTaxExclude+costProjectManageTaxExclude+costOtherOther));
$("input[name='costTotalTaxExclude']").val(f2(costPurchaseDeviceTaxExclude+costPurchaseBuildTaxExclude
+costPurchaseServiceTaxExclude+costPurchaseOtherTaxExclude+costProjectManageTaxExclude+costOtherOther));*/
calCostExclude();
updateProjectContributionProfitRate();
});

View File

@ -84,7 +84,7 @@ function updateCostProjectManageData(data,returnData) {
$("input[name='costProjectManageTaxExclude']").val(total);
$("input[name='costProjectManageTaxInclude']").val(total);
var costPurchaseDeviceTaxInclude = f2($("input[name='costPurchaseDeviceTaxInclude']").val());
/*var costPurchaseDeviceTaxInclude = f2($("input[name='costPurchaseDeviceTaxInclude']").val());
var costPurchaseBuildTaxInclude = f2($("input[name='costPurchaseBuildTaxInclude']").val());
var costPurchaseServiceTaxInclude = f2($("input[name='costPurchaseServiceTaxInclude']").val());
var costPurchaseOtherTaxInclude = f2($("input[name='costPurchaseOtherTaxInclude']").val());
@ -105,7 +105,10 @@ function updateCostProjectManageData(data,returnData) {
var costOtherOtherTaxExclude = f2($("input[name='costOtherOtherTaxExclude']").val());
$("input[name='costTotalTaxExclude']").val(f2(costPurchaseDeviceTaxExclude+costPurchaseBuildTaxExclude+costPurchaseServiceTaxExclude+costPurchaseOtherTaxExclude+total+costOtherOtherTaxExclude));
*/
calCostExclude();
calCostInclude();
updateProjectContributionProfitRate();
}

View File

@ -44,3 +44,50 @@ function postAjax(url, data, callback) {
}
});
}
/**
* 统计成本(含税)有一项没填就置空
*/
function calCostInclude() {
var costPurchaseDeviceTaxInclude = $("input[name='costPurchaseDeviceTaxInclude']").val();
var costPurchaseBuildTaxInclude = $("input[name='costPurchaseBuildTaxInclude']").val();
var costPurchaseServiceTaxInclude = $("input[name='costPurchaseServiceTaxInclude']").val();
var costPurchaseOtherTaxInclude = $("input[name='costPurchaseOtherTaxInclude']").val();
var costProjectManageTaxInclude = $("input[name='costProjectManageTaxInclude']").val();
var costOtherOtherTaxInclude = $("input[name='costOtherOtherTaxInclude']").val();
var costTotalTaxInclude = $("input[name='costTotalTaxInclude']");
if(costPurchaseDeviceTaxInclude && costPurchaseBuildTaxInclude && costPurchaseServiceTaxInclude && costPurchaseOtherTaxInclude && costProjectManageTaxInclude && costOtherOtherTaxInclude){
costTotalTaxInclude.val(f2(costPurchaseDeviceTaxInclude) +f2(costPurchaseBuildTaxInclude)
+f2(costPurchaseServiceTaxInclude)+f2(costPurchaseOtherTaxInclude)
+f2(costProjectManageTaxInclude)+f2(costOtherOtherTaxInclude));
}else {
costTotalTaxInclude.val("");
}
}
/**
* 统计成本(不含税)有一项没填就置空
*/
function calCostExclude() {
var costPurchaseDeviceTaxExclude = $("input[name='costPurchaseDeviceTaxExclude']").val();
var costPurchaseBuildTaxExclude = $("input[name='costPurchaseBuildTaxExclude']").val();
var costPurchaseServiceTaxExclude = $("input[name='costPurchaseServiceTaxExclude']").val();
var costPurchaseOtherTaxExclude = $("input[name='costPurchaseOtherTaxExclude']").val();
var costProjectManageTaxExclude = $("input[name='costProjectManageTaxExclude']").val();
var costOtherOtherTaxExclude = $("input[name='costOtherOtherTaxExclude']").val();
var costTotalTaxExclude = $("input[name='costTotalTaxExclude']");
if(costPurchaseDeviceTaxExclude && costPurchaseBuildTaxExclude && costPurchaseServiceTaxExclude && costPurchaseOtherTaxExclude && costProjectManageTaxExclude && costOtherOtherTaxExclude){
costTotalTaxExclude.val(f2(costPurchaseDeviceTaxExclude)+f2(costPurchaseBuildTaxExclude)
+f2(costPurchaseServiceTaxExclude)+f2(costPurchaseOtherTaxExclude)
+f2(costProjectManageTaxExclude)+f2(costOtherOtherTaxExclude));
}else {
costTotalTaxExclude.val("");
}
}

View File

@ -103,7 +103,7 @@ function calIncomeInclude() {
var incomeTotalTaxInclude = $("input[name='incomeTotalTaxInclude']");
if(incomeDeviceTaxInclude && incomeEngineerTaxInclude && incomeServiceTaxInclude){
incomeTotalTaxInclude.val(parseFloat(incomeDeviceTaxInclude)+parseFloat(incomeEngineerTaxInclude)+parseFloat(incomeServiceTaxInclude));
incomeTotalTaxInclude.val(f2(incomeDeviceTaxInclude)+f2(incomeEngineerTaxInclude)+f2(incomeServiceTaxInclude));
}else {
incomeTotalTaxInclude.val("");
}
@ -119,53 +119,12 @@ function calIncomeExclude() {
var incomeTotalTaxExclude = $("input[name='incomeTotalTaxExclude']");
if(incomeDeviceTaxExclude && incomeEngineerTaxExclude && incomeServiceTaxExclude){
incomeTotalTaxExclude.val(parseFloat(incomeDeviceTaxExclude)+parseFloat(incomeEngineerTaxExclude)+parseFloat(incomeServiceTaxExclude));
incomeTotalTaxExclude.val(f2(incomeDeviceTaxExclude)+f2(incomeEngineerTaxExclude)+f2(incomeServiceTaxExclude));
}else {
incomeTotalTaxExclude.val("");
}
}
/**
* 统计成本(含税)有一项没填就置空
*/
function calCostInclude() {
var costPurchaseDeviceTaxInclude = $("input[name='costPurchaseDeviceTaxInclude']").val();
var costPurchaseBuildTaxInclude = $("input[name='costPurchaseBuildTaxInclude']").val();
var costPurchaseServiceTaxInclude = $("input[name='costPurchaseServiceTaxInclude']").val();
var costPurchaseOtherTaxInclude = $("input[name='costPurchaseOtherTaxInclude']").val();
var costProjectManageTaxInclude = $("input[name='costProjectManageTaxInclude']").val();
var costOtherOtherTaxInclude = $("input[name='costOtherOtherTaxInclude']").val();
var costTotalTaxInclude = $("input[name='costTotalTaxInclude']");
if(costPurchaseDeviceTaxInclude && costPurchaseBuildTaxInclude && costPurchaseServiceTaxInclude && costPurchaseOtherTaxInclude && costProjectManageTaxInclude && costOtherOtherTaxInclude){
costTotalTaxInclude.val(parseFloat(costPurchaseDeviceTaxInclude)+parseFloat(costPurchaseBuildTaxInclude)+parseFloat(costPurchaseServiceTaxInclude)+parseFloat(costPurchaseOtherTaxInclude)+parseFloat(costProjectManageTaxInclude)+parseFloat(costOtherOtherTaxInclude));
}else {
costTotalTaxInclude.val("");
}
}
/**
* 统计成本(不含税)有一项没填就置空
*/
function calCostExclude() {
var costPurchaseDeviceTaxExclude = $("input[name='costPurchaseDeviceTaxExclude']").val();
var costPurchaseBuildTaxExclude = $("input[name='costPurchaseBuildTaxExclude']").val();
var costPurchaseServiceTaxExclude = $("input[name='costPurchaseServiceTaxExclude']").val();
var costPurchaseOtherTaxExclude = $("input[name='costPurchaseOtherTaxExclude']").val();
var costProjectManageTaxExclude = $("input[name='costProjectManageTaxExclude']").val();
var costOtherOtherTaxExclude = $("input[name='costOtherOtherTaxExclude']").val();
var costTotalTaxExclude = $("input[name='costTotalTaxExclude']");
if(costPurchaseDeviceTaxExclude && costPurchaseBuildTaxExclude && costPurchaseServiceTaxExclude && costPurchaseOtherTaxExclude && costProjectManageTaxExclude && costOtherOtherTaxExclude){
costTotalTaxExclude.val(parseFloat(costPurchaseDeviceTaxExclude)+parseFloat(costPurchaseBuildTaxExclude)+parseFloat(costPurchaseServiceTaxExclude)+parseFloat(costPurchaseOtherTaxExclude)+parseFloat(costProjectManageTaxExclude)+parseFloat(costOtherOtherTaxExclude));
}else {
costTotalTaxExclude.val("");
}
}
/**
* 计算毛利毛利率贡献贡献率
*/
@ -181,16 +140,16 @@ function calIncomeCost() {
var projectContributionProfitRate = $("input[name='projectContributionProfitRate']");
if (incomeTotalTaxExclude && costTotalTaxExclude && costExpropriationTaxExclude) {
projectGrossProfit.val(parseFloat(incomeTotalTaxExclude) - parseFloat(costTotalTaxExclude) - parseFloat(costExpropriationTaxExclude));
projectGrossProfitRate.val(parseFloat(projectGrossProfit.val()) * 100 / parseFloat(incomeTotalTaxExclude));
projectGrossProfit.val(f2(incomeTotalTaxExclude) - f2(costTotalTaxExclude) - f2(costExpropriationTaxExclude));
projectGrossProfitRate.val(f2(projectGrossProfit.val()) * 100 / f2(incomeTotalTaxExclude));
} else {
projectGrossProfit.val("");
projectGrossProfitRate.val("");
}
if (projectGrossProfit.val() && costCompanyManageTaxExclude) {
projectContributionProfit.val(parseFloat(projectGrossProfit.val()) - parseFloat(costCompanyManageTaxExclude));
projectContributionProfitRate.val(parseFloat(projectContributionProfit.val()) * 100 / parseFloat(incomeTotalTaxExclude))
projectContributionProfit.val(f2(projectGrossProfit.val()) - f2(costCompanyManageTaxExclude));
projectContributionProfitRate.val(f2(projectContributionProfit.val()) * 100 / f2(incomeTotalTaxExclude))
} else {
projectContributionProfit.val("");
projectContributionProfitRate.val("");

View File

@ -330,6 +330,7 @@
</div>
</div>
<script src="${base}/assets/js/project_common.js"></script>
<script src="${base}/assets/js/project_estimate.js"></script>
<script>
$(function () {