diff --git a/application/admin/controller/oa/Doc.php b/application/admin/controller/oa/Doc.php new file mode 100644 index 0000000..3329cd2 --- /dev/null +++ b/application/admin/controller/oa/Doc.php @@ -0,0 +1,198 @@ +model = new \app\admin\model\oa\Doc; + + + $this->childrenAdminIds = $this->auth->getChildrenAdminIds($this->auth->isSuperAdmin()); + $this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin()); + + $groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray(); + + Tree::instance()->init($groupList); + $groupdata = []; + if ($this->auth->isSuperAdmin()) { + $result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0)); + foreach ($result as $k => $v) { + $groupdata[$v['id']] = $v['name']; + } + } else { + $result = []; + $groups = $this->auth->getGroups(); + foreach ($groups as $m => $n) { + $childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id'])); + $temp = []; + foreach ($childlist as $k => $v) { + $temp[$v['id']] = $v['name']; + } + $result[__($n['name'])] = $temp; + } + $groupdata = $result; + } + + $this->view->assign("typeList", $this->model->getTypeList()); + $this->view->assign('groupdata', $groupdata); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + + + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if (false === $this->request->isAjax()) { + return $this->view->fetch(); + } + //如果发送的来源是 Selectpage,则转发到 Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + [$where, $sort, $order, $offset, $limit] = $this->buildparams(); + + $list = $this->model + ->where($where) + ->whereRaw('JSON_OVERLAPS(group_ids, ?)', [json_encode($this->auth->getChildrenGroupIds(true))]) + ->order($sort, $order) + ->paginate($limit); + $result = ['total' => $list->total(), 'rows' => $list->items()]; + return json($result); + } + + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + 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); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $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); + } + + $group = $this->request->post("group/a"); + $group = array_map(function ($item) { + return intval($item); + }, $group); + $params['group_ids'] = json_encode($group); + $params['create_time'] = date('Y-m-d H:i:s'); + $params['update_time'] = date('Y-m-d H:i:s'); + + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + public function edit($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("groupids", json_decode($row['group_ids'])); + $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 . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + + + $group = $this->request->post("group/a"); + $group = array_map(function ($item) { + return intval($item); + }, $group); + $params['group_ids'] = json_encode($group); + $params['update_time'] = date('Y-m-d H:i:s'); + + $result = $row->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(); + } + + +} diff --git a/application/admin/controller/oa/Schedule.php b/application/admin/controller/oa/Schedule.php new file mode 100644 index 0000000..6387656 --- /dev/null +++ b/application/admin/controller/oa/Schedule.php @@ -0,0 +1,253 @@ +model = new \app\admin\model\oa\Schedule; + $this->view->assign("typeList", $this->model->getTypeList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['admin']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + + public function custom_index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + + + $filter = $this->request->param('filter'); + $filter = json_decode($filter, true); + + $startDate = date('Y-m-01'); + $endDate = date('Y-m-t'); + + if (isset($filter['timetype']) && $filter['timetype'] == 2) { + $startDate = date('Y-m-d', strtotime('monday this week')); + $endDate = date('Y-m-d', strtotime('sunday this week')); + } + + $res = []; + $admins = Db::name('admin')->field('id,nickname')->select(); + $admins = array_column($admins, NULL, 'id'); + $adminIds = array_keys($admins); + + $adminNames = array_column($admins, 'nickname', 'id'); + + $tmpDate = $startDate; + $dates = []; + while(true) { + + if ($tmpDate > $endDate) { + break; + } + + foreach ($adminIds as $adminId) { + $res[$adminId][$tmpDate] = '无'; + $res[$adminId]['name'] = $adminNames[$adminId]; + } + + $dates[] = $tmpDate; + $tmpDate = date('Y-m-d', strtotime($tmpDate) + 86400); + } + + $queryData = $this->model + ->with([ + 'admin' + ]) + ->where('date', '>=', $startDate) + ->where('date', '<=', $endDate) + ->select(); + foreach ($queryData as $queryDatum) { + $queryDatum = $queryDatum->toArray(); + + $adminId = $queryDatum['admin']['id']; + $date = $queryDatum['date']; + $type = $queryDatum['type']; + + if (isset($res[$adminId][$date])) { + $res[$adminId][$date] = $this->model->getTypeList()[$type]; + } + } + + + $res = array_values($res); + + $result = array("total" => count($res), "rows" => $res); + + return json($result); + } + + $timeType = [ + 1 => '本月排班', + 2 => '本周排班', + ]; + $this->view->assign("timetype", $timeType); + return $this->view->fetch(); + } + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + 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); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $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'); + + + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($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 . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + + + $params['update_time'] = date('Y-m-d H:i:s'); + + $result = $row->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(); + } + +} diff --git a/application/admin/controller/oa/Task.php b/application/admin/controller/oa/Task.php new file mode 100644 index 0000000..3085afc --- /dev/null +++ b/application/admin/controller/oa/Task.php @@ -0,0 +1,246 @@ +model = new \app\admin\model\oa\Task; + $this->view->assign("typeList", $this->model->getTypeList()); + $this->view->assign("statusList", $this->model->getStatusList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $dateTime = date('Y-m-d'); + foreach ($where as $k => $item) { + if ($item[0] != 'task.status') { + continue; + } + + if (in_array($item[2], [1, 4])) { + $where[] = ['expire_end_time', '<=', $dateTime]; + continue; + } + + if ($item[2] == 2) { + $where[$k][2] = 4; + $where[] = ['expire_end_time', '>', $dateTime]; + continue; + } + + if ($item[2] == 6) { + $where[$k][2] = 1; + $where[] = ['expire_end_time', '>', $dateTime]; + continue; + } + + } + + + $list = $this->model + ->with(['admin']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $k => $row) { + + if (strtotime($row['expire_end_time']) > time()) { + if ($row['status'] == 1) { + $list[$k]['status'] = 6; + } + + if ($row['status'] == 4) { + $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 review($ids) + { + if (false === $this->request->isPost()) { + $this->error(__("Invalid parameters")); + } + + if (empty($ids)) { + $this->error(__('Parameter %s can not be empty', 'id')); + } + + $status = $this->request->post('status'); + $reason = $this->request->post('remark'); + + if ($status == 5) { + if (empty($reason)) { + $this->error('驳回原因不能为空'); + } + } + + $task = $this->model->where('id', '=', $ids)->where('status', 3)->find(); + + if (!$task) { + $this->error('任务状态已变更,请刷新后操作'); + } + $task->save(['status' => $status, 'refuse_reason' => $reason]); + + $this->success(); + } + + + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + 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); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $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'); + + + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($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 . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + + + $params['update_time'] = date('Y-m-d H:i:s'); + + $result = $row->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(); + } + +} diff --git a/application/admin/lang/zh-cn/oa/doc.php b/application/admin/lang/zh-cn/oa/doc.php new file mode 100644 index 0000000..10b780a --- /dev/null +++ b/application/admin/lang/zh-cn/oa/doc.php @@ -0,0 +1,15 @@ + 'ID', + 'Admin_id' => '创建人ID', + 'Type' => '培训资料类型', + 'Type 1' => '视频', + 'Type 2' => '图片', + 'Type 3' => '文档', + 'Title' => '标题', + 'Desc' => '描述', + 'Path' => '文件地址', + 'Create_time' => '创建时间', + 'Update_time' => '编辑时间' +]; diff --git a/application/admin/lang/zh-cn/oa/schedule.php b/application/admin/lang/zh-cn/oa/schedule.php new file mode 100644 index 0000000..74d25ab --- /dev/null +++ b/application/admin/lang/zh-cn/oa/schedule.php @@ -0,0 +1,29 @@ + 'ID', + 'Admin_id' => '创建人ID', + 'Exec_admin_id' => '执行人ID', + 'Type' => '任务类型', + 'Type 1' => '早班', + 'Type 2' => '中班', + 'Type 3' => '晚班', + 'Date' => '日期', + 'Create_time' => '创建时间', + 'Update_time' => '编辑时间', + 'Admin.id' => 'ID', + 'Admin.username' => '用户名', + 'Admin.nickname' => '昵称', + 'Admin.password' => '密码', + 'Admin.salt' => '密码盐', + 'Admin.avatar' => '头像', + 'Admin.email' => '电子邮箱', + 'Admin.mobile' => '手机号码', + 'Admin.loginfailure' => '失败次数', + 'Admin.logintime' => '登录时间', + 'Admin.loginip' => '登录IP', + 'Admin.createtime' => '创建时间', + 'Admin.updatetime' => '更新时间', + 'Admin.token' => 'Session标识', + 'Admin.status' => '状态' +]; diff --git a/application/admin/lang/zh-cn/oa/task.php b/application/admin/lang/zh-cn/oa/task.php new file mode 100644 index 0000000..ba93a5b --- /dev/null +++ b/application/admin/lang/zh-cn/oa/task.php @@ -0,0 +1,48 @@ + 'ID', + 'Admin_id' => '创建人id', + 'Review_admin_id' => '审核人id', + 'Type' => '任务类型', + 'Type 1' => '每日任务', + 'Type 2' => '每周任务', + 'Type 3' => '每月任务', + 'Title' => '任务标题', + 'Desc' => '任务描述', + 'Status' => '状态', + 'Status 1' => '待完成', + 'Set status to 1' => '设为待完成', + 'Status 2' => '已完成', + 'Set status to 2' => '设为已完成', + 'Status 3' => '待审核', + 'Set status to 3' => '设为待审核', + 'Status 4' => '已通过', + 'Set status to 4' => '设为已通过', + 'Status 5' => '已驳回', + 'Set status to 5' => '设为已驳回', + 'Status 6' => '待执行', + 'Set status to 6' => '设为待执行', + 'Refuse_reason' => '驳回原因', + 'Expire_start_time' => '有效期开始时间', + 'Expire_end_time' => '有效期结束时间', + 'Complete_time' => '完成时间', + 'Create_time' => '创建时间', + 'Update_time' => '编辑时间', + 'Admin.id' => 'ID', + 'Admin.username' => '用户名', + 'Admin.nickname' => '昵称', + 'Admin.password' => '密码', + 'Admin.salt' => '密码盐', + 'Admin.area_ids' => '地区ID,英文逗号分隔', + 'Admin.avatar' => '头像', + 'Admin.email' => '电子邮箱', + 'Admin.mobile' => '手机号码', + 'Admin.loginfailure' => '失败次数', + 'Admin.logintime' => '登录时间', + 'Admin.loginip' => '登录IP', + 'Admin.createtime' => '创建时间', + 'Admin.updatetime' => '更新时间', + 'Admin.token' => 'Session标识', + 'Admin.status' => '状态' +]; diff --git a/application/admin/model/oa/Doc.php b/application/admin/model/oa/Doc.php new file mode 100644 index 0000000..9fe7775 --- /dev/null +++ b/application/admin/model/oa/Doc.php @@ -0,0 +1,49 @@ + __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')]; + } + + + public function getTypeTextAttr($value, $data) + { + $value = $value ?: ($data['type'] ?? ''); + $list = $this->getTypeList(); + return $list[$value] ?? ''; + } + + + + +} diff --git a/application/admin/model/oa/Schedule.php b/application/admin/model/oa/Schedule.php new file mode 100644 index 0000000..e01e4fb --- /dev/null +++ b/application/admin/model/oa/Schedule.php @@ -0,0 +1,53 @@ + __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')]; + } + + + public function getTypeTextAttr($value, $data) + { + $value = $value ?: ($data['type'] ?? ''); + $list = $this->getTypeList(); + return $list[$value] ?? ''; + } + + + + + public function admin() + { + return $this->belongsTo('app\admin\model\Admin', 'exec_admin_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/model/oa/Task.php b/application/admin/model/oa/Task.php new file mode 100644 index 0000000..c536521 --- /dev/null +++ b/application/admin/model/oa/Task.php @@ -0,0 +1,67 @@ + __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')]; + } + + public function getStatusList() + { + return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5'), '6' => __('Status 6')]; + } + + + public function getTypeTextAttr($value, $data) + { + $value = $value ?: ($data['type'] ?? ''); + $list = $this->getTypeList(); + return $list[$value] ?? ''; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ?: ($data['status'] ?? ''); + $list = $this->getStatusList(); + return $list[$value] ?? ''; + } + + + + + public function admin() + { + return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/validate/oa/Doc.php b/application/admin/validate/oa/Doc.php new file mode 100644 index 0000000..883038f --- /dev/null +++ b/application/admin/validate/oa/Doc.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/validate/oa/Schedule.php b/application/admin/validate/oa/Schedule.php new file mode 100644 index 0000000..89fb753 --- /dev/null +++ b/application/admin/validate/oa/Schedule.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/validate/oa/Task.php b/application/admin/validate/oa/Task.php new file mode 100644 index 0000000..db3d442 --- /dev/null +++ b/application/admin/validate/oa/Task.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/oa/doc/add.html b/application/admin/view/oa/doc/add.html new file mode 100644 index 0000000..d412acf --- /dev/null +++ b/application/admin/view/oa/doc/add.html @@ -0,0 +1,54 @@ +
+ +
+ +
+ {:build_select('group[]', $groupdata, null, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])} +
+
+ +
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+
    +
    +
    + +
    diff --git a/application/admin/view/oa/doc/edit.html b/application/admin/view/oa/doc/edit.html new file mode 100644 index 0000000..b7c0ce2 --- /dev/null +++ b/application/admin/view/oa/doc/edit.html @@ -0,0 +1,54 @@ +
    + + +
    + +
    + {:build_select('group[]', $groupdata, $groupids, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])} +
    +
    +
    + +
    + + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      + +
      diff --git a/application/admin/view/oa/doc/index.html b/application/admin/view/oa/doc/index.html new file mode 100644 index 0000000..4fc3950 --- /dev/null +++ b/application/admin/view/oa/doc/index.html @@ -0,0 +1,29 @@ +
      + {:build_heading()} + +
      +
      +
      + +
      + +
      +
      +
      diff --git a/application/admin/view/oa/schedule/add.html b/application/admin/view/oa/schedule/add.html new file mode 100644 index 0000000..cd4d268 --- /dev/null +++ b/application/admin/view/oa/schedule/add.html @@ -0,0 +1,33 @@ +
      + +
      + +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/oa/schedule/custom_index.html b/application/admin/view/oa/schedule/custom_index.html new file mode 100644 index 0000000..45b5ec5 --- /dev/null +++ b/application/admin/view/oa/schedule/custom_index.html @@ -0,0 +1,52 @@ +
      + {:build_heading()} + +
      +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      +
      +
      + diff --git a/application/admin/view/oa/schedule/edit.html b/application/admin/view/oa/schedule/edit.html new file mode 100644 index 0000000..1634edf --- /dev/null +++ b/application/admin/view/oa/schedule/edit.html @@ -0,0 +1,33 @@ +
      + +
      + +
      + +
      +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/oa/schedule/index.html b/application/admin/view/oa/schedule/index.html new file mode 100644 index 0000000..7f38eef --- /dev/null +++ b/application/admin/view/oa/schedule/index.html @@ -0,0 +1,29 @@ +
      + {:build_heading()} + +
      +
      +
      + +
      + +
      +
      +
      diff --git a/application/admin/view/oa/task/add.html b/application/admin/view/oa/task/add.html new file mode 100644 index 0000000..3ddd5c7 --- /dev/null +++ b/application/admin/view/oa/task/add.html @@ -0,0 +1,44 @@ +
      +
      + +
      + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/oa/task/edit.html b/application/admin/view/oa/task/edit.html new file mode 100644 index 0000000..005b076 --- /dev/null +++ b/application/admin/view/oa/task/edit.html @@ -0,0 +1,21 @@ +
      + +
      + +
      + +
      +
      +
      + +
      + +
      +
      + +
      diff --git a/application/admin/view/oa/task/index.html b/application/admin/view/oa/task/index.html new file mode 100644 index 0000000..2198a2d --- /dev/null +++ b/application/admin/view/oa/task/index.html @@ -0,0 +1,46 @@ +
      + +
      + {:build_heading(null,FALSE)} + +
      + + +
      +
      +
      +
      +
      + + {:__('Add')} + {:__('Edit')} + {:__('Delete')} + + + + + +
      + +
      +
      +
      + +
      +
      +
      diff --git a/public/assets/js/backend/oa/doc.js b/public/assets/js/backend/oa/doc.js new file mode 100644 index 0000000..6ab8913 --- /dev/null +++ b/public/assets/js/backend/oa/doc.js @@ -0,0 +1,57 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'oa/doc/index' + location.search, + add_url: 'oa/doc/add', + edit_url: 'oa/doc/edit', + del_url: 'oa/doc/del', + multi_url: 'oa/doc/multi', + import_url: 'oa/doc/import', + table: 'doc', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'admin_id', title: __('Admin_id')}, + {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal}, + {field: 'title', title: __('Title'), operate: 'LIKE'}, + {field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'path', title: __('Path'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); diff --git a/public/assets/js/backend/oa/schedule.js b/public/assets/js/backend/oa/schedule.js new file mode 100644 index 0000000..86a4a76 --- /dev/null +++ b/public/assets/js/backend/oa/schedule.js @@ -0,0 +1,151 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'oa/schedule/index' + location.search, + add_url: 'oa/schedule/add', + edit_url: 'oa/schedule/edit', + del_url: 'oa/schedule/del', + multi_url: 'oa/schedule/multi', + import_url: 'oa/schedule/import', + table: 'schedule', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'admin.nickname', title: __('Admin.nickname'), operate: 'LIKE'}, + {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal}, + {field: 'date', title: __('Date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + custom_index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'oa/schedule/custom_index' + location.search, + // add_url: 'oa/schedule/add', + // edit_url: 'oa/schedule/edit', + // del_url: 'oa/schedule/del', + // multi_url: 'oa/schedule/multi', + // import_url: 'oa/schedule/import', + table: 'schedule', + } + }); + + var table = $("#table"); + + var defaultColumnArr = []; + defaultColumnArr.push({ + "title":"用户名", + "field":"name", + }); + + const startDate = new Date(new Date().setDate(1)); + const endDate = new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0); + + console.log('Start Date:', startDate); + console.log('End Date:', endDate); + + for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) { + let tmpDate = d.toISOString().split('T')[0]; + console.log('Current Date:', tmpDate); + defaultColumnArr.push({ + "title": tmpDate, + "field": tmpDate, + }); + } + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + columns: defaultColumnArr, + searchFormVisible: true, + searchFormTemplate: 'customformtpl', + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + + $(document).on("click", ".btn-block", function () { + + let selectedValue = $('#c-flag').val(); + + let changeColumn = []; + if (selectedValue == 2) { + changeColumn = [{ + "title":"用户名", + "field":"name", + }]; + + const today = new Date(); + const startDate = new Date(today.setDate(today.getDate() - today.getDay() + 1)); // 星期一 + const endDate = new Date(today.setDate(today.getDate() - today.getDay() + 7)); // 星期天 + + for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) { + let tmpDate = d.toISOString().split('T')[0]; // 使用 d,而不是 date + changeColumn.push({ + "title": tmpDate, + "field": tmpDate, + }); + } + + } else { + changeColumn = defaultColumnArr; + } + + var options = table.bootstrapTable('getOptions'); + var queryParams = options.queryParams; + options.queryParams = function (params) { + //这一行必须要存在,否则在点击下一页时会丢失搜索栏数据 + params = queryParams(params); + + var filter = params.filter ? JSON.parse(params.filter) : {}; + filter.timetype = selectedValue; + + params.filter = JSON.stringify(filter); + return params; + }; + + table.bootstrapTable('refreshOptions', { + columns: changeColumn, + }); + + $('#c-flag').val(selectedValue).change(); + return false; + }); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); diff --git a/public/assets/js/backend/oa/task.js b/public/assets/js/backend/oa/task.js new file mode 100644 index 0000000..78229cb --- /dev/null +++ b/public/assets/js/backend/oa/task.js @@ -0,0 +1,157 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'oa/task/index' + location.search, + add_url: 'oa/task/add', + edit_url: 'oa/task/edit', + del_url: 'oa/task/del', + multi_url: 'oa/task/multi', + import_url: 'oa/task/import', + table: 'task', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal}, + {field: 'title', title: __('Title'), operate: 'LIKE'}, + {field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6')}, formatter: Table.api.formatter.status}, + {field: 'refuse_reason', title: __('Refuse_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'expire_start_time', title: __('Expire_start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'expire_end_time', title: __('Expire_end_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'complete_time', title: __('Complete_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'admin.username', title: __('Admin.username'), operate: 'LIKE'}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, + buttons:[ + { + name: 'complete', + text:"完成任务", + title:"完成任务", + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-success btn-magic btn-ajax', + icon: 'fa fa-magic', + url: 'oa/task/complete', + confirm: '确认发送', + refresh: true, + success: function (data, ret) { + return false; + }, + error: function (data, ret) { + Layer.alert(ret.msg); + return false; + }, + visible: function (row) { + //返回true时按钮显示,返回false隐藏 + if (row.status != 1) { + return false; + } + return true; + } + }, + { + name: 'pass', + text:"通过", + title: '通过', + classname: 'btn btn-xs btn-success btn-click', + icon: 'fa fa-magic', + 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; + }, + + visible:function(row){ + if (row.status != 3) { + return false; + } + if (!Config.review) { + return false; + } + return true; + }, + }, + { + name: 'abort', + text:"驳回", + title: '驳回', + classname: 'btn btn-xs btn-info btn-click', + icon: 'fa fa-magic', + click: function (e, row) { + Layer.prompt({ + title: "填写驳回原因", + success: function (layero) { + $("input", layero).prop("placeholder", "填写驳回原因"); + } + }, function (value) { + Fast.api.ajax({ + url: "oa/task/review/ids/"+ row.id, + data: {status:5, remark: value}, + }, function (data, ret) { + Layer.closeAll(); + $(".btn-refresh").trigger("click"); + //return false; + }); + }); + return false; + }, + + visible:function(row){ + if (row.status != 3) { + return false; + } + if (!Config.review) { + return false; + } + return true; + }, + } + + ]} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +});