<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MESWebSite.Manage.Index" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>MES</title>
    <style type="text/css">
        .menuItem {
            height: 24px;
            /*border-bottom: solid 1px #55873A;*/
            border-bottom: solid 1px #3E4E70;
            display: block;
            padding-left: 20px;
            padding-top: 5px;
            padding-bottom: 5px;
            line-height: 15px;
            /*background: #6CBD47;*/
            background: #2A354E;
            vertical-align: bottom;
            align-content: center;
            text-align: left;
            font-size: 14px;
        }

            .menuItem a {
                font-size: 14px;
                color: white;
                text-decoration: none;
            }

                .menuItem a:hover {
                    font-size: 14px;
                    color: #84ccc9;
                    text-decoration: none;
                }

        #ft .saveBtn {
            background-image: url('/SysImages/Basics/save.png');
            line-height: 25px;
            height: 25px;
            padding: 3px 20px 3px 36px;
            border: 1px solid #ccc;
            color: #333;
            font-size: 14px;
            cursor: pointer;
            background-repeat: no-repeat;
            background-position: 5px 5px;
            background-color: #fff;
        }

            #ft .saveBtn:hover {
                border: 1px solid #999;
                background-color: #eee;
            }

        element.style {
            padding: 10px;
            text-align: center;
            background-color: rgb(249, 249, 249);
            visibility: visible;
        }

        .window .panel-footer {
            border: 1px solid #ddd;
            position: relative;
            top: -1px;
        }

        .panel-footer-noborder {
            border-width: 1px 0 0 0;
        }

        .panel-footer {
            border: 1px solid #ddd;
            overflow: hidden;
            background: #fff;
        }
    </style>
    <link href="../Themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/EasyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/EasyUI/themes/icon.css" rel="stylesheet" />
    <script src="../Scripts/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../Scripts/EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var piframe = null;
        function createFrame(url) {
            var s = '<iframe id="paraframe" class="pifm" frameborder="0" width="100%" height="95%" scrolling="auto" onload="fraresize(\'\')" src="' + url + '"style="min-height:1023px; max-height:none;"></iframe>';
            return s;
        }
        //  添加标签
        function addtab(obj) {

            var title = $(obj).text();
            var url = $(obj).attr("ahref");
            if ($('#tabmain').tabs('exists', title)) {
                $('#tabmain').tabs('select', title); //选中
            }
            else {
                var content = createFrame(url);
                $('#tabmain').tabs('add', {
                    title: title,
                    content: content,
                    closable: true
                });
            }
            return false;
        }
        function closetab_selected() {
            var tab = $('#tabmain').tabs('getSelected');
            var index = $('#tabmain').tabs('getTabIndex', tab);
            $('#tabmain').tabs('close', index);
        }

        function closetab_title(title) {
            $('#tabmain').tabs('close', title);
        }

        function fraresize(fra) {
            $("#piframe").height($('#divcenter').height() - 32);
        }

        //
        // 生成菜单
        //
        function getmenu() {
            //var menuItem = "";
            //menuItem += "<span class='menuItem'><a href='#' ahref='QYIOnlineManager/UserCustom.aspx' onclick=addtab(this)></a></span>";
            //menuItem += "<span class='menuItem'><a href='#'  ahref='QYIOnlineManager/UserPatient.aspx' onclick=addtab(this)></a></span>";
            //menuItem += "<span class='menuItem'> <a href='#'  ahref='QYIOnlineManager/SMSSendLog.aspx' onclick=addtab(this)></a></span>";
            //menuItem += "<span class='menuItem'><a href='#'  ahref='QYIOnlineManager/LogInterface.aspx' onclick=addtab(this)></a></span>";
            //$('#divmenu').accordion('add', { title: "查询", content: menuItem, iconCls: 'icon-search' });


            //$('#divmenu').accordion('add', { title: "设置", content: menuItem, iconCls: 'icon-add' });


            //$('#divmenu').accordion('add', { title: "监控", content: menuItem, iconCls: 'icon-tip' });

            var uu = "../Service/SystemManager.ashx?action=GETMENU";
            var userid = $("#<%=txt_UserID.ClientID%>").val();
            $.ajax({
                url: uu,
                type: 'POST',
                data: { "userID": userid },
                dataType: 'json',
                error: function () {
                },
                success: function (data) {
                    if (data.success) {
                        for (var i = 0; i < data.data.length; i++) {
                            var menuItem = "";
                            for (var j = 0; j < data.data[i].SubNavMenuList.length; j++) {
                                menuItem += "<span class='menuItem'><img src='" + data.data[i].SubNavMenuList[j].ItemPic + "' />&nbsp;&nbsp;&nbsp;&nbsp;<a href='#'  ahref='" + data.data[i].SubNavMenuList[j].URLStr + "' onclick=addtab(this)>" + data.data[i].SubNavMenuList[j].MenuName + "</a></span>";
                            }
                            if (i == 1) {
                                $('#divmenu').accordion('add', { title: data.data[i].MenuName, content: menuItem, selected: true, iconCls: data.data[i].ItemPic });
                            } else {
                                $('#divmenu').accordion('add', { title: data.data[i].MenuName, content: menuItem, selected: false, iconCls: data.data[i].ItemPic });
                            }

                        }
                    }
                    else {
                        alert(data.message);
                    }
                }

            });
        }

        function getuserinfo() {
            return;
            $.ajax(
                "service/report/User.ashx?action=searchUserInfo"
                , {
                    async: false
                    , cache: false
                    , success: function (data, textStatus, jqXHR) {
                        if (textStatus == "success") {
                            if (data.success) {

                                $("#spuserinfo").html("欢迎[<b>" + data.truename + "</b>]登录系统,登录时间[" + data["logintime"] + "]");
                                $("#linkm").attr("href", "themes/" + data.css + "/easyui.css");
                                $('#csssel').combobox('setValue', data.css);
                            } else {
                                alert("请重新登录");
                                document.location = "Login.aspx";
                            }

                        }
                    }
                    , dataType: "json"
                    , data: {}
                    , type: "post"
                    , processData: true
                }
            ).error(function () { $.messager.alert("getuserinfo", "提交错误了!"); });
        }

        function logout() {
            document.location = "Login.aspx";
        }

        //
        // 页面加载
        //
        $(function () {
            getmenu();
            $("#divwelcome").height($('#divcenter').height() - 41);
            $("#divwelcome").width($('#divcenter').width() - 15);
            $.extend($.messager.defaults, {
                ok: "确定",
                cancel: "取消"
            });


            //修改密码点击
            $('.toppenBtn').first().click(function () {
                isEdit = false;
                $('#w').window('open');

            });

            //修改密码窗口加载
            $('#w').window({
                modal: true,
                closed: true,
                minimizable: false,
                maximizable: false,
                collapsible: false,
                width: 400,
                height: 320,
                footer: '#ft',
                top: 50,
                onBeforeClose: function () { clearw(); },
                onBeforeOpen: function () {
                    $('#w').css('visibility', 'visible');
                }

            });

            //保存按钮
            $('#saveBtn').bind('click', function () {
                SaveInfo();
            });


        });


        function openWindow(title, url, dwidth, dheight) {
            if ($("#Popup").css("display") == "none")
                $("#Popup").css("display", "block");
            $("#Popup").dialog({
                title: title,
                width: dwidth,
                height: dheight,
                modal: true,
                onOpen: function () {

                    $("#PopupUrl").attr("src", url);
                    $("#PopupUrl").attr("width", dwidth - 20);
                    $("#PopupUrl").attr("height", dheight - 40);
                }
            });

        }

        var obj;
        function openWindow_obj(title, url, dwidth, dheight, _obj) {
            if ($("#Popup").css("display") == "none")
                $("#Popup").css("display", "block");
            $("#Popup").dialog({
                title: title,
                width: dwidth,
                height: dheight,
                modal: true,
                onOpen: function () {

                    $("#PopupUrl").attr("src", url);
                    $("#PopupUrl").attr("width", dwidth - 20);
                    $("#PopupUrl").attr("height", dheight - 40);
                    obj = _obj;
                }
            });

        }

        //打开窗口传递参数(不显示关闭按钮)
        function openWindow_obj_(title, url, dwidth, dheight, _obj, isclose) {
            if ($("#Popup").css("display") == "none")
                $("#Popup").css("display", "block");
            $("#Popup").dialog({
                title: title,
                width: dwidth,
                height: dheight,
                modal: true,
                closable: isclose,
                onOpen: function () {

                    $("#PopupUrl").attr("src", url);
                    $("#PopupUrl").attr("width", dwidth - 20);
                    $("#PopupUrl").attr("height", dheight - 40);
                    obj = _obj;
                }
            });

        }


        function tabSelected(title) {
            $(".tabs-panels .panel").each(function () {

                if ($(this).is(':visible')) {
                    if ($(this).children('div').children('iframe')[0] != null) {
                        piframe = $(this).children('div').children('iframe')[0].contentWindow;
                    }
                }
            });
            //alert(title + ' is selected');   
        }

        //弹出更改密码的对话框
        function updatePwd() {
            openWindow("更改密码", "../QYIOnlineManager/UpdatePwd.aspx", 400, 185);
        }

        //清空修改密码输入框
        function clearw() {

            $('#old_password').val('');
            $('#password_1').val('');
            $('#password_2').val('');

        }

        //修改密码
        function SaveInfo() {

           
            var old_password = $('#old_password').val();
            var password_1 = $('#password_1').val();
            var password_2 = $('#password_2').val();
            var userid = $("#<%=txt_UserID.ClientID%>").val();

            if (password_1 != password_2) {
                $.messager.alert('提示', '两次输入的密码不相同,请重新输入', 'warning');
                return;
            }

            var model = {
                old_password: old_password,
                password_1: password_1,
                password_2: password_2,
                userid: userid,
                method: 'SaveInfo'
            };
            SaveModel(model);
        }
        function SaveModel(model) {
            $.ajax({
                type: "POST",
                async: false,
                url: "/HttpHandlers/IndexHandler.ashx",
                data: model,
                success: function (data) {
                    if (data == 'true') {
                        $.messager.alert('提示', '密码已更新成功', 'info');
                        $('#w').window('close');
                    }
                    else {
                        $.messager.alert('提示', '请核对旧密码是否正确', 'warning');
                    }

                },
                error: function () {
                }
            });
        }


    </script>
