<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <title>首页</title>
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">工单流程</div>
                        <div class="layui-card-body item-flow pt-50 pb-20 pl-50">
                            <div><b>平台端派单</b></div>
                            <img src="${ctxPlugin}/static/img1/smartart.png" alt="">
                            <div><a lay-href="${ctx}/service/order/getFormOrder" lay-tips="接单" lay-direction="2">接单</a></div>
                            <img src="${ctxPlugin}/static/img1/smartart.png" alt="">
                            <div><b>待派工</b></div>
                            <img src="${ctxPlugin}/static/img1/smartart.png" alt="">
                            <div><b>服务中</b></div>
                            <img src="${ctxPlugin}/static/img1/smartart.png" alt="">
                            <div><b>已完工</b></div>
                            <img src="${ctxPlugin}/static/img1/smartart.png" alt="">
                            <div><b>已结算</b></div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <div class="layui-btn-group">
                                <button type="button" class="layui-btn orderBtn" >本日</button>
                                <button type="button" class="layui-btn layui-btn-primary orderBtn">本周</button>
                                <button type="button" class="layui-btn layui-btn-primary orderBtn">本月</button>
                            </div>
                        </div>
                        <div class="layui-card-body ">
                            <ul class="layui-row layui-col-space10 text-c">
                                <li class="layui-col-xs4 h-100 pt-20">
                                    <a class="layadmin-backlog-body">
                                        <h3>待接收</h3>
                                        <p><cite class="siteDjsCount">0</cite></p>
                                    </a>
                                </li>
                                <li class="layui-col-xs4 h-100 pt-20">
                                    <a class="layadmin-backlog-body">
                                        <h3>服务中</h3>
                                        <p><cite class="fwzCount">0</cite></p>
                                    </a>
                                </li>
                                <li class="layui-col-xs4 h-100 pt-20">
                                    <a class="layadmin-backlog-body">
                                        <h3>已完成</h3>
                                        <p><cite class="ywcCount">0</cite></p>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">备件概况(当月)</div>
                        <div class="layui-card-body">
                            <ul class="layui-row layui-col-space10 text-c">
                                <li class="layui-col-xs4 h-100 pt-20">
                                    <a class="layadmin-backlog-body">
                                        <h3>待审核</h3>
                                        <p><cite class="dshCount">0</cite></p>
                                    </a>
                                </li>

                                <li class="layui-col-xs4 h-100 pt-20">
                                    <a class="layadmin-backlog-body">
                                        <h3>已审核</h3>
                                        <p><cite class="ywcfiCount">0</cite></p>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <span>通知公告</span>
                            <a lay-href="${ctx}/announce/announceList" style="float: right;color: #D9B589;" lay-text="通知公告">更多</a>
                        </div>
                        <div class="layui-card-body">
                        <table id="dataList" class="scroll-list" lay-filter="dataList"></table>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <span>技术资料</span>
                            <a lay-href="${ctx}/technical/technicalInfoList" style="float: right;color: #D9B589;" lay-text="技术资料">更多</a>
                        </div>
                        <div class="layui-card-body">
                            <table class="layui-hide" lay-skin="row" id="test-table-reload" lay-filter="table-toolbar"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="rowToolbar">
    <span style="color:#D9B589;cursor:pointer;" lay-event="showDetail">{{d.title}}</span>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>

<script>

    var $;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','jquery','table','tableExt'],function(){
        $= layui.jquery,
        table = layui.table,
        tableExt = layui.tableExt;

        orderCount('');
      $(".orderBtn").on('click',function(){
            $(".orderBtn").addClass("layui-btn-primary");
            $(this).removeClass("layui-btn-primary");
            var index = $(this).index();
            if(index ==1){
                orderCount('week')//本周
            }else if(index == 2){
                orderCount('month')//本月
            }else{
                orderCount('')
            }

        });
        function orderCount(factor){
            $.ajax({
                type:"POST",
                url:"${ctx}/order/getSiteOrderCount",
                data:{
                    factor:factor
                },
                success:function(data){
                    var order = data.order;
                    var fitting = data.fitting;
                    $(".fwzCount").html(order.columns.fuzCount);
                    $(".siteDjsCount").html(order.columns.siteDjsCount);
                    $(".ywcCount").html(order.columns.ywcCount);

                    $(".dshCount").html(fitting.columns.dckCount);
                    $(".ywcfiCount").html(fitting.columns.ywcCount);
                }
            });
        }

        //初始化通知公告table表格，事件处理在初始化之后
        table.render({
            elem : '#dataList',
            /*height : 'full-200',*/
            url : '${ctx}/msg/center/listData', //数据接口
          //  page : false, //开启分页
//				toolbar : "#tableToolbar",
            defaultToolbar : [],
            limits : [ 20, 50, 100 ],
            limit : 6,
            cols : [[
                {type: 'numbers',title:'序号'}
                ,{field: 'title', title: '公告标题', templet: '#rowToolbar'}
                ,{field: 'bid', title: '状态', templet: function(d) {
                    return !!d.bid ? '已读' : '<span style="color: #D9B589;">未读</span>';
                }}
                ,{field: 'create_time', title: '发布时间'}
            ]]
        });

        table.on("tool(dataList)", function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            //查看公告内容
            if (layEvent === 'showDetail') {
                layer.open({
                    type: 2,
                    title: '详情',
                    content: '${ctx}/msg/center/showDetail?id=' + data.id,
                    maxmin: true,
                    area: ['800px', '495px'],
                    btn: ['关闭'],
                    yes: function (index, layero) {
                        layer.close(index);
                        if (!data.bid) {
                            table.reload('dataList', {
                               /* page: {
                                    curr: layui.$('.layui-laypage-skip').find('input').val()
                                }*/
                            });
                        }
                    },
                    cancel: function (index, layero) {
                        layer.close(index);
                        if (!data.bid) {
                            table.reload('dataList', {
                               /* page: {
                                    curr: layui.$('.layui-laypage-skip').find('input').val()
                                }*/
                            });
                        }
                    }
                });
            }
        });

       //初始化技术资料table表格，事件处理在初始化之后
        tableExt.render({
            elem: '#test-table-reload'
            // ,toolbar : '#toolbarDemo'
            ,defaultToolbar : false
          //  ,page:false
            ,limit : 6
            ,url: '${ctx}/notification/ajaxTechnicalData'
            ,cols: [[
                {type: 'numbers',title:'序号'}
                ,{field:'href', title: '技术资料', templet: function(d){
                    return '<a target="_blank" style="color:#D9B589;cursor:pointer;" href="${commonStaticImgPath}'+d.href+'">'+d.name+'</a>'
                }}
                ,{field:'create_time', title: '发布时间'}
            ]]
        });


    });






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

