feature: task

This commit is contained in:
zhuyu 2025-04-06 15:32:08 +08:00
parent fad7b7d4a3
commit 0c557472c7
3 changed files with 43 additions and 64 deletions

View File

@ -83,10 +83,9 @@ class Doc extends Backend
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin());
$list = $this->model
->where($where)
->whereRaw('JSON_OVERLAPS(group_ids, ?)', [json_encode($this->childrenAdminIds)])
->whereRaw('JSON_OVERLAPS(group_ids, ?)', [json_encode($this->auth->getChildrenGroupIds(true))])
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];

View File

@ -22,6 +22,8 @@ class Task extends Backend
*/
protected $model = null;
protected $dataLimit = 'personal';
public function _initialize()
{
parent::_initialize();
@ -95,60 +97,23 @@ class Task extends Backend
}
if ($row['status'] == 4) {
$row[$k]['status'] = 2;
$list[$k]['status'] = 2;
}
}
$list[$k]['refuse_reason'] = $list['refuse_reason'] ?? '';
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
$this->assignconfig("review", $this->auth->check("oa/task/review"));
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)
public function review($ids)
{
if (false === $this->request->isPost()) {
$this->error(__("Invalid parameters"));
@ -158,17 +123,21 @@ class Task extends Backend
$this->error(__('Parameter %s can not be empty', 'id'));
}
$status = $this->request->post('status');
$reason = $this->request->post('remark');
if ($status == 5) {
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]);
$task->save(['status' => $status, 'refuse_reason' => $reason]);
$this->success();
}

View File

@ -66,28 +66,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
{
name: 'pass',
text:"审核通过",
title:"审核通过",
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
text:"通过",
title: '通过',
classname: 'btn btn-xs btn-success btn-click',
icon: 'fa fa-magic',
url: 'oa/task/pass',
confirm: '确认发送',
refresh: true,
success: function (data, ret) {
click: function (e, row) {
Layer.confirm("确定通过?", {
}, function (index) {
Fast.api.ajax({
url: "oa/task/review/ids/"+ row.id,
data: {status:4}
}, function (data) {
Layer.closeAll();
$(".btn-refresh").trigger("click");
});
layer.close(index);
}, function (index) {
layer.close(index);
});
return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
visible:function(row){
if (row.status != 3) {
return false;
}
return true;
if (!Config.review) {
return false;
}
return true;
},
},
{
name: 'abort',
@ -103,8 +111,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
}, function (value) {
Fast.api.ajax({
url: "oa/task/abort/ids/"+ row.id,
data: {remark: value},
url: "oa/task/review/ids/"+ row.id,
data: {status:5, remark: value},
}, function (data, ret) {
Layer.closeAll();
$(".btn-refresh").trigger("click");
@ -118,6 +126,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
if (row.status != 3) {
return false;
}
if (!Config.review) {
return false;
}
return true;
},
}