| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?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['spare_parts'] = ServiceWorkSpare::getLists($id, 1);
- $spare_parts['self_spare_parts'] = ServiceWorkSpare::getLists($id, 2);
- }
- 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;
- }
- }
|