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

115 lines
6.2 KiB
JavaScript
Raw Normal View History

2021-11-03 09:53:27 +00:00
/**
* 一个采购成本详情的字段
*/
COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"];
/**
* 采购成本增加一行
*/
function appendTrCost() {
var template = '<tr><td><select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost">'+
'<option value="1">设备</option>'+
'<option value="2">施工</option>'+
'<option value="3">服务</option>'+
'<option value="4">其他</option>'+
'</select>'+
'</td>'+
'<td>'+
'<select style="width: auto" class="am-modal-prompt-input am-modal-prompt-input-cost">'+
'<option value="1">华智产品</option>'+
'<option value="2">紫光其他产品</option>'+
'<option value="3">外购产品</option>'+
'<option value="4">外购工程</option>'+
'<option value="5">华智服务</option>'+
'<option value="6">紫光其他服务</option>'+
'<option value="7">外购服务</option>'+
'<option value="8">其他</option>'+
'</select>'+
'</td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost"></td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost""></td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-amount"></td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-price"></td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-tax-rate"></td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-include" readonly></td>'+
'<td><input type="text" class="am-modal-prompt-input am-modal-prompt-input-cost input-changeable-total-tax-exclude" readonly></td>'+
'<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>'+
'</tr>';
$("#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);
});
}