@model Com._9pm2.ClientWeb.Models.EmployeeList
@{
    ViewBag.Title = "员工管理";
}
<script src="../../Scripts/employee.js?vn=20180813"></script>

<form method="post" action="/HR/Employee">
    <div class="divSearch">
        <div>
            @Html.DropDownList("sDepartmentId", new SelectList(Model.DdlDepartment, "ItemValue", "ItemText"))
            @Html.TextBox("sKeywords", null, new { maxlength = "50", placeholder = "关键字" })
            <button class="btn btn-default" id="btnSearch">搜索</button>
            <button id="btnNew" type="button" class="btn btn-default">新增</button>
        </div>
    </div>
</form>

<div class="error-msg"></div>

<div class="list">
    <table id="tEmployee" class="">
        <thead>
            <tr>
                <th>姓名</th>
                <th>工号</th>
                <th>部门</th>
                <th>职位</th>
                <th>状态</th>
                <th>登录账号</th>
                <th style="width:120px;">操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Employees)
            {
                <tr class="specify" id="@item.UserId">
                    <td>
                        <a href="/HR/EmployeeDetail/@item.Employee.Id">@item.Employee.EmployeeName</a>
                        @if (item.IsAdmin)
                        {
                            <span class="is-admin">管理员</span>
                        }
                        @if (!item.IsActive)
                        {
                            <span class="is-no-login">禁止登录</span>
                        }
                    </td>
                    <td>@item.Employee.EmployeeNo</td>
                    <td>@item.Employee.Department.DepartmentName</td>
                    <td>@item.Employee.Position</td>
                    <td>@(((Com._9pm2.ClientWeb.Common.EmployeeStatus)item.Employee.EmployeeStatus).ToString())</td>
                    <td>
                        @if (item.IsActive)
                        {
                            @item.LoginId
                        }
                    </td>

                    <td style="text-align:center">

                        <div class="operation-btns">
                            <div>
                                <button id="select">&nbsp;</button>
                            </div>
                            <ul>

                                <li><a href="/HR/EmployeeDetail/@item.Employee.Id">详情</a></li>

                                @if (!item.IsAdmin)
                                {
                                    <li><a href="javascript:void(0);" onclick="DeleteEmployee('@item.Employee.Id');">删除</a></li>
                                    if (item.IsActive)
                                    {
                                        <li><a href="javascript:void(0);" onclick="EditPermission('@item.UserId');">授权</a></li>
                                        <li><a href="javascript:void(0);" onclick="CopyPermission('@item.UserId','@item.UserName');">复制授权</a></li>
                                    }
                                }

                                <li><a href="javascript:void(0);" onclick="ResetUserPassword('@item.UserId','@item.Employee.EmployeeName');">重置密码</a></li>

                            </ul>
                        </div>
                    </td>
                </tr>
            }
        </tbody>
    </table>
    @Html.Pager("Employee", "HR", Model.RouterDirectory, Model.PagerConfig, "pagerDiv", "pagerDiv", 8, true, false, true, true, false)
</div>



<div id="divPermission" title="用户权限" style="display:none">
    <div id="divPermissionContent" style="margin-bottom:15px;">
        <div style="border:1px;overflow:hidden; border-color:Blue;border-bottom: 2px solid #1D6387; padding-bottom:2px;padding-left:2px;">
            <input type="checkbox" id="chkAll" />&nbsp;全选
        </div>
        @foreach (Com._9pm2.ClientWeb.Models.RoleGroupModel rg in Model.RoleGroups)
            {
            <div class="groupPermission">
                <div style="clear:both;font-weight:bold; padding:5px;position:relative;">
                    <span style="margin-left:15px;">@rg.RoleGroupName</span>
                    <input type="checkbox" style="left:2px; top:5px;position :absolute; " id="chkGroupAll" />
                </div>
                <div style="border:1px;overflow:hidden; border-color:Blue;border-bottom: 2px solid #1D6387; padding-bottom:2px;">
                    @foreach (Com._9pm2.ClientWeb.Models.PermissionModel p in rg.Permissions)
                {
                        <div style="float:left; margin-right:10px; width:130px;padding:2px;">
                            <input class="chkSingle" type="checkbox" id="@p.PermissionNo" /> @p.PermissionName
                        </div>
                    }
                </div>
            </div>
        }

    </div>
    <div style="text-align:right;">
        <div style="text-align:right;">
            <div class="error-msg"></div>
            <button class="btn btn-primary" type="button" id="btnSavePermission">保存</button>
            <button class="btn btn-default" type="button" id="btnCancelPermission" onclick="closePermission();">取消</button>
        </div>
    </div>
</div>


<div id="divPassword" title="重置密码" style="display:none">
    <div id="divPasswordContent">

        <table id="tableEdit" class="font85 tableEdit">
            <tr>
                <td class="label" style="height:41px">新密码</td>
                <td>
                    <input type="password" id="newPassword" placeholder="请输入新密码" />&nbsp;<span class="redStar">*</span>
                </td>
            </tr>

        </table>
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        <button class="btn btn-default" type="button" onclick="$('#divPassword').dialog('close');">关闭</button>
        <button class="btn btn-primary" type="button" onclick="SavePassword()">保存</button>
    </div>
</div>

<div id="divCopyPermission" title="复制授权" style="display:none">
    <div id="divCopyPermissionContent">
        <div class="">提示：复制完成后，目标用户将拥有和源用户完全一致的权限。</div>
        <table id="tableEdit" class="font85 tableEdit">
            <tr>
                <td class="label" style="height:41px">源用户</td>
                <td>
                    @Html.DropDownList("sUserId", new SelectList(Model.DdlUser, "ItemValue", "ItemText"))&nbsp;<span class="redStar">*</span>
                </td>
            </tr>
            <tr>
                <td class="label" style="height:41px">目标用户</td>
                <td>
                    <span id="destinationUserName"></span>
                    <input type="hidden" id="destinationUserId" />
                </td>
            </tr>

        </table>
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        <button class="btn btn-default" type="button" onclick="$('#divCopyPermission').dialog('close');">关闭</button>
        <button class="btn btn-primary" type="button" onclick="SaveCopiedPermission()">保存</button>
    </div>

</div>
@Html.Hidden("UserId")