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

<style>
    .can-login {
        background-color: green;
        color: white;
        padding: 5px;
    }

    .can-not-login {
        background-color: #ddd;
        color: #666;
        padding: 5px;
    }

    .rs_field {
        display: none;
    }

    .et_field {
        display: none;
    }

    .td_label {
        background-color: #f9f9f9;
        width: 120px;
        height: 41px !important;
    }

    textarea {
        width: 90%;
    }

    #tab_2 table {
        border-top: 2px solid #3c8dbc;
    }

    #tab_1 td {
        height: 41px;
    }

    #tab_2 .group-title {
        margin-top: 15px;
        padding-bottom: 5px;
    }

        #tab_2 .group-title .title {
            font-size: 18px;
            margin-right: 20px;
        }

    input[type=text], input[type=password], select {
        width: 140px;
    }

    .login-status {
        width: 24px;
    }
</style>

<div>
    @{
        Com._9pm2.ClientWeb.Models.LoginUser user = Session["LoginUser"] as Com._9pm2.ClientWeb.Models.LoginUser;
    }


    @if (!string.IsNullOrEmpty(ViewBag.message))
    {
        <div class="info-msg" style="display:block;margin-bottom:10px;">@ViewBag.message</div>
    }

    <div class="nav-tabs-custom ">
        <ul class="nav nav-tabs">
            <li class="active"><a href="javascript:void(0)" id="a1">员工基本信息</a></li>
            @if (user.PermissionList.Contains(Com._9pm2.ClientWeb.Common.PT_PermissionType.P5_薪酬配置))
            {
                <li class="">
                    <a href="javascript:void(0)" id="a2">员工薪酬配置</a>
                </li>
            }
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="tab_1">
                <div style="">
                    <span id="basic-message" class="auto-display-message"></span>

                </div>

                <div class="error-msg"></div>
                <table style="margin-bottom:10px;">
                    <tr>

                        <td class="td_label">登录设置</td>
                        <td>
                            <span id="sp_login" class="rs_field">
                                @if (Model.User.IsActive)
                                {
                                    <img src="~/Images/grid/check2.png" title="可正常登录" class="login-status" />
                                }
                                else
                                {
                                    <img src="~/Images/grid/delete2.png" title="禁止登录" class="login-status" />
                                }


                                <span style="height:32px;line-height:32px;display:inline-block">@Model.User.LoginId</span>
                            </span>

                            <span class="et_field">
                                @Html.RadioButtonFor(m => m.User.IsActive, false, new { @id = "IsActive0" }) 禁止登录
                                @Html.RadioButtonFor(m => m.User.IsActive, true, new { @id = "IsActive1" }) 可正常登录 &nbsp;
                                @Html.TextBoxFor(m => m.User.LoginId, new { placeholder = "请输入Email作为登录账号", style = "width:200px", autocomplete = "new-password" })
                                @Html.PasswordFor(m => m.User.Password, new { placeholder = "请输入初始登录密码", style = "width:200px", autocomplete = "new-password" })
                            </span>

                        </td>

                    </tr>
                </table>
                <table>
                    <tr>
                        <td class="td_label">姓名</td>
                        <td>
                            <span class="rs_field">@Model.Employee.EmployeeName</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.EmployeeName) &nbsp;<span class="redStar">*</span>  </span>
                        </td>
                        <td class="td_label">工号</td>
                        <td>
                            <span class="rs_field">@Model.Employee.EmployeeNo</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.EmployeeNo)</span>
                        </td>
                        <td class="td_label">性别</td>
                        <td>
                            <span class="rs_field">@(Model.Employee.Gender == true ? "男" : (Model.Employee.Gender == false ? "女" : ""))</span>
                            <span class="et_field">
                                @Html.RadioButtonFor(m => m.Employee.Gender, true, new { @id = "Gendear1", @name = "Gendear1" }) 男&nbsp;
                                @Html.RadioButtonFor(m => m.Employee.Gender, false, new { @id = "Gendear0", @name = "Gendear0" }) 女&nbsp;<span class="redStar">*</span>
                            </span>
                        </td>
                    </tr>

                    <tr>
                        <td class="td_label">部门</td>
                        <td>
                            <span class="rs_field">@(Model.Employee.Department == null ? "" : Model.Employee.Department.DepartmentName)</span>
                            <span class="et_field">
                                @Html.DropDownListFor(m => m.Employee.DepartmentId, new SelectList(Model.DdlDepartment, "ItemValue", "ItemText"))
                                &nbsp;<span class="redStar">*</span>
                            </span>
                        </td>
                        <td class="td_label">出生日期</td>
                        <td>
                            <span class="rs_field">@(Model.Employee.Birthday.HasValue ? Model.Employee.Birthday.Value.ToString("yyyy-MM-dd") : "")</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.Birthday, new { maxlength = "50", @class = "text-date-1", Value = Model.Employee.Birthday.HasValue ? Model.Employee.Birthday.Value.ToString("yyyy-MM-dd") : "" })</span>
                        </td>
                        <td class="td_label">身份证号</td>
                        <td>
                            <span class="rs_field">@Model.Employee.IdCardNo</span>
                            <span class="et_field">
                                <span class="et_field">@Html.TextBoxFor(m => m.Employee.IdCardNo, new { style = "width:180px" })</span>
                            </span>
                        </td>
                    </tr>


                    <tr>
                        <td class="td_label">员工类型</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeType)Model.Employee.EmployeeType).ToString())</span>
                            <span class="et_field">
                                @Html.DropDownListFor(m => m.Employee.EmployeeType, new SelectList(Model.DdlEmployeeType, "ItemValue", "ItemText"))
                                &nbsp;<span class="redStar">*</span>
                            </span>
                        </td>
                        <td class="td_label">员工状态</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeStatus)Model.Employee.EmployeeStatus).ToString())</span>
                            <span class="et_field">
                                @Html.DropDownListFor(m => m.Employee.EmployeeStatus, new SelectList(Model.DdlEmployeStatus, "ItemValue", "ItemText"))
                                &nbsp;<span class="redStar">*</span>
                            </span>
                        </td>
                        <td class="td_label">员工职位</td>
                        <td>
                            <span class="rs_field">@Model.Employee.Position</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.Position, new { style = "width:180px" })</span>
                        </td>
                    </tr>


                    <tr>
                        <td class="td_label">办公电话</td>
                        <td>
                            <span class="rs_field">@Model.Employee.OfficePhone</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.OfficePhone)</span>
                        </td>
                        <td class="td_label">手机号</td>
                        <td>
                            <span class="rs_field">@Model.Employee.Mobile</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.Mobile)</span>
                        </td>
                        <td class="td_label">Email</td>
                        <td>
                            <span class="rs_field">@Model.Employee.Email</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.Email, new { style = "width:180px" })</span>
                        </td>
                    </tr>

                    <tr>
                        <td class="td_label">学历</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeQualification)Model.Employee.Qualifications).ToString())</span>
                            <span class="et_field">@Html.DropDownListFor(m => m.Employee.Qualifications, new SelectList(Model.DdlQualifications, "ItemValue", "ItemText"))</span>
                        </td>
                        <td class="td_label">国籍</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeCountry)Model.Employee.Country).ToString())</span>
                            <span class="et_field">@Html.DropDownListFor(m => m.Employee.Country, new SelectList(Model.DdlCountry, "ItemValue", "ItemText"))</span>
                        </td>
                        <td class="td_label">民族</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeNationality)Model.Employee.Nationality).ToString())</span>
                            <span class="et_field">@Html.DropDownListFor(m => m.Employee.Nationality, new SelectList(Model.DdlNationality, "ItemValue", "ItemText"))</span>
                        </td>
                    </tr>


                    <tr>
                        <td class="td_label">政治面貌</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeePoliticsStatus)Model.Employee.PoliticsStatus).ToString())</span>
                            <span class="et_field">@Html.DropDownListFor(m => m.Employee.PoliticsStatus, new SelectList(Model.DdlPoliticsStatus, "ItemValue", "ItemText"))</span>
                        </td>
                        <td class="td_label">婚姻状况</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeMaritalStatus)Model.Employee.MaritalStatus).ToString())</span>
                            <span class="et_field">@Html.DropDownListFor(m => m.Employee.MaritalStatus, new SelectList(Model.DdlMaritalStatus, "ItemValue", "ItemText"))</span>
                        </td>
                        <td class="td_label">户口所在地</td>
                        <td>
                            <span class="rs_field">@Model.Employee.HuKou</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.HuKou)</span>
                        </td>
                    </tr>

                    <tr>
                        <td class="td_label">入职日期</td>
                        <td>
                            <span class="rs_field">@(Model.Employee.OnboardDate.HasValue ? Model.Employee.OnboardDate.Value.ToString("yyyy-MM-dd") : "")</span>
                            <span class="et_field">
                                @Html.TextBoxFor(m => m.Employee.OnboardDate, new { maxlength = "50", @class = "text-date-1", Value = Model.Employee.OnboardDate.HasValue ? Model.Employee.OnboardDate.Value.ToString("yyyy-MM-dd") : "" })
                                &nbsp;<span class="redStar">*</span>
                            </span>
                        </td>
                        <td class="td_label">转正日期</td>
                        <td>
                            <span class="rs_field">@(Model.Employee.PositiveDate.HasValue ? Model.Employee.PositiveDate.Value.ToString("yyyy-MM-dd") : "")</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.PositiveDate, new { maxlength = "50", @class = "text-date-1", Value = Model.Employee.PositiveDate.HasValue ? Model.Employee.PositiveDate.Value.ToString("yyyy-MM-dd") : "" })</span>
                        </td>
                        <td class="td_label">离职日期</td>
                        <td>
                            <span class="rs_field">@(Model.Employee.LeaveDate.HasValue ? Model.Employee.LeaveDate.Value.ToString("yyyy-MM-dd") : "")</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.LeaveDate, new { maxlength = "50", @class = "text-date-1", Value = Model.Employee.LeaveDate.HasValue ? Model.Employee.LeaveDate.Value.ToString("yyyy-MM-dd") : "" })</span>
                        </td>
                    </tr>

                    <tr>
                        <td class="td_label">紧急联系人</td>
                        <td>
                            <span class="rs_field">@Model.Employee.EmergencyContact</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.EmergencyContact)</span>
                        </td>
                        <td class="td_label">关系</td>
                        <td>
                            <span class="rs_field">@(((Com._9pm2.ClientWeb.Common.EmployeeEmergencyRelation)Model.Employee.EmergencyRelation).ToString())</span>
                            <span class="et_field">@Html.DropDownListFor(m => m.Employee.EmergencyRelation, new SelectList(Model.DdlEmergencyRelation, "ItemValue", "ItemText"))</span>
                        </td>
                        <td class="td_label">联系人手机</td>
                        <td>
                            <span class="rs_field">@Model.Employee.EmergencyPhone</span>
                            <span class="et_field">@Html.TextBoxFor(m => m.Employee.EmergencyPhone)</span>
                        </td>

                    </tr>

                    <tr>
                        <td class="td_label">家庭住址</td>
                        <td>
                            <span class="rs_field">@Model.Employee.FamilyAddress</span>
                            <span class="et_field">@Html.TextAreaFor(m => m.Employee.FamilyAddress)</span>
                        </td>

                        <td class="td_label">备注</td>
                        <td colspan="3">
                            <span class="rs_field">@Model.Employee.Memo</span>
                            <span class="et_field">@Html.TextAreaFor(m => m.Employee.Memo)</span>
                        </td>

                    </tr>


                </table>

                <div style="text-align:right;padding:10px 0">
                    <button type="button" class="btn btn-primary" style="display:none" id="btnSaveBasicInfo" onclick="SaveBasicInfo()">保存</button>
                    <button type="button" class="btn btn-primary" style="display:none" id="btnEditBasicInfo" onclick="EditBasicInfo()">编辑</button>
                    <button type="button" class="btn btn-default" style="display:none" id="btnCancelBasicInfo" onclick="CancelBasicInfo()">取消</button>
                    <button type="button" class="btn btn-default" style="display:none" id="btnReturnBasicInfo">返回</button>
                </div>
            </div>
            <!-- /.tab-pane -->
            <div class="tab-pane" id="tab_2">
                <div class="group-title">
                    <span class="title">基本配置</span>
                    <button class="btn btn-primary" onclick="SaveBasicSetting()">保存</button>
                    <span id="message-1" class="auto-display-message"></span>
                </div>

                <table class="tableEdit" id="table_basic">
                    <tr>
                        <td class="td_label">
                            基本工资
                        </td>
                        <td>
                            @Html.TextBoxFor(m => m.BaseSalary)<span class="redStar">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="td_label">
                            社会保险缴存基数
                        </td>
                        <td>
                            @Html.TextBoxFor(m => m.InsuranceBase)<span class="redStar">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="td_label">
                            公积金缴存基数
                        </td>
                        <td>
                            @Html.TextBoxFor(m => m.HouseFundBase)<span class="redStar">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="td_label">
                            是否计算薪酬
                        </td>
                        <td>
                            @Html.CheckBoxFor(m => m.HasSalary)
                        </td>
                    </tr>
                    <tr>
                        <td class="td_label">
                            是否缴纳五险
                        </td>
                        <td>
                            @Html.CheckBoxFor(m => m.HasInsurance)
                        </td>
                    </tr>
                    <tr>
                        <td class="td_label">
                            是否缴纳公积金
                        </td>
                        <td>
                            @Html.CheckBoxFor(m => m.HasHouseFund)
                        </td>
                    </tr>
                    <tr>
                        <td class="td_label">
                            是否缴纳个税
                        </td>
                        <td>
                            @Html.CheckBoxFor(m => m.HasTax)
                        </td>
                    </tr>


                </table>

                <div class="group-title">
                    <span class="title">五险一金缴存比例</span>
                    <button class="btn btn-primary" onclick="Save5x1j()">保存</button>
                    <span id="message-2" class="auto-display-message"></span>
                </div>
                <table class="tableEdit" id="table_5x1j">
                    <thead>
                        <tr>
                            <th>险种</th>
                            <th>个人缴存比例</th>
                            <th>公司缴存比例</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="td_label">
                                养老保险
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.YangLao1, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.YangLao2, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_label">
                                医疗保险
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.YiLiao1, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.YiLiao2, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>

                        </tr>
                        <tr>
                            <td class="td_label">
                                生育保险
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.ShengYu1, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.ShengYu2, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>

                        </tr>
                        <tr>
                            <td class="td_label">
                                工伤保险
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.GongShang1, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.GongShang2, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>

                        </tr>
                        <tr>
                            <td class="td_label">
                                失业保险
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.ShiYe1, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.ShiYe2, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_label">
                                住房公积金
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.HouseFund1, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>
                            <td>
                                @Html.TextBoxFor(m => m.HouseFund2, new { @class = "amount" }) % &nbsp;<span class="redStar"></span>
                            </td>

                        </tr>

                    </tbody>
                </table>


                <div class="group-title">
                    <span class="title">津贴项目</span>
                    <button type="button" class="btn btn-primary" onclick="NewAllowance()">新增</button>
                </div>

                <table>
                    <thead>
                        <tr class="title">
                            <th>津贴名称</th>
                            <th>金额</th>
                            <th style="width:120px"></th>
                        </tr>
                    </thead>
                    <tbody id="tbodyAllowance">
                        @{
                            var list = Model.Employee.EmployeeSalarySetting.Where(m => m.SettingType == (int)Com._9pm2.ClientWeb.Common.SalarySettingType.津贴).ToList();
                            foreach (var a in list)
                            {
                                <tr id="@a.Id">
                                    <td>@a.SettingName</td>
                                    <td>@a.SettingValue</td>
                                    <td>
                                        <a href="javascript:void(0)" onclick="EditAllowance(@a.Id,'@a.SettingName','@a.SettingValue')">编辑</a>
                                        <a href="javascript:void(0)" onclick="DeleteAllowance(@a.Id)">删除</a>
                                    </td>
                                </tr>
                            }
                        }

                    </tbody>
                </table>

                <div class="group-title">
                    <span class="title">扣款项目</span>
                    <button type="button" class="btn btn-primary" onclick="NewDeduct()">新增</button>
                </div>
                <table>
                    <thead>
                        <tr class="title">
                            <th>扣款名称</th>
                            <th>金额</th>
                            <th style="width:120px"></th>
                        </tr>
                    </thead>
                    <tbody id="tbodyDeduct">
                        @{
                            var list1 = Model.Employee.EmployeeSalarySetting.Where(m => m.SettingType == (int)Com._9pm2.ClientWeb.Common.SalarySettingType.扣款).ToList();
                            foreach (var a in list1)
                            {
                                <tr id="@a.Id">
                                    <td>@a.SettingName</td>
                                    <td>@a.SettingValue</td>
                                    <td>
                                        <a href="javascript:void(0)" onclick="EditDeduct(@a.Id,'@a.SettingName','@a.SettingValue')">编辑</a>
                                        <a href="javascript:void(0)" onclick="DeleteDeduct(@a.Id)">删除</a>
                                    </td>
                                </tr>
                            }
                        }
                    </tbody>
                </table>
            </div>

        </div>
        <!-- /.tab-content -->
    </div>


