['project_id'], '%like%' => ['cost_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 14:32 */ public function lists(): array { return ProjectCostBudget::where($this->searchWhere) ->field('id,org_id,dept_id,project_id,cost_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_amount'] = ProjectCostBudgetDetail::where('cost_budget_id',$data['id'])->sum('amount'); return $data; }) ->toArray(); } /** * @notes 获取费用预算数量 * @return int * @author likeadmin * @date 2024/01/16 14:32 */ public function count(): int { return ProjectCostBudget::where($this->searchWhere)->count(); } public function setFileName(): string { return '费用预算列表'; } /** * @notes 导出字段 * @return string[] * @author 段誉 * @date 2022/11/24 16:17 */ public function setExcelFields(): array { return [ "id" => "id", "project_name" => "项目名称", "cost_budget_code" => "费用预算单号", "total_amount" => "金额", "remark" => "备注", ]; } }