<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <style>
        .layui-form-select dl{
            max-height:200px;
            width: 80%;
        }
    </style>
</head>
<body>
<div class="aaa">
    <div class="layui-card">
        <form class="layui-form layui-card-body over pt-20 pb-40 h-250" action="" id="detailSet">
            <div class="layui-col-xs12 mb-15 pr-30">
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>姓名：</label>
                    <div class="layui-input-block w-200" >
                        <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入姓名" class="layui-input" value="${emp.name}">
                    </div>
                </div>
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>手机号：</label>
                    <div class="layui-input-block w-200">
                        <input type="text" name="mobile" lay-verify="mobile" autocomplete="off" placeholder="请输入手机号" class="layui-input" value="${emp.mobile}">
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 mb-10 pr-30">

                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>工号：</label>
                    <div class="layui-input-block w-200" >
                        <input type="text" name="jobNumber" lay-verify="required"  autocomplete="off" class="layui-input" value="${emp.jobNumber}">
                    </div>
                </div>
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130">入职时间：</label>
                    <div class="layui-input-block w-200" >
                        <input type="text" name="inductionTime" autocomplete="off"  class="layui-input" id="inductionTime" placeholder="入职时间" value="${emp.inductionTime}">
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 mb-10 pr-30">
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>登录账号：</label>
                    <div class="layui-input-block w-200">
                        <input type="text"  name="loginName" lay-verify="loginName" autocomplete="off" placeholder="请输入登录账号" class="layui-input" value="${user.loginName}">
                    </div>
                </div>
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label w-130"><i class="red">*</i>登录密码：</label>
                    <div class="layui-input-block w-200" >
                        <input type="password" name="password" lay-verify="password" autocomplete="new-password" placeholder="请输入登录密码" class="layui-input" <c:if test="${user.password eq null}">value=""</c:if> value="default">
                    </div>
                </div>
                <div class="layui-inline layui-col-xs6">
                    <label class="layui-form-label">浏览权限：</label>
                    <div class="layui-input-block" >
                        <input type="checkbox" name="isBrowse" title="是" <c:if test="${emp.isBrowse eq '2'}"> checked</c:if> value="2">
                    </div>
                </div>
            </div>
            <input type="hidden" name="id" id="id" value="${emp.id}">
            <div class="layui-col-xs12 mb-20 pr-30 mt-20">
                <div class="layui-form-item " style="text-align: center;">
                    <input type="button" lay-submit lay-filter="confirm" id="confirm" class="layui-btn " value="保存">
                    <input type="button"   value="取消" class="layui-btn layui-btn-primary " onclick="closeDiv();" >
                </div>
            </div>
        </form>
    </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    //初始数据
    var $form;
    var form;
    var $;

    var imgs='';
    var myreg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    var reg =/^(0|[1-9][0-9]*)(\.\d+)?$/;
    layui.use(['form','laydate', 'jquery'], function () {
        $ = layui.jquery;
        form = layui.form;
        laydate = layui.laydate;
        $form = $('form');


        form.verify({
            loginName:function(value,item){
                if(!$.trim(value)){
                    return "登录账号不能为空,请输入账号后保存！";
                }
                if($.trim(value).length<6){
                    return "登录账号不得小于6位,请重新输入！";
                }
            },
            password:function(value,item){
                if(!$.trim(value)){
                    return "登录密码不能为空,请输入登录密码后保存！";
                }
            },
            name:function(value,item){
                if(!$.trim(value)){
                    return "姓名不能为空,请输入姓名后保存！";
                }
            },
            mobile:function(value,item){
                if(!$.trim(value)){
                    return "手机号码不能为空,请输入手机号码后保存！";
                }
                if(!myreg.test($.trim(value))){
                    return "请输入正确的手机号码后保存！";
                }
            }


        });

       laydate.render({
            elem: '#inductionTime'
           ,trigger: 'click'
          // ,type: 'datetime'
        });

        form.on('submit(confirm)', function(data){
            console.log(data)
            if(isBlank(data.field.isBrowse)){
                data.field.isBrowse ='1';
            }
            $.ajax({
                url:'${ctx}/partnerStaff/employeSave',
                method:'post',
                data:data.field,
                dataType:'JSON',
                success:function(res){
                    console.log(res);
                    if(res.code=="200"){
                        layer.msg("保存成功",{time:1000});
                        closeDiv();
                        parent.table.reload('test');
                    }else if(res.code=="201") {
                        layer.msg("该登录账号已存在，请重新输入",{time:1500});
                    }else if(res.code=="203") {
                        layer.msg("该工程师姓名已存在，请重新输入",{time:1500});
                    }else{
                        layer.msg("保存失败",{time:1000});
                    }
                },
                error:function (data) {
                }
            }) ;
        });

    })

    function  closeDiv() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }



</script>
</body>
</html>
