海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.2 KiB

4 years ago
  1. const workordertimer = setInterval(function () {
  2. $.ajax({
  3. url: '/'+window.location.pathname.split('/')[1]+'/workorder_notice',
  4. type: 'POST',
  5. data: {},
  6. dataType: 'text',
  7. success: function (res) {
  8. if (res == true) {
  9. Dcat.info("你有新的工单信息 <a href='/"+window.location.pathname.split('/')[1]+"/workorder_item' target='_blank'>[前往查看]</a>", '新消息提醒', {
  10. closeButton: true,
  11. escapeHtml: false,
  12. timeOut: 10000,
  13. extendedTimeOut: 5000,
  14. onHidden: function () {
  15. if (window.location.pathname == '/'+window.location.pathname.split('/')[1]+'/workorder_item') {
  16. location.reload()
  17. }
  18. }
  19. })
  20. }
  21. },
  22. error: function (error) {
  23. }
  24. });
  25. $.ajax({
  26. url: '/'+window.location.pathname.split('/')[1]+'/workorder_notice',
  27. type: 'POST',
  28. data: {badge: 1},
  29. dataType: 'text',
  30. success: function (res) {
  31. if (res > 0) {
  32. if ($('a[href*="workorder_item"] p .workorder_badge').length > 0) {
  33. $('a[href*="workorder_item"] p .workorder_badge').text(res);
  34. } else {
  35. $('a[href*="workorder_item"] p').append('<span class="workorder_badge" style="' +
  36. 'display: inline-block; ' +
  37. 'width: 20px; ' +
  38. 'height: 20px; ' +
  39. 'border-radius: 20px; ' +
  40. 'line-height: 20px; ' +
  41. 'text-align: center; ' +
  42. 'font-size: 12px; ' +
  43. 'background-color: red;' +
  44. 'color: white;' +
  45. '">'+res+'</span>');
  46. }
  47. if ($('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').length > 0) {
  48. $('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').text(res);
  49. } else {
  50. $('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p').append('<span class="workorder_badge" style="' +
  51. 'display: inline-block; ' +
  52. 'width: 20px; ' +
  53. 'height: 20px; ' +
  54. 'border-radius: 20px; ' +
  55. 'line-height: 20px; ' +
  56. 'text-align: center; ' +
  57. 'font-size: 12px; ' +
  58. 'background-color: red;' +
  59. 'color: white;' +
  60. '">' + res + '</span>');
  61. }
  62. }
  63. },
  64. error: function (error) {
  65. }
  66. });
  67. }, 1000);