/*************************************************************** *
ProName:EdorBZInput.js
*Title:建工险保单中止
*Description:建工险保单中止
*Copyright:Copyright (c) 2012
*Company:Sinosoft
* @author : 蔡云聪 * @version : 8.0 * @date : 2014-06-25 ****************************************************************/ var showInfo; var turnPage = new turnPageClass(); var turnPage1 = new turnPageClass(); var turnPage2 = new turnPageClass(); var mOperate = "";//操作状态 var tSQLInfo = new SqlClass(); //初始化查询 function initQueryClick(){ tSQLInfo = new SqlClass(); tSQLInfo.setResourceName("g_pos.EdorBZSql"); tSQLInfo.setModule("grp_pa"); tSQLInfo.setSqlId("EdorBZSql1"); tSQLInfo.addSubPara(tEdorAppNo); tSQLInfo.addSubPara(tEdorNo); tSQLInfo.addSubPara(tEdorType); tSQLInfo.addSubPara(tGrpContNo); var tPropEntry = easyExecSql(tSQLInfo.getString(), 1, 0, 1); if (tPropEntry==null) { return false; } else { document.all("Reason").value=tPropEntry[0][0]; document.all("ReasonName").value=tPropEntry[0][1]; document.all("ReasonDesc").value=tPropEntry[0][2]; document.all("EndDate").value=tPropEntry[0][3]; } } //保存操作 function saveClick(){ if(!verifyForm("fm")){ return false; } var tEndDate = document.all('EndDate').value; //查询保单的生效日期 tSQLInfo = new SqlClass(); tSQLInfo.setResourceName("g_pos.EdorBZSql"); tSQLInfo.setModule("grp_pa"); tSQLInfo.setSqlId("EdorBZSql7"); tSQLInfo.addSubPara(tGrpContNo); var upArrResul = easyExecSql(tSQLInfo.getString(), 1, 0, 1); var tCvailDate = ""; if(upArrResul != null){ tCvailDate = upArrResul[0][0]; if(tEndDate < tCvailDate ){ i18nAlert("输入的保全中止日期小于保单生效日期,请核实!", "LIS-13894"); return false; } } if(!isValidDateWithin365Days(tCvailDate,tEndDate)){ alert("输入的保全中止日期不能大于保单生效日+365天,请核实!"); return false; } //查询保单最近一次效力恢复日期 tSQLInfo = new SqlClass(); tSQLInfo.setResourceName("g_pos.EdorBZSql"); tSQLInfo.setModule("grp_pa"); tSQLInfo.setSqlId("EdorBZSql8"); tSQLInfo.addSubPara(tGrpContNo); var sArrResul= easyExecSql(tSQLInfo.getString(), 1, 0, 1); var tStartDate = ""; if(sArrResul != null){ tStartDate = sArrResul[0][0]; if(tEndDate < tStartDate ){ i18nAlert("本次中止日期不能在上一次中止恢复日期之前,请核实!", "LIS-BQ-0054"); return false; } } mOperate="SAVE"; fm.action="../API/grp_pa/g_pos/EdorBZSave/ADD?Operate="+ mOperate+"&EdorNo="+tEdorNo+"&EdorType="+tEdorType+"&EdorAppNo="+tEdorAppNo+"&GrpContNo="+tGrpContNo+"&MissionID="+tMissionID+"&SubMissionID="+tSubMissionID+"&ActivityID="+tActivityID; submitFunc(); ajaxSubmit2(document.getElementById("fm")); } function submitFunc(){ var showStr=i18nMessage("正在保存数据,请您稍候并且不要修改屏幕上的值或链接其他页面", "LIS-04525"); var urlStr="../common/jsp/MessagePage.jsp?picture=C&content=" + encodeURIComponent(showStr); //showInfo=window.showModelessDialog(urlStr,window,"status:no;help:0;close:0;dialogWidth:550px;dialogHeight:250px"); var name='提示'; //网页名称,可为空; var iWidth=550; //弹出窗口的宽度; var iHeight=250; //弹出窗口的高度; var iTop = (window.screen.availHeight - iHeight) / 2; //获得窗口的垂直位置 var iLeft = (window.screen.availWidth - iWidth) / 2; //获得窗口的水平位置 showInfo = window.open (urlStr,name, "status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no,height="+ iHeight+",width="+iWidth+",innerHeight="+iHeight+",innerWidth=" +iWidth+",left="+iLeft+",top="+iTop,false); showInfo.focus(); } function returnbak() { top.opener.initForm(); top.close(); } /** * 提交数据后返回操作 */ function afterSubmit(FlagStr, content) { if (typeof(showInfo)=="object" && typeof(showInfo)!="unknown") { showInfo.close(); } if (FlagStr=="Fail") { var urlStr = "../common/jsp/MessagePage.jsp?picture=C&content="+ encodeURIComponent(content); //showModalDialog(urlStr,window,"status:no;help:0;close:0;dialogWidth:550px;dialogHeight:250px"); var name='提示'; //网页名称,可为空; var iWidth=550; //弹出窗口的宽度; var iHeight=250; //弹出窗口的高度; var iTop = (window.screen.availHeight - iHeight) / 2; //获得窗口的垂直位置 var iLeft = (window.screen.availWidth - iWidth) / 2; //获得窗口的水平位置 showInfo = window.open (urlStr,name, "status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no,height="+ iHeight+",width="+iWidth+",innerHeight="+iHeight+",innerWidth=" +iWidth+",left="+iLeft+",top="+iTop,false); showInfo.focus(); } else { var urlStr = "../common/jsp/MessagePage.jsp?picture=S&content="+ encodeURIComponent(content); //showModalDialog(urlStr,window,"status:no;help:0;close:0;dialogWidth:550px;dialogHeight:250px"); var name='提示'; //网页名称,可为空; var iWidth=550; //弹出窗口的宽度; var iHeight=250; //弹出窗口的高度; var iTop = (window.screen.availHeight - iHeight) / 2; //获得窗口的垂直位置 var iLeft = (window.screen.availWidth - iWidth) / 2; //获得窗口的水平位置 showInfo = window.open (urlStr,name, "status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no,height="+ iHeight+",width="+iWidth+",innerHeight="+iHeight+",innerWidth=" +iWidth+",left="+iLeft+",top="+iTop,false); showInfo.focus(); } } /** * 校验时间是否不大于保单生效日 + 365 天 * @param {Date|string} policyStartDate - 保单生效日(Date对象或可解析的字符串) * @param {Date|string} inputDate - 待校验的日期(Date对象或可解析的字符串) * @returns {boolean} 是否满足条件(inputDate <= policyStartDate + 365天) */ function isValidDateWithin365Days(policyStartDate, inputDate) { // 转换为 Date 对象 const startDate = new Date(policyStartDate); const checkDate = new Date(inputDate); // 判断是否是有效日期 if (isNaN(startDate.getTime()) || isNaN(checkDate.getTime())) { throw new Error('Invalid date input'); } // 计算保单生效日后 365 天 const maxDate = new Date(startDate); maxDate.setDate(maxDate.getDate() + 365); // 校验日期是否超出范围 return checkDate <= maxDate; }