company_edit.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*自定义jQuery校验是9位数字和字母*/
  2. jQuery.validator.addMethod("LetterAndNum9", function (value, element) {
  3. return this.optional(element) || /^[a-zA-Z0-9]{9}$/.test(value);
  4. }, "组织结构代码由9位数字或字母组成");
  5. $(function () {
  6. $("#form-content-edit").validate({
  7. rules: {
  8. company_name: {
  9. required: true,
  10. minlength: 1,
  11. maxlength: 45,
  12. remote: {
  13. url: pagePath + "/build/company/isExist",
  14. type: "get",
  15. data: {
  16. 'company_name': function () {
  17. return $("#company_name").val();
  18. },
  19. 'id': $("#companyId").val()
  20. }
  21. }
  22. },
  23. // is_product:{
  24. // required:true,
  25. //
  26. // },
  27. // is_industry:{
  28. // required:true
  29. // },
  30. // house_number:{
  31. // required:true,
  32. // minlength:1,
  33. // maxlength:45
  34. // },
  35. remark: {
  36. minlength: 1,
  37. maxlength: 255
  38. },
  39. contact: {
  40. required: true,
  41. minlength: 1,
  42. maxlength: 45
  43. },
  44. // floor:{
  45. // required:true,
  46. // digits:true,
  47. // min:1,
  48. // minlength:1,
  49. // maxlength:45
  50. // },
  51. location: {
  52. required: true,
  53. minlength: 1,
  54. maxlength: 80,
  55. },
  56. phone: {
  57. required: true,
  58. isMobile: true,
  59. },
  60. email: {
  61. required: true,
  62. email: true,
  63. },
  64. business: {
  65. // required:true,
  66. minlength: 1,
  67. maxlength: 255
  68. },
  69. },
  70. messages: {
  71. company_name: {
  72. remote: "该公司名已存在!"
  73. }
  74. },
  75. onkeyup: false,
  76. focusCleanup: true,
  77. success: "valid",
  78. submitHandler: function (form) {
  79. $(form).ajaxSubmit({
  80. type: 'put',
  81. url: pagePath + "/build/company/updateCompany/" + $("#companyId").val(),
  82. dataType: "json",
  83. success: function (data) {
  84. if (data.success) {
  85. succeedMessage(data.message);
  86. setTimeClose();
  87. } else {
  88. errorMessage(data.message);
  89. }
  90. }
  91. });
  92. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  93. },
  94. errorPlacement: function (error, element) {
  95. if (element.attr('id') == 'business') {
  96. error.addClass(' label_error')
  97. }
  98. error.appendTo(element.parent());
  99. }
  100. });
  101. //企业编辑企业联系人信息
  102. $("#form-companyInfo-edit").validate({
  103. rules: {
  104. contact: {
  105. required: true,
  106. minlength: 1,
  107. maxlength: 45
  108. },
  109. phone: {
  110. required: true,
  111. isMobile: true,
  112. },
  113. staff_number: {
  114. // required: true,
  115. isGtZero: true
  116. },
  117. registration_capital: {
  118. min: 0,
  119. max: 999999999.9999,
  120. number: true,
  121. isFloat6Fn: $("#registration_capital").val()
  122. },
  123. organization_code: {
  124. //required: true,
  125. remote: {
  126. url: pagePath + "/company/companyInfoManage/getOrganization_code",
  127. type: "get",
  128. data: {
  129. organization_code: function () {
  130. return $("#organization_code").val();
  131. },
  132. id: $("#companyId").val()
  133. }
  134. },
  135. LetterAndNum9: $("#organization_code").val(),
  136. }
  137. },
  138. messages: {
  139. organization_code: {
  140. remote: "该组织机构代码已存在"
  141. }
  142. },
  143. onkeyup: false,
  144. focusCleanup: true,
  145. success: "valid",
  146. submitHandler: function (form) {
  147. setBuildStreetName();
  148. $(form).ajaxSubmit({
  149. type: 'put',
  150. url: pagePath + "/build/company/updateCompany/" + $("#companyId").val(),
  151. data: {
  152. timeStamp: new Date()
  153. },
  154. dataType: "json",
  155. success: function (data) {
  156. if (data.success) {
  157. succeedMessage(data.message);
  158. //location.reload();
  159. } else {
  160. errorMessage(data.message);
  161. }
  162. }
  163. });
  164. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  165. }
  166. });
  167. });