extends /apps/include/layout.pug
block content
    style.
        .beyond-hiding td {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .beyond-hiding th, .beyond-hiding td {
            width: 70px;
            padding: 9px 5px;
            cursor: default;
        }

    .layui-side.layui-bg-black
        .layui-side-scroll
            .row
                .col-lg-12
                    h1.site-h1 访客视图
                    .box.ukefu-console(style='padding-top:0px !important;')
                        span.user-webim-icon
                            i.layui-icon.ukewo-btn(style='font-size:40px;') 
                        .ukefu-user-index
                            h1(title=agentUser.username + (contacts ? '（' + contacts.name + '）' : '')
                            , style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;overflow: hidden;")
                                | #{agentUser.username}
                                if contacts
                                    | （#{contacts.name}）
                            .ukefu-join-time.ukefu-text-muted(title='访问时间')
                                if agentUser && agentUser.createtime
                                    | #{pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', agentUser.createtime)}
                    .box.ukefu-console
                        .ukefu-relation
                            span.ukefu-relation-item(lay-event, style='width:20%;')
                                | 咨询
                                a.measure(href='/service/history/index.html')
                                    if agentServiceList
                                        | #{agentServiceList.size()}
                            span.ukefu-relation-item(lay-event)
                                | 邀请
                                a.measure(href='/apps/onlineuser.html')
                                    | #{inviteResult.users + inviteResult.inviteusers + inviteResult.refuseusers}
                            span.ukefu-relation-item(lay-event)
                                | 拒绝
                                a.measure(href='/apps/onlineuser.html', style='color:red !important;')= inviteResult.refuseusers
                    .box.ukefu-console
                        .ukefu-relation
                            span.ukefu-relation-item(style='width:55%;')
                                | 平均会话时长
                                a.measure(href='/service/history/index.html')
                                    if agentServicesAvg
                                        | #{pugHelper.padRight(agentServicesAvg / (1000 * 60 * 60), "00")}:#{pugHelper.padRight(agentServicesAvg / (1000 * 60 * 60) / (1000 * 60), "00")}:#{pugHelper.padRight(agentServicesAvg / (1000 * 60) / 1000, "00")}
                                    else
                                        | 00:00:00
                    .box
                        .box-title
                            h1.site-h1(style='background-color:#EEEEEE;')
                                | 访问信息
                        .box-body(style='padding:0px 10px;position: relative;')
                            if agentUser.channel && agentUser.channel == "webim"
                                include /apps/agent/channel/webim.pug
    .layui-body.ukefu-chat-agent#ukefu-chat-agent
        .main-agentuser(style='overflow-y:auto;')
            .box
                .box-title
                    h1.site-h1(style='border-top:1px solid #e6e6e6;height:50px;')
                        span.ukefu-bt
                            .ukefu-bt-text(style='width: 99%;padding-left: 0px;')
                                i.layui-icon.ukewo-btn(style='font-size:28px;margin-right: 10px') 
                                .ukefu-bt-text-title(title=agentUser.username + (onlineUser ? '（' + onlineUser.region + '）' : weiXinUser ? '（' + weiXinUser.country + weiXinUser.province + weiXinUser.city + '）' : ''), style='text-overflow: ellipsis;white-space: nowrap;overflow: hidden;')
                                    | #{agentUser.username}
                                    if onlineUser
                                        | （#{onlineUser.region}）
                                .ukefu-bt-text-content(style='margin-top: 0px;line-height: 20px;') 访客视图-访客访问记录，访客咨询记录
                .box-body
                    .layui-tab
                        ul.layui-tab-title
                            li.layui-this 咨询记录
                            li 访问记录
                            if contacts
                                li 联系人
                        .layui-tab-content
                            .layui-tab-item.layui-show
                                table.layui-table.beyond-hiding(lay-skin='line', style='word-wrap:break-word; word-break:break-all;table-layout: fixed')
                                    thead
                                        tr.design-sortable-tr
                                            th 用户名
                                            th 接入渠道
                                            th 服务坐席
                                            th 访问时间
                                            th 咨询时间
                                            th 咨询时长
                                            th 状态
                                    tbody
                                        if agentServiceList && agentServiceList.size() > 0
                                            for agentService in agentServiceList
                                                tr(class=({
                                                    "tdHasContorllor": true,
                                                    "design-dropable-td": true,
                                                    "ukefu-agentservice-list": true,
                                                    "ukefu-current-agentservice": curAgentService && curAgentService.id == agentService.id
                                                }))
                                                    td(title=agentService.username)
                                                        a(href="/service/online/chatmsg.html?id=#{agentService.id}", data-toggle="load", data-target="#onlinecontent")
                                                            | #{agentService.username}
                                                    td(title=agentService.channel)= agentService.channel
                                                    td(title=agentService.agentusername)= agentService.agentusername
                                                    td(title="#{agentService.logindate ? (pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', agentService.logindate)) : ''}")
                                                        if agentService.logindate
                                                            | #{pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', agentService.logindate)}
                                                    td(title="#{agentService.servicetime ? (pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', agentService.servicetime)) : ''}")
                                                        if agentService.servicetime
                                                            | #{pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', agentService.servicetime)}
                                                    td.minSize
                                                        | #{pugHelper.padRight(agentService.sessiontimes / (1000 * 60 * 60), "00")}:#{pugHelper.padRight(agentService.sessiontimes / (1000 * 60 * 60) / (1000 * 60), "00")}:#{pugHelper.padRight(agentService.sessiontimes / (1000 * 60) / (1000), "00")}
                                                    td.minSize
                                                        if agentService.status && agentService.status == 'inservice'
                                                            small.ukefu-label.theme1(title="对话中") 对话中
                                                        else
                                                            small.ukefu-label.theme1(title="访客已邀请") 已结束
                                        else
                                            tr
                                                td(colspan="7", style="height:400px;")
                                                    .ukefu-empty(style="background: none")
                                                        i.layui-icon 
                                                        div(style="") 还没有历史会话
                            .layui-tab-item
                                table.layui-table(lay-skin='line')
                                    thead
                                        tr.design-sortable-tr
                                            th(width='22%') 终端/操作系统/浏览器
                                            th(width='20%') 访问时间
                                            th 停留时间
                                            th 地域
                                            th 邀请
                                            th 拒绝
                                    tbody
                                        if onlineUserHistList && onlineUserHistList.size() > 0
                                            for onlineuser in onlineUserHistList
                                                tr.tdHasContorllor.design-dropable-td
                                                    td.ukefu-online-client
                                                        if onlineuser.mobile && onlineuser.mobile == "1"
                                                            i.kfont 
                                                        else
                                                            i.kfont 
                                                        if onlineuser.opersystem && onlineuser.opersystem == "windows"
                                                            i.kfont 
                                                        else if onlineuser.opersystem && onlineuser.opersystem == "linux"
                                                            i.kfont 
                                                        else if onlineuser.opersystem && onlineuser.opersystem == "mac"
                                                            i.kfont 
                                                        | #{onlineuser.browser}
                                                    td
                                                        if onlineuser.createtime
                                                            #{pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', onlineuser.createtime)}
                                                    td.minSize
                                                        | #{pugHelper.padRight(onlineuser.betweentime / (1000 * 60 * 60), "00")}:#{pugHelper.padRight(onlineuser.betweentime / (1000 * 60 * 60) / (1000 * 60), "00")}:#{pugHelper.padRight(onlineuser.betweentime / (1000 * 60) / (1000), "00")}
                                                    td= onlineuser.region
                                                    td= onlineuser.invitetimes
                                                    td= onlineuser.refusetimes
                                        else
                                            tr
                                                td(colspan="7", style="height:400px;")
                                                    .ukefu-empty(style="background: none")
                                                        i.layui-icon 
                                                        div(style="") 还没有在线访客记录
                            .layui-tab-item
                                h1.site-h1 联系人详细信息
                                .box.ukefu-console(style='padding-top:0px !important;')
                                    include /apps/service/online/contacts.pug
        .ukefu-chat-prop
            .ukefu-prop-list
                .layui-side-scroll#onlinecontent
                    include /apps/service/online/chatmsg.pug
    script.
        $('#tag').click(function () {
            $('#taglist').show();
        })
        $('.tag-switch').click(
            function () {
                if ($('#tag_' + $(this).data("id")).length > 0) {
                    $('#tag_' + $(this).data("id")).remove();
                } else {
                    $("#tags").append(
                        "<small id='tag_" + $(this).data("id")
                        + "' class='ukefu-label "
                        + $(this).data("theme") + "'>"
                        + $(this).data("name") + "</small>");
                }
                loadURL($(this).data("href"));
            });
        $("#taglist").hover(null, function () {
            $(this).hide();
        });
        $('.ukefu-agentservice-list').on("click", function () {
            $('.ukefu-agentservice-list').removeClass("ukefu-current-agentservice");
            $(this).addClass("ukefu-current-agentservice");
        });
        $('.quick-reply').click(function () {
            var target = $(this).data("id");
            if ($('#' + target).is(":hidden")) {
                $('#' + target).show();
            } else {
                $('#' + target).hide();
            }
        });

