{extend name="Public/base" /}
{block name="css"}
<style>
    .layui-table-page {
        /*margin-top: -60px;*/
        margin-left: 4px;
        height: auto!important;
    }
    .layui-table-view {
        position: relative;
        margin: 10px 45px;
        overflow: hidden;

    }
</style>
{/block}
{block name="main"}
<div class="if_wrap">
    <div class="cus-con">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>坐席列表</legend>
        </fieldset>
        </div>
        <table class="layui-table" lay-data="{limit:100, url:'/crm/Call/callListData',id:'idTest'}" lay-filter="msgTable">
            <thead>
            <tr>
                <th lay-data="{field:'id', width:50,align:'center', sort: true,toolbar: '#titleTpl'}">序号</th>
                <th lay-data="{field:'staff_name',align:'center' ,width:100}">用户名</th>
                <th lay-data="{field:'user',align:'center',width:150}">坐席号</th>
                <th lay-data="{field:'customer_name',align:'center',width:150}">客资姓名</th>
                <th lay-data="{field:'customer_tel',align:'center',width:150}">客资手机</th>
                <th lay-data="{field:'status',align:'center',width:150,toolbar: '#status'}">是否在线</th>
                <th lay-data="{field:'is_busy',align:'center',width:150,toolbar: '#busy'}">忙/闲</th>
                <th lay-data="{width:200,field:'score',align:'center', toolbar: '#show'}">查看</th>
            </tr>
            </thead>
        </table>
        <script type="text/html" id="show">
            {{#  if(d.is_busy == 1){ }}
            <a class="layui-btn layui-btn-mini" lay-event="detail">查看客资</a>
            <a class="layui-btn layui-btn-mini" lay-event="monitor">监听</a>
            {{#  } }}
        </script>
        <script type="text/html" id="status">
            {{#  if(d.status == 1){ }}
            <span style="color: #00FF00">在线</span>
            {{#  } else { }}
            <span style="color:#9d9d9d">离线</span>
            {{#  } }}
        </script>
        <script type="text/html" id="busy">
            {{#  if(d.is_busy == 1){ }}
            <span style="color: #ff2f2a">忙</span>
            {{#  } else { }}
            <span style="color: #b2d4dd;">闲</span>
            {{#  } }}
        </script>
        <script type="text/html" id="titleTpl">
            {{d.LAY_TABLE_INDEX+1}}
        </script>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        setInterval(function(){
            layui.table.reload('idTest', {});
        },10000)
    })

    //日历
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#start'
            ,max:0
            ,format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#end'
            ,max:0
            ,format: 'yyyy-MM-dd'
        });
    });
    // 表格
    layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element'], function(){
        var laydate  = layui.laydate, //日期
                laypage  = layui.laypage //分页
        layer    = layui.layer, //弹层
                table    = layui.table, //表格
                carousel = layui.carousel, //轮播
                upload   = layui.upload, //上传
                element  = layui.element; //元素操作
        //分页
        laypage.render({
            elem: 'pageDemo' //分页容器的id
            ,count: 100 //总页数
            ,limit:15
            ,skin: '#1E9FFF' //自定义选中色值
            ,jump: function(obj, first){
                if(!first){
                    layer.msg('第'+ obj.curr +'页');
                }
            }
        });

        table.on('tool(msgTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'detail') {
                var id = obj.data.customer_id;
                load_page(
                        '/crm/customer/customerinfo/id/'+id,
                        '客资详情',
                        function(){
                            layer.closeAll();
                        },
                        ['关闭'],
                        740,550
                );
            }
            if (layEvent === 'monitor') {
                url_DoMonitor(0,obj.data.guid);
            }
        })
    })

</script>
{/block}