Commit c24e7588 by wancheng

生产计划前端校验优化

parent c85d2d39
......@@ -121,6 +121,7 @@ public class ServiceHPSC003 extends ServiceBase {
for (int i = 0; i < eiBlock.getRowCount(); i++) {
Map<?, ?> map = eiBlock.getRow(i);
HPSC003.fromMap(map);
HPSC003.setPlanCompletionDate(DateUtils.formatShort(HPSC003.getPlanCompletionDate()));
DaoUtils.update("HPSC003.update", HPSC003.toMap());
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
......
......@@ -40,6 +40,14 @@ $(function () {
return template;
}
}],
onSave: function (e) {
// 阻止默认请求,使用自定义保存
e.preventDefault();
let btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
saveResult(btnNode);
},
onSuccess: function (e) {
if (e.eiInfo.extAttr.methodName == 'update'
|| e.eiInfo.extAttr.methodName == 'insert') {
......@@ -72,68 +80,12 @@ $(function () {
// delete: true, // 显示删除按钮
},
onSave: function (e) {
var rowCount = detailGrid.getCheckedRows();
// 检验是否选中数据
if (rowCount == null || rowCount == "") {
NotificationUtil({
msg: '请选择一条或多条数据'
}, "warning");
}
let flag = false;
for (let i = 0; i <rowCount.length; i++) {
let startT = new Date(rowCount[i].planCommentDate).getTime();
let endT = new Date(rowCount[i].planCompletionDate).getTime();
if (startT > endT) {
flag = true;
break
}
}
if (flag){
NotificationUtil({
msg: '计划结束时间不能小于计划开始时间'
}, "warning");
return false;
}
var btnNode = $(this);
// 阻止默认请求,使用自定义保存
e.preventDefault();
let btnNode = $(this);
//禁用按钮
btnNode.attr("disabled", true);
IPLAT.submitNode($("#HPSC003"), "HPSC003", "updatePlanDetail", {
onSuccess: function (ei) {
if (ei["status"] == -1) {
NotificationUtil(ei, "error");
} else {
NotificationUtil({
msg: '修改成功'
});
// 绑定grid
detailGrid.setEiInfo(ei);
resultGrid.dataSource.page(resultGrid.dataSource._page);
}
//释放禁用按钮
btnNode.attr("disabled", false);
},
onFail: function (ei) { // onFail 表示失败回调函数
// 发生异常
console.log(ei);
//释放禁用按钮
btnNode.attr("disabled", false);
}
});
},
afterEdit: function (e) {
if (e.field === "planCompletionDate") {
let startT = new Date(e.model.planCommentDate).getTime();
let endT = new Date(e.model.planCompletionDate).getTime();
if (startT > endT) {
e.preventDefault();
NotificationUtil({
msg: '计划结束时间不能小于计划开始时间'
}, "warning");
}
}
saveDetail(btnNode);
},
columns: [{
field: "operator",
......@@ -282,3 +234,76 @@ function check_time(model,rows){
}
return true;
}
/**
* 保存汇总
*/
function saveResult(btn) {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let planCompletionDate= item.get("planCompletionDate");
if(isBlank(planCompletionDate)){
message("选中的第"+(index+1)+"行\"计划结束时间\",不能为空!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPSC003", "update", true);
//释放禁用按钮
btn.attr("disabled", false);
}
});
}
}
/**
* 保存明细
*/
function saveDetail(btn) {
let rows = detailGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
let flag = true;
$.each(rows, function(index, item) {
let planCommentDate= item.get("planCommentDate");
let planCompletionDate= item.get("planCompletionDate");
if(isBlank(planCommentDate)){
message("选中的第"+(index+1)+"行\"计划开始时间\",不能为空!");
flag = false;
return false;
}
if(isBlank(planCompletionDate)){
message("选中的第"+(index+1)+"行\"计划结束时间\",不能为空!");
flag = false;
return false;
}
let startT = new Date(planCommentDate).getTime();
let endT = new Date(planCompletionDate).getTime();
if (startT > endT) {
message("选中的第"+(index+1)+"行\"计划开始时间\"不能大于\"计划结束时间\"!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("detail", "HPSC003", "updatePlanDetail", true);
//释放禁用按钮
btn.attr("disabled", false);
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment