Jianghan vor 5 Jahren
Ursprung
Commit
6d6606d1b7

+ 6 - 0
dataprocess/src/front/front.go

@@ -43,6 +43,12 @@ type Front struct {
 	roleDel        xweb.Mapper `xweb:"/front/role/edit/del"`    //权限编辑删除
 	roleSecondEdit xweb.Mapper `xweb:"/front/role/second/edit"` //二级权限编辑
 
+	logicManager	xweb.Mapper `xweb:"/front/logic"`			//逻辑管理
+	logicPre		xweb.Mapper	`xweb:"/front/logic/pre"`		//预处理逻辑
+	logicMatch		xweb.Mapper	`xweb:"/front/logic/match"`		//匹配逻辑
+	logicClean		xweb.Mapper	`xweb:"/front/logic/clean"`		//清洗
+	logicPreSav		xweb.Mapper	`xweb:"/front/logic/pre/save"`	//预处理逻辑保存
+
 }
 
 func (f *Front) Login() {

+ 74 - 0
dataprocess/src/front/logic.go

@@ -0,0 +1,74 @@
+package front
+
+import (
+	. "../util"
+	qu "qfw/util"
+	"time"
+)
+
+func (f *Front) LogicManager() {
+	defer qu.Catch()
+	f.Render("com/logic_list.html")
+}
+
+func (f *Front) LogicPre() {
+	defer qu.Catch()
+	if f.Method() == "POST" {
+		data, _ := Mgo.Find("logic", nil, nil, nil, false, -1, -1)
+		f.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		f.Render("com/logic_pre.html")
+	}
+}
+
+func (f *Front) LogicMatch() {
+	defer qu.Catch()
+	if f.Method() == "POST" {
+		data, _ := Mgo.Find("logic", nil, nil, nil, false, -1, -1)
+		f.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		f.Render("com/logic_match.html")
+	}
+}
+
+func (f *Front) LogicClean() {
+	defer qu.Catch()
+	if f.Method() == "POST" {
+		data, _ := Mgo.Find("logic", nil, nil, nil, false, -1, -1)
+		f.ServeJson(map[string]interface{}{
+			"data": data,
+		})
+	} else {
+		f.Render("com/logic_clean.html")
+	}
+}
+
+func (f *Front) LogicPreSav() {
+	defer qu.Catch()
+	_id := f.GetString("_id")
+	data := GetPostForm(f.Request)
+	b := false
+	if _id == "" {
+		data["delete"] = false
+		data["l_comeintime"] = time.Now().Unix()
+		data["i_type"] = 0
+		//session := f.GetSession("user").(map[string]interface{})
+		//data["s_username"] = session["name"].(string)
+		//data["s_userid"] = session["id"].(string)
+		//data["i_runstate"] = 0
+		b = Mgo.Save("logic", data) != ""
+	} else {
+		data["l_lasttime"] = time.Now().Unix()
+		b = Mgo.Update("logic", `{"_id":"`+_id+`"}`, map[string]interface{}{
+			"$set": data,
+		}, false, false)
+	}
+	f.ServeJson(map[string]interface{}{
+		"rep": b,
+	})
+}
+

+ 252 - 0
dataprocess/src/web/templates/com/logic_clean.html

@@ -0,0 +1,252 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+	<section class="content-header">
+		<h1>
+			<small><a class="btn btn-primary opr" opr="new">新增逻辑</a></small>
+		</h1>
+		<ol class="breadcrumb">
+		  	<li><a href="/front/logic"><i class="fa fa-dashboard"></i> 逻辑管理</a></li>
+			<li><a href="/front/logic/clean"><i class="fa fa-dashboard"></i> 清洗逻辑</a></li>
+		</ol>
+    </section>
+  <!-- Main content -->
+  <section class="content">
+      <div class="row">
+	      <div class="col-xs-12">
+	        <div class="box">
+		        <div class="box-body">
+		            <table id="dataTable" class="table table-bordered table-hover">
+		              <thead>
+		              <tr>
+		                <th>逻辑名称</th> <th>创建时间</th> <th>创建人</th> <th>描述</th><th>任务逻辑</th> <th>操作</th>
+		              </tr>
+		              </thead>
+		            </table>
+		        </div>
+	          <!-- /.box-body -->
+	        </div>
+        <!-- /.box -->
+		</div>
+	</div>
+  </section>
+</div>
+{{include "com/dialog.html"}}
+{{include "com/footer.html"}}
+<script>
+menuActive("logic/list")
+$(function () {
+	ttable=$('#dataTable').DataTable({
+		"paging"      : false,
+		"lengthChange": false,
+		"searching"   : false,
+		"ordering"    : false,
+		"info"        : true,
+		"autoWidth"   : false,
+		"ajax": {
+			"url": "/logic/list",
+			"type": "post",
+			"data":{}
+		 },
+		"language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+		"columns": [
+            { "data": "s_taskname"},
+			{ "data": "l_comeintime",render:function(val){
+				var dt=new Date()
+				dt.setTime(parseInt(val)*1000)
+				return dt.format("yyyy-MM-dd hh:mm:ss")
+			}},
+			{ "data": "s_username"},
+			{ "data": "s_descript","width":"25%"},
+			{ "data": "i_runstate",render:function(val){
+					if(val==1){
+						return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
+					}else{
+						return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
+					}
+				}},
+			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
+				tmp = '<div>'+
+					'<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
+					'<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
+					'<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\''+row._id+'\')">停止</a> '+
+					'<a class="btn btn-sm btn-danger opr" opr="del" onclick="del(\''+val+'\')">删除</a>'+
+					'</div>';
+				return  tmp
+			}}
+       	]
+	});
+	ttable.on('init.dt', function () {
+		$("#showbtn").on('click','a.opr',function(){
+			var n=$(this).attr("opr");
+			var taskid=$(this).attr("taskid");
+			var htmlObj={},obj,tag=[],bts=[];
+			var _tit="";
+			switch(n){
+			case "edit":			
+				obj=ttable.row($(this).closest("tr")).data();	
+			case "new":
+				/*表单*/
+				addtask=[
+					{label:"任务名称",s_label:"s_taskname",placeholder:"数据清洗",must:true},
+					{label:"源库连接",s_label:"s_mgoaddr",must:true},
+					{label:"源数据库",s_label:"s_mgodb",must:true},
+					{label:"源表",s_label:"s_mgocoll",must:true},
+					{label:"保存表",s_label:"s_mgosavecoll",placeholder:"127.0.0.1:27080/dataprocess/bidding(数据库地址/数据库/表)",must:true},
+					{label:"描述",s_label:"s_descript",type:"tpl_text"},
+					/*
+					{label:"是否追踪",s_label:"i_track",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0,fun:function(){
+						var to=$("#i_track")					
+						to.val($(this).attr("_id"))
+						$("#s_show",to.closest("div")).val($(this).text())
+						//追踪表样式
+						$("#s_trackcoll").attr("must",$(this).attr("_id")==1)
+						$("#s_trackcoll").closest("div.row").find("label").css("color",$(this).attr("_id")==1?"red":"")
+					}},
+					{label:"追踪记录表",s_label:"s_trackcoll",must:function(){
+						return  obj&&obj.i_track
+					}()},
+					{label:"是否统计",s_label:"i_count",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0},
+					*/
+					//{label:"使用版本",s_label:"s_version",type:"tpl_list_local",must:true,url:"/admin/task/getversion"},
+					{label:"并发数量",s_label:"i_process",placeholder:"5",must:true},
+					{label:"预处理逻辑",s_label:"s_preprocesslogic",type:"tpl_list_local",url:""},
+					{label:"匹配逻辑",s_label:"s_class",type:"tpl_list_ajax",url:"",fun:function(){
+						var ids=$("#s_class").data("ids")
+						var parentDiv=$("#s_class").closest("div")
+						ids=ids||{}
+						var tid=$(this).attr("_id")
+						if(!ids[tid]){
+							ids[tid]=true
+							$("#s_class").data("ids",ids)
+							var tpl1=$('<div class="alert alert-dismissible alert-success" style="min-width:50px;max-width:250px;font-size:10px;padding:3px;margin:5px;display:inline-block"><button type="button" class="close" data-dismiss="alert" style="right:0px;">&times;</button><span></span></div>')
+							tpl1.find("span").text($(this).text())							
+							tpl1.attr("tid",tid)
+							tpl1.find("button").click(function(){
+								var ttid=$(this).closest(".alert").attr("tid");
+								var iids=$("#s_class").data("ids")
+								delete iids[ttid]
+								$("#s_class").val(function(){
+									var strid=[]
+									for(var k in iids){
+										strid.push(k)
+									}
+									return strid.join(",")
+								}())
+							})
+							$("#s_show",parentDiv).append(tpl1)
+							$("#s_class").val(function(){
+								var strid=[]
+								for(var k in ids){
+									strid.push(k)
+								}
+								return strid.join(",")
+							}())
+						}
+					}},
+					//{label:"匹配逻辑",s_label:"s_matchlogic",type:"tpl_list_local",url:""},
+					{label:"字段",s_label:"s_field",placeholder:"title"},
+					{label:"起始id",s_label:"s_extlastid",must:true},
+					{s_label:"_id",type:"tpl_hidden"},
+				];
+				/*testtask=[
+					{label:"起始id",s_label:"s_startid",must:true},
+					{label:"数据数量",s_label:"s_datanum",placeholder:"5",must:true}
+				];*/
+				/*按钮*/
+				//新增保存按钮
+				addtaskbtn=[
+					{label:"保存",class:"btn-primary",
+						fun:function(){
+							var obj={}
+							var bcon=true
+							$("#_con").find("input[id!=s_show],textarea").each(function(i,el){
+								var val=$(el).val();
+								if(el.id!="_id"&&$(el).attr("must")&&!val){
+									bcon=false
+									return false
+								}
+								obj[el.id]=$(el).val()
+							})
+							if (bcon){								
+								$.post("/task/save",obj,function(data){
+									if(data&&data.rep){
+										//window.location.href="/task/list"
+										$('#myModal').modal('hide');
+										ttable.ajax.reload();
+									}else{
+										alert(data.msg)
+									}
+								},'json')
+							}else{
+								alert("红色标签的表单不能为空!")
+							}
+						}
+					}
+				];
+				if(n == "new"){
+					_tit="新增抽取任务";
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}else if(n == "edit"){
+					_tit="编辑-"+obj.s_taskname;
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}
+				htmlObj={
+					title:_tit,
+					tag:tag,
+					bts:bts
+				}
+			OpenDialog(htmlObj,obj)
+			break;
+			}
+		});
+	})
+	
+})
+function start(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/start",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload();
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function stop(_id){
+	showConfirm("确定停止?", function() {
+		$.ajax({
+			url:"/task/stop",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload()
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function del(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/del",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+</script>

+ 12 - 11
dataprocess/src/web/templates/com/logic_list.html

@@ -7,10 +7,10 @@
 <div class="content-wrapper" id="showbtn">
 	<section class="content-header">
 		<h1>
-			<small><a class="btn btn-primary opr" opr="new">新增任务</a></small>
+			<small><a class="btn btn-primary opr" opr="new">新增逻辑</a></small>
 		</h1>
 		<ol class="breadcrumb">
-		  <li><a href="/admin/task/list"><i class="fa fa-dashboard"></i> 任务管理</a></li>		  
+		  	<li><a href="/front/logic"><i class="fa fa-dashboard"></i> 逻辑管理</a></li>
 		</ol>
     </section>
   <!-- Main content -->
@@ -22,7 +22,7 @@
 		            <table id="dataTable" class="table table-bordered table-hover">
 		              <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>操作</th>
 		              </tr>
 		              </thead>
 		            </table>
@@ -37,7 +37,7 @@
 {{include "com/dialog.html"}}
 {{include "com/footer.html"}}
 <script>
-menuActive("list")
+menuActive("logic/list")
 $(function () {
 	ttable=$('#dataTable').DataTable({
 		"paging"      : false,
@@ -62,13 +62,14 @@ $(function () {
 				return dt.format("yyyy-MM-dd hh:mm:ss")
 			}},
 			{ "data": "s_username"},
-			{ "data": "s_descript","width":"25%"},
-			{ "data": "i_runstate",render:function(val){
-				if(val==1){
-					return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
-				}else{
-					return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
-				}
+			{ "data": "s_descript","width":"23%"},
+			{ "data": "_id","width":"21%",render:function(row){
+				add_logic = '<div>'+
+						'<a class="btn btn-sm btn-primary" href="/front/logic/pre">预处理</a> '+
+						'<a class="btn btn-sm btn-success" href="/front/logic/match">匹配</a> '+
+						'<a class="btn btn-sm btn-info" href="/front/logic/clean">清洗</a> '+
+						'</div>'
+				return add_logic
 			}},
 			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
 				tmp = '<div>'+

+ 252 - 0
dataprocess/src/web/templates/com/logic_match.html

@@ -0,0 +1,252 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+	<section class="content-header">
+		<h1>
+			<small><a class="btn btn-primary opr" opr="new">新增逻辑</a></small>
+		</h1>
+		<ol class="breadcrumb">
+		  	<li><a href="/front/logic"><i class="fa fa-dashboard"></i> 逻辑管理</a></li>
+			<li><a href="/front/logic/pre"><i class="fa fa-dashboard"></i> 预处理逻辑</a></li>
+		</ol>
+    </section>
+  <!-- Main content -->
+  <section class="content">
+      <div class="row">
+	      <div class="col-xs-12">
+	        <div class="box">
+		        <div class="box-body">
+		            <table id="dataTable" class="table table-bordered table-hover">
+		              <thead>
+		              <tr>
+		                <th>逻辑名称</th> <th>创建时间</th> <th>创建人</th> <th>描述</th><th>任务逻辑</th> <th>操作</th>
+		              </tr>
+		              </thead>
+		            </table>
+		        </div>
+	          <!-- /.box-body -->
+	        </div>
+        <!-- /.box -->
+		</div>
+	</div>
+  </section>
+</div>
+{{include "com/dialog.html"}}
+{{include "com/footer.html"}}
+<script>
+menuActive("logic/list")
+$(function () {
+	ttable=$('#dataTable').DataTable({
+		"paging"      : false,
+		"lengthChange": false,
+		"searching"   : false,
+		"ordering"    : false,
+		"info"        : true,
+		"autoWidth"   : false,
+		"ajax": {
+			"url": "/logic/list",
+			"type": "post",
+			"data":{}
+		 },
+		"language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+		"columns": [
+            { "data": "s_taskname"},
+			{ "data": "l_comeintime",render:function(val){
+				var dt=new Date()
+				dt.setTime(parseInt(val)*1000)
+				return dt.format("yyyy-MM-dd hh:mm:ss")
+			}},
+			{ "data": "s_username"},
+			{ "data": "s_descript","width":"25%"},
+			{ "data": "i_runstate",render:function(val){
+					if(val==1){
+						return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
+					}else{
+						return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
+					}
+				}},
+			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
+				tmp = '<div>'+
+					'<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
+					'<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
+					'<a class="btn btn-sm btn-info opr" opr="stop" onclick="stop(\''+row._id+'\')">停止</a> '+
+					'<a class="btn btn-sm btn-danger opr" opr="del" onclick="del(\''+val+'\')">删除</a>'+
+					'</div>';
+				return  tmp
+			}}
+       	]
+	});
+	ttable.on('init.dt', function () {
+		$("#showbtn").on('click','a.opr',function(){
+			var n=$(this).attr("opr");
+			var taskid=$(this).attr("taskid");
+			var htmlObj={},obj,tag=[],bts=[];
+			var _tit="";
+			switch(n){
+			case "edit":			
+				obj=ttable.row($(this).closest("tr")).data();	
+			case "new":
+				/*表单*/
+				addtask=[
+					{label:"任务名称",s_label:"s_taskname",placeholder:"数据清洗",must:true},
+					{label:"源库连接",s_label:"s_mgoaddr",must:true},
+					{label:"源数据库",s_label:"s_mgodb",must:true},
+					{label:"源表",s_label:"s_mgocoll",must:true},
+					{label:"保存表",s_label:"s_mgosavecoll",placeholder:"127.0.0.1:27080/dataprocess/bidding(数据库地址/数据库/表)",must:true},
+					{label:"描述",s_label:"s_descript",type:"tpl_text"},
+					/*
+					{label:"是否追踪",s_label:"i_track",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0,fun:function(){
+						var to=$("#i_track")					
+						to.val($(this).attr("_id"))
+						$("#s_show",to.closest("div")).val($(this).text())
+						//追踪表样式
+						$("#s_trackcoll").attr("must",$(this).attr("_id")==1)
+						$("#s_trackcoll").closest("div.row").find("label").css("color",$(this).attr("_id")==1?"red":"")
+					}},
+					{label:"追踪记录表",s_label:"s_trackcoll",must:function(){
+						return  obj&&obj.i_track
+					}()},
+					{label:"是否统计",s_label:"i_count",type:"tpl_list_local",must:true,list:[{"s_name":"是","_id":1},{"s_name":"否","_id":0}],default:0},
+					*/
+					//{label:"使用版本",s_label:"s_version",type:"tpl_list_local",must:true,url:"/admin/task/getversion"},
+					{label:"并发数量",s_label:"i_process",placeholder:"5",must:true},
+					{label:"预处理逻辑",s_label:"s_preprocesslogic",type:"tpl_list_local",url:""},
+					{label:"匹配逻辑",s_label:"s_class",type:"tpl_list_ajax",url:"",fun:function(){
+						var ids=$("#s_class").data("ids")
+						var parentDiv=$("#s_class").closest("div")
+						ids=ids||{}
+						var tid=$(this).attr("_id")
+						if(!ids[tid]){
+							ids[tid]=true
+							$("#s_class").data("ids",ids)
+							var tpl1=$('<div class="alert alert-dismissible alert-success" style="min-width:50px;max-width:250px;font-size:10px;padding:3px;margin:5px;display:inline-block"><button type="button" class="close" data-dismiss="alert" style="right:0px;">&times;</button><span></span></div>')
+							tpl1.find("span").text($(this).text())							
+							tpl1.attr("tid",tid)
+							tpl1.find("button").click(function(){
+								var ttid=$(this).closest(".alert").attr("tid");
+								var iids=$("#s_class").data("ids")
+								delete iids[ttid]
+								$("#s_class").val(function(){
+									var strid=[]
+									for(var k in iids){
+										strid.push(k)
+									}
+									return strid.join(",")
+								}())
+							})
+							$("#s_show",parentDiv).append(tpl1)
+							$("#s_class").val(function(){
+								var strid=[]
+								for(var k in ids){
+									strid.push(k)
+								}
+								return strid.join(",")
+							}())
+						}
+					}},
+					//{label:"匹配逻辑",s_label:"s_matchlogic",type:"tpl_list_local",url:""},
+					{label:"字段",s_label:"s_field",placeholder:"title"},
+					{label:"起始id",s_label:"s_extlastid",must:true},
+					{s_label:"_id",type:"tpl_hidden"},
+				];
+				/*testtask=[
+					{label:"起始id",s_label:"s_startid",must:true},
+					{label:"数据数量",s_label:"s_datanum",placeholder:"5",must:true}
+				];*/
+				/*按钮*/
+				//新增保存按钮
+				addtaskbtn=[
+					{label:"保存",class:"btn-primary",
+						fun:function(){
+							var obj={}
+							var bcon=true
+							$("#_con").find("input[id!=s_show],textarea").each(function(i,el){
+								var val=$(el).val();
+								if(el.id!="_id"&&$(el).attr("must")&&!val){
+									bcon=false
+									return false
+								}
+								obj[el.id]=$(el).val()
+							})
+							if (bcon){
+								$.post("/task/save",obj,function(data){
+									if(data&&data.rep){
+										//window.location.href="/task/list"
+										$('#myModal').modal('hide');
+										ttable.ajax.reload();
+									}else{
+										alert(data.msg)
+									}
+								},'json')
+							}else{
+								alert("红色标签的表单不能为空!")
+							}
+						}
+					}
+				];
+				if(n === "new"){
+					_tit="新增抽取任务";
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}else if(n == "edit"){
+					_tit="编辑-"+obj.s_taskname;
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}
+				htmlObj={
+					title:_tit,
+					tag:tag,
+					bts:bts
+				}
+			OpenDialog(htmlObj,obj)
+			break;
+			}
+		});
+	})
+	
+})
+function start(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/start",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload();
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function stop(_id){
+	showConfirm("确定停止?", function() {
+		$.ajax({
+			url:"/task/stop",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload()
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function del(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/del",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+</script>

+ 190 - 0
dataprocess/src/web/templates/com/logic_pre.html

@@ -0,0 +1,190 @@
+{{include "com/inc.html"}}
+<!-- Main Header -->
+{{include "com/header.html"}}
+<!-- Left side column. 权限菜单 -->
+{{include "com/menu.html"}}
+
+<div class="content-wrapper" id="showbtn">
+	<section class="content-header">
+		<h1>
+			<small><a class="btn btn-primary opr" opr="new">新增逻辑</a></small>
+		</h1>
+		<ol class="breadcrumb">
+		  	<li><a href="/front/logic"><i class="fa fa-dashboard"></i> 逻辑管理</a></li>
+			<li><a href="/front/logic/pre"><i class="fa fa-dashboard"></i> 预处理逻辑</a></li>
+		</ol>
+    </section>
+  <!-- Main content -->
+  <section class="content">
+      <div class="row">
+	      <div class="col-xs-12">
+	        <div class="box">
+		        <div class="box-body">
+		            <table id="dataTable" class="table table-bordered table-hover">
+		              <thead>
+		              <tr>
+		                <th>逻辑名称</th> <th>创建时间</th> <th>创建人</th> <th>描述</th><th>任务逻辑</th> <th>操作</th>
+		              </tr>
+		              </thead>
+		            </table>
+		        </div>
+	          <!-- /.box-body -->
+	        </div>
+        <!-- /.box -->
+		</div>
+	</div>
+  </section>
+</div>
+{{include "com/dialog.html"}}
+{{include "com/footer.html"}}
+<script>
+menuActive("logic/list")
+$(function () {
+	ttable=$('#dataTable').DataTable({
+		"paging"      : false,
+		"lengthChange": false,
+		"searching"   : false,
+		"ordering"    : false,
+		"info"        : true,
+		"autoWidth"   : false,
+		"ajax": {
+			"url": "/logic/list",
+			"type": "post",
+			"data":{}
+		 },
+		"language": {
+            "url": "/dist/js/dataTables.chinese.lang"
+        },
+		"columns": [
+            { "data": "s_taskname"},
+			{ "data": "l_comeintime",render:function(val){
+				var dt=new Date()
+				dt.setTime(parseInt(val)*1000)
+				return dt.format("yyyy-MM-dd hh:mm:ss")
+			}},
+			{ "data": "s_username"},
+			{ "data": "s_descript","width":"25%"},
+			{ "data": "i_runstate",render:function(val){
+					if(val==1){
+						return "<i class='fa fa-fw fa-circle text-green'></i>运行中"
+					}else{
+						return "<i class='fa fa-fw fa-circle text-danger'></i>未启动"
+					}
+				}},
+			{ "data":"_id","width":"25%",render:function(val,a,row,pos){
+				tmp = '<div>'+
+					'<a class="btn btn-sm btn-primary opr" opr="edit" row="'+pos.row+'" >编辑</a> '+
+					'<a class="btn btn-sm btn-success opr" opr="start" onclick="start(\''+row._id+'\')">启动</a> '+
+					'</div>';
+				return  tmp
+			}}
+       	]
+	});
+	ttable.on('init.dt', function () {
+		$("#showbtn").on('click','a.opr',function(){
+			var n=$(this).attr("opr");
+			var taskid=$(this).attr("taskid");
+			var htmlObj={},obj,tag=[],bts=[];
+			var _tit="";
+			switch(n){
+			case "edit":			
+				obj=ttable.row($(this).closest("tr")).data();	
+			case "new":
+				/*表单*/
+				addtask=[
+					{label:"逻辑名称",s_label:"s_logicname",placeholder:"数据清洗",must:true},
+					{label:"描述",s_label:"s_descript",type:"tpl_text",must:true},
+					{s_label:"_id",type:"tpl_hidden"},
+				];
+				/*按钮*/
+				//新增保存按钮
+				addtaskbtn=[
+					{label:"保存",class:"btn-primary",
+						fun:function(){
+							var obj={}
+							var bcon=true
+							$("#_con").find("input[id!=s_show],textarea").each(function(i,el){
+								var val=$(el).val();
+								if(el.id!="_id"&&$(el).attr("must")&&!val){
+									bcon=false
+									return false
+								}
+								obj[el.id]=$(el).val()
+							})
+							if (bcon){
+								console.log(obj)
+								$.post("/front/logic/pre/save",obj,function(data){
+									if(data&&data.rep){
+										//window.location.href="/task/list"
+										$('#myModal').modal('hide');
+										ttable.ajax.reload();
+									}else{
+										alert(data.msg)
+									}
+								},'json')
+							}else{
+								alert("红色标签的表单不能为空!")
+							}
+						}
+					}
+				];
+				if(n == "new"){
+					_tit="新增抽取任务";
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}else if(n == "edit"){
+					_tit="编辑-"+obj.s_taskname;
+					tag = com.pushArry(tag,addtask);
+					bts = com.pushArry(bts,addtaskbtn);
+				}
+				htmlObj={
+					title:_tit,
+					tag:tag,
+					bts:bts
+				}
+			OpenDialog(htmlObj,obj)
+			break;
+			}
+		});
+	})
+	
+})
+function start(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/start",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload();
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function stop(_id){
+	showConfirm("确定停止?", function() {
+		$.ajax({
+			url:"/task/stop",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				//window.location.reload()
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+function del(_id){
+	showConfirm("确定启动?", function() {
+		$.ajax({
+			url:"/task/del",
+			type:"post",
+			data:{"_id":_id},
+			success:function(r){
+				ttable.ajax.reload();
+			}
+		})
+	});
+}
+</script>