diff --git a/src/main/resources/static/assets/js/project_budget.js b/src/main/resources/static/assets/js/project_budget.js deleted file mode 100644 index 67cea2b..0000000 --- a/src/main/resources/static/assets/js/project_budget.js +++ /dev/null @@ -1,325 +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..987ac9f --- /dev/null +++ b/src/main/resources/static/assets/js/project_budget_cost.js @@ -0,0 +1,115 @@ +/** + * 一个采购成本详情的字段 + */ +COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"]; + +/** + * 采购成本增加一行 + */ +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_income.js b/src/main/resources/static/assets/js/project_budget_income.js new file mode 100644 index 0000000..39306a6 --- /dev/null +++ b/src/main/resources/static/assets/js/project_budget_income.js @@ -0,0 +1,70 @@ +/** + * 一个收入详情的字段 + */ +INCOME_DETAIL_ARR=["type","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"]; + +/** + * 更新页面收入的数据【累加】 + */ +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 - + + +