feature: task

This commit is contained in:
zhuyu 2025-03-30 17:59:00 +08:00
parent b5c32bb8ad
commit 7e535c03b0
7 changed files with 158 additions and 149 deletions

View File

@ -69,4 +69,70 @@ class Task extends Backend
return $this->view->fetch();
}
public function complete($ids)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'id'));
}
$task = $this->model->where('id', '=', $ids)->where('status', 1)->find();
if (!$task) {
$this->error('任务状态已变更,请刷新后操作');
}
$task->save(['status' => 3]);
$this->success();
}
public function pass($ids)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'id'));
}
$task = $this->model->where('id', '=', $ids)->where('status', 3)->find();
if (!$task) {
$this->error('任务状态已变更,请刷新后操作');
}
$task->save(['status' => 4]);
$this->success();
}
public function abort($ids)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
if (empty($ids)) {
$this->error(__('Parameter %s can not be empty', 'id'));
}
$reason = $this->request->post('remark');
if (empty($reason)) {
$this->error('驳回原因不能为空');
}
$task = $this->model->where('id', '=', $ids)->where('status', 3)->find();
if (!$task) {
$this->error('任务状态已变更,请刷新后操作');
}
$task->save(['status' => 5, 'refuse_reason' => $reason]);
$this->success();
}
}

View File

