apply_add.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. $(function () {
  2. $("#form-projectApplication-add").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. "super_type_name": {
  64. required: true
  65. },
  66. "category_id": {
  67. required: true
  68. },
  69. "project_id": {
  70. required: true
  71. }/*,
  72. "project_id" :{
  73. remote : {
  74. url: pagePath+"/projectApplication/canApply",
  75. type: "get",
  76. data: {
  77. name: function () {
  78. return $("#project_id").val();
  79. }
  80. }
  81. }
  82. }*/
  83. },
  84. messages: {
  85. "project_id": {
  86. remote: "已经申请过该项目(互斥类),不能重复申请"
  87. }
  88. },
  89. onkeyup: false,
  90. focusCleanup: true,
  91. success: "valid"
  92. });
  93. });
  94. function submit() {
  95. if (!($("#isDraft").val() == 1)) {
  96. if ($("#form-projectApplication-add").valid()) {
  97. if (!checkFile()) {
  98. return false;
  99. }
  100. } else {
  101. return false;
  102. }
  103. } /*else {
  104. //保存草稿
  105. var validateBaseInfo = true;
  106. if ($("#project_type").val() == "" || $("#project_id").val() == "") {
  107. errorMessage('请选择项目!');
  108. validateBaseInfo = false;
  109. }
  110. if (!validateBaseInfo) {
  111. return false;
  112. }
  113. }*/
  114. //提交
  115. $("#form-projectApplication-add").ajaxSubmit({
  116. type: 'post',
  117. url: pagePath + "/company/projectMatters/save",
  118. dataType: "json",
  119. success: function (data) {
  120. if (data.success) {
  121. layer.open({
  122. title: '提示!'
  123. , content: data.message
  124. , btn: ['确定']
  125. , yes: function (index, layero) {
  126. layer.close(index);
  127. var index = parent.layer.getFrameIndex(window.name);
  128. if (index) {
  129. parent.location.reload();
  130. parent.layer.close(index);
  131. } else {
  132. window.location.href = pagePath + "/home/informList/78";
  133. //history.back(-2);
  134. }
  135. }
  136. , cancel: function () {
  137. var index = parent.layer.getFrameIndex(window.name);
  138. if (index) {
  139. parent.location.reload();
  140. parent.layer.close(index);
  141. } else {
  142. window.location.href = pagePath + "/home/informList/78";
  143. //history.back(-2);
  144. }
  145. return true;
  146. }
  147. });
  148. } else {
  149. // $(form).find(":submit").attr("disabled", false);
  150. errorMessage(data.message);
  151. }
  152. },
  153. error: function () {
  154. errorMessage('系统错误!');
  155. }
  156. });
  157. return false;
  158. }
  159. //弹出框
  160. function open_dialog(title, url, w, h) {
  161. layer_show(title, pagePath + url, w, h);
  162. }
  163. //添加文件
  164. function addFile(title, url, w, h) {
  165. layer_show(title, pagePath + url, w, h);
  166. }
  167. //添加相应name的文件
  168. function addFileByName(url, obj) {
  169. var name = $(obj).next().attr("name");
  170. url += "?fileIdName=" + name;
  171. layer_show('添加文件', pagePath + url, 800, 350);
  172. }
  173. function checkFile() {
  174. if ($("#fileListPre").find("input[name='fileDown.file_id']").length == 0) {
  175. errorMessage('请上传附件!');
  176. return false;
  177. } else {
  178. var file_name = $("#fileListPre").find(".info").text();
  179. var file_id = $("#fileListPre").find("input[name='fileDown.file_id']").val();
  180. console.log(file_name);
  181. console.log(file_id);
  182. if ($.trim(file_name) == "" || $.trim(file_id) == "") {
  183. errorMessage('文件未上传完成!');
  184. return false;
  185. }
  186. }
  187. return true;
  188. }