mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-01-09 16:56:56 +08:00
Pre Merge pull request !33 from OSDEVER/v6
This commit is contained in:
commit
2f0f5f24f7
@ -113,4 +113,46 @@ class Queue extends Controller
|
||||
{
|
||||
SystemQueue::mDelete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置重复任务的下次执行时间
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function exec()
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
SystemQueue::mForm('', 'code');
|
||||
} else {
|
||||
try {
|
||||
$data = $this->_vali([
|
||||
'code.require' => '任务编号不能为空!',
|
||||
'exec_time.require' => '执行时间不能为空',
|
||||
]);
|
||||
|
||||
// 任务编号
|
||||
$map = ['code' => $data['code']];
|
||||
$info = SystemQueue::mk()->where($map)->find();
|
||||
if (empty($info)) $this->error('任务不存在');
|
||||
|
||||
// 任务状态检查
|
||||
if ($info['status'] <> 1) $this->error('任务当前状态不可重置下次执行时间');
|
||||
|
||||
// 更新任务下次执行时间
|
||||
$this->app->db->transaction(function () use ($map, $data) {
|
||||
SystemQueue::mk()->where($map)->update([
|
||||
'exec_time' => strtotime($data['exec_time'])
|
||||
]);
|
||||
});
|
||||
$this->success('任务重置成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
app/admin/view/queue/exec.html
Normal file
24
app/admin/view/queue/exec.html
Normal file
@ -0,0 +1,24 @@
|
||||
<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="QueueTable">
|
||||
|
||||
<div class="layui-card-body">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">下次执行时间</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="exec_time" value='' data-date-input="datetime" required placeholder="请选择下次执行时间" class="layui-input">
|
||||
<p class="help-block"><b>仅重复任务可设置,请勿早于当前时间</b></p>
|
||||
<p class="help-block">启动重复任务时可设置延时时间</p>
|
||||
<p class="help-block">再手动修改下次(第一次的)时间即可</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
{notempty name='vo.code'}<input type='hidden' value='{$vo.code}' name='code'>{/notempty}
|
||||
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" type='submit'>保存数据</button>
|
||||
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
|
||||
</div>
|
||||
</form>
|
||||
@ -99,14 +99,22 @@
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
|
||||
<!--{if auth('redo')}-->
|
||||
{{# if(d.status===4||d.status===3){ }}
|
||||
<a class="layui-btn layui-btn-sm" data-confirm="确定要重置该任务吗?" data-queue="{:url('redo')}?code={{d.code}}">重 置</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn layui-btn-sm layui-btn-disabled">重 置</a>
|
||||
{{# } }}
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth('exec')}-->
|
||||
{{# if(d.status===1){ }}
|
||||
<a class="layui-btn layui-btn-sm" data-width="450px" data-modal='{:url("exec")}?code={{d.code}}'">重 置</a>
|
||||
{{# }else{ }}
|
||||
|
||||
<!--{if auth('redo')}-->
|
||||
{{# if(d.status===4||d.status===3){ }}
|
||||
<a class="layui-btn layui-btn-sm" data-confirm="确定要重置该任务吗?" data-queue="{:url('redo')}?code={{d.code}}">重 置</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn layui-btn-sm layui-btn-disabled">重 置</a>
|
||||
{{# } }}
|
||||
<!--{/if}-->
|
||||
|
||||
{{# } }}
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth('remove')}-->
|
||||
<a class='layui-btn layui-btn-sm layui-btn-danger' data-confirm="确定要删除该任务吗?" data-action='{:url("remove")}' data-value="id#{{d.id}}">删 除</a>
|
||||
|
||||
@ -888,7 +888,7 @@ define('ThinkAdmin', function (require) {
|
||||
onEvent('click', '[data-modal]', function () {
|
||||
var un = undefined, emap = this.dataset, data = {open_type: 'modal'};
|
||||
return applyRuleValue(this, data, function () {
|
||||
return $.form.modal(emap.modal, data, emap.title || this.innerText || '编辑', un, un, un, emap.area || emap.width || '800px', emap.offset || 'auto', emap.full !== un);
|
||||
return $.form.modal(emap.modal, data, emap.title || this.innerText || '编辑', un, un, un, (typeof emap.area === 'string' ? eval("(" + emap.area + ")") : undefined) || emap.width || '800px', emap.offset || 'auto', emap.full !== un);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user