mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-05 19:41:44 +08:00
Pre Merge pull request !32 from LiuPengFei/v6
This commit is contained in:
commit
dfdaf3675e
@ -112,4 +112,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="MenuTable">
|
||||
|
||||
<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' data-confirm="确定要重置该任务的下次执行时间吗?">保存数据</button>
|
||||
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
|
||||
</div>
|
||||
</form>
|
@ -104,7 +104,7 @@
|
||||
{{# 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>
|
||||
<a class="layui-btn layui-btn-sm" data-width="400px" data-modal='{:url("exec")}?code={{d.code}}'">重 置</a>
|
||||
{{# } }}
|
||||
<!--{/if}-->
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user