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

738 lines
27 KiB
JavaScript
Raw Normal View History

2022-01-10 08:14:06 +00:00
INCOME_DETAIL={
2022-01-13 07:33:01 +00:00
"num":[false,"序号","string"],
2022-01-10 08:14:06 +00:00
"type":[true,"类别","string"],
"name":[true,"名称","string"],
"unit":[true,"单位","string"],
"amount":[true,"数量","string"],
"price":[true,"单价","price"],
"taxRate":[true,"税率","number"],
"totalTaxInclude":[true,"含税总金额","number"],
"totalTaxExclude":[true,"不含税金额","number"]
2022-01-04 08:33:10 +00:00
};
COST_DETAIL={
2022-01-13 07:33:01 +00:00
"num":[false,"序号","string"],
2022-01-10 08:14:06 +00:00
"type":[true,"大类","string"],
"category":[true,"类别","string"],
"name":[true,"名称","string"],
"unit":[true,"单位","string"],
"amount":[true,"数量","string"],
"price":[true,"单价","price"],
"taxRate":[true,"税率","number"],
"totalTaxInclude":[true,"含税总金额","number"],
"totalTaxExclude":[true,"不含税金额","number"]
2022-01-04 08:33:10 +00:00
};
COST_PROJECT_MANAGE_DETAIL={
2022-01-13 07:33:01 +00:00
"num":[false,"序号","string"],
2022-01-10 08:14:06 +00:00
"type":[true,"财务费用类别","string"],
"name1":[false,"业务项目","string"],
"name2":[false,"业务项目","string"],
"detail":[true,"项目明细","string"],
"unit":[true,"单位","string"],
"amount":[true,"数量","string"],
"price":[true,"单价","price"],
"total":[true,"总金额","number"],
"predictMethod":[false,"预估计算方法","string"],
"predictWhy":[false,"预估依据","string"],
"remark":[false,"备注","string"],
"deletable":[true,"是否可删除","string"]
2022-01-04 08:33:10 +00:00
};
BUDGET_PLAN_DETAIL={
"month":[true,"月份"],
2022-01-10 08:14:06 +00:00
"deviceCost":[true,"设备支出","number"],
"engineerCost":[true,"工程支出","number"],
"projectManageCost":[true,"经营性开支","number"],
"earnestMoneyCost":[true,"保证金支出","number"],
"totalCost":[true,"支出合计","number"],
"saleIncome":[true,"销售收款","number"],
"earnestMoneyIncome":[true,"保证金收款","number"],
"totalIncome":[true,"收款合计","number"],
"fundBalance":[true,"资金余额","number"],
"capitalInterest":[true,"资金利息","number"],
"underwrittenPlan":[true,"垫资计划","number"],
"repaymentPlan":[true,"还款计划","number"]
2022-01-04 08:33:10 +00:00
};
2021-11-06 06:45:57 +00:00
$(function () {
2022-01-07 01:57:34 +00:00
$("input[name='costCompanyManageTaxExclude']").change(function () {
digitalSelf("costCompanyManageTaxExclude", "input[name='costCompanyManageTaxExclude']");
});
$("input[name='costOtherOtherTaxInclude']").change(function () {
console.log("budget.js:costOtherOtherTaxInclude");
digitalSelf("costOtherOtherTaxInclude", "input[name='costOtherOtherTaxInclude']");
});
$("input[name='costOtherOtherTaxExclude']").change(function () {
console.log("budget.js:costOtherOtherTaxExclude");
digitalSelf("costOtherOtherTaxExclude", "input[name='costOtherOtherTaxExclude']");
});
2021-11-06 06:45:57 +00:00
//绑定删除按钮删除当前行
bindDeleteBtn();
//绑定收入和采购成本的输入框【都有税率】
bindChangeableInput();
2022-04-19 07:47:59 +00:00
//绑定总计的输入框
bindIncomeTotal();
$("#saveDraft").click(function () {
2022-01-18 06:51:07 +00:00
$("#saveDraft").attr('disabled', true);
2022-01-04 07:27:55 +00:00
var dataIncome = collectData("am-modal-prompt-input-income");
2022-01-04 08:33:10 +00:00
if (dataIncome.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写收入明细表');
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataIncomeCheck = convertDetailVerifyCheck(dataIncome, INCOME_DETAIL, "收入明细表");
if (dataIncomeCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
//如果没有提交则自动计算预算信息
2022-01-05 03:22:40 +00:00
dataIncome = prepareAjaxDataVerify(dataIncome, INCOME_DETAIL, $("#id").val());
if(dataIncome.details){
postAjax(base+"/project/budgetEditSaveIncomeDetail", dataIncome);
}
updateIncomeDataUnsubmit(dataIncomeCheck);
2022-01-04 07:27:55 +00:00
var dataCost = collectData("am-modal-prompt-input-cost");
2022-01-04 08:33:10 +00:00
if (dataCost.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写采购成本明细表');
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataCostCheck = convertDetailVerifyCheck(dataCost, COST_DETAIL, "采购成本明细表");
if (dataCostCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
//如果没有提交则自动计算预算信息
2022-01-05 03:22:40 +00:00
dataCost = prepareAjaxDataVerify(dataCost, COST_DETAIL, $("#id").val());
if(dataCost){
postAjax(base+"/project/budgetEditSaveCostDetail", dataCost);
}
updateCostDataIfUnsubmit(dataCostCheck);
2022-01-04 07:27:55 +00:00
var dataManage = collectData("am-modal-prompt-input-cost-project-manage");
2022-01-04 08:33:10 +00:00
if (dataManage.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写项目管理成本表');
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataManageCheck = convertDetailVerifyCheck(dataManage, COST_PROJECT_MANAGE_DETAIL, "项目管理成本表");
if (dataManageCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
2022-01-05 03:22:40 +00:00
dataManage = prepareAjaxDataVerify(dataManage, COST_PROJECT_MANAGE_DETAIL, $("#id").val());
if(dataManage){
postAjax(base+"/project/budgetEditSaveCostProjectManageDetail", dataManage);
}
updateCostProjectManageDataUnsubmit(dataManageCheck);
2022-01-04 07:27:55 +00:00
var dataPlan = collectData("am-modal-prompt-input-budget-plan-detail");
2022-01-04 08:33:10 +00:00
if (dataPlan.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写项目资金计划表');
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataPlanCheck = convertDetailVerifyCheck(dataPlan, BUDGET_PLAN_DETAIL, "项目资金计划表");
if (dataPlanCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
2022-01-05 08:44:25 +00:00
//校验数据正确性
var message = verifyBudgetPlan();
if (message) {
layuiAlert(message);
2022-02-11 09:05:10 +00:00
$("#saveDraft").attr('disabled', false);
2022-01-05 08:44:25 +00:00
return;
}
2022-01-05 03:29:47 +00:00
dataPlan = prepareAjaxDataVerify(dataPlan, BUDGET_PLAN_DETAIL, $("#id").val());
if(dataPlan){
postAjax(base+"/project/budgetEditSaveBudgetPlanDetail", dataPlan);
}
updateBudgetPlanDetailDataUnsubmit();
var message = verifyProjectContributionProfitRate();
if (message) {
2022-01-04 08:33:10 +00:00
$("#saveDraft").attr('disabled', false);
2021-12-09 12:09:45 +00:00
layuiAlert(message);
2022-01-04 08:33:10 +00:00
return;
}
console.log(message);
2021-12-08 09:37:57 +00:00
var startTime = $("#startDate").val();
var endTime = $("#endDate").val();
if (startTime > endTime) {
2022-01-04 08:33:10 +00:00
$("#saveDraft").attr('disabled', false);
2021-12-08 09:37:57 +00:00
window.confirm('开始日期应早于结束日期');
return;
}
2022-01-18 06:51:07 +00:00
setTimeout(function () {
$("#saveDraft").attr('disabled', false);
}, 5000);
2022-01-04 08:33:10 +00:00
$("#pmsForm").attr("action", base + "/project/budgetEditSave");
$("#pmsForm").submit();
});
$("#saveApprove").click(function () {
2022-01-18 06:51:07 +00:00
$("#saveApprove").attr('disabled', true);
2022-01-04 07:27:55 +00:00
var dataIncome = collectData("am-modal-prompt-input-income");
2022-01-04 08:33:10 +00:00
if (dataIncome.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写收入明细表');
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataIncomeCheck = convertDetailVerifyCheck(dataIncome, INCOME_DETAIL, "收入明细表");
if (dataIncomeCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
2022-01-05 03:29:47 +00:00
//如果没有提交则自动计算预算信息
dataIncome = prepareAjaxDataVerify(dataIncome, INCOME_DETAIL, $("#id").val());
if(dataIncome.details){
postAjax(base+"/project/budgetEditSaveIncomeDetail", dataIncome);
}
updateIncomeDataUnsubmit(dataIncomeCheck);
2022-01-04 07:27:55 +00:00
var dataCost = collectData("am-modal-prompt-input-cost");
2022-01-04 08:33:10 +00:00
if (dataCost.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写采购成本明细表');
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataCostCheck = convertDetailVerifyCheck(dataCost, COST_DETAIL, "采购成本明细表");
if (dataCostCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
2022-01-05 03:29:47 +00:00
//如果没有提交则自动计算预算信息
dataCost = prepareAjaxDataVerify(dataCost, COST_DETAIL, $("#id").val());
if(dataCost){
postAjax(base+"/project/budgetEditSaveCostDetail", dataCost);
}
updateCostDataIfUnsubmit(dataCostCheck);
2022-01-04 07:27:55 +00:00
var dataManage = collectData("am-modal-prompt-input-cost-project-manage");
2022-01-04 08:33:10 +00:00
if (dataManage.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写项目管理成本表');
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataManageCheck = convertDetailVerifyCheck(dataManage, COST_PROJECT_MANAGE_DETAIL, "项目管理成本表");
if (dataManageCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
2022-01-05 03:29:47 +00:00
dataManage = prepareAjaxDataVerify(dataManage, COST_PROJECT_MANAGE_DETAIL, $("#id").val());
if(dataManage){
postAjax(base+"/project/budgetEditSaveCostProjectManageDetail", dataManage);
}
updateCostProjectManageDataUnsubmit(dataManageCheck);
2022-01-04 07:27:55 +00:00
var dataPlan = collectData("am-modal-prompt-input-budget-plan-detail");
2022-01-04 08:33:10 +00:00
if (dataPlan.length <= 0) {
2022-01-04 07:27:55 +00:00
window.confirm('请填写项目资金计划表');
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 07:27:55 +00:00
return;
}
2022-01-04 08:33:10 +00:00
var dataPlanCheck = convertDetailVerifyCheck(dataPlan, BUDGET_PLAN_DETAIL, "项目资金计划表");
if (dataPlanCheck == null) {
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-04 08:33:10 +00:00
return;
}
2022-01-05 08:44:25 +00:00
//校验数据正确性
var message = verifyBudgetPlan();
if (message) {
layuiAlert(message);
2022-02-11 09:05:10 +00:00
$("#saveApprove").attr('disabled', false);
2022-01-05 08:44:25 +00:00
return;
}
2022-01-05 03:22:40 +00:00
dataPlan = prepareAjaxDataVerify(dataPlan, BUDGET_PLAN_DETAIL, $("#id").val());
if(dataPlan){
2022-01-05 03:26:17 +00:00
postAjax(base+"/project/budgetEditSaveBudgetPlanDetail", dataPlan);
2022-01-05 03:22:40 +00:00
}
updateBudgetPlanDetailDataUnsubmit();
var message = verifyProjectContributionProfitRate();
if (message) {
2022-01-04 08:33:10 +00:00
$("#saveApprove").attr('disabled', false);
2021-12-09 12:09:45 +00:00
layuiAlert(message);
return;
}
2021-12-08 09:37:57 +00:00
var startTime = $("#startDate").val();
var endTime = $("#endDate").val();
if (startTime > endTime) {
2022-01-04 08:33:10 +00:00
$("#saveApprove").attr('disabled', false);
2021-12-08 09:37:57 +00:00
window.confirm('开始日期应早于结束日期');
return;
}
2022-01-18 06:51:07 +00:00
setTimeout(function () {
$("#saveApprove").attr('disabled', false);
}, 5000);
2022-01-04 08:33:10 +00:00
$("#pmsForm").attr("action", base + "/project/budgetEditSaveAndApprove");
$("#pmsForm").submit();
});
2021-11-06 06:45:57 +00:00
});
2021-11-08 06:45:41 +00:00
/**
* 一维数组变二维数组
* @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;
}
/**
* 根据映射关系将数组变为对象
2021-11-24 12:36:50 +00:00
* @param arr 一行数据
* @param mapArr 映射数组
* @param keepBlank 如果有空的并且不保留空就返回空废弃这一行
* @returns {*}
2021-11-08 06:45:41 +00:00
*/
2021-11-24 12:36:50 +00:00
function arr2Object(arr, mapArr, keepBlank) {
2021-11-08 06:45:41 +00:00
var obj = {};
for (var i = 0; i < mapArr.length; i++) {
2022-01-04 08:33:10 +00:00
if (!arr[i] && !keepBlank) {
2021-11-08 06:45:41 +00:00
return null;
}
2022-01-04 08:33:10 +00:00
obj[mapArr[i]] = arr[i];
2021-11-08 06:45:41 +00:00
}
return obj;
}
2022-01-04 08:33:10 +00:00
2021-12-09 11:49:42 +00:00
function arr2ObjectVerify(line, arr, detailPropertyArr, detailProperty) {
var obj = {};
for (var i = 0; i < detailPropertyArr.length; i++) {
var o = detailProperty[detailPropertyArr[i]];
//空但是要求非空
2022-01-04 08:33:10 +00:00
if (!arr[i] && o[0]) {
layuiAlert("第 " + (line + 1) + " 行的 " + o[1] + " 不允许为空");
2021-12-09 11:49:42 +00:00
return null;
}
2022-01-06 06:11:26 +00:00
//如果要求是数字类型的,进行转换
var v = arr[i];
if(o[2] === 'number' ){
v = f2(v);
2022-01-10 08:14:06 +00:00
} else if(o[2] === 'price' ){
v = f5(v);
2022-01-06 06:11:26 +00:00
}
obj[detailPropertyArr[i]]=v;
2022-01-04 08:33:10 +00:00
}
return obj;
}
function arr2ObjectVerifyCheck(line, arr, detailPropertyArr, detailProperty, s) {
var obj = {};
for (var i = 0; i < detailPropertyArr.length; i++) {
var o = detailProperty[detailPropertyArr[i]];
//空但是要求非空
if (!arr[i] && o[0]) {
layuiAlert(s + "第 " + (line + 1) + " 行的 " + o[1] + " 不允许为空");
return null;
}
obj[detailPropertyArr[i]] = arr[i];
2021-12-09 11:49:42 +00:00
}
return obj;
}
2021-11-08 06:45:41 +00:00
/**
* 收集收入明细的数据因为动态添加的行modal无法识别所以自己来收集
* @returns {Array}
*/
function collectData(className) {
2022-01-04 08:33:10 +00:00
var a = [];
2021-11-08 06:45:41 +00:00
$("." + className).each(function (t) {
a.push($(this).val());
});
return a;
}
/**
* 绑定每一行的删除事件删除当前的一行tr
*/
function bindDeleteBtn() {
$(".am-modal-line-delete").click(function () {
//删除自己对应的tr
$(this).parent().parent().remove();
2022-01-13 07:51:34 +00:00
bindNum();
2021-11-08 06:45:41 +00:00
});
}
/**
* 将页面收集到的数据转换为ajax请求的数据一维数组转换为对象数组
* @param data
* @param detailPropertyArr
2021-11-24 12:37:30 +00:00
* @param keepBlank
2021-11-08 06:45:41 +00:00
* @returns {Array}
*/
2022-01-04 08:33:10 +00:00
function convertDetail(data, detailPropertyArr, keepBlank) {
var arr = arrayToMatrix(data, detailPropertyArr.length);
2021-11-08 06:45:41 +00:00
var details = [];
2022-01-04 08:33:10 +00:00
for (var i = 0; i < arr.length; i++) {
2021-11-24 12:36:50 +00:00
var obj = arr2Object(arr[i], detailPropertyArr, keepBlank);
2022-01-04 08:33:10 +00:00
if (obj) {
2021-11-08 06:45:41 +00:00
details.push(obj);
}
}
return details;
}
2022-01-04 08:33:10 +00:00
function convertDetailVerify(data, detailProperty) {
2021-12-09 11:49:42 +00:00
var detailPropertyArr = Object.keys(detailProperty);
2022-01-04 08:33:10 +00:00
var arr = arrayToMatrix(data, detailPropertyArr.length);
2021-12-09 11:49:42 +00:00
var details = [];
2022-01-04 08:33:10 +00:00
for (var i = 0; i < arr.length; i++) {
2022-04-18 10:03:19 +00:00
if (i === arr.length - 1 && detailProperty !== BUDGET_PLAN_DETAIL) {
continue;
}
2021-12-09 11:49:42 +00:00
var obj = arr2ObjectVerify(i, arr[i], detailPropertyArr, detailProperty);
2022-01-04 08:33:10 +00:00
if (!obj) {
2021-12-09 11:49:42 +00:00
return null;
}
details.push(obj);
}
return details;
}
2021-11-08 06:45:41 +00:00
2022-01-04 08:33:10 +00:00
function convertDetailVerifyCheck(data, detailProperty, s) {
var detailPropertyArr = Object.keys(detailProperty);
var arr = arrayToMatrix(data, detailPropertyArr.length);
var details = [];
for (var i = 0; i < arr.length; i++) {
2022-04-18 10:03:19 +00:00
if (i === arr.length - 1 && s !== "项目资金计划表") {
continue;
}
2022-01-04 08:33:10 +00:00
var obj = arr2ObjectVerifyCheck(i, arr[i], detailPropertyArr, detailProperty, s);
if (!obj) {
return null;
}
details.push(obj);
}
return details;
}
function prepareAjaxData(data, detailPropertyArr, projectId, keepBlank) {
2021-11-24 12:36:50 +00:00
var details = convertDetail(data, detailPropertyArr, keepBlank);
2021-11-08 06:45:41 +00:00
return {
2022-01-04 08:33:10 +00:00
"details": details,
"projectId": projectId
2021-11-08 06:45:41 +00:00
};
}
2022-01-04 08:33:10 +00:00
function prepareAjaxDataVerify(data, detailProperty, projectId) {
2021-12-09 11:49:42 +00:00
var details = convertDetailVerify(data, detailProperty);
return {
2022-01-04 08:33:10 +00:00
"details": details,
"projectId": projectId
2021-12-09 11:49:42 +00:00
};
}
2022-01-04 08:33:10 +00:00
2021-11-08 06:45:41 +00:00
/**
* 绑定每个可改变的输入框修改后改变对应输入框的值
*/
function bindChangeableInput() {
//数量改变
$(".input-changeable-amount").change(function () {
var amount = parseInt($(this).val());
//找到对应的单价和税率
2022-01-18 10:27:55 +00:00
var price = f5($(this).parent().parent().find(".input-changeable-price").val());
2021-11-08 06:45:41 +00:00
var taxRate = f2($(this).parent().parent().find(".input-changeable-tax-rate").val());
2022-01-04 08:33:10 +00:00
console.log(amount, price, taxRate);
2021-11-08 06:45:41 +00:00
2022-01-04 08:33:10 +00:00
$(this).parent().parent().find(".input-changeable-total-tax-include").val(f2Fixed(amount * price));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount * price / (1 + taxRate / 100)));
2021-11-08 06:45:41 +00:00
});
//单价改变
$(".input-changeable-price").change(function () {
var price = f5($(this).val());
2021-11-08 06:45:41 +00:00
//找到对应的数量和税率
var amount = parseInt($(this).parent().parent().find(".input-changeable-amount").val());
var taxRate = f2($(this).parent().parent().find(".input-changeable-tax-rate").val());
2022-01-04 08:33:10 +00:00
console.log(amount, price, taxRate);
2021-11-08 06:45:41 +00:00
2022-01-04 08:33:10 +00:00
$(this).parent().parent().find(".input-changeable-total-tax-include").val(f2Fixed(amount * price));
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount * price / (1 + taxRate / 100)));
$(this).val(f5Price(price));
2022-01-07 03:23:21 +00:00
console.log("单价:" + $(this).val());
2021-11-08 06:45:41 +00:00
});
//税率改变
$(".input-changeable-tax-rate").change(function () {
var taxRate = f2($(this).val());
//找到对应的数量和单价
var amount = parseInt($(this).parent().parent().find(".input-changeable-amount").val());
2022-01-18 10:27:55 +00:00
var price = f5($(this).parent().parent().find(".input-changeable-price").val());
2022-01-04 08:33:10 +00:00
console.log(amount, price, taxRate);
2021-11-08 06:45:41 +00:00
2022-01-04 08:33:10 +00:00
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount * price / (1 + taxRate / 100)));
2021-11-08 06:45:41 +00:00
});
}
2022-01-04 08:33:10 +00:00
/**
* 每次更新数量单价和税率时更改总计中含税和不含税总金额
* @param className
* @param totalClassName
*/
function updateTotal(className, totalClassName) {
var total = 0;
//找到本列所有的
$("."+className).each(function (t) {
total += f2($(this).val());
console.log("total2: " + total);
});
$("."+totalClassName).val(f2Fixed(total));
}
/**
* 每次更新数量时更新总计中数量
* @param className
* @param totalClassName
*/
function updateAmount(className, totalClassName) {
var total = 0;
//找到本列所有的
$("."+className).each(function (t) {
console.log(className + ": " + f2($(this).val()));
total += f2($(this).val());
});
$("."+totalClassName).val(total);
}
2022-01-13 07:33:01 +00:00
/**
* 绑定序号
*/
function bindNum() {
$(".input-budget-num").each(function(t) {
var prevIndex = $(this).parent().parent().prev("tr").find(".input-budget-num").val();
$(this).val(f2(prevIndex) + 1);
});
}
/**
* 校验项目贡献利润率必须大于阀值
* 低于阀值就返回提示信息否则返回""
*/
function verifyProjectContributionProfitRate() {
2021-11-17 09:28:55 +00:00
var projectContributionProfitRate = f2(inputVal("projectContributionProfitRate"));
var projectContributionProfitRateThreshold = f2($("#projectContributionProfitRateThreshold").val());
2022-01-04 08:33:10 +00:00
if (projectContributionProfitRate < projectContributionProfitRateThreshold) {
return "项目贡献利润率[" + projectContributionProfitRate + "]低于阀值[" + projectContributionProfitRateThreshold + "],请调整后重新提交";
}
return "";
}
2021-11-05 10:33:13 +00:00
/**
* 更新
* 毛利=收入总计不含税-成本总计不含税-财务费用总计不含税
* 毛利率=毛利不含税/收入总计不含税
* 贡献利润=项目毛利不含税-公司管理费用总计不含税
* 贡献利润率=贡献利润不含税/收入总计不含税
*/
function updateProjectContributionProfitRate() {
//收入总计不含税
2021-11-17 09:28:55 +00:00
var incomeTotalTaxExclude = f2(inputVal("incomeTotalTaxExclude"));
2021-11-05 10:33:13 +00:00
//成本总计不含税
2021-11-17 09:28:55 +00:00
var costTotalTaxExclude = f2(inputVal("costTotalTaxExclude"));
2021-11-05 10:33:13 +00:00
//资金使用成本不含税
2021-11-17 09:28:55 +00:00
var costExpropriationTaxExclude = f2(inputVal("costExpropriationTaxExclude"));
2021-11-05 10:33:13 +00:00
//公司管理费用
2021-11-17 09:28:55 +00:00
var costCompanyManageTaxExclude = f2(inputVal("costCompanyManageTaxExclude"));
2021-11-05 10:33:13 +00:00
2022-01-04 08:33:10 +00:00
var projectGrossProfit = f2Fixed(incomeTotalTaxExclude - costTotalTaxExclude - costExpropriationTaxExclude);
2022-01-10 08:14:06 +00:00
var projectGrossProfitRate = f2Fixed(rate(f2(projectGrossProfit), incomeTotalTaxExclude));
var projectContributionProfit = f2Fixed(f2(projectGrossProfit) - costCompanyManageTaxExclude);
var projectContributionProfitRate = f2Fixed(rate(f2(projectContributionProfit), incomeTotalTaxExclude));
2021-11-05 10:33:13 +00:00
$("input[name='projectGrossProfit']").val(projectGrossProfit);
$("input[name='projectGrossProfitRate']").val(projectGrossProfitRate);
$("input[name='projectContributionProfit']").val(projectContributionProfit);
$("input[name='projectContributionProfitRate']").val(projectContributionProfitRate);
}
/**
* 更新页面收入的数据累加
*/
function updateCostDataIfUnsubmit(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 += f2(t["totalTaxInclude"]);
deviceTaxExclude += f2(t["totalTaxExclude"]);
}else if(t["type"] == "2"){
//施工类
buildTaxInclude += f2(t["totalTaxInclude"]);
buildTaxExclude += f2(t["totalTaxExclude"]);
}else if(t["type"] == "3"){
//服务类
serviceTaxInclude += f2(t["totalTaxInclude"]);
serviceTaxExclude += f2(t["totalTaxExclude"]);
}else if(t["type"] == "4"){
//其他类
otherTaxInclude += f2(t["totalTaxInclude"]);
otherTaxExclude += f2(t["totalTaxExclude"]);
}
});
$("input[name='costPurchaseDeviceTaxInclude']").val(f2Fixed(deviceTaxInclude));
$("input[name='costPurchaseDeviceTaxExclude']").val(f2Fixed(deviceTaxExclude));
$("input[name='costPurchaseBuildTaxInclude']").val(f2Fixed(buildTaxInclude));
$("input[name='costPurchaseBuildTaxExclude']").val(f2Fixed(buildTaxExclude));
$("input[name='costPurchaseServiceTaxInclude']").val(f2Fixed(serviceTaxInclude));
$("input[name='costPurchaseServiceTaxExclude']").val(f2Fixed(serviceTaxExclude));
$("input[name='costPurchaseOtherTaxInclude']").val(f2Fixed(otherTaxInclude));
$("input[name='costPurchaseOtherTaxExclude']").val(f2Fixed(otherTaxExclude));
//资金计划表中的
$(".input-total-title-device-cost-budget-plan").val(f2Fixed(deviceTaxInclude));
$(".input-total-title-engineer-cost-budget-plan").val(f2Fixed(f2(serviceTaxInclude)+f2(buildTaxInclude)+f2(otherTaxInclude)));
$(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude)
+f2($(".input-total-title-project-manage-cost-budget-plan").val())
+f2($(".input-total-title-earnest-money-cost-budget-plan").val())));
calCostExclude();
calCostInclude();
updateProjectContributionProfitRate();
}
/**
* 更新页面收入的数据累加
*/
function updateIncomeDataUnsubmit(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(f2Fixed(deviceTaxInclude));
$("input[name='incomeDeviceTaxExclude']").val(f2Fixed(deviceTaxExclude));
$("input[name='incomeEngineerTaxInclude']").val(f2Fixed(engineerTaxInclude));
$("input[name='incomeEngineerTaxExclude']").val(f2Fixed(engineerTaxExclude));
$("input[name='incomeServiceTaxInclude']").val(f2Fixed(serviceTaxInclude));
$("input[name='incomeServiceTaxExclude']").val(f2Fixed(serviceTaxExclude));
$("input[name='incomeTotalTaxInclude']").val(f2Fixed(deviceTaxInclude+engineerTaxInclude+serviceTaxInclude));
$("input[name='incomeTotalTaxExclude']").val(f2Fixed(deviceTaxExclude+engineerTaxExclude+serviceTaxExclude));
$(".input-total-title-sale-income-budget-plan").val($("input[name='incomeTotalTaxInclude']").val());
$(".input-total-title-total-income-budget-plan").val(f2Fixed(f2($("input[name='incomeTotalTaxInclude']").val())
+f2($(".input-total-title-earnest-money-income-budget-plan").val())));
updateProjectContributionProfitRate();
}
/**
* 更新页面收入的数据累加
*/
function updateCostProjectManageDataUnsubmit(details) {
var total = 0;
details.forEach(function (t, number, ts) {
total += f2(t["total"]);
});
total = f2(total);
$("input[name='costProjectManageTaxExclude']").val(f2Fixed(total));
$("input[name='costProjectManageTaxInclude']").val(f2Fixed(total));
//资金计划表中的
$(".input-total-title-project-manage-cost-budget-plan").val(f2Fixed(total));
var deviceTaxExclude = $("input[name='costPurchaseDeviceTaxExclude']").val();
var buildTaxExclude = $("input[name='costPurchaseBuildTaxExclude']").val();
var serviceTaxExclude = $("input[name='costPurchaseServiceTaxExclude']").val();
var otherTaxExclude = $("input[name='costPurchaseOtherTaxExclude']").val();
var deviceTaxInclude = $("input[name='costPurchaseDeviceTaxInclude']").val();
var buildTaxInclude = $("input[name='costPurchaseBuildTaxInclude']").val();
var serviceTaxInclude = $("input[name='costPurchaseServiceTaxInclude']").val();
var otherTaxInclude = $("input[name='costPurchaseOtherTaxInclude']").val();
$(".input-total-title-total-cost-budget-plan").val(f2Fixed(f2(deviceTaxInclude)+f2(buildTaxInclude)+f2(serviceTaxInclude)+f2(otherTaxInclude)
+total
+f2($(".input-total-title-earnest-money-cost-budget-plan").val())));
calCostExclude();
calCostInclude();
updateProjectContributionProfitRate();
}
/**
* 更新页面收入的数据
*/
function updateBudgetPlanDetailDataUnsubmit(data,returnData) {
//var details = data.details;
//主页面上的财务费用
$("input[name='costExpropriationTaxExclude']").val($(".input-underwritten-plan-statistic-capital-interest-budget-plan").val());
//更新项目贡献率
updateProjectContributionProfitRate();
//更新现金流量
updateCashFlow();
}