/**
* 一个采购成本详情的字段
*/
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);
});
}