</head>
<body class="easyui-layout">

    <form id="form1" runat="server">
        <div data-options="region:'north',border:false" style="height: 66px; overflow: hidden; background: url(../SysImages/images/top.jpg)" align="left">
            <div style="float: left; width: 1024px; height: 66px;">
                <div style="margin: 10px 0 0 30px; float: left; width: 51px;height: 52px">
                    <img style="float: left; width: 100%;height: 100%" src="../SysImages/images/logo.png"/>
                </div>
                <div  style="margin: 10px 0 0 50px;height: 52px"> 
                    <span style="height: 100%; font-size: 36px; color: #1256A5; padding-top: 10px;">BBMPT管理系统</span>
                </div>
                
                <%--<span style="float: left; height: 60px; font-size: 36px; color: #1256A5; padding-top: 10px;">BBMPT管理系统</span>--%>
                <%--<img src="../SysImages/images/百分比新的界面.png" alt="" />--%>
            </div>
            <div style="float: right; height: 21px; color: #1256A5; padding-top: 45px;">
                当前用户:<asp:Label ID="lbl_UserName" runat="server" Text="Label"></asp:Label>
                &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <a class="toppenBtn">修改密码</a>
                &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
                <%--登录时间:<asp:Label ID="lbl_LastLoginTime" runat="server" Text=""></asp:Label>,--%>
                <asp:LinkButton ID="lbtn_quit" runat="server" Style="color: #1256A5"
                    OnClick="lbtn_quit_Click" OnClientClick="return confirm('确认退出?');">退出</asp:LinkButton>
                &nbsp;&nbsp;
                <div style="display: none">
                    <asp:TextBox ID="txt_UserID" runat="server"></asp:TextBox>
                </div>
                <%--<asp:Label ID="lbl_UserID" runat="server" Text="Label" Visible="true">aa</asp:Label>--%>
                <%--<a id="lbtn_updatepwd" onclick="updatePwd();" style="color:#fff">更改密码</a>--%>  
            </div>
        </div>
        <div data-options="region:'west',collapsed:false,splite:false,title:'菜单',border:false" style="width: 230px; padding: 0px; border: 0px; height: 100%; background-color: #2a354e;">
            <div id="divmenu" class="easyui-accordion" style="width: 230px; height: auto; border: 0px; color: white; text-align: center;">
            </div>
        </div>
        <div id="divcenter" data-options="region:'center',border:false" style="width: auto;">
            <div id="tabmain" class="easyui-tabs" data-options="onSelect:tabSelected">
                <div title="欢迎" data-options="iconCls:'icon-tip',closable:false" style="padding: 10px; background-image: url('images/welcome_bg.gif'); min-height: 551px;">
                    <div id="divwelcome" style="">
                        <div title="服务器信息" style="padding: 10px;">
                            <p style="font-size: 14px">
                                <asp:Literal ID="ServerInformation" runat="server" Visible="false"></asp:Literal>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            <div id="Popup" style="display: none;">
                <iframe id="PopupUrl" frameborder="0" scrolling="no"></iframe>
            </div>
            <div id="PopupTwo"></div>
        </div>
        <!-- 修改密码窗口 -->
        <div id="w" style="padding: 10px; visibility: hidden" title="编辑">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td class="title">
                        <p>
                            旧密码:
                        </p>
                    </td>
                    <td colspan="2">
                        <input id="old_password" type="password" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
                    </td>
                </tr>

                <tr>
                    <td class="title" style="width: 110px;">
                        <p>
                            新密码:
                        </p>
                    </td>
                    <td colspan="2">
                        <input id="password_1" type="password" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="title" style="width: 110px;">
                        <p>
                            再次输入新密码:
                        </p>
                    </td>
                    <td colspan="2">
                        <input id="password_2" type="password" class="text" style="width: 230px; height: 30px;" /><span style="color: red; font-size: 18px; vertical-align: middle;">*</span>
                    </td>
                </tr>
            </table>
             <div id="ft" style="padding: 50px; text-align: center;" >
            <a class="saveBtn" id="saveBtn">保存</a>
        </div>
        </div>
    </form>
</body>
</html>