| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- var flag = true;
- function submitUserForm(){//保存
- //alert("保存!");
- // if(!checkUserName())return;
- var saveobject = window.document.theForm ;
- /*if(!flag){
- return;
- }*/
- if(saveobject == null || saveobject == ""){
- addError("当前没有用户需要保存!");
- return;
- }
- if(window.document.theForm.userName.value.replace(/(^\s*)|(\s*$)/g, "") == ''){
- addFieldError("userName","请输入用户名!");
- return;
- }
-
- // if((window.document.theForm.userName.value.length <4)){
- // addFieldError("userName","至少4位的用户名!");
- // return;
- // }
-
- var reg = /^[0-9]\w+$/;
- if(reg.test(window.document.theForm.userName.value)){
- addFieldError("userName","用户名为非数字开头的字母和数字组合!");
- return;
- }
-
- if(window.document.theForm.position != null){
- if (window.document.theForm.position.value == '') {
- addFieldError("position","请选择职位!");
- return;
- }
- }
- /*if(window.document.theForm.birthday != null){
- if (window.document.theForm.birthday.value == '') {
- addFieldError("birtherror","请选择生日!");
- return;
- }
- } */
- if(window.document.theForm.desktop_phone.value.replace(/(^\s*)|(\s*$)/g, "") == ''){
-
- } else {
- var reg = /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/;
- if(!reg.test(window.document.theForm.desktop_phone.value)){
- addFieldError("desktop_phone","请输入合法的工作电话!");
- return;
- }
- }
- if(window.document.theForm.fax.value != ''){
- var reg = /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/;
- if(!reg.test(window.document.theForm.fax.value)){
- addFieldError("fax","请输入合法的传真号码!");
- return;
- }
- }
-
- //if(window.document.theForm.email.value.replace(/(^\s*)|(\s*$)/g, "") == ''){
- //addFieldError("email","请输入电子邮箱!");
- //return;
- //}else
- if(window.document.theForm.email.value.replace(/(^\s*)|(\s*$)/g, "") != ''){
- var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ ;
- if(!reg.test(window.document.theForm.email.value)){
- addFieldError("email","请输入合法的电子邮箱!");
- return;
- }
- }
- if(window.document.theForm.qqnum.value != ''){
- var reg = /^[1-9]\d{4,10}$/;
- if(!reg.test(window.document.theForm.qqnum.value)){
- addFieldError("qqnum","请输入合法的QQ号码!");
- return;
- }
- }
- if(window.document.theForm.msnnum.value != ''){
- var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
- if(!reg.test(window.document.theForm.msnnum.value)){
- addFieldError("msnnum","请输入合法的MSN号码!");
- return;
- }
- }
- if(window.document.theForm.address.value != ''){
- if( window.document.theForm.address.value.length>100){
- addFieldError("address","请输入100位以内的地址!");
- return;
- }
- }
- if(window.document.theForm.homeno.value != ''){
- var reg = /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/;
- if(!reg.test(window.document.theForm.homeno.value)){
- addFieldError("homeno","请输入合法的电话号码!");
- return;
- }
- }
-
- var phone = $("#contact_tel1").val();
- var phone1 = $("#fixed_phone").val();
- if(phone == phone1&&phone){
- addFieldError("fixed_phone","两个手机号相同!");
- return;
- }
-
- if ($("#recMsg").attr("checked")){
- $("#recMsg").val("1");
- }else{
- $("#recMsg").val("0");
- }
- if ($("#recSms").attr("checked")){
- $("#recSms").val("1");
- }else{
- $("#recSms").val("0");
- }
- if ($("#recMail").attr("checked")){
- $("#recMail").val("1");
- }else{
- $("#recMail").val("0");
- }
- if(!validateDept()){
- return;
- }
- if(!checkUserName()){
- return;
- }
- if(!checkPhone('contact_tel1')){
- return;
- }
- if(!checkPhone('fixed_phone')){
- return;
- }
- if(!validateFace()){
- return;
- }
- // if(!checkAttendanceId()){
- // return;
- // }
- var isFollow = $("input[name='isFollow']:checked").parent().parent();
- var isLogin = $("input[name='isdLogin']:checked").parent().parent();
- var seleceFollowValue = $("[name='othergroupid']",isFollow).val();
- if(!seleceFollowValue&&isAdmin=='0'){
- addFieldError($(isFollow).attr("id"),"请设定主岗部门!");
- return;
- }
- var seleceFollowPosition = $("[name='otherposname']",isFollow).val();
- var seleceLoginValue = $("[name='othergroupid']",isLogin).val();
- var seleceLoginPosition = $("[name='otherposname']",isLogin).val();
- $("input[name='isFollow']:checked").val(seleceFollowValue+"_"+seleceFollowPosition);
- $("input[name='isdLogin']:checked").val(seleceLoginValue+"_"+seleceLoginPosition);
- if(window.checkmobile("contact_tel1")&&window.checkpixed_phone("fixed_phone")){
- var defaultRole = $("#defaultRole").val();
- if(defaultRole==''){
- yrConfirm("系统没有默认角色,新建用户没有任何权限,是否继续?",backValidate);
- }
- else{
- window.document.theForm.submit();
- }
- }
- }
- function getUserName(){
- var name = $("#name").val();
- name = codefans_net_CC2PY(name);
- if($("#userName").attr('type')!='hidden'){
- $("#userName").val(name);
- }
- }
- function checkUserNameProcess(data){
- if(data != null && data !=""){
- addFieldErrors("userName","该用户名已存在!");
- flag=false ;
- }else{
- flag=true;
- }
- }
- function checkUserName(){
- clearSingelMsg("userName");
- var initname = $("#initUserName").val();
- var url = "checkMessage.do?date="+new Date()+"&action=checkUserName";
- if (theForm.userName.value != initname) {
- var param = {'name':$("#userName").val()};
- sendAjaxParam(param,url,"text",checkUserNameProcess);
- }else{
- flag=true;
- }
- return flag;
- }
- var obj;
- function checkPhoneProcess(data){
- if(data != null && data !=""){
- addFieldErrors(obj,"该手机号已被使用!");
- flag=false ;
- }else{
- flag=true;
- }
- }
- function checkPhone(id){
- clearSingelMsg(id);
- obj = id;
- var vPhone = $("#"+id).val();
- var userId = $("#userId").val();
- if(!vPhone){
- return flag;
- }
- var url = "checkMessage.do?date="+new Date()+"&action=checkPhone";
- var param = {'userId':userId,'phone':vPhone};
- sendAjaxParam(param,url,"text",checkPhoneProcess);
- return flag;
- }
- function backValidate(r){
- if(r==true){
- window.document.theForm.submit();
- }
- }
- function validateDept(){
- var temp = "";
- var b = true;
- $(".formselect").each(function(){
- var deptId = $(this).val();
- var posId = $(this).next().val();
- var id = $(this).parent().attr("id");
- var r = deptId+"_"+posId;
- if(r!="_"){
- if(temp =="")temp = r;
- else if(temp.indexOf(r)!=-1){
- addFieldError(id,"该部门职位已经选择!");
- b = false;
- }else{
- temp += ","+r;
- }
- }
- });
- return b;
- }
- function checkmobile(formname){
- var mobile=document.getElementById(formname).value;
- if(mobile.length!=0){
- if(mobile.length!=11)
- {
- addFieldError("contact_tel1","请输入合法的手机号码!");
- document.getElementById(formname).focus();
- return false;
- }
- var myreg = /^1[1-9][0-9]\d{8}$/
- if(!myreg.test(mobile)){
- addFieldError("contact_tel1","请输入合法的手机号码!");
- document.getElementById(formname).focus();
- return false;
- }
- }
- return true;
- }
- function checkpixed_phone(formname){
- var pixed_phone=document.getElementById(formname).value;
- if(pixed_phone.length!=0){
- var myreg = /(^\d{3}\-\d{7,8}$)|(^\d{4}\-\d{7,8}$)|(^\d{3}\d{7,8}$)|(^\d{4}\d{7,8}$)|(^\d{7,8}$)/;
- if(!myreg.test(pixed_phone)){
- addFieldError("fixed_phone","请输入合法的电话号码!");
- document.getElementById(formname).focus();
- return false;
- }
- }
- return true;
- }
- function bindDept(){
- $(".add a").bind("click",function(){
- var o = $(this).parent().parent();
- addOtherDept(o);
- });
- $(".del a").bind("click",function(){
- delOtherDept(this);
- });
- }
- function bindFace(){
- $(".addFace a").bind("click",function(){
- var o = $(this).parent().parent();
- addOtherFace(o);
- });
- $(".delFace a").bind("click",function(){
- delOtherDept(this);
- });
- }
- function addOtherDept(o){
- var deptPosition = $(".dept-position").clone();
- var len = $(".dept-position-remove").length+1;
- $(".error_msg",deptPosition).remove();
- $(deptPosition).addClass("dept-position-remove");
- $(deptPosition).removeClass("inputError");
- $(deptPosition).attr("id","dept-position"+len);
- $("#name_0",deptPosition).attr("id","name_"+len);
- $("#gid_0",deptPosition).attr("id","gid_"+len);
- $("select",deptPosition).each(function(){
- $(this).get(0).options[0].selected = true;
- });
- $(deptPosition).removeClass("dept-position");
- $(".add a",deptPosition).html("删除");
- $(".add a",deptPosition).unbind("click");
- $(".add a",deptPosition).bind("click",function(){
- delOtherDept(this);
- });
- $(".add",deptPosition).removeClass("add");
- $(".add",deptPosition).addClass("del");
- $("[name='isFollow']",deptPosition).attr("checked",false);
- $("[name='isdLogin']",deptPosition).attr("checked",false);
- $(o).parent().append(deptPosition);
- }
- function addOtherFace(o){
- var facePosition = $(".face-position").clone();
- var len = $(".face-position-remove").length+1;
- $(".error_msg",facePosition).remove();
- $(facePosition).addClass("face-position-remove");
- $(facePosition).removeClass("inputError");
- $(facePosition).attr("id","face-position"+len);
- $("#name_0",facePosition).attr("id","name_"+len);
- $("#gid_0",facePosition).attr("id","gid_"+len);
- $("input[type='text']", facePosition).val('');
- $("select",facePosition).each(function(){
- $(this).get(0).options[0].selected = true;
- });
- $(facePosition).removeClass("face-position");
- $(".addFace a",facePosition).html("删除");
- $(".addFace a",facePosition).unbind("click");
- $(".addFace a",facePosition).bind("click",function(){
- delOtherDept(this);
- });
- $(".addFace",facePosition).removeClass("addFace");
- $(".addFace",facePosition).addClass("delFace");
- $(o).parent().append(facePosition);
- }
- function delOtherDept(e){
- $(e).parent().parent().remove();
- }
- function isRelacePos(e){
- var v = $(e).val();
- var posSelect = $(e).next().next();
- if(v == ''||v==undefined){
- $(posSelect).prepend("<option value='' selected='selected'>--请选择--</option>");
- $(posSelect).get(0).options[0].selected = true;
- }else{
- $("option[value='']",posSelect).remove();
- }
- }
- function addFlowDept(){
- $("select[name='othergroupid']").each(function(){
- var id = this.id;
- $(this).val(id);
- });
- }
- function checkAttendanceId(serialno, attendance_id){
- console.log("000")
- clearSingelMsg("attendance_id");
- console.log(1111)
- var userId = $("#userId").val();
- if(!attendance_id){
- return flag;
- }
- var url = "checkMessage.do?date="+new Date()+"&action=checkAttendanceId";
- var param = {'userId':userId,'attendance_id':attendance_id, 'serialno':serialno};
- sendAjaxParam(param,url,"text",checkAttendanceIdProcess);
- return flag;
- }
- function checkAttendanceIdProcess(data){
- if(data != null && data !=""){
- console.log(data,"考勤data")
- addFieldErrors("attendance_id",data);
- return flag ;
- }else{
- return flag;
- }
- }
- function validateFace(){
- var temp = "";
- var b = true;
- var userId = $("#userId").val();
- $("select[name='otherSerialno']").each(function(){
- var serialno = $(this).val();
- var attendance_id = $(this).next().val();
- var id = $(this).parent().attr("id");
- if(serialno.length > 0) {
- if(attendance_id == '') {
- addFieldError(id,"请输入考勤ID!");
- b = false;
- } else {
- var r = serialno+"_"+"attendance_id";
- if(r!="_"){
- if(temp =="") {
- temp = r;
- } else if(temp.indexOf(r)!=-1){
- addFieldError(id,"该设备已选择!");
- b = false;
- } else {
- temp += ","+r;
- }
- var url = "checkMessage.do?date="+new Date()+"&action=checkAttendanceId";
- var param = {'userId':userId,'attendance_id':attendance_id, 'serialno':serialno};
- sendAjaxParam(param,url,"text",function(data) {
- if(data != null && data !=""){
- console.log(data,"考勤data")
- addFieldError(id, data);
- b = false ;
- }
- });
- }
- }
- }
-
- });
- return b;
- }
|