100 lines
3.6 KiB
PHP
100 lines
3.6 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\supplier;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\supplier\Supplier;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use think\facade\Db;
|
||
|
||
/**
|
||
* Supplier列表
|
||
* Class SupplierLists
|
||
* @package app\adminapi\listssupplier
|
||
*/
|
||
class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/26 10:56
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['supplier_group', 'supplier_category', 'supplier_grade'],
|
||
'%like%' => ['supplier_code','supplier_name','contacts'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/26 10:56
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
$params = $this->request->get(['create_user_name']);
|
||
$where = [];
|
||
if(isset($params['create_user_name']) && $params['create_user_name'] != ''){
|
||
$create_user_ids = Admin::where('name','like','%'.$params['create_user_name'].'%')->column('id');
|
||
$where[] = ['create_user_id','in',$create_user_ids];
|
||
}
|
||
return Supplier::where($this->searchWhere)->where($where)
|
||
->field('id,create_user_id,supplier_code,supplier_name,brand_category,supplier_group,supplier_category,supplier_grade,contacts,contacts_sex,phone,remark')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$create_user = Admin::field('name')->where('id',$data['create_user_id'])->findOrEmpty();
|
||
$data['create_user_name'] = $create_user['name'];
|
||
$data['supplier_group'] = $data->supplier_group_text;
|
||
$data['supplier_category'] = $data->supplier_category_text;
|
||
$data['supplier_grade'] = $data->supplier_grade_text;
|
||
$data['contacts_sex'] = $data->contacts_sex_text;
|
||
unset($data['create_user_id']);
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/26 10:56
|
||
*/
|
||
public function count(): int
|
||
{
|
||
$params = $this->request->get(['create_user_name']);
|
||
$where = [];
|
||
if(isset($params['create_user_name']) && $params['create_user_name'] != ''){
|
||
$create_user_ids = Admin::where('name','like','%'.$params['create_user_name'].'%')->column('id');
|
||
$where[] = ['create_user_id','in',$create_user_ids];
|
||
}
|
||
return Supplier::field('id')->where($this->searchWhere)->where($where)->count();
|
||
}
|
||
|
||
} |