</div>

<div id="divAllowance" title="津贴项目" style="display:none">
    <div id="divAllowanceContent">
        @using (Html.BeginForm())
        {
            <table id="tableEdit" class="font85 tableEdit">
                <tr>
                    <td class="label">津贴名称</td>
                    <td>
                        @Html.TextBox("AllowanceName", null, new { maxlength = "100", @style = "width:160px" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">金额</td>
                    <td>
                        @Html.TextBox("AllowanceAmount", null, new { maxlength = "100", @style = "width:160px", @class = "amount" }) /月 &nbsp;<span class="redStar">*</span>
                    </td>
                </tr>

            </table>
        }
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        @Html.Hidden("AllowanceId")
        <button type="button" class="btn btn-default" onclick="$('#divAllowance').dialog('close');">关闭</button>
        <button type="button" class="btn btn-primary" onclick="SaveAllowance()">保存</button>

    </div>
</div>


<div id="divDeduct" title="扣款项目" style="display:none">
    <div id="divDeductContent">
        @using (Html.BeginForm())
        {
            <table id="tableEdit" class="font85 tableEdit">
                <tr>
                    <td class="label">扣款名称</td>
                    <td>
                        @Html.TextBox("DeductName", null, new { maxlength = "100", @style = "width:160px" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">金额</td>
                    <td>
                        @Html.TextBox("DeductAmount", null, new { maxlength = "100", @style = "width:160px", @class = "amount" }) /月 &nbsp;<span class="redStar">*</span>
                    </td>
                </tr>

            </table>
        }
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        @Html.Hidden("DeductId")
        <button type="button" class="btn btn-default" onclick="$('#divDeduct').dialog('close');">关闭</button>
        <button type="button" class="btn btn-primary" onclick="SaveDeduct()">保存</button>

    </div>
</div>


@Html.HiddenFor(m => m.Employee.Id)
@Html.HiddenFor(m => m.User.IsAdmin)
