diff --git a/addons/editable/bootstrap.js b/addons/editable/bootstrap.js index 6a88649..2942c43 100644 --- a/addons/editable/bootstrap.js +++ b/addons/editable/bootstrap.js @@ -16,9 +16,12 @@ if ($("table.table").length > 0) { require(['editable', 'table'], function (Editable, Table) { $.fn.bootstrapTable.defaults.onEditableSave = function (field, row, oldValue, $el) { var data = {}; - data["row[" + field + "]"] = row[field]; + data["row[field]"] = field; + for(var i in row){ + data["row[" + i + "]"] = row[i]; + } Fast.api.ajax({ - url: this.extend.edit_url + "/ids/" + row[this.pk], + url: this.extend.editable + "/idsssssssssss/" + row[this.pk], data: data }); }; diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php index 6387656..63f7a57 100644 --- a/application/admin/controller/oa/Schedule.php +++ b/application/admin/controller/oa/Schedule.php @@ -109,6 +109,7 @@ class Schedule extends Backend foreach ($adminIds as $adminId) { $res[$adminId][$tmpDate] = '无'; + $res[$adminId]['admin_id'] = $adminId; $res[$adminId]['name'] = $adminNames[$adminId]; } @@ -250,4 +251,58 @@ class Schedule extends Backend $this->success(); } + + public function editable() + { + + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + + + $date = $params['field']; + $adminId = $params['admin_id']; + + $value = $params[$date] ?? '无'; + $valueMap = [ + '无' => 0, + '早班' => 1, + '中班' => 2, + '晚班' => 3, + '行政班' => 4, + ]; + + if ($value == '无') { + $this->model->where('exec_admin_id', $adminId)->delete(); + $this->success(); + } + + $dbValue = $valueMap[$value]; + + $data = $this->model + ->where('date', '=', $date) + ->where('exec_admin_id', '=', $adminId) + ->find(); + + $nowTime = date('Y-m-d H:i:s'); + if (!empty($data)) { + $data->save([ + "date" => $date, + "exec_admin_id" => $adminId, + "type" => $dbValue, + "update_time" => $nowTime, + ]); + } + + $this->model->insert([ + "date" => $date, + "exec_admin_id" => $adminId, + "type" => $dbValue, + "create_time" => $nowTime, + "update_time" => $nowTime, + ]); + + $this->success(); + } } diff --git a/application/admin/controller/oa/Task.php b/application/admin/controller/oa/Task.php index 3085afc..ea60d08 100644 --- a/application/admin/controller/oa/Task.php +++ b/application/admin/controller/oa/Task.php @@ -24,6 +24,10 @@ class Task extends Backend protected $dataLimit = 'personal'; + protected $dataLimitField = 'exec_admin_id'; + + protected $dataLimitFieldAutoFill = false; + public function _initialize() { parent::_initialize(); @@ -101,7 +105,7 @@ class Task extends Backend } } - $list[$k]['refuse_reason'] = $list['refuse_reason'] ?? ''; + $list[$k]['refuse_reason'] = $row['refuse_reason'] ?? ''; } $result = array("total" => $list->total(), "rows" => $list->items()); @@ -113,6 +117,26 @@ 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 review($ids) { if (false === $this->request->isPost()) { @@ -177,6 +201,7 @@ class Task extends Backend $params['create_time'] = date('Y-m-d H:i:s'); $params['update_time'] = date('Y-m-d H:i:s'); + $params['admin_id'] = $this->auth->id; $result = $this->model->allowField(true)->save($params); diff --git a/application/admin/lang/zh-cn/oa/schedule.php b/application/admin/lang/zh-cn/oa/schedule.php index 74d25ab..d3a348b 100644 --- a/application/admin/lang/zh-cn/oa/schedule.php +++ b/application/admin/lang/zh-cn/oa/schedule.php @@ -8,6 +8,7 @@ return [ 'Type 1' => '早班', 'Type 2' => '中班', 'Type 3' => '晚班', + 'Type 4' => '行政班', 'Date' => '日期', 'Create_time' => '创建时间', 'Update_time' => '编辑时间', diff --git a/application/admin/lang/zh-cn/oa/task.php b/application/admin/lang/zh-cn/oa/task.php index ba93a5b..ccab904 100644 --- a/application/admin/lang/zh-cn/oa/task.php +++ b/application/admin/lang/zh-cn/oa/task.php @@ -3,7 +3,7 @@ return [ 'Id' => 'ID', 'Admin_id' => '创建人id', - 'Review_admin_id' => '审核人id', + 'Exec_admin_id' => '执行人ID', 'Type' => '任务类型', 'Type 1' => '每日任务', 'Type 2' => '每周任务', diff --git a/application/admin/model/oa/Schedule.php b/application/admin/model/oa/Schedule.php index e01e4fb..991b076 100644 --- a/application/admin/model/oa/Schedule.php +++ b/application/admin/model/oa/Schedule.php @@ -32,7 +32,7 @@ class Schedule extends Model public function getTypeList() { - return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')]; + return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4')]; } diff --git a/application/admin/model/oa/Task.php b/application/admin/model/oa/Task.php index c536521..43fa03e 100644 --- a/application/admin/model/oa/Task.php +++ b/application/admin/model/oa/Task.php @@ -62,6 +62,6 @@ class Task extends Model public function admin() { - return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0); + return $this->belongsTo('app\admin\model\Admin', 'exec_admin_id', 'id', [], 'LEFT')->setEagerlyType(0); } } diff --git a/application/admin/view/oa/schedule/custom_index.html b/application/admin/view/oa/schedule/custom_index.html index 45b5ec5..9b6bbbb 100644 --- a/application/admin/view/oa/schedule/custom_index.html +++ b/application/admin/view/oa/schedule/custom_index.html @@ -41,7 +41,7 @@