const workordertimer = setInterval(function () { $.ajax({ url: '/'+window.location.pathname.split('/')[1]+'/workorder_notice', type: 'POST', data: {}, dataType: 'text', success: function (res) { if (res == true) { Dcat.info("你有新的工单信息 [前往查看]", '新消息提醒', { closeButton: true, escapeHtml: false, timeOut: 10000, extendedTimeOut: 5000, onHidden: function () { if (window.location.pathname == '/'+window.location.pathname.split('/')[1]+'/workorder_item') { location.reload() } } }) } }, error: function (error) { } }); $.ajax({ url: '/'+window.location.pathname.split('/')[1]+'/workorder_notice', type: 'POST', data: {badge: 1}, dataType: 'text', success: function (res) { if (res > 0) { if ($('a[href*="workorder_item"] p .workorder_badge').length > 0) { $('a[href*="workorder_item"] p .workorder_badge').text(res); } else { $('a[href*="workorder_item"] p').append(''+res+''); } if ($('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').length > 0) { $('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p .workorder_badge').text(res); } else { $('a[href*="workorder_item"]').parent().parent().parent(':not(.menu-open)').find('a[href="#"] p').append('' + res + ''); } } }, error: function (error) { } }); }, 1000);