| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace app\workerapi\lists;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\works\ServiceWork;
- use app\common\model\works\ServiceWorkSpare;
- /**
- * SparePart列表
- * Class SparePartLists
- * @package app\workerapi\lists
- */
- class ServiceWorkSparePartLists extends BaseWorkerDataLists implements ListsSearchInterface
- {
- protected $count = 0;
- /**
- * 设置搜索条件
- * @return array[]
- * @author liuguanci
- * @date 2024/7/11 下午1:46
- */
- public function setSearch(): array
- {
- if(isset($this->params['user_id']) && !empty($this->params['user_id'])){
- $this->params['master_worker_id'] = $this->params['user_id'];
- }
- return [
- '=' => ['work_sn','master_worker_id'],
- ];
- }
- /*
- * 查询条件
- * @return array
- * @author liuguanci
- * @date 2024/7/11 下午1:46
- */
- public function queryWhere(){
- $where = [];
- if(isset($this->params['spare_name']) && !empty($this->params['spare_name'])){
- $where[] = ['spare_name','like','%'.$this->params['spare_name'].'%'];
- }
- return $where;
- }
- /**
- * @notes 获取列表
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function lists(): array
- {
- // 配件信息
- $id = ServiceWork::where($this->searchWhere)->value('id');
- $spare_parts = [];
- if($id){
- $spare_parts = ServiceWorkSpare::getLists($id);
- }
- return $spare_parts?array_values($spare_parts):[];
- }
- /**
- * @notes 获取数量
- * @return int
- * @author likeadmin
- * @date 2024/09/14 15:08
- */
- public function count(): int
- {
- return $this->count;
- }
- }
|