diff --git a/src/main/resources/static/assets/js/project_budget.js b/src/main/resources/static/assets/js/project_budget.js index 3820852..540001a 100644 --- a/src/main/resources/static/assets/js/project_budget.js +++ b/src/main/resources/static/assets/js/project_budget.js @@ -107,8 +107,8 @@ $(function () { //如果没有提交则自动计算预算信息 dataIncome = prepareAjaxDataVerify(dataIncome, INCOME_DETAIL2, $("#id").val()); - if(dataIncome.details){ - postAjax(base+"/project/budgetEditSaveIncomeDetail", dataIncome); + if (dataIncome.details) { + postAjax(base + "/project/budgetEditSaveIncomeDetail", dataIncome); } updateIncomeDataUnsubmit(dataIncomeCheck); @@ -127,8 +127,8 @@ $(function () { //如果没有提交则自动计算预算信息 dataCost = prepareAjaxDataVerify(dataCost, COST_DETAIL2, $("#id").val()); - if(dataCost){ - postAjax(base+"/project/budgetEditSaveCostDetail", dataCost); + if (dataCost) { + postAjax(base + "/project/budgetEditSaveCostDetail", dataCost); } updateCostDataIfUnsubmit(dataCostCheck); @@ -146,17 +146,9 @@ $(function () { } dataManage = prepareAjaxDataVerify(dataManage, COST_PROJECT_MANAGE_DETAIL2, $("#id").val()); - var totalTotal=dataManage.details.reduce((total,now)=>{ - return now.total+total - },0) - var projectGrossProfitA=$('[name="projectGrossProfitA"]').val() - if(Number(totalTotal)> (Number(projectGrossProfitA)*0.1) ){ - layuiAlert(`总金额合计不能超过毛利A(${projectGrossProfitA})的10%`); - $("#saveDraft").attr('disabled', false) - return - } - if(dataManage){ - postAjax(base+"/project/budgetEditSaveCostProjectManageDetail", dataManage); + + if (dataManage) { + postAjax(base + "/project/budgetEditSaveCostProjectManageDetail", dataManage); } updateCostProjectManageDataUnsubmit(dataManageCheck); @@ -182,8 +174,8 @@ $(function () { // } dataPlan = prepareAjaxDataVerify(dataPlan, BUDGET_PLAN_DETAIL2, $("#id").val()); - if(dataPlan){ - postAjax(base+"/project/budgetEditSaveBudgetPlanDetail", dataPlan); + if (dataPlan) { + postAjax(base + "/project/budgetEditSaveBudgetPlanDetail", dataPlan); } updateBudgetPlanDetailDataUnsubmit(); @@ -195,15 +187,15 @@ $(function () { // } // console.log(message); // 保存付款计划表 - var flagPay= verifyBudgetPay() - if(!flagPay) { + var flagPay = verifyBudgetPay() + if (!flagPay) { $("#saveDraft").attr('disabled', false) return; } var dataPay = collectData("am-modal-prompt-input-pay"); dataPay = prepareAjaxDataVerify(dataPay, pay_DETAIL2, $("#id").val()); - if(dataPay){ - postAjax(base+"/project/budgetEditSaveBudgetPayPlan", dataPay); + if (dataPay) { + postAjax(base + "/project/budgetEditSaveBudgetPayPlan", dataPay); } @@ -245,8 +237,8 @@ $(function () { //如果没有提交则自动计算预算信息 dataIncome = prepareAjaxDataVerify(dataIncome, INCOME_DETAIL, $("#id").val()); - if(dataIncome.details){ - postAjax(base+"/project/budgetEditSaveIncomeDetail", dataIncome); + if (dataIncome.details) { + postAjax(base + "/project/budgetEditSaveIncomeDetail", dataIncome); } updateIncomeDataUnsubmit(dataIncomeCheck); @@ -265,8 +257,8 @@ $(function () { //如果没有提交则自动计算预算信息 dataCost = prepareAjaxDataVerify(dataCost, COST_DETAIL, $("#id").val()); - if(dataCost){ - postAjax(base+"/project/budgetEditSaveCostDetail", dataCost); + if (dataCost) { + postAjax(base + "/project/budgetEditSaveCostDetail", dataCost); } updateCostDataIfUnsubmit(dataCostCheck); @@ -285,16 +277,22 @@ $(function () { } dataManage = prepareAjaxDataVerify(dataManage, COST_PROJECT_MANAGE_DETAIL, $("#id").val()); - var totalTotal=dataManage.details.reduce((total,now)=>{ - return now.total+total - },0) - var projectGrossProfitA=$('[name="projectGrossProfitA"]').val() - if(Number(totalTotal)> (Number(projectGrossProfitA)*0.1) ){ - layuiAlert(`总金额合计不能超过毛利A(${projectGrossProfitA})的10%`); + var totalTotal = dataManage.details.reduce((total, now) => { + return now.total + total + }, 0) + var limitTotal = dataManage.details.reduce((total, now) => { + if (now.type == 2 && (now.name == 5 || now.name == 4)) + return now.total + total + else return total + }, 0) + var projectGrossProfitA = $('[name="projectGrossProfitA"]').val() + if (limitTotal > ((Number(projectGrossProfitA)-(totalTotal-limitTotal)) * 0.1)) { + layuiAlert(`差旅费+业务费总金额不超过【毛利A(${projectGrossProfitA})-(项目管理费用-差旅费-业务费)】*10%`); + return } - if(dataManage){ - postAjax(base+"/project/budgetEditSaveCostProjectManageDetail", dataManage); + if (dataManage) { + postAjax(base + "/project/budgetEditSaveCostProjectManageDetail", dataManage); } updateCostProjectManageDataUnsubmit(dataManageCheck); @@ -321,8 +319,8 @@ $(function () { } dataPlan = prepareAjaxDataVerify(dataPlan, BUDGET_PLAN_DETAIL, $("#id").val()); - if(dataPlan){ - postAjax(base+"/project/budgetEditSaveBudgetPlanDetail", dataPlan); + if (dataPlan) { + postAjax(base + "/project/budgetEditSaveBudgetPlanDetail", dataPlan); } updateBudgetPlanDetailDataUnsubmit(); @@ -333,15 +331,15 @@ $(function () { // return; // } // 保存付款计划表 - var flagPay= verifyBudgetPay() - if(!flagPay) { + var flagPay = verifyBudgetPay() + if (!flagPay) { $("#saveDraft").attr('disabled', false) return; } var dataPay = collectData("am-modal-prompt-input-pay"); dataPay = prepareAjaxDataVerify(dataPay, pay_DETAIL2, $("#id").val()); - if(dataPay){ - postAjax(base+"/project/budgetEditSaveBudgetPayPlan", dataPay); + if (dataPay) { + postAjax(base + "/project/budgetEditSaveBudgetPayPlan", dataPay); } var startTime = $("#startDate").val(); @@ -358,7 +356,7 @@ $(function () { $("#pmsForm").submit(); }); - function checkName () { + function checkName() { var name = $("#name").val(); var id = $("#id").val(); $.ajax({ @@ -412,8 +410,6 @@ function checkIfFillIn() { } - - // if (projectNo.length <= 0) { // window.confirm('项目编号不能为空'); // check = 1; @@ -428,9 +424,6 @@ function checkIfFillIn() { // } - - - if (underwrittenMode > 2 && (advanceInterestAmount == undefined || advanceInterestAmount.length <= 0)) { window.confirm('垫资利息不能为空'); check = 1; @@ -525,7 +518,7 @@ function checkIfFillIn() { /** * 判断是否重名 */ -function checkName () { +function checkName() { var name = $("#name").val(); var id = $("#id").val(); $.ajax({ @@ -590,12 +583,12 @@ function arr2ObjectVerify(line, arr, detailPropertyArr, detailProperty) { } //如果要求是数字类型的,进行转换 var v = arr[i]; - if(o[2] === 'number' ){ + if (o[2] === 'number') { v = f2(v); - } else if(o[2] === 'price' ){ + } else if (o[2] === 'price') { v = f5(v); } - obj[detailPropertyArr[i]]=v; + obj[detailPropertyArr[i]] = v; } return obj; } @@ -622,8 +615,8 @@ function arr2ObjectVerifyCheck(line, arr, detailPropertyArr, detailProperty, s) function collectData(className) { var a = []; $("." + className).each(function (t) { - if(!$(this).is(':hidden')) - a.push($(this).val()); + if (!$(this).is(':hidden')) + a.push($(this).val()); }); return a; } @@ -726,7 +719,7 @@ function bindChangeableInput() { $(this).parent().parent().find(".input-changeable-total-tax-include").val(f2Fixed(amount * price)); $(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount * price / (1 + taxRate / 100))); - $(this).parent().parent().find(".input-changeable-total-tax").val(f2Fixed(amount * price * taxRate /(100 + taxRate))); + $(this).parent().parent().find(".input-changeable-total-tax").val(f2Fixed(amount * price * taxRate / (100 + taxRate))); }); //单价改变 $(".input-changeable-price").change(function () { @@ -738,21 +731,21 @@ function bindChangeableInput() { $(this).parent().parent().find(".input-changeable-total-tax-include").val(f2Fixed(amount * price)); $(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount * price / (1 + taxRate / 100))); - $(this).parent().parent().find(".input-changeable-total-tax").val(f2Fixed(amount * price * taxRate /(100 + taxRate))); + $(this).parent().parent().find(".input-changeable-total-tax").val(f2Fixed(amount * price * taxRate / (100 + taxRate))); $(this).val(f5Price(price)); console.log("单价:" + $(this).val()); }); //税率改变 $(".input-changeable-tax-rate").change(function () { var taxRate = f2($(this).val()); - var rowVal=$(this).parent().parent().find(".input-changeable-total-tax-include").val() + var rowVal = $(this).parent().parent().find(".input-changeable-total-tax-include").val() $(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(rowVal * (1 - (taxRate / 100)))); $(this).parent().parent().find(".input-changeable-total-tax").val(f2Fixed(rowVal * (taxRate / 100))); }); // 不含税金额改变 $(".input-changeable-total-tax-include").change(function () { - var rowVal = f2($(this).val()); - var taxRate=$(this).parent().parent().find(".input-changeable-tax-rate").val() + var rowVal = f2($(this).val()); + var taxRate = $(this).parent().parent().find(".input-changeable-tax-rate").val() $(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(rowVal * (1 - (taxRate / 100)))); $(this).parent().parent().find(".input-changeable-total-tax").val(f2Fixed(rowVal * (taxRate / 100))); }); @@ -766,11 +759,11 @@ function bindChangeableInput() { function updateTotal(className, totalClassName) { var total = 0; //找到本列所有的 - $("."+className).each(function (t) { + $("." + className).each(function (t) { total += f2($(this).val()); console.log("total2: " + total); }); - $("."+totalClassName).val(f2Fixed(total)); + $("." + totalClassName).val(f2Fixed(total)); } /** @@ -781,18 +774,18 @@ function updateTotal(className, totalClassName) { function updateAmount(className, totalClassName) { var total = 0; //找到本列所有的 - $("."+className).each(function (t) { + $("." + className).each(function (t) { console.log(className + ": " + f2($(this).val())); total += f2($(this).val()); }); - $("."+totalClassName).val(f2Fixed(total)); + $("." + totalClassName).val(f2Fixed(total)); } /** * 绑定序号 */ function bindNum() { - $(".input-budget-num").each(function(t) { + $(".input-budget-num").each(function (t) { var prevIndex = $(this).parent().parent().prev("tr").find(".input-budget-num").val(); $(this).val(f2(prevIndex) + 1); }); @@ -864,19 +857,19 @@ function updateCostDataIfUnsubmit(details) { var otherTaxInclude = 0; var otherTaxExclude = 0; details.forEach(function (t, number, ts) { - if(t["type"] == "1"){ + if (t["type"] == "1") { //设备类 deviceTaxInclude += f2(t["totalTaxInclude"]); deviceTaxExclude += f2(t["totalTaxExclude"]); - }else if(t["type"] == "2"){ + } else if (t["type"] == "2") { //施工类 buildTaxInclude += f2(t["totalTaxInclude"]); buildTaxExclude += f2(t["totalTaxExclude"]); - }else if(t["type"] == "3"){ + } else if (t["type"] == "3") { //服务类 serviceTaxInclude += f2(t["totalTaxInclude"]); serviceTaxExclude += f2(t["totalTaxExclude"]); - }else if(t["type"] == "4"){ + } else if (t["type"] == "4") { //其他类 otherTaxInclude += f2(t["totalTaxInclude"]); otherTaxExclude += f2(t["totalTaxExclude"]); @@ -893,10 +886,10 @@ function updateCostDataIfUnsubmit(details) { //资金计划表中的 $(".input-total-title-device-cost-budget-plan").val(f2Fixed(deviceTaxInclude)); - $(".input-total-title-engineer-cost-budget-plan").val(f2Fixed(f2(serviceTaxInclude)+f2(buildTaxInclude)+f2(otherTaxInclude))); - $(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude) - +f2($(".input-total-title-project-manage-cost-budget-plan").val()) - +f2($(".input-total-title-earnest-money-cost-budget-plan").val()))); + $(".input-total-title-engineer-cost-budget-plan").val(f2Fixed(f2(serviceTaxInclude) + f2(buildTaxInclude) + f2(otherTaxInclude))); + $(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude) + f2(buildTaxInclude) + f2(serviceTaxInclude) + f2(otherTaxInclude) + + f2($(".input-total-title-project-manage-cost-budget-plan").val()) + + f2($(".input-total-title-earnest-money-cost-budget-plan").val()))); calCostExclude(); calCostInclude(); @@ -922,15 +915,15 @@ function updateIncomeDataUnsubmit(incomeDetails) { incomeDetails.forEach(function (t, number, ts) { console.log("income cost " + t["type"] + ", " + t["taxRate"] + ", " + t["totalTaxInclude"] + ", " + t["totalTaxExclud"]); - if(t["type"] == "1"){ + if (t["type"] == "1") { //设备类 deviceTaxInclude += f2(t["totalTaxInclude"]); deviceTaxExclude += f2(t["totalTaxExclude"]); - }else if(t["type"] == "2"){ + } else if (t["type"] == "2") { //工程类 engineerTaxInclude += f2(t["totalTaxInclude"]); engineerTaxExclude += f2(t["totalTaxExclude"]); - }else if(t["type"] == "3"){ + } else if (t["type"] == "3") { //服务类 serviceTaxInclude += f2(t["totalTaxInclude"]); serviceTaxExclude += f2(t["totalTaxExclude"]); @@ -943,15 +936,15 @@ function updateIncomeDataUnsubmit(incomeDetails) { $("input[name='incomeServiceTaxInclude']").val(f2Fixed(serviceTaxInclude)); $("input[name='incomeServiceTaxExclude']").val(f2Fixed(serviceTaxExclude)); - $("input[name='incomeTotalTaxInclude']").val(f2Fixed(deviceTaxInclude+engineerTaxInclude+serviceTaxInclude)); - $("input[name='incomeTotalTaxExclude']").val(f2Fixed(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude)); - $("input[name='incomeTotalTax']").val(f2Fixed(deviceTaxInclude+engineerTaxInclude+serviceTaxInclude-(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude))); - $("input[name='costCompanyManageTaxExclude']").val(f2Fixed(0.028*(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude))); + $("input[name='incomeTotalTaxInclude']").val(f2Fixed(deviceTaxInclude + engineerTaxInclude + serviceTaxInclude)); + $("input[name='incomeTotalTaxExclude']").val(f2Fixed(deviceTaxExclude + engineerTaxExclude + serviceTaxExclude)); + $("input[name='incomeTotalTax']").val(f2Fixed(deviceTaxInclude + engineerTaxInclude + serviceTaxInclude - (deviceTaxExclude + engineerTaxExclude + serviceTaxExclude))); + $("input[name='costCompanyManageTaxExclude']").val(f2Fixed(0.028 * (deviceTaxExclude + engineerTaxExclude + serviceTaxExclude))); $(".input-total-title-sale-income-budget-plan").val($("input[name='incomeTotalTaxInclude']").val()); $(".input-total-title-total-income-budget-plan").val(f2Fixed(f2($("input[name='incomeTotalTaxInclude']").val()) - +f2($(".input-total-title-earnest-money-income-budget-plan").val()))); + + f2($(".input-total-title-earnest-money-income-budget-plan").val()))); updateProjectContributionProfitRate(); @@ -983,9 +976,9 @@ function updateCostProjectManageDataUnsubmit(details) { var buildTaxInclude = $("input[name='costPurchaseBuildTaxInclude']").val(); var serviceTaxInclude = $("input[name='costPurchaseServiceTaxInclude']").val(); var otherTaxInclude = $("input[name='costPurchaseOtherTaxInclude']").val(); - $(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude) - +total - +f2($(".input-total-title-earnest-money-cost-budget-plan").val()))); + $(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude) + f2(buildTaxInclude) + f2(serviceTaxInclude) + f2(otherTaxInclude) + + total + + f2($(".input-total-title-earnest-money-cost-budget-plan").val()))); calCostExclude(); calCostInclude(); @@ -996,7 +989,7 @@ function updateCostProjectManageDataUnsubmit(details) { /** * 更新页面收入的数据 */ -function updateBudgetPlanDetailDataUnsubmit(data,returnData) { +function updateBudgetPlanDetailDataUnsubmit(data, returnData) { //var details = data.details; //主页面上的财务费用 $("input[name='costExpropriationTaxExclude']").val($(".input-underwritten-plan-statistic-capital-interest-budget-plan").val()); diff --git a/src/main/resources/static/assets/js/project_budget_cost.js b/src/main/resources/static/assets/js/project_budget_cost.js index e07d0f7..aaeaa4b 100644 --- a/src/main/resources/static/assets/js/project_budget_cost.js +++ b/src/main/resources/static/assets/js/project_budget_cost.js @@ -445,7 +445,7 @@ function bindOtherOtherChangeable() { */ function bindTypeSelectChange() { //大类变化联动类别 - $(".input-changeable-tax-rate-income-select").on('change',function () { + $(".input-changeable-tax-rate-cost-select").on('change',function () { var nameSelect = $(this).parent().parent().find(".input-changeable-tax-rate-cost-select"); var nameInput = $(this).parent().parent().find(".input-changeable-tax-rate-cost-name"); var type = $(this).val(); diff --git a/src/main/resources/templates/admin/project_budget_edit.ftl b/src/main/resources/templates/admin/project_budget_edit.ftl index 1595184..308ff3d 100644 --- a/src/main/resources/templates/admin/project_budget_edit.ftl +++ b/src/main/resources/templates/admin/project_budget_edit.ftl @@ -1133,44 +1133,27 @@ - - style="display:none" class="am-modal-prompt-input am-modal-prompt-input am-modal-prompt-input-cost am-modal-prompt-input-cost-category input-changeable-tax-rate-cost-select"> - type="text" + type="text" <#else>type="hidden" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-tax-rate-cost-name" - value="${incomeDetail.name!}"> - - - + value="${costDetail.category!}">