<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改仓库管理')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-warehouse-edit" th:object="${amsWarehouse}">
            <input name="warehouseId" th:field="*{warehouseId}" type="hidden">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">仓库编码：</label>
                    <div class="col-sm-8">
                        <input name="warehouseCode" th:field="*{warehouseCode}" 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 is-required">仓库名称：</label>
                    <div class="col-sm-8">
                        <input name="warehouseName" th:field="*{warehouseName}" 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">
                        <select name="manageDeptId" th:field="*{manageDeptId}" class="form-control">
                            <option value="">请选择</option>
                            <option th:each="dept : ${deptList}" th:text="${dept.deptName}" th:value="${dept.deptId}"></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="warehouseAddress" th:field="*{warehouseAddress}" 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 id="managerUserId" name="managerUserId" th:field="*{managerUserId}" class="form-control">
                            <option value="">请选择</option>
                            <option th:each="user : ${userList}" th:text="${user.userName + '（' + user.loginName + '）'}" th:value="${user.userId}" th:data-phone="${user.phonenumber}"></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="contactPhone" th:field="*{contactPhone}" class="form-control" type="text" readonly>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">启用状态：</label>
                    <div class="col-sm-8">
                        <div class="radio-box" th:each="dict : ${@dict.getType('ams_enabled_status')}">
                            <input type="radio" th:id="${'enabled_' + dict.dictCode}" name="enabled" th:value="${dict.dictValue}" th:field="*{enabled}" required>
                            <label th:for="${'enabled_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </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">
                        <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "asset/warehouse";
        $("#managerUserId").select2({
            placeholder: "请选择负责人",
            allowClear: true
        }).on("change", fillContactPhone);

        function fillContactPhone() {
            var phone = $("#managerUserId").find("option:selected").data("phone") || "";
            $("input[name='contactPhone']").val(phone);
        }

        $("#form-warehouse-edit").validate({
            focusCleanup: true
        });

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