浏览代码

task列表页修改

maxiaoshan 3 年之前
父节点
当前提交
bbe2a555e6
共有 3 个文件被更改,包括 90 次插入36 次删除
  1. 24 0
      src/taskManager/taskManager.go
  2. 32 30
      src/web/templates/mytask.html
  3. 34 6
      src/web/templates/task.html

+ 24 - 0
src/taskManager/taskManager.go

@@ -37,6 +37,7 @@ type TaskM struct {
 	closeChangeTaskState  xweb.Mapper `xweb:"/center/task/closeChangeTaskState"`  //关闭任务
 	batchAssign           xweb.Mapper `xweb:"/center/task/batchAssign"`           //批量分发任务
 	batchClose            xweb.Mapper `xweb:"/center/task/batchClose"`            //批量关闭任务
+	batchDeal             xweb.Mapper `xweb:"/center/task/batchDeal"`             //批量处理任务
 	getJumpMark           xweb.Mapper `xweb:"/center/task/getJumpMark"`           //跳转标记
 	searchErrLog          xweb.Mapper `xweb:"/center/task/searchErrLog"`          //搜索错误日志
 	searchDataInfo        xweb.Mapper `xweb:"/center/task/searchDataInfo"`        //搜索数据的标题和发布时间
@@ -1031,6 +1032,29 @@ func (t *TaskM) BatchClose() {
 	}
 }
 
