fourcal/src/main/resources/static/assets/js/project_budget_income.js

70 lines
3.6 KiB
JavaScript

/**
* 一个收入详情的字段
*/
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 = '<tr>\n' +
' <td>\n' +
' <select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-income">\n' +
' <option value="1">设备类</option>\n' +
' <option value="2">工程类</option>\n' +
' <option value="3">服务类</option>\n' +
' </select>\n' +
' </td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-amount"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-price"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-tax-rate"></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-total-tax-include" readonly></td>\n' +
' <td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-income input-changeable-total-tax-exclude" readonly></td>\n' +
' <td><button type="button" class="am-btn am-btn-warning am-btn-xs am-modal-line-delete"><span class="am-icon-minus"></span></button></td>\n' +
' </tr>';
$("#incomeTable").append(template);
//重新绑定删除事件和input修改事件
bindDeleteBtn();
bindChangeableInput();
}