diff --git a/src/main/resources/static/assets/js/project_budget.js b/src/main/resources/static/assets/js/project_budget.js index 007d5e2..e69de29 100644 --- a/src/main/resources/static/assets/js/project_budget.js +++ b/src/main/resources/static/assets/js/project_budget.js @@ -1,332 +0,0 @@ -/** - * 一维数组变二维数组 - * @param list - * @param elementsPerSubArray - * @returns {Array} - */ -function arrayToMatrix(list, elementsPerSubArray) { - var matrix = [], i, k; - - for (i = 0, k = -1; i < list.length; i++) { - if (i % elementsPerSubArray === 0) { - k++; - matrix[k] = []; - } - - matrix[k].push(list[i]); - } - - return matrix; -} - -/** - * 根据映射关系将数组变为对象 - */ -function arr2Object(arr, mapArr) { - var obj = {}; - for (var i = 0; i < mapArr.length; i++) { - if(!arr[i]){ - //如果有空的就返回空 - return null; - } - obj[mapArr[i]]=arr[i]; - } - return obj; -} - - -/** - * 收集收入明细的数据,因为动态添加的行modal无法识别,所以自己来收集 - * @returns {Array} - */ -function collectData(className) { - var a= []; - $("." + className).each(function (t) { - a.push($(this).val()); - }); - return a; -} - -/** - * 绑定每一行的删除事件,删除当前的一行tr - */ -function bindDeleteBtn() { - $(".am-modal-line-delete").click(function () { - //删除自己对应的tr - $(this).parent().parent().remove(); - }); -} -/** - * 一个收入详情的字段 - */ -INCOME_DETAIL_ARR=["type","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"]; -/** - * 一个采购成本详情的字段 - */ -COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"]; - -/** - * 将页面收集到的数据转换为ajax请求的数据【一维数组转换为对象数组】 - * @param data - * @param detailPropertyArr - * @returns {Array} - */ -function convertDetail(data,detailPropertyArr) { - var arr = arrayToMatrix(data,detailPropertyArr.length); - - var details = []; - for (var i=0;i\n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' \n' + - ' '; - $("#incomeTable").append(template); - //重新绑定删除事件和input修改事件 - bindDeleteBtn(); - bindChangeableInput(); -} - - -/** - * 采购成本增加一行 - */ -function appendTrCost() { - var template = ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''; - $("#costTable").append(template); - //重新绑定删除事件和input修改事件 - bindDeleteBtn(); - bindChangeableInput(); -} -/** - * 更新页面收入的数据【累加】 - * 明细保存后回来更新总含税金额和不含税金额 - */ -function updateCostData(details) { - var deviceTaxInclude = 0; - var deviceTaxExclude = 0; - var buildTaxInclude = 0; - var buildTaxExclude = 0; - var serviceTaxInclude = 0; - var serviceTaxExclude = 0; - var otherTaxInclude = 0; - var otherTaxExclude = 0; - details.forEach(function (t, number, ts) { - if(t["type"] == "1"){ - //设备类 - deviceTaxInclude += parseFloat(t["totalTaxInclude"]); - deviceTaxExclude += parseFloat(t["totalTaxExclude"]); - }else if(t["type"] == "2"){ - //施工类 - buildTaxInclude += parseFloat(t["totalTaxInclude"]); - buildTaxExclude += parseFloat(t["totalTaxExclude"]); - }else if(t["type"] == "3"){ - //服务类 - serviceTaxInclude += parseFloat(t["totalTaxInclude"]); - serviceTaxExclude += parseFloat(t["totalTaxExclude"]); - }else if(t["type"] == "4"){ - //其他类 - otherTaxInclude += parseFloat(t["totalTaxInclude"]); - otherTaxExclude += parseFloat(t["totalTaxExclude"]); - } - }); - $("input[name='costPurchaseDeviceTaxInclude']").val(deviceTaxInclude); - $("input[name='costPurchaseDeviceTaxExclude']").val(deviceTaxExclude); - $("input[name='costPurchaseBuildTaxInclude']").val(buildTaxInclude); - $("input[name='costPurchaseBuildTaxExclude']").val(buildTaxExclude); - $("input[name='costPurchaseServiceTaxInclude']").val(serviceTaxInclude); - $("input[name='costPurchaseServiceTaxExclude']").val(serviceTaxExclude); - $("input[name='costPurchaseOtherTaxInclude']").val(otherTaxInclude); - $("input[name='costPurchaseOtherTaxExclude']").val(otherTaxExclude); - - var costOtherOtherTaxInclude = parseFloat($("input[name='costOtherOtherTaxInclude']").val()); - var costOtherOtherTaxExclude = parseFloat($("input[name='costOtherOtherTaxExclude']").val()); - - var costProjectManageTaxExclude = parseFloat($("input[name='costProjectManageTaxExclude']").val()); - - $("input[name='costTotalTaxInclude']").val(deviceTaxInclude+buildTaxInclude+serviceTaxInclude+otherTaxInclude+costOtherOtherTaxInclude); - $("input[name='costTotalTaxExclude']").val(deviceTaxExclude+buildTaxExclude+serviceTaxExclude+otherTaxExclude+costOtherOtherTaxExclude+costProjectManageTaxExclude); -} - -function bindOtherOtherChangeable() { - /** - * 其他其他含税金额改变的时候,修改总含税金额 - */ - $("input[name='costOtherOtherTaxInclude']").change(function () { - var costPurchaseDeviceTaxInclude = parseFloat($("input[name='costPurchaseDeviceTaxInclude']").val()); - var costPurchaseBuildTaxInclude = parseFloat($("input[name='costPurchaseBuildTaxInclude']").val()); - var costPurchaseServiceTaxInclude = parseFloat($("input[name='costPurchaseServiceTaxInclude']").val()); - var costPurchaseOtherTaxInclude = parseFloat($("input[name='costPurchaseOtherTaxInclude']").val()); - - var costOtherOther = parseFloat($(this).val()); - - $("input[name='costTotalTaxInclude']").val(costPurchaseDeviceTaxInclude+costPurchaseBuildTaxInclude+costPurchaseServiceTaxInclude+costPurchaseOtherTaxInclude+costOtherOther); - }); - /** - * 其他其他不含税金额改变的时候,修改总不含税金额 - */ - $("input[name='costOtherOtherTaxExclude']").change(function () { - var costPurchaseDeviceTaxExclude = parseFloat($("input[name='costPurchaseDeviceTaxExclude']").val()); - var costPurchaseBuildTaxExclude = parseFloat($("input[name='costPurchaseBuildTaxExclude']").val()); - var costPurchaseServiceTaxExclude = parseFloat($("input[name='costPurchaseServiceTaxExclude']").val()); - var costPurchaseOtherTaxExclude = parseFloat($("input[name='costPurchaseOtherTaxExclude']").val()); - - var costProjectManageTaxExclude = parseFloat($("input[name='costProjectManageTaxExclude']").val()); - var costOtherOther = parseFloat($(this).val()); - - $("input[name='costTotalTaxExclude']").val(costPurchaseDeviceTaxExclude+costPurchaseBuildTaxExclude+costPurchaseServiceTaxExclude+costPurchaseOtherTaxExclude+costProjectManageTaxExclude+costOtherOther); - }); -} \ No newline at end of file diff --git a/src/main/resources/static/assets/js/project_budget_cost.js b/src/main/resources/static/assets/js/project_budget_cost.js new file mode 100644 index 0000000..09f2f2e --- /dev/null +++ b/src/main/resources/static/assets/js/project_budget_cost.js @@ -0,0 +1,132 @@ +/** + * 一个采购成本详情的字段 + */ +COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"]; +$(function () { + $("#cost-detail").click(function () { + $('#my-prompt-cost-detail').modal({ + relatedTarget: this, + onConfirm: function(e) { + //不能使用e.data,因为无法获取动态添加的 + var data = collectData("am-modal-prompt-input-cost"); + data = prepareAjaxData(data, COST_DETAIL_ARR, $("#id").val()); + saveDetail("/fourcal/project/budgetEditSaveCostDetail", data, updateCostData); + }, + onCancel: function(e) { + } + }); + }); + $("#costAddBtn").click(function () { + appendTrCost(); + }); +}); +/** + * 采购成本增加一行 + */ +function appendTrCost() { + var template = ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''; + $("#costTable").append(template); + //重新绑定删除事件和input修改事件 + bindDeleteBtn(); + bindChangeableInput(); +} +/** + * 更新页面收入的数据【累加】 + */ +function updateCostData(details) { + var deviceTaxInclude = 0; + var deviceTaxExclude = 0; + var buildTaxInclude = 0; + var buildTaxExclude = 0; + var serviceTaxInclude = 0; + var serviceTaxExclude = 0; + var otherTaxInclude = 0; + var otherTaxExclude = 0; + details.forEach(function (t, number, ts) { + if(t["type"] == "1"){ + //设备类 + deviceTaxInclude += parseFloat(t["totalTaxInclude"]); + deviceTaxExclude += parseFloat(t["totalTaxExclude"]); + }else if(t["type"] == "2"){ + //施工类 + buildTaxInclude += parseFloat(t["totalTaxInclude"]); + buildTaxExclude += parseFloat(t["totalTaxExclude"]); + }else if(t["type"] == "3"){ + //服务类 + serviceTaxInclude += parseFloat(t["totalTaxInclude"]); + serviceTaxExclude += parseFloat(t["totalTaxExclude"]); + }else if(t["type"] == "4"){ + //其他类 + otherTaxInclude += parseFloat(t["totalTaxInclude"]); + otherTaxExclude += parseFloat(t["totalTaxExclude"]); + } + }); + $("input[name='costPurchaseDeviceTaxInclude']").val(deviceTaxInclude); + $("input[name='costPurchaseDeviceTaxExclude']").val(deviceTaxExclude); + $("input[name='costPurchaseBuildTaxInclude']").val(buildTaxInclude); + $("input[name='costPurchaseBuildTaxExclude']").val(buildTaxExclude); + $("input[name='costPurchaseServiceTaxInclude']").val(serviceTaxInclude); + $("input[name='costPurchaseServiceTaxExclude']").val(serviceTaxExclude); + $("input[name='costPurchaseOtherTaxInclude']").val(otherTaxInclude); + $("input[name='costPurchaseOtherTaxExclude']").val(otherTaxExclude); + + var costOtherOtherTaxInclude = parseFloat($("input[name='costOtherOtherTaxInclude']").val()); + var costOtherOtherTaxExclude = parseFloat($("input[name='costOtherOtherTaxExclude']").val()); + + var costProjectManageTaxExclude = parseFloat($("input[name='costProjectManageTaxExclude']").val()); + + $("input[name='costTotalTaxInclude']").val(deviceTaxInclude+buildTaxInclude+serviceTaxInclude+otherTaxInclude+costOtherOtherTaxInclude); + $("input[name='costTotalTaxExclude']").val(deviceTaxExclude+buildTaxExclude+serviceTaxExclude+otherTaxExclude+costOtherOtherTaxExclude+costProjectManageTaxExclude); +} + +function bindOtherOtherChangeable() { + $("input[name='costOtherOtherTaxInclude']").change(function () { + var costPurchaseDeviceTaxInclude = parseFloat($("input[name='costPurchaseDeviceTaxInclude']").val()); + var costPurchaseBuildTaxInclude = parseFloat($("input[name='costPurchaseBuildTaxInclude']").val()); + var costPurchaseServiceTaxInclude = parseFloat($("input[name='costPurchaseServiceTaxInclude']").val()); + var costPurchaseOtherTaxInclude = parseFloat($("input[name='costPurchaseOtherTaxInclude']").val()); + + var costOtherOther = parseFloat($(this).val()); + + $("input[name='costTotalTaxInclude']").val(costPurchaseDeviceTaxInclude+costPurchaseBuildTaxInclude+costPurchaseServiceTaxInclude+costPurchaseOtherTaxInclude+costOtherOther); + }); + + $("input[name='costOtherOtherTaxExclude']").change(function () { + var costPurchaseDeviceTaxExclude = parseFloat($("input[name='costPurchaseDeviceTaxExclude']").val()); + var costPurchaseBuildTaxExclude = parseFloat($("input[name='costPurchaseBuildTaxExclude']").val()); + var costPurchaseServiceTaxExclude = parseFloat($("input[name='costPurchaseServiceTaxExclude']").val()); + var costPurchaseOtherTaxExclude = parseFloat($("input[name='costPurchaseOtherTaxExclude']").val()); + + var costProjectManageTaxExclude = parseFloat($("input[name='costProjectManageTaxExclude']").val()); + var costOtherOther = parseFloat($(this).val()); + + $("input[name='costTotalTaxExclude']").val(costPurchaseDeviceTaxExclude+costPurchaseBuildTaxExclude+costPurchaseServiceTaxExclude+costPurchaseOtherTaxExclude+costProjectManageTaxExclude+costOtherOther); + }); +} \ No newline at end of file diff --git a/src/main/resources/static/assets/js/project_budget_cost_project_manage.js b/src/main/resources/static/assets/js/project_budget_cost_project_manage.js new file mode 100644 index 0000000..0cddd01 --- /dev/null +++ b/src/main/resources/static/assets/js/project_budget_cost_project_manage.js @@ -0,0 +1,91 @@ +/** + * 一个采购成本详情的字段 + */ +COST_PROJECT_MANAGE_DETAIL_ARR=["type","name","detail","unit","amount","price","total","predictMethod","predictWhy","remark"]; +$(function () { + $("#cost-project-manage-detail").click(function () { + $('#my-prompt-cost-project-manage-detail').modal({ + relatedTarget: this, + onConfirm: function(e) { + //不能使用e.data,因为无法获取动态添加的 + var data = collectData("am-modal-prompt-input-cost-project-manage"); + data = prepareAjaxData(data, COST_PROJECT_MANAGE_DETAIL_ARR, $("#id").val()); + saveDetail("/fourcal/project/budgetEditSaveCostProjectManageDetail", data, updateCostProjectManageData); + }, + onCancel: function(e) { + } + }); + }); + $("#costProjectManageAddBtn").click(function () { + appendTrCostProjectManage(); + }); +}); +/** + * 采购成本增加一行 + */ +function appendTrCostProjectManage() { + var template = '\n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' '; + $("#costProjectManageTable").append(template); + //重新绑定删除事件和input修改事件 + bindDeleteBtn(); + bindChangeableInputProjectManage(); +} + +function bindChangeableInputProjectManage() { + //数量改变 + $(".input-changeable-amount0").change(function () { + var amount = parseFloat($(this).val()); + //找到对应的单价 + var price = parseFloat($(this).parent().parent().find(".input-changeable-price-project-manage").val()); + console.log(amount,price); + + $(this).parent().parent().find(".input-changeable-total-project-manage").val(amount*price); + }); + //单价改变 + $(".input-changeable-price0").change(function () { + var price = parseFloat($(this).val()); + //找到对应的数量 + var amount = parseFloat($(this).parent().parent().find(".input-changeable-amount-project-manage").val()); + console.log(amount,price); + + $(this).parent().parent().find(".input-changeable-total-project-manage").val(amount*price); + }); +} +/** + * 更新页面收入的数据【累加】 + */ +function updateCostProjectManageData(details) { + var total = 0; + details.forEach(function (t, number, ts) { + total += parseFloat(t["total"]); + }); + + $("input[name='costProjectManageTaxExclude']").val(total); + + var costPurchaseDeviceTaxExclude = parseFloat($("input[name='costPurchaseDeviceTaxExclude']").val()); + var costPurchaseBuildTaxExclude = parseFloat($("input[name='costPurchaseBuildTaxExclude']").val()); + var costPurchaseServiceTaxExclude = parseFloat($("input[name='costPurchaseServiceTaxExclude']").val()); + var costPurchaseOtherTaxExclude = parseFloat($("input[name='costPurchaseOtherTaxExclude']").val()); + + var costOtherOtherTaxExclude = parseFloat($("input[name='costOtherOtherTaxExclude']").val()); + + $("input[name='costTotalTaxExclude']").val(costPurchaseDeviceTaxExclude+costPurchaseBuildTaxExclude+costPurchaseServiceTaxExclude+costPurchaseOtherTaxExclude+total+costOtherOtherTaxExclude); +} \ No newline at end of file diff --git a/src/main/resources/static/assets/js/project_budget_income.js b/src/main/resources/static/assets/js/project_budget_income.js new file mode 100644 index 0000000..64c850f --- /dev/null +++ b/src/main/resources/static/assets/js/project_budget_income.js @@ -0,0 +1,90 @@ +/** + * 一个收入详情的字段 + */ +INCOME_DETAIL_ARR=["type","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"]; + +$(function () { + $("#income-detail").click(function () { + $('#my-prompt-income-detail').modal({ + relatedTarget: this, + onConfirm: function(e) { + //不能使用e.data,因为无法获取动态添加的 + var data = collectData("am-modal-prompt-input-income"); + data = prepareAjaxData(data, INCOME_DETAIL_ARR, $("#id").val()); + saveDetail("/fourcal/project/budgetEditSaveIncomeDetail", data, updateIncomeData); + }, + onCancel: function(e) { + } + }); + }); + $("#incomeAddBtn").click(function () { + appendTrIncome(); + }); +}); + + +/** + * 更新页面收入的数据【累加】 + */ +function updateIncomeData(incomeDetails) { + var deviceTaxInclude = 0; + var deviceTaxExclude = 0; + var engineerTaxInclude = 0; + var engineerTaxExclude = 0; + var serviceTaxInclude = 0; + var serviceTaxExclude = 0; + incomeDetails.forEach(function (t, number, ts) { + if(t["type"] == "1"){ + //设备类 + deviceTaxInclude += parseFloat(t["totalTaxInclude"]); + deviceTaxExclude += parseFloat(t["totalTaxExclude"]); + }else if(t["type"] == "2"){ + //工程类 + engineerTaxInclude += parseFloat(t["totalTaxInclude"]); + engineerTaxExclude += parseFloat(t["totalTaxExclude"]); + }else if(t["type"] == "3"){ + //服务类 + serviceTaxInclude += parseFloat(t["totalTaxInclude"]); + serviceTaxExclude += parseFloat(t["totalTaxExclude"]); + } + }); + $("input[name='incomeDeviceTaxInclude']").val(deviceTaxInclude); + $("input[name='incomeDeviceTaxExclude']").val(deviceTaxExclude); + $("input[name='incomeEngineerTaxInclude']").val(engineerTaxInclude); + $("input[name='incomeEngineerTaxExclude']").val(engineerTaxExclude); + $("input[name='incomeServiceTaxInclude']").val(serviceTaxInclude); + $("input[name='incomeServiceTaxExclude']").val(serviceTaxExclude); + + $("input[name='incomeTotalTaxInclude']").val(deviceTaxInclude+engineerTaxInclude+serviceTaxInclude); + $("input[name='incomeTotalTaxExclude']").val(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude); +} + + + + +/** + * 收入明细增加一行 + */ +function appendTrIncome() { + var template = '\n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' '; + $("#incomeTable").append(template); + //重新绑定删除事件和input修改事件 + bindDeleteBtn(); + bindChangeableInput(); +} \ No newline at end of file diff --git a/src/main/resources/static/assets/js/project_common.js b/src/main/resources/static/assets/js/project_common.js new file mode 100644 index 0000000..f9d32f2 --- /dev/null +++ b/src/main/resources/static/assets/js/project_common.js @@ -0,0 +1,140 @@ +/** + * 一维数组变二维数组 + * @param list + * @param elementsPerSubArray + * @returns {Array} + */ +function arrayToMatrix(list, elementsPerSubArray) { + var matrix = [], i, k; + + for (i = 0, k = -1; i < list.length; i++) { + if (i % elementsPerSubArray === 0) { + k++; + matrix[k] = []; + } + + matrix[k].push(list[i]); + } + + return matrix; +} + +/** + * 根据映射关系将数组变为对象 + */ +function arr2Object(arr, mapArr) { + var obj = {}; + for (var i = 0; i < mapArr.length; i++) { + if(!arr[i]){ + //如果有空的就返回空 + return null; + } + obj[mapArr[i]]=arr[i]; + } + return obj; +} + + +/** + * 收集收入明细的数据,因为动态添加的行modal无法识别,所以自己来收集 + * @returns {Array} + */ +function collectData(className) { + var a= []; + $("." + className).each(function (t) { + a.push($(this).val()); + }); + return a; +} + +/** + * 绑定每一行的删除事件,删除当前的一行tr + */ +function bindDeleteBtn() { + $(".am-modal-line-delete").click(function () { + //删除自己对应的tr + $(this).parent().parent().remove(); + }); +} + +/** + * 将页面收集到的数据转换为ajax请求的数据【一维数组转换为对象数组】 + * @param data + * @param detailPropertyArr + * @returns {Array} + */ +function convertDetail(data,detailPropertyArr) { + var arr = arrayToMatrix(data,detailPropertyArr.length); + + var details = []; + for (var i=0;i + <#--项目管理明细表弹窗--> +
+
+
新增项目管理成本明细表——${project.name}
+
+ + + + + + + + + + + + + + + + <#if costProjectManageDetails??> + <#list costProjectManageDetails as costProjectManageDetail> + + + + + + + + + + + + + + + - + +
财务费用类别业务项目项目明细单位数量单价总金额(元)预估计算方法预估依据备注操作
+ +
+ +
+ +
+
@@ -542,13 +594,17 @@ - + + + +