<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('复制数据')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-modelEntity-copy" th:object="${modelEntity}">
        <input type="hidden" id="projectId" name="projectId" th:value="${modelProject.id}">
        <input type="hidden" id="orgEntityId" name="orgEntityId" th:value="${modelProject.orgEntityid}">

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">表名称：</label>
            <div class="col-sm-8">
                <input id="entityName" name="entityName" th:field="*{entityName}" placeholder="表名称" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">表逻辑名：</label>
            <div class="col-sm-8">
                <input id="entityCode" name="entityCode" th:field="*{entityCode}"  placeholder="m_tablename" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">
                <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "model/modelEntity"
    $("#form-modelEntity-add").validate({
        onkeyup: false,
        rules:{
            entityCode:{
                maxlength: 50,
                remote: {
                    url: prefix + "/checkEntityCodeUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "projectId":$("#projectId").val(),
                        "entityCode": function() {
                            return $.common.trim($("#entityCode").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            entityName:{
                maxlength: 25
            },
            remark:{
                maxlength: 100
            },
        },
        messages: {
            "entityCode": {
                remote: "数据表已经存在"
            },
        },
        focusCleanup: true
    });

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