register.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. * 处理注册界面的一些逻辑
  3. * 包括切换选项卡、错误信息提示、更新确认信息、提交用户信息等
  4. * 例如,要切换到选项卡2,调用toggleTo(2)即可;提交用户所有注册信息到后台,调用register()即可
  5. * @author yingp
  6. */
  7. $(function(){
  8. /**
  9. * 将form信息序列化
  10. */
  11. $.fn.serializeForm = function(o) {
  12. var a = this.serializeArray();
  13. $.each(a, function() {
  14. if (o[this.name]) {
  15. if (!o[this.name].push) {
  16. o[this.name] = [ o[this.name] ];
  17. }
  18. o[this.name].push(this.value || '');
  19. } else {
  20. o[this.name] = this.value || '';
  21. }
  22. });
  23. return o;
  24. };
  25. });
  26. /**
  27. * 切换选项卡
  28. * @param img 切换到的id
  29. */
  30. function toggleTo(img){
  31. if($(".up").attr("id") == "tab1"){//如果当前tab是tab1
  32. if(!checkTab1()){//判断tab1信息填写是否正确
  33. return;
  34. }
  35. } else if($(".up").attr("id") == "tab2"){//如果当前tab是tab2
  36. if(!checkTab2()){//判断tab2信息填写是否正确
  37. return;
  38. }
  39. }
  40. $.each($("div[id*='oDIV']"),function(i){//改变tab选项卡样式
  41. if(this.id == "oDIV"+img){
  42. $(this).css("display","");
  43. $(this).parent().removeClass();
  44. $(this).parent().addClass("up");
  45. } else {
  46. $(this).css("display","none");
  47. $(this).parent().removeClass();
  48. $(this).parent().addClass("tab"+(i+1));
  49. }
  50. });
  51. if(img == 4){
  52. updateTab4();//更新tab4信息
  53. }
  54. }
  55. /**
  56. * 判断该企业名称是否已存在
  57. */
  58. function checkName(){
  59. $.ajax({
  60. type : 'POST',
  61. contentType : 'application/json',
  62. url: "http://localhost:8080/ERP/system/checkEnName.action",
  63. data: {en_Name:$("#en_Name").val()},
  64. success: function(data){
  65. if(data.success){
  66. $("#en_Name_err").html("<font color=blue>*您输入的企业名称可以使用!</font>");
  67. }else{
  68. $("#en_Name_err").html("<font color=red>*您输入的企业名称已存在!</font>");
  69. $("#en_Name").focus();
  70. }
  71. }
  72. });
  73. }
  74. /**
  75. * 提交注册信息
  76. */
  77. function register(){
  78. //先判断信息填写是否完全
  79. if(!checkTab1()){//判断tab1信息填写是否正确
  80. toggleTo(1);
  81. return;
  82. } else if(!checkTab2()){//判断tab2信息填写是否正确
  83. toggleTo(2);
  84. return;
  85. } else {
  86. var o = new Object($("#form1").serializeForm({}));//序列化form1数据
  87. o = $("#form2").serializeForm(o);//序列化form2数据
  88. $.ajax({
  89. type : 'POST',
  90. contentType : 'application/json',
  91. url: "system/register.action",
  92. data: $.toJSON(o),
  93. success: function(data){
  94. if(data.success){
  95. document.location.href = 'login.jsp';
  96. }else{
  97. }
  98. }
  99. });
  100. }
  101. }
  102. /**
  103. * 判断tab1信息填写是否正确
  104. * @returns true 信息已完善
  105. */
  106. function checkTab1(){
  107. var bool = true;
  108. if($("#en_Name").val() == ''){
  109. $("#en_Name_err").html("<font color=red>*企业名称不能为空!</font>");
  110. bool = false;
  111. } else {
  112. $("#en_Name_err").html("&nbsp;*请输入企业在工商局注册时使用的名称");
  113. }
  114. if($("#en_Corporation").val() == ''){
  115. $("#en_Corporation_err").html("<font color=red>*公司法人不能为空!</font>");
  116. bool = false;
  117. } else {
  118. $("#en_Corporation_err").html("*请输入企业在工商局注册时的法人");
  119. }
  120. if($("#en_Businesscode").val() == ''){
  121. $("#en_Businesscode_err").html("<font color=red>*商业登记证号不能为空!</font>");
  122. bool = false;
  123. } else {
  124. $("#en_Businesscode_err").html("*请输入企业在工商局注册时得到的编号");
  125. }
  126. return bool;
  127. }
  128. /**
  129. * 判断tab2信息填写是否正确
  130. * @returns true 信息已完善
  131. */
  132. function checkTab2(){
  133. var bool = true;
  134. if($("#en_Admin").val() == ''){
  135. $("#en_Admin_err").html("<font color=red>*管理员名不能为空!</font>");
  136. bool = false;
  137. } else {
  138. $("#en_Admin_err").html("&nbsp;*管理员联系资料非常重要,请认真填写");
  139. }
  140. if($("#en_Adminphone").val() == ''){
  141. $("#en_Adminphone_err").html("<font color=red>*管理员电话不能为空!</font>");
  142. bool = false;
  143. } else {
  144. $("#en_Adminphone_err").html("&nbsp;*请输入管理员移动电话号");
  145. }
  146. if($("#en_Email").val() == ''){
  147. $("#en_Email_err").html("<font color=red>*管理员邮箱不能为空!</font>");
  148. bool = false;
  149. } else {
  150. $("#en_Email_err").html("&nbsp;*请输入正确邮箱格式");
  151. }
  152. return bool;
  153. }
  154. /**
  155. * 修改tab4信息
  156. *
  157. */
  158. function updateTab4(){
  159. $("#en_Name_td").text($("#en_Name").val());
  160. $("#en_Shortname_td").text($("#en_Shortname").val());
  161. $("#en_Name_En_td").text($("#en_Name_En").val());
  162. $("#en_Type_td").text($("#en_Type").val());
  163. $("#en_Corporation_td").text($("#en_Corporation").val());
  164. $("#en_Businesscode_td").text($("#en_Businesscode").val());
  165. $("#en_Tel_td").text($("#en_Tel").val());
  166. $("#en_Fax_td").text($("#en_Fax").val());
  167. $("#en_Deliveraddr_td").text($("#en_Deliveraddr").val());
  168. $("#en_Address_td").text($("#en_Address").val());
  169. $("#en_Registercapital_td").text($("#en_Registercapital").val());
  170. $("#en_Url_td").text($("#en_Url").val());
  171. $("#en_Taxcode_td").text($("#en_Taxcode").val());
  172. $("#en_Time_td").text($("#en_Time").val());
  173. $("#en_Admin_td").text($("#en_Admin").val());
  174. $("#en_Adminphone_td").text($("#en_Adminphone").val());
  175. $("#en_Email_td").text($("#en_Email").val());
  176. $("#en_Attachment_td").text($("#en_Attachment").val());
  177. }