Нет описания

addOverTime.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * 超时计划添加
  3. * */
  4. $(function() {
  5. $('#ot_plancycle').find('input[name="plancycleRadios"]').on('change',function(){
  6. console.log($(this).val());
  7. //超时任务周期:5.小时,6.分钟
  8. switch ($(this).val()){
  9. case '5':
  10. $('.ot_planinterval1').show();
  11. $('.ot_planinterval2').hide();
  12. // $('.ot_planinterval3').hide();
  13. break;
  14. case '6':
  15. $('.ot_planinterval1').hide();
  16. $('.ot_planinterval2').show();
  17. // $('.ot_planinterval3').hide();
  18. break;
  19. // case '6':
  20. // $('.ot_planinterval1').hide();
  21. // $('.ot_planinterval2').hide();
  22. // $('.ot_planinterval3').show();
  23. // break;
  24. default:
  25. break;
  26. }
  27. });
  28. $('#ot_plancycle').find('input[name="plancycleRadios"]:checked').trigger('change');
  29. laydate.render({
  30. elem: '#ot_planinterval_h',
  31. type: 'time',
  32. theme: '#249fea',
  33. value: '0小时',
  34. format: 'H小时'
  35. });
  36. laydate.render({
  37. elem: '#ot_planinterval_m',
  38. type: 'time',
  39. theme: '#249fea',
  40. value: '0分钟',
  41. format: 'm分钟'
  42. });
  43. laydate.render({
  44. elem: '#ot_planinterval_s',
  45. type: 'time',
  46. theme: '#249fea',
  47. value: '0秒',
  48. format: 's秒'
  49. });
  50. //添加编辑保存按钮点击
  51. $('#pro_save').on('click', saveOverTimeOrder);
  52. });
  53. //保存
  54. function saveOverTimeOrder() {
  55. var ot_plancycle = $('#ot_plancycle').find('input[name="plancycleRadios"]:checked').val();//超时任务周期
  56. var ot_planinterval = 0;//计划间隔数
  57. switch (ot_plancycle){
  58. //4.小时,5.分钟,6.秒
  59. case '5':
  60. ot_planinterval = $('#ot_planinterval_h').val().split('小时')[0] - 0
  61. break;
  62. case '6':
  63. ot_planinterval = $('#ot_planinterval_m').val().split('分钟')[0] - 0
  64. break;
  65. // case '6':
  66. // ot_planinterval = $('#ot_planinterval_s').val().split('秒')[0] - 0
  67. // break;
  68. default:
  69. break;
  70. }
  71. var loadIndex;
  72. $.ajax({
  73. type: 'post',
  74. url: huayi.config.callcenter_url + "distributionapi/api/HangfirePlanTimeing/addautoassign",
  75. dataType: 'json',
  76. async: true,
  77. beforeSend: function() { //触发ajax请求开始时执行
  78. $('#pro_save').attr("disabled", true);
  79. $('#pro_save').text('保存中...');
  80. loadIndex = layer.load();
  81. },
  82. data: {
  83. // wotype: $('#ot_wotype').find('input[name="wotypeRadios"]:checked').val(), // 是 int 工单类型 1.报修,2.保养,3.巡检
  84. plancycle: ot_plancycle, // 是 int 超时任务周期:4.小时,5.分钟,6.秒
  85. planinterval: ot_planinterval, // 是 int 计划间隔秒数(0-59)
  86. },
  87. success: function(data) {
  88. layer.close(loadIndex);
  89. if(data.state == "success") {
  90. var index = parent.layer.getFrameIndex(window.name);
  91. parent.layer.close(index);
  92. // parent.$('#table1').bootstrapTable('refresh');
  93. parent.layer.msg("保存成功");
  94. } else {
  95. $('#pro_save').attr("disabled", false);
  96. $('#pro_save').text('保存');
  97. }
  98. },
  99. error: function(textStatus) {
  100. layer.close(loadIndex);
  101. layer.confirm('网络繁忙,请稍后再试...', {
  102. closeBtn: 0,
  103. btn: ['确定'] //按钮
  104. });
  105. $('#pro_save').attr("disabled", false);
  106. $('#pro_save').text('保存');
  107. },
  108. complete: function(XMLHttpRequest, textStatus) {
  109. layer.close(loadIndex);
  110. if(textStatus == 'timeout') {
  111. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  112. xmlhttp.abort();
  113. layer.confirm('网络超时,请稍后再试...', {
  114. closeBtn: 0,
  115. btn: ['确定'] //按钮
  116. });    
  117. }
  118. $('#pro_save').attr("disabled", false);
  119. $('#pro_save').text('保存');
  120. },
  121. });
  122. }