<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">类别：</label>
                            <div class="col-sm-3">

                                <select data-placeholder="--选择--" id="catId"
                                        name="catId"
                                        class="form-control chosen-select" tabindex="2"
                                        >
                                </select>

                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8">
                                <input type="hidden" id="catName" name="catName"/>


                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">来源：</label>
                            <div class="col-sm-3">
                                <input id="sourceName" name="sourceName"
                                       class="form-control"
                                       type="text" maxlength="10">

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="col-sm-8">
                                <input id="title" name="title"
                                       class="form-control"
                                       type="text" maxlength="30">

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">内容：</label>
                            <div class="col-sm-8">
                                <input type="hidden" id="content" name="content"/>
                                <div id="contentEditorcontent">

                                </div>

                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
<script type="text/javascript" src="/js/appjs/novel/news/add.js">
</script>
<script>
    $.ajax({
        type: "GET",
        url: "/novel/category/list",
        data: {limit:100,offset:0},
        success: function (r) {
            if (r.code == 0) {
                var list = r.data.rows;
                var catHtml = "<option>请选择</option>";
                for(var i = 0 ; i < list.length ; i++){
                    var cat = list[i];
                    catHtml += ("<option value='"+cat.id+"'>"+cat.name+"</option>");

                }
                $("#catId").html(catHtml);
                $("#catId").change(function(){
                    var catName = $(this).find("option:selected").text();
                    if(catName != '请选择'){

                        $("#catName").val(catName);
                    }else{
                        $("#catName").val('');
                    }
                });
            } else {
                layer.msg(r.msg);
            }
        },
    });
</script>
</body>
</html>
