@{
    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>下载类型</label>
                        <select id="datatype" name="datatype" class="form-control" style="width:150px">
                            <option value="">请选择下载类型</option>
                            @if (ViewBag.datatypes.Count > 0)
                            {
                                foreach (var item in ViewBag.datatypes)
                                {
                                    <option value="@(item.data_type)">@(item.data_type_name)</option>
                                }
                            }
                        </select>
                    </div>
                    <div class="form-group">
                        <label></label>
                        <select id="status" name="status" class="form-control" style="width:150px">
                            <option value="">请选择任务状态</option>
                            <option value="0">未认领</option>
                            <option value="1">任务执行失败</option>
                            <option value="2">已认领</option>
                            <option value="3">执行成功</option>
                        </select>
                    </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" style="table-layout:fixed;"></table>
        </div>
    </div>
</div>

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

            list();
        })

        function list() {
            var columns = [
                { field: 'datatype', title: '数据类型', width: '130'},
                { field: 'platform_type', title: '平台', width: '130' },
                { field: 'website', title: '站点', width: '130'},
                { field: 'account', title: '帐号', width: '130' },
                { field: 'status', title: '任务状态', width: '80' },
                { field: 'createtime', title: '创建时间', width: '130' },
                { field: 'lastupdatetime', title: '最后时间', width: '130' },
                { field: 'fileurl', title: '文件下载', width: '200' }

            ];

            var url = '@Url.Content("~/TaskCenter/Home/ListTaskJson")' + '?' + $('#toolbar').serialize();

            if (tb == undefined) {
                tb = OnlyTable("roletable", columns, url, "");
            }
            else {
                tb.bootstrapTable('refresh', { url: url });
            }
        }

        function Add() {
            layer_show('新增模版', '@Url.Content("~/TaskCenter/Home/AddTaskTemplate?id=0")', '90%', '90%');
        }

    </script>

}

