#@layout()
#define script()
<script>

    $('.del-action').on('click', function () {
        if (confirm('确定要删除该分类吗？删除后不可恢复')) {
            var id = $(this).attr("data-id");
            ajaxGet("#(CPATH)/admin/product/category/doDel/" + id);
        }
    });

    $(".tflag").each(function () {
        $(this).on('click', function () {
            $("#flag").val($(this).text());
        })
    });


</script>
#end
#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            分类管理
            <small>Product Category</small>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-lg-5">
                <div class="box box-primary">
                    <div class="box-header ">
                        <h3 class="box-title"></h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form class="form-horizontal form-setting autoAjaxSubmit" autocomplete="off"
                          action="#(CPATH)/admin/product/category/doSave"
                          data-ok-href="#(CPATH)/admin/product/category"
                          method="post">
                        <input type="hidden" name="category.id" value="#(category.id ??)">
                        <input type="hidden" name="category.type" value="category">
                        <div class="box-body ">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">名称</label>

                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="取个适合的分类名称..."
                                           value="#(category.title ??)" name="category.title">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">父级</label>

                                <div class="col-sm-9">
                                    <select class="form-control" name="category.pid">
                                        #if(category && category.pid == 0)
                                        <option value="0" selected>顶级</option>
                                        #else
                                        <option value="0">顶级</option>
                                        #end

                                        #for(c : categories)
                                        #if(category && category.pid == c.id)
                                        <option value="#(c.id)" selected>#(c.layerString)#(c.title)</option>
                                        #elseif(category && (category.id == c.id || category.isMyChild(c.id)))
                                        <option value="#(c.id)" disabled>#(c.layerString)#(c.title)</option>
                                        #else
                                        <option value="#(c.id)">#(c.layerString)#(c.title)</option>
                                        #end
                                        #end
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">slug</label>

                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="slug会显示在网址上..."
                                           value="#(category.slug ??)" name="category.slug">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="此分类排序的序号"
                                           value="#(category.order_number ??)"
                                           name="category.order_number">
                                    <p class="help-block"> 越小的数字越靠前，只在同级分类上影响。 </p>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">内容</label>
                                <div class="col-sm-9">
                                    <textarea rows="3" class="form-control"
                                              placeholder="..."
                                              name="category.content">#(category.content ??)</textarea>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">摘要</label>
                                <div class="col-sm-9">
                                    <textarea rows="3" class="form-control"
                                              placeholder="..."
                                              name="category.summary">#(category.summary ??)</textarea>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">图标</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="给该分类设置图标"
                                           value="#(category.icon ??)" name="category.icon">
                                    <p class="help-block"> 图标只用于前台显示，是否显示决定于模板。<a target="_blank" href="#(CPATH)/admin/setting/icons">获取</a> </p>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-sm-2 control-label">标识</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="展示标识"
                                           value="#(category.flag ??)" name="category.flag" id="flag">
                                    #if(flags && flags.size() > 0)
                                    <p class="help-block">当前模板支持的展示标识有：
                                        #for(flag : flags ??)
                                        <a href="javascript:;" class="tflag">#(flag)</a>
                                        #end
                                    </p>
                                    #end
                                </div>
                            </div>


                            #if(styles && styles.size() > 0)
                            <div class="form-group">
                                <label class="col-sm-2 control-label">样式</label>
                                <div class="col-sm-9">
                                    <select class="form-control" name="category.style">
                                        <option value="">默认</option>
                                        #for(style : styles)
                                        <option value="#(style)" #selectedIf(category && category.style== style)>
                                            #(style)
                                        </option>
                                        #end
                                    </select>
                                </div>
                            </div>
                            #end

                            <div class="form-group">
                                <label class="col-sm-2 control-label">显示到菜单</label>
                                <div class="col-sm-9">
                                    <input type="checkbox" class="switchery" data-for="displayInMenu"
                                           #checkedIf(isDisplayInMenu)>
                                    <input type="hidden" id="displayInMenu" name="displayInMenu" value="false">
                                </div>
                            </div>


                            <h4 class="page-header">SEO</h4>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">描述</label>

                                <div class="col-sm-9">
                                    <textarea rows="3" class="form-control"
                                              placeholder="此内容会显示在搜索引擎的列表描述上..."
                                              name="category.meta_description">#(category.meta_description ??)</textarea>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">关键字</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="多个关键字用逗号隔开"
                                           name="category.meta_keywords"
                                           value="#(category.meta_keywords ??)">
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-offset-2 col-sm-10 submit-block">
                                <div class="box-submit">
                                    <button type="submit" class="btn btn-primary">提交</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
            <div class="col-lg-7">
                <div class="box box-primary">

                    <div class="box-header with-border">

                    </div>

                    <div class="box-body no-padding ">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 40%">标题</th>
                                <th>Slug</th>
                                <th>描述</th>
                                <th>排序</th>
                            </tr>
                            #for(category : categories)
                            <tr class="jp-actiontr">
                                <td>
                                    <strong>
                                        <a href="#(category.url ??)" target="_blank">
                                            #(category.layerString)#(category.title)
                                        </a>
                                        （#(category.count ?? 0)）
                                    </strong>
                                    <div class="jp-actionblock">
                                        <div class="jp-actionitem">
                                            <a href="#(CPATH)/admin/product/category/#(category.id)">编辑</a> |
                                            <a href="javascript:;" class="del-action red-action"
                                               data-id="#(category.id)">删除</a> |
                                            <a href="#(category.url ??)" target="_blank" class="red-action">查看</a>
                                        </div>
                                    </div>
                                </td>
                                <td>#(category.slug ??)</td>
                                <td>#(category.content ??)</td>
                                <td>#(category.order_number ??)</td>
                            </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
