['cbd.org_id', 'cbd.dept_id', 'cbd.cost_subject_id', 'cbd.cost_budget_id'], ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/18 11:22 */ public function lists(): array { return Db::name('CostBudgetDetail')->alias('cbd') ->where($this->searchWhere) ->whereNull('cbd.delete_time') ->leftJoin('cost_subject cs','cs.id = cbd.cost_subject_id') ->leftJoin('cost_budget cb','cb.id = cbd.cost_budget_id') ->leftJoin('orgs o','o.id = cb.org_id') ->leftJoin('dept d','d.id = cb.dept_id') ->field('cbd.*, d.name as dept_name, o.name as org_name, cb.years, cs.sn, cs.subject1, cs.subject2') ->limit($this->limitOffset, $this->limitLength) ->order(['cbd.id' => 'desc']) ->select()->each(function($item, $key){ return $item; }) ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2023/12/18 11:22 */ public function count(): int { return Db::name('CostBudgetDetail')->alias('cbd') ->where($this->searchWhere) ->whereNull('cbd.delete_time') ->leftJoin('cost_subject cs','cs.id = cbd.cost_subject_id') ->leftJoin('cost_budget cb','cb.id = cbd.cost_budget_id') ->leftJoin('orgs o','o.id = cb.org_id') ->leftJoin('dept d','d.id = cb.dept_id')->count(); } }