seo_root_words.hbs 7.02 KB
<style>
.seo-tdk-page ul {
        padding: 0;
    }

    .seo-tdk-page li {
        list-style: none;
    }

    .seo-tdk-page .query-form {
        font-size: 0;
    }

    .seo-tdk-page .query-form .btn-group {
        margin-bottom: 0;
    }

    .seo-tdk-page .query-form .dropdown-toggle {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .seo-tdk-page .query-form .query-submit-btn {
        height: 39px;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }

    .seo-tdk-page .query-key {
        width: 300px;
        height: 39px;
        font-size: 14px;
        vertical-align: middle;
        outline: none;
    }
</style>

<div class="pageheader">
    <div class="media">
        <div class="pageicon pull-left">
            <i class="fa fa-th-list"></i>
        </div>
        <div class="media-body">
            <ul class="breadcrumb">
                <li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
                <li><a href="/seo/tdk">{{title}}</a></li>
                <li>{{typeName}}</li>
            </ul>
            <h4>{{title}}</h4>
        </div>
    </div>
    <!-- media -->
</div>
<!-- pageheader -->

<div class="contentpanel seo-tdk-page" style="padding-bottom:0;">
    <div class="panel panel-default">
        <div class="panel-body">
            <label style="margin-right:20px;"><input type="checkbox" id="check-all" style="margin-right:5px;">全选</label>
            <a href="/seo/rootwords/add" class="btn btn-default" style="margin-right:10px;">增加</a>
            <button class="btn btn-default delete-all" type="submit" id="del-all">删除</button>
            <button class="btn btn-default delete-all" type="submit" id="root-to-keywords">词根计入关键词</button>

            <div class="input-append pull-right">
                <form id="query-form" action="/seo/tdk" class="query-form" method="get">
                    <div class="btn-group">
                        <button class="btn dropdown-toggle" data-toggle="dropdown">
                            {{typeName}}
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            {{# typeList}}
                                <li><a href="?type={{type}}">{{name}}</a></li>
                            {{/ typeList}}
                        </ul>
                    </div>
                    <input type="hidden" name="type" value="{{type}}">
                    <input class="span2 query-key" type="text" name="query" value="{{query}}">
                    <button class="btn query-submit-btn" type="submit">搜索</button>
                </form>
            </div>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body">
            <table id="table-root-words" class="table table-striped table-bordered responsive">
                <thead>
                    <tr>
                        <th class="text-center" width="60">ID</th>
                        <th class="text-center" width="160">词根</th>
                        <th class="text-center">品牌</th>
                        <th class="text-center">品类</th>
                        <th class="text-center">过滤词</th>
                        <th class="text-center">已拓词</th>
                        <th class="text-center" width="120">操作</th>
                    </tr>
                </thead>

                <tbody>
                {{#each list}}
                    <tr data-type="{{../type}}" data-key="{{key}}" data-title="{{title}}" data-keywords="{{keywords}}" data-description="{{description}}">
                        <td class="text-center"><input type="checkbox" style="margin-right:5px;" value="{{id}}">{{id}}</td>
                        <td class="text-center">{{keyword}}</td>
                        <td>{{brand_name}}</td>
                        <td>{{sort_name}}</td>
                        <td>{{filter_words}}</td>
                        <td>{{#if is_expand}}{{^}}{{/if}}</td>
                        <td class="text-center">
                            <a href="javascript:delRootWords({{id}});" class="del-tdk-btn">删除</a>
                        </td>
                    </tr>
                {{/each}}
                {{#unless list}}
                    <tr>
                        <td class="text-center" colspan="6">暂无数据</td>
                    </tr>
                {{/unless}}
                </tbody>
            </table>
            {{# pager}}
                <div class="text-right">
                {{#if pages}}
                    <ul class="pagination">
                        {{# prePage}}
                            <li><a href="{{url}}">上一页</a></li>
                        {{/ prePage}}
                        {{# pages}}
                            <li class="{{#unless url}}disabled {{/unless}}{{#if cur}}active{{/if}}"><a {{#if url}}href="{{url}}"{{^}}href="javascript:;"{{/if}}>{{num}}</a></li>
                        {{/ pages}}
                        {{# nextPage}}
                            <li><a href="{{url}}">下一页</a></li>
                        {{/ nextPage}}
                    </ul>
                {{/if}}
                </div>
            {{/ pager}}
        </div>
    </div>
</div>

<script>
var $checkAll = $('#check-all'),
    $wordsCheckbox = $('#table-root-words input:checkbox'),
    $delAll= $('#del-all');
    $rootToKeywords= $('#root-to-keywords');

// 全选/反选
$checkAll.on('click', function(){
    $wordsCheckbox.each(function() {
        $(this).trigger('click');
    })
})
// 批量删除
$delAll.on('click', function(){
    var ids = [];

    $wordsCheckbox.each(function() {
        if ($(this)[0].checked) {
            ids.push($(this).val());
        }
    })

    if (ids.length > 0) {
        delRootWords(ids.join(','));
    } else {
        alert('先选择词根');
    }


})

// 删除
function delRootWords(ids) {
    confirm('确认删除?');
    $.ajax({
         url: '/seo/rootwords/delete',
         dataType: 'json',
         type: 'POST',
         data: {
             ids: ids
         },
         success: function(data) {
             window.location.reload();
         },
         error: function(err) {
            console.log(err);
         }

    });
}

// 批量删除
$rootToKeywords.on('click', function(){
    var ids = [];

    $wordsCheckbox.each(function() {
        if ($(this)[0].checked) {
            ids.push($(this).val());
        }
    })

    if (ids.length > 0) {
        rootToKeywords(ids.join(','));
    } else {
        alert('先选择词根');
    }


})
// 词根计入关键词
function rootToKeywords(ids) {
    confirm('确认计入关键词?');
    $.ajax({
        url: '/seo/rootwords/rootToKeywords',
        dataType: 'json',
        type: 'POST',
        data: {
            ids: ids
        },
        success: function(data) {
            window.location.reload();
        },
        error: function(err) {
            console.log(err);
        }

    });
}
</script>