<!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_info-add">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">设备编码：</label>
                    <div class="col-sm-8">
                        <input name="deviceCode" id="deviceCode" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">设备名称：</label>
                    <div class="col-sm-8">
                        <input name="deviceName" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">设备类型：</label>
                    <div class="col-sm-8">
                        <select name="deviceType" class="form-control" th:with="type=${@baseTypeService.selectBaseTypeList(null)}">
                            <option th:each="dict : ${type}" th:text="${dict.deviceTypeName}" th:value="${dict.objId}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">摆放桩位：</label>
                    <div class="col-sm-8">
                        <input name="locationName" class="form-control" type="text">
                    </div>
                </div>
            </div>
<!--            <div class="col-xs-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label">开锁密码：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <input name="openPassword" class="form-control" type="text">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "device/base_info"
        $("#form-base_info-add").validate({
            onkeyup: false,
            rules: {
                deviceCode: {
                    remote: {
                        url: prefix + "/checkDeviceCode",
                        type: "post",
                        dataType: "json",
                        data: {
                            "deviceCode": function() {
                                return $("input[name='deviceCode']").val();
                            },

                        }
                    }
                },
            },

            messages: {
                "deviceCode": {
                    remote: "设备编码已经存在"
                }
            },
            focusCleanup: true
        });

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