companyReport_add.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. $(function () {
  2. $("#form-companyReport-add").validate({
  3. rules: {
  4. report_year: {
  5. required: true,
  6. remote: {
  7. url: pagePath+"/government/companyReport/isExistReportMonth",
  8. type: "get",
  9. data: {
  10. report_year: function () {
  11. return $("#report_year").val();
  12. },
  13. report_month: function () {
  14. return $("#report_month").val();
  15. },
  16. timestamp: new Date().getTime()
  17. }
  18. }
  19. },
  20. report_month:{
  21. required: true,
  22. remote: {
  23. url: pagePath+"/government/companyReport/isExistReportMonth",
  24. type: "get",
  25. data: {
  26. report_year: function () {
  27. return $("#report_year").val();
  28. },
  29. report_month: function () {
  30. return $("#report_month").val();
  31. },
  32. timestamp: new Date().getTime()
  33. }
  34. }
  35. },
  36. revenue: {
  37. isFloat2:true,
  38. required: true,
  39. maxlength:12
  40. },
  41. cost: {
  42. isFloat2:true,
  43. required: true,
  44. maxlength:12
  45. },
  46. account: {
  47. isFloat2:true,
  48. required: true,
  49. maxlength:12
  50. },
  51. taxs: {
  52. isFloat2:true,
  53. required: true,
  54. maxlength:12
  55. },
  56. employees: {
  57. required: true,
  58. isInteger:true,
  59. maxlength:12
  60. },
  61. profits: {
  62. isFloat2:true,
  63. required: true,
  64. maxlength:12
  65. },
  66. electricity: {
  67. isFloat2:true,
  68. required: true,
  69. maxlength:12
  70. },
  71. wages: {
  72. isFloat4:true,
  73. required: true,
  74. maxlength:12
  75. },
  76. assets: {
  77. isFloat4:true,
  78. required: true,
  79. maxlength:12
  80. },
  81. debt: {
  82. isFloat4:true,
  83. required: true,
  84. maxlength:12
  85. }
  86. },
  87. messages: {
  88. report_year: {
  89. remote: "该月份数据已经上报!"
  90. },
  91. report_month: {
  92. remote: "该月份数据已经上报!"
  93. }
  94. },
  95. onkeyup: false,
  96. focusCleanup: true,
  97. success: "valid",
  98. submitHandler: function (form) {
  99. $(form).ajaxSubmit({
  100. type: 'post',
  101. url: pagePath+"/government/companyReport/save",
  102. dataType: "json",
  103. success: function (data) {
  104. if (data.success) {
  105. succeedMessage(data.message);
  106. setTimeClose();
  107. } else {
  108. errorMessage(data.message);
  109. }
  110. }
  111. });
  112. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  113. }
  114. });
  115. });