<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="refresh" content="3600">
    <title>{$orgInfo.name}陪护平台</title>
    <!--    <link rel="Shortcut Icon" href="/img/logo.png" type="image/x-icon" />-->
    <link rel="stylesheet" href="/static/bootstrap-3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="/screen/css/style.css">
    <style>
        .fullscreen{
            width: 100px;
            height: 100px;
            font-size: 60px;
            position: fixed;
            z-index: 100000000000000000000;
            right: 50px;
            top: 50px;
            color: #ffffff;
            cursor: pointer;
        }
    </style>
</head>
<body>

<div class="nav-header">
    <div class="nav-title">
<!--        {notempty name="logo"}-->
<!--        <img class="nav-title-logo" src="{$logo}" alt="">-->
<!--        {/notempty}-->
        <text>智能陪护平台-{$orgInfo.name}</text>
    </div>
    <div class="nav-date">
        <div class="fgx1"></div>
        <text id="his"></text>
        <div class="fgx2"></div>
        <text id="ymd"></text>
        <div class="fgx3"></div>
        <text id="weekDate"></text>
    </div>
</div>
<div class="main">
    <div class="main1">
        <div class="main1-one">
            <div class="title-all">
                <div class="title-left">
                    <img src="/screen/images/project/title-zsys.png" alt="">
                    <text>护工数据分析</text>
                </div>
            </div>
            <div class="main1-bottom">
                <div class="main1-bottom-left" id="workersStatusEcharts"></div>
                <div class="underway-workers">
                    <div class="title">服务中护工</div>
                    <div class="nums" id="fwzWorker"></div>
                </div>
                <div class="main1-bottom-right">
                    <div class="leisure-workers">
                        <div class="title">空闲中护工</div>
                        <div class="nums" id="kxzWorker"></div>
                    </div>
                    <div class="workers-count-nums">
                        <div class="title">护工总数</div>
                        <div class="nums" id="workerCount"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="main1-two">
            <div class="title-all">
                <div class="title-left">
                    <img src="/screen/images/project/title-zsys.png" alt="">
                    <text>护工工作量统计</text>
                </div>
            </div>
            <div class="worker-comment-order">
                <table class="table2" style="margin: 10px 0;" border="0">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>进行中</th>
                        <th>已完成</th>
                    </tr>
                    </thead>
                    <tbody id="commentOrder">
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="main2">
        <div class="main2-one">
            <div class="title-all">
                <div class="title-left">
                    <img src="/screen/images/project/title-zsys.png" alt="">
                    <text>订单数据分析</text>
                </div>
            </div>
            <div class="main2-order-all">
                <div class="main2-order-left">
                    <div class="underway-order">
                        <div class="title">服务中订单</div>
                        <div class="nums" id="fwzOrder"></div>
                    </div>
                    <div class="add-order">
                        <div class="title">今日新增订单</div>
                        <div class="nums" id="addOrder"></div>
                    </div>
                    <div class="accomplish-order">
                        <div class="title">今日结算订单</div>
                        <div class="nums" id="jsOrder"></div>
                    </div>

                </div>
                <div class="main2-order-right">
                    <div class="main2-order-title">订单总数</div>
                    <div class="main2-order-nums">
                        <text id="orderCount"></text>
                    </div>
                </div>
            </div>
        </div>
        <div class="main2-two">
            <div class="title-all">
                <div class="title-left">
                    <img src="/screen/images/project/title-zsys.png" alt="">
                    <text>订单数据分析</text>
                </div>
            </div>
            <div class="order-data" id="orderDataEcharts"></div>
        </div>
    </div>

    <div class="main3">
        <div class="main3-top">
            <div class="title-all">
                <div class="title-left">
                    <img src="/screen/images/project/title-zsys.png" alt="">
                    <text>护工数据分析</text>
                </div>
            </div>
            <div class="main3-top-table">
                <table class="table2" style="margin: 10px 0;" border="0">
                    <tr>
                        <th>姓名</th>
                        <th>服务病人数</th>
                        <th>服务天数</th>
                    </tr>
                    <tbody id="workerInfo">
                    </tbody>
                </table>
            </div>

        </div>
        <div class="main3-bottom">
            <div class="title-all">
                <div class="title-left">
                    <img src="/screen/images/project/title-zsys.png" alt="">
                    <text>订单实时数据</text>
                </div>
            </div>
            <div class="main3-bottom-table">
                <table class="table2" style="margin: 10px 0;" border="0">
                    <tbody  id="orderMessageLists">

                    </tbody>
                </table>
            </div>

        </div>
    </div>

