apply_add.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. "project_type": {
  64. required: true
  65. },
  66. "customize_name": {
  67. required: true
  68. }/*,
  69. "project_id" :{
  70. remote : {
  71. url: pagePath+"/projectApplication/canApply",
  72. type: "get",
  73. data: {
  74. name: function () {
  75. return $("#project_id").val();
  76. }
  77. }
  78. }
  79. }*/
  80. },
  81. messages: {
  82. "project_id": {
  83. remote: "已经申请过该项目(互斥类),不能重复申请"
  84. }
  85. },
  86. onkeyup: false,
  87. focusCleanup: true,
  88. success: "valid"
  89. });
  90. });
  91. function submit() {
  92. if (!($("#isDraft").val() == 1)) {
  93. if ($("#form-projectApplication-add").valid()) {
  94. var valid = true;
  95. $("#applyMaterials").find(".uploadFileName").each(function () {
  96. if ($(this).val() == "") {
  97. errorMessage('请上传所有申报材料!');
  98. valid = false;
  99. }
  100. });
  101. if (!$("#isStatement").is(":checked")) {
  102. errorMessage('请勾选企业声明!');
  103. valid = false;
  104. }
  105. if (!valid) {
  106. return false;
  107. }
  108. } else {
  109. return false;
  110. }
  111. } else {
  112. //保存草稿
  113. var validateBaseInfo = true;
  114. if ($("#project_type").val() == "" || $("#project_id").val() == "") {
  115. errorMessage('请选择项目!');
  116. validateBaseInfo = false;
  117. }
  118. if (!validateBaseInfo) {
  119. return false;
  120. }
  121. }
  122. //提交
  123. $("#form-projectApplication-add").ajaxSubmit({
  124. type: 'post',
  125. url: pagePath + "/projectApplication/save",
  126. dataType: "json",
  127. success: function (data) {
  128. if (data.success) {
  129. layer.open({
  130. title: '提示!'
  131. , content: data.message
  132. , btn: ['确定']
  133. , yes: function (index, layero) {
  134. layer.close(index);
  135. var index = parent.layer.getFrameIndex(window.name);
  136. if (index) {
  137. parent.location.reload();
  138. parent.layer.close(index);
  139. } else {
  140. // window.location.href = pagePath + "/home/informList/69";
  141. history.back(-1);
  142. }
  143. }
  144. , cancel: function () {
  145. var index = parent.layer.getFrameIndex(window.name);
  146. if (index) {
  147. parent.location.reload();
  148. parent.layer.close(index);
  149. } else {
  150. // window.location.href = pagePath + "/home/informList/69";
  151. history.back(-1);
  152. }
  153. return true;
  154. }
  155. });
  156. } else {
  157. // $(form).find(":submit").attr("disabled", false);
  158. errorMessage(data.message);
  159. }
  160. },
  161. error: function () {
  162. errorMessage('系统错误!');
  163. }
  164. });
  165. return false;
  166. }
  167. $(function () {
  168. $.ajax({
  169. url: pagePath + "/projectApplication/hasDraft",
  170. type: "get",
  171. data: {
  172. "timestamp": new Date().getTime()
  173. },
  174. dataType: "json",
  175. success: function (result) {
  176. if (result.success) {
  177. // var projects = result.obj;
  178. layer.confirm('检测到您有未提交的草稿,是否前往查看并继续填写?', function (index) {
  179. location.href = pagePath + "/admin/home?module=C_SERVICE_MANAGE&menu=C_MYPROJECT_MANAGE"
  180. });
  181. } /*else {
  182. errorMessage(result.message);
  183. }*/
  184. },
  185. error: function () {
  186. errorMessage('系统错误!');
  187. }
  188. });
  189. })
  190. //弹出框
  191. function open_dialog(title, url, w, h) {
  192. layer_show(title, pagePath + url, w, h);
  193. }
  194. //添加文件
  195. function addFile(title, url, w, h) {
  196. layer_show(title, pagePath + url, w, h);
  197. }
  198. //添加相应name的文件
  199. function addFileByName(url, obj) {
  200. var name = $(obj).next().attr("name");
  201. url += "?fileIdName=" + name;
  202. layer_show('添加文件', pagePath + url, 800, 350);
  203. }