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/public/assets/js/backend/oa/schedule.js b/public/assets/js/backend/oa/schedule.js index 04dd289..081a85d 100644 --- a/public/assets/js/backend/oa/schedule.js +++ b/public/assets/js/backend/oa/schedule.js @@ -86,7 +86,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function {value: '中班', text: '中班'}, {value: '晚班', text: '晚班'}, {value: '行政班', text: '行政班'}, - ] + ], + noeditFormatter: function (value, row, index) { + if (row.editable === 1) { + return false; + } else { + return value; + } + }, } }); }