57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\lists\approve;
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\Approve;
|
|
use app\common\model\auth\Admin;
|
|
use app\common\model\Company;
|
|
use think\facade\Db;
|
|
|
|
class ApproveLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return \string[][]
|
|
* @author likeadmin
|
|
* @date 2023/08/31 11:08
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
|
|
public function queryWhere()
|
|
{
|
|
$where = [];
|
|
// $where[] = ['check_admin_ids', '=', $this->adminId]; // todo 放开过滤条件,只有片区经理才能查看
|
|
return $where;
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
return Approve::where($this->searchWhere)
|
|
->where($this->queryWhere())
|
|
->with('task')
|
|
->field('*')
|
|
->append(['area_manager', 'company_name'], true)
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order(['id' => 'desc'])
|
|
->select()
|
|
->withAttr('area_manager',function($value,$data){
|
|
return Admin::where(['id' => $data['check_admin_ids']])->value('name');
|
|
})
|
|
->withAttr('company_name',function($value,$data){
|
|
return Company::where(['admin_id' => $data['check_admin_ids']])->value('company_name');
|
|
})
|
|
->toArray();
|
|
}
|
|
|
|
|
|
public function count(): int
|
|
{
|
|
return Approve::where($this->searchWhere)->count();
|
|
}
|
|
} |