['project_id', 'subpackage_budget_id'], ]; } /** * @notes 获取分包预算明细列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/01/10 15:19 */ public function lists(): array { return ProjectSubpackageBudgetDetail::where($this->searchWhere) ->field('id,project_id,subpackage_budget_id,work_type,work_content,project_features,unit,num,price,amount,remark') ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $subpackage_budget = ProjectSubpackageBudget::field('subpackage_budget_code')->where('id',$data['subpackage_budget_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['subpackage_budget_code'] = $subpackage_budget['subpackage_budget_code']; //已分包工作量 $data['has_subcontract_num'] = 0; //剩余工作量 $data['residue_num'] = $data['num'] - $data['has_subcontract_num']; return $data; }) ->toArray(); } /** * @notes 获取分包预算明细数量 * @return int * @author likeadmin * @date 2024/01/10 15:19 */ public function count(): int { return ProjectSubpackageBudgetDetail::where($this->searchWhere)->count(); } }