@using MySystem.Models;
@{
    List<RightDic> menus = ViewBag.menus as List<RightDic>;
    List<RightDic> datalist = ViewBag.datalist as List<RightDic>;
    List<Dictionary<string, object>> statlist = ViewBag.statlist as List<Dictionary<string, object>>;
    string RightInfo = ViewBag.RightInfo as string;
    string Role = ViewBag.Role as string;
    string tables = "";
}
<!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">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>

    <div class="layui-fluid">
        @if(Role != "13")
        {
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header">快捷方式</div>
                            <div class="layui-card-body">

                                <div class="layui-carousel layadmin-carousel layadmin-shortcut">
                                    <div carousel-item>
                                        <ul class="layui-row layui-col-space10">
                                            @foreach(RightDic sub in menus)
                                            {
                                                if (RightInfo.Contains("," + sub.Id + ","))
                                                {
                                                    string url = sub.Url;
                                                    if (url.Contains("?"))
                                                    {
                                                        url += "&right=" + sub.Id;
                                                    }
                                                    else
                                                    {
                                                        url += "?right=" + sub.Id;
                                                    }
                                                    <li class="layui-col-xs3">
                                                        <a lay-href="@url">
                                                            <i class="layui-icon @(string.IsNullOrEmpty(sub.Icon) ? "layui-icon-component" : sub.Icon)"></i>
                                                            <cite>@sub.Name</cite>
                                                        </a>
                                                    </li>
                                                }
                                            }
                                        </ul>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header">统计</div>
                            <div class="layui-card-body">

                                <div class="layui-carousel layadmin-carousel layadmin-backlog">
                                    <div carousel-item>
                                        <ul class="layui-row layui-col-space10">
                                            @{int i=0;}
                                            @foreach(Dictionary<string, object> sub in statlist)
                                            {
                                                i += 1;
                                                if(i % 4 == 1 && i > 1)
                                                {
                                                    @Html.Raw("</ul><ul class=\"layui-row layui-col-space10\">");
                                                }
                                                <li class="layui-col-xs6">
                                                    <a href="javascript:;" class="layadmin-backlog-body">
                                                        <h3>@sub["Name"]</h3>
                                                        <p><cite>@sub["Count"]</cite></p>
                                                    </a>
                                                </li>
                                            }
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    @if(datalist.Count > 0)
                    {
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-tab layui-tab-brief layadmin-latestData">
                                <ul class="layui-tab-title">
                                    @{i=0;}
                                    @foreach(RightDic sub in datalist)
                                    {
                                        i += 1;
                                        <li class="@(i == 1 ? "layui-this" : "")">@sub.Name</li>
                                    }
                                </ul>
                                <div class="layui-tab-content">
                                    @{i=0;}
                                    @foreach(RightDic sub in datalist)
                                    {
                                        i += 1;
                                        string table = sub.Url.Split('/')[2];
                                        tables += "'" + table + "',";
                                        <div class="layui-tab-item @(i == 1 ? "layui-show" : "")">
                                            <table id="LAY-index-Search@(table)"></table>
                                        </div>
                                    }
                                </div>
                            </div>
                        </div>
                    </div>
                    }
                    
                </div>
            </div>

            <div class="layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header">版本信息</div>
                    <div class="layui-card-body layui-text">
                        <table class="layui-table">
                            <colgroup>
                                <col width="100">
                                <col>
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td>当前版本</td>
                                    <td>
                                        <script type="text/html" template>
                                            v1.0
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td>名称</td>
                                    <td>
                                        <script type="text/html" template>
                                            客小爽管理平台
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td>短信条数</td>
                                    <td>
                                        <script type="text/html" template>
                                            @ViewBag.SMSCount
                                        </script>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="layui-col-m12 layui-col-space15">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            新增创客数
                        </div>
                        <div class="layui-card-body" id="users" style="width: 100%;height:400px;">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            新增商户数
                        </div>
                        <div class="layui-card-body" id="actives" style="width: 100%;height:400px;">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-m12 layui-col-space15">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            新增消费者数
                        </div>
                        <div class="layui-card-body" id="trades" style="width: 100%;height:400px;">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        }
    </div>

    <script src="/layuiadmin/modules/Main_Admin.js"></script>
    <script src="../../layuiadmin/layui/layui.js?t=1"></script>
    <script src="../../admin/js/echart.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/'
        }).extend({
            index: 'lib/index'
        }).use(['index', 'console', 'table'], function(){
            var $ = layui.$
            ,table = layui.table;

            var tables = [@(Html.Raw(tables.TrimEnd(',')))];
            //今日热搜
            for(var i = 0; i < tables.length; i++){
                table.render({
                    elem: '#LAY-index-Search' + tables[i]
                    , url: '/Admin/' + tables[i] + '/IndexData' //模拟接口
                    , cols: eval(tables[i] + '_cols')
                    , page: true
                    , text: '对不起，加载出现异常！'
                    , done: function (res, curr, count) {
                        $(".layui-none").text("无数据");
                    }
                    , skin: 'line'
                });
            }
        });

        var myChart = echarts.init(document.getElementById('users'));

        function showEChart() {
            var option = {
                tooltip: {},
                xAxis: {
                    type: 'category',
                    data: ['11月19日', '11月20日', '11月21日', '11月22日', '11月23日', '11月24日', '11月25日']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: [150, 230, 224, 218, 135, 147, 260],
                        type: 'line'
                    }
                ]
            };
            myChart.setOption(option);
        }
        showEChart();


        var myChartHeight = echarts.init(document.getElementById('actives'));
		var optionHeight = {
            tooltip: {},
            xAxis: {
                type: 'category',
                data: ['11月19日', '11月20日', '11月21日', '11月22日', '11月23日', '11月24日', '11月25日']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    data: [820, 932, 901, 934, 1290, 1330, 1320],
                    type: 'line',
                    smooth: true
                }
            ]
		};
		myChartHeight.setOption(optionHeight);


		var myChartWeight = echarts.init(document.getElementById('trades'));
		var optionWeight = {
            tooltip: {},
            xAxis: {
                data: ["11月19日","11月20日","11月21日","11月22日","11月23日","11月24日","11月25日"]
            },
            yAxis: {},
            series: [{
                name: '新增创客数',
                type: 'bar',
                data: [50, 20, 36, 10, 10, 20, 66]
            }]
		};
		myChartWeight.setOption(optionWeight);
    </script>
</body>
</html>