<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <base th:href="${#request.getContextPath() + '/'}">
    <meta charset="utf-8">
    <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">
    <link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
    <style>
        *{margin:0;padding:0;}
        [v-cloak]{display: none}
        ul{list-style: none}
        .container{width: 97%;margin:0 auto;}
        .tab{margin-bottom: 10px;float: right;width: 74%;height:140px;overflow-y: auto}
        .top:after, .tab:after, .list:after{content: '';display: block;clear: both}
        .logo-box{float: left;width:25%;}
        .logo{max-width: 100%;height:183px;}
        .box h3{white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 18px;font-weight: normal;color: #000;}
        .list-box{float:left;width: 18%;padding: 5px;box-sizing: border-box;border-top: 1px solid #000;border-bottom: 1px solid #000;border-left: 1px solid #000;}
        .list-box:last-child{margin-right: 0}
        .list-box h4{font-size: 16px;font-weight: normal;color: #000;}
        .list-box ul li{height: 35px;color: #000;border-bottom: 1px solid #DDD;font-size: 0}
        .list-box ul li a{display:inline-block;margin-right:5px;color: #000;text-decoration: none;font-size: 14px;line-height: 35px;vertical-align: top;}
        .list-box ul li span{float:right;font-size: 14px;line-height: 35px;display: inline-block;max-width: 70%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;vertical-align: top;}
        .layui-card-body{padding: 15px;line-height:42px;font-size: 20px;}
        .h360{height: 360px;}
        .layui-input-block{margin-left: 0;}
        .layui-card-header{font-size: 20px;}
        #card-box .layui-col-md2{width: 20%;}
    </style>
</head>
<body>

<div class="layui-fluid layui-anim layui-anim-fadein">
    <div class="layui-row layui-col-space15" id="card-box"></div>
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="list layui-row layui-col-space10">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="schoolInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="personHarmInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="personFollowInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="caseDetectInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="list layui-row layui-col-space10">
                <div class="layui-col-md4">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="areaSecurityInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="areaTypeInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div id="majorInfoPieDiv" class="h360"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="list" style="margin: 30px 0;">
                <div class="layui-input-block">
                    <label class="layui-form-label">事件年份</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="caseYearData" id="caseYearData" placeholder="年">
                    </div>
                </div>
                <div id="caseInfoDiv" style="width: 100%;height:360px;margin: 20px auto;background: #fff;padding: 15px;box-sizing: border-box"></div>
            </div>
            <div class="list">
                <div class="layui-input-block">
                    <label class="layui-form-label" style="width: 120px;margin-left: 15px;">重点场所/区域年份</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="keyPlaceYearData" id="keyPlaceYearData" placeholder="年">
                    </div>
                </div>
                <div id="keyPlaceInfoDiv" style="width:100%;height:360px;margin: 20px auto;background: #fff;padding: 15px;box-sizing: border-box"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="assets/js/vue.min.js"></script>
<script type="text/javascript" src="assets/js/vendor/echarts/echarts.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: 'assets/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'form', 'table', 'laydate', 'common', 'laytpl'], function() {
        var $ = layui.$;
        var $win = $(window);
        var laytpl = layui.laytpl;
        var form = layui.form;
        var table = layui.table;
        var admin = layui.admin;
        var laydate = layui.laydate;
        var common = layui.common;
        var resizeTimeout = null;
        var tableUrl = 'api/statistics/base_sys_info';
        // 学校类型数据信息
        var schoolInfoPieUrl = 'api/statistics/school_info';
        // 学校重点人员危害程度数据信息
        var personHarmInfoPieUrl = 'api/statistics/person_harm_info';
        // 学校重点人员是否关注数据信息
        var personFollowInfoPieUrl = 'api/statistics/person_follow_info';
        // 学校安全事件侦破情况数据信息
        var caseDetectInfoPieUrl = 'api/statistics/case_detect_info';
        // 重点区域排查占比治安类型数据信息
        var areaSecurityInfoPieUrl = 'api/statistics/area_security_info';
        // 重点区域排查占比区域类型数据信息
        var areaTypeInfoPieUrl = 'api/statistics/area_type_info';
        // 重特大案(事)件数据信息
        var majorInfoPieUrl = 'api/statistics/major_info';
        // 年度重大事件统计
        var caseInfoUrl = 'api/statistics/case_info';
        // 年度重点场所/区域巡查统计数据信息
        var keyPlaceInfoUrl = 'api/statistics/key_place_info';
        var selectedAreaArray = [];
        var app = {};

        laydate.render({
            elem: '#caseYearData',
            type: 'year',
            format: 'yyyy',
            done:function(value,data){
                reloadCaseInfoLineData(value);
            }
        })

        laydate.render({
            elem: '#keyPlaceYearData',
            type: 'year',
            format: 'yyyy',
            done:function(value,data){
                reloadKeyPlaceInfoLineData(value);
            }
        })

        // 年度重大事件统计折线图
        function caseInfoLineCharts(data) {
            var chartDom = document.getElementById('caseInfoDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var lengendData = [];
            var xAxisData = [];
            var yAxisSeriesData = [];

            if(!$.isEmptyObject(data)) {
                var lineDataArr = data;
                var statisticsDTOList = lineDataArr[0].statisticsDTOList;
                for(let key in statisticsDTOList) {
                    lengendData.push(statisticsDTOList[key].dataType)
                }
                if(null != lineDataArr && lineDataArr.length > 0) {
                    for(var i=0;i<lengendData.length;i++) {
                        var seriesData = [];
                        var yAxisSeriesDataObj = {};
                        for (let key in lineDataArr) {
                            yAxisSeriesDataObj.type = 'line';
                            yAxisSeriesDataObj.stack = 'Total';
                            yAxisSeriesDataObj.name = lengendData[i];
                            var subList = lineDataArr[key].statisticsDTOList;
                            seriesData.push(subList[i]['count']);
                        }
                        yAxisSeriesDataObj.data = seriesData;
                        yAxisSeriesData.push(yAxisSeriesDataObj);
                    }
                    for (let key in lineDataArr) {
                        xAxisData.push(lineDataArr[key].month);
                    }
                }
            }

            option = {
                title: {
                    text: '年度重大事件'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: lengendData
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: xAxisData
                },
                yAxis: {
                    type: 'value'
                },
                series: yAxisSeriesData
            };

            option && myChart.setOption(option);
        }

        function reloadCaseInfoLineData(year) {
            var layIndex;
            top.restAjax.get(top.restAjax.path(caseInfoUrl + '?year={year}', [year]), {}, null, function (code, data) {
                caseInfoLineCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initCaseInfoLineData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(caseInfoUrl, []), {}, null, function (code, data) {
                caseInfoLineCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        initCaseInfoLineData();

        // 年度重点场所/区域巡查统计数据信息折线图
        function keyPlaceInfoLineCharts(data) {
            console.log(data)
            var chartDom = document.getElementById('keyPlaceInfoDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var lengendData = [];
            var xAxisData = [];
            var yAxisSeriesData = [];

            if(!$.isEmptyObject(data)) {
                var lineDataArr = data;
                var statisticsDTOList = lineDataArr[0].statisticsDTOList;
                for(let key in statisticsDTOList) {
                    lengendData.push(statisticsDTOList[key].dataType)
                }
                if(null != lineDataArr && lineDataArr.length > 0) {
                    for(var i=0;i<lengendData.length;i++) {
                        var seriesData = [];
                        var yAxisSeriesDataObj = {};
                        for (let key in lineDataArr) {
                            yAxisSeriesDataObj.type = 'line';
                            yAxisSeriesDataObj.stack = 'Total';
                            yAxisSeriesDataObj.name = lengendData[i];
                            var subList = lineDataArr[key].statisticsDTOList;

                            seriesData.push(parseInt(subList[i]['count']));
                        }
                        yAxisSeriesDataObj.data = seriesData;
                        yAxisSeriesData.push(yAxisSeriesDataObj);
                    }
                    for (let key in lineDataArr) {
                        xAxisData.push(lineDataArr[key].month);
                    }
                }
            }
            console.log(lengendData)
            console.log(xAxisData)
            console.log(yAxisSeriesData)

            option = {
                title: {
                    text: '年度重点场所/区域巡查统计'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: lengendData
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: xAxisData
                },
                yAxis: {
                    type: 'value'
                },
                series: yAxisSeriesData
            };

            option && myChart.setOption(option);
        }

        function reloadKeyPlaceInfoLineData(year) {
            var layIndex;
            top.restAjax.get(top.restAjax.path(keyPlaceInfoUrl + '?year={year}', [year]), {}, null, function (code, data) {
                console.log(data)
                keyPlaceInfoLineCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initKeyPlaceInfoLineData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(keyPlaceInfoUrl, []), {}, null, function (code, data) {
                console.log(data)
                keyPlaceInfoLineCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        initKeyPlaceInfoLineData();


        // 学校类型数据信息饼图
        function schoolInfoPieCharts(data) {
            var chartDom = document.getElementById('schoolInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '学校类型占比',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 学校重点人员危害程度数据信息饼图
        function personHarmInfoPieCharts(data) {
            var chartDom = document.getElementById('personHarmInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '学校重点人员',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 学校重点人员是否关注数据信息饼图
        function personFollowInfoPieCharts(data) {
            var chartDom = document.getElementById('personFollowInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '学校重点人员(是否关注)',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 学校安全事件侦破情况数据信息饼图
        function caseDetectInfoPieCharts(data) {
            var chartDom = document.getElementById('caseDetectInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '学校安全事件侦破情况',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 重点区域排查占比治安类型数据信息饼图
        function areaSecurityInfoPieCharts(data) {
            var chartDom = document.getElementById('areaSecurityInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '重点区域排查占比',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 重点区域排查占比区域类型数据信息饼图
        function areaTypeInfoPieCharts(data) {
            var chartDom = document.getElementById('areaTypeInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '重点区域排查占比(场所类型)',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 重特大案(事)件数据信息饼图
        function majorInfoPieCharts(data) {
            var chartDom = document.getElementById('majorInfoPieDiv');
            var myChart = echarts.init(chartDom);
            var option;

            var pieData = [];

            if(!$.isEmptyObject(data)) {
                var pieDataArr = data;
                if(null != pieDataArr && pieDataArr.length > 0) {
                    for(let key in pieDataArr) {
                        pieData.push({
                            name: pieDataArr[key]['dataType'],
                            value: pieDataArr[key]['count']
                        })
                    }
                }
            }

            option = {
                title: {
                    text: '重特大案(事)件',
                    left: 'left'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'right'
                },
                series: [
                    {
                        name: '任务数据',
                        type: 'pie',
                        radius: '50%',
                        data: pieData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            option && myChart.setOption(option);
        }

        // 9+x系统数据
        function initBaseSysInfoData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(tableUrl, []), {}, null, function (code, data) {
                $('#card-box').empty();
               for(var i=0;i<data.length;i++) {
                   var html = '<div class="layui-col-md2">\n' +
                       '            <div class="layui-card">\n' +
                       '                <div class="layui-card-header">' + data[i].dataType +'</div>\n' +
                       '                <div class="layui-card-body">\n' + data[i].count + '\n' +
                       '                </div>\n' +
                       '            </div>\n' +
                       '        </div>'
                   $('#card-box').append(html)
               }
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initSchoolInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(schoolInfoPieUrl, []), {}, null, function (code, data) {
                schoolInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initPersonHarmInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(personHarmInfoPieUrl, []), {}, null, function (code, data) {
                personHarmInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initPersonFollowInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(personFollowInfoPieUrl, []), {}, null, function (code, data) {
                personFollowInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initCaseDetectInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(caseDetectInfoPieUrl, []), {}, null, function (code, data) {
                caseDetectInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initAreaSecurityInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(areaSecurityInfoPieUrl, []), {}, null, function (code, data) {
                areaSecurityInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initAreaTypeInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(areaTypeInfoPieUrl, []), {}, null, function (code, data) {
                areaTypeInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initMajorInfoPieData() {
            var layIndex;
            top.restAjax.get(top.restAjax.path(majorInfoPieUrl, []), {}, null, function (code, data) {
                majorInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function testDat() {
            var layIndex;
            top.restAjax.get(top.restAjax.path("api/testdata/get", []), {}, null, function (code, data) {
                majorInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function getkeyplace() {
            var layIndex;
            top.restAjax.get(top.restAjax.path("api/testdata/getkeyplace", []), {}, null, function (code, data) {
                majorInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function getkeyarea() {
            var layIndex;
            top.restAjax.get(top.restAjax.path("api/testdata/getkeyarea", []), {}, null, function (code, data) {
                majorInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function setFileKey() {
            var layIndex;
            top.restAjax.get(top.restAjax.path("api/testdata/setFileKey", []), {}, null, function (code, data) {
                majorInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function setFileZZ() {
            var layIndex;
            top.restAjax.get(top.restAjax.path("api/testdata/setFileZZ", []), {}, null, function (code, data) {
                majorInfoPieCharts(data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        function initData() {
            initSchoolInfoPieData();
            initPersonHarmInfoPieData();
            initPersonFollowInfoPieData();
            initCaseDetectInfoPieData();
            initAreaSecurityInfoPieData();
            initAreaTypeInfoPieData();
            initMajorInfoPieData();
            initBaseSysInfoData();


            /*setFileZZ();
            testDat();
            getkeyplace();
            getkeyarea();
            setFileKey();
            */
        }

        initData();

        // 选择区域
        $(document).on('click', '#area', function() {
            top.dialog.open({
                title: '选择地区',
                url: top.restAjax.path('route/mongo/area/get-select?areaName={areaName}', [encodeURI($('#area').val())]),
                width: '800px',
                height: '225px',
                onClose: function () {
                    selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
                    var areaCode = '';
                    var areaName = '';
                    if (selectedAreaArray.length > 0) {
                        areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
                        for (var i = 0, item; item = selectedAreaArray[i++];) {
                            if (areaName) {
                                areaName += ',';
                            }
                            areaName += item.areaName;
                            $('#areaId_' + i).val(item.areaId);
                        }
                    }
                    $('#area').val(areaName);
                }
            })
        });

        // 重载表格
        function reloadTable(currentPage) {
            var layIndex;
            top.restAjax.get(top.restAjax.path(tableUrl, []), {
                keywords: $('#keywords').val(),
                // distributeDeadline: $('#distributeDeadline').val(),
                startTime: $('#startTime').val(),
                endTime: $('#endTime').val(),
                taskArea1Id: $('#areaId_1').val(),
                taskArea1Id: $('#areaId_1').val(),
                taskArea2Id: $('#areaId_2').val(),
                taskArea3Id: $('#areaId_3').val(),
                taskArea4Id: $('#areaId_4').val(),
                taskArea5Id: $('#areaId_5').val(),
                userId: $('#userId').val(),
                urgentLevel: $('#urgentLevel').val(),
                reportCount: $('#reportCount').val(),
            }, null, function (code, data) {
                barCharts(data.data);
            }, function (code, data) {
                top.dialog.msg(data.msg);
            }, function () {
                layIndex = top.dialog.msg(top.dataMessage.updating, {icon: 16, time: 0, shade: 0.3});
            }, function () {
                top.dialog.close(layIndex);
            });
        }

        // 初始化日期
        function initDate() {
            // 日期选择
            laydate.render({
                elem: '#startTime',
                format: 'yyyy-MM-dd HH:mm:ss'
            });
            laydate.render({
                elem: '#endTime',
                format: 'yyyy-MM-dd HH:mm:ss'
            });
        }

        initDate();

        // 事件 - 页面变化
        $win.on('resize', function() {
            clearTimeout(resizeTimeout);
            resizeTimeout = setTimeout(function() {
                initData();
            }, 500);
        });

        // 事件 - 搜索
        $(document).on('click', '#search', function() {
            reloadTable(1);
        });

        // 事件 - 清空搜索条件
        $(document).on('click', '#reset', function() {
            $('#keywords').val('');
            $('#startTime').val('');
            $('#endTime').val('');
            $('#area').val('');
            $('#areaId_1').val('');
            $('#areaId_2').val('');
            $('#areaId_3').val('');
            $('#areaId_4').val('');
            $('#areaId_5').val('');
            $('#receiverUser').val('');
            $('#userId').val('');
            $('#urgentLevel').val('');
            $('#reportCount').val('');
        });

    });
</script>
</body>
</html>