+//批量处理任务
+func (t *TaskM) BatchDeal() {
+	ids := strings.Split(t.GetString("ids"), ",")
+	auth := qu.IntAll(t.GetSession("auth"))
+	if auth == role_admin {
+		update := bson.M{
+			"$set": bson.M{
+				"i_state": 2,
+			},
+		}
+		for _, id := range ids {
+			query := bson.M{
+				"_id": bson.ObjectIdHex(id),
+			}
+			flag := mgdb.Update("task", query, update, false, false)
+			log.Println("任务id:", id, "	更新为处理中:", flag)
+		}
+		t.ServeJson("处理成功")
+	} else {
+		t.ServeJson("没有权限")
+	}
+}
+
 func (t *TaskM) GetJumpMark() {
 	jumpMark := t.GetSession("jumpMark")
 	if jumpMark == "y" {

+ 32 - 30
src/web/templates/mytask.html

@@ -21,8 +21,9 @@
 								<td>栏目名称</td>
 								<td>节点</td>
 								<td>任务状态</td>
-                <td>类型</td>
+                				<td>类型</td>
 								<td>紧急度</td>
+								<td>来源</td>
 								<td>最迟完成时间</td>
 								<th class="hidden-xs">操作</th>
 							</tr>
@@ -45,9 +46,9 @@
 				
        		 },
 			"columnDefs": [
-			    { "orderable": false, "targets": 8 }
+			    { "orderable": false, "targets": 9 }
 			],	
-      "order": [[7,"desc"]], //默认排序列
+      		"order": [[8,"desc"]], //默认排序列
 			"lengthChange":false,
 			"serverSide": true,
 			"searching": true,
@@ -56,37 +57,38 @@
 			"autoWidth": true,
 			"columns": [
 				{"data":"s_code"},
-	      {"data": "s_site"},
+	      		{"data": "s_site"},
 				{"data": "s_channel"},
 				{"data": "i_event"},
 				{"data": "i_state"},
-        {"data": "s_type",render:function(val,a,row){
-          if(val== "8"){
-            val="采集频率异常"
-          }else if(val=="7"){
-            val="列表页异常"
-          }else if(val=="6"){
-            val="404 异常"
-          }else if(val=="5"){
-            val="下载异常"
-          }else if(val=="4"){
-            val="运行异常"
-          }else if(val=="3"){
-            val="时间异常"
-          }else if(val=="2"){
-            val="数据异常"
-          }else if(val=="1"){
-            val="数量异常"
-          }else if (val=="10"){
-            val="抽查任务"
-          }else if(val=="0"){
-            val="常规任务"
-          }else{
-            val="历史任务"
-          }
-          return val
-        }},
+				{"data": "s_type",render:function(val,a,row){
+				  if(val== "8"){
+					val="采集频率异常"
+				  }else if(val=="7"){
+					val="列表页异常"
+				  }else if(val=="6"){
+					val="404 异常"
+				  }else if(val=="5"){
+					val="下载异常"
+				  }else if(val=="4"){
+					val="运行异常"
+				  }else if(val=="3"){
+					val="时间异常"
+				  }else if(val=="2"){
+					val="数据异常"
+				  }else if(val=="1"){
+					val="数量异常"
+				  }else if (val=="10"){
+					val="抽查任务"
+				  }else if(val=="0"){
+					val="常规任务"
+				  }else{
+					val="历史任务"
+				  }
+				  return val
+				}},
 				{"data": "s_urgency"},
+				{"data": "s_source"},
 				{"data":"l_complete"},
 				{"data":"_id",render:function(val,a,row){
 					var div=$("<div><div class=\"btn-group\"></div></div>")

+ 34 - 6
src/web/templates/task.html

@@ -47,7 +47,7 @@
 				&nbsp;&nbsp;
 				<a class="btn btn-default btn-sm" id="batchAssign" onclick="batchAssign()">批量分发</a>
 				<a class="btn btn-default btn-sm" id="batchClose" onclick="batchClose()">批量关闭</a>
-				
+				<a class="btn btn-default btn-sm" id="batchDeal" onclick="batchDeal()">批量处理</a>
 			 </small>
 		   </h1>
 		   <ol class="breadcrumb">
@@ -71,7 +71,7 @@
 								<td>栏目名称</td>
 								<td>爬虫代码</td>
 								<td>状态</td>
-               	<td>类型</td>
+               					<td>类型</td>
 								<td>维护人</td>
 								<td>紧急度</td>
 								<td>节点</td>
@@ -79,8 +79,8 @@
 								<td>下限/下载</td>
 								<td>下限</td>
 								<td>下载</td>
-                <td>下载时间</td>
-                <td>来源</td>
+                				<td>下载时间</td>
+                				<td>来源</td>
 								<td>最迟完成时间</td>
 								<th class="hidden-xs">操作</th>
 							</tr>
@@ -119,7 +119,7 @@
 				{ "targets": 0 ,"bVisible": false}, //隐藏列
 				{ "targets": 13 ,"bVisible": false},
 				{ "targets": 14 ,"bVisible": false},
-			    { "orderable": false, "targets": [0,1,2,4,6,8,9,10,14,15,16,18] } //设置列不可排序
+			    { "orderable": false, "targets": [0,1,2,4,6,8,9,10,14,15,18] } //设置列不可排序
 			],	
 			"order": [[17,"desc"]], //默认排序列
 			"lengthChange":false,
@@ -534,7 +534,35 @@
 			showTip("没有选择项", 1000);
 		}
 	}
-	
+
+  	//批量处理
+  	function batchDeal(){
+	  var ids=[]
+	  // var codes=[];
+	  $("#import_wrapper td input[type=checkbox]").each(function(){
+		  if($(this).prop("checked")){
+			  var state = $(this).attr("state")
+			  if(state == "待处理"){
+				  ids.push($(this).val());
+				  // codes.push($(this).attr("code"));
+			  }
+		  }
+	  });
+	  if(ids.length >0){
+		  showConfirm("确定批量处理?", function() {
+			  $.post("/center/task/batchDeal",{"ids":ids.join(",")},function(r){
+				  showTip(r, 1000);
+				  $("#selrow").prop('checked',false);
+				  $('#com-alert').on('hidden.bs.modal', function () {
+					  ttabletask.ajax.reload();
+				  })
+			  })
+		  })
+	  }else{
+		  showTip("没有选择正确项", 1000);
+	  }
+  }
+
 	function selectrow(me){
 		var sel=$(me);
 		var isSelected=sel.prop('checked');