/** * 一个收入详情的字段 */ 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 += f2(t["totalTaxInclude"]); deviceTaxExclude += f2(t["totalTaxExclude"]); }else if(t["type"] == "2"){ //工程类 engineerTaxInclude += f2(t["totalTaxInclude"]); engineerTaxExclude += f2(t["totalTaxExclude"]); }else if(t["type"] == "3"){ //服务类 serviceTaxInclude += f2(t["totalTaxInclude"]); serviceTaxExclude += f2(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 = '