{extend name="Public/base"/}
{block name="css"}
<link rel="stylesheet" href="__PUBLIC__/css/set.css?v={$Think.const.APP_VERSION}">
<style>
    .layui-table-page {
        height: 26px;
        margin-top: -14px;
    }
</style>
{/block}
{block name="js"}
<script>
    $(function(){
        // $(".nul_bli").eq(4).find(".navb").addClass("active");
        // $(".navb.active").parent().find(".nul_s .nul_sli").eq(1).find(".navs").addClass("active");
    })
</script>
{/block}
{block name="main"}
<div class="if_wrap">
    <div class="cus-con">
        <div class="set_tit">
            <span>{$title}</span>
            {auth code="menu1538119117"}
            <a class="layui-btn layui-btn-primary cus-model-btn" href="/crm/Logs/checkOnlineStaff" target="_blank" style="margin-top: 3px;">
                <i class="fa fa-child" style="font-size: 14px;margin-right: 5px"></i>网销签到信息
            </a>
            {/auth}
        </div>
		<div class="set-top layui-form" style="min-width: 1130px;">
            <div class="mkz_title">选择日期：</div>
            <div class="layui-input-inline">
                <input class="layui-input" id="start" placeholder="" readonly="readonly" type="text" value="">
            </div>
            <span class="date-span">-</span>
            <div class="layui-input-inline">
                <input class="layui-input" id="end" placeholder="" readonly="readonly" type="text" value="">
            </div>
            <div class="mkz_title">分配方式：</div>
            <div class="layui-input-inline">
                <select name="fp_model" id="fp_model" lay-filter="fp_model" lay-search="">
                    <option value="">全部</option>
                    <option value="1">自动分配</option>
                    <option value="2">手动分配</option>
                    <option value="3">录入指定</option>
                    <option value="4">话务录入</option>
                </select>
            </div>
            <div class="mkz_title">分配状态：</div>
            <div class="layui-input-inline">
                <select name="fp_staff" id="fp_status" lay-filter="fp_status" lay-search="">
                    <option value="">全部</option>
                    <option value="1">已分配</option>
                    <option value="2">未分配</option>
                    <option value="3">待接收</option>
                    <option value="4">分配失败</option>
                    <option value="5">放弃</option>
                </select>
            </div>
            <div class="mkz_title">接收人：</div>
            <div class="layui-input-inline">
                <select name="jr_staff_id" id="jr_staff_id" lay-filter="jr_staff" lay-search="">
                    <option value="0">全部</option>
                    {volist name="jr_staff" id="vo"}
                    <option value="{$vo.id}">{$vo.staffname}</option>
                    {/volist}
                </select>
            </div>
            <div class="mkz_title">客资：</div>
            <div class="layui-input-inline">
                <input class="layui-input" id="cid" placeholder="" type="text" value="">
            </div>
            <button class="layui-btn layui-btn-primary cus-model-btn" id="sub" >
                查询
            </button>
        </div>
        <table class="layui-table" lay-data="{height:700, url:'/crm/Logs/searchFplogs',page:true,limit:20, id:'idTest'}" lay-filter="demo">
            <thead>
            <tr>
            	<th lay-data="{width:100,field:'id',align:'center',templet: '#titleTpl'}">序号</th>
                <th lay-data="{width:100,field:'cid'}">客资ID</th>
                <th lay-data="{width:120,field:'fp_model',templet:'#model'}">分配方式</th>
                <th lay-data="{width:120,field:'fp_status',templet:'#status'}">分配状态</th>
                <th lay-data="{width:150,field:'fp_time'}">分配时间</th>
                <th lay-data="{width:120,field:'fp_staff_name'}">分配人</th>
                <th lay-data="{width:200,field:'fp_shop_name'}">分配店</th>
                <th lay-data="{width:150,field:'jr_time'}">接收时间</th>
                <th lay-data="{width:120,field:'jr_staff_name'}">接收人</th>
                <th lay-data="{width:200,field:'jr_shop_name'}">接收店</th>
            </tr>
            </thead>
        </table>
        <script type="text/html" id="model">
            {{#  if(d.fp_model == 1){ }}
            自动分配
            {{#  } else if(d.fp_model == 2) { }}
            手动分配
            {{#  } else if(d.fp_model == 3) { }}
            录入指定
            {{#  } else if(d.fp_model == 4) { }}
            话务录入
            {{#  } }}
        </script>
        <script type="text/html" id="status">
            {{#  if(d.fp_status == 1){ }}
            已分配
            {{#  } else if(d.fp_status == 2) { }}
            未分配
            {{#  } else if(d.fp_status == 3) { }}
            待接收
            {{#  } else if(d.fp_status == 4) { }}
            分配失败
            {{#  } else if(d.fp_status == 5) { }}
            放弃接收
            {{#  } }}
        </script>
        <script type="text/html" id="titleTpl">
			{{d.LAY_TABLE_INDEX+1}}
		</script>
	</div>
</div>
<script type="text/javascript">

//日历
layui.use('laydate', function () {
    var laydate = layui.laydate;
    laydate.render({
        elem: '#start'
        ,format: 'yyyy-MM-dd'
        ,value: new Date()
        ,max: 0
    });
});
layui.use('laydate', function () {
    var laydate = layui.laydate;
    laydate.render({
        elem: '#end'
        ,format: 'yyyy-MM-dd'
        ,value: new Date()
        ,max: 0
    });
});

// 数据表格
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 //总页数
	    ,skin: '#1E9FFF' //自定义选中色值
		// ,skip: true //开启跳页
	    ,jump: function(obj, first){
	        if(!first){
	            layer.msg('第'+ obj.curr +'页');
	        }
	    }
	});
})

// 查询按钮
$("#sub").click(function(){
	// 生成表格
    var start = $('#start').val();
	var end   = $('#end').val();
    var jr_staff_id = $('#jr_staff_id').val();
	var cid   = $('#cid').val();
	var fp_model   = $('#fp_model').val();
	var fp_status   = $('#fp_status').val();
    var index = layer.load(1, {shade: false}); //0代表加载的风格，支持0-2
	// 重新载入表格
	table.reload('idTest', {
        url: 'searchFplogs',
        where: {start:start,end:end, jr_staff_id:jr_staff_id, cid:cid,fp_model:fp_model,fp_status:fp_status},
        done: function(res, curr, count){
            layer.close(index);
        }
    });
});

</script>
{/block}