apply_edit.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. $(function () {
  2. $("#form-projectApplication-edit").validate({
  3. rules: {
  4. "companyInfo.company_name": {
  5. required: true
  6. },
  7. "companyInfo.industry_code": {
  8. required: true
  9. },
  10. "companyInfo.registration_address": {
  11. required: true
  12. },
  13. "companyInfo.currency_unit": {
  14. required: true
  15. },
  16. "companyInfo.registration_capital": {
  17. required: true,
  18. min: 0,
  19. max: 999999999.9999,
  20. isFloat: true,
  21. isFloat4Fn: true
  22. },
  23. "companyInfo.legal_representative": {
  24. required: true
  25. },
  26. "companyInfo.contact": {
  27. required: true
  28. },
  29. "companyInfo.lr_position": {
  30. required: true
  31. },
  32. "companyInfo.contact_position": {
  33. required: true
  34. },
  35. "companyInfo.lr_phone": {
  36. required: true,
  37. isTel: true
  38. },
  39. "companyInfo.contact_phone": {
  40. required: true,
  41. isTel: true
  42. },
  43. "companyInfo.total_assets_currency_unit": {
  44. required: true
  45. },
  46. "companyInfo.total_assets": {
  47. required: true,
  48. min: 0,
  49. max: 999999999.999999,
  50. isFloat: true,
  51. isFloat6Fn: true
  52. },
  53. "companyInfo.fixed_assets_currency_unit": {
  54. required: true
  55. },
  56. "companyInfo.fixed_assets": {
  57. required: true,
  58. min: 0,
  59. max: 999999999.999999,
  60. isFloat: true,
  61. isFloat6Fn: true
  62. },
  63. "project_type": {
  64. required: true
  65. }
  66. },
  67. messages: {},
  68. onkeyup: false,
  69. focusCleanup: true,
  70. success: "valid"
  71. });
  72. });
  73. function submit() {
  74. if (!($("#isDraft").val() == 1)) {
  75. if ($("#form-projectApplication-edit").valid()) {
  76. var valid = true;
  77. /*$("#applyMaterials").find(".uploadFileName").each(function(){
  78. if($(this).val()==""){
  79. errorMessage('请上传所有申报材料!');
  80. valid = false;
  81. }
  82. });*/
  83. if (!valid) {
  84. return false;
  85. }
  86. if($("#fileListPre").find("a[id='fileName']").length == 0){
  87. console.log($("#fileListPre").find("input[id='fileName']").length == 0);
  88. if (!checkFile()) {
  89. return false;
  90. }
  91. }
  92. } else {
  93. return false;
  94. }
  95. }
  96. //提交
  97. $("#form-projectApplication-edit").ajaxSubmit({
  98. type: 'post',
  99. url: pagePath + "/company/projectIntelligent/save",
  100. dataType: "json",
  101. success: function (data) {
  102. if (data.success) {
  103. layer.open({
  104. title: '提示!'
  105. , content: data.message
  106. , btn: ['确定']
  107. , yes: function (index, layero) {
  108. layer.close(index);
  109. var index = parent.layer.getFrameIndex(window.name);
  110. if (index) {
  111. parent.location.reload();
  112. parent.layer.close(index);
  113. } else {
  114. // window.location.href = pagePath + "/home/informList/69";
  115. history.back(-2);
  116. }
  117. }
  118. , cancel: function () {
  119. var index = parent.layer.getFrameIndex(window.name);
  120. if (index) {
  121. parent.location.reload();
  122. parent.layer.close(index);
  123. } else {
  124. // window.location.href = pagePath + "/home/informList/69";
  125. history.back(-2);
  126. }
  127. return true;
  128. }
  129. });
  130. } else {
  131. // $(form).find(":submit").attr("disabled", false);
  132. errorMessage(data.message);
  133. }
  134. },
  135. error: function () {
  136. errorMessage('系统错误!');
  137. }
  138. });
  139. return false;
  140. }
  141. //弹出框
  142. function open_dialog(title, url, w, h) {
  143. layer_show(title, pagePath + url, w, h);
  144. }
  145. //添加文件
  146. function addFile(title, url, w, h) {
  147. layer_show(title, pagePath + url, w, h);
  148. }
  149. //添加相应name的文件
  150. function addFileByName(url, obj) {
  151. var name = $(obj).next().attr("name");
  152. url += "?fileIdName=" + name;
  153. layer_show('添加文件', pagePath + url, 800, 350);
  154. }
  155. function checkFile() {
  156. if ($("#fileListPre").find("input[name='fileDown.file_id']").length == 0) {
  157. errorMessage('请上传附件!');
  158. return false;
  159. } else {
  160. var file_name = $("#fileListPre").find(".info").text();
  161. var file_id = $("#fileListPre").find("input[name='fileDown.file_id']").val();
  162. console.log(file_name);
  163. console.log(file_id);
  164. if ($.trim(file_name) == "" || $.trim(file_id) == "") {
  165. errorMessage('文件未上传完成!');
  166. return false;
  167. }
  168. }
  169. return true;
  170. }