</div>

<div class="fullscreen">
    <i class="glyphicon glyphicon-fullscreen" id="fullscreenbtn" onclick="fullScreen(this)"></i>
</div>


<script src="/static/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="/static/echarts.js"></script>
<script>
    $(window).resize(function(){
        // location.reload()
        $('#fullscreenbtn').show();
        changeZoom();
    });
    $(function () {
        $('.fullscreen').hover(function () {
            $('#fullscreenbtn').show();
        },function () {
            setTimeout(function () {
                $('#fullscreenbtn').hide();
            },5000);
        });
        changeZoom();
    });

    var orgid = '{$orgInfo.id}';
    var text = document.title;
    var timer;
    function loadingTitle() {
        clearTimeout(timer);
        document.title = text.substring(1,text.length) + text.substring(0,1);
        text = document.title.substring(0,text.length);
        timer = setTimeout("loadingTitle()", 500)
    }
    loadingTitle();


    getWorkerCount();
    getWorkerNums();
    getOrderNums();
    getWorkerInfo();
    // getCommentCount();
    getCommentOrder();
    getSevenDayOrder();
    getOrderMessageList();

    // setTimeout(function () {
    //     getPatrolTask();
    //     getPatrolImg();
    // }, 10000);
    //
    setInterval(function () {
        getWorkerCount();
        getWorkerNums();
        getOrderNums();
        getWorkerInfo();
        getCommentOrder();
        getSevenDayOrder();
        getOrderMessageList();

    }, 1*30000);

    function fullScreen(_self){
        var el = document.documentElement;
        var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;

        //typeof rfs != "undefined" && rfs
        if (rfs) {
            rfs.call(el);
        } else if (typeof window.ActiveXObject !== "undefined") {
            //for IE,这里其实就是模拟了按下键盘的F11,使浏览器全屏
            var wscript = new ActiveXObject("WScript.Shell");
            if (wscript != null) {
                wscript.SendKeys("{F11}");
            }
        }
    }

    function changeZoom() {
        var wb = $(window).width()/1920;
        var hb = $(window).height()/1080;
        if(wb >= hb){
            $('body').css({
                'zoom': hb,
            });
        }else{
            $('body').css({
                'zoom': wb,
            });
        }
    }
    function getWorkerCount(){
        var url = '/h5/project/workerCount';
        $.post(url,{orgid:orgid},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                option = {

                    legend: {
                        data: ['服务中', '空闲中'],
                        textStyle: {
                            color: "#ffffff"
                        },
                        orient: 'right',
                        y: 'bottom',
                        x: 'right',
                    },
                    color:['#0263FF', '#42E2FF'],
                    series: [
                        {
                            type: 'pie',
                            radius: ['15%', '30%'],
                            center: ['40%', '50%'],
                            avoidLabelOverlap: false,
                            // minAngle: 1,  // 设置每块扇形的最小占比
                            hoverAnimation: false,
                            label: {
                                normal: {
                                    show : true,
                                    formatter: "{b}:{d}%",
                                    textStyle: {
                                        fontSize: 12,
                                        color: "#fff",
                                    },
                                }
                            },
                            labelLine:{
                                show: true,
                                normal:{
                                    length:1
                                }
                            },

                            data:lists
                        }
                    ]
                };
                var myChart = echarts.init(document.getElementById('workersStatusEcharts'));
                myChart.setOption(option);
            }
        })
    }


    function getWorkerNums(){
        var url = '/h5/project/workerNums';
        $.post(url,{orgid:orgid},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                $('#fwzWorker').html(lists.fwz);
                $('#kxzWorker').html(lists.kxz);
                $('#workerCount').html(lists.count);
            }
        })
    }
    function  getOrderNums(){
        var url = '/h5/project/orderNums';
        $.post(url,{orgid:orgid},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                $('#fwzOrder').html(lists.serverCount);
                $('#addOrder').html(lists.count);
                $('#jsOrder').html(lists.jsCount);
                $('#orderCount').html(lists.orderCount);
            }
        })
    }
    //workerInfo
    function  getWorkerInfo(){
        var url = '/h5/project/worderList';
        $.post(url,{orgid:orgid},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                var str = '';
                for (let o in lists){
                    str += '<tr>';
                    str += '<td>'+lists[o].realName+'</td>';
                    str += '<td>'+lists[o].servicesNum+'</td>';
                    str += '<td>'+lists[o].servicesDay+'</td>';
                    str += '</tr>';
                }
                $('#workerInfo').html(str);
            }
            if (res.data.length > 8) {
                $(function(){
                    var text=$("#workerInfo:first");
                    var clear;
                    text.hover(function(){
                        clearInterval(clear);
                    },function(){
                        clear=setInterval(function(){
                            var field=text.find("tr:first");
                            var high=field.height();
                            text.animate({ marginTop:-high+"px"},600,function(){
                                field.css("marginTop",0).appendTo(text);
                                text.css("marginTop",0);
                            })
                        },3000)//滚动间隔时间
                    }).trigger("mouseleave");//自动滚动
                });
            }
        })
    }
    function getCommentCount(){
        var url = '/h5/project/commentCount';
        $.post(url,{orgid:orgid},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                option = {
                    // legend: {
                    //     left: 'center',
                    //     top: 'bottom',
                    //     data: ['一星评价', '二星评价', '三星评价', '四星评价', '五星评价']
                    // },
                    color:['#0263FF', '#FF7723', '#F0BC2E', '#CF23A4','#7C2AF4'],
                    series: [
                        {
                            type: 'pie',
                            radius: [20, 60],
                            center: ['50%', '50%'],
                            roseType: 'radius',
                            // minAngle: 1,
                            itemStyle: {
                                borderRadius: 5
                            },
                            label: {
                                normal: {
                                    show : true,
                                    formatter: "{b}:{d}%",
                                    textStyle: {
                                        fontSize: 12,
                                        color: "#fff",
                                    },
                                }
                            },
                            emphasis: {
                                label: {
                                    show: true
                                }
                            },
                            data: lists
                        },

                    ]
                };
                var myChart = echarts.init(document.getElementById('commentEcharts'));
                myChart.setOption(option);
            }
        })
    }
    function  getCommentOrder(){
        var url = '/h5/project/commentList';
        $.post(url,{orgid:orgid,size:5},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                var str = '';
                for (let o in lists){
                    if(o <=8){
                        str += '<tr>';
                        // str += '<td><div style="width: 140px!important; display: inline-block">'+lists[o].createTime+'</div></td>';
                        // str += '<td><div style="width: 300px!important;">'+lists[o].commentInfo+'</div></td>';
                        str += '<td>'+lists[o].realName+'</td>';
                        str += '<td>'+lists[o].jxz+'</td>';
                        str += '<td>'+lists[o].ywc+'</td>';

                        str += '</tr>';
                    }

                }
                $('#commentOrder').html(str);
            }
            // if (res.data.length > 9) {
            //     $(function(){
            //         var text=$("#commentOrder:first");
            //         var clear;
            //         text.hover(function(){
            //             clearInterval(clear);
            //         },function(){
            //             clear=setInterval(function(){
            //                 var field=text.find("tr:first");
            //                 var high=field.height();
            //                 text.animate({ marginTop:-high+"px"},600,function(){
            //                     field.css("marginTop",0).appendTo(text);
            //                     text.css("marginTop",0);
            //                 })
            //             },3000)//滚动间隔时间
            //         }).trigger("mouseleave");//自动滚动
            //     });
            // }
        })
    }

    function getSevenDayOrder(){
        var url = '/h5/project/sevenDayOrder';
        $.post(url,{orgid:orgid},function (res) {
            if(res.code == 0) {
                var lists = res.data;
                option = {
                    legend: {
                        right:'5',
                        data: ['服务中订单数', '新增订单数'],
                        textStyle: {
                            color: "#ffffff"
                        },
                    },
                    color: ['#2C7EDE','#F0652E'],
                    dataZoom: {
                        show: false,
                        start: 0,
                        end: 100
                    },
                    xAxis: {
                        type: 'category',
                        axisLabel: {
                            show: true,
                            textStyle: {
                                color: '#ffffff'   //这里用参数代替了
                            }
                        },
                        axisLine:{
                            lineStyle:{
                                color:'#FFFFFF',
                                width:1,//这里是为了突出显示加上的
                            }
                        },
                        data: lists.xdata
                    },
                    yAxis: {
                        type: 'value',
                        splitLine:{
                            show:false //  去掉背景的网格线
                        },

                        axisLabel: {
                            show: true,
                            textStyle: {
                                color:'#ffffff'  //这里用参数代替了
                            }
                        },
                        axisLine:{
                            lineStyle:{
                                color:'#FFFFFF',
                                width:1,//这里是为了突出显示加上的
                            }
                        }
                    },

                    series: [
                        {
                            name: '服务中订单数',
                            type: 'line',
                            data: lists.count2
                        },
                        {
                            name: '新增订单数',
                            type: 'line',
                            data: lists.count3
                        },
                    ]
                };
                var myChart = echarts.init(document.getElementById('orderDataEcharts'));
                myChart.setOption(option);
            }
        })
    }
    function getOrderMessageList(){
        var url = '/h5/project/orderMessageList';
        $.post(url,{orgid:orgid},function (res) {

            if(res.code == 0) {
                var lists = res.data;
                var str = '';
                for (let o in lists){
                    str += '<tr>';
                    // str += '<td><div style="width: 140px!important; display: inline-block">'+lists[o].createTime+'</div></td>';
                    // str += '<td><div style="width: 300px!important;">'+lists[o].commentInfo+'</div></td>';
                    str += '<td>'+lists[o].createTime+'</td>';
                    str += '<td>'+lists[o].content+'</td>';

                    str += '</tr>';
                }
                $('#orderMessageLists').html(str);
            }
            if (res.data.length > 5) {
                $(function(){
                    var text=$("#orderMessageLists:first");
                    var clear;
                    text.hover(function(){
                        clearInterval(clear);
                    },function(){
                        clear=setInterval(function(){
                            var field=text.find("tr:first");
                            var high=field.height();
                            text.animate({ marginTop:-high+"px"},600,function(){
                                field.css("marginTop",0).appendTo(text);
                                text.css("marginTop",0);
                            })
                        },3000)//滚动间隔时间
                    }).trigger("mouseleave");//自动滚动
                });
            }
        })
    }

    function  ymdTime(ymd){
        var now = new Date();
        var year = now.getFullYear(); //获取年份
        var month = now.getMonth(); //获取月份
        var date = now.getDate(); //获取日期
        month = month + 1;
        if (month<10) {
            month = '0'+month
        }
        if (date<10) {
            date = '0'+date
        }
        var time = year + "." + month + "." + date;
        ymd.innerHTML = time;
    }
    function hisTime(his) {
        var now = new Date();
        var hour = now.getHours(); //获取小时
        var minute = now.getMinutes(); //获取分钟
        var seconds = now.getSeconds(); //获取秒month = month + 1;

        if (hour<10) {
            hour = '0'+hour
        }
        if (minute<10) {
            minute = '0'+minute
        }
        if (seconds<10) {
            seconds = '0'+seconds
        }
        var time =  hour + ":" + minute + ":" + seconds;
        his.innerHTML = time;
    }
    function weekTime(week) {
        var now = new Date();
        var day = now.getDay(); //获取星期
        var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
        var week = arr_week[day];

        var time =  week;
        weekDate.innerHTML = time;
        console.log(time);
    }
    function show() {
        window.setInterval("ymdTime(ymd)", 1000);
        window.setInterval("hisTime(his)", 1000);
        window.setInterval("weekTime(weekDate)", 1000);
    }
    window.onload=show();


    function logout() {
        window.location.href = '/Account/logout';
    }
</script>
</body>
</html>