123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- {{include "head.html"}}
- <div class="content-wrapper">
- <section class="content-header">
- <h1>
- 日常任务列表
- </h1>
- <ol class="breadcrumb">
- <li><a href="#"><i class="fa fa-dashboard"></i> 任务</a></li>
- <li class="active">列表</li>
- </ol>
- </section>
- <section class="content">
- <div class="box">
- <div class="box-body">
- <table id="mytask" class="table table-bordered table-striped">
- <thead>
- <tr>
- <th>爬虫代码</th>
- <th>网站名称</th>
- <th>栏目名称</th>
- <th>平台</th>
- <th>节点</th>
- <th>任务状态</th>
- <th>类型</th>
- <!-- <th>紧急度</th>-->
- <th>次数</th>
- <!-- <th>频率次数</th>-->
- <th>来源</th>
- <th>7日下载量</th>
- <th>失败占比</th>
- <th>最迟完成时间</th>
- <!-- <th>挂起</th>-->
- <th class="hidden-xs">操作</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- </section>
- <script>
- // common.setActive("index_rwlb");
- common.menuActive("mytask");
- $(function(){
- setCookie("mytask","");
- mytask = $('#mytask').DataTable({
- "language": {
- "url": "/js/dataTables.chinese.lang"
- },
- "ajax": {
- "url": "/center/mytask",
- "type": "POST"
-
- },
- "columnDefs": [
- { "orderable": false, "targets": [0,1,2,3,4,5,6,12] },
- ],
- "order": [[11,"desc"]], //默认排序列
- "lengthChange":false,
- "serverSide": true,
- "searching": true,
- "ordering": true,
- "info": true,
- "autoWidth": false,
- "columns": [
- {"data":"s_code"},
- {"data": "s_site"},
- {"data": "s_channel"},
- {"data": "s_platform",render:function(val,a,row){
- if (val == null || val == undefined){
- return "golua平台"
- }
- return val
- }},
- {"data": "i_event"},
- {"data": "i_state","width":"5%",render:function(val,a,row){
- if (val == 0){
- return "待确认"
- }else if (val == 1){
- return "待处理"
- }else if (val == 2){
- return "处理中"
- }else if (val == 3){
- return "待审核"
- }else if (val == 4){
- return "审核通过"
- }else if (val == 5){
- return "未通过"
- }else if (val == 6){
- return "关闭"
- }
- }},
- {"data": "s_type","width":"7%",render:function(val,a,row){
- if(val== "1"){
- val="列表页异常"
- }else if(val=="2"){
- val="数据异常错误"
- }else if(val=="3"){
- val="爬虫翻页异常"
- }else if(val=="4"){
- val="采集频率异常"
- }else if(val=="5"){
- val="下载异常"
- }else if(val=="6"){
- val="数据异常警告"
- }else if(val=="0"){
- val="常规任务"
- }
- return val;
- }},
- {"data": "i_times"},
- {"data": "s_source"},
- {"data": "i_count"},
- {"data": "f_failrate"},
- {"data": "l_complete","width":"8%",render:function(val,a,row){
- var dt = new Date()
- dt.setTime(parseInt(val) * 1000);
- return dt.format("yyyy-MM-dd hh:mm:ss");
- }},
- {"data":"_id",render:function(val,a,row){
- var div=$("<div><div class=\"btn-group\"></div></div>")
- var dbutton=$('<a type="button" href="#" class="btn btn-sm btn-info" onclick="viewtask(\''+row._id+'\',\''+row.relatecode+'\');">查看</a>');
- div.find(".btn-group").append(dbutton);
- return div.html();
- // var div=$("<div><div class=\"btn-group\"></div></div>")
- // var buttonWatch=$('<a type="button" class="btn btn-sm btn-default">查看</a>');
- // buttonWatch.attr("href","/center/task/edit/"+row['_id']+"__1");
- // div.find(".btn-group").append(buttonWatch);
- // return div.html()
- }}
-
- ],
- "fnDrawCallback": function(table) {
- $("ul.pagination").prepend(" 转到第 <input type='text' id='changePage' style='width:20px;'> 页 <a type='text' href='javascript:void(0);' id='dataTable-btn' style='text-align:center'>GO</a>");
- $('#dataTable-btn').click(function(e) {
- var redirectpage=0
- if($("#changePage").val() && $("#changePage").val() > 0) {
- var redirectpage = $("#changePage").val() - 1;
- }
- ttable.page(redirectpage).draw(false);
- });
- },
- "fnServerParams": function (e) {
- var taskState = $("#task_state").val();
- var taskEvent = $("#task_event").val();
- var taskStype = $("#task_stype").val();
- var platform = $("#platform").val();
- if(taskState){
- e.taskState = taskState;
- }else{
- e.taskState="2";//默认选中处理中任务
- }
- //节点
- if(taskEvent){
- e.taskEvent = taskEvent;
- }else{
- e.taskEvent="-1";
- }
- //任务类型
- if(taskStype){
- e.taskStype = taskStype;
- }else{
- e.taskStype="-1";
- }
- //平台
- if(platform){
- e.platform = platform;
- }else{
- e.platform="-1";
- }
- }
- });
- mytask.on('init.dt', function () {
- var search=getCookie("mytask");
- if(search){
- $("[type=search]").val(search);
- }
- var taskState="<option value='-1'>全部</option>"+
- "<option value='0'>待确认</option>"+
- "<option value='1'>待处理</option>"+
- "<option selected value='2'>处理中</option>"+
- "<option value='3'>待审核</option>"+
- "<option value='4'>审核通过</option>"+
- "<option value='5'>未通过</option>"+
- "<option value='6'>关闭</option>";
-
- var selectState="<div class='form-group'><label for='name'>任务状态:</label>"+
- "<select id='task_state' onchange='checkclick(this.value)' class='form-control input-sm'>"+
- taskState+
- "</select></div>"
- $("#mytask_filter").prepend(" ");
- $("#mytask_filter").prepend(selectState);
- var taskStype="<option value='-1'>全部</option>"+
- "<option value='1'>列表页异常</option>"+
- "<option value='2'>数据异常错误</option>"+
- "<option value='3'>爬虫翻页异常</option>"+
- "<option value='4'>采集频率异常</option>"+
- "<option value='5'>下载异常</option>"+
- "<option value='6'>数据异常警告</option>"+
- "<option value='0'>常规任务</option>";
- var selectStype="<div class='form-group'><label for='name'>任务类型:</label>"+
- "<select id='task_stype' onchange='checkclick(this.value)' class='form-control input-sm'>"+
- taskStype+
- "</select></div>"
- $("#mytask_filter").prepend(" ");
- $("#mytask_filter").prepend(selectStype);
-
- var taskEvent="<option value='-1'>全部</option>"
- var events={{.T.events}}
- for(k in events){
- taskEvent+="<option value='"+events[k]+"'>"+events[k]+"</option>"
- }
- var selectEvent="<div class='form-group'><label for='name'>节点:</label>"+
- "<select id='task_event' onchange='checkclick(this.value)' class='form-control input-sm'>"+
- taskEvent+
- "</select></div>"
- $("#mytask_filter").prepend(" ");
- $("#mytask_filter").prepend(selectEvent);
- //平台
- var platform="<option value='-1'>全部</option>"
- platform+="<option value='golua平台'>golua平台</option>";
- platform+="<option value='chrome'>chrome</option>";
- platform+="<option value='python'>python</option>";
- platform+="<option value='通用平台'>通用平台</option>";
- platform+="<option value='jschrome'>jschrome</option>";
- var selectPlatform="<div class='form-group'><label for='name'>平台:</label>"+
- "<select id='platform' onchange='checkclick(this.value)' class='form-control input-sm'>"+
- platform+
- "</select></div>"
- $("#mytask_filter").prepend(" ");
- $("#mytask_filter").prepend(selectPlatform);
- //修改样式
- $("#mytask_wrapper .col-sm-6").css({width:"100%"});
- });
- mytask.on('preXhr.dt', function ( e, settings, data ) {
- $("[type=search]").keypress(function(){
- setCookie("mytask",$("[type=search]").val());
- })
- });
- //每次登陆提示还有多少条未通过的任务和错误爬虫个数
- var failedtasknum = {{.T.failedtasknum}};
- var errluanum = {{.T.errluanum}};
- var tips = "";
- if(failedtasknum>0){
- tips = "你当前有未通过的任务"+failedtasknum.toString()+"条;";
- }
- if(errluanum>0){
- tips = tips + "你当前有错误爬虫"+errluanum.toString()+"个";
- }
- if(tips!=""){
- showTip(tips,5000);
- }
- });
-
- function checkclick(urgency){
- mytask.ajax.reload();
- }
- function createComboxPendState(code,id){
- return "<select onchange='changeCodePendState(this.value,\""+code+"\",\""+id+"\")' class='form-control input-sm'>"+
- "<option value=1>是</option>"+
- "<option value=0>否</option>"+
- "</select>"
- };
- function changeCodePendState(pendstate,code,id){
- $.ajax({
- url:"/center/spider/updatePendState",
- type:"post",
- data:{
- "pendstate":pendstate,
- "id":id,
- "code":code,
- "stype":"task"
- },
- success:function(r){
- if(!r || !r.success){
- showTip("修改失败", 1000, function() {});
- }
- mytask.ajax.reload();
- }
- })
- }
- function viewtask(id,relatecode) {
- if(relatecode != ""){
- showConfirm("请注意修改关联爬虫:"+relatecode, function() {
- $.get("/center/task/createrelatetask?relatecode="+relatecode+"&id="+id,function(r){
- if (r&&r.ok){
- window.location.href="/center/task/edit/"+id+"__1";
- }else{
- showTip("关联爬虫任务创建失败", 1000, function() {});
- }
- })
- });
- }else{
- window.location.href="/center/task/edit/"+id+"__1";
- }
- }
- </script>
- </div>
- {{include "bottom.html"}}
|