Browse Source

菜单栏红点

develop
shuixiang 4 years ago
parent
commit
ff17ef3f2f
  1. 8
      app/AdminAgent/Controllers/WorkorderController.php
  2. 6
      app/AdminGuide/Controllers/WorkorderController.php
  3. 6
      app/AdminSupplier/Controllers/WorkorderController.php
  4. 13
      app/Service/Admin/GlobalNoticeService.php
  5. 47
      public/js/workorder-notice.js
  6. 35
      resources/views/admin/pages/workorder.blade.php

8
app/AdminAgent/Controllers/WorkorderController.php

@ -365,6 +365,12 @@ class WorkorderController extends AdminController
public function checkUnread()
{
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[0]);
if (\request('badge', '')) {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[0], true);
} else {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[0]);
}
}
}

6
app/AdminGuide/Controllers/WorkorderController.php

@ -328,6 +328,10 @@ class WorkorderController extends AdminController
public function checkUnread()
{
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[2]);
if (\request('badge', '')) {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[2], true);
} else {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[2]);
}
}
}

6
app/AdminSupplier/Controllers/WorkorderController.php

@ -330,6 +330,10 @@ class WorkorderController extends AdminController
public function checkUnread()
{
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[1]);
if (\request('badge', '')) {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[1], true);
} else {
return (new GlobalNoticeService())->unreadWOrder(DemandTraits::$col[1]);
}
}
}

13
app/Service/Admin/GlobalNoticeService.php

@ -15,21 +15,26 @@ use Illuminate\Support\Facades\DB;
*/
class GlobalNoticeService
{
public function unreadWOrder($pointType)
public function unreadWOrder($pointType, $isBadge = false)
{
$cacheNotice = Cache::get('w_order_notice', '[]');
$cacheNoticeIds = json_decode($cacheNotice, true);
$res = WorkorderItem::query()
$builder = WorkorderItem::query()
->has('workorder')
->where(function ($query) use ($pointType) {
$query->where('point_id',Admin::user()->id)
->where('point_type',$pointType);
})
->where('is_read', 0)
->whereIn('id', $cacheNoticeIds)
->pluck('id')
->whereIn('id', $cacheNoticeIds);
if ($isBadge === true) {
return $builder->count();
}
$res = $builder->pluck('id')
->toArray();
$cacheNoticeIds = array_diff($cacheNoticeIds, $res);

47
public/js/workorder-notice.js

@ -25,4 +25,49 @@ const workordertimer = setInterval(function () {
}
});
}, 5000);
$.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('<span class="workorder_badge" style="' +
'display: inline-block; ' +
'width: 20px; ' +
'height: 20px; ' +
'border-radius: 20px; ' +
'line-height: 20px; ' +
'text-align: center; ' +
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">'+res+'</span>');
}
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('<span class="workorder_badge" style="' +
'display: inline-block; ' +
'width: 20px; ' +
'height: 20px; ' +
'border-radius: 20px; ' +
'line-height: 20px; ' +
'text-align: center; ' +
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">' + res + '</span>');
}
}
},
error: function (error) {
}
});
}, 1000);

35
resources/views/admin/pages/workorder.blade.php

@ -1,20 +1,21 @@
<style>
.chat-container { padding: 20px 40px; height: calc(100vh - 160px) }
.msg-chat {
position: relative; background-color: white; padding: 40px 20px 50px 20px;
position: relative; background-color: white; padding: 40px 20px 90px 20px;
border-top-right-radius: 8px; border-bottom-right-radius: 8px; height: 100%;
}
.msg-chat-list { height: 100%; overflow-y: auto; overflow-x: hidden; padding-bottom: 20px; }
.msg-chat-list { height: 100%; overflow-y: auto; overflow-x: hidden; padding-bottom: 20px; padding-right: 20px; }
.msg-user { margin: 5px 0px; line-height: 30px; }
.msg-name { display: inline-block; font-size: 14px; font-weight: bold; padding: 0px 5px; }
.msg-avatar { display: inline-block; }
.msg-avatar img { width: 30px; height: 30px; border-radius: 50%; }
.msg-content { display: inline-block; background-color: #f4f4f4; padding: 20px; border-radius: 10px; }
.msg-content-image { max-width: 120px; max-height: 120px; }
.msg-send { position: absolute; bottom: 0; left: 0; z-index: 999; height: 50px; }
.msg-send .input-group-addon { width: 40px; border: none; line-height: 2.7; background-color: #dbe3e6; cursor: pointer; }
.msg-send .input-group-addon.msg-text { background-color: #586cb1; color: white; padding: 5px 10px; width: 60px; line-height: 2.8; }
.msg-send { position: absolute; bottom: 0; left: 0; z-index: 999; height: 90px; }
.msg-send .input-group-addon { width: 40px; border: none; line-height: 5.4; background-color: #dbe3e6; cursor: pointer; }
.msg-send .input-group-addon.msg-text { background-color: #586cb1; color: white; padding: 5px 10px; width: 60px; line-height: 5.5; }
.msg-time { padding: 0 5px; color: gray; font-size: 12px; margin: 5px 0; }
.msg-image { line-height: 90px; }
.msg-list {
position: relative; background-color: white;
@ -77,7 +78,8 @@
<div class="text-center">暂无工单数据</div>
@else
<div class="input-group input-group-lg msg-send">
<input name="msg-input" type="text" class="form-control" style="border-radius: 0; border-color: #dbe3e6; text-align: center;">
<textarea name="msg-input" id="msg-input" type="text" class="form-control" rows="3" style="height: 90px; border-radius: 0; border-color: #dbe3e6; text-align: left; padding-left: 5px;"></textarea>
{{-- <input name="msg-input" type="text" class="form-control" style="border-radius: 0; border-color: #dbe3e6; text-align: left; padding-left: 5px;">--}}
<div class="input-group-addon msg-image"><span class="fa fa-picture-o"></span></div>
<div class="input-group-addon msg-text">发送</div>
<input type="file" class="hidden image" name="image">
@ -234,20 +236,29 @@
});
});
$('input[name=msg-input]').on('keyup', function (e) {
if (e.keyCode == 13) {
$('#msg-input').on('keyup', function (event) {
// 只按下ctrl情况,等待enter键的按下
let stat = false;
if (event.keyCode === 17) {
stat = true;
//取消等待
setTimeout(function(){
stat = false;
},300);
}
if (event.keyCode === 13 && (stat || event.ctrlKey)) {
$('.msg-text').click()
}
});
$('.msg-text').on('click', function (e) {
let msgText = $('input[name=msg-input]').val()
let msgText = $('#msg-input').val()
let workorderId = $('input[name=workorder-id]').val()
if (msgText == '') {
$('input[name=msg-input]').css('border-color', 'red').focus();
$('#msg-input').css('border-color', 'red').focus();
setTimeout(function () {
$('input[name=msg-input]').css('border-color', '#dbe3e6');
$('#msg-input').css('border-color', '#dbe3e6');
}, 3000)
}
@ -268,7 +279,7 @@
templateHtml = templateHtml.replace('#contents', msgText)
templateHtml = templateHtml.replace('#times', msgTime)
$(".msg-chat-list").append(templateHtml)
$('input[name=msg-input]').val('')
$('#msg-input').val('')
$(".msg-chat-list").animate({ scrollTop: $(".msg-chat-list")[0].scrollHeight - $('.msg-chat-list').height() }, 1)
},
error: function (error) {

Loading…
Cancel
Save