Workreport.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace addons\qingdongams\controller;
  3. use addons\qingdongams\model\Message;
  4. use addons\qingdongams\model\WorkReport as WorkreportModel;
  5. /**
  6. * 工作报告
  7. */
  8. class Workreport extends StaffApi
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = [];
  12. //获取工作报告
  13. public function getList()
  14. {
  15. $staff_id = input('staff_id');
  16. $type = input('type');//日 周 月 季 年
  17. $times = input('times');//时间
  18. $where = [];
  19. if ($staff_id) {
  20. $where['staff_id'] = $staff_id;
  21. }
  22. if ($type) {
  23. $where['type'] = $type;
  24. }
  25. if ($times) {
  26. $times=setTimes($times,'date');
  27. $where['report_date'] = ['between', $times];
  28. }
  29. $list = WorkreportModel::where($where)->with(['staff'])->order('id desc')->paginate();
  30. $this->success('请求成功', $list);
  31. }
  32. //获取报告详情
  33. public function getDetail()
  34. {
  35. $id = input('id');
  36. $detail = WorkreportModel::where(['id' => $id])->with(['staff'])->find();
  37. if (empty($detail)) {
  38. $this->error('报告不存在');
  39. }
  40. //标记通知已读
  41. Message::setRead(Message::WORKREPORT_TYPE, $id, $this->auth->id);
  42. $this->success('请求成功', $detail);
  43. }
  44. }