<!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-industry-edit" th:object="${industry}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">行业名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" 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">
                    <input name="level" th:field="*{level}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">父节点id：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="pId" type="hidden" th:field="*{pId}" />
                        <input class="form-control" type="text" onclick="selectIndustryTree()" id="treeName" readonly="true" th:field="*{parentName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-9">
                    <label class="toggle-switch switch-solid">
                        <input type="checkbox" id="status" name="status" value="1" checked="" th:field="*{status}"> <span></span>
                    </label>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">行业发散：</label>
                <div class="col-sm-8">
                    <input name="tags" th:field="*{tags}" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "business/industry";
        $("#form-industry-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-industry-edit').serialize());
            }
        }

        /*行业-编辑-选择父行业树*/
        function selectIndustryTree() {
            var options = {
                title: '行业选择',
                width: "380",
                url: prefix + "/selectIndustryTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>