contract_edit_modal.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. $(function () {
  2. $("#form-contract-edit").validate({
  3. onkeyup: false,
  4. focusCleanup: true,
  5. success: "valid",
  6. submitHandler: function (form) {
  7. if($(".type:checked").length==0){
  8. errorMessage("至少选择一个模块");
  9. return false;
  10. }
  11. $(form).ajaxSubmit({
  12. type: 'put',
  13. url: pagePath+"/build/contract/updateContractModal/" + $("#contract_id").val(),
  14. dataType: "json",
  15. success: function (data) {
  16. if (data.status) {
  17. succeedMessage(data.message);
  18. setTimeClose();
  19. } else {
  20. errorMessage(data.message);
  21. }
  22. }
  23. });
  24. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  25. },
  26. errorPlacement: function (error, element) {
  27. if (element.attr('name') == 'buildLives[0].use_area' || element.attr('name') == 'buildLives[0].pay' ||
  28. element.attr('name') == 'buildLives[0].build_number' || element.attr('name') == 'buildLives[0].floor'
  29. ) {
  30. error.addClass('label_error')
  31. }
  32. if (element.attr('name') == 'contractWaterList[0].name' || element.attr('name') == 'contractWaterList[0].start_water_meter_count') {
  33. error.addClass('label_error')
  34. }
  35. if (element.attr('name') == 'paid_tenancy' || element.attr('name') == 'paid_tenancy_month') {
  36. error.addClass('label_error')
  37. }
  38. if (element.attr('name') == 'contractElectrics[0].name' || element.attr('name') == 'contractElectrics[0].start_electric_meter_count') {
  39. error.addClass('label_error')
  40. }
  41. if (element.attr('name') == 'contractProperties[0].price' || element.attr('name') == 'contractProperties[0].number' ||
  42. element.attr('name') == 'contractProperties[0].payment_cycle'
  43. ) {
  44. error.addClass('label_error')
  45. }
  46. if (element.attr('name') == 'contractParkings[0].price' || element.attr('name') == 'contractParkings[0].number' ||
  47. element.attr('name') == 'contractParkings[0].payment_cycle'
  48. ) {
  49. error.addClass('label_error')
  50. }
  51. error.appendTo(element.parent());
  52. }
  53. });
  54. });
  55. function contract_dialog(title, url, w, h) {
  56. layer_show(title, pagePath+url, w, h);
  57. }