IssueWorkLists.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\model\works\IssueWork;
  4. use app\common\lists\ListsSearchInterface;
  5. /**
  6. * IssueWork列表
  7. * Class IssueWorkLists
  8. * @package app\workerapi\listsworks
  9. */
  10. class IssueWorkLists extends BaseWorkerDataLists implements ListsSearchInterface
  11. {
  12. /**
  13. * @notes 设置搜索条件
  14. * @return \string[][]
  15. * @author whitef
  16. * @date 2024/07/10 15:06
  17. */
  18. public function setSearch(): array
  19. {
  20. return [
  21. '=' => ['work_sn', 'service_work_id', 'master_worker_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details', 'finished_time', 'approval_admin_id', 'approval_time', 'create_time', 'update_time'],
  22. ];
  23. }
  24. public function querySearch(): array
  25. {
  26. $where['issue_approval'] = ['<>',0];
  27. $where['master_worker_id'] = ['=',$this->userId];
  28. return $where;
  29. }
  30. /**
  31. * @notes 获取列表
  32. * @return array
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. * @author whitef
  37. * @date 2024/07/10 15:06
  38. */
  39. public function lists(): array
  40. {
  41. return IssueWork::where($this->searchWhere)
  42. ->where($this->querySearch())
  43. ->field(['id', 'work_sn', 'service_work_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details', 'complaint_images', 'finished_time', 'create_time', 'update_time'])
  44. ->limit($this->limitOffset, $this->limitLength)
  45. ->order(['id' => 'desc'])
  46. ->select()
  47. ->toArray();
  48. }
  49. /**
  50. * @notes 获取数量
  51. * @return int
  52. * @author whitef
  53. * @date 2024/07/10 15:06
  54. */
  55. public function count(): int
  56. {
  57. return IssueWork::where($this->searchWhere)->where($this->querySearch())->count();
  58. }
  59. }