From 0c557472c77483ab7a71b3716ff576fe42912b64 Mon Sep 17 00:00:00 2001 From: zhuyu Date: Sun, 6 Apr 2025 15:32:08 +0800 Subject: [PATCH] feature: task --- application/admin/controller/oa/Doc.php | 3 +- application/admin/controller/oa/Task.php | 59 ++++++------------------ public/assets/js/backend/oa/task.js | 45 +++++++++++------- 3 files changed, 43 insertions(+), 64 deletions(-) diff --git a/application/admin/controller/oa/Doc.php b/application/admin/controller/oa/Doc.php index d13df6f..3329cd2 100644 --- a/application/admin/controller/oa/Doc.php +++ b/application/admin/controller/oa/Doc.php @@ -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()]; diff --git a/application/admin/controller/oa/Task.php b/application/admin/controller/oa/Task.php index 9bcc1ba..3085afc 100644 --- a/application/admin/controller/oa/Task.php +++ b/application/admin/controller/oa/Task.php @@ -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,9 +123,13 @@ class Task extends Backend $this->error(__('Parameter %s can not be empty', 'id')); } + $status = $this->request->post('status'); $reason = $this->request->post('remark'); - if (empty($reason)) { - $this->error('驳回原因不能为空'); + + if ($status == 5) { + if (empty($reason)) { + $this->error('驳回原因不能为空'); + } } $task = $this->model->where('id', '=', $ids)->where('status', 3)->find(); @@ -168,7 +137,7 @@ class Task extends Backend if (!$task) { $this->error('任务状态已变更,请刷新后操作'); } - $task->save(['status' => 5, 'refuse_reason' => $reason]); + $task->save(['status' => $status, 'refuse_reason' => $reason]); $this->success(); } diff --git a/public/assets/js/backend/oa/task.js b/public/assets/js/backend/oa/task.js index 09ce35b..78229cb 100644 --- a/public/assets/js/backend/oa/task.js +++ b/public/assets/js/backend/oa/task.js @@ -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; } + 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; }, }