<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html >
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>用户详情</title>
    <link rel="stylesheet" href="${ctx}/js/plugin/layerui/css/layui.css"
          media="all">
    <link rel="stylesheet"
          href="${ctx}/css/plugin/bootstrap/bootstrap.min.css">
    <link rel="stylesheet"
          href="${ctx}/css/plugin/datatables/datatables.bootstrap.css">
    <link rel="stylesheet"
          href="${ctx}/css/plugin/datatables/buttons.dataTables.min.css">
    <link rel="stylesheet" href="${ctx}/css/basic.css">
    <style type="text/css">
        html {
            overflow: hidden;
        }

        .btn {
            padding: 1px 9px !important;
            font-size: 12px !important
        }

        .align-center {
            margin: 0 auto; /* 居中 这个是必须的，，其它的属性非必须 */
            text-align: center; /* 文字等内容居中 */
        }
    </style>
</head>
<body class="bg-white">
<div >
    <div style="width:45%;float: left;">
        <label class="layui-form-label" style="margin-top: 10px; ">昵称:</label>
        <input type="text" id="name" autocomplete="off" maxlength="200" style="margin-top: 7%" disabled>

    </div>
    <div style="width:45%;margin-left: -60px;float: right;">
        <label class="layui-form-label" style="margin-top: 10px">登录名:</label>
        <input type="text" id="loginName" disabled autocomplete="off" style="margin-top: 7%" maxlength="50">
    </div>
    <div style="width:45%;float: left;">
        <label class="layui-form-label" style="margin-top: 10px; ">部门:</label>
        <input type="text" id="deptsName" autocomplete="off" maxlength="200" style="margin-top: 7%" disabled>
    </div>
    <div  style="width:45%;margin-left: -60px;float: right;">
        <label class="layui-form-label" style="margin-top: 10px">角色:</label>
        <input type="text" id="roleName" disabled autocomplete="off" style="margin-top: 7%" maxlength="50">
    </div>
<div>
    <button type="button" class="layui-btn themeBGColor"
            id="updatetUser"
            style="margin-top: 25%;">修改密码
    </button>
</div>

</div>
<%--当前会话的用户名--%>
<input type="hidden" id="username" value="${username}">
<input type="hidden" id="userIndex" value="${userIndex}">
<script src="${ctx}/js/plugin/jquery.min.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${ctx}/js/plugin/layerui/layer.js"></script>
<script src="${ctx}/js/basic.js"></script>
<script src="${ctx}/js/plugin/xss/xss.js"></script>
<script src="${ctx}/jspJS/utils/judgeAjaxStatus.js"></script>
<script src="${ctx}/js/plugin/xss/aes.js"></script>
<script src="${ctx}/jspJS/sm2.js"></script>
<script src="${ctx}/jspJS/sm3.js"></script>
<script src="${ctx}/js/plugin/xss/security.js"></script>
<script src="${ctx}/jspJS/confirmIndentity.js"></script>
<script>
    var userIndex = $("#userIndex").val();
    $(function () {
        getUserAll(userIndex);
    })
    function getUserAll(userIndex) {
        $.ajax({
            type: 'POST',
            async: false,
            url: '/pqs9200/device/getUserAll',
            data: {
                userIndex:userIndex
            },
            success: function (data) {
                if(data!=null){
                    $("#name").val(data.userName);
                    $("#loginName").val(data.loginName);
                    $("#deptsName").val(data.deptsName);
                    $("#roleName").val(data.roleName);
                }
            }
        })
    }

    $("#updatetUser").click(function () {
        updateUserPassWordByIndex(userIndex);
    })

    //修改密码
    function updateUserPassWordByIndex(index) {
        //先进行密码确认
        var username = $("#username").val();
        confirmIndentity(username, function () {
            parent.layer.open({
                type: 2,
                title: '修改密码',
                shadeClose: true,
                resize: false,
                shade: 0.3,
                area: ['20%', '32%'],
                content: 'updatePassWord?userIndex='+index, //iframe的url
                scrollbar: false,
                end: function () {
                    layer.close();
                }
            });
        })
    }
</script>
</body>
</html>