<!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-modelVersion-add">
            <input type="hidden" id="projectId" name="projectId" th:value="${modelProject.id}">
            <input type="hidden" id="parentVersionId" name="parentVersionId" th:value="${modelProject.versionId}">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">版本号：</label>
                <div class="col-sm-8">
                    <input name="versionNo" 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">
                    <textarea name="versionRemark" class="form-control" required></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "model/modelVersion"
        $("#form-modelVersion-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var config = {
                    url: prefix + "/add",
                    type: "post",
                    dataType: "json",
                    data: $('#form-modelVersion-add').serialize(),
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍候...");
                        $.modal.disable();
                    },
                    success: function(result) {
                        if (result.code == web_status.SUCCESS) {
                            $.modal.alertSuccess(result.msg)
                            $.modal.close();
                            var parent = activeWindow();
                            parent.location.reload();
                        } else if (result.code == web_status.WARNING) {
                            $.modal.alertWarning(result.msg)
                        }  else {
                            $.modal.alertError(result.msg);
                        }
                        $.modal.closeLoading();
                        $.modal.enable();
                    }
                };
                $.ajax(config)

                // $.operate.saveModal(prefix + "/add", $('#form-modelVersion-add').serialize());
            }
        }
    </script>
</body>
</html>