<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>id</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_id" name="id" required="" autocomplete="off"
                           class="layui-input layui-disabled" disabled th:value="${company.id}"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>账号</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_username" name="username" disabled required="" lay-verify="username"
                           autocomplete="off"
                           class="layui-input layui-disabled" th:value="${company.username}"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_company" class="layui-form-label">
                    <span class="x-red">*</span>公司名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_company" name="companyName" required="" lay-verify=""
                           autocomplete="off" class="layui-input" th:value="${company.name}"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_district" class="layui-form-label">
                    <span class="x-red">*</span>地区</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_district" name="district" required="" lay-verify=""
                           autocomplete="off" class="layui-input" th:value="${company.district}"></div>
                <div class="layui-form-mid layui-word-aux">xx省xx市</div>
            </div>
            <div class="layui-form-item">
                <label for="L_detailedAddress" class="layui-form-label">
                    <span class="x-red">*</span>具体地址</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_detailedAddress" name="detailedAddress" required="" lay-verify=""
                           autocomplete="off" class="layui-input" th:value="${company.detailedAddress}"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_contact" class="layui-form-label">
                    <span class="x-red">*</span>联系人</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_contact" name="contact" required="" lay-verify="contact"
                           autocomplete="off" class="layui-input" th:value="${company.contact}"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_phone" class="layui-form-label">
                    <span class="x-red">*</span>联系方式</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_phone" name="phone" required="" lay-verify="phone"
                           autocomplete="off" class="layui-input" th:value="${company.phone}"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="edit" lay-submit="">修改</button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer', 'jquery'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            username: function (value) {
                if (value.length < 5) {
                    return '账号只能5到10个字符';
                }
            },
            pass: [/(.+){6,12}$/, '密码必须6到12位'],
            // repass: function (value) {
            //     if ($('#L_pass').val() != $('#L_repass').val()) {
            //         return '两次密码不一致';
            //     }
            // }
            contact: function (value) {
                console.log(value)
                console.log(value.length)
                if (value.length > 4 || value.length < 2) {
                    return '联系人最少2个字符，最多4个字符'
                }
            },
            phone: [/^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/, '请正确输入手机号']
        });

        //监听提交
        form.on('submit(edit)',
            function (data) {
                $.ajax({
                    url: "[[${#request.contextPath}]]" + '/operator/edit',
                    data: JSON.stringify(data.field),
                    method: "post",
                    contentType: "application/json;charset=UTF-8", //定义数据格式为JSON
                    success: function (data) {
                        if (data.code == 0) {
                            //发异步，把数据提交给php
                            layer.alert(data.data, {
                                    icon: 6
                                },
                                function () {
                                    //关闭当前frame
                                    xadmin.close();

                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                        }
                    }
                })
                return false;
            });

    });</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>