<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>日报</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-form layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <sfTags:pagePermission authFlag="BBTJ_DAILY_RECORD_T" html='<a href="${ctx}/customerEntryDailyRecord/dailyRecordList"><li class="layui-this">日报</li></a>'/>
                <sfTags:pagePermission authFlag="BBTJ_WEEKLY_RECORD_T" html='<a href="${ctx}/customerEntryWeeklyRecord/weeklyRecordList"><li>周报</li></a>'/>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset"  onclick="reset()" >
                    <i class="layui-icon fs-12">&#xe9aa;</i>
                    重置
                </button>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10" id="searchBtn" lay-submit lay-filter="LAY-user-back-search"><i class="layui-icon fs-12">&#xe615;</i>查询</button>
            </ul>
        </div>
        <div class="layui-card-body layuiadmin-card-header-auto" >
            <form class="layui-form layui-card" action="" id="searchForm">

                <div class="layui-form-item">

                    <div class="layui-col-lg4 layui-col-sm6">
                        <label class="layui-form-label">日期：</label>
                        <div class="layui-input-block">
                            <div class="layui-col-xs5">
                                <input type="text" name="creatTime" class="layui-input" id="creatTime" placeholder="统计日期" value="${maxDate}" >
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <sfTags:pagePermission authFlag="BBTJ_DAILY_RECORD_DC_B" html='<button class="layui-btn layui-btn-sm"  id="exportExcel"  onclick="exportExcel()"  ><i class="layui-icon layui-icon-export"></i>导出列表</button>'/>
                    <sfTags:pagePermission authFlag="BBTJ_DAILY_RECORD_TBRB_B" html='<button class="layui-btn layui-btn-sm"  id="syncDailyRecord" onclick="syncDailyRecord()">同步日报</button>'/>
                </div>
            </script>
        </div>
    </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/xm-select.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();

        //统计日期
        var creatTime = laydate.render({
            elem: '#creatTime',
            min: '${minDate}',
            max: '${maxDate}'
        });

        tableExt.render({
            elem: '#test'
            , title:'日报'
            , height: 'full-180'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntryDailyRecord/getDailyRecordListData'
            , where:_serializeJson($("#searchForm"))
            , cols:[[
                {type: 'numbers',fixed:'left',title:'序号',rowspan:2}
                , {field: 'province', title: '省区',minWidth:'130', sort: false, align: 'center',exportable:true,rowspan:2}
                , {field: 'leader_name', title: '负责人',minWidth:'130', sort: false, align: 'center', exportable:true,rowspan:2}
                , {title: '代理商签约',minWidth:'130', sort: false, align: 'center',exportable:true,colspan:3}
                , {title: '发货量（MW）',minWidth:'130', sort: false, align: 'center',exportable:true,colspan:2}
                , {title: '进件数量（个）',minWidth:'130', sort: false, align: 'center',exportable:true,colspan:2}
                , {title: '安装量 提交验工验收（MW）',minWidth:'130', sort: false, align: 'center',exportable:true,colspan:2}
                , {title: '安装量 终审通过（MW）',minWidth:'130', sort: false, align: 'center',exportable:true,colspan:2}
                , {title: '并网量 终审通过（MW）',minWidth:'130', sort: false, align: 'center',exportable:true,colspan:2}
                ],[
                  {field: 'signed_cnt_day', title: '当日签约数量',minWidth:'130', sort: false, align: 'center', exportable:true}
                , {field: 'cum_signed_cnt', title: '累计签约数量',minWidth:'130', sort: false, align: 'center', exportable:true}
                , {field: 'signed_cnt_with_app', title: '有进件的签约数量',minWidth:'150', sort: false, align: 'center', exportable:true}
                , {field: 'shipped_cnt_day', title: '当日发货量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'shipped_cnt_month', title: '本月发货量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'app_cnt_day', title: '当日进件数量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'app_cnt_month', title: '本月进件数量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'submitted_day', title: '当日安装量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'submitted_month', title: '本月安装量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'final_approved_day', title: '当日安装量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'final_approved_month', title: '本月安装量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'grid_connected_day', title: '当日并网量',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'grid_connected_month', title: '本月并网量',minWidth:'130', sort: false, align: 'center',exportable:true}
            ]]
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '日报记录',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 5000,                    //当pageData为false生效
                fileName: '日报记录',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            }
        });


        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            tableExt.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });

        $('input').on('keydown', function(event){
            if(event.keyCode == 13){
                //执行相关操作
                $("#searchBtn").click();
            }
        });
    })

    function syncDailyRecord(){
        layer.open({
            type: 2,
            title:"同步日报",
            resize:false,
            area: ['30%', '50%'],
            content: '${ctx}/customerEntryDailyRecord/toSyncDailyRecord'
        });
    }

    function exportExcel(){
        window.open('${ctx}/customerEntryDailyRecord/exportExcel?'+$('#searchForm').serialize());
    }


    function searchOrder() {
        //执行重载
        table.reload('test', {
            where: function (){
                return _serializeJson($("#searchForm"));
            }
        });
    }
    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
        $("#creatTime").val('${maxDate}');

    }
</script>
</body>
</html>


