@{
    ViewData["Title"] = "自动下载帐号管理";
    Layout = "~/Pages/Shared/_MainLayout.cshtml";
    ViewBag.Nav = new string[] { "自动下载中心", "自动下载模版","帐号管理" };
}

<div class="row">
    <div class="col-sm-12">
        <div class="ibox-content m-b-sm border-bottom">
            <form id="toolbar">
                <div class="form-inline" style="line-height:40px;">
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <button type="button" class="btn btn-warning" onclick="Detail(0);">新增帐号</button>
                    </div>
                    <div class="form-group">
                        <label>&nbsp;</label>
                        <input class="form-control" style="width:180px" placeholder="可输入帐号" />
                    </div>
                    <div class="form-group">
                        <button type="button" class="btn btn-primary" onclick="list();">查询</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="ibox-content m-b-sm border-bottom">
            <table id="roletable" class="table table-border table-bordered table-hover table-bg table-sort form-inline" style="table-layout:fixed;">
                <thead>
                    <tr>
                        <th style="width:160px;">平台名称</th>
                        <th style="width:120px;">平台索引值</th>
                        <th style="width:100px;">站点</th>
                        <th style="width:120px;">下载数据类型</th>
                        <th style="width:150px;">帐号</th>
                        <th style="width:150px;">密码</th>
                        <th style="width:80px;">状态</th>
                        <th style="width:120px;">Token</th>
                        <th style="width:240px;">请求地址</th>
                        <th style="width:160px;">备注</th>
                        <th style="width:120px;">操作</th>
                    </tr>
                </thead>
                <tbody id="tb">

                </tbody>
            </table>
        </div>
    </div>
</div>

@section css{ 
    <style>
        .mules {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
}

@section scripts{
    <script>
        
        $(document).ready(function () {
            var height = document.body.clientHeight;
            $("#roletable").attr("data-height", (height - 170));

            list();
        })

        function list() {
            $.submit({
                url: '@Url.Content("~/TaskCenter/Home/ListAccountJson")',
                type:'POST',
                paramData: 'datatype=@(ViewBag.datatype)',
                func: function (result) {
                    $('#tb').html('');
                    if (result.success) {
                        for (var i in result.data) {
                            var _obj = result.data[i];
                            var s = '<tr>';
                            s += '<td>' + _obj.platform + '</td>';
                            s += '<td>' + _obj.platform_index + '</td>';
                            s += '<td>' + _obj.website + '</td>';
                            s += '<td>' + _obj.data_type + '</td>';
                            s += '<td>' + _obj.account + '</td>';
                            s += '<td>' + _obj.pwd + '</td>';
                            s += '<td>' + _obj.status + '</td>';
                            s += '<td><div class="mules" title="' + _obj.token + '">' + _obj.token + '</div></td>';
                            s += '<td><div class="mules" title="' + _obj.apiurl + '">' + _obj.apiurl + '</div></td>';
                            s += '<td>' + _obj.note + '</td>';
                            s += '<td><a href="javascript:;" class="btn btn-success btn-xs" onclick="Detail(' + _obj.id + ')">查看详情</a></td>';

                            $('#tb').append(s);
                        }
                    }
                }
            })
        }

        function Detail(id) {
            layer_show('帐号详情信息', '@Url.Content("~/TaskCenter/Home/AccountDetail?datatype="+ ViewBag.datatype + "&id=")'+id, '90%', '90%');
        }

    </script>

}
