116 lines
4.4 KiB
PHP
116 lines
4.4 KiB
PHP
<?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\project;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectMember;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\project\ProjectRoleSet;
|
||
|
||
|
||
/**
|
||
* 项目成员列表
|
||
* Class ProjectMemberLists
|
||
* @package app\adminapi\listsproject
|
||
*/
|
||
class ProjectMemberLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取项目成员列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
//project_name project_role_name admin_name
|
||
$params = $this->request->param();
|
||
$where = [];
|
||
if(isset($params['project_name']) && $params['project_name'] != ''){
|
||
$projectIds = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
|
||
$where[] = ['project_id','in',$projectIds];
|
||
}
|
||
if(isset($params['project_role_name']) && $params['project_role_name'] != ''){
|
||
$projectRoleIds = ProjectRoleSet::where('name','like','%'.$params['project_role_name'].'%')->column('id');
|
||
$where[] = ['project_role_id','in',$projectRoleIds];
|
||
}
|
||
if(isset($params['admin_name']) && $params['admin_name'] != ''){
|
||
$adminIds = Admin::where('name','like','%'.$params['admin_name'].'%')->column('id');
|
||
$where[] = ['admin_id','in',$adminIds];
|
||
}
|
||
return ProjectMember::where($this->searchWhere)->where($where)
|
||
->field(['id', 'project_id', 'project_role_id', 'admin_id', 'working_unit_price', 'remark'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($item){
|
||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||
$role = ProjectRoleSet::field('name')->where('id',$item['project_role_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id',$item['admin_id'])->findOrEmpty();
|
||
$item['project_name'] = $project['name'];
|
||
$item['project_code'] = $project['project_code'];
|
||
$item['project_role_name'] = $role['name'];
|
||
$item['admin_name'] = $admin['name'];
|
||
return $item;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取项目成员数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/15 09:59
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->param();
|
||
$where = [];
|
||
if(isset($params['project_name']) && $params['project_name'] != ''){
|
||
$projectIds = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
|
||
$where[] = ['project_id','in',$projectIds];
|
||
}
|
||
if(isset($params['project_role_name']) && $params['project_role_name'] != ''){
|
||
$projectRoleIds = ProjectRoleSet::where('name','like','%'.$params['project_role_name'].'%')->column('id');
|
||
$where[] = ['project_role_id','in',$projectRoleIds];
|
||
}
|
||
if(isset($params['admin_name']) && $params['admin_name'] != ''){
|
||
$adminIds = Admin::where('name','like','%'.$params['admin_name'].'%')->column('id');
|
||
$where[] = ['admin_id','in',$adminIds];
|
||
}
|
||
return ProjectMember::where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |