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

267 lines
9.1 KiB
Plaintext

<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><%
//获得组件参数,客户代码
String flag = CurPage.getParameter("flag");
if(flag == null)flag="";
String status = CurPage.getParameter("status");
if(status == null)status="";
String ismaincert= CurPage.getParameter("ismaincert");
if(ismaincert == null)ismaincert="";
String customerid = CurPage.getParameter("customerid");
if(customerid == null) customerid ="";
String rightType = CurPage.getParameter("rightType");
if(rightType ==null)rightType="";
String customerType = CurPage.getParameter("customerType");
if(customerType == null) customerType = "";
String id=CurPage.getParameter("id");
if(id==null) id="";
String sTempletNo = "CustomerPersonCertInfo";//--模板号--
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
/* if("".equals(id)){
if(customerType.equals("01")){
doTemp.setDDDWJbo("certtype","jbo.sys.CODE_LIBRARY,itemNo,ItemName,Codeno='CertType' and SortNo like 'Ent%' and IsInuse='1' ");
}else{
doTemp.setDDDWJbo("certtype","jbo.sys.CODE_LIBRARY,itemNo,ItemName,Codeno='CertType' and SortNo like 'Ind%' and IsInuse='1' ");
}
} */
doTemp.setDDDWJbo("certtype","jbo.sys.CODE_LIBRARY,itemNo,ItemName,Codeno='CertType' and SortNo like 'Ind%' and IsInuse='1' ");
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
if(rightType.equals("ReadOnly")){
dwTemp.ReadOnly = "1";//只读模式
}
dwTemp.genHTMLObjectWindow(id);
CurPage.getCurComp().setAttribute("RightType", rightType);
String sButtons[][] = {
{"true","All","Button","保存","保存所有修改","saveRecord()","","","",""},
{"true","","Button","返回","返回列表页面","goBack()","","","","btn_icon_return"},
};
sButtonPosition = "south";
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
/* window.onload=function(){
setItemValue(0,getRow(),"certtype","Ind01");
} */
function goBack(){
parent.AsDialog.ClosePage();
}
function saveRecord(){
if(!iV_all("0")) return;//先检查填写完整性
if(checkCertInfo(false)){
var isadd = getItemValue(0,getRow(),"isadd");
var status = getItemValue(0,getRow(),"status");//状态
var certid = getItemValue(0,getRow(),"certid");//证件类型
var certtype = getItemValue(0,getRow(),"certtype");//证件类型
var ismaincert = getItemValue(0,getRow(),"ismaincert");//主证件
var id = getItemValue(0,getRow(),"id");
//身份证号码验证
if(certtype == "Ind01" || certtype == "Ind08"){
if (isIdCardNo(certid) != "true"){
alert(getBusinessMessage('156'));//身份证号码有误!
return;
}
}
//点击保存是不允许状态为否时设置主证件
if(status == "invalid" ){
if(ismaincert == "yes"){
alert("该客户为失效状态,不允许设置为主证件");
return false;
}
}
//修改时必须保证至少有一条为有效
if('<%=flag%>' == "viewAndEdit"){
if('<%=status%>' == "valid" ){
if(status == "invalid"){
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.cert.CustomerCertController","checkStatus","id="+id+",customerid="+"<%=customerid%>");
if(sReturnInfo == "false"){
alert("该客户目前有且只有一个有效证件,不予许做失效操作");
return false;
}
}
}
}
//修改时不允许把主证件设为否
if('<%=flag%>' == "viewAndEdit"){
if('<%=ismaincert%>' == "yes" ){
if(ismaincert == "no"){
alert("该客户目前有且只有一个主证件,不允许改为否");
return false;
}
}
}
<%-- //失效只能不能为主证件
if('<%=flag%>' == "viewAndEdit"){
if(status == "invalid"){
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.cert.CustomerCertController","checkIsmaincert","id="+id+",customerid="+"<%=customerid%>");
}
} --%>
as_save("myiframe0","parent.AsDialog.ClosePage()");
}
}
function setErrorTips(colName,tips){
if(tips==""){
setItemUnit(0,getRow(),colName,"");
return ;
}
setItemUnit(0,getRow(),colName,"<font color=red>"+tips+"</font>");
}
function checkCertInfo(flag){
if(typeof(flag)=="undefined") flag=false;
var id = getItemValue(0,getRow(0),'id');
var certType = getItemValue(0,getRow(),"certtype");
var certid = getItemValue(0,getRow(),"certid");
var issuecountry = getItemValue(0,getRow(),"issuecountry");
var idexpiry = getItemValue(0,getRow(),"idexpiry");
var status = getItemValue(0,getRow(),"status ");
//判断组织机构代码合法性
if(certType =='Ent02'){
if(!checkORGRight(certid) ){
setErrorTips("certid","组织机构代码格式错误!");
return false;
}
}
if(certType =='Ent01'){
if(!isValidSocialCreditIdentifier(certid) ){
setErrorTips("certid","社会统一信用代码格式错误!");
return false;
}
}
//判断证件到期日
var idexpiry = getItemValue(0,getRow(0),'IDEXPIRY');
var s = idexpiry.split("/");
var date = new Date(s[0],s[1]-1,s[2]);
if(date.getTime() < (new Date()).getTime()){
alert("证件到期时间不正确,必须大于当前时间,请重新填写!");
return;
}
return true;
}
function selectCountryCode(){//选择国别
var sParaString = "CodeNo"+",CountryCode";
AsDialog.setObjectValue("SelectCountry",sParaString,"@issuecountry@0@issuecountryname@1",0,0,"resizable=yes;dialogWidth=560px;dialogHeight=355px;center:yes;status:no;statusbar:no",function(sReturn){
if(typeof(sReturn)!=undefined && sReturn!='' && '<%=customerType%>'=='01'){
var results = sReturn.split('@');
if(results[0]!='CHN'){
if($("#CERTTYPE option").size()==3){
$("#CERTTYPE").append("<option value='Ent03'>其他证件</option>");
}
}else{
$("#CERTTYPE option[value='Ent03']").remove();
}
}
});
}
//身份证验证
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"%>