<%@ page language="java" pageEncoding="UTF-8"
         contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>兰亭集智知识管理系统-Dashboard</title>
    <jsp:include page="../common/head.jsp"></jsp:include>
    <script type="text/javascript" src="<%=basePath%>/resource/plugins/echart/echarts.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>/resource/plugins/jquerytimer/jquery.timer.js"></script>
    <link  rel="stylesheet" type="text/css" href="<%=basePath%>/resource/plugins/fundation-icons/foundation-icons.css">
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style="height:80px;padding:10px;background-color: #E0ECFF;"><span style="font-size: 30px;">兰亭集智综合管理系统</span><sub style="font-size: 12px;margin-left: 10px;">构建版本:V0.1.0 Build 170418</sub><div style="float: right;margin-top: 20px;margin-right: 20px;">欢迎【${showname}】[<a href="javascript:void(0);" id="user_main_logout">注销</a>]</div></div>
<div data-options="region:'west',split:true,title:'功能导航'" style="width:250px;padding:10px;">
    <ul id="menuTree" class="easyui-tree large" data-options="url:'<%=basePath%>/menu/list.action',method:'get',animate:true,lines:true"></ul>
</div>
<div data-options="region:'south',border:false" style="height:50px;padding:15px 10px 10px 10px;text-align: center;">
    CopyRight &copy;All Right Reserved 北京兰亭集智信息技术有限公司（lightinit.com） 2016-2019
</div>
<div data-options="region:'center',border:false">
    <div class="easyui-tabs" id="contentTab" style="width:100%;height:100%">
        <div title="仪表盘" style="padding:10px">
            欢迎使用本系统
        </div>
    </div>
</div>
<script type="text/javascript">
    $("#user_main_logout").click(function(){
        logout();
    });
    function logout(){
        $.messager.confirm('温馨提示', '您确定要注销当前帐号?', function(r){
            if (r){
                var win = null;
                $.ajax({
                    type:"post",//请求方式
                    url:"<%=basePath %>/passport/logout.action",//发送请求地址
                    timeout:30000,//超时时间：30秒
                    dataType:"json",//设置返回数据的格式
                    beforeSend:function(XMLHttpRequest){
                        win=$.messager.progress({
                            title:'密钥校验',
                            msg:'正在注销用户信息...'
                        });
                    },
                    success:function(data){
                        if(data.status==2008){
                            window.location.href="<%=basePath %>";
                        }else{
                            $.messager.alert('温馨提示',data.message);
                        }
                    },
                    complete:function(XMLHttpRequest, textStatus){
                        $.messager.progress('close');
                    },
                    //请求出错的处理
                    error:function(){
                        alert("请求出错");
                    }
                });
            }
        });
    }
   $("#menuTree").tree({
       onClick: function (node) {
           if(node.children!=undefined && node.children!=null && node.children.length>0)
            return;
           var nodeType="tab";
           var nodeAction = "";
           if (node != null && node.attributes != undefined && node.attributes != null && node.attributes.action != null) {
               nodeAction = node.attributes.action+"?code="+node.attributes.code;
           }
           if (node != null && node.attributes != undefined && node.attributes != null && node.attributes.type != null) {
               nodeType = node.attributes.type;
           }

           if ("dialog" == nodeType) {
               logout();
           } else {
               if (nodeAction != null && nodeAction.length > 0) {
                   if ($("#contentTab").tabs('exists', node.text)) {
                       $('#contentTab').tabs('select', node.text);
                   } else {
                       if(/^(http:\/\/|https:\/\/)*/i.test(nodeAction))
                            nodeAction='<%=basePath%>'+nodeAction;
                       if(node.attributes.iframe){
                           $("#contentTab").tabs('add', {
                               title: node.text,
                               content:'<iframe scrolling="no" frameborder="0"  src="'+nodeAction+'" style="width:100%;height:100%;"></iframe>',
                               closable: true
                           });
                       }else{
                           $("#contentTab").tabs('add', {
                               title: node.text,
                               href: nodeAction,
                               closable: true
                           });
                       }
                   }
               }
           }
       }
   });
</script>
</body>
</html>