apply_edit.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. $(function () {
  2. $("#form-projectFilling-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. isFloat: true,
  20. isFloat4Fn: true
  21. },
  22. "companyInfo.legal_representative": {
  23. required: true
  24. },
  25. "companyInfo.contact": {
  26. required: true
  27. },
  28. "companyInfo.lr_position": {
  29. required: true
  30. },
  31. "companyInfo.contact_position": {
  32. required: true
  33. },
  34. "companyInfo.lr_phone": {
  35. required: true,
  36. isTel: true
  37. },
  38. "companyInfo.contact_phone": {
  39. required: true,
  40. isTel: true
  41. },
  42. "companyInfo.total_assets_currency_unit": {
  43. required: true
  44. },
  45. "companyInfo.total_assets": {
  46. required: true,
  47. min: 0,
  48. isFloat: true,
  49. isFloat4Fn: true
  50. },
  51. "companyInfo.fixed_assets_currency_unit": {
  52. required: true
  53. },
  54. "companyInfo.fixed_assets": {
  55. required: true,
  56. min: 0,
  57. isFloat: true,
  58. isFloat4Fn: true
  59. }
  60. },
  61. messages: {},
  62. onkeyup: false,
  63. focusCleanup: true,
  64. success: "valid"
  65. });
  66. });
  67. function submit() {
  68. //保存提交
  69. if (!($("#isDraft").val() == 1)) {
  70. if (!$("#form-projectFilling-edit").valid()) {
  71. return false;
  72. }
  73. if($("#fileListPre").find("a[id='fileName']").length == 0){
  74. console.log($("#fileListPre").find("input[id='fileName']").length == 0);
  75. if (!checkFile()) {
  76. return false;
  77. }
  78. }
  79. }
  80. //提交
  81. $("#form-projectFilling-edit").ajaxSubmit({
  82. type: 'post',
  83. url: pagePath + "/company/projectFilling/save",
  84. dataType: "json",
  85. success: function (data) {
  86. if (data.success) {
  87. layer.open({
  88. title: '提示!'
  89. , content: data.message
  90. , btn: ['确定']
  91. , yes: function (index, layero) {
  92. layer.close(index);
  93. var index = parent.layer.getFrameIndex(window.name);
  94. if (index) {
  95. parent.location.reload();
  96. parent.layer.close(index);
  97. } else {
  98. window.location.href = pagePath + "/home/informList/77";
  99. //history.back(-2);
  100. }
  101. }
  102. , cancel: function () {
  103. var index = parent.layer.getFrameIndex(window.name);
  104. if (index) {
  105. parent.location.reload();
  106. parent.layer.close(index);
  107. } else {
  108. window.location.href = pagePath + "/home/informList/77";
  109. //history.back(-2);
  110. }
  111. return true;
  112. }
  113. });
  114. } else {
  115. // $(form).find(":submit").attr("disabled", false);
  116. errorMessage(data.message);
  117. }
  118. },
  119. error: function () {
  120. errorMessage('系统错误!');
  121. }
  122. });
  123. return false;
  124. }
  125. function checkFile() {
  126. if ($("#fileListPre").find("input[name='fileDown.file_id']").length == 0) {
  127. errorMessage('请上传附件!');
  128. return false;
  129. } else {
  130. var file_name = $("#fileListPre").find(".info").text();
  131. var file_id = $("#fileListPre").find("input[name='fileDown.file_id']").val();
  132. console.log(file_name);
  133. console.log(file_id);
  134. if ($.trim(file_name) == "" || $.trim(file_id) == "") {
  135. errorMessage('文件未上传完成!');
  136. return false;
  137. }
  138. }
  139. return true;
  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. }