Authored by qinchao

任务api一键开启

@@ -59,6 +59,7 @@ public class HttpUriContants { @@ -59,6 +59,7 @@ public class HttpUriContants {
59 public static final String JAVA_API_GET = "/javaApi/query"; 59 public static final String JAVA_API_GET = "/javaApi/query";
60 public static final String JAVA_API_DEL = "/javaApi/del"; 60 public static final String JAVA_API_DEL = "/javaApi/del";
61 public static final String JAVA_API_SAVE = "/javaApi/save"; 61 public static final String JAVA_API_SAVE = "/javaApi/save";
  62 + public static final String JAVA_API_TASKENABLEORDISABLE = "/javaApi/taskEnableOrDisable";
62 public static final String JAVA_API_STATUS = "/javaApiStatus/query"; 63 public static final String JAVA_API_STATUS = "/javaApiStatus/query";
63 public static final String JAVA_API_HIS = "/javaApiStatus/queryhis"; 64 public static final String JAVA_API_HIS = "/javaApiStatus/queryhis";
64 public static final String JAVA_API_STATUS_ALL = "/javaApiStatus/queryAll"; 65 public static final String JAVA_API_STATUS_ALL = "/javaApiStatus/queryAll";
@@ -10,6 +10,9 @@ public class JavaApiInfoReq extends PageRequest { @@ -10,6 +10,9 @@ public class JavaApiInfoReq extends PageRequest {
10 10
11 private Integer serviceId; 11 private Integer serviceId;
12 12
  13 + //多个id组成的参数
  14 + private String serviceIds;
  15 +
13 private Integer serviceType; 16 private Integer serviceType;
14 17
15 private String apiName; 18 private String apiName;
@@ -79,6 +79,12 @@ public class JavaAPICtrl { @@ -79,6 +79,12 @@ public class JavaAPICtrl {
79 return rep; 79 return rep;
80 } 80 }
81 81
  82 + @RequestMapping("/taskEnableOrDisable")
  83 + @ResponseBody
  84 + public BaseResponse taskEnableOrDisable(JavaApiInfoReq req) {
  85 + BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_API_TASKENABLEORDISABLE, req, BaseResponse.class);
  86 + return rep;
  87 + }
82 88
83 @RequestMapping("/del") 89 @RequestMapping("/del")
84 @ResponseBody 90 @ResponseBody
@@ -115,6 +115,14 @@ @@ -115,6 +115,14 @@
115 <button id="addInfoBtn" class="btn btn-info" style="margin-top: 12px;margin-left: 100px;"> 115 <button id="addInfoBtn" class="btn btn-info" style="margin-top: 12px;margin-left: 100px;">
116 新增 116 新增
117 </button> 117 </button>
  118 +
  119 + <button id="taskEnableOrDisable_open" class="btn btn-warning" style="margin-top: 12px;margin-left: 5px;">
  120 + 开启任务
  121 + </button>
  122 +
  123 + <button id="taskEnableOrDisable_close" class="btn btn-warning" style="margin-top: 12px;margin-left: 5px;">
  124 + 关闭任务
  125 + </button>
118 </div> 126 </div>
119 </div> 127 </div>
120 <div id="infoTable"> 128 <div id="infoTable">
@@ -326,6 +334,12 @@ @@ -326,6 +334,12 @@
326 getJavaApp(); 334 getJavaApp();
327 335
328 336
  337 + $("#taskEnableOrDisable_open").click(function () {
  338 + taskEnableOrDisable(1);
  339 + });
  340 + $("#taskEnableOrDisable_close").click(function () {
  341 + taskEnableOrDisable(0);
  342 + });
329 343
330 $("#addInfoBtn").click(function () { 344 $("#addInfoBtn").click(function () {
331 editJavaInfo(null); 345 editJavaInfo(null);
@@ -345,6 +359,31 @@ @@ -345,6 +359,31 @@
345 }); 359 });
346 }); 360 });
347 361
  362 + //flag 1开启,0关闭
  363 + function taskEnableOrDisable(flag) {
  364 + var ids=getSelectedServiceIds();
  365 + if(ids.length<=0){
  366 + localAlert("提示","请至少选择一个任务!");
  367 + return ;
  368 + }
  369 + $.ajax({
  370 + url: contextPath + "/javaApi/taskEnableOrDisable",
  371 + type: 'post',
  372 + dataType: "json",
  373 + sync: false,
  374 + data: {
  375 + 'serviceIds': ids,
  376 + 'apiToggle':flag
  377 + },
  378 + success: function (data) {
  379 + $("#infoTable").table("load");
  380 + },
  381 + error: function (data) {
  382 +
  383 + }
  384 + });
  385 + }
  386 +
348 function getTableParam() { 387 function getTableParam() {
349 388
350 var tableParam = { 389 var tableParam = {
@@ -367,6 +406,12 @@ @@ -367,6 +406,12 @@
367 //refreshJavaAppStatus(); 406 //refreshJavaAppStatus();
368 }, 407 },
369 columns: [{ 408 columns: [{
  409 + title : " <input type='checkbox' onclick='selectAll(this)' > &nbsp; 全选 " ,
  410 + width : "3%",
  411 + formatter : function(value, rowData, rowIndex) {
  412 + return "<input type='checkbox' name ='checkboxServiceId' data-sign='"+rowData.serviceId+"' >";
  413 + }
  414 + },{
370 title: "ID", 415 title: "ID",
371 field: "serviceId", 416 field: "serviceId",
372 width: "4%" 417 width: "4%"
@@ -695,5 +740,36 @@ @@ -695,5 +740,36 @@
695 }] 740 }]
696 }); 741 });
697 } 742 }
  743 +
  744 +
  745 + //点击表头 的checkbox事件
  746 + function selectAll(that){
  747 + var isChecked = $(that).is(':checked');
  748 + if( isChecked ) {
  749 + $("#infoTable tbody").find("input[name='checkboxServiceId']").each(function (index,val) {
  750 + $(this).prop("checked",true);
  751 + });
  752 + }else{
  753 + $("#infoTable tbody").find("input[name='checkboxServiceId']").each(function (index,val) {
  754 + $(this).prop("checked",false);
  755 + });
  756 + }
  757 +
  758 + }
  759 +
  760 + function getSelectedServiceIds(){
  761 + var ids="";
  762 + $("#infoTable tbody").find("input[name='checkboxServiceId']:checked").each(function (index,val) {
  763 + var srvId=$(this).attr("data-sign");
  764 + if(srvId!=null&&srvId.length>0){
  765 + if(ids.length>0){
  766 + ids += ",";
  767 + }
  768 + ids += srvId;
  769 + }
  770 + });
  771 + return ids;
  772 + }
  773 +
698 </script> 774 </script>
699   775