@ -3,7 +3,7 @@
return [
'Id' => 'ID',
'Admin_id' => '创建人id',
'Exec_admin_id' => '执行人id',
'Review_admin_id' => '审核人id',
'Type' => '任务类型',
'Type 1' => '每日任务',
'Type 2' => '每周任务',
@ -21,8 +21,8 @@ return [
'Set status to 4' => '设为已通过',
'Status 5' => '已驳回',
'Set status to 5' => '设为已驳回',
'Status 6' => '执行',
'Set status to 6' => '设为执行',
'Status 6' => '执行',
'Set status to 6' => '设为执行',
'Refuse_reason' => '驳回原因',
'Expire_start_time' => '有效期开始时间',
'Expire_end_time' => '有效期结束时间',
@ -34,6 +34,7 @@ return [
'Admin.nickname' => '昵称',
'Admin.password' => '密码',
'Admin.salt' => '密码盐',
'Admin.area_ids' => '地区ID,英文逗号分隔',
'Admin.avatar' => '头像',
'Admin.email' => '电子邮箱',
'Admin.mobile' => '手机号码',

View File

@ -62,6 +62,6 @@ class Task extends Model
public function admin()
{
return $this->belongsTo('app\admin\model\Admin', 'exec_admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}

View File

@ -1,11 +1,4 @@
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Exec_admin_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/selectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
@ -30,24 +23,6 @@
<input id="c-desc" class="form-control" name="row[desc]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Refuse_reason')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-refuse_reason" class="form-control" name="row[refuse_reason]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Expire_start_time')}:</label>
<div class="col-xs-12 col-sm-8">
@ -60,24 +35,6 @@
<input id="c-expire_end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expire_end_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Complete_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-complete_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[complete_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-create_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-update_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">

View File

@ -1,23 +1,5 @@
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Exec_admin_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/selectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="{$row.exec_admin_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
<div class="col-xs-12 col-sm-8">
@ -30,54 +12,6 @@
<input id="c-desc" class="form-control" name="row[desc]" type="text" value="{$row.desc|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Refuse_reason')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-refuse_reason" class="form-control" name="row[refuse_reason]" type="text" value="{$row.refuse_reason|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Expire_start_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-expire_start_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expire_start_time]" type="text" value="{$row.expire_start_time}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Expire_end_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-expire_end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expire_end_time]" type="text" value="{$row.expire_end_time}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Complete_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-complete_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[complete_time]" type="text" value="{$row.complete_time}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-create_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{$row.create_time}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-update_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{$row.update_time}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">

View File

@ -26,27 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'admin_id', title: __('Admin_id')},
{field: 'exec_admin_id', title: __('Exec_admin_id')},
{field: 'admin.nickname', title: __('Admin.nickname'), operate: 'LIKE'},
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
{field: 'date', title: __('Date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'admin.id', title: __('Admin.id')},
{field: 'admin.username', title: __('Admin.username'), operate: 'LIKE'},
{field: 'admin.nickname', title: __('Admin.nickname'), operate: 'LIKE'},
{field: 'admin.password', title: __('Admin.password'), operate: 'LIKE'},
{field: 'admin.salt', title: __('Admin.salt'), operate: 'LIKE'},
{field: 'admin.avatar', title: __('Admin.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'admin.email', title: __('Admin.email'), operate: 'LIKE'},
{field: 'admin.mobile', title: __('Admin.mobile'), operate: 'LIKE'},
{field: 'admin.loginfailure', title: __('Admin.loginfailure')},
{field: 'admin.logintime', title: __('Admin.logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.loginip', title: __('Admin.loginip'), operate: 'LIKE'},
{field: 'admin.createtime', title: __('Admin.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.updatetime', title: __('Admin.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.token', title: __('Admin.token'), operate: 'LIKE'},
{field: 'admin.status', title: __('Admin.status'), operate: 'LIKE', formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]

View File

@ -28,8 +28,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'admin_id', title: __('Admin_id')},
{field: 'exec_admin_id', title: __('Exec_admin_id')},
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
@ -38,24 +36,93 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'expire_start_time', title: __('Expire_start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'expire_end_time', title: __('Expire_end_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'complete_time', title: __('Complete_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'admin.id', title: __('Admin.id')},
{field: 'admin.username', title: __('Admin.username'), operate: 'LIKE'},
{field: 'admin.nickname', title: __('Admin.nickname'), operate: 'LIKE'},
{field: 'admin.password', title: __('Admin.password'), operate: 'LIKE'},
{field: 'admin.salt', title: __('Admin.salt'), operate: 'LIKE'},
{field: 'admin.avatar', title: __('Admin.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'admin.email', title: __('Admin.email'), operate: 'LIKE'},
{field: 'admin.mobile', title: __('Admin.mobile'), operate: 'LIKE'},
{field: 'admin.loginfailure', title: __('Admin.loginfailure')},
{field: 'admin.logintime', title: __('Admin.logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.loginip', title: __('Admin.loginip'), operate: 'LIKE'},
{field: 'admin.createtime', title: __('Admin.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.updatetime', title: __('Admin.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'admin.token', title: __('Admin.token'), operate: 'LIKE'},
{field: 'admin.status', title: __('Admin.status'), operate: 'LIKE', formatter: Table.api.formatter.status},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons:[
{
name: 'complete',
text:"完成任务",
title:"完成任务",
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa fa-magic',
url: 'oa/task/complete',
confirm: '确认发送',
refresh: true,
success: function (data, ret) {
return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
if (row.status != 1) {
return false;
}
return true;
}
},
{
name: 'pass',
text:"审核通过",
title:"审核通过",
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
icon: 'fa fa-magic',
url: 'oa/task/pass',
confirm: '确认发送',
refresh: true,
success: function (data, ret) {
return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
if (row.status != 3) {
return false;
}
return true;
}
},
{
name: 'abort',
text:"驳回",
title: '驳回',
classname: 'btn btn-xs btn-info btn-click',
icon: 'fa fa-magic',
click: function (e, row) {
Layer.prompt({
title: "填写驳回原因",
success: function (layero) {
$("input", layero).prop("placeholder", "填写驳回原因");
}
}, function (value) {
Fast.api.ajax({
url: "oa/task/abort/ids/"+ row.id,
data: {remark: value},
}, function (data, ret) {
Layer.closeAll();
$(".btn-refresh").trigger("click");
//return false;
});
});
return false;
},
visible:function(row){
if (row.status != 3) {
return false;
}
return true;
},
}
]}
]
]
});