Merge remote-tracking branch 'origin/master'
commit
b31e795c13
|
@ -1,3 +1,56 @@
|
|||
INCOME_DETAIL = {
|
||||
"type": [true, "类别"],
|
||||
"name": [true, "名称"],
|
||||
"unit": [true, "单位"],
|
||||
"amount": [true, "数量"],
|
||||
"price": [true, "单价"],
|
||||
"taxRate": [true, "税率"],
|
||||
"totalTaxInclude": [true, "含税总金额"],
|
||||
"totalTaxExclude": [true, "不含税金额"]
|
||||
};
|
||||
|
||||
COST_DETAIL={
|
||||
"type":[true,"大类"],
|
||||
"category":[true,"类别"],
|
||||
"name":[true,"名称"],
|
||||
"unit":[true,"单位"],
|
||||
"amount":[true,"数量"],
|
||||
"price":[true,"单价"],
|
||||
"taxRate":[true,"税率"],
|
||||
"totalTaxInclude":[true,"含税总金额"],
|
||||
"totalTaxExclude":[true,"不含税金额"]
|
||||
};
|
||||
|
||||
COST_PROJECT_MANAGE_DETAIL={
|
||||
"type":[true,"财务费用类别"],
|
||||
"name1":[false,"业务项目"],
|
||||
"name2":[false,"业务项目"],
|
||||
"detail":[true,"项目明细"],
|
||||
"unit":[true,"单位"],
|
||||
"amount":[true,"数量"],
|
||||
"price":[true,"单价"],
|
||||
"total":[true,"总金额"],
|
||||
"predictMethod":[false,"预估计算方法"],
|
||||
"predictWhy":[false,"预估依据"],
|
||||
"remark":[false,"备注"],
|
||||
"deletable":[true,"是否可删除"]
|
||||
};
|
||||
|
||||
BUDGET_PLAN_DETAIL={
|
||||
"month":[true,"月份"],
|
||||
"deviceCost":[true,"设备支出"],
|
||||
"engineerCost":[true,"工程支出"],
|
||||
"projectManageCost":[true,"经营性开支"],
|
||||
"earnestMoneyCost":[true,"保证金支出"],
|
||||
"totalCost":[true,"支出合计"],
|
||||
"saleIncome":[true,"销售收款"],
|
||||
"earnestMoneyIncome":[true,"保证金收款"],
|
||||
"totalIncome":[true,"收款合计"],
|
||||
"fundBalance":[true,"资金余额"],
|
||||
"capitalInterest":[true,"资金利息"],
|
||||
"underwrittenPlan":[true,"垫资计划"],
|
||||
"repaymentPlan":[true,"还款计划"]
|
||||
};
|
||||
|
||||
$(function () {
|
||||
//绑定删除按钮删除当前行
|
||||
|
@ -8,82 +61,122 @@ $(function () {
|
|||
$("#saveDraft").click(function () {
|
||||
|
||||
var dataIncome = collectData("am-modal-prompt-input-income");
|
||||
if(dataIncome.length <= 0){
|
||||
if (dataIncome.length <= 0) {
|
||||
window.confirm('请填写收入明细表');
|
||||
return;
|
||||
}
|
||||
|
||||
var dataIncomeCheck = convertDetailVerifyCheck(dataIncome, INCOME_DETAIL, "收入明细表");
|
||||
if (dataIncomeCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataCost = collectData("am-modal-prompt-input-cost");
|
||||
if(dataCost.length <= 0){
|
||||
if (dataCost.length <= 0) {
|
||||
window.confirm('请填写采购成本明细表');
|
||||
return;
|
||||
}
|
||||
|
||||
var dataCostCheck = convertDetailVerifyCheck(dataCost, COST_DETAIL, "采购成本明细表");
|
||||
if (dataCostCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataManage = collectData("am-modal-prompt-input-cost-project-manage");
|
||||
if(dataManage.length <= 0){
|
||||
if (dataManage.length <= 0) {
|
||||
window.confirm('请填写项目管理成本表');
|
||||
return;
|
||||
}
|
||||
|
||||
var dataManageCheck = convertDetailVerifyCheck(dataManage, COST_PROJECT_MANAGE_DETAIL, "项目管理成本表");
|
||||
if (dataManageCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataPlan = collectData("am-modal-prompt-input-budget-plan-detail");
|
||||
if(dataPlan.length <= 0){
|
||||
if (dataPlan.length <= 0) {
|
||||
window.confirm('请填写项目资金计划表');
|
||||
return;
|
||||
}
|
||||
|
||||
$("#saveDraft").attr('disabled',true);
|
||||
var dataPlanCheck = convertDetailVerifyCheck(dataPlan, BUDGET_PLAN_DETAIL, "项目资金计划表");
|
||||
if (dataPlanCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#saveDraft").attr('disabled', true);
|
||||
|
||||
var message = verifyProjectContributionProfitRate();
|
||||
if (message) {
|
||||
$("#saveDraft").attr('disabled',false);
|
||||
$("#saveDraft").attr('disabled', false);
|
||||
layuiAlert(message);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
console.log(message);
|
||||
|
||||
var startTime = $("#startDate").val();
|
||||
var endTime = $("#endDate").val();
|
||||
if (startTime > endTime) {
|
||||
$("#saveDraft").attr('disabled',false);
|
||||
$("#saveDraft").attr('disabled', false);
|
||||
window.confirm('开始日期应早于结束日期');
|
||||
return;
|
||||
}
|
||||
|
||||
$("#pmsForm").attr("action",base+"/project/budgetEditSave");
|
||||
$("#pmsForm").attr("action", base + "/project/budgetEditSave");
|
||||
$("#pmsForm").submit();
|
||||
$("#saveDraft").attr('disabled',false);
|
||||
$("#saveDraft").attr('disabled', false);
|
||||
});
|
||||
$("#saveApprove").click(function () {
|
||||
|
||||
var dataIncome = collectData("am-modal-prompt-input-income");
|
||||
if(dataIncome.length <= 0){
|
||||
if (dataIncome.length <= 0) {
|
||||
window.confirm('请填写收入明细表');
|
||||
return;
|
||||
}
|
||||
|
||||
var dataIncomeCheck = convertDetailVerifyCheck(dataIncome, INCOME_DETAIL, "收入明细表");
|
||||
if (dataIncomeCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataCost = collectData("am-modal-prompt-input-cost");
|
||||
if(dataCost.length <= 0){
|
||||
if (dataCost.length <= 0) {
|
||||
window.confirm('请填写采购成本明细表');
|
||||
return;
|
||||
}
|
||||
|
||||
var dataCostCheck = convertDetailVerifyCheck(dataCost, COST_DETAIL, "采购成本明细表");
|
||||
if (dataCostCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataManage = collectData("am-modal-prompt-input-cost-project-manage");
|
||||
if(dataManage.length <= 0){
|
||||
if (dataManage.length <= 0) {
|
||||
window.confirm('请填写项目管理成本表');
|
||||
return;
|
||||
}
|
||||
|
||||
var dataManageCheck = convertDetailVerifyCheck(dataManage, COST_PROJECT_MANAGE_DETAIL, "项目管理成本表");
|
||||
if (dataManageCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dataPlan = collectData("am-modal-prompt-input-budget-plan-detail");
|
||||
if(dataPlan.length <= 0){
|
||||
if (dataPlan.length <= 0) {
|
||||
window.confirm('请填写项目资金计划表');
|
||||
return;
|
||||
}
|
||||
|
||||
$("#saveApprove").attr('disabled',true);
|
||||
var dataPlanCheck = convertDetailVerifyCheck(dataPlan, BUDGET_PLAN_DETAIL, "项目资金计划表");
|
||||
if (dataPlanCheck == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#saveApprove").attr('disabled', true);
|
||||
|
||||
var message = verifyProjectContributionProfitRate();
|
||||
if (message) {
|
||||
$("#saveApprove").attr('disabled',false);
|
||||
$("#saveApprove").attr('disabled', false);
|
||||
layuiAlert(message);
|
||||
return;
|
||||
}
|
||||
|
@ -91,14 +184,14 @@ $(function () {
|
|||
var startTime = $("#startDate").val();
|
||||
var endTime = $("#endDate").val();
|
||||
if (startTime > endTime) {
|
||||
$("#saveApprove").attr('disabled',false);
|
||||
$("#saveApprove").attr('disabled', false);
|
||||
window.confirm('开始日期应早于结束日期');
|
||||
return;
|
||||
}
|
||||
|
||||
$("#pmsForm").attr("action",base+"/project/budgetEditSaveAndApprove");
|
||||
$("#pmsForm").attr("action", base + "/project/budgetEditSaveAndApprove");
|
||||
$("#pmsForm").submit();
|
||||
$("#saveApprove").attr('disabled',false);
|
||||
$("#saveApprove").attr('disabled', false);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -133,23 +226,38 @@ function arrayToMatrix(list, elementsPerSubArray) {
|
|||
function arr2Object(arr, mapArr, keepBlank) {
|
||||
var obj = {};
|
||||
for (var i = 0; i < mapArr.length; i++) {
|
||||
if(!arr[i] && !keepBlank){
|
||||
if (!arr[i] && !keepBlank) {
|
||||
return null;
|
||||
}
|
||||
obj[mapArr[i]]=arr[i];
|
||||
obj[mapArr[i]] = arr[i];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function arr2ObjectVerify(line, arr, detailPropertyArr, detailProperty) {
|
||||
var obj = {};
|
||||
for (var i = 0; i < detailPropertyArr.length; i++) {
|
||||
var o = detailProperty[detailPropertyArr[i]];
|
||||
//空但是要求非空
|
||||
if(!arr[i] && o[0]){
|
||||
layuiAlert("第 "+(line+1)+" 行的 "+o[1]+" 不允许为空");
|
||||
if (!arr[i] && o[0]) {
|
||||
layuiAlert("第 " + (line + 1) + " 行的 " + o[1] + " 不允许为空");
|
||||
return null;
|
||||
}
|
||||
obj[detailPropertyArr[i]]=arr[i];
|
||||
obj[detailPropertyArr[i]] = arr[i];
|
||||
}
|
||||
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];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
@ -160,7 +268,7 @@ function arr2ObjectVerify(line, arr, detailPropertyArr, detailProperty) {
|
|||
* @returns {Array}
|
||||
*/
|
||||
function collectData(className) {
|
||||
var a= [];
|
||||
var a = [];
|
||||
$("." + className).each(function (t) {
|
||||
console.log("收集:" + className + "," + $(this).val())
|
||||
a.push($(this).val());
|
||||
|
@ -185,26 +293,27 @@ function bindDeleteBtn() {
|
|||
* @param keepBlank
|
||||
* @returns {Array}
|
||||
*/
|
||||
function convertDetail(data,detailPropertyArr, keepBlank) {
|
||||
var arr = arrayToMatrix(data,detailPropertyArr.length);
|
||||
function convertDetail(data, detailPropertyArr, keepBlank) {
|
||||
var arr = arrayToMatrix(data, detailPropertyArr.length);
|
||||
|
||||
var details = [];
|
||||
for (var i=0;i<arr.length;i++){
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var obj = arr2Object(arr[i], detailPropertyArr, keepBlank);
|
||||
if(obj){
|
||||
if (obj) {
|
||||
details.push(obj);
|
||||
}
|
||||
|
||||
}
|
||||
return details;
|
||||
}
|
||||
function convertDetailVerify(data,detailProperty) {
|
||||
|
||||
function convertDetailVerify(data, detailProperty) {
|
||||
var detailPropertyArr = Object.keys(detailProperty);
|
||||
var arr = arrayToMatrix(data,detailPropertyArr.length);
|
||||
var arr = arrayToMatrix(data, detailPropertyArr.length);
|
||||
var details = [];
|
||||
for (var i=0;i<arr.length;i++){
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var obj = arr2ObjectVerify(i, arr[i], detailPropertyArr, detailProperty);
|
||||
if(!obj){
|
||||
if (!obj) {
|
||||
return null;
|
||||
}
|
||||
details.push(obj);
|
||||
|
@ -213,20 +322,37 @@ function convertDetailVerify(data,detailProperty) {
|
|||
return details;
|
||||
}
|
||||
|
||||
function prepareAjaxData(data,detailPropertyArr,projectId, keepBlank){
|
||||
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++) {
|
||||
var obj = arr2ObjectVerifyCheck(i, arr[i], detailPropertyArr, detailProperty, s);
|
||||
if (!obj) {
|
||||
return null;
|
||||
}
|
||||
details.push(obj);
|
||||
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
function prepareAjaxData(data, detailPropertyArr, projectId, keepBlank) {
|
||||
var details = convertDetail(data, detailPropertyArr, keepBlank);
|
||||
return {
|
||||
"details":details,
|
||||
"projectId":projectId
|
||||
"details": details,
|
||||
"projectId": projectId
|
||||
};
|
||||
}
|
||||
function prepareAjaxDataVerify(data,detailProperty,projectId){
|
||||
|
||||
function prepareAjaxDataVerify(data, detailProperty, projectId) {
|
||||
var details = convertDetailVerify(data, detailProperty);
|
||||
return {
|
||||
"details":details,
|
||||
"projectId":projectId
|
||||
"details": details,
|
||||
"projectId": projectId
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定每个可改变的输入框,修改后改变对应输入框的值
|
||||
*/
|
||||
|
@ -237,10 +363,10 @@ function bindChangeableInput() {
|
|||
//找到对应的单价和税率
|
||||
var price = f2($(this).parent().parent().find(".input-changeable-price").val());
|
||||
var taxRate = f2($(this).parent().parent().find(".input-changeable-tax-rate").val());
|
||||
console.log(amount,price,taxRate);
|
||||
console.log(amount, price, taxRate);
|
||||
|
||||
$(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).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)));
|
||||
});
|
||||
//单价改变
|
||||
$(".input-changeable-price").change(function () {
|
||||
|
@ -248,10 +374,10 @@ function bindChangeableInput() {
|
|||
//找到对应的数量和税率
|
||||
var amount = parseInt($(this).parent().parent().find(".input-changeable-amount").val());
|
||||
var taxRate = f2($(this).parent().parent().find(".input-changeable-tax-rate").val());
|
||||
console.log(amount,price,taxRate);
|
||||
console.log(amount, price, taxRate);
|
||||
|
||||
$(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).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)));
|
||||
});
|
||||
//税率改变
|
||||
$(".input-changeable-tax-rate").change(function () {
|
||||
|
@ -259,11 +385,12 @@ function bindChangeableInput() {
|
|||
//找到对应的数量和单价
|
||||
var amount = parseInt($(this).parent().parent().find(".input-changeable-amount").val());
|
||||
var price = f2($(this).parent().parent().find(".input-changeable-price").val());
|
||||
console.log(amount,price,taxRate);
|
||||
console.log(amount, price, taxRate);
|
||||
|
||||
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount*price/(1+taxRate/100)));
|
||||
$(this).parent().parent().find(".input-changeable-total-tax-exclude").val(f2Fixed(amount * price / (1 + taxRate / 100)));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验项目贡献利润率必须大于阀值
|
||||
* 低于阀值就返回提示信息,否则返回""
|
||||
|
@ -271,8 +398,8 @@ function bindChangeableInput() {
|
|||
function verifyProjectContributionProfitRate() {
|
||||
var projectContributionProfitRate = f2(inputVal("projectContributionProfitRate"));
|
||||
var projectContributionProfitRateThreshold = f2($("#projectContributionProfitRateThreshold").val());
|
||||
if(projectContributionProfitRate<projectContributionProfitRateThreshold){
|
||||
return "项目贡献利润率["+projectContributionProfitRate+"]低于阀值["+projectContributionProfitRateThreshold+"],请调整后重新提交";
|
||||
if (projectContributionProfitRate < projectContributionProfitRateThreshold) {
|
||||
return "项目贡献利润率[" + projectContributionProfitRate + "]低于阀值[" + projectContributionProfitRateThreshold + "],请调整后重新提交";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
@ -295,9 +422,9 @@ function updateProjectContributionProfitRate() {
|
|||
//公司管理费用
|
||||
var costCompanyManageTaxExclude = f2(inputVal("costCompanyManageTaxExclude"));
|
||||
|
||||
var projectGrossProfit = f2Fixed(incomeTotalTaxExclude-costTotalTaxExclude-costExpropriationTaxExclude);
|
||||
var projectGrossProfit = f2Fixed(incomeTotalTaxExclude - costTotalTaxExclude - costExpropriationTaxExclude);
|
||||
var projectGrossProfitRate = f2Fixed(rate(projectGrossProfit, incomeTotalTaxExclude));
|
||||
var projectContributionProfit = f2Fixed(projectGrossProfit-costCompanyManageTaxExclude);
|
||||
var projectContributionProfit = f2Fixed(projectGrossProfit - costCompanyManageTaxExclude);
|
||||
var projectContributionProfitRate = f2Fixed(rate(projectContributionProfit, incomeTotalTaxExclude));
|
||||
|
||||
$("input[name='projectGrossProfit']").val(projectGrossProfit);
|
||||
|
|
Loading…
Reference in New Issue