!19 魔改版合并

Merge pull request !19 from 我是D/dev
This commit is contained in:
小东 2019-12-24 15:19:35 +08:00 committed by Gitee
commit cdac7d2e73
10 changed files with 69 additions and 30 deletions

View File

@ -5,12 +5,9 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.spiderflow.context.SpiderContext;
import org.spiderflow.context.SpiderContextHolder;
import org.spiderflow.core.Spider;
@ -65,14 +62,15 @@ public class SpiderJob extends QuartzJobBean {
}
public void run(SpiderFlow spiderFlow, Date nextExecuteTime) {
SpiderJobContext context = null;
Date now = new Date();
SpiderJobContext context = SpiderJobContext.create(this.spiderLogPath, spiderFlow.getId() + ".log");
SpiderContextHolder.set(context);
Task task = new Task();
task.setFlowId(spiderFlow.getId());
task.setBeginTime(new Date());
try {
taskService.save(task);
context = SpiderJobContext.create(this.spiderLogPath, spiderFlow.getId() + task.getId() + ".log");
SpiderContextHolder.set(context);
contextMap.put(task.getId(), context);
logger.info("开始执行任务{}", spiderFlow.getName());
spider.run(spiderFlow, context);
@ -80,7 +78,9 @@ public class SpiderJob extends QuartzJobBean {
} catch (Exception e) {
logger.error("执行任务{}出错", spiderFlow.getName(), e);
} finally {
context.close();
if (context != null) {
context.close();
}
task.setEndTime(new Date());
taskService.saveOrUpdate(task);
contextMap.remove(task.getId());

View File

@ -15,6 +15,8 @@ import org.spiderflow.core.model.SpiderFlow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 爬虫定时执行管理
* @author Administrator
@ -51,7 +53,7 @@ public class SpiderJobManager {
* @param spiderFlow 爬虫流程图
* @return boolean true/false
*/
public boolean addJob(SpiderFlow spiderFlow){
public Date addJob(SpiderFlow spiderFlow){
try {
JobDetail job = JobBuilder.newJob(SpiderJob.class).withIdentity(getJobKey(spiderFlow.getId())).build();
job.getJobDataMap().put(JOB_PARAM_NAME, spiderFlow);
@ -60,12 +62,10 @@ public class SpiderJobManager {
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(spiderFlow.getId())).withSchedule(cronScheduleBuilder).build();
scheduler.scheduleJob(job,trigger);
return true;
return scheduler.scheduleJob(job,trigger);
} catch (SchedulerException e) {
logger.error("创建定时任务出错",e);
return false;
return null;
}
}

View File

@ -54,10 +54,16 @@ public interface SpiderFlowMapper extends BaseMapper<SpiderFlow>{
@Update("update sp_flow set enabled = #{enabled} where id = #{id}")
int resetSpiderStatus(@Param("id") String id, @Param("enabled") String enabled);
@Update("update sp_flow set next_execute_time = null where id = #{id}")
int resetNextExecuteTime(@Param("id") String id);
@Select("select id,name from sp_flow")
List<SpiderFlow> selectFlows();
@Select("select id,name from sp_flow where id != #{id}")
List<SpiderFlow> selectOtherFlows(@Param("id") String id);
@Select("select max(a.id) from `sp_task` a left join sp_flow b on a.flow_id = b.id where b.id = #{id}")
int getFlowMaxTaskId(@Param("id")String id);
}

View File

@ -43,10 +43,14 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
@PostConstruct
private void initJobs(){
List<SpiderFlow> spiderFlows = sfMapper.selectList(new QueryWrapper<SpiderFlow>().eq("enabled", "1"));
if(spiderFlows != null){
if(spiderFlows != null && !spiderFlows.isEmpty()){
for (SpiderFlow sf : spiderFlows) {
if(StringUtils.isNotEmpty(sf.getCron())){
spiderJobManager.addJob(sf);
Date nextExecuteTimt = spiderJobManager.addJob(sf);
if (nextExecuteTimt != null) {
sf.setNextExecuteTime(nextExecuteTimt);
sfMapper.updateById(sf);
}
}
}
}
@ -110,14 +114,19 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
public void stop(String id){
sfMapper.resetSpiderStatus(id,"0");
sfMapper.resetNextExecuteTime(id);
spiderJobManager.remove(id);
}
public void start(String id){
spiderJobManager.remove(id);
SpiderFlow spiderFlow = getById(id);
spiderJobManager.addJob(spiderFlow);
sfMapper.resetSpiderStatus(id,"1");
Date nextExecuteTime = spiderJobManager.addJob(spiderFlow);
if (nextExecuteTime != null) {
spiderFlow.setNextExecuteTime(nextExecuteTime);
sfMapper.updateById(spiderFlow);
sfMapper.resetSpiderStatus(id, "1");
}
}
public void run(String id){
@ -164,4 +173,8 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
}
return list;
}
public Integer getFlowMaxTaskId(String flowId){
return sfMapper.getFlowMaxTaskId(flowId);
}
}

View File

@ -156,8 +156,12 @@ public class SpiderFlowController {
}
@RequestMapping("/log")
public JsonBean<List<Line>> log(String id, String keywords, Long index, Integer count, Boolean reversed,Boolean matchcase,Boolean regx){
try (RandomAccessFileReader reader = new RandomAccessFileReader(new RandomAccessFile(new File(spiderLogPath,id + ".log"),"r"), index == null ? -1 : index, reversed == null || reversed)){
public JsonBean<List<Line>> log(String id, String taskId, String keywords, Long index, Integer count, Boolean reversed, Boolean matchcase, Boolean regx) {
if (StringUtils.isBlank(taskId)) {
Integer maxId = spiderFlowService.getFlowMaxTaskId(id);
taskId = maxId == null ? "" : maxId.toString();
}
try (RandomAccessFileReader reader = new RandomAccessFileReader(new RandomAccessFile(new File(spiderLogPath,id + taskId +".log"),"r"), index == null ? -1 : index, reversed == null || reversed)){
return new JsonBean<>(reader.readLine(count == null ? 10 : count,keywords,matchcase != null && matchcase,regx != null && regx));
} catch(FileNotFoundException e){
return new JsonBean<>(0,"日志文件不存在");

View File

@ -495,35 +495,43 @@ $(function(){
},{
name : 'request',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACbUlEQVRYR+2XTXLTQBCFX5sF7DALsHaYE+AbxD4ByQlITmDrBCQnGHMClBMkOUHMCRAnIOwU2JhdssCPamnkkmRJM5KTKqpgqryxpqe/7unpH0HHFRhOIXhPYCLARMUJxALEIM6TUFZdjhTfzS8NJ08EBsDUIbP6TYQ/Q4l9zvYCUKspuBBg6HMogbUQRz7ecAKo5QPBta/yHFAhNsTM5QknQLDkNwBjH8tr9twkC3nTJtsKEBgeQ/Cpp/JMjDhJQomazmgFGBleiuDdPgAkrm5DOewFECzJfZTnsslCGg1NPwSGYwqMCOJkLme54GMAvDI8HAjmG+Ljj1AuUwD754VVHCULORkaDp/ZRLOvF+6AeB3KuhRTWdI63rqmct8RBmgMnD5AJCZCLNO4JL7eA1OF2gKoxU+BlQje9lHgK1NUrjKl4OgMQcxsLVj6gFeV7wDYgDyF4IOPRXl0B4YrCA6cMsRZEsppcd/O8wgM/wP8Yx4YGWqiLOZ7rXxe1a9zEAI3yH5ZnSKuZJ902wNg56FImobLKVd7PveTAtAZgPgMYNszbrJesrz+hmeoHrh2JpUeHtgQR1oBXYno0QBAzKqNam2jMDJci+C5ywtdY+COeKEVsNUD+nFkqMVl/pAATa1ZrQfsEPLlIQHq7r+2GqYlOZsD0rGrbXW5Ah3f7olZ6xVUlWv9bqvzXgDEdwhe275hB6LcERUtt/18YBjpMFrnCSeA7fuKvWDVE1uAkqLKMJEeAGiVTC3JVxMAiV8CLIoDSV1DWooBLUqqpCpYVGjTtg4ZY03XJYBsTF8TiKrJJj8jhyAR3oaSNqh/AKendd/nwfiIAAAAAElFTkSuQmCC',
title : '开始抓取'
title : '开始抓取',
desc : '抓取静态HTML页面或者API接口抓取结果存为resp变量中。<br/>支持方法参考命令提示。'
},{
name : 'variable',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAgCAYAAACYTcH3AAACe0lEQVRYR+2WMW5TQRCGv0mEoMMUKK80J0joKJBITgCUVAkniLehjQ+A9GwugLlBboA5QZITYLpnaEwXkZhBs+xu1s8vkhMDMpItudh9szP//PPP7Aor9JMVwsLqgmmV2roD7W9OTpsYe1jqzgWMJk4m9e/FO30W986nnDXZ1P2bPzsT480ws9XTE4EdlNeVk0EesCj1AOE9MKw6smffzPk9oQQOGsAPz5WXOajcP4KB9+cUTrng6SyYUici3M8DxiDRkSpnYyc+o+TcHCpnAhOFlgjb4VwCbuuipxr2R0A7T0DhSR1MT4RDb6Q8qpzYIYpS2wif/bbixk56Ram7CB+D7QyTRanDkDlVR1KMDIz5/wAMfhp4aJvPGTBNQT0DpSaQ58oDo95KdBeslKOxk06eZW6Pslc5GdaYIfrJz811U8zK6jjuyOPgxFhpWzaVkxl9eN1sso2ya3+FHYFWCtIERvlUOdmt66wJTBSqL5UHcVWOlKUH2dcjVToxuCrfTW9+/Vug5mOemUXBhLJ4IavSD473Ub5UTpLosu7y9Z9CL7ZoUWoX4ehPgYkaGfnugFYUbuquUo9FeG7rXKQhmfRtaWZyIadBFoQb10WpA4T9vJu8fjY4ROlmmkmdlrrpJmUK7Zzas0m4Nj03hZO6CEP797MRkUSfgZlrBDt37d1kwTZgYIPMJmWcOXnwYNP1UxtsJtm/a7amKYWOQverk+OQoDF2MIUXTVfO6l6UTZT/y701M9exvWZmzcxNO3F1NbPV18OZt8hNU1vCXn/w9upJmD0tl/B566MqvKo/O+3umHuB3TrC4gdHesmb1dXM4on8Hcs1M//FBP4FX81QGwO29kEAAAAASUVORK5CYII=',
title : '定义变量'
title : '定义变量',
desc : '定义流程变量。<br/>定义变量有先后顺序,先定义变量后续可以使用,拖动可以交换变量顺序。'
},{
name : 'loop',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADO0lEQVRYR9WWS2hTURCGvwnVlVjpzgdWxQeo0IWP7rQuRBQVFayLSlUQH5V2UWhzo4takOTGCF1UlOJCKyJiFxUFSwWxioguRBEV31qhVXeKSI3ajJybGxPTJDdpCtUDIeFmZv7vzpmZc4RxXjLO+vzHAH4tZZhySihzsih8JCTPCs1o/hlo0UlE2QlsA2YD0zOI3QV68dFBUD7kA+MN0KIT+U4zwg5gbkrQn8ArYELac2MyCJzClsNeELkB/DoT4SJQ6QZ6AZzFRw8TeEyr/HCeH9YyhqhEWAzUAbNc+26GaSIir7OBZAcIaCXKbaAEGAIaidJJm5jf2ZelRrwFnO0y6wlCNSF5mskpM0CdTmIyX12HAWLs4Khc90rnX/9bagBO/4FQ1hGW9+kxMgNYesEpNuUtw2zimDwqSDxhbOlupxbMUjoIyz5vAEuN0UnXqYawnB+VeBKiCTjqxjNZ6EmNNzIDlt4AqhDaCUlDUeJJiHNATaaYIwECuhClOp8WyhsuoOtRrjhta8u83BnIO2qBhpaq67EUW+4nvP/OgKWm55cBzdjSVaBEZnOzpcoUBDMlTX3tdVs0ii2rkgBx8a0pUcw2FA9h6QAwzZkHsCjlexBbpscBRoonOIqHCOhGlLNAacrLfUGoJSSXBUurAFP55kTrRylH+YwwBegzaSp6K/y6AnGG0hzgDcouwnIrLmmWXyP4uIk6J912FNP7gwjfxqwbDupiYrTjo56gPM5WhHuADicDMZYTkZdFv71HgPQuMMdtXFRpICztYwJgqSnuOpRDhOWO1yS8CqwFerBlXdEAAZ2PYg6yGUBr+paOnIR+rUXodIXbsKWxKIhkhw3gYwlB+eQ9Cf16HOGAa1iPLcdHBWHpEeCQ67sGW66lx8l+IUmdDUITITlWEERAT6Dsd326sWVLJv/cV7Lk/Da+ffiwCUpvTpD4wWO6aYNr14Ut1dl8vC+lliaKMh5DuYQP08cP8HEP5RcxKlAWIKxOETbWFraEcwF7Azhh1LyR+Szx3AYzQ+AMMTqJyEMv+/wAElEs3QxUACvdA2YqEAWeu/Oj3xG35Z2XcOZJmK/XGNoVloExFP5nMvAbItf8IXnK1DcAAAAASUVORK5CYII=',
title : '循环'
title : '循环',
desc : ''
},{
name : 'loopJoin',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADtUlEQVRYR8WXTWgdVRTHf2cCJgi2RdGFWFGXpaZ+2xYEu7FYF9222oVRsaAgJjbJJF34umhyk2grgoLBahetydaFLbppQTCpGmOiuIylSheKYhWkETpHzsyd92bem3mZxgQPPHjMPR//e8+55/yv8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uj+t5mr3qKVuVurxAwFv//WnWHCqhbpaaLSWP0x+A80a1qqDMN6KqFmus9y+zTEcwb5XSdQAAAABJRU5ErkJggg==',
title : '循环结束'
title : '循环结束',
desc : ''
},{
name : 'output',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAByUlEQVRYR+WXwVHDMBBF/4YD3AgHwEd3QKiA0IE7IOnAqoCkAqWDmAqACggVJJTAzRku4UYOmWVWloMZgi17bGcGdNGMrZWeVtrdL4JtXc3dI8I9gH76rWIfxSENXW0pHehpHoAwdTXMHccYx4pGLnNlAUYg3BojxtjFODPGB+Hmmw1jGCuKiubZCRCHtP1eNIH89zT3QXgy7IwXIlzYjRRC1A7wwTg5BGauELUDiPfkQrtCNAIg7neFaAzAFaJRAIE41dzrJHfieNfFrB2gMGoYz7GibbL7GwAmjQO9vN0zMDGh2YQHCt2eJKsZCFf/F+A3L9VyCV2OQMLxgKA3DPWmaJHatAbgaTbVloHFmnG9UrQSiDYBfFlcEpL0y5AuWwWQxc40B51EdUkzyqmUB6xs0wB8l3PfNYaBHgFdqx1UKYCs8KgKkLVjYFUKwJbYKN1BFQjjga/CNC4FUGXBrI0NxbmtinexokFrAJ5mnwlz8Z7oxjXQl1BsEyDJA4z3NeC3ngeM+4HJBgj3kgn3XgvONRs9IOe/VBTuoxa46wEQnN51pcKSMTAZNEcR1fc4zSFjxuNSUfDjCKyuezCyqanGeN0AQTYKPgFOSUMAph/CYQAAAABJRU5ErkJggg==',
title : '输出'
title : '输出',
desc : '输出流程中的变量结果(仅测试下有用)'
},{
name : 'executeSql',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAD1ElEQVRYR7WXUXIaRxCGv4YqR2+WH2zxZukEUU5gdAKjExhfILAnMD7BohMYn8D4BEYnsHQCobfd5CHkDVIFnerZmc0sLAJjMlVUSbszPX93//13r7DnOk319JcGb0TpAOfRzyxMw0+F8WLF7S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453ycQ7DH/o0iy276QisQgq1q64wJ5SzZPla+WznDv44Xb/J0vIM2o1CmEwJT4NSuq5mqYLpCsb/wGRf3vwLgODoY+vqQ1gAAAAASUVORK5CYII=',
title : '执行SQL'
title : '执行SQL',
desc : '执行sql需配置数据源sql执行结果存于变量rs中。<br/>语句类型为select返回:List&lt;Map&lt;String,Object&gt;&gt;<br/>语句类型为selectOne返回:Map&lt;String,Object&gt;<br/>语句类型为selectInt返回:Integer<br/>语句类型为insert、update、delete返回:int批量操作返回int数组<br/>sql中变量必须用 # # 包裹,如:#${title}#'
},{
name : 'function',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAgCAYAAACPb1E+AAAC9UlEQVRYR+2YP0zUUBjAf9+RKJPgQK6THptxERPiZOTUxEUj/tlMjCS62xoT3YARl5bJTXByBGcHISQmxhjQ6A6TPRg8JrnE62de6Z0Htne9XhMw4W1N3/u+X7//rwJgzeokygRQMs+HYSksBsr0liNrYrk6gTB3GMBiGNZ9W4al6OqiCOOqfFGYKkD1oIEVRkRwQw5l2FhyCWEMZdp3ZOqgARv6LU/1CDIPbxxZMg8rhmUxj5gcdHWw6khiJSh6+lVgAGXMd2S90/79H9czpOXpd+CsKk7FEe8fBab2whwCdeF6n/ISOFUPuLT1RFbSWLsnSMvTOVUmREJVM74tz1uVGov1C6tR9/rs2zJqefoL6FfYDpSy6SKdQDNDGkAI2yeqvKk4ci/GilMIk40aZ1w95OpIQVgWOKFQDZTLnUAzQbYCorz2HQlhW5flakmFVYFBVWYrjtiN9yEoLIkwkAa0a0jL0x8m4SLrxAKGGenqPMIDVbZrUNqfWE1Qk1AFqAc83HLkVZzrs0AGgKhQDwJG41xluVpGeB99SGKLtTx9i3LTJFUAC5u23MkFcsjTZwWYFjie5CrLUwNYRtnwHYkd+fbENHyr/eZG9als5AJphLSLqdZxL1BubzqyGFP3mkmXFNN74jtrMW8FRdgB7u4EfGiWHGXZd6QcA7iCcBEz1yQkXa7F3ID2wUeEY0HATJ9wRoVxo6SunI+N18gqCu8qtlzrVCNzaYtFVx8BVwJ4UYB5Ec4pfKrYciEOoOiqjXC1ptxv10pzcXccQBQC5VqdhaQkSGO5XN2dRWGWM13XySxKej1zBNmrBRvnYy25fyDIS1kWOdG49zNqseG92xPhcSRsqWuhgoXSn3jOFH3F71Kuaatha91RTpp7d0lhzYxQXQra3W66yO4AHL86vW+nNOpOofgI9JaZAzOAmt80p9tAmgFivlu5Aaw1ZoB2Nkglt/kHJNmSsf08lfBoU2pIy9W/14JuNCTs9e3olpRC1n8B+Qd0Dhp9ddQMugAAAABJRU5ErkJggg==',
title : '执行函数'
title : '执行函数',
desc : '单独执行函数方法,结果不保存为变量'
},{
name : 'process',
image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACMklEQVRYR+2WwXHTQBSGv+fMkNwIB7BvMRVgV0DoIFRAUoGlCpJUsKICnApCB4QKcCrAvslwwEebGfyYp2g1QgmytBmPOaCjtLv/t+/9+neFHT+yY31aAxw6PdwXzgVOgH5lA1OEcTqSy6Ybaw3QdZqIMKoTUOX9PJaoCUQIwEKEp7+U4fdYJmWR504He8IXYJpG8tK+9RJVP0ZhIkKSjuTKv9sOgDJLY8naUwYog6yUN4tYFq0Bek4vEM5ry6tcprFclMeYd57AcQcShCOrxjySYWsAWzTzgZlQOPoDRJkB46p4FeQAJtlc5SwIoIm56sa8cHrSEa4zTzx2sZD51o4D4YfN3QlAz2kf4evOAIoWKLetKxCShD2np2ksY9txXn7Lin6QCdsmoYkjfFgqz/Y7vBYlMXFVbuexDB6sQNdphPBOYOBNlkaSje06bZyEXrxqVBNfwfG9IMrL+6ksHASQJ2EVwIQFEt+OeybsOrWsfoUyW0P0E26MsryDtknoIXwFq9UoWmBlF8GZ+BIGVeHyxLZJWDZhHUC2+7Xy9lssH0MCJmROUQF/aplb63YfIlI3598B8AbcWQsKE8J0qQx9G3pO7Xg99WUMScJGLchD5u43hKkK0WrN5/zUGqeRnBV3gW3dCbPdwU0OUQXPINokYRPDPhjF9t8qWC5YNe4e5cpa0QigdCfcBLHxNMx+z1zcFmubhI8HqJiw8EHgnfCvSbiJdFvfN7ZgW8J+3f8AvwFIqFFyobd5IgAAAABJRU5ErkJggg==',
title : '子流程'
title : '子流程',
desc : '执行其他spiderFlow流程父子流程变量共享'
}];
var addShape = function(shape){
var image = new Image();
@ -532,7 +540,11 @@ $(function(){
image.id = shape.name;
image.onclick = function (ev) {
if(shape.desc){
layer.tips("(" + shape.name + ")" + shape.title + "<hr/>" + shape.desc, '#' + shape.name);
layer.tips("(" + shape.name + ")" + shape.title + "<hr/>" + shape.desc, '#' + shape.name,{
tips: [1, '#3595CC'],
area: ['auto', 'auto'],
time: 4000
});
}
}
if(!shape.hidden){

View File

@ -5,6 +5,7 @@ function LogViewer(options){
this.onSearchFinish = options.onSearchFinish || function(){};
this.bufferSize = this.maxLines * 10;
this.logId = options.logId;
this.taskId = options.taskId;
this.url = options.url;
this.buffer = [];
this.displayIndex = -1;
@ -148,6 +149,7 @@ LogViewer.prototype.loadLines = function(count,callback,async){
reversed : this.reversed,
count : this.bufferSize,
id : this.logId,
taskId: this.taskId,
index : _this.index,
keywords : this.keywords,
matchcase : this.matchcase,

View File

@ -170,10 +170,12 @@
<script type="text/javascript">
$(function(){
var logId = getQueryString('id');
var taskId = getQueryString('taskId');
var viewer = new LogViewer({
url: 'spider/log',
maxLines : parseInt(($('.log-container').height() - 8) / 14),
logId : logId,
taskId: taskId,
element : $('.log-container'),
onSearchFinish : function(hasData){
if(hasData){

View File

@ -187,7 +187,7 @@
</script>
<script type="text/html" id="buttons">
<a class="layui-btn layui-btn-sm btn-run" data-id="{{d.id}}">手动运行</a>
<a class="layui-btn layui-btn-sm btn-log" data-name="{{d.name}}" data-id="{{d.id}}">查看日志</a>
<a class="layui-btn layui-btn-sm btn-log" data-name="{{d.name}}" data-id="{{d.id}}">最新日志</a>
<a class="layui-btn layui-btn-sm btn-remove" data-id="{{d.id}}">删除</a>
</script>
</body>

View File

@ -90,14 +90,14 @@
layui.layer.close(index);
})
}).on('click','.btn-log',function(){
parent.openTab(decodeURIComponent(decodeURIComponent(getQueryString('name'))) + '-日志',$(this).data('id') + '-log','log.html?id=' + $(this).data('id'));
parent.openTab(decodeURIComponent(decodeURIComponent(getQueryString('name'))) + '-日志',$(this).data('id') + '-log','log.html?id=' + $(this).data('id') + "&taskId=" + $(this).data("task"));
})
</script>
<script type="text/html" id="buttons">
{{# if(!d.endTime){ }}
<a class="layui-btn layui-btn-sm btn-stop" data-id="{{d.id}}">停止</a>
{{# } }}
<a class="layui-btn layui-btn-sm btn-log" data-id="{{d.flowId}}">查看日志</a>
<a class="layui-btn layui-btn-sm btn-log" data-id="{{d.flowId}}" data-task="{{d.id}}">查看日志</a>
<a class="layui-btn layui-btn-sm btn-remove" data-id="{{d.id}}">删除记录</a>
</script>
</body>