<!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-edit" th:object="${baseInfo}">
            <input name="objId" th:field="*{objId}" type="hidden">
            <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" th:field="*{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" th:field="*{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:field="*{deviceType}" 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">
                        <select name="useState" class="form-control" th:with="type=${@dict.getType('use_state')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{useState}"></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">
                        <select name="deviceState" class="form-control" th:with="type=${@dict.getType('device_state')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{deviceState}"></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 class="form-control" name="locationName" th:field="*{locationName}" type="text">
<!--                        <select class="form-control" name="locationName" th:field="*{locationName}" th:with="type=${@lundang.selectLundangBaseStoreList()}">-->
<!--                            <option th:each="dict : ${type}" th:text="${dict.storeName}" th:value="${dict.storeName}"></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="openPassword" th:field="*{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-edit").validate({
            onkeyup: false,
            rules: {
                deviceCode: {
                    remote: {
                        url: prefix + "/checkDeviceCode",
                        type: "post",
                        dataType: "json",
                        data: {
                            "deviceCode": function() {
                                return $("input[name='deviceCode']").val();
                            },
                            "objId": function() {
                                return $("input[name='objId']").val();
                            }
                        }
                    }
                }
            },

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

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