apply_add.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. $(function () {
  2. $("#form-landApply-add").validate({
  3. rules: {
  4. company_name: {
  5. required : true
  6. },
  7. "companyInfo.industry_code" :{
  8. required : true
  9. },
  10. "companyInfo.registration_address" :{
  11. required : true
  12. },
  13. "companyInfo.contact" :{
  14. required : true
  15. },
  16. "companyInfo.contact_phone" :{
  17. required : true,
  18. isTel : true
  19. }
  20. },
  21. messages: {
  22. },
  23. onkeyup: false,
  24. focusCleanup: true,
  25. success: "valid"
  26. /*submitHandler: function (form) {
  27. // $(form).find(":submit").attr("disabled", true);
  28. if(!($("#isDraft").val()==1)){
  29. var validateFile = true;
  30. $("#applyMaterials").find(".uploadFileName").each(function(){
  31. if($(this).val()==""){
  32. errorMessage('请上传所有基准材料!');
  33. validateFile = false;
  34. }
  35. });
  36. if(validateFile){
  37. if($("#summaryProcedureType").find("input:checked").length>0){
  38. //简易程序材料必填
  39. $("#summaryMaterials").find(".uploadFileName").each(function(){
  40. if($(this).val()==""){
  41. errorMessage('请上传所有简易程序相关材料!');
  42. validateFile = false;
  43. }
  44. });
  45. }
  46. }
  47. if(validateFile){
  48. if($("#otherMaterials").find(".td_material").length>1){
  49. //已经添加材料,不能有空行
  50. $("#otherMaterials").find(".uploadFileName").each(function(){
  51. if($(this).val()==""){
  52. errorMessage('请上传所有其他材料!');
  53. validateFile = false;
  54. }
  55. });
  56. }
  57. }
  58. if(!validateFile){
  59. return false;
  60. }
  61. }
  62. setDocName();
  63. $(form).ajaxSubmit({
  64. type: 'post',
  65. url: pagePath + "/stockLand/applySave",
  66. dataType: "json",
  67. success: function (data) {
  68. if (data.success) {
  69. succeedMessage(data.message);
  70. setTimeClose();
  71. } else {
  72. // $(form).find(":submit").attr("disabled", false);
  73. errorMessage(data.message);
  74. }
  75. },
  76. error: function () {
  77. errorMessage('系统错误!');
  78. }
  79. });
  80. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  81. }*/
  82. });
  83. });
  84. //弹出框
  85. function open_dialog(title, url, w, h) {
  86. var index = layer_show(title, pagePath + url, w, h);
  87. layer.full(index);
  88. }
  89. //添加文件
  90. function addFile(title,url,w,h,obj){
  91. var fileName = $(obj).val();
  92. if(fileName!=""){
  93. errorMessage('请先点击右侧按钮删除文件,再重新添加!');
  94. }else{
  95. layer_show(title,pagePath+url,w,h);
  96. }
  97. }
  98. //添加相应name的文件
  99. function addFileByName(url,obj){
  100. var name = $(obj).next().attr("name");
  101. url += "?fileIdName="+name;
  102. layer_show('添加文件',pagePath+url,800,350);
  103. }
  104. function changeType(obj){
  105. var type = $(obj).val();
  106. var url = pagePath+"/stockLand/add/"+type;
  107. url += "?companyId=" + $("#companyId").val();
  108. url += "&companyName=" + encodeURI($("#company_name").val());
  109. location.replace(url);
  110. }
  111. function save(isDraft){
  112. $("#isDraft").val(isDraft);
  113. // $(form).find(":submit").attr("disabled", true);
  114. if(!($("#isDraft").val()==1)){
  115. if(!$("#form-landApply-add").valid()){
  116. return false;
  117. }
  118. var validateFile = true;
  119. $("#applyMaterials").find(".uploadFileName").each(function(){
  120. if($(this).val()==""){
  121. errorMessage('请上传所有基准材料!');
  122. validateFile = false;
  123. }
  124. });
  125. if(validateFile){
  126. if($("#summaryProcedureType").find("input:checked").length>0){
  127. //简易程序材料必填
  128. $("#summaryMaterials").find(".uploadFileName").each(function(){
  129. if($(this).val()==""){
  130. errorMessage('请上传所有简易程序相关材料!');
  131. validateFile = false;
  132. }
  133. });
  134. }
  135. }
  136. if(validateFile){
  137. if($("#otherMaterials").find(".td_material").length>1){
  138. //已经添加材料,不能有空行
  139. $("#otherMaterials").find(".uploadFileName").each(function(){
  140. if($(this).val()==""){
  141. errorMessage('请上传所有其他材料!');
  142. validateFile = false;
  143. }
  144. });
  145. }
  146. }
  147. if(!validateFile){
  148. return false;
  149. }
  150. }
  151. setDocName();
  152. $("#form-landApply-add").ajaxSubmit({
  153. type: 'post',
  154. url: pagePath + "/stockLand/applySave",
  155. dataType: "json",
  156. success: function (data) {
  157. if (data.success) {
  158. succeedMessage(data.message);
  159. setTimeClose();
  160. } else {
  161. // $(form).find(":submit").attr("disabled", false);
  162. errorMessage(data.message);
  163. }
  164. },
  165. error: function () {
  166. errorMessage('系统错误!');
  167. }
  168. });
  169. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  170. }