<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改商户')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-merchant-edit" th:object="${merchant}">
            <input name="mercId" th:field="*{mercId}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">商户名称：</label>
                    <div class="col-sm-8">
                        <input name="mercName" th:field="*{mercName}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">商户状态：</label>
                    <div class="col-sm-8">
                        <select name="mercStatus" class="form-control m-b" th:with="type=${@dict.getType('merc_status')}" th:field="*{mercStatus}">
                            <option value="">-</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">商户类型：</label>
                    <div class="col-sm-8">
                        <select name="mercType" class="form-control m-b" th:with="type=${@dict.getType('merc_type')}" th:field="*{mercType}">
                            <option value="">-</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">联系人：</label>
                    <div class="col-sm-8">
                        <input name="contact" th:field="*{contact}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">联系信箱：</label>
                    <div class="col-sm-8">
                        <input name="mail" th:field="*{mail}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">手机号：</label>
                    <div class="col-sm-8">
                        <input name="mobile" th:field="*{mobile}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">通信地址：</label>
                    <div class="col-sm-8">
                        <input name="address" th:field="*{address}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">个人名字：</label>
                    <div class="col-sm-8">
                        <input name="personName" th:field="*{personName}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">身份证号：</label>
                    <div class="col-sm-8">
                        <input name="idNumber" th:field="*{idNumber}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">公司名称：</label>
                    <div class="col-sm-8">
                        <input name="companyName" th:field="*{companyName}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">纳税人识别号：</label>
                    <div class="col-sm-8">
                        <input name="companyCode" th:field="*{companyCode}" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "master/merchant";
        $("#form-merchant-edit").validate({
            rules: {
                mercName: {
                    required: true,
                },
                mercStatus: {
                    required: true,
                },
                mercType: {
                    required: true,
                },
                contact: {
                    required: true,
                },
                mail: {
                    required: true,
                    email: true,
                },
                mobile: {
                    required: true,
                    isPhone: true,
                },
                address: {
                    required: true,
                },
                personName: {
                    required: true,
                },
                idNumber: {
                    required: true,
                    isIdentity: true,
                },
                companyName: {
                    required: true,
                },
                companyCode: {
                    required: true,
                    minlength:15,
                    maxlength:18,
                },
            },
            messages: {
                mercName: {
                    required: icon + "请输入商户名称",
                },
                mercStatus: {
                    required: icon + "请选择商户状态",
                },
                mercType: {
                    required: icon + "请选择商户类型",
                },
                contact: {
                    required: icon + "请输入联系人",
                },
                mail: {
                    required: icon + "请输入联系信箱",
                    email: icon + "请填写正确的邮箱格式",
                },
                mobile: {
                    required: icon + "请输入手机号",
                    isPhone: icon + "请填写正确的11位手机号",
                },
                address: {
                    required: icon + "请输入通信地址",
                },
                personName: {
                    required: icon + "请输入个人名字",
                },
                idNumber: {
                    required: icon + "请输入身份证号",
                    isIdentity: icon + "请输入正确的身份证号,末尾若为X请大写",
                },
                companyName: {
                    required: icon + "请输入公司名称",
                },
                companyCode: {
                    required: icon + "请输入纳税人识别号",
                    minlength: icon + "纳税人识别号最小长度为15位",
                    maxlength: icon + "纳税人识别号最大长度为18位",
                },
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-merchant-edit').serialize());
            }
        }
    </script>
</body>
</html>