diff --git a/application/admin/controller/oa/Task.php b/application/admin/controller/oa/Task.php index 9c5d4d5..66c74c9 100644 --- a/application/admin/controller/oa/Task.php +++ b/application/admin/controller/oa/Task.php @@ -244,6 +244,53 @@ class Task extends Backend $this->success(); } + public function copy($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + + + $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); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + public function notice($ids = null) { diff --git a/application/admin/view/oa/task/copy.html b/application/admin/view/oa/task/copy.html new file mode 100644 index 0000000..cd7b3a4 --- /dev/null +++ b/application/admin/view/oa/task/copy.html @@ -0,0 +1,52 @@ +
+ diff --git a/public/assets/js/backend/oa/task.js b/public/assets/js/backend/oa/task.js index 7d29994..8a8ff78 100644 --- a/public/assets/js/backend/oa/task.js +++ b/public/assets/js/backend/oa/task.js @@ -88,6 +88,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-info btn-editone', }, + { + name: 'copy', + text: "复制", + title: "复制", + classname: 'btn btn-xs btn-warning btn-dialog', + icon: 'fa fa-copy', + url: 'oa/task/copy', + }, { name: 'del', text: "删除", @@ -110,6 +118,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin edit: function () { Controller.api.bindevent(); }, + copy: function () { + Controller.api.bindevent(); + }, review: function () { $(document).on('click', '.btn-preview', function (e) {