['project_id'], '%like%' => ['equipment_budget_code'], ]; } /** * @notes 获取机具预算列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/01/16 11:40 */ public function lists(): array { return ProjectEquipmentBudget::where($this->searchWhere) ->field(['id', 'project_id', 'equipment_budget_code', 'remark', 'annex']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; //预算总量 $data['total_num'] = ProjectEquipmentBudgetDetail::where('equipment_budget_id',$data['id'])->sum('num'); //预算总金额 $data['total_amount'] = ProjectEquipmentBudgetDetail::where('equipment_budget_id',$data['id'])->sum('amount'); return $data; }) ->toArray(); } /** * @notes 获取机具预算数量 * @return int * @author likeadmin * @date 2024/01/16 11:40 */ public function count(): int { return ProjectEquipmentBudget::where($this->searchWhere)->count(); } }