diff --git a/application/admin/controller/Dashboard.php b/application/admin/controller/Dashboard.php index 8258282..ffd2a71 100755 --- a/application/admin/controller/Dashboard.php +++ b/application/admin/controller/Dashboard.php @@ -3,6 +3,8 @@ namespace app\admin\controller; use app\admin\model\Admin; +use app\admin\model\kpi\Template; +use app\admin\model\oa\Task; use app\admin\model\User; use app\common\controller\Backend; use app\common\model\Attachment; @@ -105,7 +107,73 @@ class Dashboard extends Backend return $this->view->fetch(); } + public function task() + { + $dayTasks = (new Task()) + ->where('exec_admin_id','=',$this->auth->id) + ->where('type','=',1) + ->select(); + + $weekTasks = (new Task()) + ->where('exec_admin_id','=',$this->auth->id) + ->where('type','=',2) + ->select(); + + $monthTasks = (new Task()) + ->where('exec_admin_id','=',$this->auth->id) + ->where('type','=',3) + ->select(); + + $this->view->assign('day', $dayTasks); + $this->view->assign('week', $weekTasks); + $this->view->assign('month', $monthTasks); + + return $this->view->fetch(); + } + + public function kpi() + { + + $groupIds = $this->auth->getGroupIds(); + $groupId = $groupIds[0] ?? 0; + + $kpiTemplate = (new Template()) + ->where('group_id','=', 6) + ->with('kpiitem') + ->find(); + + + $kpiItems = $kpiTemplate['kpiitem']; + + $this->view->assign('kpi_template', $kpiTemplate); + $this->view->assign('kpi_items', $kpiItems); + + return $this->view->fetch(); + } + + public function task_complete($ids = null) + { + + $row = (new Task())->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + + $task = (new Task())->where('id', '=', $ids)->where('status', 1)->find(); + + if (!$task) { + $this->error('任务状态已变更,请刷新后操作'); + } + $task->save(['status' => 3, 'prove_file_path' => $params['prove_file_path']]); + + $this->success(); + } } diff --git a/application/admin/controller/kpi/Template.php b/application/admin/controller/kpi/Template.php index e549e39..92140c0 100644 --- a/application/admin/controller/kpi/Template.php +++ b/application/admin/controller/kpi/Template.php @@ -136,7 +136,12 @@ class Template extends Backend $templateItem = []; $kpiItems = json_decode($params['kpiitem'], true); + $kpiItemIds = array_column($kpiItems, 'id'); + if (count($kpiItemIds) !== count(array_unique($kpiItemIds))) { + throw new Exception('指标有重复项'); + } + $rateAll = 0; foreach ($kpiItems as $kpiItem) { $templateItem[] = [ 'admin_id' => $this->auth->id, @@ -144,6 +149,10 @@ class Template extends Backend 'item_id' => $kpiItem['id'], 'rate' => $kpiItem['rate'], ]; + $rateAll += $kpiItem['rate']; + } + if ($rateAll != 100) { + throw new Exception('指标权重总和必须为100'); } Db::name('kpi_template_item') @@ -216,7 +225,12 @@ class Template extends Backend $templateItem = []; $kpiItems = json_decode($params['kpiitem'], true); + $kpiItemIds = array_column($kpiItems, 'id'); + if (count($kpiItemIds) !== count(array_unique($kpiItemIds))) { + throw new Exception('指标有重复项'); + } + $rateAll = 0; foreach ($kpiItems as $kpiItem) { $templateItem[] = [ 'admin_id' => $this->auth->id, @@ -224,6 +238,11 @@ class Template extends Backend 'item_id' => $kpiItem['id'], 'rate' => $kpiItem['rate'], ]; + $rateAll += $kpiItem['rate']; + } + + if ($rateAll != 100) { + throw new Exception('指标权重总和必须为100'); } Db::name('kpi_template_item') diff --git a/application/admin/controller/oa/Doc.php b/application/admin/controller/oa/Doc.php index 3329cd2..282e9f8 100644 --- a/application/admin/controller/oa/Doc.php +++ b/application/admin/controller/oa/Doc.php @@ -88,11 +88,34 @@ class Doc extends Backend ->whereRaw('JSON_OVERLAPS(group_ids, ?)', [json_encode($this->auth->getChildrenGroupIds(true))]) ->order($sort, $order) ->paginate($limit); + + foreach ($list as $k => $row) { + $list[$k]['url'] = cdnurl($row['path']); + } + $result = ['total' => $list->total(), 'rows' => $list->items()]; return json($result); } + public function detail($ids) + { + $row = $this->model->get(['id' => $ids]); + if (!$row) { + $this->error(__('No Results were found')); + } + if ($this->request->isAjax()) { + $this->success("Ajax请求成功", null, ['id' => $ids]); + } + + $row['url'] = cdnurl($row['path']); + + + $this->view->assign("row", $row->toArray()); + return $this->view->fetch(); + } + + /** * 添加 * diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index 63f7a57..038f61e 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -93,7 +93,13 @@ class Schedule extends Backend } $res = []; - $admins = Db::name('admin')->field('id,nickname')->select(); + + if (!$this->auth->isSuperAdmin()) { + $admins = Db::name('admin')->where('id', $this->auth->id)->field('id,nickname')->select(); + } else{ + $admins = Db::name('admin')->field('id,nickname')->select(); + } + $admins = array_column($admins, NULL, 'id'); $adminIds = array_keys($admins); @@ -111,19 +117,25 @@ class Schedule extends Backend $res[$adminId][$tmpDate] = '无'; $res[$adminId]['admin_id'] = $adminId; $res[$adminId]['name'] = $adminNames[$adminId]; + $res[$adminId]['editable'] = $this->auth->isSuperAdmin() ? 1 : 0; } $dates[] = $tmpDate; $tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400); } - $queryData = $this->model + $builder = $this->model ->with([ 'admin' ]) ->where('date', '>=', $startDate) - ->where('date', '<=', $endDate) - ->select(); + ->where('date', '<=', $endDate); + + if (!$this->auth->isSuperAdmin()) { + $builder = $builder->where('exec_admin_id', $this->auth->id); + } + + $queryData = $builder->select(); foreach ($queryData as $queryDatum) { $queryDatum = $queryDatum->toArray(); diff --git a/application/admin/controller/oa/Task.php b/application/admin/controller/oa/Task.php index ea60d08..4d3e464 100644 --- a/application/admin/controller/oa/Task.php +++ b/application/admin/controller/oa/Task.php @@ -114,6 +114,7 @@ class Task extends Backend } $this->assignconfig("review", $this->auth->check("oa/task/review")); + $this->assignconfig("detail", $this->auth->check("oa/task/detail")); return $this->view->fetch(); } diff --git a/application/admin/lang/zh-cn/kpi/item.php b/application/admin/lang/zh-cn/kpi/item.php index 5a064e6..c03ad8b 100644 --- a/application/admin/lang/zh-cn/kpi/item.php +++ b/application/admin/lang/zh-cn/kpi/item.php @@ -13,6 +13,8 @@ return [ 'Unit 1' => '%', 'Unit 2' => '元', 'Unit 3' => '单', + 'Unit 4' => '个', + 'Unit 5' => '小时', 'Create_time' => '创建时间', 'Update_time' => '编辑时间' ]; diff --git a/application/admin/lang/zh-cn/kpi/template.php b/application/admin/lang/zh-cn/kpi/template.php index 5328a56..f0f20ce 100644 --- a/application/admin/lang/zh-cn/kpi/template.php +++ b/application/admin/lang/zh-cn/kpi/template.php @@ -8,6 +8,7 @@ return [ 'Name' => '名称', 'Desc' => '描述', 'Score' => '单个绩点分', + 'Max_score' => '最高得分上限', 'Create_time' => '创建时间', 'Update_time' => '编辑时间' ]; diff --git a/application/admin/model/kpi/Item.php b/application/admin/model/kpi/Item.php index 73dece1..367b53e 100644 --- a/application/admin/model/kpi/Item.php +++ b/application/admin/model/kpi/Item.php @@ -41,7 +41,7 @@ class Item extends Model public function getUnitList() { - return ['1' => __('Unit 1'), '2' => __('Unit 2'), '3' => __('Unit 3')]; + return ['1' => __('Unit 1'), '2' => __('Unit 2'), '3' => __('Unit 3'), '4' => __('Unit 4'), '5' => __('Unit 5')]; } diff --git a/application/admin/view/dashboard/kpi.html b/application/admin/view/dashboard/kpi.html new file mode 100644 index 0000000..a4943dc --- /dev/null +++ b/application/admin/view/dashboard/kpi.html @@ -0,0 +1,33 @@ + + +
| 指标名称 | +目标值 | +目标值(单位) | +指标描述 | +权重 | +
|---|---|---|---|---|
| {$item->name|htmlentities} | +{$item->target_value|htmlentities} | +{$item->unit_text|htmlentities} | +{$item->desc|htmlentities} | +{$item->pivot->rate|htmlentities} | +