risk_management.hbs 2.39 KB
<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>风险控制</li>
            </ul>
            <h4>风险控制</h4>
        </div>
    </div>
    <!-- media -->
</div>
<!-- pageheader -->

<div class="contentpanel servers-page">
    <button type="button" class="btn btn-success add">新增配置</button>
    <table class="table table-hover table-striped table-bordered" style="margin-top: 2rem">
        <thead>
            <tr>
                <th>应用名称</th>
                <th>路由路径</th>
                <th>间隔时间</th>
                <th>请求次数</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{#list}}
                <tr>
                    <td class="app">{{app}}</td>
                    <td class="route">{{route}}</td>
                    <td>{{interval}}</td>
                    <td>{{requests}}</td>
                    <td>{{state}}</td>
                    <td><button type="button" class="btn btn-success edit">编辑</button><button  type="button" class="btn btn-danger ml10 del">删除</button></td>
                </tr>
            {{/list}}

            {{#if noData}}
                <tr>
                    <td colspan="4" class="text-center">无数据</td>
                </tr>
            {{/if}}
        </tbody>
    </table>
</div>

<script>
    $('.add').on('click', function() {
        location.href = '/risk_management/add_risk';
    });

    $('.del').on('click', function() {
        var key = $(this).parents('tr').find('.app').html() + '/' + $(this).parents('tr').find('.route').html();

        $.post('/risk_management/remove', {
            key: key
        }, function(ret) {
            if (ret.code === 200) {
                alert('删除成功!');
                location.reload();
            } else {
                alert('删除失败!');
            }
        });
    });

    $('.edit').on('click', function() {
        var key = $(this).parents('tr').find('.app').html() + '/' + $(this).parents('tr').find('.route').html();

        location.href = '/risk_management/add_risk?key=' + key;
    });
</script>