['is_mrp'], '%like%' => ['code', 'name'], ]; } /** * @notes 获取仓库管理列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/01/04 14:23 */ public function lists(): array { $params = $this->request->get(['project_name']); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$project_ids]; } return MaterialWarehouse::where($this->searchWhere)->where($where) ->field(['id', 'org_id', 'dept_id', 'project_id', 'code', 'name', 'is_mrp', 'head_user', 'address', 'telephone', 'remark', 'annex']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$item['head_user'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; $item['head_user'] = $admin['name']; $item['is_mrp'] = $item->is_mrp_text; unset($item['org_id'],$item['dept_id'],$item['project_id']); return $item; }) ->toArray(); } /** * @notes 获取仓库管理数量 * @return int * @author likeadmin * @date 2024/01/04 14:23 */ public function count(): int { $params = $this->request->get(['project_name']); $where = []; if(isset($params['project_name']) && $params['project_name'] != ''){ $project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id'); $where[] = ['project_id','in',$project_ids]; } return MaterialWarehouse::where($this->searchWhere)->where($where)->count(); } }