<!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-base_type-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">设备类型名称：</label>
                    <div class="col-sm-8">
                        <input name="deviceTypeName" id="deviceTypeName" class="form-control" type="text" required>
                    </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="defaultPrice" 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="defaultTime" 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">
                        <textarea class="form-control" id="remark" name="remark" type="text" ></textarea>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "device/base_type"
        $("#form-base_type-add").validate({
            onkeyup: false,
            rules:{
                deviceTypeName:{
                    remote: {
                        url: prefix + "/checkDeviceTypeName",
                        type: "post",
                        dataType: "json",
                        data: {
                            "deviceTypeName": function() {
                                return $("input[name='deviceTypeName']").val();
                            },

                        }
                    }
                },

            },
            messages: {
                "deviceTypeName": {
                    remote: "名称已经存在"
                }
            },
            focusCleanup: true
        });

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