1
0

ServiceWorkSparePartLists.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\lists\ListsSearchInterface;
  4. use app\common\model\works\ServiceWork;
  5. use app\common\model\works\ServiceWorkSpare;
  6. /**
  7. * SparePart列表
  8. * Class SparePartLists
  9. * @package app\workerapi\lists
  10. */
  11. class ServiceWorkSparePartLists extends BaseWorkerDataLists implements ListsSearchInterface
  12. {
  13. protected $count = 0;
  14. /**
  15. * 设置搜索条件
  16. * @return array[]
  17. * @author liuguanci
  18. * @date 2024/7/11 下午1:46
  19. */
  20. public function setSearch(): array
  21. {
  22. if(isset($this->params['user_id']) && !empty($this->params['user_id'])){
  23. $this->params['master_worker_id'] = $this->params['user_id'];
  24. }
  25. return [
  26. '=' => ['work_sn','master_worker_id'],
  27. ];
  28. }
  29. /*
  30. * 查询条件
  31. * @return array
  32. * @author liuguanci
  33. * @date 2024/7/11 下午1:46
  34. */
  35. public function queryWhere(){
  36. $where = [];
  37. if(isset($this->params['spare_name']) && !empty($this->params['spare_name'])){
  38. $where[] = ['spare_name','like','%'.$this->params['spare_name'].'%'];
  39. }
  40. return $where;
  41. }
  42. /**
  43. * @notes 获取列表
  44. * @return array
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @author likeadmin
  49. * @date 2024/09/14 15:08
  50. */
  51. public function lists(): array
  52. {
  53. // 配件信息
  54. $id = ServiceWork::where($this->searchWhere)->value('id');
  55. $spare_parts = [];
  56. if($id){
  57. $spare_parts = ServiceWorkSpare::getLists($id);
  58. }
  59. return $spare_parts?array_values($spare_parts):[];
  60. }
  61. /**
  62. * @notes 获取数量
  63. * @return int
  64. * @author likeadmin
  65. * @date 2024/09/14 15:08
  66. */
  67. public function count(): int
  68. {
  69. return $this->count;
  70. }
  71. }