diff --git a/app/adminapi/lists/cost/CostBudgetDetailLists.php b/app/adminapi/lists/cost/CostBudgetDetailLists.php index ec0cb08cd..5379e3dc2 100644 --- a/app/adminapi/lists/cost/CostBudgetDetailLists.php +++ b/app/adminapi/lists/cost/CostBudgetDetailLists.php @@ -18,7 +18,7 @@ namespace app\adminapi\lists\cost; use app\adminapi\lists\BaseAdminDataLists; use app\common\model\cost\CostBudgetDetail; use app\common\lists\ListsSearchInterface; - +use think\facade\Db; /** * CostBudgetDetail列表 @@ -38,7 +38,7 @@ class CostBudgetDetailLists extends BaseAdminDataLists implements ListsSearchInt public function setSearch(): array { return [ - '=' => ['cost_subject_id', 'cost_budget_id'], + '=' => ['cbd.org_id', 'cbd.dept_id', 'cbd.cost_subject_id', 'cbd.cost_budget_id'], ]; } @@ -54,15 +54,17 @@ class CostBudgetDetailLists extends BaseAdminDataLists implements ListsSearchInt */ public function lists(): array { - return CostBudgetDetail::where($this->searchWhere) - ->field(['id', 'cost_subject_id', 'cost_budget_id', 'dept_id', 'month1', 'month2', 'month3', 'month4', 'month5', 'month6', 'month7', 'month8', 'month9', 'month10', 'month11', 'month12']) + 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(['id' => 'desc']) + ->order(['cbd.id' => 'desc']) ->select()->each(function($item, $key){ - //关联数据后续添加 - $item['subject_no'] = '科目编号'; - $item['subject_first'] = '一级科目'; - $item['subject_second'] = '二级科目'; return $item; }) ->toArray(); @@ -77,7 +79,13 @@ class CostBudgetDetailLists extends BaseAdminDataLists implements ListsSearchInt */ public function count(): int { - return CostBudgetDetail::where($this->searchWhere)->count(); + 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(); } } \ No newline at end of file diff --git a/app/adminapi/lists/cost/CostBudgetLists.php b/app/adminapi/lists/cost/CostBudgetLists.php index 8f355430b..0c38b4303 100644 --- a/app/adminapi/lists/cost/CostBudgetLists.php +++ b/app/adminapi/lists/cost/CostBudgetLists.php @@ -63,7 +63,6 @@ class CostBudgetLists extends BaseAdminDataLists implements ListsSearchInterface ->limit($this->limitOffset, $this->limitLength) ->order(['cb.id' => 'desc']) ->select()->each(function($item, $key){ - $item['year'] = date('Y', strtotime($item['document_preparation_time'])); //关联数据后续添加 $item['approve_no'] = '付款单号'; $item['approve_step'] = '流程步骤';