<?php // +---------------------------------------------------------------------- // | likeadmin快速开发前后端分离管理后台(PHP版) // +---------------------------------------------------------------------- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力 // | 开源版本可自由商用,可去除界面版权logo // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin // | github下载:https://github.com/likeshop-github/likeadmin // | 访问官网:https://www.likeadmin.cn // | likeadmin团队 版权所有 拥有最终解释权 // +---------------------------------------------------------------------- // | author: likeadminTeam // +---------------------------------------------------------------------- namespace app\adminapi\lists\cost_project; use app\adminapi\lists\BaseAdminDataLists; use app\common\model\cost_project\CostProject; use app\common\lists\ListsSearchInterface; /** * 造价项目台账列表 * Class CostProjectLists * @package app\adminapi\listscost_project */ class CostProjectLists extends BaseAdminDataLists implements ListsSearchInterface { /** * @notes 设置搜索条件 * @return \string[][] * @author likeadmin * @date 2024/02/21 09:23 */ public function setSearch(): array { return [ '=' => ['cost_project_id'], '%like%' => ['superior_sort', 'name'], ]; } /** * @notes 获取造价项目台账列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/02/21 09:23 */ public function lists(): array { $task_allocation = $this->request->param('task_allocation', 0); // 筛选出关联了任务类别的项目 if ($task_allocation == 1) { return CostProject::alias('p') ->join('task_type t', 'p.id=t.cost_project_id') ->where($this->searchWhere) ->field('p.*') ->limit($this->limitOffset, $this->limitLength) ->with(['contract']) ->order(['id' => 'desc']) ->select() ->toArray(); } return CostProject::where($this->searchWhere) ->field(['id', 'project_num', 'project_name', 'contract_id', 'types', 'industry', 'province', 'city', 'address', 'starting', 'endtime', 'jhgq', 'depar', 'principal', 'person', 'invest', 'budget', 'cost', 'approval', 'aunit', 'Acontact', 'acontactnum', 'date', 'generalize', 'note', 'remark', 'annex']) ->limit($this->limitOffset, $this->limitLength) ->with(['contract']) ->order(['id' => 'desc']) ->select() ->toArray(); } /** * @notes 获取造价项目台账数量 * @return int * @author likeadmin * @date 2024/02/21 09:23 */ public function count(): int { $task_allocation = $this->request->param('task_allocation', 0); // 筛选出关联了任务类别的项目 if ($task_allocation == 1) { return CostProject::alias('p')->join('task_type t', 'p.id=t.cost_project_id')->where($this->searchWhere)->count(); } return CostProject::where($this->searchWhere)->count(); } }