apply_edit.js 5.9 KB

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