2018-06-03 22:26:41 +08:00

346 lines
12 KiB
Plaintext

<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><%
String customer_id = CurPage.getParameter("customerId");
if(customer_id == null)customer_id="";
String flag = CurPage.getParameter("flag");
if(flag == null)flag="";
String rightType = CurPage.getParameter("rightType");
if(rightType ==null)rightType="";
String sTempletNo = "CustomerRelative";//--模板号--
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
if(rightType.equals("ReadOnly")){
dwTemp.ReadOnly = "1";//只读模式
}
dwTemp.genHTMLObjectWindow(CurPage.getParameter("id"));
CurPage.getCurComp().setAttribute("RightType", rightType);
String sButtons[][] = {
{"true","All","Button","保存","保存所有修改","saveRecord()","","","","btn_icon_save"},
{"true","All","Button","保存并新增","保存所有修改并新增","saveAndAdd()","","","","btn_icon_save"},
{"true","","Button","返回","返回列表页面","goBack()","","","","btn_icon_return"}
};
sButtonPosition = "north";
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
function newRecord(){
CHANGED=false; //跳转新页面时是否弹框提示已修改本页。
AsControl.OpenView("/Tenwa/Customer/Lessee/Comm/Relative/CustomerRelative.jsp","customerId="+"<%=customer_id%>","_self","");
}
//证件号为身份证时自动填入出生日期和性别
function certIdOnChange(){
var CERTTYPE = getItemValue(0,getRow(0),'CERTTYPE');//证件类型
var CERTID = getItemValue(0,getRow(0),'CERTID');//证件号码
//身份证号码验证
if(CERTTYPE == "Ind01" || CERTTYPE == "Ind08"){
//将身份证中的日期自动赋给出生日期,把身份证中的性别赋给性别
if(CERTID.length == 15){
sex = CERTID.substring(14);
sex = parseInt(sex);
CERTID = CERTID.substring(6,12);
CERTID = "19"+CERTID.substring(0,2)+"/"+CERTID.substring(2,4)+"/"+CERTID.substring(4,6);
setItemValue(0,getRow(),"BIRTHDAY",CERTID);
if(sex%2==0){//奇男偶女
setItemValue(0,getRow(),"SEX","2");
}else{
setItemValue(0,getRow(),"SEX","1");
}
}
if(CERTID.length == 18){
sex = CERTID.substring(16,17);
sex = parseInt(sex);
CERTID = CERTID.substring(6,14);
CERTID = CERTID.substring(0,4)+"/"+CERTID.substring(4,6)+"/"+CERTID.substring(6,8);
setItemValue(0,getRow(),"BIRTHDAY",CERTID);
if(sex%2==0){//奇男偶女
setItemValue(0,getRow(),"SEX","2");
}else{
setItemValue(0,getRow(),"SEX","1");
}
}
}
}
//保存
function saveRecord(){
if(!iV_all("0")) return;//先检查填写完整性
var CERTTYPE = getItemValue(0,getRow(0),'CERTTYPE');//证件类型
var id = getItemValue(0,getRow(0),'id');
var CERTID = getItemValue(0,getRow(0),'CERTID');//证件号码
var EFFECT = getItemValue(0,getRow(0),'EFFECT');//是否有效
if(EFFECT == "valid"){
//修改证件号验重
if('<%=flag%>' == "edit"){
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.relative.CustomerRelativeController","editcheckCERTID","CERTID="+CERTID+",id="+id+",customer_id="+"<%=customer_id%>");
if(sReturnInfo == "false"){
alert("证件号码重复!");
return;
}
}else{
if(id == ''){
//新增证件号码验重
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.relative.CustomerRelativeController","checkCERTID","CERTID="+CERTID+",customer_id="+"<%=customer_id%>");
if(sReturnInfo == "false"){
alert("证件号码重复!");
return;
}
}
}
}
//身份证号码验证
if(CERTTYPE == "Ind01" || CERTTYPE == "Ind08"){
if(isIdCardNo(CERTID) != "true"){
alert(getBusinessMessage('156'));//身份证号码有误!
return;
}
}
//出生日期校验
var birthday = getItemValue(0,getRow(0),'BIRTHDAY');
var s = birthday.split("/");
var date = new Date(s[0],s[1]-1,s[2]);
if(date.getFullYear() > (new Date()).getFullYear()){
alert("出生日期不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getFullYear() == (new Date()).getFullYear()){
if(date.getMonth() > (new Date()).getMonth()){
alert("出生日期不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getMonth() == (new Date()).getMonth()){
if(date.getDate() > (new Date()).getDate() || date.getDate() == (new Date()).getDate()){
alert("出生日期不正确,必须早于当前时间,请重新填写!");
return;
}
}
}
//担任该职务时间校验
var holdDate = getItemValue(0,getRow(0),'HOLDDATE');
var s = holdDate.split("/");
var date = new Date(s[0],s[1]-1,s[2]);
if(date.getFullYear() > (new Date()).getFullYear()){
alert("担任该职务时间不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getFullYear() == (new Date()).getFullYear()){
if(date.getMonth() > (new Date()).getMonth()){
alert("担任该职务时间不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getMonth() == (new Date()).getMonth()){
if(date.getDate() > (new Date()).getDate() || date.getDate() == (new Date()).getDate()){
alert("担任该职务时间不正确,必须早于当前时间,请重新填写!");
return;
}
}
}
//相关行业从业年限校验
var holdDate = getItemValue(0,getRow(0),'HOLDDATE');
var holdYear = holdDate.split("/")[0];
var engageterm = getItemValue(0,getRow(0),'ENGAGETERM');
var nowYear = new Date().getFullYear();
/* if(engageterm > nowYear - holdYear){
alert("相关行业从业年限过大,请重新调整相关行业从业年限或担任该职务时间!");
return;
} */
//验证联系电话
var TELEPHONE = getItemValue(0,getRow(),"TELEPHONE");//联系电话
if(typeof(TELEPHONE) != undefined && TELEPHONE != "" ){
if(!CheckPhoneCode(TELEPHONE)){
alert("联系电话格式错误!");
return;
}
}
as_save("myiframe0","");
}
//保存并新增
function saveAndAdd(){
if(!iV_all("0")) return;//先检查填写完整性
var CERTTYPE = getItemValue(0,getRow(0),'CERTTYPE');//证件类型
var id = getItemValue(0,getRow(0),'id');
var CERTID = getItemValue(0,getRow(0),'CERTID');//证件号码
var EFFECT = getItemValue(0,getRow(0),'EFFECT');//是否有效
if(EFFECT == "valid"){
//证件号验重
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.relative.CustomerRelativeController","editcheckCERTID","CERTID="+CERTID+",id="+id+",customer_id="+"<%=customer_id%>");
if(sReturnInfo == "false"){
alert("证件号码重复!");
return;
}
}
//身份证号码验证
if(CERTTYPE == "Ind01" || CERTTYPE == "Ind08"){
if (isIdCardNo(CERTID) != "true"){
alert(getBusinessMessage('156'));//身份证号码有误!
return;
}
}
//出生日期校验
var birthday = getItemValue(0,getRow(0),'BIRTHDAY');
var s = birthday.split("/");
var date = new Date(s[0],s[1]-1,s[2]);
if(date.getFullYear() > (new Date()).getFullYear()){
alert("出生日期不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getFullYear() == (new Date()).getFullYear()){
if(date.getMonth() > (new Date()).getMonth()){
alert("出生日期不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getMonth() == (new Date()).getMonth()){
if(date.getDate() > (new Date()).getDate() || date.getDate() == (new Date()).getDate()){
alert("出生日期不正确,必须早于当前时间,请重新填写!");
return;
}
}
}
//担任该职务时间校验
var holdDate = getItemValue(0,getRow(0),'HOLDDATE');
var s = holdDate.split("/");
var date = new Date(s[0],s[1]-1,s[2]);
if(date.getFullYear() > (new Date()).getFullYear()){
alert("担任该职务时间不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getFullYear() == (new Date()).getFullYear()){
if(date.getMonth() > (new Date()).getMonth()){
alert("担任该职务时间不正确,必须早于当前时间,请重新填写!");
return;
}else if(date.getMonth() == (new Date()).getMonth()){
if(date.getDate() > (new Date()).getDate() || date.getDate() == (new Date()).getDate()){
alert("担任该职务时间不正确,必须早于当前时间,请重新填写!");
return;
}
}
}
//相关行业从业年限校验
var holdDate = getItemValue(0,getRow(0),'HOLDDATE');
var holdYear = holdDate.split("/")[0];
var engageterm = getItemValue(0,getRow(0),'ENGAGETERM');
var nowYear = new Date().getFullYear();
/* if(engageterm > nowYear - holdYear){
alert("相关行业从业年限过大,请重新调整相关行业从业年限或担任该职务时间!");
return;
} */
//验证手机号
var TELEPHONE = getItemValue(0,getRow(),"TELEPHONE");//联系电话
if(typeof(TELEPHONE) != undefined && TELEPHONE != "" ){
if(!CheckPhoneCode(TELEPHONE)){
alert("联系电话格式错误!");
return;
}
}
as_save("myiframe0","newRecord()");
}
//返回
function goBack(){
CHANGED=false;//跳转新页面时是否弹框提示已修改本页。
var customer_id='<%=customer_id%>';
AsControl.OpenView("/Tenwa/Customer/Lessee/Comm/Relative/CustomerRelativeList.jsp","customerId="+customer_id,"_self","");
}
//身份证验证
function isIdCardNo(num) {
//权重值
var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
//校验码
var parityBit = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
//地区码省级 @todo市级地级代码也可以枚举
var provinces = {11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", //华北两市三省
21: "辽宁", 22: "吉林", 23: "黑龙江", //东北三省
31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", //华东一市六省
41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", //华南五省
50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏",//西南一市四省
61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆",//西北五省
71: "台湾",
81: "香港", 82: "澳门",
91: "国外"};
var varArray = new Array();
var intweightSum = 0;
var intCheckDigit;
var intStrLen = num.length;
var idNumber = num.toString().toUpperCase();
//基本位数判断
if ((intStrLen != 15) && (intStrLen != 18)) {
return '身份证号为18位!';
}
//省级信息 @todo 可以枚举市级 和 县级 区域的
if (provinces[parseInt(idNumber.substr(0, 2))] == null) {
return '身份证号前六位地区码有误!';
}
// 判断每一位字符,顺便计算加权值
for (i = 0; i < intStrLen; i++) {
varArray[i] = idNumber.charAt(i);
if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
return '身份证号有错误字符!';
} else if (i < 17) {
varArray[i] = varArray[i] * factorArr[i];
intweightSum = intweightSum + varArray[i];
}
}
if (intStrLen == 18) {
//生日期校验
var date8 = idNumber.substring(6, 14);
if (isDate8(date8) == false) {
return '身份证出生日期错误!';
}
// 校验码验证 余数在校验数组中的值
intCheckDigit = parityBit[intweightSum % 11];
// 最后一位和计算出的校验码是否一致
if (varArray[17] != intCheckDigit) {
return '身份证号有误,校验失败!';
}
} else {
var date6 = idNumber.substring(6, 12);
if (isDate6(date6) == false) {
return '身份证出生日期错误!';
}
}
return "true";
}
function isDate8(sDate) {
if (!/^[0-9]{8}$/.test(sDate)) {
return false;
}
var year, month, day;
year = sDate.substring(0, 4);
month = sDate.substring(4, 6);
day = sDate.substring(6, 8);
var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (year < 1900 || year > new Date().getFullYear())
return false
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
iaMonthDays[1] = 29;
if (month < 1 || month > 12)
return false
if (day < 1 || day > iaMonthDays[month - 1])
return false
return true
}
function isDate6(sDate) {
if (!/^[0-9]{6}$/.test(sDate)) {
return false;
}
var year, month, day;
year = "19"+sDate.substring(0, 2);
month = sDate.substring(2, 4);
day = sDate.substring(4, 6);
var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
iaMonthDays[1] = 29;
if (month < 1 || month > 12)
return false
if (day < 1 || day > iaMonthDays[month - 1])
return false
if (month < 1 || month > 12)
return false
return true
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>