<?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\contract; use app\adminapi\lists\BaseAdminDataLists; use app\common\model\contract\Contract; use app\common\lists\ListsSearchInterface; use think\facade\Db; /** * 项目合同列表 * Class ContractLists * @package app\adminapi\listscontract */ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface { /** * @notes 设置搜索条件 * @return \string[][] * @author likeadmin * @date 2023/12/02 17:19 */ public function setSearch(): array { return [ '=' => ['c.org_id', 'c.dept_id', 'c.customer_id', 'c.contract_name', 'c.contract_type', 'c.contract_code'], ]; } /** * @notes 获取项目合同列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/02 17:19 */ public function lists(): array { return Db::name('Contract')->alias('c') ->where($this->searchWhere) ->whereNull('c.delete_time') ->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id') ->leftJoin('orgs o','o.id = c.org_id') ->leftJoin('dept d','d.id = c.dept_id') ->leftJoin('project p','p.id = bbbd.project_id') ->leftJoin('custom ct','ct.id = c.customer_id') ->field('c.*, d.name as dept_name, o.name as org_name, bbbd.project_id, p.name as project_name, p.project_code, ct.name as customer_name') ->limit($this->limitOffset, $this->limitLength) ->order(['c.id' => 'desc']) ->select()->each(function($item, $key){ //关联数据后续添加 $item['approve_no'] = '付款单号'; $item['approve_step'] = '流程步骤'; $item['approve_settle_status'] = 1; return $item; }) ->toArray(); } /** * @notes 获取项目合同数量 * @return int * @author likeadmin * @date 2023/12/02 17:19 */ public function count(): int { return Db::name('Contract')->alias('c') ->where($this->searchWhere) ->whereNull('c.delete_time') ->leftJoin('bid_buy_bidding_document bbbd','c.id = c.buy_bidding_document_id') ->leftJoin('project p','p.id = bbbd.project_id') ->leftJoin('custom ct','ct.id = c.customer_id')->count(); } }