对话框中的数据非空校验
parent
7bad5248f2
commit
f537b4d01b
|
@ -82,6 +82,19 @@ function arr2Object(arr, mapArr, keepBlank) {
|
||||||
}
|
}
|
||||||
return obj;
|
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]){
|
||||||
|
alert("第 "+(line+1)+" 行的 "+o[1]+" 不允许为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
obj[detailPropertyArr[i]]=arr[i];
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,6 +139,21 @@ function convertDetail(data,detailPropertyArr, keepBlank) {
|
||||||
}
|
}
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
function convertDetailVerify(data,detailProperty) {
|
||||||
|
var detailPropertyArr = Object.keys(detailProperty);
|
||||||
|
var arr = arrayToMatrix(data,detailPropertyArr.length);
|
||||||
|
|
||||||
|
var details = [];
|
||||||
|
for (var i=0;i<arr.length;i++){
|
||||||
|
var obj = arr2ObjectVerify(i, arr[i], detailPropertyArr, detailProperty);
|
||||||
|
if(!obj){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
details.push(obj);
|
||||||
|
|
||||||
|
}
|
||||||
|
return details;
|
||||||
|
}
|
||||||
|
|
||||||
function prepareAjaxData(data,detailPropertyArr,projectId, keepBlank){
|
function prepareAjaxData(data,detailPropertyArr,projectId, keepBlank){
|
||||||
var details = convertDetail(data, detailPropertyArr, keepBlank);
|
var details = convertDetail(data, detailPropertyArr, keepBlank);
|
||||||
|
@ -134,6 +162,13 @@ function prepareAjaxData(data,detailPropertyArr,projectId, keepBlank){
|
||||||
"projectId":projectId
|
"projectId":projectId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function prepareAjaxDataVerify(data,detailProperty,projectId){
|
||||||
|
var details = convertDetailVerify(data, detailProperty);
|
||||||
|
return {
|
||||||
|
"details":details,
|
||||||
|
"projectId":projectId
|
||||||
|
};
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 绑定每个可改变的输入框,修改后改变对应输入框的值
|
* 绑定每个可改变的输入框,修改后改变对应输入框的值
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
/**
|
/**
|
||||||
* 一个采购成本详情的字段
|
* 一个采购成本详情的字段
|
||||||
*/
|
*/
|
||||||
COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"];
|
//COST_DETAIL_ARR=["type","category","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"];
|
||||||
|
COST_DETAIL={
|
||||||
|
"type":[true,"大类"],
|
||||||
|
"category":[true,"类别"],
|
||||||
|
"name":[true,"名称"],
|
||||||
|
"unit":[true,"单位"],
|
||||||
|
"amount":[true,"数量"],
|
||||||
|
"price":[true,"单价"],
|
||||||
|
"taxRate":[true,"税率"],
|
||||||
|
"totalTaxInclude":[true,"含税总金额"],
|
||||||
|
"totalTaxExclude":[true,"不含税金额"]
|
||||||
|
};
|
||||||
/*
|
/*
|
||||||
[
|
[
|
||||||
{"id":"1","name":"xxx1"},{"id":"2","name":"xxx2"}
|
{"id":"1","name":"xxx1"},{"id":"2","name":"xxx2"}
|
||||||
|
@ -72,8 +83,11 @@ $(function () {
|
||||||
onConfirm: function(e) {
|
onConfirm: function(e) {
|
||||||
//不能使用e.data,因为无法获取动态添加的
|
//不能使用e.data,因为无法获取动态添加的
|
||||||
var data = collectData("am-modal-prompt-input-cost");
|
var data = collectData("am-modal-prompt-input-cost");
|
||||||
data = prepareAjaxData(data, COST_DETAIL_ARR, $("#id").val(),false);
|
//data = prepareAjaxData(data, COST_DETAIL_ARR, $("#id").val(),false);
|
||||||
|
data = prepareAjaxDataVerify(data, COST_DETAIL, $("#id").val());
|
||||||
|
if(data){
|
||||||
postAjax(base+"/project/budgetEditSaveCostDetail", data, updateCostData);
|
postAjax(base+"/project/budgetEditSaveCostDetail", data, updateCostData);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onCancel: function(e) {
|
onCancel: function(e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
/**
|
/**
|
||||||
* 一个项目管理成本详情的字段
|
* 一个项目管理成本详情的字段
|
||||||
*/
|
*/
|
||||||
COST_PROJECT_MANAGE_DETAIL_ARR=["type","name","detail","unit","amount","price","total","predictMethod","predictWhy","remark","deletable"];
|
//COST_PROJECT_MANAGE_DETAIL_ARR=["type","name","detail","unit","amount","price","total","predictMethod","predictWhy","remark","deletable"];
|
||||||
|
COST_PROJECT_MANAGE_DETAIL={
|
||||||
|
"type":[true,"财务费用类别"],
|
||||||
|
"name":[true,"业务项目"],
|
||||||
|
"detail":[true,"项目明细"],
|
||||||
|
"unit":[true,"单位"],
|
||||||
|
"amount":[true,"数量"],
|
||||||
|
"price":[true,"单价"],
|
||||||
|
"total":[true,"总金额"],
|
||||||
|
"predictMethod":[false,"预估计算方法"],
|
||||||
|
"predictWhy":[false,"预估依据"],
|
||||||
|
"remark":[false,"备注"],
|
||||||
|
"deletable":[true,"是否可删除"]
|
||||||
|
};
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$("#cost-project-manage-detail").click(function () {
|
$("#cost-project-manage-detail").click(function () {
|
||||||
$('#my-prompt-cost-project-manage-detail').modal({
|
$('#my-prompt-cost-project-manage-detail').modal({
|
||||||
|
@ -10,8 +24,11 @@ $(function () {
|
||||||
onConfirm: function(e) {
|
onConfirm: function(e) {
|
||||||
//不能使用e.data,因为无法获取动态添加的
|
//不能使用e.data,因为无法获取动态添加的
|
||||||
var data = collectData("am-modal-prompt-input-cost-project-manage");
|
var data = collectData("am-modal-prompt-input-cost-project-manage");
|
||||||
data = prepareAjaxData(data, COST_PROJECT_MANAGE_DETAIL_ARR, $("#id").val(),true);
|
//data = prepareAjaxData(data, COST_PROJECT_MANAGE_DETAIL_ARR, $("#id").val(),true);
|
||||||
|
data = prepareAjaxDataVerify(data, COST_PROJECT_MANAGE_DETAIL, $("#id").val());
|
||||||
|
if(data){
|
||||||
postAjax(base+"/project/budgetEditSaveCostProjectManageDetail", data, updateCostProjectManageData);
|
postAjax(base+"/project/budgetEditSaveCostProjectManageDetail", data, updateCostProjectManageData);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onCancel: function(e) {
|
onCancel: function(e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
/**
|
/**
|
||||||
* 一个收入详情的字段
|
* 一个收入详情的字段
|
||||||
*/
|
*/
|
||||||
INCOME_DETAIL_ARR=["type","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"];
|
//INCOME_DETAIL_ARR=["type","name","unit","amount","price","taxRate","totalTaxInclude","totalTaxExclude"];
|
||||||
|
INCOME_DETAIL={
|
||||||
|
"type":[true,"类别"],
|
||||||
|
"name":[true,"名称"],
|
||||||
|
"unit":[true,"单位"],
|
||||||
|
"amount":[true,"数量"],
|
||||||
|
"price":[true,"单价"],
|
||||||
|
"taxRate":[true,"税率"],
|
||||||
|
"totalTaxInclude":[true,"含税总金额"],
|
||||||
|
"totalTaxExclude":[true,"不含税金额"]
|
||||||
|
};
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$("#income-detail").click(function () {
|
$("#income-detail").click(function () {
|
||||||
|
@ -11,8 +21,11 @@ $(function () {
|
||||||
onConfirm: function(e) {
|
onConfirm: function(e) {
|
||||||
//不能使用e.data,因为无法获取动态添加的
|
//不能使用e.data,因为无法获取动态添加的
|
||||||
var data = collectData("am-modal-prompt-input-income");
|
var data = collectData("am-modal-prompt-input-income");
|
||||||
data = prepareAjaxData(data, INCOME_DETAIL_ARR, $("#id").val(),false);
|
//data = prepareAjaxData(data, INCOME_DETAIL_ARR, $("#id").val(),false);
|
||||||
|
data = prepareAjaxDataVerify(data, INCOME_DETAIL, $("#id").val());
|
||||||
|
if(data.details){
|
||||||
postAjax(base+"/project/budgetEditSaveIncomeDetail", data, updateIncomeData);
|
postAjax(base+"/project/budgetEditSaveIncomeDetail", data, updateIncomeData);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onCancel: function(e) {
|
onCancel: function(e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,23 @@
|
||||||
* 一个资金计划的字段
|
* 一个资金计划的字段
|
||||||
*/
|
*/
|
||||||
BUDGET_PLAN_DETAIL_ARR=["month","deviceCost","engineerCost","projectManageCost","earnestMoneyCost","totalCost","saleIncome","earnestMoneyIncome","totalIncome","fundBalance","capitalInterest","underwrittenPlan","repaymentPlan"];
|
BUDGET_PLAN_DETAIL_ARR=["month","deviceCost","engineerCost","projectManageCost","earnestMoneyCost","totalCost","saleIncome","earnestMoneyIncome","totalIncome","fundBalance","capitalInterest","underwrittenPlan","repaymentPlan"];
|
||||||
|
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 () {
|
$(function () {
|
||||||
$(".budget-plan-detail").click(function () {
|
$(".budget-plan-detail").click(function () {
|
||||||
$('#my-prompt-budget-plan-detail').modal({
|
$('#my-prompt-budget-plan-detail').modal({
|
||||||
|
@ -19,8 +36,11 @@ $(function () {
|
||||||
|
|
||||||
//不能使用e.data,因为无法获取动态添加的
|
//不能使用e.data,因为无法获取动态添加的
|
||||||
var data = collectData("am-modal-prompt-input-budget-plan-detail");
|
var data = collectData("am-modal-prompt-input-budget-plan-detail");
|
||||||
data = prepareAjaxData(data, BUDGET_PLAN_DETAIL_ARR, $("#id").val(),false);
|
//data = prepareAjaxData(data, BUDGET_PLAN_DETAIL_ARR, $("#id").val(),false);
|
||||||
|
data = prepareAjaxDataVerify(data, BUDGET_PLAN_DETAIL, $("#id").val());
|
||||||
|
if(data){
|
||||||
postAjax(base+"/project/budgetEditSaveBudgetPlanDetail", data, updateBudgetPlanDetailData);
|
postAjax(base+"/project/budgetEditSaveBudgetPlanDetail", data, updateBudgetPlanDetailData);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onCancel: function(e) {
|
onCancel: function(e) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue